@mptool/all 0.11.1 → 0.12.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.d.mts +1466 -1379
- package/dist/index.d.ts +1466 -1379
- package/dist/index.js +10 -9
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +10 -9
- package/dist/index.mjs.map +1 -1
- package/package.json +33 -24
package/dist/index.d.ts
CHANGED
|
@@ -1,12 +1,14 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
1
|
+
//#region ../api/dist/index.d.mts
|
|
2
|
+
//#region src/clipboard.d.ts
|
|
3
|
+
declare const writeClipboard: (data?: string) => Promise<void>; //#endregion
|
|
4
|
+
//#region src/contact.d.ts
|
|
3
5
|
/**
|
|
4
6
|
* 保存联系人到通讯录
|
|
5
7
|
*
|
|
6
8
|
* @param config 联系人信息
|
|
7
9
|
*/
|
|
8
|
-
declare const addContact: (config: Omit<WechatMiniprogram.AddPhoneContactOption, "success" | "fail" | "complete">) => Promise<void>;
|
|
9
|
-
|
|
10
|
+
declare const addContact: (config: Omit<WechatMiniprogram.AddPhoneContactOption, "success" | "fail" | "complete">) => Promise<void>; //#endregion
|
|
11
|
+
//#region src/compareVersion.d.ts
|
|
10
12
|
/**
|
|
11
13
|
* 比较版本号
|
|
12
14
|
* @param versionA 版本号A
|
|
@@ -14,41 +16,45 @@ declare const addContact: (config: Omit<WechatMiniprogram.AddPhoneContactOption,
|
|
|
14
16
|
*
|
|
15
17
|
* @returns 1: versionA > versionB, 0: versionA = versionB, -1: versionA < versionB
|
|
16
18
|
*/
|
|
17
|
-
declare const compareVersion: (versionA: string, versionB: string) => number;
|
|
18
|
-
|
|
19
|
+
declare const compareVersion: (versionA: string, versionB: string) => number; //#endregion
|
|
20
|
+
//#region src/framework.d.ts
|
|
19
21
|
declare const getCurrentPage: <T extends Record<string, any>>() => (T & WechatMiniprogram.Page.TrivialInstance) | null;
|
|
20
|
-
declare const getCurrentRoute: () => string;
|
|
21
|
-
|
|
22
|
+
declare const getCurrentRoute: () => string; //#endregion
|
|
23
|
+
//#region src/media/document.d.ts
|
|
22
24
|
declare const openDocument: (url: string) => void;
|
|
23
|
-
declare const saveDocument: (url: string, filename?: string) => void;
|
|
24
|
-
|
|
25
|
+
declare const saveDocument: (url: string, filename?: string) => void; //#endregion
|
|
26
|
+
//#region src/media/photo.d.ts
|
|
25
27
|
/**
|
|
26
28
|
* 保存图片到相册
|
|
27
29
|
*
|
|
28
30
|
* @param imgPath 图片地址
|
|
31
|
+
* @returns 保存回调
|
|
29
32
|
*/
|
|
30
|
-
declare const savePhoto: (imgPath: string) => Promise<void>;
|
|
31
|
-
|
|
33
|
+
declare const savePhoto: (imgPath: string) => Promise<void>; //#endregion
|
|
34
|
+
//#region src/network/download.d.ts
|
|
32
35
|
/**
|
|
33
36
|
* 下载文件
|
|
34
37
|
*
|
|
35
|
-
* @param
|
|
38
|
+
* @param url 下载路径
|
|
36
39
|
* @param mask 遮罩层
|
|
40
|
+
*
|
|
41
|
+
* @returns 下载完成回调,返回临时文件路径
|
|
37
42
|
*/
|
|
38
|
-
declare const download: (url: string, mask?: boolean) => Promise<string>;
|
|
39
|
-
|
|
43
|
+
declare const download: (url: string, mask?: boolean) => Promise<string>; //#endregion
|
|
44
|
+
//#region src/network/report.d.ts
|
|
40
45
|
/** 网络状态汇报 */
|
|
41
|
-
declare const reportNetworkStatus: () => void;
|
|
42
|
-
|
|
46
|
+
declare const reportNetworkStatus: () => void; //#endregion
|
|
47
|
+
//#region src/ui/confirm.d.ts
|
|
43
48
|
/**
|
|
44
49
|
* 确认操作
|
|
45
50
|
*
|
|
46
51
|
* @param text 行为文字
|
|
47
|
-
* @param
|
|
48
|
-
* @param
|
|
52
|
+
* @param confirmAction 确定回调函数
|
|
53
|
+
* @param cancelAction 取消回调函数
|
|
54
|
+
* @param warning 额外警告信息
|
|
49
55
|
*/
|
|
50
|
-
declare const confirm: (text: string,
|
|
51
|
-
|
|
56
|
+
declare const confirm: (text: string, confirmAction: () => Promise<void> | void, cancelAction?: () => void | Promise<void>, warning?: string) => void; //#endregion
|
|
57
|
+
//#region src/ui/modal.d.ts
|
|
52
58
|
/**
|
|
53
59
|
* 显示提示窗口
|
|
54
60
|
*
|
|
@@ -57,10 +63,10 @@ declare const confirm: (text: string, warning: string | undefined, confirmAction
|
|
|
57
63
|
* @param confirmAction 点击确定的回调函数
|
|
58
64
|
* @param cancelAction 点击取消的回调函数,不填则不显示取消按钮
|
|
59
65
|
*/
|
|
60
|
-
declare const showModal: (title: string, content: string, confirmAction?: () => void | Promise<void>, cancelAction?: () => void | Promise<void>) => void;
|
|
61
|
-
|
|
62
|
-
declare const retry: (title: string, content: string, retryAction: () => void | Promise<void>, navigateBack?: boolean) => void;
|
|
63
|
-
|
|
66
|
+
declare const showModal: (title: string, content: string, confirmAction?: () => void | Promise<void>, cancelAction?: () => void | Promise<void>) => void; //#endregion
|
|
67
|
+
//#region src/ui/retry.d.ts
|
|
68
|
+
declare const retry: (title: string, content: string, retryAction: () => void | Promise<void>, navigateBack?: boolean) => void; //#endregion
|
|
69
|
+
//#region src/ui/toast.d.ts
|
|
64
70
|
/**
|
|
65
71
|
* 显示提示文字
|
|
66
72
|
*
|
|
@@ -68,33 +74,36 @@ declare const retry: (title: string, content: string, retryAction: () => void |
|
|
|
68
74
|
* @param duration 提示持续时间,单位 ms,默认为 `1500`
|
|
69
75
|
* @param icon 提示图标,默认为 `'none'`
|
|
70
76
|
*/
|
|
71
|
-
declare const showToast: (title: string, duration?: number, icon?: "success" | "error" | "loading" | "none") => Promise<void>;
|
|
72
|
-
|
|
73
|
-
declare const getWindowInfo: () => WechatMiniprogram.WindowInfo;
|
|
74
|
-
|
|
77
|
+
declare const showToast: (title: string, duration?: number, icon?: "success" | "error" | "loading" | "none") => Promise<void>; //#endregion
|
|
78
|
+
//#region src/ui/window.d.ts
|
|
79
|
+
declare const getWindowInfo: () => WechatMiniprogram.WindowInfo; //#endregion
|
|
80
|
+
//#region src/update.d.ts
|
|
75
81
|
interface UpdateInfo {
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
82
|
+
/** 是否进行强制更新 */
|
|
83
|
+
force: boolean;
|
|
84
|
+
/** 是否进行强制初始化 */
|
|
85
|
+
reset: boolean;
|
|
80
86
|
}
|
|
81
87
|
/**
|
|
82
88
|
* 检查小程序更新
|
|
83
89
|
*
|
|
84
90
|
* 如果检测到小程序更新,获取升级状态 (新版本号,是否立即更新、是否重置小程序) 并做相应处理
|
|
85
91
|
*
|
|
86
|
-
* @param
|
|
92
|
+
* @param onUpdateReady 获取升级状态的回调函数,参数为一个函数,调用该函数以应用更新
|
|
87
93
|
*/
|
|
88
|
-
declare const updateApp: (onUpdateReady: (applyUpdate: () => void) => Promise<void> | void) => void;
|
|
89
|
-
|
|
94
|
+
declare const updateApp: (onUpdateReady: (applyUpdate: () => void) => Promise<void> | void) => void; //#endregion
|
|
95
|
+
//#endregion
|
|
96
|
+
//#region ../enhance/dist/index.d.mts
|
|
97
|
+
//#region ../shared/dist/index.d.mts
|
|
98
|
+
//#region ../../node_modules/.pnpm/base64-arraybuffer@1.0.2/node_modules/base64-arraybuffer/dist/types/index.d.ts
|
|
90
99
|
declare const encode: (arraybuffer: ArrayBuffer) => string;
|
|
91
|
-
declare const decode: (base64: string) => ArrayBuffer;
|
|
92
|
-
|
|
100
|
+
declare const decode: (base64: string) => ArrayBuffer; //#endregion
|
|
101
|
+
//#region src/env.d.ts
|
|
93
102
|
/** 运行环境 */
|
|
94
103
|
type Env = "wx" | "qq" | "donut" | "js";
|
|
95
104
|
/** 运行环境 */
|
|
96
|
-
declare const env: Env;
|
|
97
|
-
|
|
105
|
+
declare const env: Env; //#endregion
|
|
106
|
+
//#region src/emitter.d.ts
|
|
98
107
|
type EventType = string | symbol;
|
|
99
108
|
type Handler<T = unknown> = (event: T) => void | Promise<void>;
|
|
100
109
|
type WildcardHandler<T = Record<string, unknown>> = (type: keyof T, event: T[keyof T]) => void | Promise<void>;
|
|
@@ -102,33 +111,39 @@ type EventHandlerList<T = unknown> = Handler<T>[];
|
|
|
102
111
|
type WildCardEventHandlerList<T = Record<string, unknown>> = WildcardHandler<T>[];
|
|
103
112
|
type EventHandlerMap<Events> = Map<keyof Events | "*", EventHandlerList<Events[keyof Events]> | WildCardEventHandlerList<Events>>;
|
|
104
113
|
interface EmitterInstance<Events> {
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
+
all: EventHandlerMap<Events>;
|
|
115
|
+
on<Key extends keyof Events>(type: Key, handler: Handler<Events[Key]>): void;
|
|
116
|
+
on(type: "*", handler: WildcardHandler<Events>): void;
|
|
117
|
+
off<Key extends keyof Events>(type: Key, handler?: Handler<Events[Key]>): void;
|
|
118
|
+
off(type: "*", handler: WildcardHandler<Events>): void;
|
|
119
|
+
emit<Key extends keyof Events>(type: Key, event: Events[Key]): void;
|
|
120
|
+
emit<Key extends keyof Events>(type: undefined extends Events[Key] ? Key : never): void;
|
|
121
|
+
emitAsync<Key extends keyof Events>(type: Key, event: Events[Key]): Promise<void>;
|
|
122
|
+
emitAsync<Key extends keyof Events>(type: undefined extends Events[Key] ? Key : never): Promise<void>;
|
|
114
123
|
}
|
|
115
124
|
/**
|
|
116
125
|
* Tiny (~300b) functional event emitter / pubsub.
|
|
117
|
-
*
|
|
126
|
+
*
|
|
127
|
+
* @param all An optional event handler map to use as the backing store for the emitter's events. Use
|
|
118
128
|
* @returns Emitter
|
|
119
129
|
*/
|
|
120
|
-
declare
|
|
121
|
-
|
|
122
|
-
interface MpErrorOptions
|
|
123
|
-
|
|
124
|
-
|
|
130
|
+
declare const Emitter: <Events>(all?: EventHandlerMap<Events>) => EmitterInstance<Events>; //#endregion
|
|
131
|
+
//#region src/error.d.ts
|
|
132
|
+
interface MpErrorOptions {
|
|
133
|
+
code?: number;
|
|
134
|
+
message?: string;
|
|
125
135
|
}
|
|
126
|
-
declare class MpError
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
136
|
+
declare class MpError extends Error {
|
|
137
|
+
code: number | null;
|
|
138
|
+
constructor({
|
|
139
|
+
code,
|
|
140
|
+
message
|
|
141
|
+
}: MpErrorOptions);
|
|
142
|
+
toString(): string;
|
|
143
|
+
}
|
|
144
|
+
declare namespace logger_d_exports {
|
|
145
|
+
export { debug, error, filter, info, warn };
|
|
130
146
|
}
|
|
131
|
-
|
|
132
147
|
/** 写入普通日志 */
|
|
133
148
|
declare const debug: (...args: any[]) => void;
|
|
134
149
|
/** 写入信息日志 */
|
|
@@ -143,27 +158,14 @@ declare const error: (...args: any[]) => void;
|
|
|
143
158
|
* @param filterMsg 过滤信息
|
|
144
159
|
*/
|
|
145
160
|
declare const filter: (filterMsg: string) => void;
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
declare const logger_error: typeof error;
|
|
149
|
-
declare const logger_filter: typeof filter;
|
|
150
|
-
declare const logger_info: typeof info;
|
|
151
|
-
declare const logger_warn: typeof warn;
|
|
152
|
-
declare namespace logger {
|
|
153
|
-
export {
|
|
154
|
-
logger_debug as debug,
|
|
155
|
-
logger_error as error,
|
|
156
|
-
logger_filter as filter,
|
|
157
|
-
logger_info as info,
|
|
158
|
-
logger_warn as warn,
|
|
159
|
-
};
|
|
161
|
+
declare namespace query_d_exports {
|
|
162
|
+
export { join, parse, stringify };
|
|
160
163
|
}
|
|
161
|
-
|
|
162
164
|
/**
|
|
163
165
|
* 字符串参数解析
|
|
164
166
|
*
|
|
165
167
|
* @param queryString 需要解析的字符串
|
|
166
|
-
* @param
|
|
168
|
+
* @param splitter 分隔符
|
|
167
169
|
*
|
|
168
170
|
* @returns 参数对象
|
|
169
171
|
*/
|
|
@@ -172,8 +174,8 @@ declare const parse: (queryString?: string, splitter?: string) => Record<string,
|
|
|
172
174
|
* query 对象转换字符串
|
|
173
175
|
*
|
|
174
176
|
* @param params query 对象
|
|
175
|
-
* @param
|
|
176
|
-
* @param
|
|
177
|
+
* @param splitter 分隔符
|
|
178
|
+
* @param unencoded 是否已经解码
|
|
177
179
|
*
|
|
178
180
|
* @returns 解析的字符串
|
|
179
181
|
*/
|
|
@@ -187,19 +189,8 @@ declare const stringify: (params?: Record<string, string>, splitter?: string, un
|
|
|
187
189
|
*
|
|
188
190
|
* @returns 处理过的 url
|
|
189
191
|
*/
|
|
190
|
-
declare const join: (path: string, queries: Record<string, string>, unencoded?: boolean) => string;
|
|
191
|
-
|
|
192
|
-
declare const query_join: typeof join;
|
|
193
|
-
declare const query_parse: typeof parse;
|
|
194
|
-
declare const query_stringify: typeof stringify;
|
|
195
|
-
declare namespace query {
|
|
196
|
-
export {
|
|
197
|
-
query_join as join,
|
|
198
|
-
query_parse as parse,
|
|
199
|
-
query_stringify as stringify,
|
|
200
|
-
};
|
|
201
|
-
}
|
|
202
|
-
|
|
192
|
+
declare const join: (path: string, queries: Record<string, string>, unencoded?: boolean) => string; //#endregion
|
|
193
|
+
//#region src/type.d.ts
|
|
203
194
|
/**
|
|
204
195
|
* 获取变量类型
|
|
205
196
|
*
|
|
@@ -207,8 +198,8 @@ declare namespace query {
|
|
|
207
198
|
* @returns 对象的类型
|
|
208
199
|
*/
|
|
209
200
|
declare const type: (obj: unknown) => string;
|
|
210
|
-
declare const isFunction: <T extends Function>(obj: unknown) => obj is T;
|
|
211
|
-
|
|
201
|
+
declare const isFunction: <T extends Function>(obj: unknown) => obj is T; //#endregion
|
|
202
|
+
//#region src/utils.d.ts
|
|
212
203
|
/**
|
|
213
204
|
* 包装函数,先执行 wrapper ,然后执行原函数
|
|
214
205
|
*
|
|
@@ -227,8 +218,8 @@ declare const isFunction: <T extends Function>(obj: unknown) => obj is T;
|
|
|
227
218
|
* c(); // expect to output 'a', and then output 'b'
|
|
228
219
|
* ```
|
|
229
220
|
*/
|
|
230
|
-
declare function wrapFunction<
|
|
231
|
-
declare function wrapFunction<
|
|
221
|
+
declare function wrapFunction<ThisType>(original: ((this: ThisType, ...args: any[]) => void) | undefined, pre: (this: ThisType, ...args: any[]) => void): (this: ThisType, ...args: any[]) => void;
|
|
222
|
+
declare function wrapFunction<ThisType>(original: ((this: ThisType, ...args: any[]) => Promise<void>) | undefined, pre: (this: ThisType, ...args: any[]) => void): (this: ThisType, ...args: any[]) => Promise<void>;
|
|
232
223
|
/**
|
|
233
224
|
* 锁定某个函数使其无法被再次执行直到函数自己解锁
|
|
234
225
|
*
|
|
@@ -256,7 +247,7 @@ declare function wrapFunction<T>(original: ((this: T, ...args: any[]) => Promise
|
|
|
256
247
|
* }, 15);
|
|
257
248
|
* ```
|
|
258
249
|
*/
|
|
259
|
-
declare const lock: <
|
|
250
|
+
declare const lock: <ThisType, Args extends unknown[], ReturnType>(fn: (this: ThisType, release: () => void, ...args: Args) => ReturnType, ctx?: ThisType) => ((this: ThisType, ...args: Args) => ReturnType | undefined);
|
|
260
251
|
/**
|
|
261
252
|
* 包装函数保证其之被调用一次
|
|
262
253
|
*
|
|
@@ -274,39 +265,39 @@ declare const lock: <T, A extends unknown[], R>(fn: (this: T, release: () => voi
|
|
|
274
265
|
* counter(); // count is still 1
|
|
275
266
|
* ```
|
|
276
267
|
*/
|
|
277
|
-
declare const once: <
|
|
268
|
+
declare const once: <ThisType, Args extends unknown[], ReturnType>(func: (...args: Args) => ReturnType, ctx?: ThisType) => ((this: ThisType, ...args: Args) => ReturnType | undefined);
|
|
278
269
|
interface Task<ArgType extends unknown[] = unknown[], This = unknown> {
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
270
|
+
/** 函数本身 */
|
|
271
|
+
func: (this: This, next: () => void, ...args: ArgType) => void;
|
|
272
|
+
/** 函数的运行上下文 */
|
|
273
|
+
ctx: This;
|
|
274
|
+
/** 函数的参数 */
|
|
275
|
+
args: ArgType;
|
|
285
276
|
}
|
|
286
277
|
/**
|
|
287
278
|
* 一个队列,在上一个函数执行完毕后执行 `next()` 才会开始执行下一个函数。
|
|
288
279
|
*/
|
|
289
280
|
declare class Queue {
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
281
|
+
/** 允许同时并行的任务数 */
|
|
282
|
+
capacity: number;
|
|
283
|
+
constructor(/** 允许同时并行的任务数 */
|
|
284
|
+
|
|
285
|
+
capacity?: number);
|
|
286
|
+
/** 回调队列 */
|
|
287
|
+
funcQueue: Task[];
|
|
288
|
+
/** 正在运行的数量 */
|
|
289
|
+
running: number;
|
|
290
|
+
/** 执行下一个函数 */
|
|
291
|
+
next(): void;
|
|
292
|
+
/**
|
|
293
|
+
* 添加函数
|
|
294
|
+
* @param func 函数
|
|
295
|
+
* @param ctx 函数运行上下文
|
|
296
|
+
* @param args 函数参数
|
|
297
|
+
*/
|
|
298
|
+
add<Args extends any[], T>(func: (next: () => void, ...args: Args) => void, ctx?: T, ...args: Args): void;
|
|
299
|
+
/** 清除队列,不再执行尚未执行的函数 */
|
|
300
|
+
clear(): void;
|
|
310
301
|
}
|
|
311
302
|
/**
|
|
312
303
|
* 在调用函数的时候启用队列,在上一个函数执行完毕后执行 `next()` 才会开始执行下一个函数。
|
|
@@ -317,697 +308,689 @@ declare class Queue {
|
|
|
317
308
|
* @returns 包装过的函数
|
|
318
309
|
* @async
|
|
319
310
|
*/
|
|
320
|
-
declare const funcQueue: <
|
|
321
|
-
|
|
311
|
+
declare const funcQueue: <Args extends unknown[], T = unknown>(fn: (next: () => void, ...args: Args) => void, capacity?: number) => ((this: T, ...args: Args) => void); //#endregion
|
|
312
|
+
//#endregion
|
|
313
|
+
//#region src/component/typings.d.ts
|
|
322
314
|
type Props = Record<string, unknown>;
|
|
323
|
-
type PropsOptions<Property = Props> = {
|
|
324
|
-
[K in keyof Property]: PropItem<Property[K]> | null;
|
|
325
|
-
};
|
|
315
|
+
type PropsOptions<Property = Props> = { [Key in keyof Property]: PropItem<Property[Key]> | null };
|
|
326
316
|
type PropItem<Type, Default = Type> = PropOption<Type, Default> | PropConstructor<Type>;
|
|
327
317
|
interface PropOption<Type = any, Default = Type> {
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
318
|
+
/** 属性类型 */
|
|
319
|
+
type?: PropType<Type> | null;
|
|
320
|
+
/**
|
|
321
|
+
* 是否必填
|
|
322
|
+
*
|
|
323
|
+
* @description 仅用作类型推导,无检查
|
|
324
|
+
*/
|
|
325
|
+
required?: boolean;
|
|
326
|
+
/** 属性初始值 */
|
|
327
|
+
default?: Default | null | undefined | object;
|
|
338
328
|
}
|
|
339
|
-
type PropMethod<Type, TypeConstructor = any> = Type extends (...args: any) => any ? {
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
329
|
+
type PropMethod<Type, TypeConstructor = any> = Type extends ((...args: any) => any) ? {
|
|
330
|
+
new (): TypeConstructor;
|
|
331
|
+
(): Type;
|
|
332
|
+
readonly prototype: TypeConstructor;
|
|
343
333
|
} : never;
|
|
344
334
|
type PropConstructor<Type = any> = (new (...args: any[]) => Type & {}) | (() => Type) | PropMethod<Type>;
|
|
345
335
|
type PropType<T> = PropConstructor<T> | PropConstructor<T>[];
|
|
346
|
-
type InferFromType<Type> = [Type] extends [null] ? any : [Type] extends [ArrayConstructor] ? any[] : [Type] extends [ObjectConstructor] ? WechatMiniprogram.IAnyObject : [Type] extends [BooleanConstructor] ? boolean : [Type] extends [PropConstructor<infer
|
|
347
|
-
type RequiredKeys<T> = {
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
} ? never : K : never;
|
|
355
|
-
}[keyof T];
|
|
336
|
+
type InferFromType<Type> = [Type] extends [null] ? any : [Type] extends [ArrayConstructor] ? any[] : [Type] extends [ObjectConstructor] ? WechatMiniprogram.IAnyObject : [Type] extends [BooleanConstructor] ? boolean : [Type] extends [PropConstructor<infer Value>] ? unknown extends Value ? any : Value : Type;
|
|
337
|
+
type RequiredKeys<T> = { [Key in keyof T]: T[Key] extends {
|
|
338
|
+
required: true;
|
|
339
|
+
} | {
|
|
340
|
+
default: any;
|
|
341
|
+
} ? T[Key] extends {
|
|
342
|
+
default: undefined | (() => undefined);
|
|
343
|
+
} ? never : Key : never }[keyof T];
|
|
356
344
|
type OptionalKeys<Type> = Exclude<keyof Type, RequiredKeys<Type>>;
|
|
357
345
|
type InferPropType<Type> = [Type] extends [null] ? any : [Type] extends [{
|
|
358
|
-
|
|
346
|
+
type: null;
|
|
359
347
|
}] ? any : [Type] extends [ArrayConstructor | {
|
|
360
|
-
|
|
348
|
+
type: ArrayConstructor;
|
|
361
349
|
}] ? any[] : [Type] extends [ObjectConstructor | {
|
|
362
|
-
|
|
350
|
+
type: ObjectConstructor;
|
|
363
351
|
}] ? WechatMiniprogram.IAnyObject : [Type] extends [BooleanConstructor | {
|
|
364
|
-
|
|
352
|
+
type: BooleanConstructor;
|
|
365
353
|
}] ? boolean : [Type] extends [PropItem<infer Value, infer Default>] ? unknown extends Value ? Default : Value : Type;
|
|
366
|
-
type InferPropTypes<
|
|
367
|
-
[K in keyof O]?: unknown;
|
|
368
|
-
} & {
|
|
369
|
-
[K in RequiredKeys<O>]: InferPropType<O[K]>;
|
|
370
|
-
} & {
|
|
371
|
-
[K in OptionalKeys<O>]?: InferPropType<O[K]>;
|
|
372
|
-
} : Record<string, any>;
|
|
354
|
+
type InferPropTypes<Obj> = Obj extends object ? { [Key in keyof Obj]?: unknown } & { [Key in RequiredKeys<Obj>]: InferPropType<Obj[Key]> } & { [Key in OptionalKeys<Obj>]?: InferPropType<Obj[Key]> } : Record<string, any>;
|
|
373
355
|
interface ComponentLifetimes {
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
/**
|
|
377
|
-
* 在组件实例刚刚被创建时执行,注意此时不能调用 `setData`
|
|
378
|
-
*
|
|
379
|
-
* 最低基础库版本:[`1.6.3`](https://developers.weixin.qq.com/miniprogram/dev/framework/compatibility.html)
|
|
380
|
-
*/
|
|
381
|
-
created(): void;
|
|
382
|
-
/**
|
|
383
|
-
* 在组件实例进入页面节点树时执行
|
|
384
|
-
*
|
|
385
|
-
* 最低基础库版本:[`1.6.3`](https://developers.weixin.qq.com/miniprogram/dev/framework/compatibility.html)
|
|
386
|
-
*/
|
|
387
|
-
attached(): void;
|
|
388
|
-
/**
|
|
389
|
-
* 在组件在视图层布局完成后执行
|
|
390
|
-
*
|
|
391
|
-
* 最低基础库版本:[`1.6.3`](https://developers.weixin.qq.com/miniprogram/dev/framework/compatibility.html)
|
|
392
|
-
*/
|
|
393
|
-
ready(): void;
|
|
394
|
-
/**
|
|
395
|
-
* 在组件实例被移动到节点树另一个位置时执行
|
|
396
|
-
*
|
|
397
|
-
* 最低基础库版本:[`1.6.3`](https://developers.weixin.qq.com/miniprogram/dev/framework/compatibility.html)
|
|
398
|
-
*/
|
|
399
|
-
moved(): void;
|
|
400
|
-
/**
|
|
401
|
-
* 在组件实例被从页面节点树移除时执行
|
|
402
|
-
*
|
|
403
|
-
* 最低基础库版本:[`1.6.3`](https://developers.weixin.qq.com/miniprogram/dev/framework/compatibility.html)
|
|
404
|
-
*/
|
|
405
|
-
detached(): void;
|
|
406
|
-
/**
|
|
407
|
-
* 每当组件方法抛出错误时执行
|
|
408
|
-
*
|
|
409
|
-
* 最低基础库版本:[`2.4.1`](https://developers.weixin.qq.com/miniprogram/dev/framework/compatibility.html)
|
|
410
|
-
*/
|
|
411
|
-
error(err: WechatMiniprogram.Error): void;
|
|
412
|
-
}>;
|
|
413
|
-
}
|
|
414
|
-
interface ExtendedComponentProperty {
|
|
356
|
+
/** 组件生命周期声明对象 */
|
|
357
|
+
lifetimes: Partial<{
|
|
415
358
|
/**
|
|
416
|
-
*
|
|
359
|
+
* 在组件实例刚刚被创建时执行,注意此时不能调用 `setData`
|
|
360
|
+
*
|
|
361
|
+
* 最低基础库版本:[`1.6.3`](https://developers.weixin.qq.com/miniprogram/dev/framework/compatibility.html)
|
|
417
362
|
*/
|
|
418
|
-
|
|
363
|
+
created(): void;
|
|
419
364
|
/**
|
|
420
|
-
*
|
|
365
|
+
* 在组件实例进入页面节点树时执行
|
|
366
|
+
*
|
|
367
|
+
* 最低基础库版本:[`1.6.3`](https://developers.weixin.qq.com/miniprogram/dev/framework/compatibility.html)
|
|
421
368
|
*/
|
|
422
|
-
|
|
369
|
+
attached(): void;
|
|
423
370
|
/**
|
|
424
|
-
*
|
|
371
|
+
* 在组件在视图层布局完成后执行
|
|
425
372
|
*
|
|
426
|
-
*
|
|
373
|
+
* 最低基础库版本:[`1.6.3`](https://developers.weixin.qq.com/miniprogram/dev/framework/compatibility.html)
|
|
427
374
|
*/
|
|
428
|
-
|
|
375
|
+
ready(): void;
|
|
429
376
|
/**
|
|
430
|
-
*
|
|
377
|
+
* 在组件实例被移动到节点树另一个位置时执行
|
|
431
378
|
*
|
|
432
|
-
*
|
|
379
|
+
* 最低基础库版本:[`1.6.3`](https://developers.weixin.qq.com/miniprogram/dev/framework/compatibility.html)
|
|
433
380
|
*/
|
|
434
|
-
|
|
381
|
+
moved(): void;
|
|
435
382
|
/**
|
|
436
|
-
*
|
|
383
|
+
* 在组件实例被从页面节点树移除时执行
|
|
437
384
|
*
|
|
438
|
-
*
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
|
|
442
|
-
*
|
|
385
|
+
* 最低基础库版本:[`1.6.3`](https://developers.weixin.qq.com/miniprogram/dev/framework/compatibility.html)
|
|
386
|
+
*/
|
|
387
|
+
detached(): void;
|
|
388
|
+
/**
|
|
389
|
+
* 每当组件方法抛出错误时执行
|
|
443
390
|
*
|
|
444
|
-
*
|
|
445
|
-
* $Component({
|
|
446
|
-
* lifetimes:{
|
|
447
|
-
* attached() {
|
|
448
|
-
* this.$refs.customComp // 根据ref属性获取子组件的实例引用
|
|
449
|
-
* }
|
|
450
|
-
* }
|
|
451
|
-
* });
|
|
452
|
-
* ```
|
|
391
|
+
* 最低基础库版本:[`2.4.1`](https://developers.weixin.qq.com/miniprogram/dev/framework/compatibility.html)
|
|
453
392
|
*/
|
|
454
|
-
|
|
393
|
+
error(err: Error): void;
|
|
394
|
+
}>;
|
|
395
|
+
}
|
|
396
|
+
interface ExtendedComponentProperty {
|
|
397
|
+
/**
|
|
398
|
+
* 当前组件的唯一标识
|
|
399
|
+
*/
|
|
400
|
+
$id: number;
|
|
401
|
+
/**
|
|
402
|
+
* 当前组件上用于索引的 ref ID 值
|
|
403
|
+
*/
|
|
404
|
+
$refID: string;
|
|
405
|
+
/**
|
|
406
|
+
* 当前组件所属的页面组件实例
|
|
407
|
+
*
|
|
408
|
+
* @description 只在 `attached`, `ready` 生命周期后生效
|
|
409
|
+
*/
|
|
410
|
+
$root: TrivialPageInstance;
|
|
411
|
+
/**
|
|
412
|
+
* 当前组件所属的父组件实例引用
|
|
413
|
+
*
|
|
414
|
+
* @description 只在 `attached`, `ready` 生命周期后生效
|
|
415
|
+
*/
|
|
416
|
+
$parent: TrivialPageInstance | TrivialComponentInstance;
|
|
417
|
+
/**
|
|
418
|
+
* 指定了 `ref` 的子组件实例映射
|
|
419
|
+
*
|
|
420
|
+
* 示例:
|
|
421
|
+
*
|
|
422
|
+
* ```html
|
|
423
|
+
* <custom-component binding="$" ref="customComp"/>
|
|
424
|
+
* ```
|
|
425
|
+
*
|
|
426
|
+
* ```js
|
|
427
|
+
* $Component({
|
|
428
|
+
* lifetimes:{
|
|
429
|
+
* attached() {
|
|
430
|
+
* this.$refs.customComp // 根据ref属性获取子组件的实例引用
|
|
431
|
+
* }
|
|
432
|
+
* }
|
|
433
|
+
* });
|
|
434
|
+
* ```
|
|
435
|
+
*/
|
|
436
|
+
$refs: RefMap;
|
|
455
437
|
}
|
|
456
438
|
/** 组件实例 */
|
|
457
439
|
interface ExtendedComponentMethods extends InstanceEmitterMethods {
|
|
458
|
-
|
|
459
|
-
|
|
460
|
-
|
|
461
|
-
|
|
462
|
-
|
|
463
|
-
|
|
464
|
-
|
|
465
|
-
|
|
466
|
-
* @private
|
|
467
|
-
*/
|
|
468
|
-
$attached(parent: TrivialComponentInstance | TrivialPageInstance): void;
|
|
440
|
+
/**
|
|
441
|
+
* 通过消息的方式调用父组件方法,方法不存在也不会报错
|
|
442
|
+
*
|
|
443
|
+
* @param method 方法名称
|
|
444
|
+
* @param args 传递的参数
|
|
445
|
+
*/
|
|
446
|
+
$call(method: string, ...args: unknown[]): void;
|
|
447
|
+
$attached(parent: TrivialComponentInstance | TrivialPageInstance): void;
|
|
469
448
|
}
|
|
470
|
-
type ComponentInstance<Data extends WechatMiniprogram.Component.DataOption,
|
|
471
|
-
|
|
472
|
-
|
|
473
|
-
|
|
474
|
-
|
|
475
|
-
|
|
476
|
-
|
|
477
|
-
|
|
478
|
-
properties: Data & InferPropTypes<Props>;
|
|
449
|
+
type ComponentInstance<Data extends WechatMiniprogram.Component.DataOption, ComponentProps extends PropsOptions, Method extends Partial<WechatMiniprogram.Component.MethodOption>, Behavior extends WechatMiniprogram.Component.BehaviorOption, InstanceProps extends WechatMiniprogram.IAnyObject = Record<never, never>, IsPage extends boolean = false> = WechatMiniprogram.Component.InstanceProperties & WechatMiniprogram.Component.InstanceMethods<Data> & ExtendedComponentMethods & Method & (IsPage extends true ? WechatMiniprogram.Page.ILifetime : Record<never, never>) & InstanceProps & ExtendedComponentProperty & ExtendedPageMethods<Data & InferPropTypes<ComponentProps>, InstanceProps & Method & WechatMiniprogram.Component.MixinMethods<Behavior> & (IsPage extends true ? WechatMiniprogram.Page.ILifetime : Record<never, never>)> & {
|
|
450
|
+
/** 组件数据,**包括内部数据和属性值** */data: Data & InferPropTypes<ComponentProps>;
|
|
451
|
+
/**
|
|
452
|
+
* @deprecated 优先使用 `data`
|
|
453
|
+
*
|
|
454
|
+
* 组件数据,**包括内部数据和属性值**(与 `data` 一致)
|
|
455
|
+
*/
|
|
456
|
+
properties: Data & InferPropTypes<ComponentProps>;
|
|
479
457
|
};
|
|
480
|
-
type ComponentOptions<Data extends WechatMiniprogram.Component.DataOption,
|
|
481
|
-
|
|
482
|
-
|
|
483
|
-
|
|
484
|
-
type
|
|
485
|
-
type
|
|
486
|
-
|
|
487
|
-
|
|
488
|
-
]>;
|
|
489
|
-
type RefMap = Record<string, TrivialComponentInstance>;
|
|
490
|
-
|
|
458
|
+
type ComponentOptions<Data extends WechatMiniprogram.Component.DataOption, ComponentProps extends PropsOptions, Method extends WechatMiniprogram.Component.MethodOption, Behavior extends WechatMiniprogram.Component.BehaviorOption, InstanceProps extends WechatMiniprogram.IAnyObject = Record<never, never>, IsPage extends boolean = false> = Partial<WechatMiniprogram.Component.Data<Data>> & Partial<{
|
|
459
|
+
/** 组件属性 */props: ComponentProps;
|
|
460
|
+
}> & Partial<WechatMiniprogram.Component.Behavior<Behavior>> & Partial<WechatMiniprogram.Component.Method<Method, IsPage>> & Partial<WechatMiniprogram.Component.OtherOption> & Partial<ComponentLifetimes> & ThisType<ComponentInstance<Data, ComponentProps, Method, Behavior, InstanceProps, IsPage>>;
|
|
461
|
+
type ComponentConstructor = <Data extends WechatMiniprogram.Component.DataOption, ComponentProps extends PropsOptions, Method extends WechatMiniprogram.Component.MethodOption, Behavior extends WechatMiniprogram.Component.BehaviorOption, InstanceProps extends WechatMiniprogram.IAnyObject = Record<never, never>, IsPage extends boolean = false>(options: ComponentOptions<Data, ComponentProps, Method, Behavior, InstanceProps, IsPage>) => string;
|
|
462
|
+
type TrivialComponentInstance = ComponentInstance<WechatMiniprogram.IAnyObject, Record<string, null>, Record<string, (...args: unknown[]) => any>, []>;
|
|
463
|
+
type TrivialComponentOptions = ComponentOptions<WechatMiniprogram.IAnyObject, Record<string, null>, Record<string, (...args: any[]) => any>, []>;
|
|
464
|
+
type RefMap = Map<string, TrivialComponentInstance>; //#endregion
|
|
465
|
+
//#region src/component/component.d.ts
|
|
491
466
|
declare const handleProperties: (oldProps?: PropsOptions) => WechatMiniprogram.Component.PropertyOption;
|
|
492
467
|
/**
|
|
493
468
|
* 组件注册器
|
|
494
469
|
*
|
|
495
470
|
* @param options 注册选项
|
|
471
|
+
* @returns 返回组件实例ID
|
|
496
472
|
*/
|
|
497
|
-
declare const $Component: ComponentConstructor;
|
|
498
|
-
|
|
499
|
-
declare const getRef: (id: number) => TrivialComponentInstance;
|
|
473
|
+
declare const $Component: ComponentConstructor; //#endregion
|
|
474
|
+
//#region src/component/store.d.ts
|
|
475
|
+
declare const getRef: (id: number) => TrivialComponentInstance | undefined;
|
|
500
476
|
declare const setRef: (id: number, value: TrivialComponentInstance) => void;
|
|
501
|
-
declare const removeRef: (id: number) => void;
|
|
502
|
-
|
|
477
|
+
declare const removeRef: (id: number) => void; //#endregion
|
|
478
|
+
//#region src/bridge.d.ts
|
|
503
479
|
declare const go: (pageName: string) => Promise<WechatMiniprogram.NavigateToSuccessCallbackResult>;
|
|
504
480
|
declare const redirect: (pageName: string) => Promise<WechatMiniprogram.GeneralCallbackResult>;
|
|
505
481
|
declare const switchTab: (pageName: string) => Promise<WechatMiniprogram.GeneralCallbackResult>;
|
|
506
482
|
declare const reLaunch: (pageName: string) => Promise<WechatMiniprogram.GeneralCallbackResult>;
|
|
507
|
-
declare
|
|
508
|
-
|
|
509
|
-
|
|
510
|
-
|
|
511
|
-
}>)
|
|
512
|
-
|
|
483
|
+
declare const bind: (this: TrivialComponentInstance, touchEvent: WechatMiniprogram.Touch<{
|
|
484
|
+
id: number;
|
|
485
|
+
event: string;
|
|
486
|
+
args: unknown[];
|
|
487
|
+
}>) => void; //#endregion
|
|
488
|
+
//#region src/navigator/typings.d.ts
|
|
513
489
|
/** 页面跳转 API */
|
|
514
490
|
interface NavigatorMethods {
|
|
515
|
-
|
|
516
|
-
|
|
517
|
-
|
|
518
|
-
|
|
519
|
-
|
|
520
|
-
|
|
521
|
-
|
|
522
|
-
|
|
523
|
-
|
|
524
|
-
|
|
525
|
-
|
|
526
|
-
|
|
527
|
-
|
|
528
|
-
|
|
529
|
-
|
|
530
|
-
|
|
531
|
-
|
|
532
|
-
|
|
533
|
-
|
|
534
|
-
|
|
535
|
-
|
|
536
|
-
|
|
537
|
-
|
|
538
|
-
|
|
539
|
-
|
|
540
|
-
|
|
541
|
-
|
|
542
|
-
|
|
543
|
-
|
|
544
|
-
|
|
545
|
-
|
|
546
|
-
|
|
547
|
-
|
|
548
|
-
|
|
549
|
-
|
|
550
|
-
|
|
551
|
-
|
|
552
|
-
|
|
553
|
-
|
|
554
|
-
|
|
555
|
-
|
|
556
|
-
|
|
557
|
-
|
|
558
|
-
|
|
559
|
-
|
|
560
|
-
|
|
561
|
-
|
|
562
|
-
|
|
563
|
-
|
|
564
|
-
|
|
565
|
-
|
|
566
|
-
|
|
567
|
-
|
|
568
|
-
|
|
569
|
-
|
|
570
|
-
|
|
571
|
-
|
|
572
|
-
|
|
573
|
-
|
|
574
|
-
|
|
575
|
-
|
|
576
|
-
|
|
577
|
-
|
|
578
|
-
|
|
579
|
-
|
|
580
|
-
|
|
581
|
-
|
|
582
|
-
|
|
583
|
-
|
|
584
|
-
|
|
585
|
-
|
|
586
|
-
|
|
587
|
-
|
|
588
|
-
|
|
589
|
-
|
|
590
|
-
|
|
591
|
-
|
|
592
|
-
|
|
593
|
-
|
|
594
|
-
|
|
595
|
-
|
|
596
|
-
|
|
597
|
-
|
|
598
|
-
|
|
599
|
-
|
|
600
|
-
|
|
601
|
-
|
|
602
|
-
|
|
603
|
-
|
|
604
|
-
|
|
605
|
-
|
|
606
|
-
|
|
607
|
-
|
|
608
|
-
|
|
609
|
-
|
|
610
|
-
|
|
611
|
-
|
|
612
|
-
|
|
613
|
-
|
|
614
|
-
|
|
615
|
-
|
|
616
|
-
|
|
617
|
-
|
|
618
|
-
|
|
619
|
-
|
|
620
|
-
|
|
621
|
-
|
|
622
|
-
|
|
623
|
-
|
|
624
|
-
|
|
625
|
-
|
|
626
|
-
|
|
627
|
-
|
|
628
|
-
|
|
629
|
-
|
|
630
|
-
|
|
631
|
-
|
|
632
|
-
|
|
633
|
-
|
|
634
|
-
|
|
635
|
-
|
|
636
|
-
|
|
637
|
-
|
|
638
|
-
|
|
639
|
-
|
|
640
|
-
|
|
641
|
-
|
|
642
|
-
|
|
643
|
-
|
|
644
|
-
|
|
645
|
-
|
|
646
|
-
|
|
647
|
-
|
|
648
|
-
|
|
649
|
-
|
|
650
|
-
|
|
651
|
-
|
|
652
|
-
|
|
653
|
-
|
|
654
|
-
|
|
655
|
-
|
|
656
|
-
|
|
657
|
-
|
|
658
|
-
|
|
659
|
-
|
|
660
|
-
|
|
661
|
-
|
|
662
|
-
|
|
663
|
-
|
|
664
|
-
|
|
665
|
-
|
|
666
|
-
|
|
667
|
-
|
|
668
|
-
|
|
669
|
-
|
|
670
|
-
|
|
671
|
-
|
|
672
|
-
|
|
673
|
-
|
|
674
|
-
|
|
675
|
-
|
|
676
|
-
|
|
677
|
-
|
|
678
|
-
|
|
679
|
-
|
|
680
|
-
|
|
681
|
-
|
|
682
|
-
|
|
683
|
-
|
|
684
|
-
|
|
685
|
-
|
|
686
|
-
|
|
687
|
-
|
|
688
|
-
|
|
689
|
-
|
|
690
|
-
|
|
691
|
-
}
|
|
692
|
-
|
|
491
|
+
/**
|
|
492
|
+
* 导航到指定页面
|
|
493
|
+
*
|
|
494
|
+
* 本函数是 `wx.navigateTo` 的封装,`pageName` 可以带上 `queryString`
|
|
495
|
+
*
|
|
496
|
+
* @param pageName 页面名称或页面的路径
|
|
497
|
+
*
|
|
498
|
+
* 示例:
|
|
499
|
+
*
|
|
500
|
+
* ```js
|
|
501
|
+
* this.$go('play?vid=xxx&cid=xxx');
|
|
502
|
+
* ```
|
|
503
|
+
*/
|
|
504
|
+
$go(pageName: string): Promise<WechatMiniprogram.NavigateToSuccessCallbackResult>;
|
|
505
|
+
/**
|
|
506
|
+
* 跳转到指定页面, **替换页面,不产生历史**
|
|
507
|
+
*
|
|
508
|
+
* 本函数是 `wx.redirectTo` 的封装,`pageName` 可以带上 `queryString`
|
|
509
|
+
*
|
|
510
|
+
* @param pageName 页面名称或页面的路径
|
|
511
|
+
*
|
|
512
|
+
* 示例:
|
|
513
|
+
*
|
|
514
|
+
* ```js
|
|
515
|
+
* this.$redirect('about');
|
|
516
|
+
* ```
|
|
517
|
+
*/
|
|
518
|
+
$redirect(pageName: string): Promise<WechatMiniprogram.GeneralCallbackResult>;
|
|
519
|
+
/**
|
|
520
|
+
* 跳转到指定 tabBar 页面,并关闭其他所有非 tabBar 页面
|
|
521
|
+
*
|
|
522
|
+
* 本函数是 `wx.switchTab` 的封装,路径参数只用于触发 `onNavigate`
|
|
523
|
+
*
|
|
524
|
+
* @param pageName 页面名称或页面的路径
|
|
525
|
+
*
|
|
526
|
+
* 示例:
|
|
527
|
+
*
|
|
528
|
+
* ```js
|
|
529
|
+
* this.$switch('main?user=mrhope');
|
|
530
|
+
* ```
|
|
531
|
+
*/
|
|
532
|
+
$switch(pageName: string): Promise<WechatMiniprogram.GeneralCallbackResult>;
|
|
533
|
+
/**
|
|
534
|
+
* 关闭所有页面,之后打开到应用内的某个页面
|
|
535
|
+
*
|
|
536
|
+
* 本函数是 `wx.reLaunch` 的封装,`pageName` 可以带上 `queryString`
|
|
537
|
+
*
|
|
538
|
+
* @param pageName 页面名称或页面的路径
|
|
539
|
+
*
|
|
540
|
+
* 示例:
|
|
541
|
+
*
|
|
542
|
+
* ```js
|
|
543
|
+
* this.$launch('main');
|
|
544
|
+
* ```
|
|
545
|
+
*/
|
|
546
|
+
$reLaunch(pageName: string): Promise<WechatMiniprogram.GeneralCallbackResult>;
|
|
547
|
+
/**
|
|
548
|
+
* 返回上一页,`wx.navigateBack` 的封装
|
|
549
|
+
*
|
|
550
|
+
* @param delta 返回的层数,默认为 `1`
|
|
551
|
+
*
|
|
552
|
+
* 示例:
|
|
553
|
+
*
|
|
554
|
+
* ```js
|
|
555
|
+
* this.$back();
|
|
556
|
+
* this.$back(2);
|
|
557
|
+
* ```
|
|
558
|
+
*/
|
|
559
|
+
$back(delta?: number): Promise<WechatMiniprogram.GeneralCallbackResult>;
|
|
560
|
+
/**
|
|
561
|
+
* 提前预加载指定页面 (会触发对应页面的 `onPreload` 生命周期)
|
|
562
|
+
*
|
|
563
|
+
* @param pageName 页面名称或页面的路径,可以带上 `queryString`
|
|
564
|
+
*
|
|
565
|
+
* 示例:
|
|
566
|
+
*
|
|
567
|
+
* ```js
|
|
568
|
+
* this.$preload('main?id=xxx&target=xxx');
|
|
569
|
+
* this.$preload('/page/main?userName=xxx&action=xxx');
|
|
570
|
+
* ```
|
|
571
|
+
*/
|
|
572
|
+
$preload(pageName: string): void | Promise<void>;
|
|
573
|
+
/**
|
|
574
|
+
* 点击代理方法,绑定 `$go` 逻辑
|
|
575
|
+
*
|
|
576
|
+
* 在元素上声明 `data-url` 作为跳转地址,支持切面方法:
|
|
577
|
+
*
|
|
578
|
+
* - `data-before` 跳转前执行
|
|
579
|
+
* - `data-after` 跳转后执行
|
|
580
|
+
*
|
|
581
|
+
* 示例:
|
|
582
|
+
*
|
|
583
|
+
* ```html
|
|
584
|
+
* <button
|
|
585
|
+
* catch:tap="$bindGo"
|
|
586
|
+
* data-url="/pages/play"
|
|
587
|
+
* data-before="onClickBefore"
|
|
588
|
+
* >click go</button>
|
|
589
|
+
* ```
|
|
590
|
+
*/
|
|
591
|
+
$bindGo(event: WechatMiniprogram.Touch): void | Promise<void>;
|
|
592
|
+
/**
|
|
593
|
+
* 点击代理方法,绑定 `$redirect` 逻辑
|
|
594
|
+
*
|
|
595
|
+
* 你需要在元素上声明 `data-url` 作为跳转地址,同时支持切面方法:
|
|
596
|
+
*
|
|
597
|
+
* - `data-before` 跳转前执行
|
|
598
|
+
* - `data-after` 跳转后执行
|
|
599
|
+
*
|
|
600
|
+
* 示例:
|
|
601
|
+
*
|
|
602
|
+
* ```html
|
|
603
|
+
* <button
|
|
604
|
+
* catch:tap="$bindRedirect"
|
|
605
|
+
* data-url="/pages/play"
|
|
606
|
+
* data-before="onClickBefore"
|
|
607
|
+
* >click redirect</button>
|
|
608
|
+
* ```
|
|
609
|
+
*/
|
|
610
|
+
$bindRedirect(event: WechatMiniprogram.Touch): void | Promise<void>;
|
|
611
|
+
/**
|
|
612
|
+
* 点击代理方法,绑定 `$switch` 逻辑
|
|
613
|
+
*
|
|
614
|
+
* 你需要在元素上声明 `data-url` 作为跳转地址,同时支持切面方法:
|
|
615
|
+
*
|
|
616
|
+
* - `data-before` 跳转前执行
|
|
617
|
+
* - `data-after` 跳转后执行
|
|
618
|
+
*
|
|
619
|
+
* 示例:
|
|
620
|
+
*
|
|
621
|
+
* ```html
|
|
622
|
+
* <button
|
|
623
|
+
* catch:tap="$bindSwitch"
|
|
624
|
+
* data-url="/pages/play"
|
|
625
|
+
* data-before="onClickBefore"
|
|
626
|
+
* >click switch</button>
|
|
627
|
+
* ```
|
|
628
|
+
*/
|
|
629
|
+
$bindSwitch(event: WechatMiniprogram.Touch): void | Promise<void>;
|
|
630
|
+
/**
|
|
631
|
+
* 点击代理方法,绑定 `$reLaunch` 逻辑。
|
|
632
|
+
*
|
|
633
|
+
* 你需要在元素上声明 `data-url` 作为跳转地址,同时支持切面方法:
|
|
634
|
+
*
|
|
635
|
+
* - `data-before` 跳转前执行
|
|
636
|
+
* - `data-after` 跳转后执行
|
|
637
|
+
*
|
|
638
|
+
* 示例:
|
|
639
|
+
*
|
|
640
|
+
* ```html
|
|
641
|
+
* <button
|
|
642
|
+
* catch:tap="$bindReLaunch"
|
|
643
|
+
* data-url="/pages/play"
|
|
644
|
+
* data-before="onClickBefore"
|
|
645
|
+
* >click relaunch</button>
|
|
646
|
+
* ```
|
|
647
|
+
*/
|
|
648
|
+
$bindRelaunch(event: WechatMiniprogram.Touch): void | Promise<void>;
|
|
649
|
+
/**
|
|
650
|
+
* 点击代理方法,绑定 `$back` 逻辑
|
|
651
|
+
* 你可以在元素上声明 `data-delta` 作为回退层数
|
|
652
|
+
*
|
|
653
|
+
* - `data-before` 跳转前执行
|
|
654
|
+
* - `data-after` 跳转后执行
|
|
655
|
+
*
|
|
656
|
+
* 示例:
|
|
657
|
+
*
|
|
658
|
+
* ```html
|
|
659
|
+
* <button
|
|
660
|
+
* catch:tap="$bindBack"
|
|
661
|
+
* data-delta="1"
|
|
662
|
+
* data-before="onClickBefore"
|
|
663
|
+
* >click relaunch</button>
|
|
664
|
+
* ```
|
|
665
|
+
*/
|
|
666
|
+
$bindBack(): Promise<void> | void;
|
|
667
|
+
} //#endregion
|
|
668
|
+
//#region src/page/typings.d.ts
|
|
693
669
|
type PageQuery = Record<string, string>;
|
|
694
670
|
interface PageState {
|
|
695
|
-
|
|
696
|
-
|
|
671
|
+
/** 是否是打开的第一个页面 */
|
|
672
|
+
firstOpen: boolean;
|
|
697
673
|
}
|
|
698
674
|
interface ExtendedPageLifeCycles {
|
|
699
|
-
|
|
700
|
-
|
|
701
|
-
|
|
702
|
-
|
|
703
|
-
|
|
704
|
-
|
|
705
|
-
|
|
706
|
-
|
|
707
|
-
|
|
708
|
-
|
|
709
|
-
|
|
710
|
-
|
|
711
|
-
|
|
712
|
-
|
|
713
|
-
|
|
714
|
-
|
|
715
|
-
|
|
716
|
-
|
|
717
|
-
|
|
718
|
-
|
|
719
|
-
|
|
720
|
-
|
|
721
|
-
|
|
722
|
-
|
|
723
|
-
|
|
724
|
-
|
|
725
|
-
|
|
726
|
-
|
|
727
|
-
|
|
728
|
-
|
|
729
|
-
|
|
730
|
-
|
|
731
|
-
|
|
732
|
-
|
|
733
|
-
|
|
734
|
-
|
|
675
|
+
/**
|
|
676
|
+
* 在页面注册时调用
|
|
677
|
+
*
|
|
678
|
+
* 此时页面的 this 还不可用
|
|
679
|
+
*/
|
|
680
|
+
onRegister(): void;
|
|
681
|
+
/**
|
|
682
|
+
* 在 `App.onLaunch` 触发时调用
|
|
683
|
+
*
|
|
684
|
+
* @param App.onLaunch 参数
|
|
685
|
+
*/
|
|
686
|
+
onAppLaunch(options: WechatMiniprogram.App.LaunchShowOption): void | Promise<void>;
|
|
687
|
+
/**
|
|
688
|
+
* 小程序在切入后台后被唤醒
|
|
689
|
+
*
|
|
690
|
+
* @param time 休眠时间 (单位 ms)
|
|
691
|
+
*/
|
|
692
|
+
onAwake(time: number): void | Promise<void>;
|
|
693
|
+
/**
|
|
694
|
+
* 页面预加载时触发
|
|
695
|
+
*
|
|
696
|
+
* 可在其他页面中使用 `this.$preload(pageNameWithArgs|pageUrl)` 触发特定页面的预加载周期
|
|
697
|
+
*
|
|
698
|
+
* @param options url 参数对象
|
|
699
|
+
*/
|
|
700
|
+
onPreload(options: PageQuery): void | Promise<void>;
|
|
701
|
+
/**
|
|
702
|
+
* 页面即将被导航时触发
|
|
703
|
+
*
|
|
704
|
+
* 需要在调用页面中使用框架提供的跳转方式 `this.$go(pageNameWithArgs|pageUrl)`
|
|
705
|
+
* 才能正确触发 `onNavigate`
|
|
706
|
+
*
|
|
707
|
+
* 另外需要特别注意第一次进入一个分包界面
|
|
708
|
+
* 或者是通过微信小程序二维码或微信内分享直接跳转到小程序子页面时同样不会触发
|
|
709
|
+
*/
|
|
710
|
+
onNavigate(options: PageQuery): void | Promise<void>;
|
|
735
711
|
}
|
|
736
712
|
interface ExtendedPageProperties {
|
|
737
|
-
|
|
738
|
-
|
|
739
|
-
|
|
740
|
-
|
|
741
|
-
|
|
742
|
-
|
|
743
|
-
|
|
744
|
-
|
|
745
|
-
|
|
746
|
-
|
|
747
|
-
|
|
748
|
-
|
|
749
|
-
|
|
750
|
-
|
|
751
|
-
|
|
752
|
-
|
|
753
|
-
|
|
754
|
-
|
|
755
|
-
|
|
756
|
-
|
|
757
|
-
|
|
758
|
-
|
|
713
|
+
/** 当前页面名称 */
|
|
714
|
+
$name: string;
|
|
715
|
+
/** 一些由框架生成的页面状态 */
|
|
716
|
+
$state: PageState;
|
|
717
|
+
/**
|
|
718
|
+
* 指定了 `ref` 的子组件实例映射
|
|
719
|
+
*
|
|
720
|
+
* 示例:
|
|
721
|
+
*
|
|
722
|
+
* ```html
|
|
723
|
+
* <custom-component binding="$" ref="customComp"/>
|
|
724
|
+
* ```
|
|
725
|
+
*
|
|
726
|
+
* ```js
|
|
727
|
+
* $Page({
|
|
728
|
+
* onLoad() {
|
|
729
|
+
* this.$refs.customComp // 根据ref属性获取子组件的实例引用
|
|
730
|
+
* }
|
|
731
|
+
* });
|
|
732
|
+
* ```
|
|
733
|
+
*/
|
|
734
|
+
$refs: RefMap;
|
|
759
735
|
}
|
|
760
736
|
interface ExtendedPageMethods<Data extends WechatMiniprogram.IAnyObject, Custom extends WechatMiniprogram.IAnyObject> extends InstanceEmitterMethods, NavigatorMethods {
|
|
761
|
-
|
|
762
|
-
|
|
763
|
-
|
|
764
|
-
|
|
765
|
-
|
|
766
|
-
|
|
767
|
-
|
|
768
|
-
|
|
769
|
-
|
|
770
|
-
|
|
771
|
-
|
|
772
|
-
|
|
773
|
-
|
|
774
|
-
|
|
737
|
+
/**
|
|
738
|
+
* 绑定组件函数
|
|
739
|
+
*/
|
|
740
|
+
$: typeof bind;
|
|
741
|
+
/**
|
|
742
|
+
* 获取当前页面实例。
|
|
743
|
+
*/
|
|
744
|
+
$currentPage(): PageInstance<Data, Custom>;
|
|
745
|
+
/**
|
|
746
|
+
* 获得页面路径
|
|
747
|
+
*
|
|
748
|
+
* @param name 页面简称
|
|
749
|
+
*/
|
|
750
|
+
$getPath(name: string): string;
|
|
775
751
|
}
|
|
776
752
|
type PageInstance<Data extends WechatMiniprogram.IAnyObject, Custom extends WechatMiniprogram.IAnyObject> = WechatMiniprogram.OptionalInterface<WechatMiniprogram.Page.ILifetime & ExtendedPageLifeCycles> & WechatMiniprogram.Page.InstanceProperties & WechatMiniprogram.Page.InstanceMethods<Data> & ExtendedPageMethods<Data, Custom> & ExtendedPageProperties & WechatMiniprogram.Page.Data<Data> & Custom;
|
|
777
753
|
type PageOptions<Data extends WechatMiniprogram.IAnyObject, Custom extends WechatMiniprogram.IAnyObject> = (Custom & Partial<WechatMiniprogram.Page.Data<Data>> & Partial<WechatMiniprogram.Page.ILifetime & ExtendedPageLifeCycles> & Partial<ExtendedPageProperties> & {
|
|
778
|
-
|
|
754
|
+
options?: WechatMiniprogram.Component.ComponentOptions;
|
|
779
755
|
}) & ThisType<PageInstance<Data, Custom>>;
|
|
780
756
|
type PageConstructor = <Data extends WechatMiniprogram.IAnyObject, Custom extends WechatMiniprogram.IAnyObject>(name: string, options: PageOptions<Data, Custom>) => void;
|
|
781
757
|
type TrivialPageInstance = PageInstance<WechatMiniprogram.IAnyObject, WechatMiniprogram.IAnyObject>;
|
|
782
|
-
type TrivialPageOptions = PageOptions<WechatMiniprogram.IAnyObject, WechatMiniprogram.IAnyObject>;
|
|
783
|
-
|
|
784
|
-
declare const $Page: PageConstructor;
|
|
785
|
-
|
|
758
|
+
type TrivialPageOptions = PageOptions<WechatMiniprogram.IAnyObject, WechatMiniprogram.IAnyObject>; //#endregion
|
|
759
|
+
//#region src/page/page.d.ts
|
|
760
|
+
declare const $Page: PageConstructor; //#endregion
|
|
761
|
+
//#region src/emitter/emitter.d.ts
|
|
786
762
|
type UserEmitter = EmitterInstance<WechatMiniprogram.IAnyObject>;
|
|
787
|
-
declare const userEmitter: UserEmitter;
|
|
788
|
-
|
|
763
|
+
declare const userEmitter: UserEmitter; //#endregion
|
|
764
|
+
//#region src/emitter/typings.d.ts
|
|
789
765
|
interface InstanceEmitterMethods {
|
|
790
|
-
|
|
791
|
-
|
|
792
|
-
|
|
793
|
-
|
|
794
|
-
|
|
795
|
-
|
|
796
|
-
|
|
797
|
-
|
|
798
|
-
|
|
799
|
-
|
|
800
|
-
|
|
801
|
-
|
|
802
|
-
|
|
803
|
-
|
|
804
|
-
|
|
805
|
-
|
|
806
|
-
|
|
807
|
-
|
|
808
|
-
|
|
809
|
-
|
|
810
|
-
|
|
811
|
-
|
|
812
|
-
|
|
813
|
-
|
|
814
|
-
|
|
815
|
-
|
|
816
|
-
|
|
817
|
-
|
|
818
|
-
|
|
819
|
-
|
|
820
|
-
|
|
821
|
-
|
|
822
|
-
|
|
823
|
-
|
|
824
|
-
|
|
825
|
-
|
|
826
|
-
|
|
827
|
-
|
|
828
|
-
|
|
829
|
-
|
|
830
|
-
|
|
831
|
-
|
|
832
|
-
|
|
833
|
-
|
|
834
|
-
* @param type 待触发的事件类型
|
|
835
|
-
* @param event 传递给所有响应函数的事件
|
|
836
|
-
* @memberOf [Emitter](https://miniapp-tool.github.io/api/enhance/emitter.html) 实例
|
|
837
|
-
*/
|
|
838
|
-
$emitAsync: UserEmitter["emitAsync"];
|
|
839
|
-
}
|
|
840
|
-
|
|
766
|
+
/** 事件名到处理函数的映射 */
|
|
767
|
+
$all: UserEmitter["all"];
|
|
768
|
+
/**
|
|
769
|
+
* 为特定事件类型注册处理函数
|
|
770
|
+
*
|
|
771
|
+
* @param type 监听的事件类型,使用 `'*'` 监听所有事件
|
|
772
|
+
* @param handler 待添加的响应函数
|
|
773
|
+
*/
|
|
774
|
+
$on: UserEmitter["on"];
|
|
775
|
+
/**
|
|
776
|
+
* 从特定事件类型移除指定监听器
|
|
777
|
+
*
|
|
778
|
+
* 如果省略 `handler`,给定类型的所有事件均被忽略
|
|
779
|
+
*
|
|
780
|
+
* @param type 取消监听的事件类型,使用 `'*'` 取消监听所有事件
|
|
781
|
+
* @param handler 待移除的响应函数
|
|
782
|
+
*/
|
|
783
|
+
$off: UserEmitter["off"];
|
|
784
|
+
/**
|
|
785
|
+
* 调用所有给定事件类型的响应函数
|
|
786
|
+
*
|
|
787
|
+
* 如果存在,`'*'` 响应函数会在符合事件类型的响应函数之后调用
|
|
788
|
+
*
|
|
789
|
+
* 注意,手动调用 `'*'` 事件不被支持
|
|
790
|
+
*
|
|
791
|
+
* @param type 待触发的事件类型
|
|
792
|
+
* @param event 传递给所有响应函数的事件
|
|
793
|
+
*/
|
|
794
|
+
$emit: UserEmitter["emit"];
|
|
795
|
+
/**
|
|
796
|
+
* 异步调用所有给定事件类型的响应函数
|
|
797
|
+
*
|
|
798
|
+
* 所有响应函数将被并行调用。
|
|
799
|
+
*
|
|
800
|
+
* 如果存在,`'*'` 响应函数会在符合事件类型的响应函数之后并行调用
|
|
801
|
+
*
|
|
802
|
+
* 注意,手动调用 `'*'` 事件不被支持
|
|
803
|
+
*
|
|
804
|
+
* @param type 待触发的事件类型
|
|
805
|
+
* @param event 传递给所有响应函数的事件
|
|
806
|
+
*/
|
|
807
|
+
$emitAsync: UserEmitter["emitAsync"];
|
|
808
|
+
} //#endregion
|
|
809
|
+
//#region src/app/typings.d.ts
|
|
841
810
|
interface ExtendsAppOptions {
|
|
842
|
-
|
|
843
|
-
|
|
844
|
-
|
|
845
|
-
|
|
846
|
-
|
|
847
|
-
|
|
811
|
+
/**
|
|
812
|
+
* 小程序在切入后台后被唤醒
|
|
813
|
+
*
|
|
814
|
+
* @param time 休眠时间 (单位ms)
|
|
815
|
+
*/
|
|
816
|
+
onAwake?(time: number): void;
|
|
848
817
|
}
|
|
849
818
|
type ExtendedAppMethods = InstanceEmitterMethods;
|
|
850
819
|
type AppOptions<Custom> = ExtendsAppOptions & Partial<WechatMiniprogram.App.Option> & Custom & Partial<ExtendedAppMethods> & ThisType<AppInstance<Custom>>;
|
|
851
820
|
type AppInstance<Custom> = AppOptions<Custom> & Custom & ExtendedAppMethods;
|
|
852
|
-
type AppConstructor = <Custom extends WechatMiniprogram.IAnyObject>(appOptions: AppOptions<Custom>) => void;
|
|
853
|
-
|
|
821
|
+
type AppConstructor = <Custom extends WechatMiniprogram.IAnyObject>(appOptions: AppOptions<Custom>) => void; //#endregion
|
|
822
|
+
//#region src/app/app.d.ts
|
|
854
823
|
declare const appState: {
|
|
855
|
-
|
|
856
|
-
|
|
857
|
-
|
|
858
|
-
lOpt: {};
|
|
859
|
-
/** 切入后台时的时间戳 */
|
|
860
|
-
hide: number;
|
|
824
|
+
/** 是否已启动 */launch: boolean; /** 启动参数 */
|
|
825
|
+
lOpt: {}; /** 切入后台时的时间戳 */
|
|
826
|
+
hide: number;
|
|
861
827
|
};
|
|
862
828
|
/**
|
|
863
829
|
* Application wrapper
|
|
864
830
|
*
|
|
865
831
|
* @param appOptions App Option
|
|
866
832
|
*/
|
|
867
|
-
declare const $App: AppConstructor;
|
|
868
|
-
|
|
833
|
+
declare const $App: AppConstructor; //#endregion
|
|
834
|
+
//#region src/config/typings.d.ts
|
|
869
835
|
interface AppConfigCommonOptions {
|
|
870
|
-
|
|
871
|
-
|
|
872
|
-
|
|
873
|
-
|
|
874
|
-
|
|
875
|
-
|
|
876
|
-
|
|
877
|
-
|
|
878
|
-
|
|
879
|
-
|
|
880
|
-
|
|
881
|
-
|
|
882
|
-
|
|
883
|
-
|
|
884
|
-
|
|
885
|
-
|
|
886
|
-
|
|
887
|
-
|
|
888
|
-
|
|
889
|
-
|
|
890
|
-
|
|
891
|
-
|
|
892
|
-
|
|
893
|
-
|
|
894
|
-
|
|
895
|
-
|
|
896
|
-
|
|
897
|
-
|
|
898
|
-
|
|
899
|
-
|
|
900
|
-
|
|
901
|
-
|
|
902
|
-
|
|
903
|
-
|
|
904
|
-
|
|
905
|
-
|
|
906
|
-
|
|
907
|
-
|
|
908
|
-
|
|
909
|
-
|
|
910
|
-
|
|
911
|
-
|
|
912
|
-
|
|
913
|
-
|
|
914
|
-
|
|
915
|
-
|
|
916
|
-
|
|
917
|
-
|
|
918
|
-
|
|
919
|
-
|
|
836
|
+
/**
|
|
837
|
+
* 主页页面名称或路径
|
|
838
|
+
*/
|
|
839
|
+
home?: string;
|
|
840
|
+
/**
|
|
841
|
+
* 跳转延迟执行的最长时间,单位 ms
|
|
842
|
+
*
|
|
843
|
+
* @description 异步 onNavigate 方法用时过久会直接调转
|
|
844
|
+
*
|
|
845
|
+
* @default 200
|
|
846
|
+
*/
|
|
847
|
+
maxDelay?: number;
|
|
848
|
+
/**
|
|
849
|
+
* 允许进行跳转据页面首屏渲染后的最小间隔时间,单位 ms
|
|
850
|
+
*
|
|
851
|
+
* @default 100
|
|
852
|
+
*/
|
|
853
|
+
minInterval?: number;
|
|
854
|
+
/**
|
|
855
|
+
* 自定义扩展组件
|
|
856
|
+
*
|
|
857
|
+
* 时机在框架执行扩展之前,可为每个组件挂载实例方法
|
|
858
|
+
*
|
|
859
|
+
* @param options 组件选项
|
|
860
|
+
*/
|
|
861
|
+
extendComponent?(options: TrivialComponentOptions): void;
|
|
862
|
+
/**
|
|
863
|
+
* 自定义注入组件
|
|
864
|
+
*
|
|
865
|
+
* 时机在框架执行扩展之后,这意味着你可以覆盖框架的方法
|
|
866
|
+
*
|
|
867
|
+
* @param options 组件选项
|
|
868
|
+
*/
|
|
869
|
+
injectComponent?(options: TrivialComponentOptions): void;
|
|
870
|
+
/**
|
|
871
|
+
* 自定义扩展页面,在框架执行扩展之前
|
|
872
|
+
*
|
|
873
|
+
* @param name 页面名称
|
|
874
|
+
* @param options 页面选项
|
|
875
|
+
*/
|
|
876
|
+
extendPage?(name: string, options: TrivialPageOptions): void;
|
|
877
|
+
/**
|
|
878
|
+
* 自定义注入页面
|
|
879
|
+
*
|
|
880
|
+
* 在框架执行扩展之后,这意味着你可以覆盖框架的方法
|
|
881
|
+
*
|
|
882
|
+
* @param name 页面名称
|
|
883
|
+
* @param options 页面选项
|
|
884
|
+
*/
|
|
885
|
+
injectPage?(name: string, options: TrivialPageOptions): void;
|
|
920
886
|
}
|
|
921
887
|
interface RoutePathConfig {
|
|
922
|
-
|
|
923
|
-
|
|
924
|
-
|
|
925
|
-
|
|
926
|
-
|
|
927
|
-
|
|
928
|
-
|
|
929
|
-
|
|
930
|
-
|
|
931
|
-
|
|
932
|
-
|
|
933
|
-
|
|
934
|
-
|
|
935
|
-
|
|
936
|
-
|
|
937
|
-
|
|
938
|
-
|
|
939
|
-
|
|
940
|
-
|
|
941
|
-
|
|
942
|
-
|
|
943
|
-
|
|
944
|
-
|
|
945
|
-
|
|
946
|
-
|
|
947
|
-
|
|
948
|
-
|
|
949
|
-
|
|
950
|
-
|
|
951
|
-
|
|
952
|
-
|
|
953
|
-
|
|
954
|
-
|
|
955
|
-
|
|
956
|
-
|
|
957
|
-
|
|
958
|
-
|
|
959
|
-
|
|
960
|
-
|
|
961
|
-
|
|
962
|
-
|
|
963
|
-
|
|
964
|
-
|
|
965
|
-
|
|
966
|
-
|
|
967
|
-
|
|
968
|
-
|
|
969
|
-
|
|
970
|
-
|
|
971
|
-
|
|
972
|
-
|
|
973
|
-
|
|
974
|
-
|
|
975
|
-
|
|
976
|
-
|
|
977
|
-
|
|
978
|
-
|
|
888
|
+
/**
|
|
889
|
+
* 当你给出的页面路径或简称无法通过 routeMap 解析时,会回退到此路径
|
|
890
|
+
*
|
|
891
|
+
* 填入小程序路径模式,小程序路径模式是一个路径字符串,用 `$name` 表示小程序简称的位置
|
|
892
|
+
*
|
|
893
|
+
* 例子: 你可以填入 `/pages/$name/$name` 来表达:
|
|
894
|
+
*
|
|
895
|
+
* - `main': '/pages/main/main`
|
|
896
|
+
* - `user': '/pages/user/user`
|
|
897
|
+
*/
|
|
898
|
+
defaultPage: string;
|
|
899
|
+
/**
|
|
900
|
+
* 你可以直接以对象形式表示简称到路径的映射。如:
|
|
901
|
+
*
|
|
902
|
+
* ```js
|
|
903
|
+
* {
|
|
904
|
+
* main: '/pages/main/main',
|
|
905
|
+
* cart: '/pages/cart/cart',
|
|
906
|
+
* user: '/pages/user/user',
|
|
907
|
+
* }
|
|
908
|
+
* ```
|
|
909
|
+
*
|
|
910
|
+
* 也支持以在页面复杂的情况下数组格式表示小程序路径映射,数组的元素有两种填写方式:
|
|
911
|
+
*
|
|
912
|
+
* - `[页面简称, 小程序路经]`
|
|
913
|
+
*
|
|
914
|
+
* - `[页面简称数组, 小程序路经模式]`
|
|
915
|
+
*
|
|
916
|
+
* 小程序路径模式是一个路径字符串,用 `$name` 表示小程序简称的位置
|
|
917
|
+
*
|
|
918
|
+
* 如:
|
|
919
|
+
*
|
|
920
|
+
* ```js
|
|
921
|
+
* [
|
|
922
|
+
* [['main', 'cart', 'user'], '/pages/$name/$name'],
|
|
923
|
+
* [['search', 'details', 'order'], '/shop/$name/$name'],
|
|
924
|
+
* ['about', '/others/about/about'],
|
|
925
|
+
* ]
|
|
926
|
+
* ```
|
|
927
|
+
*
|
|
928
|
+
* 等效于:
|
|
929
|
+
*
|
|
930
|
+
* ```js
|
|
931
|
+
* {
|
|
932
|
+
* 'main': '/pages/main/main',
|
|
933
|
+
* 'cart': '/pages/cart/cart',
|
|
934
|
+
* 'user': '/pages/user/user',
|
|
935
|
+
* 'search': '/shop/search/search',
|
|
936
|
+
* 'details': '/shop/details/details',
|
|
937
|
+
* 'order': '/shop/order/order',
|
|
938
|
+
* 'about': '/others/about/about',
|
|
939
|
+
* }
|
|
940
|
+
* ```
|
|
941
|
+
*
|
|
942
|
+
* @description 无法解析的路径会回退到 `defaultPage`
|
|
943
|
+
*/
|
|
944
|
+
pages?: Record<string, string> | [string | string[], string][];
|
|
979
945
|
}
|
|
980
946
|
interface RouteCustomConfig {
|
|
981
|
-
|
|
982
|
-
|
|
983
|
-
|
|
984
|
-
|
|
985
|
-
|
|
986
|
-
|
|
987
|
-
|
|
947
|
+
/**
|
|
948
|
+
* 获得页面路径
|
|
949
|
+
*
|
|
950
|
+
* @param pageName 页面简称
|
|
951
|
+
* @returns 页面路径
|
|
952
|
+
*/
|
|
953
|
+
getPath: (pageName: string) => string;
|
|
988
954
|
}
|
|
989
|
-
type AppConfigOptions = AppConfigCommonOptions & (RoutePathConfig | RouteCustomConfig);
|
|
990
|
-
|
|
955
|
+
type AppConfigOptions = AppConfigCommonOptions & (RoutePathConfig | RouteCustomConfig); //#endregion
|
|
956
|
+
//#region src/config/config.d.ts
|
|
991
957
|
interface Config extends Omit<AppConfigOptions, "defaultPage" | "pages"> {
|
|
992
|
-
|
|
993
|
-
|
|
994
|
-
|
|
995
|
-
|
|
996
|
-
|
|
997
|
-
|
|
998
|
-
|
|
958
|
+
/**
|
|
959
|
+
* 获得页面路径
|
|
960
|
+
*
|
|
961
|
+
* @param pageName 页面简称
|
|
962
|
+
* @returns 页面路径
|
|
963
|
+
*/
|
|
964
|
+
getPath: (pageName: string) => string;
|
|
999
965
|
}
|
|
1000
966
|
declare const $Config: (config: AppConfigOptions) => void;
|
|
1001
|
-
declare const getConfig: () => Config;
|
|
1002
|
-
|
|
967
|
+
declare const getConfig: () => Config; //#endregion
|
|
968
|
+
//#endregion
|
|
969
|
+
//#region ../file/dist/index.d.mts
|
|
970
|
+
//#region src/file.d.ts
|
|
1003
971
|
/** 文件编码 */
|
|
1004
972
|
type FileEncoding = "ascii" | "base64" | "binary" | "hex" | "latin1" | "ucs2" | "ucs-2" | "utf8" | "utf-8" | "utf16le" | "utf-16le";
|
|
1005
973
|
declare const dirname: (path: string) => string;
|
|
1006
|
-
/**
|
|
974
|
+
/**
|
|
975
|
+
* 判断文件或文件夹是否存在
|
|
976
|
+
*
|
|
977
|
+
* @param path 文件或文件夹路径
|
|
978
|
+
* @returns 是否存在
|
|
979
|
+
*/
|
|
1007
980
|
declare const exists: (path: string) => boolean;
|
|
1008
|
-
/**
|
|
981
|
+
/**
|
|
982
|
+
* 是否是文件
|
|
983
|
+
*
|
|
984
|
+
* @param path 文件路径
|
|
985
|
+
* @returns 是否是文件
|
|
986
|
+
*/
|
|
1009
987
|
declare const isFile: (path: string) => boolean;
|
|
1010
|
-
/**
|
|
988
|
+
/**
|
|
989
|
+
* 是否是文件夹
|
|
990
|
+
*
|
|
991
|
+
* @param path 文件夹路径
|
|
992
|
+
* @returns 是否是文件夹
|
|
993
|
+
*/
|
|
1011
994
|
declare const isDir: (path: string) => boolean;
|
|
1012
995
|
/**
|
|
1013
996
|
* 删除文件或文件夹
|
|
@@ -1018,11 +1001,16 @@ declare const isDir: (path: string) => boolean;
|
|
|
1018
1001
|
* @param type 要删除的类型
|
|
1019
1002
|
*/
|
|
1020
1003
|
declare const rm: (path: string, type?: "dir" | "file") => void;
|
|
1021
|
-
/**
|
|
1004
|
+
/**
|
|
1005
|
+
* 列出目录下内容
|
|
1006
|
+
*
|
|
1007
|
+
* @param path 目录路径
|
|
1008
|
+
* @returns 目录下的文件和文件夹列表,若目录不存在则返回空数组
|
|
1009
|
+
*/
|
|
1022
1010
|
declare const ls: (path: string) => string[];
|
|
1023
1011
|
interface ReadFile {
|
|
1024
|
-
|
|
1025
|
-
|
|
1012
|
+
(path: string): string | undefined;
|
|
1013
|
+
<T extends FileEncoding>(path: string, encoding: T): (T extends "binary" ? ArrayBuffer : string) | undefined;
|
|
1026
1014
|
}
|
|
1027
1015
|
/**
|
|
1028
1016
|
* 文件管理器读取文件包装
|
|
@@ -1059,6 +1047,7 @@ declare const saveFile: (tempFilePath: string, path: string) => void;
|
|
|
1059
1047
|
*
|
|
1060
1048
|
* @param onlinePath 在线文件路径
|
|
1061
1049
|
* @param localPath 本地保存路径
|
|
1050
|
+
* @returns 本地文件路径
|
|
1062
1051
|
*/
|
|
1063
1052
|
declare const saveOnlineFile: (onlinePath: string, localPath: string) => Promise<string>;
|
|
1064
1053
|
/**
|
|
@@ -1084,14 +1073,14 @@ declare const writeJSON: <T = unknown>(path: string, data: T, encoding?: FileEnc
|
|
|
1084
1073
|
* @param targetPath 解压路径
|
|
1085
1074
|
* @param successFunc 回调函数
|
|
1086
1075
|
*/
|
|
1087
|
-
declare const unzip: (zipFilePath: string, targetPath: string) => Promise<void>;
|
|
1088
|
-
|
|
1076
|
+
declare const unzip: (zipFilePath: string, targetPath: string) => Promise<void>; //#endregion
|
|
1077
|
+
//#region src/storage.d.ts
|
|
1089
1078
|
interface StorageData<T> {
|
|
1090
|
-
|
|
1091
|
-
|
|
1079
|
+
data: T;
|
|
1080
|
+
expired: number;
|
|
1092
1081
|
}
|
|
1093
1082
|
/** 存储 */
|
|
1094
|
-
declare const storage:
|
|
1083
|
+
declare const storage: Map<string, unknown>;
|
|
1095
1084
|
/**
|
|
1096
1085
|
* 存放数据
|
|
1097
1086
|
*
|
|
@@ -1112,26 +1101,27 @@ declare const take: <T = unknown>(key: string) => T | undefined;
|
|
|
1112
1101
|
*
|
|
1113
1102
|
* @param key key
|
|
1114
1103
|
* @param value value
|
|
1115
|
-
* @param
|
|
1104
|
+
* @param expire 过期时间
|
|
1116
1105
|
* - 0: 永久有效
|
|
1117
1106
|
* - 数字:过期时间,毫秒
|
|
1118
1107
|
* - `'keep'`: 表示保持上一次缓存时间
|
|
1119
|
-
* - `'once'
|
|
1108
|
+
* - `'once'`: 仅本次启动有效
|
|
1120
1109
|
*/
|
|
1121
|
-
declare const set: <
|
|
1110
|
+
declare const set: <Value = unknown>(key: string, value: Value, expire?: number | "keep" | "once") => void;
|
|
1122
1111
|
/**
|
|
1123
1112
|
* 设置数据
|
|
1124
1113
|
*
|
|
1125
1114
|
* @param key key
|
|
1126
1115
|
* @param value value
|
|
1127
|
-
* @param
|
|
1116
|
+
* @param expire 过期时间
|
|
1128
1117
|
* - 0: 永久有效
|
|
1129
1118
|
* - 数字:过期时间,毫秒
|
|
1130
1119
|
* - `'keep'`: 表示保持上一次缓存时间
|
|
1131
|
-
* - `'once'
|
|
1120
|
+
* - `'once'`: 仅本次启动有效
|
|
1132
1121
|
* @param [asyncCB] 异步回调方法,不填为同步
|
|
1122
|
+
* @returns 异步回调结果
|
|
1133
1123
|
*/
|
|
1134
|
-
declare const setAsync: <
|
|
1124
|
+
declare const setAsync: <Value = unknown>(key: string, value: Value, expire?: number | "keep" | "once") => Promise<WechatMiniprogram.GeneralCallbackResult | void>;
|
|
1135
1125
|
/**
|
|
1136
1126
|
* 获取
|
|
1137
1127
|
*
|
|
@@ -1159,6 +1149,7 @@ declare const remove: (key: string) => void;
|
|
|
1159
1149
|
*
|
|
1160
1150
|
* @param key key
|
|
1161
1151
|
* @param option 回调函数
|
|
1152
|
+
* @returns 异步回调结果
|
|
1162
1153
|
*/
|
|
1163
1154
|
declare const removeAsync: (key: string) => Promise<WechatMiniprogram.GeneralCallbackResult>;
|
|
1164
1155
|
/**
|
|
@@ -1171,749 +1162,845 @@ declare const check: () => void;
|
|
|
1171
1162
|
* 异步清除失效数据
|
|
1172
1163
|
*
|
|
1173
1164
|
* @param key key
|
|
1165
|
+
* @returns 异步回调结果
|
|
1174
1166
|
*/
|
|
1175
|
-
declare const checkAsync: () => Promise<void
|
|
1176
|
-
|
|
1167
|
+
declare const checkAsync: () => Promise<void>; //#endregion
|
|
1168
|
+
//#endregion
|
|
1169
|
+
//#region ../net/dist/index.d.mts
|
|
1170
|
+
//#region src/typings.d.ts
|
|
1177
1171
|
interface CookieType {
|
|
1178
|
-
|
|
1179
|
-
|
|
1180
|
-
|
|
1181
|
-
|
|
1182
|
-
|
|
1183
|
-
|
|
1184
|
-
|
|
1185
|
-
|
|
1186
|
-
|
|
1187
|
-
|
|
1188
|
-
|
|
1189
|
-
|
|
1190
|
-
|
|
1191
|
-
|
|
1192
|
-
|
|
1193
|
-
|
|
1194
|
-
|
|
1195
|
-
|
|
1196
|
-
|
|
1197
|
-
|
|
1198
|
-
|
|
1199
|
-
|
|
1200
|
-
|
|
1201
|
-
|
|
1202
|
-
|
|
1203
|
-
|
|
1204
|
-
|
|
1205
|
-
|
|
1206
|
-
|
|
1207
|
-
|
|
1208
|
-
|
|
1209
|
-
|
|
1210
|
-
|
|
1211
|
-
|
|
1212
|
-
|
|
1213
|
-
|
|
1214
|
-
|
|
1215
|
-
|
|
1216
|
-
}
|
|
1217
|
-
|
|
1172
|
+
/**
|
|
1173
|
+
* cookie name
|
|
1174
|
+
*/
|
|
1175
|
+
name: string;
|
|
1176
|
+
/**
|
|
1177
|
+
* cookie value
|
|
1178
|
+
*/
|
|
1179
|
+
value: string;
|
|
1180
|
+
/**
|
|
1181
|
+
* cookie path
|
|
1182
|
+
*/
|
|
1183
|
+
path?: string | undefined;
|
|
1184
|
+
/**
|
|
1185
|
+
* absolute expiration date for the cookie
|
|
1186
|
+
*/
|
|
1187
|
+
expires?: Date | undefined;
|
|
1188
|
+
/**
|
|
1189
|
+
* relative max age of the cookie in seconds from when the client receives it (integer or undefined)
|
|
1190
|
+
* Note: when using with express's res.cookie() method, multiply maxAge by 1000 to convert to milliseconds
|
|
1191
|
+
*/
|
|
1192
|
+
maxAge?: number | undefined;
|
|
1193
|
+
/**
|
|
1194
|
+
* domain for the cookie,
|
|
1195
|
+
* may begin with "." to indicate the named domain or any subdomain of it
|
|
1196
|
+
*/
|
|
1197
|
+
domain?: string | undefined;
|
|
1198
|
+
/**
|
|
1199
|
+
* indicates that this cookie should only be sent over HTTPs
|
|
1200
|
+
*/
|
|
1201
|
+
secure?: boolean | undefined;
|
|
1202
|
+
/**
|
|
1203
|
+
* indicates that this cookie should not be accessible to client-side JavaScript
|
|
1204
|
+
*/
|
|
1205
|
+
httpOnly?: boolean | undefined;
|
|
1206
|
+
/**
|
|
1207
|
+
* indicates a cookie ought not to be sent along with cross-site requests
|
|
1208
|
+
*/
|
|
1209
|
+
sameSite?: boolean | "lax" | "strict" | "none" | undefined;
|
|
1210
|
+
} //#endregion
|
|
1211
|
+
//#region src/cookie.d.ts
|
|
1218
1212
|
/**
|
|
1219
1213
|
* Cookie 类
|
|
1220
1214
|
*/
|
|
1221
1215
|
declare class Cookie {
|
|
1222
|
-
|
|
1223
|
-
|
|
1224
|
-
|
|
1225
|
-
|
|
1226
|
-
|
|
1227
|
-
|
|
1228
|
-
|
|
1229
|
-
|
|
1230
|
-
|
|
1231
|
-
|
|
1232
|
-
|
|
1233
|
-
|
|
1234
|
-
|
|
1235
|
-
|
|
1236
|
-
|
|
1237
|
-
|
|
1238
|
-
|
|
1239
|
-
|
|
1240
|
-
|
|
1241
|
-
|
|
1242
|
-
|
|
1243
|
-
|
|
1244
|
-
|
|
1245
|
-
|
|
1246
|
-
|
|
1247
|
-
|
|
1248
|
-
|
|
1249
|
-
}
|
|
1250
|
-
|
|
1251
|
-
|
|
1252
|
-
|
|
1253
|
-
|
|
1254
|
-
|
|
1255
|
-
|
|
1256
|
-
code: number | null;
|
|
1257
|
-
constructor({ code, message }: MpErrorOptions);
|
|
1258
|
-
toString(): string;
|
|
1216
|
+
name: string;
|
|
1217
|
+
value: string;
|
|
1218
|
+
domain: string;
|
|
1219
|
+
path: string;
|
|
1220
|
+
expires: Date | "session" | "outdate";
|
|
1221
|
+
httpOnly: boolean;
|
|
1222
|
+
constructor(cookie: CookieType);
|
|
1223
|
+
/**
|
|
1224
|
+
* @returns 是否已过期
|
|
1225
|
+
*/
|
|
1226
|
+
isExpired(): boolean;
|
|
1227
|
+
/**
|
|
1228
|
+
* @returns 是否可持久化
|
|
1229
|
+
*/
|
|
1230
|
+
isPersistence(): boolean;
|
|
1231
|
+
/**
|
|
1232
|
+
* @param domain 域名
|
|
1233
|
+
* @returns 是否匹配
|
|
1234
|
+
*/
|
|
1235
|
+
isDomainMatched(domain: string): boolean;
|
|
1236
|
+
/**
|
|
1237
|
+
* @param path 路径
|
|
1238
|
+
* @returns 是否匹配
|
|
1239
|
+
*/
|
|
1240
|
+
isPathMatched(path: string): boolean;
|
|
1241
|
+
toString(): string;
|
|
1242
|
+
toJSON(): CookieType;
|
|
1243
|
+
} //#endregion
|
|
1244
|
+
//#region ../shared/dist/index.d.mts
|
|
1245
|
+
//#endregion
|
|
1246
|
+
//#region src/error.d.ts
|
|
1247
|
+
interface MpErrorOptions$1 {
|
|
1248
|
+
code?: number;
|
|
1249
|
+
message?: string;
|
|
1259
1250
|
}
|
|
1260
|
-
|
|
1251
|
+
declare class MpError$1 extends Error {
|
|
1252
|
+
code: number | null;
|
|
1253
|
+
constructor({
|
|
1254
|
+
code,
|
|
1255
|
+
message
|
|
1256
|
+
}: MpErrorOptions$1);
|
|
1257
|
+
toString(): string;
|
|
1258
|
+
} //#endregion
|
|
1259
|
+
//#region src/utils.d.ts
|
|
1261
1260
|
/**
|
|
1262
1261
|
* @see RFC 6265
|
|
1262
|
+
* @param domain - Domain to normalize
|
|
1263
|
+
* @returns Normalized domain
|
|
1263
1264
|
*/
|
|
1264
1265
|
declare const normalizeDomain: (domain?: string) => string;
|
|
1265
1266
|
declare const getDomain: (domainOrURL: string) => string;
|
|
1266
1267
|
declare const getCookieScopeDomain: (domain?: string) => string[];
|
|
1267
1268
|
interface UrlInfo {
|
|
1268
|
-
|
|
1269
|
-
|
|
1269
|
+
domain: string;
|
|
1270
|
+
path: string;
|
|
1270
1271
|
}
|
|
1271
1272
|
declare const parseUrl: (url: string) => UrlInfo;
|
|
1272
1273
|
type Url = string;
|
|
1273
1274
|
type CookieOptions = Url | {
|
|
1274
|
-
|
|
1275
|
-
|
|
1275
|
+
domain?: string;
|
|
1276
|
+
path?: string;
|
|
1276
1277
|
};
|
|
1277
|
-
declare const getUrlInfo: (options: CookieOptions) => UrlInfo;
|
|
1278
|
-
|
|
1278
|
+
declare const getUrlInfo: (options: CookieOptions) => UrlInfo; //#endregion
|
|
1279
|
+
//#region src/cookieStore.d.ts
|
|
1279
1280
|
type CookieMap = Map<string, Cookie>;
|
|
1280
1281
|
type CookieStoreType = Map<string, CookieMap>;
|
|
1281
1282
|
interface SetCookieOptions {
|
|
1282
|
-
|
|
1283
|
-
|
|
1284
|
-
|
|
1285
|
-
|
|
1286
|
-
|
|
1287
|
-
|
|
1288
|
-
|
|
1283
|
+
name: string;
|
|
1284
|
+
value: string;
|
|
1285
|
+
domain: string;
|
|
1286
|
+
path?: string;
|
|
1287
|
+
expires?: Date;
|
|
1288
|
+
maxAge?: number;
|
|
1289
|
+
httpOnly?: boolean;
|
|
1289
1290
|
}
|
|
1290
1291
|
/**
|
|
1291
1292
|
* CookieStore 类
|
|
1292
1293
|
*/
|
|
1293
1294
|
declare class CookieStore {
|
|
1294
|
-
|
|
1295
|
-
|
|
1296
|
-
|
|
1297
|
-
|
|
1298
|
-
|
|
1299
|
-
/** 存储键值 */
|
|
1300
|
-
key?: string);
|
|
1301
|
-
/**
|
|
1302
|
-
* 获取 Cookie 对象
|
|
1303
|
-
*
|
|
1304
|
-
* @param name Cookie 名称
|
|
1305
|
-
* @param options Cookie 选项
|
|
1306
|
-
* @return cookie 对象
|
|
1307
|
-
*/
|
|
1308
|
-
get(name: string, options: CookieOptions): Cookie | null;
|
|
1309
|
-
/**
|
|
1310
|
-
* 获取 Cookie 值
|
|
1311
|
-
*
|
|
1312
|
-
* @param name Cookie 名称
|
|
1313
|
-
* @param options Cookie 选项
|
|
1314
|
-
* @return Cookie 值
|
|
1315
|
-
*/
|
|
1316
|
-
getValue(name: string, options: CookieOptions): string | undefined;
|
|
1317
|
-
/**
|
|
1318
|
-
* 是否有特定的 Cookie
|
|
1319
|
-
*
|
|
1320
|
-
* @param name Cookie 名称
|
|
1321
|
-
* @param options Cookie 选项
|
|
1322
|
-
* @return 是否存在
|
|
1323
|
-
*/
|
|
1324
|
-
has(name: string, options: CookieOptions): boolean;
|
|
1325
|
-
/**
|
|
1326
|
-
* 设置 cookie
|
|
1327
|
-
*/
|
|
1328
|
-
set(cookieOptions: SetCookieOptions): Cookie;
|
|
1329
|
-
/**
|
|
1330
|
-
* 删除 cookie
|
|
1331
|
-
*
|
|
1332
|
-
* @param name cookie 名称
|
|
1333
|
-
* @param domain 域名
|
|
1334
|
-
*/
|
|
1335
|
-
delete(name: string, domain?: string): void;
|
|
1336
|
-
/**
|
|
1337
|
-
* 获取所有域名和 cookies 结构
|
|
1338
|
-
*/
|
|
1339
|
-
list(): Record<string, Record<string, string>>;
|
|
1340
|
-
/**
|
|
1341
|
-
* 获取 cookies 对象数组
|
|
1342
|
-
*
|
|
1343
|
-
* @param options Cookie 选项
|
|
1344
|
-
* @return Cookie 对象数组
|
|
1345
|
-
*/
|
|
1346
|
-
getCookies(options: CookieOptions): Cookie[];
|
|
1347
|
-
/**
|
|
1348
|
-
* 获取所有 cookies 对象
|
|
1349
|
-
*
|
|
1350
|
-
* @return Cookie 对象数组
|
|
1351
|
-
*/
|
|
1352
|
-
getAllCookies(): Cookie[];
|
|
1353
|
-
/**
|
|
1354
|
-
* 获取 cookies key/value 对象
|
|
1355
|
-
*
|
|
1356
|
-
* @return 键值 Map
|
|
1357
|
-
*/
|
|
1358
|
-
getCookiesMap(options: CookieOptions): Record<string, string>;
|
|
1359
|
-
/**
|
|
1360
|
-
* 应用 Cookies
|
|
1361
|
-
*
|
|
1362
|
-
* @param cookies 待设置的 Cookie 数组
|
|
1363
|
-
*/
|
|
1364
|
-
apply(cookies: Cookie[]): void;
|
|
1365
|
-
/**
|
|
1366
|
-
* 清除 cookies
|
|
1367
|
-
*
|
|
1368
|
-
* @param domain 指定域名
|
|
1369
|
-
*/
|
|
1370
|
-
clear(domain?: string, exact?: boolean): void;
|
|
1371
|
-
/**
|
|
1372
|
-
* 应用 header cookies
|
|
1373
|
-
*
|
|
1374
|
-
* @param header 小程序 response header
|
|
1375
|
-
* @param domainOrURL Url 或域名
|
|
1376
|
-
*/
|
|
1377
|
-
applyHeader(header: unknown, domainOrURL: string): void;
|
|
1378
|
-
/**
|
|
1379
|
-
* 应用响应 cookies
|
|
1380
|
-
*
|
|
1381
|
-
* @param response 小程序 response
|
|
1382
|
-
* @param domainOrURL Url 或域名
|
|
1383
|
-
*/
|
|
1384
|
-
applyResponse(response: unknown, domainOrURL: string): void;
|
|
1385
|
-
/**
|
|
1386
|
-
* 获取 request cookie header
|
|
1387
|
-
*
|
|
1388
|
-
* @param options Cookie 选项
|
|
1389
|
-
* @return request cookie header
|
|
1390
|
-
*/
|
|
1391
|
-
getHeader(options: CookieOptions): string;
|
|
1392
|
-
}
|
|
1295
|
+
#private;
|
|
1296
|
+
/** 存储键值 */
|
|
1297
|
+
private readonly key;
|
|
1298
|
+
private readonly store;
|
|
1299
|
+
constructor(/** 存储键值 */
|
|
1393
1300
|
|
|
1301
|
+
key?: string);
|
|
1302
|
+
/**
|
|
1303
|
+
* 获取 Cookie 对象
|
|
1304
|
+
*
|
|
1305
|
+
* @param name Cookie 名称
|
|
1306
|
+
* @param options Cookie 选项
|
|
1307
|
+
* @returns cookie 对象
|
|
1308
|
+
*/
|
|
1309
|
+
get(name: string, options: CookieOptions): Cookie | null;
|
|
1310
|
+
/**
|
|
1311
|
+
* 获取 Cookie 值
|
|
1312
|
+
*
|
|
1313
|
+
* @param name Cookie 名称
|
|
1314
|
+
* @param options Cookie 选项
|
|
1315
|
+
* @returns Cookie 值
|
|
1316
|
+
*/
|
|
1317
|
+
getValue(name: string, options: CookieOptions): string | undefined;
|
|
1318
|
+
/**
|
|
1319
|
+
* 是否有特定的 Cookie
|
|
1320
|
+
*
|
|
1321
|
+
* @param name Cookie 名称
|
|
1322
|
+
* @param options Cookie 选项
|
|
1323
|
+
* @returns 是否存在
|
|
1324
|
+
*/
|
|
1325
|
+
has(name: string, options: CookieOptions): boolean;
|
|
1326
|
+
/**
|
|
1327
|
+
* 设置 cookie
|
|
1328
|
+
*
|
|
1329
|
+
* @param cookieOptions cookie 选项
|
|
1330
|
+
* @returns 设置的 cookie 对象
|
|
1331
|
+
*/
|
|
1332
|
+
set(cookieOptions: SetCookieOptions): Cookie;
|
|
1333
|
+
/**
|
|
1334
|
+
* 删除 cookie
|
|
1335
|
+
*
|
|
1336
|
+
* @param name cookie 名称
|
|
1337
|
+
* @param domain 域名
|
|
1338
|
+
*/
|
|
1339
|
+
delete(name: string, domain?: string): void;
|
|
1340
|
+
/**
|
|
1341
|
+
* 获取所有域名和 cookies 结构
|
|
1342
|
+
*
|
|
1343
|
+
* @returns 域名和 cookies 结构对象
|
|
1344
|
+
*/
|
|
1345
|
+
list(): Record<string, Record<string, string>>;
|
|
1346
|
+
/**
|
|
1347
|
+
* 获取 cookies 对象数组
|
|
1348
|
+
*
|
|
1349
|
+
* @param options Cookie 选项
|
|
1350
|
+
* @returns Cookie 对象数组
|
|
1351
|
+
*/
|
|
1352
|
+
getCookies(options: CookieOptions): Cookie[];
|
|
1353
|
+
/**
|
|
1354
|
+
* 获取所有 cookies 对象
|
|
1355
|
+
*
|
|
1356
|
+
* @returns Cookie 对象数组
|
|
1357
|
+
*/
|
|
1358
|
+
getAllCookies(): Cookie[];
|
|
1359
|
+
/**
|
|
1360
|
+
* 获取 cookies key/value 对象
|
|
1361
|
+
*
|
|
1362
|
+
* @param options Cookie 选项
|
|
1363
|
+
* @returns 键值 Map
|
|
1364
|
+
*/
|
|
1365
|
+
getCookiesMap(options: CookieOptions): Record<string, string>;
|
|
1366
|
+
/**
|
|
1367
|
+
* 应用 Cookies
|
|
1368
|
+
*
|
|
1369
|
+
* @param cookies 待设置的 Cookie 数组
|
|
1370
|
+
*/
|
|
1371
|
+
apply(cookies: Cookie[]): void;
|
|
1372
|
+
/**
|
|
1373
|
+
* 清除 cookies
|
|
1374
|
+
*
|
|
1375
|
+
* @param domain 指定域名
|
|
1376
|
+
* @param exact 是否仅清除指定域名的 cookies,默认为 false,即同时清除指定域名和其子域名的 cookies
|
|
1377
|
+
*/
|
|
1378
|
+
clear(domain?: string, exact?: boolean): void;
|
|
1379
|
+
/**
|
|
1380
|
+
* 应用 header cookies
|
|
1381
|
+
*
|
|
1382
|
+
* @param header 小程序 response header
|
|
1383
|
+
* @param domainOrURL Url 或域名
|
|
1384
|
+
*/
|
|
1385
|
+
applyHeader(header: unknown, domainOrURL: string): void;
|
|
1386
|
+
/**
|
|
1387
|
+
* 应用响应 cookies
|
|
1388
|
+
*
|
|
1389
|
+
* @param response 小程序 response
|
|
1390
|
+
* @param domainOrURL Url 或域名
|
|
1391
|
+
*/
|
|
1392
|
+
applyResponse(response: unknown, domainOrURL: string): void;
|
|
1393
|
+
/**
|
|
1394
|
+
* 获取 request cookie header
|
|
1395
|
+
*
|
|
1396
|
+
* @param options Cookie 选项
|
|
1397
|
+
* @returns request cookie header
|
|
1398
|
+
*/
|
|
1399
|
+
getHeader(options: CookieOptions): string;
|
|
1400
|
+
} //#endregion
|
|
1401
|
+
//#region src/headers.d.ts
|
|
1394
1402
|
declare const parseCookieHeader: (setCookieHeader: string, domain: string) => Cookie[];
|
|
1395
1403
|
type HeadersInit = [string, string][] | Record<string, string> | Headers;
|
|
1396
1404
|
declare class Headers {
|
|
1397
|
-
|
|
1398
|
-
|
|
1399
|
-
|
|
1400
|
-
|
|
1401
|
-
|
|
1402
|
-
|
|
1403
|
-
|
|
1404
|
-
|
|
1405
|
-
|
|
1406
|
-
|
|
1407
|
-
|
|
1408
|
-
|
|
1409
|
-
|
|
1410
|
-
|
|
1411
|
-
|
|
1412
|
-
|
|
1413
|
-
|
|
1414
|
-
|
|
1415
|
-
|
|
1416
|
-
|
|
1417
|
-
|
|
1418
|
-
|
|
1419
|
-
|
|
1420
|
-
|
|
1421
|
-
|
|
1422
|
-
|
|
1423
|
-
|
|
1424
|
-
|
|
1425
|
-
|
|
1426
|
-
|
|
1427
|
-
|
|
1428
|
-
|
|
1429
|
-
|
|
1430
|
-
|
|
1431
|
-
|
|
1432
|
-
|
|
1433
|
-
|
|
1434
|
-
|
|
1435
|
-
|
|
1436
|
-
|
|
1437
|
-
|
|
1405
|
+
private headers;
|
|
1406
|
+
private readonly headerNames;
|
|
1407
|
+
constructor(init?: HeadersInit);
|
|
1408
|
+
/**
|
|
1409
|
+
* Appends a new value onto an existing header inside a `Headers` object, or adds the header if it does not already exist.
|
|
1410
|
+
*
|
|
1411
|
+
* @param name - The name of the header
|
|
1412
|
+
* @param value - The value to append
|
|
1413
|
+
*/
|
|
1414
|
+
append(name: string, value: string): void;
|
|
1415
|
+
/**
|
|
1416
|
+
* Deletes a header from the `Headers` object.
|
|
1417
|
+
*
|
|
1418
|
+
* @param name - The name of the header to delete
|
|
1419
|
+
*/
|
|
1420
|
+
delete(name: string): void;
|
|
1421
|
+
/**
|
|
1422
|
+
* Returns a `ByteString` sequence of all the values of a header with a given name.
|
|
1423
|
+
*
|
|
1424
|
+
* @param name - The name of the header
|
|
1425
|
+
* @returns The header value or null if not found
|
|
1426
|
+
*/
|
|
1427
|
+
get(name: string): string | null;
|
|
1428
|
+
/**
|
|
1429
|
+
* Returns an array containing the values
|
|
1430
|
+
* of all Set-Cookie headers associated
|
|
1431
|
+
* with a response
|
|
1432
|
+
*
|
|
1433
|
+
* @returns An array of Set-Cookie header values
|
|
1434
|
+
*/
|
|
1435
|
+
getSetCookie(): string[];
|
|
1436
|
+
/**
|
|
1437
|
+
* Returns a boolean stating whether a `Headers` object contains a certain header.
|
|
1438
|
+
*
|
|
1439
|
+
* @param name - The name of the header to check
|
|
1440
|
+
* @returns Whether the header exists
|
|
1441
|
+
*/
|
|
1442
|
+
has(name: string): boolean;
|
|
1443
|
+
/**
|
|
1444
|
+
* Sets a new value for an existing header inside a `Headers` object, or adds the header if it does not already exist.
|
|
1445
|
+
*
|
|
1446
|
+
* @param name - The name of the header
|
|
1447
|
+
* @param value - The value to set
|
|
1448
|
+
*/
|
|
1449
|
+
set(name: string, value: string): void;
|
|
1450
|
+
/**
|
|
1451
|
+
* Traverses the `Headers` object,
|
|
1452
|
+
* calling the given callback for each header.
|
|
1453
|
+
*
|
|
1454
|
+
* @param callback - The callback function to call for each header
|
|
1455
|
+
* @param thisArg - The `this` value to use when calling the callback
|
|
1456
|
+
*/
|
|
1457
|
+
forEach<ThisArg = this>(callback: (this: ThisArg, value: string, name: string, parent: this) => void, thisArg?: ThisArg): void;
|
|
1458
|
+
keys(): IterableIterator<string>;
|
|
1459
|
+
values(): IterableIterator<string>;
|
|
1460
|
+
entries(): IterableIterator<[string, string]>;
|
|
1461
|
+
toObject(): Record<string, string>;
|
|
1462
|
+
[Symbol.iterator](): IterableIterator<[string, string]>;
|
|
1463
|
+
} //#endregion
|
|
1464
|
+
//#region src/urlSearchParams.d.ts
|
|
1438
1465
|
declare class URLSearchParams {
|
|
1439
|
-
|
|
1440
|
-
|
|
1441
|
-
|
|
1442
|
-
|
|
1443
|
-
|
|
1444
|
-
|
|
1445
|
-
|
|
1446
|
-
|
|
1447
|
-
|
|
1448
|
-
|
|
1449
|
-
|
|
1450
|
-
|
|
1451
|
-
|
|
1452
|
-
|
|
1453
|
-
|
|
1454
|
-
|
|
1455
|
-
|
|
1456
|
-
|
|
1457
|
-
|
|
1458
|
-
|
|
1459
|
-
|
|
1460
|
-
|
|
1461
|
-
|
|
1462
|
-
|
|
1463
|
-
|
|
1464
|
-
|
|
1465
|
-
|
|
1466
|
-
|
|
1467
|
-
|
|
1468
|
-
|
|
1469
|
-
|
|
1470
|
-
|
|
1471
|
-
|
|
1472
|
-
|
|
1473
|
-
|
|
1474
|
-
|
|
1475
|
-
|
|
1476
|
-
|
|
1477
|
-
|
|
1478
|
-
|
|
1479
|
-
|
|
1480
|
-
|
|
1481
|
-
|
|
1482
|
-
|
|
1483
|
-
|
|
1484
|
-
|
|
1485
|
-
|
|
1486
|
-
|
|
1487
|
-
|
|
1488
|
-
|
|
1489
|
-
|
|
1490
|
-
|
|
1491
|
-
|
|
1492
|
-
|
|
1493
|
-
|
|
1494
|
-
|
|
1495
|
-
|
|
1496
|
-
|
|
1497
|
-
|
|
1498
|
-
|
|
1499
|
-
|
|
1500
|
-
|
|
1501
|
-
|
|
1502
|
-
|
|
1503
|
-
|
|
1504
|
-
|
|
1505
|
-
|
|
1506
|
-
|
|
1507
|
-
|
|
1508
|
-
|
|
1509
|
-
|
|
1510
|
-
|
|
1511
|
-
|
|
1512
|
-
|
|
1513
|
-
|
|
1514
|
-
|
|
1515
|
-
|
|
1516
|
-
|
|
1517
|
-
|
|
1518
|
-
|
|
1519
|
-
|
|
1520
|
-
|
|
1521
|
-
|
|
1522
|
-
|
|
1523
|
-
|
|
1524
|
-
|
|
1525
|
-
|
|
1526
|
-
|
|
1527
|
-
|
|
1528
|
-
|
|
1529
|
-
|
|
1530
|
-
|
|
1531
|
-
|
|
1532
|
-
|
|
1533
|
-
|
|
1534
|
-
|
|
1535
|
-
|
|
1536
|
-
|
|
1537
|
-
|
|
1538
|
-
|
|
1539
|
-
|
|
1540
|
-
|
|
1541
|
-
|
|
1542
|
-
|
|
1543
|
-
|
|
1544
|
-
|
|
1545
|
-
|
|
1546
|
-
|
|
1547
|
-
|
|
1548
|
-
|
|
1549
|
-
|
|
1550
|
-
|
|
1551
|
-
|
|
1552
|
-
|
|
1553
|
-
|
|
1554
|
-
|
|
1555
|
-
|
|
1556
|
-
|
|
1557
|
-
|
|
1466
|
+
private params;
|
|
1467
|
+
constructor(init?: URLSearchParams | string | Record<string, string | string[]> | Iterable<[string, string]>);
|
|
1468
|
+
get size(): number;
|
|
1469
|
+
/**
|
|
1470
|
+
* Append a new name-value pair to the query string.
|
|
1471
|
+
*
|
|
1472
|
+
* @param name - The name of the parameter
|
|
1473
|
+
* @param value - The value of the parameter
|
|
1474
|
+
*/
|
|
1475
|
+
append(name: string, value: string): void;
|
|
1476
|
+
/**
|
|
1477
|
+
* If `value` is provided, removes all name-value pairs
|
|
1478
|
+
* where name is `name` and value is `value`..
|
|
1479
|
+
*
|
|
1480
|
+
* If `value` is not provided, removes all name-value pairs whose name is `name`.
|
|
1481
|
+
*
|
|
1482
|
+
* @param name - The name of the parameter to delete
|
|
1483
|
+
*/
|
|
1484
|
+
delete(name: string): void;
|
|
1485
|
+
/**
|
|
1486
|
+
* Returns an ES6 `Iterator` over each of the name-value pairs in the query.
|
|
1487
|
+
* Each item of the iterator is a JavaScript `Array`. The first item of the `Array`is the `name`, the second item of the `Array` is the `value`.
|
|
1488
|
+
*
|
|
1489
|
+
* Alias for `urlSearchParams[@@iterator]()`.
|
|
1490
|
+
*
|
|
1491
|
+
* @returns An iterator over the name-value pairs in the query
|
|
1492
|
+
*/
|
|
1493
|
+
entries(): IterableIterator<[string, string]>;
|
|
1494
|
+
/**
|
|
1495
|
+
* Iterates over each name-value pair in the query and invokes the given function.
|
|
1496
|
+
*
|
|
1497
|
+
* ```js
|
|
1498
|
+
* const myURL = new URL('https://example.org/?a=b&c=d');
|
|
1499
|
+
* myURL.searchParams.forEach((value, name, searchParams) => {
|
|
1500
|
+
* console.log(name, value, myURL.searchParams === searchParams);
|
|
1501
|
+
* });
|
|
1502
|
+
* // Prints:
|
|
1503
|
+
* // a b true
|
|
1504
|
+
* // c d true
|
|
1505
|
+
* ```
|
|
1506
|
+
* @param callbackfn Invoked for each name-value pair in the query
|
|
1507
|
+
* @param thisArg To be used as `this` value for when `fn` is called
|
|
1508
|
+
*/
|
|
1509
|
+
forEach(callbackfn: (value: string, key: string, iterable: URLSearchParams) => void, thisArg?: unknown): void;
|
|
1510
|
+
/**
|
|
1511
|
+
* Returns the value of the first name-value pair whose name is `name`. If there
|
|
1512
|
+
* are no such pairs, `null` is returned.
|
|
1513
|
+
*
|
|
1514
|
+
* @param name - The name of the parameter
|
|
1515
|
+
* @returns The value of the first matching parameter, or `null` if not found
|
|
1516
|
+
*/
|
|
1517
|
+
get(name: string): string | null;
|
|
1518
|
+
/**
|
|
1519
|
+
* Returns the values of all name-value pairs whose name is `name`. If there are
|
|
1520
|
+
* no such pairs, an empty array is returned.
|
|
1521
|
+
*
|
|
1522
|
+
* @param name - The name of the parameter
|
|
1523
|
+
* @returns An array of values associated with the given parameter
|
|
1524
|
+
*/
|
|
1525
|
+
getAll(name: string): string[];
|
|
1526
|
+
/**
|
|
1527
|
+
* Checks if the `URLSearchParams` object contains key-value pair(s) based on`name` and an optional `value` argument.
|
|
1528
|
+
*
|
|
1529
|
+
* If `value` is provided, returns `true` when name-value pair with
|
|
1530
|
+
* same `name` and `value` exists.
|
|
1531
|
+
*
|
|
1532
|
+
* If `value` is not provided, returns `true` if there is at least one name-value
|
|
1533
|
+
* pair whose name is `name`.
|
|
1534
|
+
*
|
|
1535
|
+
* @param name - The name of the parameter to check
|
|
1536
|
+
* @returns `true` if a matching name-value pair exists, `false` otherwise
|
|
1537
|
+
*/
|
|
1538
|
+
has(name: string): boolean;
|
|
1539
|
+
/**
|
|
1540
|
+
* Returns an ES6 `Iterator` over the names of each name-value pair.
|
|
1541
|
+
*
|
|
1542
|
+
* ```js
|
|
1543
|
+
* const params = new URLSearchParams('foo=bar&foo=baz');
|
|
1544
|
+
* for (const name of params.keys()) {
|
|
1545
|
+
* console.log(name);
|
|
1546
|
+
* }
|
|
1547
|
+
* // Prints:
|
|
1548
|
+
* // foo
|
|
1549
|
+
* // foo
|
|
1550
|
+
* ```
|
|
1551
|
+
*
|
|
1552
|
+
* @returns An iterator over the names of each name-value pair
|
|
1553
|
+
*/
|
|
1554
|
+
keys(): IterableIterator<string>;
|
|
1555
|
+
/**
|
|
1556
|
+
* Sets the value in the `URLSearchParams` object associated with `name` to`value`. If there are any pre-existing name-value pairs whose names are `name`,
|
|
1557
|
+
* set the first such pair's value to `value` and remove all others. If not,
|
|
1558
|
+
* append the name-value pair to the query string.
|
|
1559
|
+
*
|
|
1560
|
+
* ```js
|
|
1561
|
+
* const params = new URLSearchParams();
|
|
1562
|
+
* params.append('foo', 'bar');
|
|
1563
|
+
* params.append('foo', 'baz');
|
|
1564
|
+
* params.append('abc', 'def');
|
|
1565
|
+
* console.log(params.toString());
|
|
1566
|
+
* // Prints foo=bar&foo=baz&abc=def
|
|
1567
|
+
*
|
|
1568
|
+
* params.set('foo', 'def');
|
|
1569
|
+
* params.set('xyz', 'opq');
|
|
1570
|
+
* console.log(params.toString());
|
|
1571
|
+
* // Prints foo=def&abc=def&xyz=opq
|
|
1572
|
+
* ```
|
|
1573
|
+
*
|
|
1574
|
+
* @param name - The name of the parameter to set
|
|
1575
|
+
* @param value - The value to set
|
|
1576
|
+
*/
|
|
1577
|
+
set(name: string, value: string): void;
|
|
1578
|
+
/**
|
|
1579
|
+
* Sort all existing name-value pairs in-place by their names. Sorting is done
|
|
1580
|
+
* with a [stable sorting algorithm](https://en.wikipedia.org/wiki/Sorting_algorithm#Stability), so relative order between name-value pairs
|
|
1581
|
+
* with the same name is preserved.
|
|
1582
|
+
*
|
|
1583
|
+
* This method can be used, in particular, to increase cache hits.
|
|
1584
|
+
*
|
|
1585
|
+
* ```js
|
|
1586
|
+
* const params = new URLSearchParams('query[]=abc&type=search&query[]=123');
|
|
1587
|
+
* params.sort();
|
|
1588
|
+
* console.log(params.toString());
|
|
1589
|
+
* // Prints query%5B%5D=abc&query%5B%5D=123&type=search
|
|
1590
|
+
* ```
|
|
1591
|
+
*/
|
|
1592
|
+
sort(): void;
|
|
1593
|
+
/**
|
|
1594
|
+
* Returns the search parameters serialized as a string, with characters
|
|
1595
|
+
* percent-encoded where necessary.
|
|
1596
|
+
*
|
|
1597
|
+
* @returns The serialized query string
|
|
1598
|
+
*/
|
|
1599
|
+
toString(): string;
|
|
1600
|
+
/**
|
|
1601
|
+
* Returns an ES6 `Iterator` over the values of each name-value pair.
|
|
1602
|
+
*
|
|
1603
|
+
* @returns An iterator over the values
|
|
1604
|
+
*/
|
|
1605
|
+
values(): IterableIterator<string>;
|
|
1606
|
+
[Symbol.iterator](): IterableIterator<[string, string]>;
|
|
1607
|
+
} //#endregion
|
|
1608
|
+
//#region src/request.d.ts
|
|
1558
1609
|
declare const requestCookieStore: CookieStore;
|
|
1559
1610
|
type RequestBody = WechatMiniprogram.IAnyObject | ArrayBuffer | URLSearchParams | string | null;
|
|
1560
1611
|
interface RequestOptions<T extends Record<never, never> | unknown[] | string | ArrayBuffer = Record<string, any>> extends Omit<WechatMiniprogram.RequestOption<T>, "url" | "method" | "header" | "data"> {
|
|
1561
|
-
|
|
1562
|
-
|
|
1563
|
-
|
|
1564
|
-
|
|
1565
|
-
|
|
1566
|
-
|
|
1567
|
-
|
|
1568
|
-
|
|
1569
|
-
|
|
1570
|
-
|
|
1571
|
-
|
|
1572
|
-
|
|
1573
|
-
|
|
1574
|
-
|
|
1575
|
-
|
|
1576
|
-
|
|
1577
|
-
|
|
1578
|
-
|
|
1579
|
-
|
|
1580
|
-
|
|
1612
|
+
/**
|
|
1613
|
+
* 请求方法
|
|
1614
|
+
*/
|
|
1615
|
+
method?: "options" | "OPTIONS" | "get" | "GET" | "head" | "HEAD" | "post" | "POST" | "put" | "PUT" | "delete" | "DELETE" | "trace" | "TRACE" | "connect" | "CONNECT" | undefined;
|
|
1616
|
+
/**
|
|
1617
|
+
* 请求头
|
|
1618
|
+
*/
|
|
1619
|
+
headers?: Record<string, string>;
|
|
1620
|
+
/**
|
|
1621
|
+
* 请求主体
|
|
1622
|
+
*/
|
|
1623
|
+
body?: RequestBody;
|
|
1624
|
+
/**
|
|
1625
|
+
* Cookie 作用域
|
|
1626
|
+
*/
|
|
1627
|
+
cookieScope?: string;
|
|
1628
|
+
/**
|
|
1629
|
+
* Cookie Store
|
|
1630
|
+
*/
|
|
1631
|
+
cookieStore?: CookieStore;
|
|
1581
1632
|
}
|
|
1582
1633
|
interface RequestResponse<T extends Record<never, never> | unknown[] | string | ArrayBuffer = Record<string, any>> {
|
|
1583
|
-
|
|
1584
|
-
|
|
1585
|
-
|
|
1586
|
-
|
|
1587
|
-
|
|
1588
|
-
|
|
1634
|
+
/** Status Code */
|
|
1635
|
+
status: number;
|
|
1636
|
+
/** Response headers */
|
|
1637
|
+
headers: Headers;
|
|
1638
|
+
/** Response data */
|
|
1639
|
+
data: T;
|
|
1589
1640
|
}
|
|
1590
1641
|
type RequestType = <T extends Record<never, never> | unknown[] | string | ArrayBuffer = Record<string, any>>(url: string, options?: RequestOptions<T>) => Promise<RequestResponse<T>>;
|
|
1591
|
-
declare const request: <T extends Record<never, never> | unknown[] | string | ArrayBuffer = Record<string, any>>(
|
|
1592
|
-
|
|
1593
|
-
url: string, {
|
|
1642
|
+
declare const request: <T extends Record<never, never> | unknown[] | string | ArrayBuffer = Record<string, any>>(/** 接口地址 */
|
|
1643
|
+
|
|
1644
|
+
url: string, {
|
|
1645
|
+
method,
|
|
1646
|
+
headers,
|
|
1647
|
+
body,
|
|
1648
|
+
cookieScope,
|
|
1649
|
+
cookieStore,
|
|
1650
|
+
...options
|
|
1651
|
+
}?: RequestOptions<T>) => Promise<RequestResponse<T>>;
|
|
1594
1652
|
interface RequestInitOptions extends Pick<WechatMiniprogram.RequestOption, "redirect" | "enableCache" | "enableChunked" | "enableHttp2" | "enableHttpDNS" | "enableQuic" | "httpDNSServiceId" | "forceCellularNetwork" | "timeout"> {
|
|
1595
|
-
|
|
1596
|
-
|
|
1597
|
-
|
|
1598
|
-
|
|
1599
|
-
|
|
1600
|
-
|
|
1601
|
-
|
|
1602
|
-
|
|
1603
|
-
|
|
1604
|
-
|
|
1605
|
-
|
|
1606
|
-
|
|
1607
|
-
|
|
1608
|
-
|
|
1609
|
-
|
|
1610
|
-
|
|
1611
|
-
|
|
1612
|
-
|
|
1613
|
-
|
|
1614
|
-
|
|
1615
|
-
|
|
1616
|
-
|
|
1617
|
-
|
|
1618
|
-
|
|
1619
|
-
|
|
1620
|
-
|
|
1621
|
-
|
|
1622
|
-
|
|
1623
|
-
|
|
1624
|
-
|
|
1625
|
-
|
|
1626
|
-
|
|
1627
|
-
|
|
1628
|
-
|
|
1629
|
-
|
|
1630
|
-
|
|
1631
|
-
|
|
1632
|
-
|
|
1633
|
-
|
|
1634
|
-
|
|
1653
|
+
/**
|
|
1654
|
+
* 访问的默认域名
|
|
1655
|
+
*/
|
|
1656
|
+
server?: string;
|
|
1657
|
+
/**
|
|
1658
|
+
* Cookie 存储
|
|
1659
|
+
*/
|
|
1660
|
+
cookieStore?: CookieStore | string;
|
|
1661
|
+
/**
|
|
1662
|
+
* 请求选项处理器
|
|
1663
|
+
*/
|
|
1664
|
+
requestHandler?: <T extends Record<never, never> | unknown[] | string | ArrayBuffer = Record<string, any>>(/** 请求地址 */
|
|
1665
|
+
|
|
1666
|
+
url: string, /** 请求配置 */
|
|
1667
|
+
|
|
1668
|
+
options: RequestOptions<T>) => RequestOptions<T>;
|
|
1669
|
+
/**
|
|
1670
|
+
* 响应处理器
|
|
1671
|
+
*
|
|
1672
|
+
* @throws {MpError} 自定义的错误数据
|
|
1673
|
+
*/
|
|
1674
|
+
responseHandler?: <T extends Record<never, never> | unknown[] | string | ArrayBuffer = Record<string, any>>(/** 响应数据 */
|
|
1675
|
+
|
|
1676
|
+
response: RequestResponse<T>, /** 请求地址 */
|
|
1677
|
+
|
|
1678
|
+
url: string, /** 请求配置 */
|
|
1679
|
+
|
|
1680
|
+
options: RequestOptions<T>) => RequestResponse<T>;
|
|
1681
|
+
/**
|
|
1682
|
+
* 错误处理器
|
|
1683
|
+
*
|
|
1684
|
+
* @throws {MpError} 自定义的错误数据
|
|
1685
|
+
*/
|
|
1686
|
+
errorHandler?: <T extends Record<never, never> | unknown[] | string | ArrayBuffer = Record<string, any>>(/** 错误信息 */
|
|
1687
|
+
|
|
1688
|
+
error: MpError$1, /** 请求地址 */
|
|
1689
|
+
|
|
1690
|
+
url: string, /** 请求配置 */
|
|
1691
|
+
|
|
1692
|
+
options: RequestOptions<T>) => RequestResponse<T> | never;
|
|
1635
1693
|
}
|
|
1636
1694
|
interface RequestFactory {
|
|
1637
|
-
|
|
1638
|
-
|
|
1639
|
-
|
|
1640
|
-
|
|
1641
|
-
|
|
1642
|
-
|
|
1643
|
-
|
|
1644
|
-
|
|
1695
|
+
/**
|
|
1696
|
+
* Cookie 存储
|
|
1697
|
+
*/
|
|
1698
|
+
cookieStore: CookieStore;
|
|
1699
|
+
/**
|
|
1700
|
+
* 请求方法
|
|
1701
|
+
*/
|
|
1702
|
+
request: RequestType;
|
|
1645
1703
|
}
|
|
1646
1704
|
/**
|
|
1647
1705
|
* @param options request 配置选项
|
|
1706
|
+
* @returns 请求工厂,包含一个请求方法和一个 Cookie 存储
|
|
1648
1707
|
*/
|
|
1649
|
-
declare const createRequest: ({
|
|
1650
|
-
|
|
1651
|
-
|
|
1652
|
-
|
|
1653
|
-
|
|
1654
|
-
|
|
1655
|
-
|
|
1656
|
-
|
|
1657
|
-
|
|
1658
|
-
|
|
1708
|
+
declare const createRequest: ({
|
|
1709
|
+
cookieStore,
|
|
1710
|
+
server,
|
|
1711
|
+
requestHandler,
|
|
1712
|
+
responseHandler,
|
|
1713
|
+
errorHandler,
|
|
1714
|
+
...defaultOptions
|
|
1715
|
+
}?: RequestInitOptions) => RequestFactory; //#endregion
|
|
1716
|
+
//#endregion
|
|
1717
|
+
//#region ../../node_modules/.pnpm/domelementtype@3.0.0/node_modules/domelementtype/dist/index.d.ts
|
|
1659
1718
|
/** Types of elements found in htmlparser2's DOM */
|
|
1660
1719
|
declare enum ElementType {
|
|
1661
|
-
|
|
1662
|
-
|
|
1663
|
-
|
|
1664
|
-
|
|
1665
|
-
|
|
1666
|
-
|
|
1667
|
-
|
|
1668
|
-
|
|
1669
|
-
|
|
1670
|
-
|
|
1671
|
-
|
|
1672
|
-
|
|
1673
|
-
|
|
1674
|
-
|
|
1675
|
-
|
|
1676
|
-
|
|
1677
|
-
|
|
1678
|
-
|
|
1720
|
+
/** Type for the root element of a document */
|
|
1721
|
+
Root = "root",
|
|
1722
|
+
/** Type for Text */
|
|
1723
|
+
Text = "text",
|
|
1724
|
+
/** Type for <? ... ?> */
|
|
1725
|
+
Directive = "directive",
|
|
1726
|
+
/** Type for <!-- ... --> */
|
|
1727
|
+
Comment = "comment",
|
|
1728
|
+
/** Type for <script> tags */
|
|
1729
|
+
Script = "script",
|
|
1730
|
+
/** Type for <style> tags */
|
|
1731
|
+
Style = "style",
|
|
1732
|
+
/** Type for Any tag */
|
|
1733
|
+
Tag = "tag",
|
|
1734
|
+
/** Type for <![CDATA[ ... ]]> */
|
|
1735
|
+
CDATA = "cdata",
|
|
1736
|
+
/** Type for <!doctype ...> */
|
|
1737
|
+
Doctype = "doctype"
|
|
1679
1738
|
}
|
|
1680
|
-
|
|
1739
|
+
//#endregion
|
|
1740
|
+
//#region ../../node_modules/.pnpm/domhandler@6.0.1/node_modules/domhandler/dist/node.d.ts
|
|
1681
1741
|
interface SourceCodeLocation {
|
|
1682
|
-
|
|
1683
|
-
|
|
1684
|
-
|
|
1685
|
-
|
|
1686
|
-
|
|
1687
|
-
|
|
1688
|
-
|
|
1689
|
-
|
|
1690
|
-
|
|
1691
|
-
|
|
1692
|
-
|
|
1693
|
-
|
|
1742
|
+
/** One-based line index of the first character. */
|
|
1743
|
+
startLine: number;
|
|
1744
|
+
/** One-based column index of the first character. */
|
|
1745
|
+
startCol: number;
|
|
1746
|
+
/** Zero-based first character index. */
|
|
1747
|
+
startOffset: number;
|
|
1748
|
+
/** One-based line index of the last character. */
|
|
1749
|
+
endLine: number;
|
|
1750
|
+
/** One-based column index of the last character. Points directly *after* the last character. */
|
|
1751
|
+
endCol: number;
|
|
1752
|
+
/** Zero-based last character index. Points directly *after* the last character. */
|
|
1753
|
+
endOffset: number;
|
|
1694
1754
|
}
|
|
1695
1755
|
interface TagSourceCodeLocation extends SourceCodeLocation {
|
|
1696
|
-
|
|
1697
|
-
|
|
1756
|
+
startTag?: SourceCodeLocation;
|
|
1757
|
+
endTag?: SourceCodeLocation;
|
|
1698
1758
|
}
|
|
1699
|
-
|
|
1700
|
-
|
|
1701
|
-
|
|
1759
|
+
/**
|
|
1760
|
+
* A node that can have children.
|
|
1761
|
+
*/
|
|
1762
|
+
type ParentNode = Document | Element | CDATA;
|
|
1763
|
+
/**
|
|
1764
|
+
* A node that can have a parent.
|
|
1765
|
+
*/
|
|
1766
|
+
type ChildNode = Text | Comment | ProcessingInstruction | Element | CDATA | Document;
|
|
1767
|
+
/**
|
|
1768
|
+
* Any node in the DOM tree.
|
|
1769
|
+
*/
|
|
1770
|
+
type AnyNode = ParentNode | ChildNode;
|
|
1702
1771
|
/**
|
|
1703
1772
|
* This object will be used as the prototype for Nodes when creating a
|
|
1704
1773
|
* DOM-Level-1-compliant structure.
|
|
1705
1774
|
*/
|
|
1706
1775
|
declare abstract class Node {
|
|
1707
|
-
|
|
1708
|
-
|
|
1709
|
-
|
|
1710
|
-
|
|
1711
|
-
|
|
1712
|
-
|
|
1713
|
-
|
|
1714
|
-
|
|
1715
|
-
|
|
1716
|
-
|
|
1717
|
-
|
|
1718
|
-
|
|
1719
|
-
|
|
1720
|
-
|
|
1721
|
-
|
|
1722
|
-
|
|
1723
|
-
|
|
1724
|
-
|
|
1725
|
-
|
|
1726
|
-
|
|
1727
|
-
|
|
1728
|
-
|
|
1729
|
-
|
|
1730
|
-
|
|
1731
|
-
|
|
1732
|
-
|
|
1733
|
-
|
|
1734
|
-
|
|
1735
|
-
|
|
1736
|
-
|
|
1737
|
-
|
|
1738
|
-
|
|
1739
|
-
|
|
1740
|
-
|
|
1741
|
-
|
|
1742
|
-
|
|
1743
|
-
|
|
1744
|
-
|
|
1745
|
-
|
|
1746
|
-
|
|
1747
|
-
|
|
1748
|
-
|
|
1749
|
-
|
|
1750
|
-
|
|
1751
|
-
|
|
1752
|
-
|
|
1753
|
-
|
|
1754
|
-
cloneNode<T extends Node>(this: T, recursive?: boolean): T;
|
|
1776
|
+
/** The type of the node. */
|
|
1777
|
+
abstract readonly type: ElementType;
|
|
1778
|
+
/** Parent of the node */
|
|
1779
|
+
parent: ParentNode | null;
|
|
1780
|
+
/** Previous sibling */
|
|
1781
|
+
prev: ChildNode | null;
|
|
1782
|
+
/** Next sibling */
|
|
1783
|
+
next: ChildNode | null;
|
|
1784
|
+
/** The start index of the node. Requires `withStartIndices` on the handler to be `true. */
|
|
1785
|
+
startIndex: number | null;
|
|
1786
|
+
/** The end index of the node. Requires `withEndIndices` on the handler to be `true. */
|
|
1787
|
+
endIndex: number | null;
|
|
1788
|
+
/**
|
|
1789
|
+
* `parse5` source code location info.
|
|
1790
|
+
*
|
|
1791
|
+
* Available if parsing with parse5 and location info is enabled.
|
|
1792
|
+
*/
|
|
1793
|
+
sourceCodeLocation?: SourceCodeLocation | null;
|
|
1794
|
+
/**
|
|
1795
|
+
* [DOM spec](https://dom.spec.whatwg.org/#dom-node-nodetype)-compatible
|
|
1796
|
+
* node {@link type}.
|
|
1797
|
+
*/
|
|
1798
|
+
abstract readonly nodeType: number;
|
|
1799
|
+
/**
|
|
1800
|
+
* Same as {@link parent}.
|
|
1801
|
+
* [DOM spec](https://dom.spec.whatwg.org)-compatible alias.
|
|
1802
|
+
*/
|
|
1803
|
+
get parentNode(): ParentNode | null;
|
|
1804
|
+
set parentNode(parent: ParentNode | null);
|
|
1805
|
+
/**
|
|
1806
|
+
* Same as {@link prev}.
|
|
1807
|
+
* [DOM spec](https://dom.spec.whatwg.org)-compatible alias.
|
|
1808
|
+
*/
|
|
1809
|
+
get previousSibling(): ChildNode | null;
|
|
1810
|
+
set previousSibling(previous: ChildNode | null);
|
|
1811
|
+
/**
|
|
1812
|
+
* Same as {@link next}.
|
|
1813
|
+
* [DOM spec](https://dom.spec.whatwg.org)-compatible alias.
|
|
1814
|
+
*/
|
|
1815
|
+
get nextSibling(): ChildNode | null;
|
|
1816
|
+
set nextSibling(next: ChildNode | null);
|
|
1817
|
+
/**
|
|
1818
|
+
* Clone this node, and optionally its children.
|
|
1819
|
+
* @param recursive Clone child nodes as well.
|
|
1820
|
+
* @returns A clone of the node.
|
|
1821
|
+
*/
|
|
1822
|
+
cloneNode<T extends Node>(this: T, recursive?: boolean): T;
|
|
1755
1823
|
}
|
|
1756
1824
|
/**
|
|
1757
1825
|
* A node that contains some data.
|
|
1758
1826
|
*/
|
|
1759
1827
|
declare abstract class DataNode extends Node {
|
|
1760
|
-
|
|
1761
|
-
|
|
1762
|
-
|
|
1763
|
-
|
|
1764
|
-
|
|
1765
|
-
|
|
1766
|
-
|
|
1767
|
-
|
|
1768
|
-
|
|
1769
|
-
|
|
1770
|
-
|
|
1828
|
+
data: string;
|
|
1829
|
+
/**
|
|
1830
|
+
* @param data The content of the data node
|
|
1831
|
+
*/
|
|
1832
|
+
constructor(data: string);
|
|
1833
|
+
/**
|
|
1834
|
+
* Same as {@link data}.
|
|
1835
|
+
* [DOM spec](https://dom.spec.whatwg.org)-compatible alias.
|
|
1836
|
+
*/
|
|
1837
|
+
get nodeValue(): string;
|
|
1838
|
+
set nodeValue(data: string);
|
|
1771
1839
|
}
|
|
1772
1840
|
/**
|
|
1773
1841
|
* Text within the document.
|
|
1774
1842
|
*/
|
|
1775
1843
|
declare class Text extends DataNode {
|
|
1776
|
-
|
|
1777
|
-
|
|
1844
|
+
type: ElementType.Text;
|
|
1845
|
+
get nodeType(): 3;
|
|
1778
1846
|
}
|
|
1779
1847
|
/**
|
|
1780
1848
|
* Comments within the document.
|
|
1781
1849
|
*/
|
|
1782
1850
|
declare class Comment extends DataNode {
|
|
1783
|
-
|
|
1784
|
-
|
|
1851
|
+
type: ElementType.Comment;
|
|
1852
|
+
get nodeType(): 8;
|
|
1785
1853
|
}
|
|
1786
1854
|
/**
|
|
1787
1855
|
* Processing instructions, including doc types.
|
|
1788
1856
|
*/
|
|
1789
1857
|
declare class ProcessingInstruction extends DataNode {
|
|
1790
|
-
|
|
1791
|
-
|
|
1792
|
-
|
|
1793
|
-
|
|
1794
|
-
|
|
1795
|
-
|
|
1796
|
-
|
|
1797
|
-
|
|
1798
|
-
|
|
1799
|
-
|
|
1858
|
+
type: ElementType.Directive;
|
|
1859
|
+
name: string;
|
|
1860
|
+
constructor(name: string, data: string);
|
|
1861
|
+
get nodeType(): 1;
|
|
1862
|
+
/** If this is a doctype, the document type name (parse5 only). */
|
|
1863
|
+
"x-name"?: string;
|
|
1864
|
+
/** If this is a doctype, the document type public identifier (parse5 only). */
|
|
1865
|
+
"x-publicId"?: string;
|
|
1866
|
+
/** If this is a doctype, the document type system identifier (parse5 only). */
|
|
1867
|
+
"x-systemId"?: string;
|
|
1800
1868
|
}
|
|
1801
1869
|
/**
|
|
1802
|
-
* A
|
|
1870
|
+
* A node that can have children.
|
|
1803
1871
|
*/
|
|
1804
1872
|
declare abstract class NodeWithChildren extends Node {
|
|
1805
|
-
|
|
1806
|
-
|
|
1807
|
-
|
|
1808
|
-
|
|
1809
|
-
|
|
1810
|
-
|
|
1811
|
-
|
|
1812
|
-
|
|
1813
|
-
|
|
1814
|
-
|
|
1815
|
-
|
|
1816
|
-
|
|
1817
|
-
|
|
1818
|
-
|
|
1819
|
-
|
|
1873
|
+
children: ChildNode[];
|
|
1874
|
+
/**
|
|
1875
|
+
* @param children Children of the node. Only certain node types can have children.
|
|
1876
|
+
*/
|
|
1877
|
+
constructor(children: ChildNode[]);
|
|
1878
|
+
/** First child of the node. */
|
|
1879
|
+
get firstChild(): ChildNode | null;
|
|
1880
|
+
/** Last child of the node. */
|
|
1881
|
+
get lastChild(): ChildNode | null;
|
|
1882
|
+
/**
|
|
1883
|
+
* Same as {@link children}.
|
|
1884
|
+
* [DOM spec](https://dom.spec.whatwg.org)-compatible alias.
|
|
1885
|
+
*/
|
|
1886
|
+
get childNodes(): ChildNode[];
|
|
1887
|
+
set childNodes(children: ChildNode[]);
|
|
1820
1888
|
}
|
|
1889
|
+
/**
|
|
1890
|
+
* CDATA nodes.
|
|
1891
|
+
*/
|
|
1821
1892
|
declare class CDATA extends NodeWithChildren {
|
|
1822
|
-
|
|
1823
|
-
|
|
1893
|
+
type: ElementType.CDATA;
|
|
1894
|
+
get nodeType(): 4;
|
|
1824
1895
|
}
|
|
1825
1896
|
/**
|
|
1826
1897
|
* The root node of the document.
|
|
1827
1898
|
*/
|
|
1828
1899
|
declare class Document extends NodeWithChildren {
|
|
1829
|
-
|
|
1830
|
-
|
|
1831
|
-
|
|
1832
|
-
|
|
1900
|
+
type: ElementType.Root;
|
|
1901
|
+
get nodeType(): 9;
|
|
1902
|
+
/** [Document mode](https://dom.spec.whatwg.org/#concept-document-limited-quirks) (parse5 only). */
|
|
1903
|
+
"x-mode"?: "no-quirks" | "quirks" | "limited-quirks";
|
|
1833
1904
|
}
|
|
1834
1905
|
/**
|
|
1835
1906
|
* The description of an individual attribute.
|
|
1836
1907
|
*/
|
|
1837
1908
|
interface Attribute {
|
|
1838
|
-
|
|
1839
|
-
|
|
1840
|
-
|
|
1841
|
-
|
|
1909
|
+
name: string;
|
|
1910
|
+
value: string;
|
|
1911
|
+
namespace?: string;
|
|
1912
|
+
prefix?: string;
|
|
1842
1913
|
}
|
|
1843
1914
|
/**
|
|
1844
1915
|
* An element within the DOM.
|
|
1845
1916
|
*/
|
|
1846
1917
|
declare class Element extends NodeWithChildren {
|
|
1847
|
-
|
|
1848
|
-
|
|
1849
|
-
|
|
1850
|
-
|
|
1851
|
-
|
|
1852
|
-
|
|
1853
|
-
|
|
1854
|
-
|
|
1855
|
-
|
|
1856
|
-
|
|
1857
|
-
|
|
1858
|
-
|
|
1859
|
-
|
|
1860
|
-
|
|
1861
|
-
|
|
1862
|
-
|
|
1863
|
-
|
|
1864
|
-
|
|
1865
|
-
|
|
1866
|
-
|
|
1867
|
-
|
|
1868
|
-
|
|
1869
|
-
|
|
1870
|
-
|
|
1871
|
-
|
|
1872
|
-
|
|
1873
|
-
|
|
1874
|
-
|
|
1875
|
-
|
|
1876
|
-
|
|
1877
|
-
|
|
1878
|
-
|
|
1879
|
-
|
|
1918
|
+
name: string;
|
|
1919
|
+
attribs: {
|
|
1920
|
+
[name: string]: string;
|
|
1921
|
+
};
|
|
1922
|
+
type: ElementType.Tag | ElementType.Script | ElementType.Style;
|
|
1923
|
+
/**
|
|
1924
|
+
* @param name Name of the tag, eg. `div`, `span`.
|
|
1925
|
+
* @param attribs Object mapping attribute names to attribute values.
|
|
1926
|
+
* @param children Children of the node.
|
|
1927
|
+
* @param type Node type used for the new node instance.
|
|
1928
|
+
*/
|
|
1929
|
+
constructor(name: string, attribs: {
|
|
1930
|
+
[name: string]: string;
|
|
1931
|
+
}, children?: ChildNode[], type?: ElementType.Tag | ElementType.Script | ElementType.Style);
|
|
1932
|
+
get nodeType(): 1;
|
|
1933
|
+
/**
|
|
1934
|
+
* `parse5` source code location info, with start & end tags.
|
|
1935
|
+
*
|
|
1936
|
+
* Available if parsing with parse5 and location info is enabled.
|
|
1937
|
+
*/
|
|
1938
|
+
sourceCodeLocation?: TagSourceCodeLocation | null;
|
|
1939
|
+
/**
|
|
1940
|
+
* Same as {@link name}.
|
|
1941
|
+
* [DOM spec](https://dom.spec.whatwg.org)-compatible alias.
|
|
1942
|
+
*/
|
|
1943
|
+
get tagName(): string;
|
|
1944
|
+
set tagName(name: string);
|
|
1945
|
+
get attributes(): Attribute[];
|
|
1946
|
+
/** Element namespace (parse5 only). */
|
|
1947
|
+
namespace?: string;
|
|
1948
|
+
/** Element attribute namespaces (parse5 only). */
|
|
1949
|
+
"x-attribsNamespace"?: Record<string, string>;
|
|
1950
|
+
/** Element attribute namespace-related prefixes (parse5 only). */
|
|
1951
|
+
"x-attribsPrefix"?: Record<string, string>;
|
|
1880
1952
|
}
|
|
1881
|
-
|
|
1953
|
+
//#endregion
|
|
1954
|
+
//#region ../parser/dist/index.d.mts
|
|
1955
|
+
//#region src/allowedTags.d.ts
|
|
1956
|
+
type AllowTag = "a" | "abbr" | "address" | "article" | "aside" | "b" | "bdi" | "bdo" | "blockquote" | "br" | "caption" | "cite" | "code" | "col" | "colgroup" | "dd" | "del" | "div" | "dl" | "dt" | "em" | "fieldset" | "footer" | "h1" | "h2" | "h3" | "h4" | "h5" | "h6" | "header" | "hr" | "i" | "img" | "ins" | "label" | "legend" | "li" | "mark" | "nav" | "ol" | "p" | "pre" | "q" | "rt" | "ruby" | "s" | "section" | "small" | "span" | "strong" | "sub" | "sup" | "table" | "tbody" | "td" | "tfoot" | "th" | "thead" | "tr" | "tt" | "u" | "ul";
|
|
1957
|
+
type DeprecatedTag = "big" | "center" | "font";
|
|
1958
|
+
type ConvertedTag = "html" | "body" | "svg";
|
|
1959
|
+
declare const ALLOWED_TAGS: [tag: AllowTag | DeprecatedTag | ConvertedTag, allowedAttrs?: string[]][]; //#endregion
|
|
1960
|
+
//#region src/parser.d.ts
|
|
1882
1961
|
declare const getHTML: (content: string | AnyNode | AnyNode[]) => string;
|
|
1883
|
-
declare const parseHTML: (content: string) => AnyNode[];
|
|
1884
|
-
|
|
1962
|
+
declare const parseHTML: (content: string) => AnyNode[]; //#endregion
|
|
1963
|
+
//#region src/typings.d.ts
|
|
1885
1964
|
interface ElementNode {
|
|
1886
|
-
|
|
1887
|
-
|
|
1888
|
-
|
|
1889
|
-
|
|
1965
|
+
type: "node";
|
|
1966
|
+
name: string;
|
|
1967
|
+
attrs?: Record<string, string>;
|
|
1968
|
+
children?: RichTextNode[];
|
|
1890
1969
|
}
|
|
1891
1970
|
interface TextNode {
|
|
1892
|
-
|
|
1893
|
-
|
|
1971
|
+
type: "text";
|
|
1972
|
+
text: string;
|
|
1894
1973
|
}
|
|
1895
|
-
type RichTextNode = ElementNode | TextNode;
|
|
1896
|
-
|
|
1974
|
+
type RichTextNode = ElementNode | TextNode; //#endregion
|
|
1975
|
+
//#region src/options.d.ts
|
|
1897
1976
|
type NodeHandler = (node: ElementNode) => ElementNode | null | Promise<ElementNode | null>;
|
|
1898
1977
|
interface ParserOptions {
|
|
1899
|
-
|
|
1900
|
-
|
|
1901
|
-
|
|
1902
|
-
|
|
1903
|
-
|
|
1904
|
-
|
|
1905
|
-
|
|
1906
|
-
|
|
1907
|
-
|
|
1908
|
-
|
|
1909
|
-
}
|
|
1910
|
-
|
|
1911
|
-
declare const getRichTextNodes: (content: string | AnyNode[], {
|
|
1912
|
-
|
|
1913
|
-
|
|
1914
|
-
|
|
1915
|
-
|
|
1916
|
-
|
|
1917
|
-
|
|
1918
|
-
|
|
1919
|
-
|
|
1978
|
+
/**
|
|
1979
|
+
* 是否附加标签名到 class
|
|
1980
|
+
*
|
|
1981
|
+
* @default true
|
|
1982
|
+
*/
|
|
1983
|
+
appendClass?: boolean;
|
|
1984
|
+
/**
|
|
1985
|
+
* 处理 Tag
|
|
1986
|
+
*/
|
|
1987
|
+
transform?: Partial<Record<AllowTag, NodeHandler>>;
|
|
1988
|
+
} //#endregion
|
|
1989
|
+
//#region src/richText.d.ts
|
|
1990
|
+
declare const getRichTextNodes: (content: string | AnyNode[], {
|
|
1991
|
+
appendClass,
|
|
1992
|
+
transform
|
|
1993
|
+
}?: ParserOptions) => Promise<RichTextNode[]>; //#endregion
|
|
1994
|
+
//#region src/svg.d.ts
|
|
1995
|
+
/**
|
|
1996
|
+
* SVG 转换
|
|
1997
|
+
*
|
|
1998
|
+
* @param content - SVG content to convert
|
|
1999
|
+
* @returns Data URI string
|
|
2000
|
+
*/
|
|
2001
|
+
declare const convertSVGToDataURI: (content: string) => string; //#endregion
|
|
2002
|
+
//#region src/text.d.ts
|
|
2003
|
+
declare const getText: (content: string | AnyNode[]) => string; //#endregion
|
|
2004
|
+
//#endregion
|
|
2005
|
+
export { $App, $Component, $Config, $Page, ALLOWED_TAGS, AllowTag, AppConfigCommonOptions, AppConfigOptions, AppConstructor, AppInstance, AppOptions, ComponentConstructor, ComponentInstance, ComponentLifetimes, ComponentOptions, Config, ConvertedTag, Cookie, CookieMap, CookieOptions, CookieStore, CookieStoreType, CookieType, DeprecatedTag, ElementNode, Emitter, EmitterInstance, Env, EventHandlerList, EventHandlerMap, EventType, ExtendedAppMethods, ExtendedComponentMethods, ExtendedComponentProperty, ExtendedPageLifeCycles, ExtendedPageMethods, ExtendedPageProperties, ExtendsAppOptions, Handler, Headers, HeadersInit, InferFromType, InferPropType, InferPropTypes, MpError, MpErrorOptions, PageConstructor, PageInstance, PageOptions, PageQuery, PageState, PropItem, PropOption, PropType, Props, PropsOptions, Queue, RefMap, RequestBody, RequestFactory, RequestInitOptions, RequestOptions, RequestResponse, RequestType, RichTextNode, RouteCustomConfig, RoutePathConfig, SetCookieOptions, StorageData, Task, TextNode, TrivialComponentInstance, TrivialComponentOptions, TrivialPageInstance, TrivialPageOptions, URLSearchParams, UpdateInfo, UrlInfo, WildCardEventHandlerList, WildcardHandler, addContact, appState, check, checkAsync, compareVersion, confirm, convertSVGToDataURI, createRequest, decode as decodeBase64, dirname, download, userEmitter as emitter, encode as encodeBase64, env, exists, funcQueue, get, getAsync, getConfig, getCookieScopeDomain, getCurrentPage, getCurrentRoute, getDomain, getHTML, getRef, getRichTextNodes, getText, getUrlInfo, getWindowInfo, go, handleProperties, isDir, isFile, isFunction, lock, logger_d_exports as logger, ls, mkdir, normalizeDomain, once, openDocument, parseCookieHeader, parseHTML, parseUrl, put, query_d_exports as query, reLaunch, readFile, readJSON, redirect, remove, removeAsync, removeRef, reportNetworkStatus, request, requestCookieStore, retry, rm, saveDocument, saveFile, saveOnlineFile, savePhoto, set, setAsync, setRef, showModal, showToast, storage, switchTab, take, type, unzip, updateApp, wrapFunction, writeClipboard, writeFile, writeJSON };
|
|
2006
|
+
//# sourceMappingURL=index.d.ts.map
|