@oiyo/framework 0.4.9 → 0.5.0
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-DpCCifZz.d.cts → index-BGIDoS5A.d.cts} +162 -122
- package/dist/{index-DpCCifZz.d.mts → index-BGIDoS5A.d.mts} +162 -122
- package/dist/index.cjs +2 -26
- package/dist/index.d.cts +3 -3
- package/dist/index.d.mts +3 -3
- package/dist/index.mjs +2 -7
- package/dist/oiyo-C5uDbL0e.mjs +7 -0
- package/dist/oiyo-Cd_IUg_L.cjs +7 -0
- package/dist/oiyo.cjs +2 -6
- package/dist/oiyo.d.cts +3 -3
- package/dist/oiyo.d.mts +3 -3
- package/dist/oiyo.mjs +2 -3
- package/dist/uni.cjs +2 -11
- package/dist/uni.d.cts +1 -1
- package/dist/uni.d.mts +1 -1
- package/dist/uni.mjs +2 -3
- package/dist/vue.cjs +2 -11
- package/dist/vue.d.cts +1 -1
- package/dist/vue.d.mts +1 -1
- package/dist/vue.mjs +2 -3
- package/package.json +1 -1
- package/dist/oiyo-BXNGL_oa.mjs +0 -7
- package/dist/oiyo-CUAtDW_Y.cjs +0 -7
|
@@ -1,13 +1,36 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* @oiyo/framework v0.
|
|
2
|
+
* @oiyo/framework v0.5.0
|
|
3
3
|
* Copyright (c) 2026 skiyee. All rights reserved.
|
|
4
4
|
* Commercial software. See LICENSE for terms.
|
|
5
5
|
* Official site: https://oiyo.js.org
|
|
6
6
|
*/
|
|
7
|
+
//#region src/oiyo/http/utils/emitter.d.ts
|
|
8
|
+
type EmitterListener = (...arg: unknown[]) => void;
|
|
9
|
+
declare abstract class Emitter {
|
|
10
|
+
private listeners;
|
|
11
|
+
constructor();
|
|
12
|
+
on(id: string, listener: EmitterListener): void;
|
|
13
|
+
off(id: string, listener: EmitterListener): void;
|
|
14
|
+
protected emit(id: string, ...args: unknown[]): void;
|
|
15
|
+
remove(id: string): void;
|
|
16
|
+
}
|
|
17
|
+
//#endregion
|
|
7
18
|
//#region src/oiyo/http/abort.d.ts
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
19
|
+
type OnabortListener = () => void;
|
|
20
|
+
declare class HttpAbortSignal extends Emitter {
|
|
21
|
+
protected _aborted: boolean;
|
|
22
|
+
protected _reason: unknown;
|
|
23
|
+
protected _onabortListener: OnabortListener | null;
|
|
24
|
+
get aborted(): boolean;
|
|
25
|
+
get reason(): unknown;
|
|
26
|
+
protected _abort(reason: unknown): void;
|
|
27
|
+
throwIfAborted(): void;
|
|
28
|
+
}
|
|
29
|
+
declare class HttpAborter {
|
|
30
|
+
private readonly _signal;
|
|
31
|
+
constructor();
|
|
32
|
+
get signal(): HttpAbortSignal;
|
|
33
|
+
abort(reason?: unknown): void;
|
|
11
34
|
}
|
|
12
35
|
/**
|
|
13
36
|
* 创建一个中断信标。
|
|
@@ -18,30 +41,6 @@ interface HttpAborter {
|
|
|
18
41
|
* aborter.abort()
|
|
19
42
|
*/
|
|
20
43
|
declare function createHttpAborter(): HttpAborter;
|
|
21
|
-
type AbortListener = (this: HttpAbortSignal, event: {
|
|
22
|
-
type: 'abort';
|
|
23
|
-
}) => void;
|
|
24
|
-
declare class AbortEmitter {
|
|
25
|
-
private listeners;
|
|
26
|
-
addEventListener(type: 'abort', listener: AbortListener): void;
|
|
27
|
-
removeEventListener(type: 'abort', listener: AbortListener): void;
|
|
28
|
-
protected emit(event: {
|
|
29
|
-
type: 'abort';
|
|
30
|
-
}): void;
|
|
31
|
-
}
|
|
32
|
-
declare class HttpAbortSignal extends AbortEmitter {
|
|
33
|
-
aborted: boolean;
|
|
34
|
-
reason: any;
|
|
35
|
-
onabort: AbortListener | null;
|
|
36
|
-
/**
|
|
37
|
-
* 内部使用:标记中断并派发 `abort` 事件(幂等)。
|
|
38
|
-
*/
|
|
39
|
-
_abort(reason?: any): void;
|
|
40
|
-
/**
|
|
41
|
-
* 已中断则抛出 `reason`,否则什么都不做。
|
|
42
|
-
*/
|
|
43
|
-
throwIfAborted(): void;
|
|
44
|
-
}
|
|
45
44
|
//#endregion
|
|
46
45
|
//#region src/oiyo/http/types/utils.d.ts
|
|
47
46
|
type Prettify<T> = { [K in keyof T]: T[K]; } & {};
|
|
@@ -56,44 +55,58 @@ type ResponseBodyType = Prettify<keyof ResponseBodyTypeMap | 'json'>;
|
|
|
56
55
|
type MappedResponseBodyType<TRBType extends ResponseBodyType, TRBJsonType = any> = TRBType extends keyof ResponseBodyTypeMap ? ResponseBodyTypeMap[TRBType] : TRBJsonType;
|
|
57
56
|
//#endregion
|
|
58
57
|
//#region src/oiyo/http/types/uni.d.ts
|
|
58
|
+
interface UniAppOnHeadersData {
|
|
59
|
+
header: Record<string, string>;
|
|
60
|
+
}
|
|
59
61
|
type UniAppRequestOptions = Omit<UniNamespace.RequestOptions, 'url' | 'data' | 'header' | 'method' | 'timeout' | 'responseType' | 'success' | 'fail' | 'complete'>;
|
|
60
|
-
interface
|
|
62
|
+
interface UniAppRequestChunkData {
|
|
61
63
|
data: ArrayBuffer;
|
|
62
64
|
}
|
|
63
65
|
type UniAppRequestResponse<TRBody = any> = Prettify<Omit<UniNamespace.RequestSuccessCallbackResult, 'data'> & {
|
|
64
66
|
data: TRBody;
|
|
65
67
|
}>;
|
|
66
68
|
type UniAppUploadOptions = Omit<UniNamespace.UploadFileOption, 'url' | 'header' | 'formData' | 'timeout' | 'success' | 'fail' | 'complete'>;
|
|
67
|
-
interface
|
|
69
|
+
interface UniAppUploadOnProgressData extends UniNamespace.OnProgressUpdateResult {}
|
|
68
70
|
type UniAppUploadResponse<TRBody = any> = Prettify<Omit<UniNamespace.UploadFileSuccessCallbackResult, 'data'> & {
|
|
69
71
|
data: TRBody;
|
|
70
72
|
}>;
|
|
71
73
|
type UniAppDownloadBodyType = 'json';
|
|
72
74
|
type UniAppDownloadBody = Prettify<Pick<UniNamespace.DownloadSuccessData, 'tempFilePath'>>;
|
|
73
75
|
type UniAppDownloadOptions = Omit<UniNamespace.DownloadFileOption, 'url' | 'header' | 'timeout' | 'success' | 'fail' | 'complete'>;
|
|
74
|
-
interface
|
|
76
|
+
interface UniAppDownloadOnProgressData extends UniNamespace.OnProgressDownloadResult {}
|
|
75
77
|
type UniAppDownloadResponse<TRBody = any> = Prettify<Omit<UniNamespace.DownloadSuccessData, keyof UniAppDownloadBody> & {
|
|
76
78
|
data: TRBody;
|
|
77
79
|
}>;
|
|
78
80
|
//#endregion
|
|
81
|
+
//#region src/oiyo/http/types/response.d.ts
|
|
82
|
+
type HttpRequestResult<TRBody = any, TRBType extends ResponseBodyType = ResponseBodyType> = MappedResponseBodyType<TRBType, TRBody>;
|
|
83
|
+
type HttpUploadResult<TRBody = any, TRBType extends ResponseBodyType = ResponseBodyType> = MappedResponseBodyType<TRBType, TRBody>;
|
|
84
|
+
type HttpDownloadResult<TRBody extends UniAppDownloadBody = UniAppDownloadBody, TRBType extends UniAppDownloadBodyType = 'json'> = MappedResponseBodyType<TRBType, TRBody>;
|
|
85
|
+
type HttpRequestResponse<TRBody = any, TRBType extends ResponseBodyType = ResponseBodyType> = UniAppRequestResponse<MappedResponseBodyType<TRBType, TRBody>>;
|
|
86
|
+
type HttpUploadResponse<TRBody = any, TRBType extends ResponseBodyType = ResponseBodyType> = UniAppUploadResponse<MappedResponseBodyType<TRBType, TRBody>>;
|
|
87
|
+
type HttpDownloadResponse<TRBody extends UniAppDownloadBody = UniAppDownloadBody, TRBType extends UniAppDownloadBodyType = 'json'> = UniAppDownloadResponse<MappedResponseBodyType<TRBType, TRBody>>;
|
|
88
|
+
type HttpResponse<T = any> = HttpRequestResponse<T> | HttpUploadResponse<T> | HttpDownloadResponse;
|
|
89
|
+
//#endregion
|
|
79
90
|
//#region src/oiyo/http/types/options.d.ts
|
|
80
|
-
/**
|
|
81
|
-
* 响应头监听回调入参。
|
|
82
|
-
*/
|
|
83
|
-
interface HeadersReceived {
|
|
84
|
-
header: Record<string, string>;
|
|
85
|
-
}
|
|
86
91
|
/**
|
|
87
92
|
* 所有传输方式共享的基础选项。
|
|
88
93
|
*/
|
|
89
94
|
interface HttpCommonOptions<TRBType extends ResponseBodyType = ResponseBodyType> {
|
|
95
|
+
/**
|
|
96
|
+
* 传输动作
|
|
97
|
+
* @description 常用于钩子中
|
|
98
|
+
* @protected
|
|
99
|
+
*/
|
|
100
|
+
_action?: 'request' | 'upload' | 'download';
|
|
101
|
+
/** 与相对 url 进行拼接的基础地址 */
|
|
90
102
|
baseURL?: string;
|
|
91
103
|
method?: 'GET' | 'POST' | 'PUT' | 'DELETE' | 'HEAD' | 'OPTIONS' | 'TRACE' | 'CONNECT';
|
|
104
|
+
/** 传输过程中所需的请求头 */
|
|
92
105
|
headers?: Record<string, string>;
|
|
106
|
+
/** 与完整传输地址进行拼接的查询参数 */
|
|
93
107
|
query?: Record<string, any>;
|
|
94
108
|
body?: any;
|
|
95
109
|
timeout?: number;
|
|
96
|
-
_action?: 'request' | 'upload' | 'download';
|
|
97
110
|
/**
|
|
98
111
|
* 为 true 时返回完整响应对象(statusCode / header / data ...),
|
|
99
112
|
* 否则只返回精炼后的 data。
|
|
@@ -101,14 +114,26 @@ interface HttpCommonOptions<TRBType extends ResponseBodyType = ResponseBodyType>
|
|
|
101
114
|
raw?: boolean;
|
|
102
115
|
responseType?: TRBType;
|
|
103
116
|
parseResponse?: (responseText: string) => any;
|
|
104
|
-
retry?: number | false;
|
|
105
|
-
retryDelay?: number;
|
|
106
117
|
/**
|
|
107
118
|
* 重试的响应状态码
|
|
108
119
|
* @default [408, 409, 425, 429, 500, 502, 503, 504]
|
|
109
120
|
*/
|
|
110
121
|
retryStatusCodes?: number[];
|
|
111
|
-
|
|
122
|
+
/**
|
|
123
|
+
* 是否基于重试响应状态码进行重试
|
|
124
|
+
* @default 1
|
|
125
|
+
*/
|
|
126
|
+
retry?: number | false;
|
|
127
|
+
/**
|
|
128
|
+
* 重试延迟时间,单位 ms
|
|
129
|
+
* @default 0
|
|
130
|
+
*/
|
|
131
|
+
retryDelay?: number;
|
|
132
|
+
/**
|
|
133
|
+
* 判定响应是否走 `onResponseSuccess`;未通过则走 `onResponseError` 并 reject。
|
|
134
|
+
* @default (status) => status >= 200 && status < 300
|
|
135
|
+
*/
|
|
136
|
+
validateStatus?: (status: number) => boolean;
|
|
112
137
|
/**
|
|
113
138
|
* 中断信号,由 `createHttpAborter()` 创建。
|
|
114
139
|
* 信号触发后传输会被中断;已中断的信号会让传输立即中断。
|
|
@@ -117,61 +142,46 @@ interface HttpCommonOptions<TRBType extends ResponseBodyType = ResponseBodyType>
|
|
|
117
142
|
/**
|
|
118
143
|
* 监听响应头(对应 task.onHeadersReceived)。
|
|
119
144
|
*/
|
|
120
|
-
|
|
145
|
+
onHeaders?: (data: UniAppOnHeadersData, off: () => void) => void;
|
|
121
146
|
}
|
|
122
147
|
interface HttpRequestOptions<TRBType extends ResponseBodyType = ResponseBodyType> extends HttpCommonOptions<TRBType>, UniAppRequestOptions {
|
|
123
|
-
/**
|
|
124
|
-
* 传输动作
|
|
125
|
-
* @description 常用于钩子中
|
|
126
|
-
* @protected
|
|
127
|
-
*/
|
|
128
148
|
_action?: 'request';
|
|
129
149
|
/**
|
|
130
|
-
*
|
|
131
|
-
* @default - '
|
|
150
|
+
* 传输方法
|
|
151
|
+
* @default - 'GET'
|
|
132
152
|
*/
|
|
133
153
|
method?: 'GET' | 'POST' | 'PUT' | 'DELETE' | 'HEAD' | 'OPTIONS' | 'TRACE' | 'CONNECT';
|
|
134
154
|
/**
|
|
135
|
-
*
|
|
136
|
-
* @description
|
|
155
|
+
* 监听流式数据,对应原生 task.onChunkReceived
|
|
156
|
+
* @description 调用 `off()` 将关闭流式数据监听
|
|
137
157
|
*/
|
|
138
|
-
onChunk?: (data:
|
|
158
|
+
onChunk?: (data: UniAppRequestChunkData, off: () => void) => void;
|
|
139
159
|
}
|
|
140
160
|
interface HttpUploadOptions<TRBType extends ResponseBodyType = ResponseBodyType> extends HttpCommonOptions<TRBType>, UniAppUploadOptions {
|
|
141
|
-
/**
|
|
142
|
-
* 传输动作
|
|
143
|
-
* @description 常用于钩子中
|
|
144
|
-
* @protected
|
|
145
|
-
*/
|
|
146
161
|
_action?: 'upload';
|
|
147
162
|
/**
|
|
148
|
-
*
|
|
163
|
+
* 传输方法,强制 POST
|
|
149
164
|
* @default - 'POST'
|
|
150
165
|
*/
|
|
151
166
|
method?: 'POST';
|
|
152
167
|
/**
|
|
153
|
-
*
|
|
154
|
-
* @description
|
|
168
|
+
* 监听上传进度,对应原生 task.onProgressUpdate
|
|
169
|
+
* @description 调用 `off()` 将关闭上传进度监听
|
|
155
170
|
*/
|
|
156
|
-
onProgress?: (data:
|
|
171
|
+
onProgress?: (data: UniAppUploadOnProgressData, off: () => void) => void;
|
|
157
172
|
}
|
|
158
173
|
interface HttpDownloadOptions<TRBType extends UniAppDownloadBodyType = 'json'> extends HttpCommonOptions<TRBType>, UniAppDownloadOptions {
|
|
159
|
-
/**
|
|
160
|
-
* 传输动作
|
|
161
|
-
* @description 常用于钩子中
|
|
162
|
-
* @protected
|
|
163
|
-
*/
|
|
164
174
|
_action?: 'download';
|
|
165
175
|
/**
|
|
166
|
-
*
|
|
176
|
+
* 传输方法,强制 GET
|
|
167
177
|
* @default - 'GET'
|
|
168
178
|
*/
|
|
169
179
|
method?: 'GET';
|
|
170
180
|
/**
|
|
171
|
-
*
|
|
172
|
-
* @description
|
|
181
|
+
* 监听下载进度,对应原生 task.onProgressUpdate
|
|
182
|
+
* @description 调用 `off()` 将关闭下载进度监听
|
|
173
183
|
*/
|
|
174
|
-
onProgress?: (data:
|
|
184
|
+
onProgress?: (data: UniAppDownloadOnProgressData, off: () => void) => void;
|
|
175
185
|
}
|
|
176
186
|
/**
|
|
177
187
|
* 传输地址
|
|
@@ -180,70 +190,78 @@ type HttpURL = string;
|
|
|
180
190
|
/**
|
|
181
191
|
* 传输属性
|
|
182
192
|
*/
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
+
type HttpOptions = HttpRequestOptions | HttpUploadOptions | HttpDownloadOptions;
|
|
194
|
+
/**
|
|
195
|
+
* 传输拦截器
|
|
196
|
+
*/
|
|
197
|
+
interface HttpHooks<TOptions, TResponse> {
|
|
198
|
+
/**
|
|
199
|
+
* 请求前置拦截器
|
|
200
|
+
* - 传输状态: 发起失败
|
|
201
|
+
* - 触发条件: 网络发出前
|
|
202
|
+
* - 接受返回值: options、void、Error
|
|
203
|
+
*/
|
|
204
|
+
onBeforeRequest?: (context: {
|
|
205
|
+
url: HttpURL;
|
|
206
|
+
options: TOptions;
|
|
207
|
+
}) => MaybePromise<TOptions | void>;
|
|
208
|
+
/**
|
|
209
|
+
* 请求错误拦截器
|
|
210
|
+
* - 传输状态: 发起失败
|
|
211
|
+
* - 触发条件: 发前抛错、传输 fail、主动 abort 等
|
|
212
|
+
* - Error类: HttpError、Error...
|
|
213
|
+
* - 接受返回值: any (抛出的值将由调用方所接受)
|
|
214
|
+
*/
|
|
215
|
+
onRequestError?: (context: {
|
|
216
|
+
error: Error;
|
|
217
|
+
url: HttpURL;
|
|
218
|
+
options: TOptions;
|
|
219
|
+
}) => MaybePromise<unknown>;
|
|
220
|
+
/**
|
|
221
|
+
* 响应成功拦截器
|
|
222
|
+
* - 传输状态: 已响应
|
|
223
|
+
* - 触发条件: `validateStatus` 通过(默认 2xx)
|
|
224
|
+
* - 接受返回值: 原响应值结构 (HttpResponse)、void
|
|
225
|
+
*/
|
|
226
|
+
onResponseSuccess?: (context: {
|
|
227
|
+
response: TResponse;
|
|
228
|
+
url: HttpURL;
|
|
229
|
+
options: TOptions;
|
|
230
|
+
}) => MaybePromise<TResponse | void>;
|
|
231
|
+
/**
|
|
232
|
+
* 响应错误拦截器
|
|
233
|
+
* - 传输状态: 已响应
|
|
234
|
+
* - 触发条件: `validateStatus` 未通过
|
|
235
|
+
* - Error类: HttpError、Error
|
|
236
|
+
* - 接受返回值: any (抛出的值将由调用方所接受)
|
|
237
|
+
*/
|
|
238
|
+
onResponseError?: (context: {
|
|
239
|
+
error: Error;
|
|
240
|
+
response: TResponse;
|
|
241
|
+
url: HttpURL;
|
|
242
|
+
options: TOptions;
|
|
243
|
+
}) => MaybePromise<unknown>;
|
|
244
|
+
}
|
|
245
|
+
interface HttpConfig extends HttpCommonOptions, HttpHooks<HttpOptions, HttpResponse> {}
|
|
193
246
|
//#endregion
|
|
194
247
|
//#region src/oiyo/http/types/core.d.ts
|
|
195
248
|
interface HttpRequest {
|
|
196
|
-
<TRBody = any, TRBType extends ResponseBodyType = 'json'>(
|
|
249
|
+
<TRBody = any, TRBType extends ResponseBodyType = 'json'>(url: HttpURL, options: HttpRequestOptions<TRBType> & {
|
|
197
250
|
raw: true;
|
|
198
251
|
}): Promise<HttpRequestResponse<TRBody, TRBType>>;
|
|
199
|
-
<TRBody = any, TRBType extends ResponseBodyType = 'json'>(
|
|
252
|
+
<TRBody = any, TRBType extends ResponseBodyType = 'json'>(url: HttpURL, options?: HttpRequestOptions<TRBType>): Promise<HttpRequestResult<TRBody, TRBType>>;
|
|
200
253
|
}
|
|
201
254
|
interface HttpUpload {
|
|
202
|
-
<TRBody = any, TRBType extends ResponseBodyType = 'json'>(
|
|
255
|
+
<TRBody = any, TRBType extends ResponseBodyType = 'json'>(url: HttpURL, options: HttpUploadOptions<TRBType> & {
|
|
203
256
|
raw: true;
|
|
204
257
|
}): Promise<HttpUploadResponse<TRBody, TRBType>>;
|
|
205
|
-
<TRBody = any, TRBType extends ResponseBodyType = 'json'>(
|
|
258
|
+
<TRBody = any, TRBType extends ResponseBodyType = 'json'>(url: HttpURL, options?: HttpUploadOptions<TRBType>): Promise<HttpUploadResult<TRBody, TRBType>>;
|
|
206
259
|
}
|
|
207
260
|
interface HttpDownload {
|
|
208
|
-
<TRBody extends UniAppDownloadBody = UniAppDownloadBody, TRBType extends UniAppDownloadBodyType = UniAppDownloadBodyType>(
|
|
261
|
+
<TRBody extends UniAppDownloadBody = UniAppDownloadBody, TRBType extends UniAppDownloadBodyType = UniAppDownloadBodyType>(url: HttpURL, options: HttpDownloadOptions<TRBType> & {
|
|
209
262
|
raw: true;
|
|
210
263
|
}): Promise<HttpDownloadResponse<TRBody, TRBType>>;
|
|
211
|
-
<TRBody extends UniAppDownloadBody = UniAppDownloadBody, TRBType extends UniAppDownloadBodyType = UniAppDownloadBodyType>(
|
|
212
|
-
}
|
|
213
|
-
type HttpHookContextOptions = HttpRequestOptions & {
|
|
214
|
-
_action: 'request';
|
|
215
|
-
} | HttpUploadOptions & {
|
|
216
|
-
_action: 'upload';
|
|
217
|
-
} | HttpDownloadOptions & {
|
|
218
|
-
_action: 'download';
|
|
219
|
-
};
|
|
220
|
-
interface HttpHooks<TContextOptions, TResponse> {
|
|
221
|
-
onRequest?: (context: {
|
|
222
|
-
resource: HttpURL;
|
|
223
|
-
options: TContextOptions;
|
|
224
|
-
}) => MaybePromise<void>;
|
|
225
|
-
onRequestError?: (context: {
|
|
226
|
-
resource: HttpURL;
|
|
227
|
-
options: TContextOptions;
|
|
228
|
-
error: Error;
|
|
229
|
-
}) => MaybePromise<void>;
|
|
230
|
-
onResponse?: (context: {
|
|
231
|
-
resource: HttpURL;
|
|
232
|
-
options: TContextOptions;
|
|
233
|
-
response: TResponse;
|
|
234
|
-
}) => MaybePromise<void>;
|
|
235
|
-
onResponseError?: (context: {
|
|
236
|
-
resource: HttpURL;
|
|
237
|
-
options: TContextOptions;
|
|
238
|
-
response: TResponse;
|
|
239
|
-
}) => MaybePromise<void>;
|
|
240
|
-
}
|
|
241
|
-
interface HttpConfig extends HttpCommonOptions, HttpHooks<HttpHookContextOptions, HttpResponse> {}
|
|
242
|
-
interface HttpError<T = any> extends Error {
|
|
243
|
-
resource?: HttpURL;
|
|
244
|
-
options?: HttpOptions;
|
|
245
|
-
response?: HttpResponse<T>;
|
|
246
|
-
data: T;
|
|
264
|
+
<TRBody extends UniAppDownloadBody = UniAppDownloadBody, TRBType extends UniAppDownloadBodyType = UniAppDownloadBodyType>(url: HttpURL, options?: HttpDownloadOptions<TRBType>): Promise<HttpDownloadResult<TRBody, TRBType>>;
|
|
247
265
|
}
|
|
248
266
|
//#endregion
|
|
249
267
|
//#region src/oiyo/http/core.d.ts
|
|
@@ -319,4 +337,26 @@ declare function createHttp(globalConfig?: HttpConfig): Http;
|
|
|
319
337
|
*/
|
|
320
338
|
declare const http: Http;
|
|
321
339
|
//#endregion
|
|
322
|
-
|
|
340
|
+
//#region src/oiyo/http/error.d.ts
|
|
341
|
+
declare class HttpError<TB = any> extends Error {
|
|
342
|
+
/** 调用方在传输过程中主动中止 */
|
|
343
|
+
static readonly ABORT = "ABORT";
|
|
344
|
+
/** 调用方无法发起传输行为:网络错误、跨域、超时等 */
|
|
345
|
+
static readonly FAIL = "FAIL";
|
|
346
|
+
/** 响应的 HTTP 状态码未通过 `validateStatus`(默认非 2xx) */
|
|
347
|
+
static readonly STATUS = "STATUS";
|
|
348
|
+
readonly url?: HttpURL;
|
|
349
|
+
readonly options?: HttpOptions;
|
|
350
|
+
readonly response?: HttpResponse<TB>;
|
|
351
|
+
readonly statusCode?: number;
|
|
352
|
+
readonly statusMessage?: string;
|
|
353
|
+
readonly data?: TB;
|
|
354
|
+
constructor(options: {
|
|
355
|
+
name: string;
|
|
356
|
+
message: string;
|
|
357
|
+
cause?: unknown;
|
|
358
|
+
});
|
|
359
|
+
}
|
|
360
|
+
declare function isHttpError(error: unknown): error is HttpError;
|
|
361
|
+
//#endregion
|
|
362
|
+
export { HttpCommonOptions as a, HttpOptions as c, HttpDownloadResponse as d, HttpRequestResponse as f, createHttpAborter as g, ResponseBodyType as h, http as i, HttpRequestOptions as l, HttpUploadResponse as m, isHttpError as n, HttpConfig as o, HttpResponse as p, createHttp as r, HttpDownloadOptions as s, HttpError as t, HttpUploadOptions as u };
|
|
@@ -1,13 +1,36 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* @oiyo/framework v0.
|
|
2
|
+
* @oiyo/framework v0.5.0
|
|
3
3
|
* Copyright (c) 2026 skiyee. All rights reserved.
|
|
4
4
|
* Commercial software. See LICENSE for terms.
|
|
5
5
|
* Official site: https://oiyo.js.org
|
|
6
6
|
*/
|
|
7
|
+
//#region src/oiyo/http/utils/emitter.d.ts
|
|
8
|
+
type EmitterListener = (...arg: unknown[]) => void;
|
|
9
|
+
declare abstract class Emitter {
|
|
10
|
+
private listeners;
|
|
11
|
+
constructor();
|
|
12
|
+
on(id: string, listener: EmitterListener): void;
|
|
13
|
+
off(id: string, listener: EmitterListener): void;
|
|
14
|
+
protected emit(id: string, ...args: unknown[]): void;
|
|
15
|
+
remove(id: string): void;
|
|
16
|
+
}
|
|
17
|
+
//#endregion
|
|
7
18
|
//#region src/oiyo/http/abort.d.ts
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
19
|
+
type OnabortListener = () => void;
|
|
20
|
+
declare class HttpAbortSignal extends Emitter {
|
|
21
|
+
protected _aborted: boolean;
|
|
22
|
+
protected _reason: unknown;
|
|
23
|
+
protected _onabortListener: OnabortListener | null;
|
|
24
|
+
get aborted(): boolean;
|
|
25
|
+
get reason(): unknown;
|
|
26
|
+
protected _abort(reason: unknown): void;
|
|
27
|
+
throwIfAborted(): void;
|
|
28
|
+
}
|
|
29
|
+
declare class HttpAborter {
|
|
30
|
+
private readonly _signal;
|
|
31
|
+
constructor();
|
|
32
|
+
get signal(): HttpAbortSignal;
|
|
33
|
+
abort(reason?: unknown): void;
|
|
11
34
|
}
|
|
12
35
|
/**
|
|
13
36
|
* 创建一个中断信标。
|
|
@@ -18,30 +41,6 @@ interface HttpAborter {
|
|
|
18
41
|
* aborter.abort()
|
|
19
42
|
*/
|
|
20
43
|
declare function createHttpAborter(): HttpAborter;
|
|
21
|
-
type AbortListener = (this: HttpAbortSignal, event: {
|
|
22
|
-
type: 'abort';
|
|
23
|
-
}) => void;
|
|
24
|
-
declare class AbortEmitter {
|
|
25
|
-
private listeners;
|
|
26
|
-
addEventListener(type: 'abort', listener: AbortListener): void;
|
|
27
|
-
removeEventListener(type: 'abort', listener: AbortListener): void;
|
|
28
|
-
protected emit(event: {
|
|
29
|
-
type: 'abort';
|
|
30
|
-
}): void;
|
|
31
|
-
}
|
|
32
|
-
declare class HttpAbortSignal extends AbortEmitter {
|
|
33
|
-
aborted: boolean;
|
|
34
|
-
reason: any;
|
|
35
|
-
onabort: AbortListener | null;
|
|
36
|
-
/**
|
|
37
|
-
* 内部使用:标记中断并派发 `abort` 事件(幂等)。
|
|
38
|
-
*/
|
|
39
|
-
_abort(reason?: any): void;
|
|
40
|
-
/**
|
|
41
|
-
* 已中断则抛出 `reason`,否则什么都不做。
|
|
42
|
-
*/
|
|
43
|
-
throwIfAborted(): void;
|
|
44
|
-
}
|
|
45
44
|
//#endregion
|
|
46
45
|
//#region src/oiyo/http/types/utils.d.ts
|
|
47
46
|
type Prettify<T> = { [K in keyof T]: T[K]; } & {};
|
|
@@ -56,44 +55,58 @@ type ResponseBodyType = Prettify<keyof ResponseBodyTypeMap | 'json'>;
|
|
|
56
55
|
type MappedResponseBodyType<TRBType extends ResponseBodyType, TRBJsonType = any> = TRBType extends keyof ResponseBodyTypeMap ? ResponseBodyTypeMap[TRBType] : TRBJsonType;
|
|
57
56
|
//#endregion
|
|
58
57
|
//#region src/oiyo/http/types/uni.d.ts
|
|
58
|
+
interface UniAppOnHeadersData {
|
|
59
|
+
header: Record<string, string>;
|
|
60
|
+
}
|
|
59
61
|
type UniAppRequestOptions = Omit<UniNamespace.RequestOptions, 'url' | 'data' | 'header' | 'method' | 'timeout' | 'responseType' | 'success' | 'fail' | 'complete'>;
|
|
60
|
-
interface
|
|
62
|
+
interface UniAppRequestChunkData {
|
|
61
63
|
data: ArrayBuffer;
|
|
62
64
|
}
|
|
63
65
|
type UniAppRequestResponse<TRBody = any> = Prettify<Omit<UniNamespace.RequestSuccessCallbackResult, 'data'> & {
|
|
64
66
|
data: TRBody;
|
|
65
67
|
}>;
|
|
66
68
|
type UniAppUploadOptions = Omit<UniNamespace.UploadFileOption, 'url' | 'header' | 'formData' | 'timeout' | 'success' | 'fail' | 'complete'>;
|
|
67
|
-
interface
|
|
69
|
+
interface UniAppUploadOnProgressData extends UniNamespace.OnProgressUpdateResult {}
|
|
68
70
|
type UniAppUploadResponse<TRBody = any> = Prettify<Omit<UniNamespace.UploadFileSuccessCallbackResult, 'data'> & {
|
|
69
71
|
data: TRBody;
|
|
70
72
|
}>;
|
|
71
73
|
type UniAppDownloadBodyType = 'json';
|
|
72
74
|
type UniAppDownloadBody = Prettify<Pick<UniNamespace.DownloadSuccessData, 'tempFilePath'>>;
|
|
73
75
|
type UniAppDownloadOptions = Omit<UniNamespace.DownloadFileOption, 'url' | 'header' | 'timeout' | 'success' | 'fail' | 'complete'>;
|
|
74
|
-
interface
|
|
76
|
+
interface UniAppDownloadOnProgressData extends UniNamespace.OnProgressDownloadResult {}
|
|
75
77
|
type UniAppDownloadResponse<TRBody = any> = Prettify<Omit<UniNamespace.DownloadSuccessData, keyof UniAppDownloadBody> & {
|
|
76
78
|
data: TRBody;
|
|
77
79
|
}>;
|
|
78
80
|
//#endregion
|
|
81
|
+
//#region src/oiyo/http/types/response.d.ts
|
|
82
|
+
type HttpRequestResult<TRBody = any, TRBType extends ResponseBodyType = ResponseBodyType> = MappedResponseBodyType<TRBType, TRBody>;
|
|
83
|
+
type HttpUploadResult<TRBody = any, TRBType extends ResponseBodyType = ResponseBodyType> = MappedResponseBodyType<TRBType, TRBody>;
|
|
84
|
+
type HttpDownloadResult<TRBody extends UniAppDownloadBody = UniAppDownloadBody, TRBType extends UniAppDownloadBodyType = 'json'> = MappedResponseBodyType<TRBType, TRBody>;
|
|
85
|
+
type HttpRequestResponse<TRBody = any, TRBType extends ResponseBodyType = ResponseBodyType> = UniAppRequestResponse<MappedResponseBodyType<TRBType, TRBody>>;
|
|
86
|
+
type HttpUploadResponse<TRBody = any, TRBType extends ResponseBodyType = ResponseBodyType> = UniAppUploadResponse<MappedResponseBodyType<TRBType, TRBody>>;
|
|
87
|
+
type HttpDownloadResponse<TRBody extends UniAppDownloadBody = UniAppDownloadBody, TRBType extends UniAppDownloadBodyType = 'json'> = UniAppDownloadResponse<MappedResponseBodyType<TRBType, TRBody>>;
|
|
88
|
+
type HttpResponse<T = any> = HttpRequestResponse<T> | HttpUploadResponse<T> | HttpDownloadResponse;
|
|
89
|
+
//#endregion
|
|
79
90
|
//#region src/oiyo/http/types/options.d.ts
|
|
80
|
-
/**
|
|
81
|
-
* 响应头监听回调入参。
|
|
82
|
-
*/
|
|
83
|
-
interface HeadersReceived {
|
|
84
|
-
header: Record<string, string>;
|
|
85
|
-
}
|
|
86
91
|
/**
|
|
87
92
|
* 所有传输方式共享的基础选项。
|
|
88
93
|
*/
|
|
89
94
|
interface HttpCommonOptions<TRBType extends ResponseBodyType = ResponseBodyType> {
|
|
95
|
+
/**
|
|
96
|
+
* 传输动作
|
|
97
|
+
* @description 常用于钩子中
|
|
98
|
+
* @protected
|
|
99
|
+
*/
|
|
100
|
+
_action?: 'request' | 'upload' | 'download';
|
|
101
|
+
/** 与相对 url 进行拼接的基础地址 */
|
|
90
102
|
baseURL?: string;
|
|
91
103
|
method?: 'GET' | 'POST' | 'PUT' | 'DELETE' | 'HEAD' | 'OPTIONS' | 'TRACE' | 'CONNECT';
|
|
104
|
+
/** 传输过程中所需的请求头 */
|
|
92
105
|
headers?: Record<string, string>;
|
|
106
|
+
/** 与完整传输地址进行拼接的查询参数 */
|
|
93
107
|
query?: Record<string, any>;
|
|
94
108
|
body?: any;
|
|
95
109
|
timeout?: number;
|
|
96
|
-
_action?: 'request' | 'upload' | 'download';
|
|
97
110
|
/**
|
|
98
111
|
* 为 true 时返回完整响应对象(statusCode / header / data ...),
|
|
99
112
|
* 否则只返回精炼后的 data。
|
|
@@ -101,14 +114,26 @@ interface HttpCommonOptions<TRBType extends ResponseBodyType = ResponseBodyType>
|
|
|
101
114
|
raw?: boolean;
|
|
102
115
|
responseType?: TRBType;
|
|
103
116
|
parseResponse?: (responseText: string) => any;
|
|
104
|
-
retry?: number | false;
|
|
105
|
-
retryDelay?: number;
|
|
106
117
|
/**
|
|
107
118
|
* 重试的响应状态码
|
|
108
119
|
* @default [408, 409, 425, 429, 500, 502, 503, 504]
|
|
109
120
|
*/
|
|
110
121
|
retryStatusCodes?: number[];
|
|
111
|
-
|
|
122
|
+
/**
|
|
123
|
+
* 是否基于重试响应状态码进行重试
|
|
124
|
+
* @default 1
|
|
125
|
+
*/
|
|
126
|
+
retry?: number | false;
|
|
127
|
+
/**
|
|
128
|
+
* 重试延迟时间,单位 ms
|
|
129
|
+
* @default 0
|
|
130
|
+
*/
|
|
131
|
+
retryDelay?: number;
|
|
132
|
+
/**
|
|
133
|
+
* 判定响应是否走 `onResponseSuccess`;未通过则走 `onResponseError` 并 reject。
|
|
134
|
+
* @default (status) => status >= 200 && status < 300
|
|
135
|
+
*/
|
|
136
|
+
validateStatus?: (status: number) => boolean;
|
|
112
137
|
/**
|
|
113
138
|
* 中断信号,由 `createHttpAborter()` 创建。
|
|
114
139
|
* 信号触发后传输会被中断;已中断的信号会让传输立即中断。
|
|
@@ -117,61 +142,46 @@ interface HttpCommonOptions<TRBType extends ResponseBodyType = ResponseBodyType>
|
|
|
117
142
|
/**
|
|
118
143
|
* 监听响应头(对应 task.onHeadersReceived)。
|
|
119
144
|
*/
|
|
120
|
-
|
|
145
|
+
onHeaders?: (data: UniAppOnHeadersData, off: () => void) => void;
|
|
121
146
|
}
|
|
122
147
|
interface HttpRequestOptions<TRBType extends ResponseBodyType = ResponseBodyType> extends HttpCommonOptions<TRBType>, UniAppRequestOptions {
|
|
123
|
-
/**
|
|
124
|
-
* 传输动作
|
|
125
|
-
* @description 常用于钩子中
|
|
126
|
-
* @protected
|
|
127
|
-
*/
|
|
128
148
|
_action?: 'request';
|
|
129
149
|
/**
|
|
130
|
-
*
|
|
131
|
-
* @default - '
|
|
150
|
+
* 传输方法
|
|
151
|
+
* @default - 'GET'
|
|
132
152
|
*/
|
|
133
153
|
method?: 'GET' | 'POST' | 'PUT' | 'DELETE' | 'HEAD' | 'OPTIONS' | 'TRACE' | 'CONNECT';
|
|
134
154
|
/**
|
|
135
|
-
*
|
|
136
|
-
* @description
|
|
155
|
+
* 监听流式数据,对应原生 task.onChunkReceived
|
|
156
|
+
* @description 调用 `off()` 将关闭流式数据监听
|
|
137
157
|
*/
|
|
138
|
-
onChunk?: (data:
|
|
158
|
+
onChunk?: (data: UniAppRequestChunkData, off: () => void) => void;
|
|
139
159
|
}
|
|
140
160
|
interface HttpUploadOptions<TRBType extends ResponseBodyType = ResponseBodyType> extends HttpCommonOptions<TRBType>, UniAppUploadOptions {
|
|
141
|
-
/**
|
|
142
|
-
* 传输动作
|
|
143
|
-
* @description 常用于钩子中
|
|
144
|
-
* @protected
|
|
145
|
-
*/
|
|
146
161
|
_action?: 'upload';
|
|
147
162
|
/**
|
|
148
|
-
*
|
|
163
|
+
* 传输方法,强制 POST
|
|
149
164
|
* @default - 'POST'
|
|
150
165
|
*/
|
|
151
166
|
method?: 'POST';
|
|
152
167
|
/**
|
|
153
|
-
*
|
|
154
|
-
* @description
|
|
168
|
+
* 监听上传进度,对应原生 task.onProgressUpdate
|
|
169
|
+
* @description 调用 `off()` 将关闭上传进度监听
|
|
155
170
|
*/
|
|
156
|
-
onProgress?: (data:
|
|
171
|
+
onProgress?: (data: UniAppUploadOnProgressData, off: () => void) => void;
|
|
157
172
|
}
|
|
158
173
|
interface HttpDownloadOptions<TRBType extends UniAppDownloadBodyType = 'json'> extends HttpCommonOptions<TRBType>, UniAppDownloadOptions {
|
|
159
|
-
/**
|
|
160
|
-
* 传输动作
|
|
161
|
-
* @description 常用于钩子中
|
|
162
|
-
* @protected
|
|
163
|
-
*/
|
|
164
174
|
_action?: 'download';
|
|
165
175
|
/**
|
|
166
|
-
*
|
|
176
|
+
* 传输方法,强制 GET
|
|
167
177
|
* @default - 'GET'
|
|
168
178
|
*/
|
|
169
179
|
method?: 'GET';
|
|
170
180
|
/**
|
|
171
|
-
*
|
|
172
|
-
* @description
|
|
181
|
+
* 监听下载进度,对应原生 task.onProgressUpdate
|
|
182
|
+
* @description 调用 `off()` 将关闭下载进度监听
|
|
173
183
|
*/
|
|
174
|
-
onProgress?: (data:
|
|
184
|
+
onProgress?: (data: UniAppDownloadOnProgressData, off: () => void) => void;
|
|
175
185
|
}
|
|
176
186
|
/**
|
|
177
187
|
* 传输地址
|
|
@@ -180,70 +190,78 @@ type HttpURL = string;
|
|
|
180
190
|
/**
|
|
181
191
|
* 传输属性
|
|
182
192
|
*/
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
+
type HttpOptions = HttpRequestOptions | HttpUploadOptions | HttpDownloadOptions;
|
|
194
|
+
/**
|
|
195
|
+
* 传输拦截器
|
|
196
|
+
*/
|
|
197
|
+
interface HttpHooks<TOptions, TResponse> {
|
|
198
|
+
/**
|
|
199
|
+
* 请求前置拦截器
|
|
200
|
+
* - 传输状态: 发起失败
|
|
201
|
+
* - 触发条件: 网络发出前
|
|
202
|
+
* - 接受返回值: options、void、Error
|
|
203
|
+
*/
|
|
204
|
+
onBeforeRequest?: (context: {
|
|
205
|
+
url: HttpURL;
|
|
206
|
+
options: TOptions;
|
|
207
|
+
}) => MaybePromise<TOptions | void>;
|
|
208
|
+
/**
|
|
209
|
+
* 请求错误拦截器
|
|
210
|
+
* - 传输状态: 发起失败
|
|
211
|
+
* - 触发条件: 发前抛错、传输 fail、主动 abort 等
|
|
212
|
+
* - Error类: HttpError、Error...
|
|
213
|
+
* - 接受返回值: any (抛出的值将由调用方所接受)
|
|
214
|
+
*/
|
|
215
|
+
onRequestError?: (context: {
|
|
216
|
+
error: Error;
|
|
217
|
+
url: HttpURL;
|
|
218
|
+
options: TOptions;
|
|
219
|
+
}) => MaybePromise<unknown>;
|
|
220
|
+
/**
|
|
221
|
+
* 响应成功拦截器
|
|
222
|
+
* - 传输状态: 已响应
|
|
223
|
+
* - 触发条件: `validateStatus` 通过(默认 2xx)
|
|
224
|
+
* - 接受返回值: 原响应值结构 (HttpResponse)、void
|
|
225
|
+
*/
|
|
226
|
+
onResponseSuccess?: (context: {
|
|
227
|
+
response: TResponse;
|
|
228
|
+
url: HttpURL;
|
|
229
|
+
options: TOptions;
|
|
230
|
+
}) => MaybePromise<TResponse | void>;
|
|
231
|
+
/**
|
|
232
|
+
* 响应错误拦截器
|
|
233
|
+
* - 传输状态: 已响应
|
|
234
|
+
* - 触发条件: `validateStatus` 未通过
|
|
235
|
+
* - Error类: HttpError、Error
|
|
236
|
+
* - 接受返回值: any (抛出的值将由调用方所接受)
|
|
237
|
+
*/
|
|
238
|
+
onResponseError?: (context: {
|
|
239
|
+
error: Error;
|
|
240
|
+
response: TResponse;
|
|
241
|
+
url: HttpURL;
|
|
242
|
+
options: TOptions;
|
|
243
|
+
}) => MaybePromise<unknown>;
|
|
244
|
+
}
|
|
245
|
+
interface HttpConfig extends HttpCommonOptions, HttpHooks<HttpOptions, HttpResponse> {}
|
|
193
246
|
//#endregion
|
|
194
247
|
//#region src/oiyo/http/types/core.d.ts
|
|
195
248
|
interface HttpRequest {
|
|
196
|
-
<TRBody = any, TRBType extends ResponseBodyType = 'json'>(
|
|
249
|
+
<TRBody = any, TRBType extends ResponseBodyType = 'json'>(url: HttpURL, options: HttpRequestOptions<TRBType> & {
|
|
197
250
|
raw: true;
|
|
198
251
|
}): Promise<HttpRequestResponse<TRBody, TRBType>>;
|
|
199
|
-
<TRBody = any, TRBType extends ResponseBodyType = 'json'>(
|
|
252
|
+
<TRBody = any, TRBType extends ResponseBodyType = 'json'>(url: HttpURL, options?: HttpRequestOptions<TRBType>): Promise<HttpRequestResult<TRBody, TRBType>>;
|
|
200
253
|
}
|
|
201
254
|
interface HttpUpload {
|
|
202
|
-
<TRBody = any, TRBType extends ResponseBodyType = 'json'>(
|
|
255
|
+
<TRBody = any, TRBType extends ResponseBodyType = 'json'>(url: HttpURL, options: HttpUploadOptions<TRBType> & {
|
|
203
256
|
raw: true;
|
|
204
257
|
}): Promise<HttpUploadResponse<TRBody, TRBType>>;
|
|
205
|
-
<TRBody = any, TRBType extends ResponseBodyType = 'json'>(
|
|
258
|
+
<TRBody = any, TRBType extends ResponseBodyType = 'json'>(url: HttpURL, options?: HttpUploadOptions<TRBType>): Promise<HttpUploadResult<TRBody, TRBType>>;
|
|
206
259
|
}
|
|
207
260
|
interface HttpDownload {
|
|
208
|
-
<TRBody extends UniAppDownloadBody = UniAppDownloadBody, TRBType extends UniAppDownloadBodyType = UniAppDownloadBodyType>(
|
|
261
|
+
<TRBody extends UniAppDownloadBody = UniAppDownloadBody, TRBType extends UniAppDownloadBodyType = UniAppDownloadBodyType>(url: HttpURL, options: HttpDownloadOptions<TRBType> & {
|
|
209
262
|
raw: true;
|
|
210
263
|
}): Promise<HttpDownloadResponse<TRBody, TRBType>>;
|
|
211
|
-
<TRBody extends UniAppDownloadBody = UniAppDownloadBody, TRBType extends UniAppDownloadBodyType = UniAppDownloadBodyType>(
|
|
212
|
-
}
|
|
213
|
-
type HttpHookContextOptions = HttpRequestOptions & {
|
|
214
|
-
_action: 'request';
|
|
215
|
-
} | HttpUploadOptions & {
|
|
216
|
-
_action: 'upload';
|
|
217
|
-
} | HttpDownloadOptions & {
|
|
218
|
-
_action: 'download';
|
|
219
|
-
};
|
|
220
|
-
interface HttpHooks<TContextOptions, TResponse> {
|
|
221
|
-
onRequest?: (context: {
|
|
222
|
-
resource: HttpURL;
|
|
223
|
-
options: TContextOptions;
|
|
224
|
-
}) => MaybePromise<void>;
|
|
225
|
-
onRequestError?: (context: {
|
|
226
|
-
resource: HttpURL;
|
|
227
|
-
options: TContextOptions;
|
|
228
|
-
error: Error;
|
|
229
|
-
}) => MaybePromise<void>;
|
|
230
|
-
onResponse?: (context: {
|
|
231
|
-
resource: HttpURL;
|
|
232
|
-
options: TContextOptions;
|
|
233
|
-
response: TResponse;
|
|
234
|
-
}) => MaybePromise<void>;
|
|
235
|
-
onResponseError?: (context: {
|
|
236
|
-
resource: HttpURL;
|
|
237
|
-
options: TContextOptions;
|
|
238
|
-
response: TResponse;
|
|
239
|
-
}) => MaybePromise<void>;
|
|
240
|
-
}
|
|
241
|
-
interface HttpConfig extends HttpCommonOptions, HttpHooks<HttpHookContextOptions, HttpResponse> {}
|
|
242
|
-
interface HttpError<T = any> extends Error {
|
|
243
|
-
resource?: HttpURL;
|
|
244
|
-
options?: HttpOptions;
|
|
245
|
-
response?: HttpResponse<T>;
|
|
246
|
-
data: T;
|
|
264
|
+
<TRBody extends UniAppDownloadBody = UniAppDownloadBody, TRBType extends UniAppDownloadBodyType = UniAppDownloadBodyType>(url: HttpURL, options?: HttpDownloadOptions<TRBType>): Promise<HttpDownloadResult<TRBody, TRBType>>;
|
|
247
265
|
}
|
|
248
266
|
//#endregion
|
|
249
267
|
//#region src/oiyo/http/core.d.ts
|
|
@@ -319,4 +337,26 @@ declare function createHttp(globalConfig?: HttpConfig): Http;
|
|
|
319
337
|
*/
|
|
320
338
|
declare const http: Http;
|
|
321
339
|
//#endregion
|
|
322
|
-
|
|
340
|
+
//#region src/oiyo/http/error.d.ts
|
|
341
|
+
declare class HttpError<TB = any> extends Error {
|
|
342
|
+
/** 调用方在传输过程中主动中止 */
|
|
343
|
+
static readonly ABORT = "ABORT";
|
|
344
|
+
/** 调用方无法发起传输行为:网络错误、跨域、超时等 */
|
|
345
|
+
static readonly FAIL = "FAIL";
|
|
346
|
+
/** 响应的 HTTP 状态码未通过 `validateStatus`(默认非 2xx) */
|
|
347
|
+
static readonly STATUS = "STATUS";
|
|
348
|
+
readonly url?: HttpURL;
|
|
349
|
+
readonly options?: HttpOptions;
|
|
350
|
+
readonly response?: HttpResponse<TB>;
|
|
351
|
+
readonly statusCode?: number;
|
|
352
|
+
readonly statusMessage?: string;
|
|
353
|
+
readonly data?: TB;
|
|
354
|
+
constructor(options: {
|
|
355
|
+
name: string;
|
|
356
|
+
message: string;
|
|
357
|
+
cause?: unknown;
|
|
358
|
+
});
|
|
359
|
+
}
|
|
360
|
+
declare function isHttpError(error: unknown): error is HttpError;
|
|
361
|
+
//#endregion
|
|
362
|
+
export { HttpCommonOptions as a, HttpOptions as c, HttpDownloadResponse as d, HttpRequestResponse as f, createHttpAborter as g, ResponseBodyType as h, http as i, HttpRequestOptions as l, HttpUploadResponse as m, isHttpError as n, HttpConfig as o, HttpResponse as p, createHttp as r, HttpDownloadOptions as s, HttpError as t, HttpUploadOptions as u };
|
package/dist/index.cjs
CHANGED
|
@@ -1,31 +1,7 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* @oiyo/framework v0.
|
|
2
|
+
* @oiyo/framework v0.5.0
|
|
3
3
|
* Copyright (c) 2026 skiyee. All rights reserved.
|
|
4
4
|
* Commercial software. See LICENSE for terms.
|
|
5
5
|
* Official site: https://oiyo.js.org
|
|
6
6
|
*/
|
|
7
|
-
Object.defineProperty(exports,
|
|
8
|
-
const require_oiyo = require("./oiyo-CUAtDW_Y.cjs");
|
|
9
|
-
require("./uni.cjs");
|
|
10
|
-
require("./vue.cjs");
|
|
11
|
-
exports.createHttp = require_oiyo.createHttp;
|
|
12
|
-
exports.createHttpAborter = require_oiyo.createHttpAborter;
|
|
13
|
-
exports.http = require_oiyo.http;
|
|
14
|
-
var _dcloudio_uni_app = require("@dcloudio/uni-app");
|
|
15
|
-
Object.keys(_dcloudio_uni_app).forEach(function(k) {
|
|
16
|
-
if (k !== "default" && !Object.prototype.hasOwnProperty.call(exports, k)) Object.defineProperty(exports, k, {
|
|
17
|
-
enumerable: true,
|
|
18
|
-
get: function() {
|
|
19
|
-
return _dcloudio_uni_app[k];
|
|
20
|
-
}
|
|
21
|
-
});
|
|
22
|
-
});
|
|
23
|
-
var vue = require("vue");
|
|
24
|
-
Object.keys(vue).forEach(function(k) {
|
|
25
|
-
if (k !== "default" && !Object.prototype.hasOwnProperty.call(exports, k)) Object.defineProperty(exports, k, {
|
|
26
|
-
enumerable: true,
|
|
27
|
-
get: function() {
|
|
28
|
-
return vue[k];
|
|
29
|
-
}
|
|
30
|
-
});
|
|
31
|
-
});
|
|
7
|
+
Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require("./oiyo-Cd_IUg_L.cjs");require("./uni.cjs"),require("./vue.cjs"),exports.HttpError=e.i,exports.createHttp=e.t,exports.createHttpAborter=e.r,exports.http=e.n,exports.isHttpError=e.a;var t=require("@dcloudio/uni-app");Object.keys(t).forEach(function(e){e!=="default"&&!Object.prototype.hasOwnProperty.call(exports,e)&&Object.defineProperty(exports,e,{enumerable:!0,get:function(){return t[e]}})});var n=require("vue");Object.keys(n).forEach(function(e){e!=="default"&&!Object.prototype.hasOwnProperty.call(exports,e)&&Object.defineProperty(exports,e,{enumerable:!0,get:function(){return n[e]}})});
|
package/dist/index.d.cts
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* @oiyo/framework v0.
|
|
2
|
+
* @oiyo/framework v0.5.0
|
|
3
3
|
* Copyright (c) 2026 skiyee. All rights reserved.
|
|
4
4
|
* Commercial software. See LICENSE for terms.
|
|
5
5
|
* Official site: https://oiyo.js.org
|
|
6
6
|
*/
|
|
7
|
-
import { a as
|
|
7
|
+
import { a as HttpCommonOptions, c as HttpOptions, d as HttpDownloadResponse, f as HttpRequestResponse, g as createHttpAborter, h as ResponseBodyType, i as http, l as HttpRequestOptions, m as HttpUploadResponse, n as isHttpError, o as HttpConfig, p as HttpResponse, r as createHttp, s as HttpDownloadOptions, t as HttpError, u as HttpUploadOptions } from "./index-BGIDoS5A.cjs";
|
|
8
8
|
import "./uni.cjs";
|
|
9
9
|
import "./vue.cjs";
|
|
10
10
|
export * from "@dcloudio/uni-app";
|
|
11
11
|
export * from "vue";
|
|
12
|
-
export { type HttpCommonOptions, type HttpConfig, type HttpDownloadOptions, type HttpDownloadResponse,
|
|
12
|
+
export { type HttpCommonOptions, type HttpConfig, type HttpDownloadOptions, type HttpDownloadResponse, HttpError, type HttpOptions, type HttpRequestOptions, type HttpRequestResponse, type HttpResponse, type HttpUploadOptions, type HttpUploadResponse, type ResponseBodyType, createHttp, createHttpAborter, http, isHttpError };
|
package/dist/index.d.mts
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* @oiyo/framework v0.
|
|
2
|
+
* @oiyo/framework v0.5.0
|
|
3
3
|
* Copyright (c) 2026 skiyee. All rights reserved.
|
|
4
4
|
* Commercial software. See LICENSE for terms.
|
|
5
5
|
* Official site: https://oiyo.js.org
|
|
6
6
|
*/
|
|
7
|
-
import { a as
|
|
7
|
+
import { a as HttpCommonOptions, c as HttpOptions, d as HttpDownloadResponse, f as HttpRequestResponse, g as createHttpAborter, h as ResponseBodyType, i as http, l as HttpRequestOptions, m as HttpUploadResponse, n as isHttpError, o as HttpConfig, p as HttpResponse, r as createHttp, s as HttpDownloadOptions, t as HttpError, u as HttpUploadOptions } from "./index-BGIDoS5A.mjs";
|
|
8
8
|
import "./uni.mjs";
|
|
9
9
|
import "./vue.mjs";
|
|
10
10
|
export * from "@dcloudio/uni-app";
|
|
11
11
|
export * from "vue";
|
|
12
|
-
export { type HttpCommonOptions, type HttpConfig, type HttpDownloadOptions, type HttpDownloadResponse,
|
|
12
|
+
export { type HttpCommonOptions, type HttpConfig, type HttpDownloadOptions, type HttpDownloadResponse, HttpError, type HttpOptions, type HttpRequestOptions, type HttpRequestResponse, type HttpResponse, type HttpUploadOptions, type HttpUploadResponse, type ResponseBodyType, createHttp, createHttpAborter, http, isHttpError };
|
package/dist/index.mjs
CHANGED
|
@@ -1,12 +1,7 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* @oiyo/framework v0.
|
|
2
|
+
* @oiyo/framework v0.5.0
|
|
3
3
|
* Copyright (c) 2026 skiyee. All rights reserved.
|
|
4
4
|
* Commercial software. See LICENSE for terms.
|
|
5
5
|
* Official site: https://oiyo.js.org
|
|
6
6
|
*/
|
|
7
|
-
import
|
|
8
|
-
import "./uni.mjs";
|
|
9
|
-
import "./vue.mjs";
|
|
10
|
-
export * from "@dcloudio/uni-app";
|
|
11
|
-
export * from "vue";
|
|
12
|
-
export { createHttp, createHttpAborter, http };
|
|
7
|
+
import{a as e,i as t,n,r,t as i}from"./oiyo-C5uDbL0e.mjs";import"./uni.mjs";import"./vue.mjs";export*from"@dcloudio/uni-app";export*from"vue";export{t as HttpError,i as createHttp,r as createHttpAborter,n as http,e as isHttpError};
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @oiyo/framework v0.5.0
|
|
3
|
+
* Copyright (c) 2026 skiyee. All rights reserved.
|
|
4
|
+
* Commercial software. See LICENSE for terms.
|
|
5
|
+
* Official site: https://oiyo.js.org
|
|
6
|
+
*/
|
|
7
|
+
var e=class extends Error{static ABORT=`ABORT`;static FAIL=`FAIL`;static STATUS=`STATUS`;url;options;response;statusCode;statusMessage;data;constructor(e){super(e.message,{cause:e.cause}),this.name=e.name}};function t(t){return!!t&&typeof t==`object`&&t instanceof e}function n(t,n,r){let i=`[${n?.method||`GET`}] ${t}`,a=r?`${r.statusCode} ${r.errMsg||``}`:`<no response>`,o=r?JSON.stringify(r.data):`<no response body>`,s=`${i}: ${a}${r.data?` ${o}`:``}`,c=new e({name:e.STATUS,message:s});for(let e of[`url`,`options`,`response`,`statusCode`,`statusMessage`,`data`])Object.defineProperty(c,e,{get(){return{url:t,options:n,response:r,statusCode:r.statusCode,statusMessage:r.errMsg,data:r.data}[e]}});return c}function r(t=`The operation was aborted`){return new e({name:e.ABORT,message:t})}function i(t=`request failed`){return new e({name:e.FAIL,message:t})}var a=class{listeners=new Map;constructor(){}on(e,t){let n=this.listeners.get(e);Array.isArray(n)?n.push(t):this.listeners.set(e,[t])}off(e,t){let n=this.listeners.get(e);if(!n?.length)return;let r=n.indexOf(t);r!==-1&&n.splice(r,1)}emit(e,...t){let n=(this.listeners.get(e)||[]).slice();for(let e of n)e.call(this,...t)}remove(e){this.listeners.has(e)&&this.listeners.delete(e)}},o=class extends a{_aborted=!1;_reason=null;_onabortListener=()=>{};get aborted(){return this._aborted}get reason(){return this._reason}_abort(e){this._aborted||(this._aborted=!0,this._reason=e??r(),this.emit(`abort`))}throwIfAborted(){if(this.aborted)throw this.reason}},s=class{_signal=new o;constructor(){}get signal(){return this._signal}abort(e){this._signal._abort(e)}};function c(){return new s}function l(e){let t=new s;if(!e)return{signal:t.signal,dispose:()=>{}};if(e.aborted)return t.abort(e.reason),{signal:t.signal,dispose:()=>{}};let n=u(e,()=>{n=void 0,t.abort(e.reason)});return{signal:t.signal,dispose(){n?.(),n=void 0}}}function u(e,t){return e?e.aborted?(t(),()=>{}):(e.on(`abort`,t),()=>e.off(`abort`,t)):()=>{}}function d(e){if(!e||typeof e!=`object`)return!1;let t=Object.getPrototypeOf(e);return t!==null&&t!==Object.prototype&&Object.getPrototypeOf(t)!==null?!1:Object.prototype.toString.call(e)===`[object Object]`}function f(e){return e===void 0}const p=[`onBeforeRequest`,`onRequestError`,`onResponseSuccess`,`onResponseError`];function m(...e){let t={},n={};for(let r of e){if(!r)continue;for(let e of p)h(n,e,r);let e=t.headers,i=t.query;Object.assign(t,r),t.headers={...e,...r.headers},t.query={...i,...r.query}}for(let[e,r]of Object.entries(n))Object.assign(t,{[e]:async e=>{let t;for(let n of r){let r=await n(e);f(r)||(t=r)}return t}});return t}function h(e,t,n){let r=n[t];typeof r==`function`&&(e[t]??=[],e[t].push(r))}async function g(e){return new Promise(t=>setTimeout(t,e))}function _(){}function v(e,t){if(!t||t===`/`)return e;let n=t[t.length-1]===`/`?t.slice(0,-1):t;return e.startsWith(n)?e:y(t,e)}function y(e,t){return!e||b(t)?t:`${e.replace(/\/+$/,``)}/${t.replace(/^\/+/,``)}`}function b(e){return/^[a-z][a-z\d+\-.]*:\/\//i.test(e)||e.startsWith(`//`)}function x(e,t){if(!t||Object.keys(t).length===0)return e;let n=e.indexOf(`?`);if(n===-1){let n=Object.entries(t).filter(([,e])=>e!==void 0).flatMap(([e,t])=>(Array.isArray(t)?t:[t]).filter(e=>!f(e)).map(t=>C(e,t))).join(`&`);return n?`${e}?${n}`:e}let r=w(e.slice(n+1)),i=e.slice(0,n);for(let[e,n]of Object.entries(t))if(n===void 0)r.delete(e);else if(Array.isArray(n))for(let t of n)f(t)||r.append(e,S(t));else r.set(e,S(n));let a=r.toString();return a?`${i}?${a}`:i}function S(e){return e===null?``:typeof e==`number`||typeof e==`boolean`?String(e):typeof e==`object`?JSON.stringify(e):String(e)}function C(e,t){return`${encodeURIComponent(e)}=${encodeURIComponent(S(t))}`}function w(e){let t=[],n=new Map;for(let r of e.split(`&`)){if(!r)continue;let e=r.indexOf(`=`),i=T(e===-1?r:r.slice(0,e)),a=T(e===-1?``:r.slice(e+1));n.has(i)||(n.set(i,[]),t.push(i)),n.get(i).push(a)}return{set(e,r){n.has(e)||t.push(e),n.set(e,[r])},append(e,r){n.has(e)||(n.set(e,[]),t.push(e)),n.get(e).push(r)},delete(e){if(!n.delete(e))return;let r=t.indexOf(e);r!==-1&&t.splice(r,1)},toString(){return t.flatMap(e=>(n.get(e)??[]).map(t=>C(e,t))).join(`&`)}}}function T(e){try{return decodeURIComponent(e.replace(/\+/g,` `))}catch{return e}}function E(e){return!e||e===`json`?`text`:e===`arrayBuffer`?`arraybuffer`:`text`}function D(e,t){let n={url:e,method:t.method,header:t.headers,data:t.body??{},timeout:t.timeout,dataType:t.dataType||`json`,responseType:E(t.responseType),sslVerify:t.sslVerify,withCredentials:t.withCredentials,firstIpv4:t.firstIpv4,enableHttp2:t.enableHttp2,enableQuic:t.enableQuic,enableCache:t.enableCache,enableHttpDNS:t.enableHttpDNS,httpDNSServiceId:t.httpDNSServiceId,enableChunked:t.enableChunked,forceCellularNetwork:t.forceCellularNetwork,complete:_},r,i=new Promise((e,t)=>{n.success=t=>{e(t)},n.fail=e=>{t(e)},r=uni.request(n)});return A(i,r),i}function O(e,t){let n={url:e,fileType:t.fileType,file:t.file,filePath:t.filePath,name:t.name??`file`,files:t.files,header:t.headers,formData:t.body??{},timeout:t.timeout,complete:_},r,i=new Promise((e,t)=>{n.success=t=>{e(t)},n.fail=e=>{t(e)},r=uni.uploadFile(n)});return A(i,r),i}function k(e,t){let n={url:e,filePath:t.filePath,header:t.headers,timeout:t.timeout,complete:_},r,i=new Promise((e,t)=>{n.success=t=>{e({...t,data:{tempFilePath:t.tempFilePath}})},n.fail=e=>{t(e)},r=uni.downloadFile(n)});return A(i,r),i}function A(e,t){if(t&&e)for(let n of[`abort`,`onHeadersReceived`,`offHeadersReceived`,`onChunkReceived`,`offChunkReceived`,`onProgressUpdate`,`offProgressUpdate`])n in t&&Object.defineProperty(e,n,{value:t[n].bind(t),writable:!1,enumerable:!1,configurable:!1})}function j(e){if(d(e)){let t=e;return t.errMsg||t.message||void 0}}function M(e){if(!e||typeof e!=`object`)return!1;let t=e.errMsg;return typeof t==`string`&&/(?:^|:)fail(?:ed)?\s+abort(?:ed)?$/i.test(t.trim())}function N(e,t,n){let r;r=e===`upload`?O(t,n):e===`download`?k(t,n):D(t,n),n.signal?.throwIfAborted(),n.signal?.on(`abort`,()=>r.abort());let i=n.onHeaders;if(typeof i==`function`&&typeof r.onHeadersReceived==`function`){let e=!1,t=n=>{e||i(n,()=>{e||(e=!0,r.offHeadersReceived?.(t))})};r.onHeadersReceived(t)}let a=n.onChunk;if(n._action===`request`&&typeof a==`function`&&typeof r.onChunkReceived==`function`){let e=!1,t=n=>{e||a(n,()=>{e||(e=!0,r.offChunkReceived?.(t))})};r.onChunkReceived(t)}let o=n.onProgress;if((n._action===`download`||n._action===`upload`)&&typeof o==`function`&&typeof r.onProgressUpdate==`function`){let e=!1,t=n=>{e||o(n,()=>{e||(e=!0,r.offProgressUpdate?.(t))})};r.onProgressUpdate(t)}return r}async function P(e,t){return t.responseType===`json`||!t.responseType?{...e,data:await F(e.data,t)}:e}function F(e,t){return typeof e==`string`?t.parseResponse?t.parseResponse(e):e?JSON.parse(e):null:e}const I=[408,409,425,429,500,502,503,504],L=new Set([`POST`,`PUT`,`DELETE`,`PATCH`]);async function R(e,t){let n=(e.retry??1)||0;(!e.method||n<=0||L.has(e.method.toUpperCase()))&&(n=0);for(let r=0;;r++){let{signal:i,dispose:a}=l(e.signal),o={...e,signal:i};try{return await t(o)}catch(e){if(r>=n||!z(e,o))throw e;let t=o.retryDelay??0;t>0&&await g(t)}finally{a()}}}function z(n,r){return!t(n)||n.name===e.ABORT?!1:n.name===e.FAIL||(r.retryStatusCodes??I).includes(n.statusCode)}function B(e,t,n){return R(n,n=>V(e,t,n))}async function V(e,t,a){try{let e=await a.onBeforeRequest?.({url:t,options:a});d(e)&&(a=m(e,a)),a.signal?.throwIfAborted()}catch(e){let n=e,r=await a.onRequestError?.({url:t,options:a,error:n});if(!f(r))return r;throw n}let o;try{o=await N(e,x(v(t,a.baseURL),a.query),a)}catch(e){let n=e;n=M(e)?r():i(j(n));let o=await a.onRequestError?.({url:t,options:a,error:n});if(!f(o))return o;throw n}finally{a.signal?.remove(`abort`)}let s=await P(o,a);if(a.validateStatus?.(s.statusCode)){let e=await a.onResponseSuccess?.({url:t,options:a,response:s});return f(e)||(s=Object.assign({},s,e)),a.raw?s:s.data}let c=n(t,a,s),l=await a.onResponseError?.({url:t,options:a,response:s,error:c});if(!f(l))return l;throw c}const H={responseType:`json`,validateStatus:e=>e>=200&&e<300};function U(e={}){let t=m(H,e);return{request:(e,n)=>B(`request`,e,m(t,{method:`GET`},n,{_action:`request`})),upload:(e,n)=>B(`upload`,e,m(t,n,{method:`POST`,_action:`upload`})),download:(e,n)=>B(`download`,e,m(t,n,{method:`GET`,_action:`download`})),create:t=>U(m(e,t))}}const W=U();export{t as a,e as i,W as n,c as r,U as t};
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @oiyo/framework v0.5.0
|
|
3
|
+
* Copyright (c) 2026 skiyee. All rights reserved.
|
|
4
|
+
* Commercial software. See LICENSE for terms.
|
|
5
|
+
* Official site: https://oiyo.js.org
|
|
6
|
+
*/
|
|
7
|
+
var e=class extends Error{static ABORT=`ABORT`;static FAIL=`FAIL`;static STATUS=`STATUS`;url;options;response;statusCode;statusMessage;data;constructor(e){super(e.message,{cause:e.cause}),this.name=e.name}};function t(t){return!!t&&typeof t==`object`&&t instanceof e}function n(t,n,r){let i=`[${n?.method||`GET`}] ${t}`,a=r?`${r.statusCode} ${r.errMsg||``}`:`<no response>`,o=r?JSON.stringify(r.data):`<no response body>`,s=`${i}: ${a}${r.data?` ${o}`:``}`,c=new e({name:e.STATUS,message:s});for(let e of[`url`,`options`,`response`,`statusCode`,`statusMessage`,`data`])Object.defineProperty(c,e,{get(){return{url:t,options:n,response:r,statusCode:r.statusCode,statusMessage:r.errMsg,data:r.data}[e]}});return c}function r(t=`The operation was aborted`){return new e({name:e.ABORT,message:t})}function i(t=`request failed`){return new e({name:e.FAIL,message:t})}var a=class{listeners=new Map;constructor(){}on(e,t){let n=this.listeners.get(e);Array.isArray(n)?n.push(t):this.listeners.set(e,[t])}off(e,t){let n=this.listeners.get(e);if(!n?.length)return;let r=n.indexOf(t);r!==-1&&n.splice(r,1)}emit(e,...t){let n=(this.listeners.get(e)||[]).slice();for(let e of n)e.call(this,...t)}remove(e){this.listeners.has(e)&&this.listeners.delete(e)}},o=class extends a{_aborted=!1;_reason=null;_onabortListener=()=>{};get aborted(){return this._aborted}get reason(){return this._reason}_abort(e){this._aborted||(this._aborted=!0,this._reason=e??r(),this.emit(`abort`))}throwIfAborted(){if(this.aborted)throw this.reason}},s=class{_signal=new o;constructor(){}get signal(){return this._signal}abort(e){this._signal._abort(e)}};function c(){return new s}function l(e){let t=new s;if(!e)return{signal:t.signal,dispose:()=>{}};if(e.aborted)return t.abort(e.reason),{signal:t.signal,dispose:()=>{}};let n=u(e,()=>{n=void 0,t.abort(e.reason)});return{signal:t.signal,dispose(){n?.(),n=void 0}}}function u(e,t){return e?e.aborted?(t(),()=>{}):(e.on(`abort`,t),()=>e.off(`abort`,t)):()=>{}}function d(e){if(!e||typeof e!=`object`)return!1;let t=Object.getPrototypeOf(e);return t!==null&&t!==Object.prototype&&Object.getPrototypeOf(t)!==null?!1:Object.prototype.toString.call(e)===`[object Object]`}function f(e){return e===void 0}const p=[`onBeforeRequest`,`onRequestError`,`onResponseSuccess`,`onResponseError`];function m(...e){let t={},n={};for(let r of e){if(!r)continue;for(let e of p)h(n,e,r);let e=t.headers,i=t.query;Object.assign(t,r),t.headers={...e,...r.headers},t.query={...i,...r.query}}for(let[e,r]of Object.entries(n))Object.assign(t,{[e]:async e=>{let t;for(let n of r){let r=await n(e);f(r)||(t=r)}return t}});return t}function h(e,t,n){let r=n[t];typeof r==`function`&&(e[t]??=[],e[t].push(r))}async function g(e){return new Promise(t=>setTimeout(t,e))}function _(){}function v(e,t){if(!t||t===`/`)return e;let n=t[t.length-1]===`/`?t.slice(0,-1):t;return e.startsWith(n)?e:y(t,e)}function y(e,t){return!e||b(t)?t:`${e.replace(/\/+$/,``)}/${t.replace(/^\/+/,``)}`}function b(e){return/^[a-z][a-z\d+\-.]*:\/\//i.test(e)||e.startsWith(`//`)}function x(e,t){if(!t||Object.keys(t).length===0)return e;let n=e.indexOf(`?`);if(n===-1){let n=Object.entries(t).filter(([,e])=>e!==void 0).flatMap(([e,t])=>(Array.isArray(t)?t:[t]).filter(e=>!f(e)).map(t=>C(e,t))).join(`&`);return n?`${e}?${n}`:e}let r=w(e.slice(n+1)),i=e.slice(0,n);for(let[e,n]of Object.entries(t))if(n===void 0)r.delete(e);else if(Array.isArray(n))for(let t of n)f(t)||r.append(e,S(t));else r.set(e,S(n));let a=r.toString();return a?`${i}?${a}`:i}function S(e){return e===null?``:typeof e==`number`||typeof e==`boolean`?String(e):typeof e==`object`?JSON.stringify(e):String(e)}function C(e,t){return`${encodeURIComponent(e)}=${encodeURIComponent(S(t))}`}function w(e){let t=[],n=new Map;for(let r of e.split(`&`)){if(!r)continue;let e=r.indexOf(`=`),i=T(e===-1?r:r.slice(0,e)),a=T(e===-1?``:r.slice(e+1));n.has(i)||(n.set(i,[]),t.push(i)),n.get(i).push(a)}return{set(e,r){n.has(e)||t.push(e),n.set(e,[r])},append(e,r){n.has(e)||(n.set(e,[]),t.push(e)),n.get(e).push(r)},delete(e){if(!n.delete(e))return;let r=t.indexOf(e);r!==-1&&t.splice(r,1)},toString(){return t.flatMap(e=>(n.get(e)??[]).map(t=>C(e,t))).join(`&`)}}}function T(e){try{return decodeURIComponent(e.replace(/\+/g,` `))}catch{return e}}function E(e){return!e||e===`json`?`text`:e===`arrayBuffer`?`arraybuffer`:`text`}function D(e,t){let n={url:e,method:t.method,header:t.headers,data:t.body??{},timeout:t.timeout,dataType:t.dataType||`json`,responseType:E(t.responseType),sslVerify:t.sslVerify,withCredentials:t.withCredentials,firstIpv4:t.firstIpv4,enableHttp2:t.enableHttp2,enableQuic:t.enableQuic,enableCache:t.enableCache,enableHttpDNS:t.enableHttpDNS,httpDNSServiceId:t.httpDNSServiceId,enableChunked:t.enableChunked,forceCellularNetwork:t.forceCellularNetwork,complete:_},r,i=new Promise((e,t)=>{n.success=t=>{e(t)},n.fail=e=>{t(e)},r=uni.request(n)});return A(i,r),i}function O(e,t){let n={url:e,fileType:t.fileType,file:t.file,filePath:t.filePath,name:t.name??`file`,files:t.files,header:t.headers,formData:t.body??{},timeout:t.timeout,complete:_},r,i=new Promise((e,t)=>{n.success=t=>{e(t)},n.fail=e=>{t(e)},r=uni.uploadFile(n)});return A(i,r),i}function k(e,t){let n={url:e,filePath:t.filePath,header:t.headers,timeout:t.timeout,complete:_},r,i=new Promise((e,t)=>{n.success=t=>{e({...t,data:{tempFilePath:t.tempFilePath}})},n.fail=e=>{t(e)},r=uni.downloadFile(n)});return A(i,r),i}function A(e,t){if(t&&e)for(let n of[`abort`,`onHeadersReceived`,`offHeadersReceived`,`onChunkReceived`,`offChunkReceived`,`onProgressUpdate`,`offProgressUpdate`])n in t&&Object.defineProperty(e,n,{value:t[n].bind(t),writable:!1,enumerable:!1,configurable:!1})}function j(e){if(d(e)){let t=e;return t.errMsg||t.message||void 0}}function M(e){if(!e||typeof e!=`object`)return!1;let t=e.errMsg;return typeof t==`string`&&/(?:^|:)fail(?:ed)?\s+abort(?:ed)?$/i.test(t.trim())}function N(e,t,n){let r;r=e===`upload`?O(t,n):e===`download`?k(t,n):D(t,n),n.signal?.throwIfAborted(),n.signal?.on(`abort`,()=>r.abort());let i=n.onHeaders;if(typeof i==`function`&&typeof r.onHeadersReceived==`function`){let e=!1,t=n=>{e||i(n,()=>{e||(e=!0,r.offHeadersReceived?.(t))})};r.onHeadersReceived(t)}let a=n.onChunk;if(n._action===`request`&&typeof a==`function`&&typeof r.onChunkReceived==`function`){let e=!1,t=n=>{e||a(n,()=>{e||(e=!0,r.offChunkReceived?.(t))})};r.onChunkReceived(t)}let o=n.onProgress;if((n._action===`download`||n._action===`upload`)&&typeof o==`function`&&typeof r.onProgressUpdate==`function`){let e=!1,t=n=>{e||o(n,()=>{e||(e=!0,r.offProgressUpdate?.(t))})};r.onProgressUpdate(t)}return r}async function P(e,t){return t.responseType===`json`||!t.responseType?{...e,data:await F(e.data,t)}:e}function F(e,t){return typeof e==`string`?t.parseResponse?t.parseResponse(e):e?JSON.parse(e):null:e}const I=[408,409,425,429,500,502,503,504],L=new Set([`POST`,`PUT`,`DELETE`,`PATCH`]);async function R(e,t){let n=(e.retry??1)||0;(!e.method||n<=0||L.has(e.method.toUpperCase()))&&(n=0);for(let r=0;;r++){let{signal:i,dispose:a}=l(e.signal),o={...e,signal:i};try{return await t(o)}catch(e){if(r>=n||!z(e,o))throw e;let t=o.retryDelay??0;t>0&&await g(t)}finally{a()}}}function z(n,r){return!t(n)||n.name===e.ABORT?!1:n.name===e.FAIL||(r.retryStatusCodes??I).includes(n.statusCode)}function B(e,t,n){return R(n,n=>V(e,t,n))}async function V(e,t,a){try{let e=await a.onBeforeRequest?.({url:t,options:a});d(e)&&(a=m(e,a)),a.signal?.throwIfAborted()}catch(e){let n=e,r=await a.onRequestError?.({url:t,options:a,error:n});if(!f(r))return r;throw n}let o;try{o=await N(e,x(v(t,a.baseURL),a.query),a)}catch(e){let n=e;n=M(e)?r():i(j(n));let o=await a.onRequestError?.({url:t,options:a,error:n});if(!f(o))return o;throw n}finally{a.signal?.remove(`abort`)}let s=await P(o,a);if(a.validateStatus?.(s.statusCode)){let e=await a.onResponseSuccess?.({url:t,options:a,response:s});return f(e)||(s=Object.assign({},s,e)),a.raw?s:s.data}let c=n(t,a,s),l=await a.onResponseError?.({url:t,options:a,response:s,error:c});if(!f(l))return l;throw c}const H={responseType:`json`,validateStatus:e=>e>=200&&e<300};function U(e={}){let t=m(H,e);return{request:(e,n)=>B(`request`,e,m(t,{method:`GET`},n,{_action:`request`})),upload:(e,n)=>B(`upload`,e,m(t,n,{method:`POST`,_action:`upload`})),download:(e,n)=>B(`download`,e,m(t,n,{method:`GET`,_action:`download`})),create:t=>U(m(e,t))}}const W=U();Object.defineProperty(exports,"a",{enumerable:!0,get:function(){return t}}),Object.defineProperty(exports,"i",{enumerable:!0,get:function(){return e}}),Object.defineProperty(exports,"n",{enumerable:!0,get:function(){return W}}),Object.defineProperty(exports,"r",{enumerable:!0,get:function(){return c}}),Object.defineProperty(exports,"t",{enumerable:!0,get:function(){return U}});
|
package/dist/oiyo.cjs
CHANGED
|
@@ -1,11 +1,7 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* @oiyo/framework v0.
|
|
2
|
+
* @oiyo/framework v0.5.0
|
|
3
3
|
* Copyright (c) 2026 skiyee. All rights reserved.
|
|
4
4
|
* Commercial software. See LICENSE for terms.
|
|
5
5
|
* Official site: https://oiyo.js.org
|
|
6
6
|
*/
|
|
7
|
-
Object.defineProperty(exports,
|
|
8
|
-
const require_oiyo = require("./oiyo-CUAtDW_Y.cjs");
|
|
9
|
-
exports.createHttp = require_oiyo.createHttp;
|
|
10
|
-
exports.createHttpAborter = require_oiyo.createHttpAborter;
|
|
11
|
-
exports.http = require_oiyo.http;
|
|
7
|
+
Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require("./oiyo-Cd_IUg_L.cjs");exports.HttpError=e.i,exports.createHttp=e.t,exports.createHttpAborter=e.r,exports.http=e.n,exports.isHttpError=e.a;
|
package/dist/oiyo.d.cts
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* @oiyo/framework v0.
|
|
2
|
+
* @oiyo/framework v0.5.0
|
|
3
3
|
* Copyright (c) 2026 skiyee. All rights reserved.
|
|
4
4
|
* Commercial software. See LICENSE for terms.
|
|
5
5
|
* Official site: https://oiyo.js.org
|
|
6
6
|
*/
|
|
7
|
-
import { a as
|
|
8
|
-
export { type HttpCommonOptions, type HttpConfig, type HttpDownloadOptions, type HttpDownloadResponse,
|
|
7
|
+
import { a as HttpCommonOptions, c as HttpOptions, d as HttpDownloadResponse, f as HttpRequestResponse, g as createHttpAborter, h as ResponseBodyType, i as http, l as HttpRequestOptions, m as HttpUploadResponse, n as isHttpError, o as HttpConfig, p as HttpResponse, r as createHttp, s as HttpDownloadOptions, t as HttpError, u as HttpUploadOptions } from "./index-BGIDoS5A.cjs";
|
|
8
|
+
export { type HttpCommonOptions, type HttpConfig, type HttpDownloadOptions, type HttpDownloadResponse, HttpError, type HttpOptions, type HttpRequestOptions, type HttpRequestResponse, type HttpResponse, type HttpUploadOptions, type HttpUploadResponse, type ResponseBodyType, createHttp, createHttpAborter, http, isHttpError };
|
package/dist/oiyo.d.mts
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* @oiyo/framework v0.
|
|
2
|
+
* @oiyo/framework v0.5.0
|
|
3
3
|
* Copyright (c) 2026 skiyee. All rights reserved.
|
|
4
4
|
* Commercial software. See LICENSE for terms.
|
|
5
5
|
* Official site: https://oiyo.js.org
|
|
6
6
|
*/
|
|
7
|
-
import { a as
|
|
8
|
-
export { type HttpCommonOptions, type HttpConfig, type HttpDownloadOptions, type HttpDownloadResponse,
|
|
7
|
+
import { a as HttpCommonOptions, c as HttpOptions, d as HttpDownloadResponse, f as HttpRequestResponse, g as createHttpAborter, h as ResponseBodyType, i as http, l as HttpRequestOptions, m as HttpUploadResponse, n as isHttpError, o as HttpConfig, p as HttpResponse, r as createHttp, s as HttpDownloadOptions, t as HttpError, u as HttpUploadOptions } from "./index-BGIDoS5A.mjs";
|
|
8
|
+
export { type HttpCommonOptions, type HttpConfig, type HttpDownloadOptions, type HttpDownloadResponse, HttpError, type HttpOptions, type HttpRequestOptions, type HttpRequestResponse, type HttpResponse, type HttpUploadOptions, type HttpUploadResponse, type ResponseBodyType, createHttp, createHttpAborter, http, isHttpError };
|
package/dist/oiyo.mjs
CHANGED
|
@@ -1,8 +1,7 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* @oiyo/framework v0.
|
|
2
|
+
* @oiyo/framework v0.5.0
|
|
3
3
|
* Copyright (c) 2026 skiyee. All rights reserved.
|
|
4
4
|
* Commercial software. See LICENSE for terms.
|
|
5
5
|
* Official site: https://oiyo.js.org
|
|
6
6
|
*/
|
|
7
|
-
import
|
|
8
|
-
export { createHttp, createHttpAborter, http };
|
|
7
|
+
import{a as e,i as t,n,r,t as i}from"./oiyo-C5uDbL0e.mjs";export{t as HttpError,i as createHttp,r as createHttpAborter,n as http,e as isHttpError};
|
package/dist/uni.cjs
CHANGED
|
@@ -1,16 +1,7 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* @oiyo/framework v0.
|
|
2
|
+
* @oiyo/framework v0.5.0
|
|
3
3
|
* Copyright (c) 2026 skiyee. All rights reserved.
|
|
4
4
|
* Commercial software. See LICENSE for terms.
|
|
5
5
|
* Official site: https://oiyo.js.org
|
|
6
6
|
*/
|
|
7
|
-
Object.defineProperty(exports,
|
|
8
|
-
var _dcloudio_uni_app = require("@dcloudio/uni-app");
|
|
9
|
-
Object.keys(_dcloudio_uni_app).forEach(function(k) {
|
|
10
|
-
if (k !== "default" && !Object.prototype.hasOwnProperty.call(exports, k)) Object.defineProperty(exports, k, {
|
|
11
|
-
enumerable: true,
|
|
12
|
-
get: function() {
|
|
13
|
-
return _dcloudio_uni_app[k];
|
|
14
|
-
}
|
|
15
|
-
});
|
|
16
|
-
});
|
|
7
|
+
Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});var e=require("@dcloudio/uni-app");Object.keys(e).forEach(function(t){t!=="default"&&!Object.prototype.hasOwnProperty.call(exports,t)&&Object.defineProperty(exports,t,{enumerable:!0,get:function(){return e[t]}})});
|
package/dist/uni.d.cts
CHANGED
package/dist/uni.d.mts
CHANGED
package/dist/uni.mjs
CHANGED
|
@@ -1,8 +1,7 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* @oiyo/framework v0.
|
|
2
|
+
* @oiyo/framework v0.5.0
|
|
3
3
|
* Copyright (c) 2026 skiyee. All rights reserved.
|
|
4
4
|
* Commercial software. See LICENSE for terms.
|
|
5
5
|
* Official site: https://oiyo.js.org
|
|
6
6
|
*/
|
|
7
|
-
export
|
|
8
|
-
export {};
|
|
7
|
+
export*from"@dcloudio/uni-app";export{};
|
package/dist/vue.cjs
CHANGED
|
@@ -1,16 +1,7 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* @oiyo/framework v0.
|
|
2
|
+
* @oiyo/framework v0.5.0
|
|
3
3
|
* Copyright (c) 2026 skiyee. All rights reserved.
|
|
4
4
|
* Commercial software. See LICENSE for terms.
|
|
5
5
|
* Official site: https://oiyo.js.org
|
|
6
6
|
*/
|
|
7
|
-
Object.defineProperty(exports,
|
|
8
|
-
var vue = require("vue");
|
|
9
|
-
Object.keys(vue).forEach(function(k) {
|
|
10
|
-
if (k !== "default" && !Object.prototype.hasOwnProperty.call(exports, k)) Object.defineProperty(exports, k, {
|
|
11
|
-
enumerable: true,
|
|
12
|
-
get: function() {
|
|
13
|
-
return vue[k];
|
|
14
|
-
}
|
|
15
|
-
});
|
|
16
|
-
});
|
|
7
|
+
Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});var e=require("vue");Object.keys(e).forEach(function(t){t!=="default"&&!Object.prototype.hasOwnProperty.call(exports,t)&&Object.defineProperty(exports,t,{enumerable:!0,get:function(){return e[t]}})});
|
package/dist/vue.d.cts
CHANGED
package/dist/vue.d.mts
CHANGED
package/dist/vue.mjs
CHANGED
|
@@ -1,8 +1,7 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* @oiyo/framework v0.
|
|
2
|
+
* @oiyo/framework v0.5.0
|
|
3
3
|
* Copyright (c) 2026 skiyee. All rights reserved.
|
|
4
4
|
* Commercial software. See LICENSE for terms.
|
|
5
5
|
* Official site: https://oiyo.js.org
|
|
6
6
|
*/
|
|
7
|
-
export
|
|
8
|
-
export {};
|
|
7
|
+
export*from"vue";export{};
|
package/package.json
CHANGED
package/dist/oiyo-BXNGL_oa.mjs
DELETED
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @oiyo/framework v0.4.9
|
|
3
|
-
* Copyright (c) 2026 skiyee. All rights reserved.
|
|
4
|
-
* Commercial software. See LICENSE for terms.
|
|
5
|
-
* Official site: https://oiyo.js.org
|
|
6
|
-
*/
|
|
7
|
-
const _0x5be832=_0x234c;(function(_0x5624d2,_0x2e5e92){const _0x741efa=_0x234c,_0x78a545=_0x5624d2();while(!![]){try{const _0xfd5f3e=-parseInt(_0x741efa(0xfb))/0x1+-parseInt(_0x741efa(0xd1))/0x2*(-parseInt(_0x741efa(0xe4))/0x3)+parseInt(_0x741efa(0xcd))/0x4+parseInt(_0x741efa(0x10c))/0x5*(parseInt(_0x741efa(0x100))/0x6)+parseInt(_0x741efa(0xf2))/0x7+parseInt(_0x741efa(0x106))/0x8+parseInt(_0x741efa(0x10b))/0x9*(-parseInt(_0x741efa(0xdd))/0xa);if(_0xfd5f3e===_0x2e5e92)break;else _0x78a545['push'](_0x78a545['shift']());}catch(_0x50553a){_0x78a545['push'](_0x78a545['shift']());}}}(_0xeeec,0xd8c32));function createHttpAborter(){const _0x5693d4=new HttpAbortSignal();return{'signal':_0x5693d4,'abort':_0xfad464=>_0x5693d4['_abort'](_0xfad464)};}function _0xeeec(){const _0x199e01=['10579464PkTkTJ','assign','responseType','response','The\x20operation\x20was\x20aborted','listeners','includes','<no\x20response\x20body>','defineProperty','728005ecWJWC','onSuccess','enableHttpDNS','GET','emit','732750LYXaOO','request','has','startsWith','slice','onFail','9687624tDrYxs','AbortError','firstIpv4','then','filePath','9dArHgm','55HpWJlN','POST','map','complete','filter','files','timeout','entries','number','headers','withCredentials','abort','download','signal','<no\x20response>','PATCH','splice','name','isArray','onabort','onChunkReceived','5088776JcrNDa','flatMap','toUpperCase','onProgressUpdate','12PoHNan','query','url','fileType','data','text','dataType','success','push','create','upload','formData','51322090BmJlOn','onHeadersReceived','sslVerify','statusCode','uploadFile','aborted','tempFilePath','705099FxRMVu','removeEventListener','reason','json','_action','body','test','file','enableCache','downloadFile','method','replace','catch','onResponse'];_0xeeec=function(){return _0x199e01;};return _0xeeec();}const ABORT_ERROR_NAME=_0x5be832(0x107);var AbortEmitter=class{['listeners']=[];['addEventListener'](_0x2c0ab6,_0x321f8e){const _0x1ee579=_0x5be832;if(_0x2c0ab6!=='abort')return;this['listeners'][_0x1ee579(0xd9)](_0x321f8e);}[_0x5be832(0xe5)](_0xf15582,_0x33f400){const _0x1f3f35=_0x5be832;if(_0xf15582!==_0x1f3f35(0xc3))return;const _0x55da68=this['listeners']['indexOf'](_0x33f400);if(_0x55da68!==-0x1)this[_0x1f3f35(0xf7)][_0x1f3f35(0xc8)](_0x55da68,0x1);}[_0x5be832(0xff)](_0x59e63b){const _0xa66d1c=_0x5be832;for(const _0x29cc45 of this['listeners'][_0xa66d1c(0x104)]())_0x29cc45['call'](this,_0x59e63b);}},HttpAbortSignal=class extends AbortEmitter{[_0x5be832(0xe2)]=![];[_0x5be832(0xe6)]=void 0x0;[_0x5be832(0xcb)]=null;['_abort'](_0x4ee2bb){const _0x7120a=_0x5be832;if(this[_0x7120a(0xe2)])return;this['aborted']=!![],this['reason']=_0x4ee2bb===void 0x0?createAbortError():_0x4ee2bb;const _0x296746={};_0x296746['type']='abort';const _0x3e40c0=_0x296746;if(typeof this[_0x7120a(0xcb)]==='function')this['onabort'](_0x3e40c0);this['emit'](_0x3e40c0);}['throwIfAborted'](){if(this['aborted'])throw this['reason'];}};function createAbortError(_0x4e17da=_0x5be832(0xf6)){const _0x1759fc=new Error(_0x4e17da);return _0x1759fc['name']=ABORT_ERROR_NAME,_0x1759fc;}function isAbortError(_0x2c9aca){const _0x4286d7=_0x5be832;return _0x2c9aca instanceof Error&&_0x2c9aca[_0x4286d7(0xc9)]===ABORT_ERROR_NAME;}function _0x234c(_0x31bbe6,_0x6300e5){_0x31bbe6=_0x31bbe6-0xba;const _0xeeecb7=_0xeeec();let _0x234c4d=_0xeeecb7[_0x31bbe6];return _0x234c4d;}function onAbort(_0x30edd6,_0x4bcd9c){const _0x33cddc=_0x5be832;if(!_0x30edd6)return()=>{};if(_0x30edd6[_0x33cddc(0xe2)])return _0x4bcd9c(),()=>{};return _0x30edd6['addEventListener'](_0x33cddc(0xc3),_0x4bcd9c),()=>_0x30edd6['removeEventListener'](_0x33cddc(0xc3),_0x4bcd9c);}const HOOK_NAMES=['onRequest','onRequestError','onResponse','onResponseError'];function mergeOptions(..._0x4d64c3){const _0x24ac55=_0x5be832,_0x1b69c9={},_0x165b7d={};for(const _0x1b53a2 of _0x4d64c3){if(!_0x1b53a2)continue;for(const _0x3292f2 of HOOK_NAMES)collectHook(_0x165b7d,_0x3292f2,_0x1b53a2);const _0x3bef7b=_0x1b69c9['headers'],_0xe5c9c2=_0x1b69c9['query'];Object['assign'](_0x1b69c9,_0x1b53a2);const _0x321b56={..._0x3bef7b,..._0x1b53a2[_0x24ac55(0xc1)]};_0x1b69c9[_0x24ac55(0xc1)]=_0x321b56;const _0x2fe4c8={..._0xe5c9c2,..._0x1b53a2[_0x24ac55(0xd2)]};_0x1b69c9['query']=_0x2fe4c8;}for(const [_0x1bfe59,_0x11caac]of Object[_0x24ac55(0xbf)](_0x165b7d))Object[_0x24ac55(0xf3)](_0x1b69c9,{[_0x1bfe59]:async _0x5c1829=>{for(const _0x30eb20 of _0x11caac)await _0x30eb20(_0x5c1829);}});return _0x1b69c9;}function collectHook(_0x556ba9,_0x2afbde,_0x3b1ab4){const _0x409956=_0x5be832,_0x198001=_0x3b1ab4[_0x2afbde];if(typeof _0x198001!=='function')return;_0x556ba9[_0x2afbde]??=[],_0x556ba9[_0x2afbde][_0x409956(0xd9)](_0x198001);}function dispatch(_0x5adf9d,_0x2bed50,_0x267114,_0x584f92){let _0x1e39c0;if(_0x5adf9d==='upload')_0x1e39c0=dispatchUpload(_0x2bed50,_0x267114,_0x584f92);else{if(_0x5adf9d==='download')_0x1e39c0=dispatchDownload(_0x2bed50,_0x267114,_0x584f92);else _0x1e39c0=dispatchRequest(_0x2bed50,_0x267114,_0x584f92);}bindTask(_0x1e39c0,_0x267114);}function bindTask(_0x9b32a5,_0x6fa55a){const _0x4c10ea=_0x5be832;onAbort(_0x6fa55a[_0x4c10ea(0xc5)],()=>_0x9b32a5['abort']());if(typeof _0x6fa55a['onHeadersReceived']==='function')_0x9b32a5[_0x4c10ea(0xde)](_0x6fa55a['onHeadersReceived']);const _0x187102=_0x6fa55a['onChunk'];if(typeof _0x187102==='function'&&_0x4c10ea(0xcc)in _0x9b32a5)_0x9b32a5[_0x4c10ea(0xcc)](_0x187102);const _0x6c855b=_0x6fa55a['onProgress'];if(typeof _0x6c855b==='function'&&_0x4c10ea(0xd0)in _0x9b32a5)_0x9b32a5[_0x4c10ea(0xd0)](_0x6c855b);}function dispatchRequest(_0x1ffc0a,_0x5f3031,_0x5afe76){const _0x39e7a2=_0x5be832,_0x5a2b67={'url':_0x1ffc0a,'method':_0x5f3031[_0x39e7a2(0xee)],'header':_0x5f3031[_0x39e7a2(0xc1)],'data':_0x5f3031[_0x39e7a2(0xe9)]??{},'timeout':_0x5f3031['timeout'],'dataType':_0x5f3031[_0x39e7a2(0xd7)]||_0x39e7a2(0xe7),'responseType':mappedResponseBodyType(_0x5f3031[_0x39e7a2(0xf4)]),'sslVerify':_0x5f3031[_0x39e7a2(0xdf)],'withCredentials':_0x5f3031[_0x39e7a2(0xc2)],'firstIpv4':_0x5f3031[_0x39e7a2(0x108)],'enableHttp2':_0x5f3031['enableHttp2'],'enableQuic':_0x5f3031['enableQuic'],'enableCache':_0x5f3031[_0x39e7a2(0xec)],'enableHttpDNS':_0x5f3031[_0x39e7a2(0xfd)],'httpDNSServiceId':_0x5f3031['httpDNSServiceId'],'enableChunked':_0x5f3031['enableChunked'],'forceCellularNetwork':_0x5f3031['forceCellularNetwork'],'success':_0x5afe76[_0x39e7a2(0xfc)],'fail':_0x5afe76[_0x39e7a2(0x105)],'complete':()=>{}};return uni['request'](_0x5a2b67);}function dispatchUpload(_0x41b556,_0x25dfad,_0x6a1dfd){const _0x3304b2=_0x5be832,_0x5ccfee={};_0x5ccfee[_0x3304b2(0xd3)]=_0x41b556,_0x5ccfee['fileType']=_0x25dfad[_0x3304b2(0xd4)],_0x5ccfee['file']=_0x25dfad[_0x3304b2(0xeb)],_0x5ccfee[_0x3304b2(0x10a)]=_0x25dfad['filePath'],_0x5ccfee['name']=_0x25dfad[_0x3304b2(0xc9)]??_0x3304b2(0xeb),_0x5ccfee[_0x3304b2(0xbd)]=_0x25dfad[_0x3304b2(0xbd)],_0x5ccfee['header']=_0x25dfad['headers'],_0x5ccfee[_0x3304b2(0xdc)]=_0x25dfad[_0x3304b2(0xe9)]??{},_0x5ccfee[_0x3304b2(0xbe)]=_0x25dfad[_0x3304b2(0xbe)],_0x5ccfee[_0x3304b2(0xd8)]=_0x6a1dfd['onSuccess'],_0x5ccfee['fail']=_0x6a1dfd[_0x3304b2(0x105)],_0x5ccfee[_0x3304b2(0xbb)]=()=>{};const _0x1dee32=_0x5ccfee;return uni[_0x3304b2(0xe1)](_0x1dee32);}function dispatchDownload(_0xdea449,_0x1bde4e,_0x4be6d8){const _0x53c775=_0x5be832,_0x220d13={'url':_0xdea449,'header':_0x1bde4e['headers'],'timeout':_0x1bde4e['timeout'],'success':_0x6a239=>{const _0x545d87=_0x234c,_0x41edad={..._0x6a239};_0x41edad[_0x545d87(0xd5)]={},_0x41edad[_0x545d87(0xd5)][_0x545d87(0xe3)]=_0x6a239[_0x545d87(0xe3)],_0x4be6d8[_0x545d87(0xfc)](_0x41edad);},'fail':_0x4be6d8[_0x53c775(0x105)],'complete':()=>{}};return uni[_0x53c775(0xed)](_0x220d13);}function mappedResponseBodyType(_0x4f9bc7){const _0x3041bf=_0x5be832;if(!_0x4f9bc7||_0x4f9bc7===_0x3041bf(0xe7))return'text';if(_0x4f9bc7==='arrayBuffer')return'arraybuffer';return _0x3041bf(0xd6);}var HttpError=class extends Error{constructor(_0x28d7c6){const _0x36426e=_0x5be832;super(_0x28d7c6),this[_0x36426e(0xc9)]='HttpError';}};function createResponseError(_0x25dcd4,_0x13fbdb,_0xff3b5b){const _0x2d6239=_0x5be832,_0x55d668=_0x25dcd4,_0x54b7b6='['+(_0x13fbdb?.['method']||'GET')+']\x20'+_0x55d668,_0x1e1624=_0xff3b5b?_0xff3b5b['statusCode']+'\x20'+(_0xff3b5b['errMsg']||''):_0x2d6239(0xc6),_0x148608=_0xff3b5b?JSON['stringify'](_0xff3b5b['data']):_0x2d6239(0xf9),_0x3d0290=new HttpError(_0x54b7b6+':\x20'+_0x1e1624+(_0xff3b5b['data']?'\x20'+_0x148608:''));for(const _0xa0bc48 of[_0x2d6239(0x101),'options','response','data'])Object[_0x2d6239(0xfa)](_0x3d0290,_0xa0bc48,{'get'(){const _0x1807db=_0x2d6239,_0x3b29b8={};return _0x3b29b8[_0x1807db(0x101)]=_0x25dcd4,_0x3b29b8['options']=_0x13fbdb,_0x3b29b8['response']=_0xff3b5b,_0x3b29b8[_0x1807db(0xd5)]=_0xff3b5b[_0x1807db(0xd5)],_0x3b29b8[_0xa0bc48];}});return _0x3d0290;}function normalizeError(_0x3fca60){if(_0x3fca60 instanceof Error)return _0x3fca60;return Object['assign'](new Error(_0x3fca60?.['errMsg']||_0x3fca60?.['message']||'HTTP\x20request\x20failed'),{'cause':_0x3fca60});}async function callRequestHooks(_0x4d5d5b,_0x37936d){await _0x37936d['onRequest']?.({'options':_0x37936d,'resource':_0x4d5d5b});}async function callRequestErrorHooks(_0x38d21c,_0x5c7121,_0x5adbb8){await _0x5c7121['onRequestError']?.({'options':_0x5c7121,'resource':_0x38d21c,'error':_0x5adbb8});}async function callResponseHooks(_0x12ed06,_0x56e203,_0x36ca7c){const _0x64fe60=_0x5be832;await _0x56e203[_0x64fe60(0xf1)]?.({'options':_0x56e203,'resource':_0x12ed06,'response':_0x36ca7c});}async function callResponseErrorHooks(_0x1d50ff,_0x77b3d9,_0x3571e0){await _0x77b3d9['onResponseError']?.({'options':_0x77b3d9,'resource':_0x1d50ff,'response':_0x3571e0});}async function refineResponse(_0x328da8,_0x15a1b8){if(_0x15a1b8['responseType']==='json'||!_0x15a1b8['responseType'])return{..._0x328da8,'data':await parseJSONResponse(_0x328da8['data'],_0x15a1b8)};return _0x328da8;}function parseJSONResponse(_0x2c72d4,_0x465be2){if(typeof _0x2c72d4!=='string')return _0x2c72d4;if(_0x465be2['parseResponse'])return _0x465be2['parseResponse'](_0x2c72d4);return _0x2c72d4?JSON['parse'](_0x2c72d4):null;}function isResponseError(_0xa973b8){const _0x30d600=_0x5be832,_0x17f130='statusCode'in _0xa973b8?_0xa973b8[_0x30d600(0xe0)]:void 0x0;return typeof _0x17f130===_0x30d600(0xc0)&&(_0x17f130<0xc8||_0x17f130>=0x12c);}const DEFAULT_RETRY_STATUS_CODES=[0x198,0x199,0x1a9,0x1ad,0x1f4,0x1f6,0x1f7,0x1f8],PAYLOAD_METHODS=new Set([_0x5be832(0x10d),'PUT','DELETE',_0x5be832(0xc7)]);async function withRetry(_0x5afcf4,_0x13febd){const _0xdffa61=_0x5be832,_0x41ff68=resolveRetryCount(_0x5afcf4);for(let _0x5e503e=0x0;;_0x5e503e++)try{return await _0x13febd();}catch(_0x2aefb5){if(_0x5e503e>=_0x41ff68||!shouldRetry(_0x2aefb5,_0x5afcf4))throw _0x2aefb5;await sleep(_0x5afcf4['retryDelay']??0x0,_0x5afcf4[_0xdffa61(0xc5)]);}}function resolveRetryCount(_0x5809ee){const _0x4aedd6=_0x5be832,{retry:_0x27ca97}=_0x5809ee;if(_0x27ca97===![])return 0x0;if(typeof _0x27ca97===_0x4aedd6(0xc0))return _0x27ca97>0x0?_0x27ca97:0x0;return isPayloadMethod(_0x5809ee['method'])?0x0:0x1;}function shouldRetry(_0x524f00,_0x38b58d){const _0x325c2f=_0x5be832;if(_0x38b58d['signal']?.[_0x325c2f(0xe2)]||isAbortError(_0x524f00))return![];const _0x54c746=_0x524f00?.[_0x325c2f(0xf5)]?.['statusCode'];if(typeof _0x54c746!=='number')return!![];return(_0x38b58d['retryStatusCodes']??DEFAULT_RETRY_STATUS_CODES)[_0x325c2f(0xf8)](_0x54c746);}function isPayloadMethod(_0x15a15f){const _0x557fe5=_0x5be832;return!!_0x15a15f&&PAYLOAD_METHODS[_0x557fe5(0x102)](_0x15a15f[_0x557fe5(0xcf)]());}function sleep(_0x7c99c0,_0x4a52ca){return new Promise((_0x3140ad,_0x82a108)=>{const _0x41797f=_0x234c;if(_0x4a52ca?.[_0x41797f(0xe2)]){_0x82a108(_0x4a52ca[_0x41797f(0xe6)]);return;}if(!(_0x7c99c0>0x0)){_0x3140ad();return;}let _0x2bdd42=()=>{};const _0x111724=setTimeout(()=>{_0x2bdd42(),_0x3140ad();},_0x7c99c0);_0x2bdd42=onAbort(_0x4a52ca,()=>{clearTimeout(_0x111724),_0x82a108(_0x4a52ca['reason']);});});}function buildURL(_0x41eb81,_0x28096e){const _0x2b16a6=_0x5be832,_0x5daf06=joinURL(_0x28096e['baseURL'],_0x41eb81),_0x38dc2e=_0x28096e['query']??{},_0x2c000d=Object['keys'](_0x38dc2e)[_0x2b16a6(0xbc)](_0x2add86=>_0x38dc2e[_0x2add86]!==void 0x0)[_0x2b16a6(0xce)](_0x1a8675=>{const _0x716409=_0x2b16a6,_0x44efc6=_0x38dc2e[_0x1a8675];return(Array[_0x716409(0xca)](_0x44efc6)?_0x44efc6:[_0x44efc6])[_0x716409(0xba)](_0x146632=>encodeURIComponent(_0x1a8675)+'='+encodeURIComponent(String(_0x146632)));})['join']('&');if(!_0x2c000d)return _0x5daf06;return''+_0x5daf06+(_0x5daf06[_0x2b16a6(0xf8)]('?')?'&':'?')+_0x2c000d;}function joinURL(_0x40b5b2,_0x6e8864){const _0x45459b=_0x5be832;if(!_0x40b5b2||isAbsoluteURL(_0x6e8864))return _0x6e8864;return _0x40b5b2[_0x45459b(0xef)](/\/+$/,'')+'/'+_0x6e8864[_0x45459b(0xef)](/^\/+/,'');}function isAbsoluteURL(_0x208f49){const _0x2293d3=_0x5be832;return/^[a-z][a-z\d+\-.]*:\/\//i[_0x2293d3(0xea)](_0x208f49)||_0x208f49[_0x2293d3(0x103)]('//');}function dispatchHttp(_0x579757,_0xbfd4d6,_0x483467){const _0x5a6b9a=buildURL(_0xbfd4d6,_0x483467);return withRetry(_0x483467,()=>attemptRequest(_0x579757,_0xbfd4d6,_0x5a6b9a,_0x483467));}function attemptRequest(_0x1f66f1,_0x4cae6b,_0x578ef5,_0x51b471){const _0x3d111f=!!_0x51b471['raw'];return new Promise((_0x39882d,_0x26a7b5)=>{const _0x2f7c0a=_0x234c;let _0x100207=![];const _0x4c4075=_0x594acb=>{if(_0x100207)return;_0x100207=!![],_0x594acb();},_0xab50cc=onAbort(_0x51b471['signal'],()=>{const _0x461756=_0x234c;_0x4c4075(()=>_0x26a7b5(_0x51b471[_0x461756(0xc5)][_0x461756(0xe6)]));}),_0x1099fc=_0x13ea98=>{_0xab50cc(),_0x4c4075(_0x13ea98);};callRequestHooks(_0x4cae6b,_0x51b471)['then'](()=>{if(_0x100207)return;dispatch(_0x1f66f1,_0x578ef5,_0x51b471,{'onSuccess':_0x4e4c23=>{const _0xae3892=_0x234c;Promise['resolve']()[_0xae3892(0x109)](()=>refineResponse(_0x4e4c23,_0x51b471))['then'](async _0xfa6309=>{if(isResponseError(_0x4e4c23)){await callResponseErrorHooks(_0x4cae6b,_0x51b471,_0xfa6309);if(!_0x51b471['ignoreResponseError'])throw createResponseError(_0x4cae6b,_0x51b471,_0xfa6309);}else await callResponseHooks(_0x4cae6b,_0x51b471,_0xfa6309);_0x1099fc(()=>_0x39882d(_0x3d111f?_0xfa6309:_0xfa6309['data']));})['catch'](_0x2b1f15=>_0x1099fc(()=>_0x26a7b5(_0x2b1f15)));},'onFail':_0x2e3f0e=>{const _0x356170=_0x234c;Promise['resolve']()[_0x356170(0x109)](async()=>{const _0x5189de=normalizeError(_0x2e3f0e);if(!isAbortError(_0x5189de))await callRequestErrorHooks(_0x4cae6b,_0x51b471,_0x5189de);throw _0x5189de;})['catch'](_0x5cf676=>_0x1099fc(()=>_0x26a7b5(_0x5cf676)));}});})[_0x2f7c0a(0xf0)](async _0x372187=>{const _0x464cc9=normalizeError(_0x372187);await callRequestErrorHooks(_0x4cae6b,_0x51b471,_0x464cc9),_0x1099fc(()=>_0x26a7b5(_0x464cc9));});});}const _0x35faf1={};_0x35faf1[_0x5be832(0xee)]='GET',_0x35faf1[_0x5be832(0xf4)]='json';const defaultConfig=_0x35faf1;function createHttp(_0x115a21={}){const _0x4e455a=_0x5be832,_0x5ba2c9=(_0x59c518,_0x941336)=>{const _0x1ddfe2=_0x234c,_0x4c397c={};return _0x4c397c['_action']='request',dispatchHttp(_0x1ddfe2(0x101),_0x59c518,mergeOptions(defaultConfig,_0x115a21,_0x941336,_0x4c397c));},_0x19535d=(_0x4ab800,_0x2eac96)=>{const _0x51cae2=_0x234c,_0x664bea={};return _0x664bea['method']=_0x51cae2(0x10d),_0x664bea[_0x51cae2(0xe8)]=_0x51cae2(0xdb),dispatchHttp(_0x51cae2(0xdb),_0x4ab800,mergeOptions(defaultConfig,_0x115a21,_0x2eac96,_0x664bea));},_0x29286f=(_0x553794,_0x417aa7)=>{const _0x2b5546=_0x234c,_0x40290d={};return _0x40290d['method']=_0x2b5546(0xfe),_0x40290d['_action']=_0x2b5546(0xc4),dispatchHttp(_0x2b5546(0xc4),_0x553794,mergeOptions(defaultConfig,_0x115a21,_0x417aa7,_0x40290d));},_0x5384d1=_0x5c2920=>createHttp(mergeOptions(_0x115a21,_0x5c2920)),_0x331af2={};return _0x331af2['request']=_0x5ba2c9,_0x331af2[_0x4e455a(0xdb)]=_0x19535d,_0x331af2[_0x4e455a(0xc4)]=_0x29286f,_0x331af2[_0x4e455a(0xda)]=_0x5384d1,_0x331af2;}const http=createHttp();export{http as n,createHttpAborter as r,createHttp as t};
|
package/dist/oiyo-CUAtDW_Y.cjs
DELETED
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @oiyo/framework v0.4.9
|
|
3
|
-
* Copyright (c) 2026 skiyee. All rights reserved.
|
|
4
|
-
* Commercial software. See LICENSE for terms.
|
|
5
|
-
* Official site: https://oiyo.js.org
|
|
6
|
-
*/
|
|
7
|
-
function _0x113e(){const _0x983e9d=['addEventListener','onSuccess','data','download','274728vUbQvW','signal','PATCH','function','timeout','filter','test','onabort','onRequest','PUT','161yuyhAS','parseResponse','options','assign','statusCode','get','firstIpv4','3DpYGYD','message','onProgress','file','onHeadersReceived','arraybuffer','json','flatMap','stringify','header','upload','splice','ignoreResponseError','parse','text','GET','onResponse','files','keys','retryStatusCodes','HttpError','POST','onRequestError','2396801JlrgZd','headers','4Xhhkyp','throwIfAborted','complete','createHttp','listeners','forceCellularNetwork','enableHttpDNS','number','map','method','defineProperty','body','enumerable','<no\x20response>','createHttpAborter','name','AbortError','response','errMsg','tempFilePath','resolve','httpDNSServiceId','formData','aborted','15887ksHKCJ','enableCache','DELETE','_action','reason','616266NLdVpv','push','abort','1542672SLQkFB','indexOf','2018920FGledO','catch','emit','87704rMPBdW','responseType','includes','request','fileType','call','5xkCRVT','onFail'];_0x113e=function(){return _0x983e9d;};return _0x113e();}const _0x1889f2=_0x153b;(function(_0x44e069,_0x4cc62d){const _0x4f9c54=_0x153b,_0x52275d=_0x44e069();while(!![]){try{const _0x142dfa=parseInt(_0x4f9c54(0x1a4))/0x1*(-parseInt(_0x4f9c54(0x18c))/0x2)+-parseInt(_0x4f9c54(0x173))/0x3*(-parseInt(_0x4f9c54(0x162))/0x4)+parseInt(_0x4f9c54(0x15c))/0x5*(parseInt(_0x4f9c54(0x1a9))/0x6)+parseInt(_0x4f9c54(0x16c))/0x7*(parseInt(_0x4f9c54(0x156))/0x8)+parseInt(_0x4f9c54(0x1ac))/0x9+-parseInt(_0x4f9c54(0x153))/0xa+-parseInt(_0x4f9c54(0x18a))/0xb;if(_0x142dfa===_0x4cc62d)break;else _0x52275d['push'](_0x52275d['shift']());}catch(_0xf522c3){_0x52275d['push'](_0x52275d['shift']());}}}(_0x113e,0x23021));function createHttpAborter(){const _0x50be6a=new HttpAbortSignal();return{'signal':_0x50be6a,'abort':_0x5b6b1d=>_0x50be6a['_abort'](_0x5b6b1d)};}const ABORT_ERROR_NAME=_0x1889f2(0x19c);var AbortEmitter=class{[_0x1889f2(0x190)]=[];[_0x1889f2(0x15e)](_0x3fd989,_0x1ea8e0){const _0xf40307=_0x1889f2;if(_0x3fd989!==_0xf40307(0x1ab))return;this[_0xf40307(0x190)][_0xf40307(0x1aa)](_0x1ea8e0);}['removeEventListener'](_0x57cc1c,_0x30f1f7){const _0x2ad128=_0x1889f2;if(_0x57cc1c!=='abort')return;const _0x14efca=this['listeners'][_0x2ad128(0x1ad)](_0x30f1f7);if(_0x14efca!==-0x1)this['listeners'][_0x2ad128(0x17e)](_0x14efca,0x1);}['emit'](_0x25fff8){const _0x4c8964=_0x1889f2;for(const _0x52b2a0 of this[_0x4c8964(0x190)]['slice']())_0x52b2a0[_0x4c8964(0x15b)](this,_0x25fff8);}},HttpAbortSignal=class extends AbortEmitter{[_0x1889f2(0x1a3)]=![];[_0x1889f2(0x1a8)]=void 0x0;[_0x1889f2(0x169)]=null;['_abort'](_0x494b57){const _0x445237=_0x1889f2;if(this['aborted'])return;this[_0x445237(0x1a3)]=!![],this['reason']=_0x494b57===void 0x0?createAbortError():_0x494b57;const _0x3c8abb={};_0x3c8abb['type']=_0x445237(0x1ab);const _0x2bf0f6=_0x3c8abb;if(typeof this[_0x445237(0x169)]===_0x445237(0x165))this['onabort'](_0x2bf0f6);this[_0x445237(0x155)](_0x2bf0f6);}[_0x1889f2(0x18d)](){const _0xeff6c5=_0x1889f2;if(this[_0xeff6c5(0x1a3)])throw this['reason'];}};function createAbortError(_0x57dfd8='The\x20operation\x20was\x20aborted'){const _0x19d58b=new Error(_0x57dfd8);return _0x19d58b['name']=ABORT_ERROR_NAME,_0x19d58b;}function isAbortError(_0x3a40e0){return _0x3a40e0 instanceof Error&&_0x3a40e0['name']===ABORT_ERROR_NAME;}function onAbort(_0x417b63,_0x3ca7ad){const _0x1b42c6=_0x1889f2;if(!_0x417b63)return()=>{};if(_0x417b63[_0x1b42c6(0x1a3)])return _0x3ca7ad(),()=>{};return _0x417b63['addEventListener'](_0x1b42c6(0x1ab),_0x3ca7ad),()=>_0x417b63['removeEventListener']('abort',_0x3ca7ad);}const HOOK_NAMES=['onRequest',_0x1889f2(0x189),'onResponse','onResponseError'];function mergeOptions(..._0x4034c9){const _0x24cc83=_0x1889f2,_0x56abea={},_0x473c0d={};for(const _0x95aac6 of _0x4034c9){if(!_0x95aac6)continue;for(const _0x442457 of HOOK_NAMES)collectHook(_0x473c0d,_0x442457,_0x95aac6);const _0x355f3f=_0x56abea['headers'],_0x449028=_0x56abea['query'];Object[_0x24cc83(0x16f)](_0x56abea,_0x95aac6);const _0x20ed85={..._0x355f3f,..._0x95aac6[_0x24cc83(0x18b)]};_0x56abea['headers']=_0x20ed85;const _0x54a190={..._0x449028,..._0x95aac6['query']};_0x56abea['query']=_0x54a190;}for(const [_0x3e130e,_0x202aea]of Object['entries'](_0x473c0d))Object[_0x24cc83(0x16f)](_0x56abea,{[_0x3e130e]:async _0x14017f=>{for(const _0x1cb16b of _0x202aea)await _0x1cb16b(_0x14017f);}});return _0x56abea;}function collectHook(_0x59f1d3,_0x107605,_0x4bdf40){const _0x24f166=_0x4bdf40[_0x107605];if(typeof _0x24f166!=='function')return;_0x59f1d3[_0x107605]??=[],_0x59f1d3[_0x107605]['push'](_0x24f166);}function dispatch(_0x3bcdae,_0x11799a,_0x17b405,_0x478591){const _0x5e10e1=_0x1889f2;let _0x5706b7;if(_0x3bcdae===_0x5e10e1(0x17d))_0x5706b7=dispatchUpload(_0x11799a,_0x17b405,_0x478591);else{if(_0x3bcdae==='download')_0x5706b7=dispatchDownload(_0x11799a,_0x17b405,_0x478591);else _0x5706b7=dispatchRequest(_0x11799a,_0x17b405,_0x478591);}bindTask(_0x5706b7,_0x17b405);}function bindTask(_0xf31368,_0x53e971){const _0x3daa56=_0x1889f2;onAbort(_0x53e971['signal'],()=>_0xf31368['abort']());if(typeof _0x53e971['onHeadersReceived']===_0x3daa56(0x165))_0xf31368['onHeadersReceived'](_0x53e971[_0x3daa56(0x177)]);const _0x19a750=_0x53e971['onChunk'];if(typeof _0x19a750===_0x3daa56(0x165)&&'onChunkReceived'in _0xf31368)_0xf31368['onChunkReceived'](_0x19a750);const _0x4feb08=_0x53e971[_0x3daa56(0x175)];if(typeof _0x4feb08==='function'&&'onProgressUpdate'in _0xf31368)_0xf31368['onProgressUpdate'](_0x4feb08);}function dispatchRequest(_0x16fd73,_0x37e054,_0x5ccd73){const _0x3541a7=_0x1889f2,_0x41c35f={'url':_0x16fd73,'method':_0x37e054['method'],'header':_0x37e054[_0x3541a7(0x18b)],'data':_0x37e054['body']??{},'timeout':_0x37e054[_0x3541a7(0x166)],'dataType':_0x37e054['dataType']||_0x3541a7(0x179),'responseType':mappedResponseBodyType(_0x37e054[_0x3541a7(0x157)]),'sslVerify':_0x37e054['sslVerify'],'withCredentials':_0x37e054['withCredentials'],'firstIpv4':_0x37e054[_0x3541a7(0x172)],'enableHttp2':_0x37e054['enableHttp2'],'enableQuic':_0x37e054['enableQuic'],'enableCache':_0x37e054[_0x3541a7(0x1a5)],'enableHttpDNS':_0x37e054[_0x3541a7(0x192)],'httpDNSServiceId':_0x37e054[_0x3541a7(0x1a1)],'enableChunked':_0x37e054['enableChunked'],'forceCellularNetwork':_0x37e054[_0x3541a7(0x191)],'success':_0x5ccd73[_0x3541a7(0x15f)],'fail':_0x5ccd73[_0x3541a7(0x15d)],'complete':()=>{}};return uni['request'](_0x41c35f);}function dispatchUpload(_0x5290d4,_0x3ff79d,_0x3d0f0e){const _0x4d75c9=_0x1889f2,_0x276add={};_0x276add['url']=_0x5290d4,_0x276add[_0x4d75c9(0x15a)]=_0x3ff79d['fileType'],_0x276add['file']=_0x3ff79d[_0x4d75c9(0x176)],_0x276add['filePath']=_0x3ff79d['filePath'],_0x276add['name']=_0x3ff79d['name']??'file',_0x276add[_0x4d75c9(0x184)]=_0x3ff79d[_0x4d75c9(0x184)],_0x276add[_0x4d75c9(0x17c)]=_0x3ff79d['headers'],_0x276add[_0x4d75c9(0x1a2)]=_0x3ff79d[_0x4d75c9(0x197)]??{},_0x276add['timeout']=_0x3ff79d['timeout'],_0x276add['success']=_0x3d0f0e['onSuccess'],_0x276add['fail']=_0x3d0f0e['onFail'],_0x276add[_0x4d75c9(0x18e)]=()=>{};const _0x2e2d34=_0x276add;return uni['uploadFile'](_0x2e2d34);}function dispatchDownload(_0x944d84,_0x3ff9ea,_0x180b97){const _0x59bf66={'url':_0x944d84,'header':_0x3ff9ea['headers'],'timeout':_0x3ff9ea['timeout'],'success':_0x21df58=>{const _0x293b9c=_0x153b,_0x2d8eed={..._0x21df58};_0x2d8eed[_0x293b9c(0x160)]={},_0x2d8eed[_0x293b9c(0x160)][_0x293b9c(0x19f)]=_0x21df58[_0x293b9c(0x19f)],_0x180b97[_0x293b9c(0x15f)](_0x2d8eed);},'fail':_0x180b97['onFail'],'complete':()=>{}};return uni['downloadFile'](_0x59bf66);}function mappedResponseBodyType(_0x3a8187){const _0x1229e0=_0x1889f2;if(!_0x3a8187||_0x3a8187===_0x1229e0(0x179))return _0x1229e0(0x181);if(_0x3a8187==='arrayBuffer')return _0x1229e0(0x178);return _0x1229e0(0x181);}var HttpError=class extends Error{constructor(_0x262d8b){const _0x2990a6=_0x1889f2;super(_0x262d8b),this[_0x2990a6(0x19b)]=_0x2990a6(0x187);}};function createResponseError(_0x1597c7,_0x2ce43c,_0x242c26){const _0x47fd06=_0x1889f2,_0x4ee9b4=_0x1597c7,_0x4e9b5e='['+(_0x2ce43c?.[_0x47fd06(0x195)]||'GET')+']\x20'+_0x4ee9b4,_0x3d000c=_0x242c26?_0x242c26[_0x47fd06(0x170)]+'\x20'+(_0x242c26[_0x47fd06(0x19e)]||''):_0x47fd06(0x199),_0x5337e4=_0x242c26?JSON[_0x47fd06(0x17b)](_0x242c26[_0x47fd06(0x160)]):'<no\x20response\x20body>',_0x763c2e=new HttpError(_0x4e9b5e+':\x20'+_0x3d000c+(_0x242c26['data']?'\x20'+_0x5337e4:''));for(const _0x5b43d0 of['request',_0x47fd06(0x16e),_0x47fd06(0x19d),_0x47fd06(0x160)])Object[_0x47fd06(0x196)](_0x763c2e,_0x5b43d0,{'get'(){const _0x388599=_0x47fd06,_0x4708c={};return _0x4708c[_0x388599(0x159)]=_0x1597c7,_0x4708c['options']=_0x2ce43c,_0x4708c[_0x388599(0x19d)]=_0x242c26,_0x4708c[_0x388599(0x160)]=_0x242c26[_0x388599(0x160)],_0x4708c[_0x5b43d0];}});return _0x763c2e;}function normalizeError(_0x56e7d3){const _0x212088=_0x1889f2;if(_0x56e7d3 instanceof Error)return _0x56e7d3;return Object['assign'](new Error(_0x56e7d3?.[_0x212088(0x19e)]||_0x56e7d3?.[_0x212088(0x174)]||'HTTP\x20request\x20failed'),{'cause':_0x56e7d3});}async function callRequestHooks(_0x502e44,_0x4b00cb){const _0x1b2eae=_0x1889f2;await _0x4b00cb[_0x1b2eae(0x16a)]?.({'options':_0x4b00cb,'resource':_0x502e44});}async function callRequestErrorHooks(_0x177434,_0x3bee86,_0x583787){await _0x3bee86['onRequestError']?.({'options':_0x3bee86,'resource':_0x177434,'error':_0x583787});}async function callResponseHooks(_0x31dd26,_0x47a2f6,_0x175459){const _0x32078a=_0x1889f2;await _0x47a2f6[_0x32078a(0x183)]?.({'options':_0x47a2f6,'resource':_0x31dd26,'response':_0x175459});}async function callResponseErrorHooks(_0x5d7492,_0x3c7b6e,_0x827b34){await _0x3c7b6e['onResponseError']?.({'options':_0x3c7b6e,'resource':_0x5d7492,'response':_0x827b34});}async function refineResponse(_0xc7049a,_0x40fbfb){const _0x301806=_0x1889f2;if(_0x40fbfb[_0x301806(0x157)]==='json'||!_0x40fbfb['responseType'])return{..._0xc7049a,'data':await parseJSONResponse(_0xc7049a['data'],_0x40fbfb)};return _0xc7049a;}function parseJSONResponse(_0x220570,_0x46a06a){const _0x110dcc=_0x1889f2;if(typeof _0x220570!=='string')return _0x220570;if(_0x46a06a['parseResponse'])return _0x46a06a[_0x110dcc(0x16d)](_0x220570);return _0x220570?JSON[_0x110dcc(0x180)](_0x220570):null;}function isResponseError(_0x1faf6d){const _0x1d0a5b=_0x1889f2,_0x2b37ed='statusCode'in _0x1faf6d?_0x1faf6d[_0x1d0a5b(0x170)]:void 0x0;return typeof _0x2b37ed===_0x1d0a5b(0x193)&&(_0x2b37ed<0xc8||_0x2b37ed>=0x12c);}const DEFAULT_RETRY_STATUS_CODES=[0x198,0x199,0x1a9,0x1ad,0x1f4,0x1f6,0x1f7,0x1f8],PAYLOAD_METHODS=new Set(['POST',_0x1889f2(0x16b),_0x1889f2(0x1a6),_0x1889f2(0x164)]);async function withRetry(_0x2a3050,_0x5b6033){const _0xea3c22=resolveRetryCount(_0x2a3050);for(let _0x2bbd4a=0x0;;_0x2bbd4a++)try{return await _0x5b6033();}catch(_0x406bd9){if(_0x2bbd4a>=_0xea3c22||!shouldRetry(_0x406bd9,_0x2a3050))throw _0x406bd9;await sleep(_0x2a3050['retryDelay']??0x0,_0x2a3050['signal']);}}function resolveRetryCount(_0x159a67){const _0x44a66b=_0x1889f2,{retry:_0x2af424}=_0x159a67;if(_0x2af424===![])return 0x0;if(typeof _0x2af424===_0x44a66b(0x193))return _0x2af424>0x0?_0x2af424:0x0;return isPayloadMethod(_0x159a67['method'])?0x0:0x1;}function shouldRetry(_0x594825,_0x306fae){const _0x4996b0=_0x1889f2;if(_0x306fae['signal']?.['aborted']||isAbortError(_0x594825))return![];const _0x500a7f=_0x594825?.[_0x4996b0(0x19d)]?.['statusCode'];if(typeof _0x500a7f!==_0x4996b0(0x193))return!![];return(_0x306fae[_0x4996b0(0x186)]??DEFAULT_RETRY_STATUS_CODES)[_0x4996b0(0x158)](_0x500a7f);}function isPayloadMethod(_0x145496){return!!_0x145496&&PAYLOAD_METHODS['has'](_0x145496['toUpperCase']());}function sleep(_0x444204,_0x502f94){return new Promise((_0xda734a,_0x24a5e1)=>{const _0x3c806d=_0x153b;if(_0x502f94?.[_0x3c806d(0x1a3)]){_0x24a5e1(_0x502f94['reason']);return;}if(!(_0x444204>0x0)){_0xda734a();return;}let _0x40595f=()=>{};const _0x3cad0b=setTimeout(()=>{_0x40595f(),_0xda734a();},_0x444204);_0x40595f=onAbort(_0x502f94,()=>{clearTimeout(_0x3cad0b),_0x24a5e1(_0x502f94['reason']);});});}function _0x153b(_0x2722dd,_0x58bcc6){_0x2722dd=_0x2722dd-0x153;const _0x113e33=_0x113e();let _0x153bda=_0x113e33[_0x2722dd];return _0x153bda;}function buildURL(_0x2b6a60,_0x43e841){const _0x10fbcd=_0x1889f2,_0x1982dc=joinURL(_0x43e841['baseURL'],_0x2b6a60),_0x13fb28=_0x43e841['query']??{},_0x1393d6=Object[_0x10fbcd(0x185)](_0x13fb28)[_0x10fbcd(0x167)](_0x1568b8=>_0x13fb28[_0x1568b8]!==void 0x0)[_0x10fbcd(0x17a)](_0x430977=>{const _0x1da221=_0x10fbcd,_0x54d388=_0x13fb28[_0x430977];return(Array['isArray'](_0x54d388)?_0x54d388:[_0x54d388])[_0x1da221(0x194)](_0x3458f7=>encodeURIComponent(_0x430977)+'='+encodeURIComponent(String(_0x3458f7)));})['join']('&');if(!_0x1393d6)return _0x1982dc;return''+_0x1982dc+(_0x1982dc[_0x10fbcd(0x158)]('?')?'&':'?')+_0x1393d6;}function joinURL(_0x468db4,_0x340229){if(!_0x468db4||isAbsoluteURL(_0x340229))return _0x340229;return _0x468db4['replace'](/\/+$/,'')+'/'+_0x340229['replace'](/^\/+/,'');}function isAbsoluteURL(_0x596ebb){const _0x3e6e63=_0x1889f2;return/^[a-z][a-z\d+\-.]*:\/\//i[_0x3e6e63(0x168)](_0x596ebb)||_0x596ebb['startsWith']('//');}function dispatchHttp(_0x537e28,_0x3554f0,_0x5e9658){const _0xf37c1a=buildURL(_0x3554f0,_0x5e9658);return withRetry(_0x5e9658,()=>attemptRequest(_0x537e28,_0x3554f0,_0xf37c1a,_0x5e9658));}function attemptRequest(_0x4c39aa,_0x3fd260,_0x465ba0,_0x4cfb4b){const _0x42fcdb=!!_0x4cfb4b['raw'];return new Promise((_0x3b9452,_0x97a517)=>{const _0x94510=_0x153b;let _0x169258=![];const _0x3cf977=_0x242510=>{if(_0x169258)return;_0x169258=!![],_0x242510();},_0x46ff8a=onAbort(_0x4cfb4b[_0x94510(0x163)],()=>{const _0x58be3a=_0x94510;_0x3cf977(()=>_0x97a517(_0x4cfb4b[_0x58be3a(0x163)][_0x58be3a(0x1a8)]));}),_0x57c3fb=_0x5d5752=>{_0x46ff8a(),_0x3cf977(_0x5d5752);};callRequestHooks(_0x3fd260,_0x4cfb4b)['then'](()=>{if(_0x169258)return;dispatch(_0x4c39aa,_0x465ba0,_0x4cfb4b,{'onSuccess':_0x2bc049=>{const _0x4fb0b1=_0x153b;Promise['resolve']()['then'](()=>refineResponse(_0x2bc049,_0x4cfb4b))['then'](async _0x13b704=>{const _0x45fbdd=_0x153b;if(isResponseError(_0x2bc049)){await callResponseErrorHooks(_0x3fd260,_0x4cfb4b,_0x13b704);if(!_0x4cfb4b[_0x45fbdd(0x17f)])throw createResponseError(_0x3fd260,_0x4cfb4b,_0x13b704);}else await callResponseHooks(_0x3fd260,_0x4cfb4b,_0x13b704);_0x57c3fb(()=>_0x3b9452(_0x42fcdb?_0x13b704:_0x13b704['data']));})[_0x4fb0b1(0x154)](_0x5465e1=>_0x57c3fb(()=>_0x97a517(_0x5465e1)));},'onFail':_0x517d32=>{const _0x5c2d0c=_0x153b;Promise[_0x5c2d0c(0x1a0)]()['then'](async()=>{const _0x541004=normalizeError(_0x517d32);if(!isAbortError(_0x541004))await callRequestErrorHooks(_0x3fd260,_0x4cfb4b,_0x541004);throw _0x541004;})[_0x5c2d0c(0x154)](_0x37d87c=>_0x57c3fb(()=>_0x97a517(_0x37d87c)));}});})[_0x94510(0x154)](async _0x28f242=>{const _0x2a8c75=normalizeError(_0x28f242);await callRequestErrorHooks(_0x3fd260,_0x4cfb4b,_0x2a8c75),_0x57c3fb(()=>_0x97a517(_0x2a8c75));});});}const _0x255b02={};_0x255b02['method']='GET',_0x255b02['responseType']='json';const defaultConfig=_0x255b02;function createHttp(_0x342319={}){const _0x8f6102=_0x1889f2,_0x58bc69=(_0x39b539,_0x3b3f4a)=>{const _0x37d091=_0x153b,_0x47dcfd={};return _0x47dcfd[_0x37d091(0x1a7)]=_0x37d091(0x159),dispatchHttp(_0x37d091(0x159),_0x39b539,mergeOptions(defaultConfig,_0x342319,_0x3b3f4a,_0x47dcfd));},_0x288b1d=(_0x2fee9f,_0x67376a)=>{const _0x374667=_0x153b,_0x36fde3={};return _0x36fde3[_0x374667(0x195)]=_0x374667(0x188),_0x36fde3[_0x374667(0x1a7)]=_0x374667(0x17d),dispatchHttp(_0x374667(0x17d),_0x2fee9f,mergeOptions(defaultConfig,_0x342319,_0x67376a,_0x36fde3));},_0x23d31c=(_0x2ef1af,_0x1a0d5a)=>{const _0x4ce23d=_0x153b,_0x51b22c={};return _0x51b22c['method']=_0x4ce23d(0x182),_0x51b22c['_action']='download',dispatchHttp(_0x4ce23d(0x161),_0x2ef1af,mergeOptions(defaultConfig,_0x342319,_0x1a0d5a,_0x51b22c));},_0x5c21f6=_0x5952b1=>createHttp(mergeOptions(_0x342319,_0x5952b1)),_0x2950c7={};return _0x2950c7[_0x8f6102(0x159)]=_0x58bc69,_0x2950c7['upload']=_0x288b1d,_0x2950c7['download']=_0x23d31c,_0x2950c7['create']=_0x5c21f6,_0x2950c7;}const http=createHttp(),_0x26df23={};_0x26df23[_0x1889f2(0x198)]=!![],_0x26df23[_0x1889f2(0x171)]=function(){return createHttp;},Object['defineProperty'](exports,_0x1889f2(0x18f),_0x26df23);const _0x51a6dd={};_0x51a6dd['enumerable']=!![],_0x51a6dd['get']=function(){return createHttpAborter;},Object[_0x1889f2(0x196)](exports,_0x1889f2(0x19a),_0x51a6dd);const _0x5ee7b9={};_0x5ee7b9[_0x1889f2(0x198)]=!![],_0x5ee7b9[_0x1889f2(0x171)]=function(){return http;},Object[_0x1889f2(0x196)](exports,'http',_0x5ee7b9);
|