@mptool/all 0.12.0 → 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 CHANGED
@@ -1,12 +1,14 @@
1
- declare const writeClipboard: (data?: string) => Promise<void>;
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 path 下载路径
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 confirmFunc 确定回调函数
48
- * @param cancelFunc 取消回调函数
52
+ * @param confirmAction 确定回调函数
53
+ * @param cancelAction 取消回调函数
54
+ * @param warning 额外警告信息
49
55
  */
50
- declare const confirm: (text: string, warning: string | undefined, confirmAction: () => Promise<void> | void, cancelAction?: () => void | Promise<void>) => void;
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
- force: boolean;
78
- /** 是否进行强制初始化 */
79
- reset: boolean;
82
+ /** 是否进行强制更新 */
83
+ force: boolean;
84
+ /** 是否进行强制初始化 */
85
+ reset: boolean;
80
86
  }
81
87
  /**
82
88
  * 检查小程序更新
83
89
  *
84
90
  * 如果检测到小程序更新,获取升级状态 (新版本号,是否立即更新、是否重置小程序) 并做相应处理
85
91
  *
86
- * @param globalData 小程序的全局数据
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
- all: EventHandlerMap<Events>;
106
- on<Key extends keyof Events>(type: Key, handler: Handler<Events[Key]>): void;
107
- on(type: "*", handler: WildcardHandler<Events>): void;
108
- off<Key extends keyof Events>(type: Key, handler?: Handler<Events[Key]>): void;
109
- off(type: "*", handler: WildcardHandler<Events>): void;
110
- emit<Key extends keyof Events>(type: Key, event: Events[Key]): void;
111
- emit<Key extends keyof Events>(type: undefined extends Events[Key] ? Key : never): void;
112
- emitAsync<Key extends keyof Events>(type: Key, event: Events[Key]): Promise<void>;
113
- emitAsync<Key extends keyof Events>(type: undefined extends Events[Key] ? Key : never): Promise<void>;
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
- * @name emitter
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 function Emitter<Events>(all?: EventHandlerMap<Events>): EmitterInstance<Events>;
121
-
122
- interface MpErrorOptions$1 {
123
- code?: number;
124
- message?: string;
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$1 extends Error {
127
- code: number | null;
128
- constructor({ code, message }: MpErrorOptions$1);
129
- toString(): string;
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
- declare const logger_debug: typeof debug;
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 [splitter='&'] 分隔符
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 [splitter='&] 分隔符
176
- * @param [unencoded=false] 是否已经解码
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<T>(original: ((this: T, ...args: any[]) => void) | undefined, pre: (this: T, ...args: any[]) => void): (this: T, ...args: any[]) => void;
231
- declare function wrapFunction<T>(original: ((this: T, ...args: any[]) => Promise<void>) | undefined, pre: (this: T, ...args: any[]) => void): (this: T, ...args: any[]) => Promise<void>;
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: <T, A extends unknown[], R>(fn: (this: T, release: () => void, ...args: A) => R, ctx?: T) => ((this: T, ...args: A) => R | undefined);
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: <T, A extends unknown[], R>(func: (...args: A) => R, ctx?: T) => ((this: T, ...args: A) => R | undefined);
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
- func: (this: This, next: () => void, ...args: ArgType) => void;
281
- /** 函数的运行上下文 */
282
- ctx: This;
283
- /** 函数的参数 */
284
- args: ArgType;
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
- capacity: number;
292
- constructor(
293
- /** 允许同时并行的任务数 */
294
- capacity?: number);
295
- /** 回调队列 */
296
- funcQueue: Task[];
297
- /** 正在运行的数量 */
298
- running: number;
299
- /** 执行下一个函数 */
300
- next(): void;
301
- /**
302
- * 添加函数
303
- * @param func 函数
304
- * @param ctx 函数运行上下文
305
- * @param args 函数参数
306
- */
307
- add<A extends any[], T>(func: (next: () => void, ...args: A) => void, ctx?: T, ...args: A): void;
308
- /** 清除队列,不再执行尚未执行的函数 */
309
- clear(): void;
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: <A extends unknown[], T = unknown>(fn: (next: () => void, ...args: A) => void, capacity?: number) => ((this: T, ...args: A) => void);
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
- type?: PropType<Type> | null;
330
- /**
331
- * 是否必填
332
- *
333
- * @description 仅用作类型推导,无检查
334
- */
335
- required?: boolean;
336
- /** 属性初始值 */
337
- default?: Default | null | undefined | object;
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
- new (): TypeConstructor;
341
- (): Type;
342
- readonly prototype: TypeConstructor;
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 V>] ? unknown extends V ? any : V : Type;
347
- type RequiredKeys<T> = {
348
- [K in keyof T]: T[K] extends {
349
- required: true;
350
- } | {
351
- default: any;
352
- } ? T[K] extends {
353
- default: undefined | (() => undefined);
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
- type: null;
346
+ type: null;
359
347
  }] ? any : [Type] extends [ArrayConstructor | {
360
- type: ArrayConstructor;
348
+ type: ArrayConstructor;
361
349
  }] ? any[] : [Type] extends [ObjectConstructor | {
362
- type: ObjectConstructor;
350
+ type: ObjectConstructor;
363
351
  }] ? WechatMiniprogram.IAnyObject : [Type] extends [BooleanConstructor | {
364
- type: BooleanConstructor;
352
+ type: BooleanConstructor;
365
353
  }] ? boolean : [Type] extends [PropItem<infer Value, infer Default>] ? unknown extends Value ? Default : Value : Type;
366
- type InferPropTypes<O> = O extends object ? {
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
- lifetimes: Partial<{
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
- $id: number;
363
+ created(): void;
419
364
  /**
420
- * 当前组件上用于索引的 ref ID 值
365
+ * 在组件实例进入页面节点树时执行
366
+ *
367
+ * 最低基础库版本:[`1.6.3`](https://developers.weixin.qq.com/miniprogram/dev/framework/compatibility.html)
421
368
  */
422
- $refID: string;
369
+ attached(): void;
423
370
  /**
424
- * 当前组件所属的页面组件实例
371
+ * 在组件在视图层布局完成后执行
425
372
  *
426
- * @description 只在 `attached`, `ready` 生命周期后生效
373
+ * 最低基础库版本:[`1.6.3`](https://developers.weixin.qq.com/miniprogram/dev/framework/compatibility.html)
427
374
  */
428
- $root: TrivialPageInstance;
375
+ ready(): void;
429
376
  /**
430
- * 当前组件所属的父组件实例引用
377
+ * 在组件实例被移动到节点树另一个位置时执行
431
378
  *
432
- * @description 只在 `attached`, `ready` 生命周期后生效
379
+ * 最低基础库版本:[`1.6.3`](https://developers.weixin.qq.com/miniprogram/dev/framework/compatibility.html)
433
380
  */
434
- $parent: TrivialPageInstance | TrivialComponentInstance;
381
+ moved(): void;
435
382
  /**
436
- * 指定了 `ref` 的子组件实例映射
383
+ * 在组件实例被从页面节点树移除时执行
437
384
  *
438
- * 示例:
439
- *
440
- * ```html
441
- * <custom-component binding="$" ref="customComp"/>
442
- * ```
385
+ * 最低基础库版本:[`1.6.3`](https://developers.weixin.qq.com/miniprogram/dev/framework/compatibility.html)
386
+ */
387
+ detached(): void;
388
+ /**
389
+ * 每当组件方法抛出错误时执行
443
390
  *
444
- * ```js
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
- $refs: RefMap;
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
- * @param method 方法名称
462
- * @param args 传递的参数
463
- */
464
- $call(method: string, ...args: unknown[]): void;
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, Props 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<Props>, InstanceProps & Method & WechatMiniprogram.Component.MixinMethods<Behavior> & (IsPage extends true ? WechatMiniprogram.Page.ILifetime : Record<never, never>)> & {
471
- /** 组件数据,**包括内部数据和属性值** */
472
- data: Data & InferPropTypes<Props>;
473
- /**
474
- * @deprecated 优先使用 `data`
475
- *
476
- * 组件数据,**包括内部数据和属性值**(与 `data` 一致)
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, Props 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<{
481
- /** 组件属性 */
482
- props: Props;
483
- }> & Partial<WechatMiniprogram.Component.Behavior<Behavior>> & Partial<WechatMiniprogram.Component.Method<Method, IsPage>> & Partial<WechatMiniprogram.Component.OtherOption> & Partial<ComponentLifetimes> & ThisType<ComponentInstance<Data, Props, Method, Behavior, InstanceProps, IsPage>>;
484
- type ComponentConstructor = <Data extends WechatMiniprogram.Component.DataOption, Props 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, Props, Method, Behavior, InstanceProps, IsPage>) => string;
485
- type TrivialComponentInstance = ComponentInstance<WechatMiniprogram.IAnyObject, Record<string, null>, Record<string, (...args: unknown[]) => any>, [
486
- ]>;
487
- type TrivialComponentOptions = ComponentOptions<WechatMiniprogram.IAnyObject, Record<string, null>, Record<string, (...args: any[]) => any>, [
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 function bind(this: TrivialComponentInstance, touchEvent: WechatMiniprogram.Touch<{
508
- id: number;
509
- event: string;
510
- args: unknown[];
511
- }>): void;
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
- * 本函数是 `wx.navigateTo` 的封装,`pageName` 可以带上 `queryString`
519
- *
520
- * @param pageName 页面名称或页面的路径
521
- *
522
- * 示例:
523
- *
524
- * ```js
525
- * this.$go('play?vid=xxx&cid=xxx');
526
- * ```
527
- */
528
- $go(pageName: string): Promise<WechatMiniprogram.NavigateToSuccessCallbackResult>;
529
- /**
530
- * 跳转到指定页面, **替换页面,不产生历史**
531
- *
532
- * 本函数是 `wx.redirectTo` 的封装,`pageName` 可以带上 `queryString`
533
- *
534
- * @param pageName 页面名称或页面的路径
535
- *
536
- * 示例:
537
- *
538
- * ```js
539
- * this.$redirect('about');
540
- * ```
541
- */
542
- $redirect(pageName: string): Promise<WechatMiniprogram.GeneralCallbackResult>;
543
- /**
544
- * 跳转到指定 tabBar 页面,并关闭其他所有非 tabBar 页面
545
- *
546
- * 本函数是 `wx.switchTab` 的封装,路径参数只用于触发 `onNavigate`
547
- *
548
- * @param pageName 页面名称或页面的路径
549
- *
550
- * 示例:
551
- *
552
- * ```js
553
- * this.$switch('main?user=mrhope');
554
- * ```
555
- */
556
- $switch(pageName: string): Promise<WechatMiniprogram.GeneralCallbackResult>;
557
- /**
558
- * 关闭所有页面,之后打开到应用内的某个页面
559
- *
560
- * 本函数是 `wx.reLaunch` 的封装,`pageName` 可以带上 `queryString`
561
- *
562
- * @param pageName 页面名称或页面的路径
563
- *
564
- * 示例:
565
- *
566
- * ```js
567
- * this.$launch('main');
568
- * ```
569
- */
570
- $reLaunch(pageName: string): Promise<WechatMiniprogram.GeneralCallbackResult>;
571
- /**
572
- * 返回上一页,`wx.navigateBack` 的封装
573
- *
574
- * @param delta 返回的层数,默认为 `1`
575
- *
576
- * 示例:
577
- *
578
- * ```js
579
- * this.$back();
580
- * this.$back(2);
581
- * ```
582
- */
583
- $back(delta?: number): Promise<WechatMiniprogram.GeneralCallbackResult>;
584
- /**
585
- * 提前预加载指定页面 (会触发对应页面的 `onPreload` 生命周期)
586
- *
587
- * @param pageName 页面名称或页面的路径,可以带上 `queryString`
588
- *
589
- * 示例:
590
- *
591
- * ```js
592
- * this.$preload('main?id=xxx&target=xxx');
593
- * this.$preload('/page/main?userName=xxx&action=xxx');
594
- * ```
595
- */
596
- $preload(pageName: string): void | Promise<void>;
597
- /**
598
- * 点击代理方法,绑定 `$go` 逻辑
599
- *
600
- * 在元素上声明 `data-url` 作为跳转地址,支持切面方法:
601
- *
602
- * - `data-before` 跳转前执行
603
- * - `data-after` 跳转后执行
604
- *
605
- * 示例:
606
- *
607
- * ```html
608
- * <button
609
- * catch:tap="$bindGo"
610
- * data-url="/pages/play"
611
- * data-before="onClickBefore"
612
- * >click go</button>
613
- * ```
614
- */
615
- $bindGo(event: WechatMiniprogram.Touch): void | Promise<void>;
616
- /**
617
- * 点击代理方法,绑定 `$redirect` 逻辑
618
- *
619
- * 你需要在元素上声明 `data-url` 作为跳转地址,同时支持切面方法:
620
- *
621
- * - `data-before` 跳转前执行
622
- * - `data-after` 跳转后执行
623
- *
624
- * 示例:
625
- *
626
- * ```html
627
- * <button
628
- * catch:tap="$bindRedirect"
629
- * data-url="/pages/play"
630
- * data-before="onClickBefore"
631
- * >click redirect</button>
632
- * ```
633
- */
634
- $bindRedirect(event: WechatMiniprogram.Touch): void | Promise<void>;
635
- /**
636
- * 点击代理方法,绑定 `$switch` 逻辑
637
- *
638
- * 你需要在元素上声明 `data-url` 作为跳转地址,同时支持切面方法:
639
- *
640
- * - `data-before` 跳转前执行
641
- * - `data-after` 跳转后执行
642
- *
643
- * 示例:
644
- *
645
- * ```html
646
- * <button
647
- * catch:tap="$bindSwitch"
648
- * data-url="/pages/play"
649
- * data-before="onClickBefore"
650
- * >click switch</button>
651
- * ```
652
- */
653
- $bindSwitch(event: WechatMiniprogram.Touch): void | Promise<void>;
654
- /**
655
- * 点击代理方法,绑定 `$reLaunch` 逻辑。
656
- *
657
- * 你需要在元素上声明 `data-url` 作为跳转地址,同时支持切面方法:
658
- *
659
- * - `data-before` 跳转前执行
660
- * - `data-after` 跳转后执行
661
- *
662
- * 示例:
663
- *
664
- * ```html
665
- * <button
666
- * catch:tap="$bindReLaunch"
667
- * data-url="/pages/play"
668
- * data-before="onClickBefore"
669
- * >click relaunch</button>
670
- * ```
671
- */
672
- $bindRelaunch(event: WechatMiniprogram.Touch): void | Promise<void>;
673
- /**
674
- * 点击代理方法,绑定 `$back` 逻辑
675
- * 你可以在元素上声明 `data-delta` 作为回退层数
676
- *
677
- * - `data-before` 跳转前执行
678
- * - `data-after` 跳转后执行
679
- *
680
- * 示例:
681
- *
682
- * ```html
683
- * <button
684
- * catch:tap="$bindBack"
685
- * data-delta="1"
686
- * data-before="onClickBefore"
687
- * >click relaunch</button>
688
- * ```
689
- */
690
- $bindBack(): Promise<void> | void;
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
- firstOpen: boolean;
671
+ /** 是否是打开的第一个页面 */
672
+ firstOpen: boolean;
697
673
  }
698
674
  interface ExtendedPageLifeCycles {
699
- /**
700
- * 在页面注册时调用
701
- *
702
- * 此时页面的 this 还不可用
703
- */
704
- onRegister(): void;
705
- /**
706
- * 在 `App.onLaunch` 触发时调用
707
- *
708
- * @param App.onLaunch 参数
709
- */
710
- onAppLaunch(options: WechatMiniprogram.App.LaunchShowOption): void | Promise<void>;
711
- /**
712
- * 小程序在切入后台后被唤醒
713
- *
714
- * @param time 休眠时间 (单位 ms)
715
- */
716
- onAwake(time: number): void | Promise<void>;
717
- /**
718
- * 页面预加载时触发
719
- *
720
- * 可在其他页面中使用 `this.$preload(pageNameWithArgs|pageUrl)` 触发特定页面的预加载周期
721
- *
722
- * @param options url 参数对象
723
- */
724
- onPreload(options: PageQuery): void | Promise<void>;
725
- /**
726
- * 页面即将被导航时触发
727
- *
728
- * 需要在调用页面中使用框架提供的跳转方式 `this.$go(pageNameWithArgs|pageUrl)`
729
- * 才能正确触发 `onNavigate`
730
- *
731
- * 另外需要特别注意第一次进入一个分包界面
732
- * 或者是通过微信小程序二维码或微信内分享直接跳转到小程序子页面时同样不会触发
733
- */
734
- onNavigate(options: PageQuery): void | Promise<void>;
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
- $name: string;
739
- /** 一些由框架生成的页面状态 */
740
- $state: PageState;
741
- /**
742
- * 指定了 `ref` 的子组件实例映射
743
- *
744
- * 示例:
745
- *
746
- * ```html
747
- * <custom-component binding="$" ref="customComp"/>
748
- * ```
749
- *
750
- * ```js
751
- * $Page({
752
- * onLoad() {
753
- * this.$refs.customComp // 根据ref属性获取子组件的实例引用
754
- * }
755
- * });
756
- * ```
757
- */
758
- $refs: RefMap;
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
- $: typeof bind;
765
- /**
766
- * 获取当前页面实例。
767
- */
768
- $currentPage(): PageInstance<Data, Custom>;
769
- /**
770
- * 获得页面路径
771
- *
772
- * @param name 页面简称
773
- */
774
- $getPath(name: string): string;
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
- options?: WechatMiniprogram.Component.ComponentOptions;
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
- * @memberOf [Emitter](https://miniapp-tool.github.io/api/enhance/emitter.html) 实例
793
- */
794
- $all: UserEmitter["all"];
795
- /**
796
- * 为特定事件类型注册处理函数
797
- *
798
- * @param type 监听的事件类型,使用 `'*'` 监听所有事件
799
- * @param handler 待添加的响应函数
800
- * @memberOf [Emitter](https://miniapp-tool.github.io/api/enhance/emitter.html) 实例
801
- */
802
- $on: UserEmitter["on"];
803
- /**
804
- * 从特定事件类型移除指定监听器
805
- *
806
- * 如果省略 `handler`,给定类型的所有事件均被忽略
807
- *
808
- * @param {string|symbol} type 取消监听的事件类型,使用 `'*'` 取消监听所有事件
809
- * @param {Function} [handler] 待移除的响应函数
810
- * @memberOf [Emitter](https://miniapp-tool.github.io/api/enhance/emitter.html) 实例
811
- */
812
- $off: UserEmitter["off"];
813
- /**
814
- * 调用所有给定事件类型的响应函数
815
- *
816
- * 如果存在,`'*'` 响应函数会在符合事件类型的响应函数之后调用
817
- *
818
- * 注意,手动调用 `'*'` 事件不被支持
819
- *
820
- * @param type 待触发的事件类型
821
- * @param event 传递给所有响应函数的事件
822
- * @memberOf [Emitter](https://miniapp-tool.github.io/api/enhance/emitter.html) 实例
823
- */
824
- $emit: UserEmitter["emit"];
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
- * @param time 休眠时间 (单位ms)
846
- */
847
- onAwake?(time: number): void;
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
- launch: boolean;
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
- home?: string;
874
- /**
875
- * 跳转延迟执行的最长时间,单位 ms
876
- *
877
- * @description 异步 onNavigate 方法用时过久会直接调转
878
- *
879
- * @default 200
880
- */
881
- maxDelay?: number;
882
- /**
883
- * 允许进行跳转据页面首屏渲染后的最小间隔时间,单位 ms
884
- *
885
- * @default 100
886
- */
887
- minInterval?: number;
888
- /**
889
- * 自定义扩展组件
890
- *
891
- * 时机在框架执行扩展之前,可为每个组件挂载实例方法
892
- *
893
- * @param options 组件选项
894
- */
895
- extendComponent?(options: TrivialComponentOptions): void;
896
- /**
897
- * 自定义注入组件
898
- *
899
- * 时机在框架执行扩展之后,这意味着你可以覆盖框架的方法
900
- *
901
- * @param options 组件选项
902
- */
903
- injectComponent?(options: TrivialComponentOptions): void;
904
- /**
905
- * 自定义扩展页面,在框架执行扩展之前
906
- *
907
- * @param name 页面名称
908
- * @param options 页面选项
909
- */
910
- extendPage?(name: string, options: TrivialPageOptions): void;
911
- /**
912
- * 自定义注入页面
913
- *
914
- * 在框架执行扩展之后,这意味着你可以覆盖框架的方法
915
- *
916
- * @param name 页面名称
917
- * @param options 页面选项
918
- */
919
- injectPage?(name: string, options: TrivialPageOptions): void;
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
- * 当你给出的页面路径或简称无法通过 routeMap 解析时,会回退到此路径
924
- *
925
- * 填入小程序路径模式,小程序路径模式是一个路径字符串,用 `$name` 表示小程序简称的位置
926
- *
927
- * 例子: 你可以填入 `/pages/$name/$name` 来表达:
928
- *
929
- * - `main': '/pages/main/main`
930
- * - `user': '/pages/user/user`
931
- */
932
- defaultPage: string;
933
- /**
934
- * 你可以直接以对象形式表示简称到路径的映射。如:
935
- *
936
- * ```js
937
- * {
938
- * main: '/pages/main/main',
939
- * cart: '/pages/cart/cart',
940
- * user: '/pages/user/user',
941
- * }
942
- * ```
943
- *
944
- * 也支持以在页面复杂的情况下数组格式表示小程序路径映射,数组的元素有两种填写方式:
945
- *
946
- * - `[页面简称, 小程序路经]`
947
- *
948
- * - `[页面简称数组, 小程序路经模式]`
949
- *
950
- * 小程序路径模式是一个路径字符串,用 `$name` 表示小程序简称的位置
951
- *
952
- * 如:
953
- *
954
- * ```js
955
- * [
956
- * [['main', 'cart', 'user'], '/pages/$name/$name'],
957
- * [['search', 'details', 'order'], '/shop/$name/$name'],
958
- * ['about', '/others/about/about'],
959
- * ]
960
- * ```
961
- *
962
- * 等效于:
963
- *
964
- * ```js
965
- * {
966
- * 'main': '/pages/main/main',
967
- * 'cart': '/pages/cart/cart',
968
- * 'user': '/pages/user/user',
969
- * 'search': '/shop/search/search',
970
- * 'details': '/shop/details/details',
971
- * 'order': '/shop/order/order',
972
- * 'about': '/others/about/about',
973
- * }
974
- * ```
975
- *
976
- * @description 无法解析的路径会回退到 `defaultPage`
977
- */
978
- pages?: Record<string, string> | [string | string[], string][];
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
- * @param pageName 页面简称
985
- * @returns 页面路径
986
- */
987
- getPath: (pageName: string) => string;
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
- * @param pageName 页面简称
996
- * @returns 页面路径
997
- */
998
- getPath: (pageName: string) => string;
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
- (path: string): string | undefined;
1025
- <T extends FileEncoding>(path: string, encoding: T): (T extends "binary" ? ArrayBuffer : string) | undefined;
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
- data: T;
1091
- expired: number;
1079
+ data: T;
1080
+ expired: number;
1092
1081
  }
1093
1082
  /** 存储 */
1094
- declare const storage: Record<string, unknown>;
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 [expire='once'] 过期时间
1104
+ * @param expire 过期时间
1116
1105
  * - 0: 永久有效
1117
1106
  * - 数字:过期时间,毫秒
1118
1107
  * - `'keep'`: 表示保持上一次缓存时间
1119
1108
  * - `'once'`: 仅本次启动有效
1120
1109
  */
1121
- declare const set: <T = unknown>(key: string, value: T, expire?: number | "keep" | "once") => void;
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 [expire='once'] 过期时间
1116
+ * @param expire 过期时间
1128
1117
  * - 0: 永久有效
1129
1118
  * - 数字:过期时间,毫秒
1130
1119
  * - `'keep'`: 表示保持上一次缓存时间
1131
1120
  * - `'once'`: 仅本次启动有效
1132
1121
  * @param [asyncCB] 异步回调方法,不填为同步
1122
+ * @returns 异步回调结果
1133
1123
  */
1134
- declare const setAsync: <T = unknown>(key: string, value: T, expire?: number | "keep" | "once") => Promise<WechatMiniprogram.GeneralCallbackResult | void>;
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
- * cookie name
1180
- */
1181
- name: string;
1182
- /**
1183
- * cookie value
1184
- */
1185
- value: string;
1186
- /**
1187
- * cookie path
1188
- */
1189
- path?: string | undefined;
1190
- /**
1191
- * absolute expiration date for the cookie
1192
- */
1193
- expires?: Date | undefined;
1194
- /**
1195
- * relative max age of the cookie in seconds from when the client receives it (integer or undefined)
1196
- * Note: when using with express's res.cookie() method, multiply maxAge by 1000 to convert to milliseconds
1197
- */
1198
- maxAge?: number | undefined;
1199
- /**
1200
- * domain for the cookie,
1201
- * may begin with "." to indicate the named domain or any subdomain of it
1202
- */
1203
- domain?: string | undefined;
1204
- /**
1205
- * indicates that this cookie should only be sent over HTTPs
1206
- */
1207
- secure?: boolean | undefined;
1208
- /**
1209
- * indicates that this cookie should not be accessible to client-side JavaScript
1210
- */
1211
- httpOnly?: boolean | undefined;
1212
- /**
1213
- * indicates a cookie ought not to be sent along with cross-site requests
1214
- */
1215
- sameSite?: boolean | "lax" | "strict" | "none" | undefined;
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
- name: string;
1223
- value: string;
1224
- domain: string;
1225
- path: string;
1226
- expires: Date | "session" | "outdate";
1227
- httpOnly: boolean;
1228
- constructor(cookie: CookieType);
1229
- /**
1230
- * @returns 是否已过期
1231
- */
1232
- isExpired(): boolean;
1233
- /**
1234
- * @returns 是否可持久化
1235
- */
1236
- isPersistence(): boolean;
1237
- /**
1238
- * @param domain 域名
1239
- * @returns 是否匹配
1240
- */
1241
- isDomainMatched(domain: string): boolean;
1242
- /**
1243
- * @param path 路径
1244
- * @returns 是否匹配
1245
- */
1246
- isPathMatched(path: string): boolean;
1247
- toString(): string;
1248
- toJSON(): CookieType;
1249
- }
1250
-
1251
- interface MpErrorOptions {
1252
- code?: number;
1253
- message?: string;
1254
- }
1255
- declare class MpError extends Error {
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
- domain: string;
1269
- path: string;
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
- domain?: string;
1275
- path?: string;
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
- name: string;
1283
- value: string;
1284
- domain: string;
1285
- path?: string;
1286
- expires?: Date;
1287
- maxAge?: number;
1288
- httpOnly?: boolean;
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
- #private;
1295
- /** 存储键值 */
1296
- private key;
1297
- private store;
1298
- constructor(
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
- private headers;
1398
- private headerNames;
1399
- constructor(init?: HeadersInit);
1400
- /**
1401
- * Appends a new value onto an existing header inside a `Headers` object, or adds the header if it does not already exist.
1402
- */
1403
- append(name: string, value: string): void;
1404
- /**
1405
- * Deletes a header from the `Headers` object.
1406
- */
1407
- delete(name: string): void;
1408
- /**
1409
- * Returns a `ByteString` sequence of all the values of a header with a given name.
1410
- */
1411
- get(name: string): string | null;
1412
- /**
1413
- * Returns an array containing the values
1414
- * of all Set-Cookie headers associated
1415
- * with a response
1416
- */
1417
- getSetCookie(): string[];
1418
- /**
1419
- * Returns a boolean stating whether a `Headers` object contains a certain header.
1420
- */
1421
- has(name: string): boolean;
1422
- /**
1423
- * Sets a new value for an existing header inside a `Headers` object, or adds the header if it does not already exist.
1424
- */
1425
- set(name: string, value: string): void;
1426
- /**
1427
- * Traverses the `Headers` object,
1428
- * calling the given callback for each header.
1429
- */
1430
- forEach<ThisArg = this>(callback: (this: ThisArg, value: string, name: string, parent: this) => void, thisArg?: ThisArg): void;
1431
- keys(): IterableIterator<string>;
1432
- values(): IterableIterator<string>;
1433
- entries(): IterableIterator<[string, string]>;
1434
- toObject(): Record<string, string>;
1435
- [Symbol.iterator](): IterableIterator<[string, string]>;
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
- private params;
1440
- constructor(init?: URLSearchParams | string | Record<string, string | string[]> | Iterable<[string, string]>);
1441
- get size(): number;
1442
- /**
1443
- * Append a new name-value pair to the query string.
1444
- */
1445
- append(name: string, value: string): void;
1446
- /**
1447
- * If `value` is provided, removes all name-value pairs
1448
- * where name is `name` and value is `value`..
1449
- *
1450
- * If `value` is not provided, removes all name-value pairs whose name is `name`.
1451
- */
1452
- delete(name: string): void;
1453
- /**
1454
- * Returns an ES6 `Iterator` over each of the name-value pairs in the query.
1455
- * 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`.
1456
- *
1457
- * Alias for `urlSearchParams[@@iterator]()`.
1458
- */
1459
- entries(): IterableIterator<[string, string]>;
1460
- /**
1461
- * Iterates over each name-value pair in the query and invokes the given function.
1462
- *
1463
- * ```js
1464
- * const myURL = new URL('https://example.org/?a=b&#x26;c=d');
1465
- * myURL.searchParams.forEach((value, name, searchParams) => {
1466
- * console.log(name, value, myURL.searchParams === searchParams);
1467
- * });
1468
- * // Prints:
1469
- * // a b true
1470
- * // c d true
1471
- * ```
1472
- * @param fn Invoked for each name-value pair in the query
1473
- * @param thisArg To be used as `this` value for when `fn` is called
1474
- */
1475
- forEach(callbackfn: (value: string, key: string, iterable: URLSearchParams) => void, thisArg?: unknown): void;
1476
- /**
1477
- * Returns the value of the first name-value pair whose name is `name`. If there
1478
- * are no such pairs, `null` is returned.
1479
- * @return or `null` if there is no name-value pair with the given `name`.
1480
- */
1481
- get(name: string): string | null;
1482
- /**
1483
- * Returns the values of all name-value pairs whose name is `name`. If there are
1484
- * no such pairs, an empty array is returned.
1485
- */
1486
- getAll(name: string): string[];
1487
- /**
1488
- * Checks if the `URLSearchParams` object contains key-value pair(s) based on`name` and an optional `value` argument.
1489
- *
1490
- * If `value` is provided, returns `true` when name-value pair with
1491
- * same `name` and `value` exists.
1492
- *
1493
- * If `value` is not provided, returns `true` if there is at least one name-value
1494
- * pair whose name is `name`.
1495
- */
1496
- has(name: string): boolean;
1497
- /**
1498
- * Returns an ES6 `Iterator` over the names of each name-value pair.
1499
- *
1500
- * ```js
1501
- * const params = new URLSearchParams('foo=bar&#x26;foo=baz');
1502
- * for (const name of params.keys()) {
1503
- * console.log(name);
1504
- * }
1505
- * // Prints:
1506
- * // foo
1507
- * // foo
1508
- * ```
1509
- */
1510
- keys(): IterableIterator<string>;
1511
- /**
1512
- * 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`,
1513
- * set the first such pair's value to `value` and remove all others. If not,
1514
- * append the name-value pair to the query string.
1515
- *
1516
- * ```js
1517
- * const params = new URLSearchParams();
1518
- * params.append('foo', 'bar');
1519
- * params.append('foo', 'baz');
1520
- * params.append('abc', 'def');
1521
- * console.log(params.toString());
1522
- * // Prints foo=bar&#x26;foo=baz&#x26;abc=def
1523
- *
1524
- * params.set('foo', 'def');
1525
- * params.set('xyz', 'opq');
1526
- * console.log(params.toString());
1527
- * // Prints foo=def&#x26;abc=def&#x26;xyz=opq
1528
- * ```
1529
- */
1530
- set(name: string, value: string): void;
1531
- /**
1532
- * Sort all existing name-value pairs in-place by their names. Sorting is done
1533
- * with a [stable sorting algorithm](https://en.wikipedia.org/wiki/Sorting_algorithm#Stability), so relative order between name-value pairs
1534
- * with the same name is preserved.
1535
- *
1536
- * This method can be used, in particular, to increase cache hits.
1537
- *
1538
- * ```js
1539
- * const params = new URLSearchParams('query[]=abc&#x26;type=search&#x26;query[]=123');
1540
- * params.sort();
1541
- * console.log(params.toString());
1542
- * // Prints query%5B%5D=abc&#x26;query%5B%5D=123&#x26;type=search
1543
- * ```
1544
- */
1545
- sort(): void;
1546
- /**
1547
- * Returns the search parameters serialized as a string, with characters
1548
- * percent-encoded where necessary.
1549
- */
1550
- toString(): string;
1551
- /**
1552
- * Returns an ES6 `Iterator` over the values of each name-value pair.
1553
- */
1554
- values(): IterableIterator<string>;
1555
- [Symbol.iterator](): IterableIterator<[string, string]>;
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&#x26;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&#x26;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&#x26;foo=baz&#x26;abc=def
1567
+ *
1568
+ * params.set('foo', 'def');
1569
+ * params.set('xyz', 'opq');
1570
+ * console.log(params.toString());
1571
+ * // Prints foo=def&#x26;abc=def&#x26;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&#x26;type=search&#x26;query[]=123');
1587
+ * params.sort();
1588
+ * console.log(params.toString());
1589
+ * // Prints query%5B%5D=abc&#x26;query%5B%5D=123&#x26;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
- method?: "options" | "OPTIONS" | "get" | "GET" | "head" | "HEAD" | "post" | "POST" | "put" | "PUT" | "delete" | "DELETE" | "trace" | "TRACE" | "connect" | "CONNECT" | undefined;
1565
- /**
1566
- * 请求头
1567
- */
1568
- headers?: Record<string, string>;
1569
- /**
1570
- * 请求主体
1571
- */
1572
- body?: RequestBody;
1573
- /**
1574
- * Cookie 作用域
1575
- */
1576
- cookieScope?: string;
1577
- /**
1578
- * Cookie Store
1579
- */
1580
- cookieStore?: CookieStore;
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
- /** Status Code */
1584
- status: number;
1585
- /** Response headers */
1586
- headers: Headers;
1587
- /** Response data */
1588
- data: T;
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, { method, headers, body, cookieScope, cookieStore, ...options }?: RequestOptions<T>) => Promise<RequestResponse<T>>;
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
- server?: string;
1599
- /**
1600
- * Cookie 存储
1601
- */
1602
- cookieStore?: CookieStore | string;
1603
- /**
1604
- * 请求选项处理器
1605
- */
1606
- requestHandler?: <T extends Record<never, never> | unknown[] | string | ArrayBuffer = Record<string, any>>(
1607
- /** 请求地址 */
1608
- url: string,
1609
- /** 请求配置 */
1610
- options: RequestOptions<T>) => RequestOptions<T>;
1611
- /**
1612
- * 响应处理器
1613
- *
1614
- * @throws {MpError} 自定义的错误数据
1615
- */
1616
- responseHandler?: <T extends Record<never, never> | unknown[] | string | ArrayBuffer = Record<string, any>>(
1617
- /** 响应数据 */
1618
- response: RequestResponse<T>,
1619
- /** 请求地址 */
1620
- url: string,
1621
- /** 请求配置 */
1622
- options: RequestOptions<T>) => RequestResponse<T>;
1623
- /**
1624
- * 错误处理器
1625
- *
1626
- * @throws {MpError} 自定义的错误数据
1627
- */
1628
- errorHandler?: <T extends Record<never, never> | unknown[] | string | ArrayBuffer = Record<string, any>>(
1629
- /** 错误信息 */
1630
- error: MpError,
1631
- /** 请求地址 */
1632
- url: string,
1633
- /** 请求配置 */
1634
- options: RequestOptions<T>) => RequestResponse<T> | never;
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
- * Cookie 存储
1639
- */
1640
- cookieStore: CookieStore;
1641
- /**
1642
- * 请求方法
1643
- */
1644
- request: RequestType;
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: ({ cookieStore, server, requestHandler, responseHandler, errorHandler, ...defaultOptions }?: RequestInitOptions) => RequestFactory;
1650
-
1651
- 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";
1652
- type DeprecatedTag = "big" | "center" | "font";
1653
- type ConvertedTag = "html" | "body" | "svg";
1654
- declare const ALLOWED_TAGS: [
1655
- tag: AllowTag | DeprecatedTag | ConvertedTag,
1656
- allowedAttrs?: string[]
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
- /** Type for the root element of a document */
1662
- Root = "root",
1663
- /** Type for Text */
1664
- Text = "text",
1665
- /** Type for <? ... ?> */
1666
- Directive = "directive",
1667
- /** Type for <!-- ... --> */
1668
- Comment = "comment",
1669
- /** Type for <script> tags */
1670
- Script = "script",
1671
- /** Type for <style> tags */
1672
- Style = "style",
1673
- /** Type for Any tag */
1674
- Tag = "tag",
1675
- /** Type for <![CDATA[ ... ]]> */
1676
- CDATA = "cdata",
1677
- /** Type for <!doctype ...> */
1678
- Doctype = "doctype"
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
- /** One-based line index of the first character. */
1683
- startLine: number;
1684
- /** One-based column index of the first character. */
1685
- startCol: number;
1686
- /** Zero-based first character index. */
1687
- startOffset: number;
1688
- /** One-based line index of the last character. */
1689
- endLine: number;
1690
- /** One-based column index of the last character. Points directly *after* the last character. */
1691
- endCol: number;
1692
- /** Zero-based last character index. Points directly *after* the last character. */
1693
- endOffset: number;
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
- startTag?: SourceCodeLocation;
1697
- endTag?: SourceCodeLocation;
1756
+ startTag?: SourceCodeLocation;
1757
+ endTag?: SourceCodeLocation;
1698
1758
  }
1699
- declare type ParentNode = Document | Element | CDATA;
1700
- declare type ChildNode = Text | Comment | ProcessingInstruction | Element | CDATA | Document;
1701
- declare type AnyNode = ParentNode | ChildNode;
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
- /** The type of the node. */
1708
- abstract readonly type: ElementType;
1709
- /** Parent of the node */
1710
- parent: ParentNode | null;
1711
- /** Previous sibling */
1712
- prev: ChildNode | null;
1713
- /** Next sibling */
1714
- next: ChildNode | null;
1715
- /** The start index of the node. Requires `withStartIndices` on the handler to be `true. */
1716
- startIndex: number | null;
1717
- /** The end index of the node. Requires `withEndIndices` on the handler to be `true. */
1718
- endIndex: number | null;
1719
- /**
1720
- * `parse5` source code location info.
1721
- *
1722
- * Available if parsing with parse5 and location info is enabled.
1723
- */
1724
- sourceCodeLocation?: SourceCodeLocation | null;
1725
- /**
1726
- * [DOM spec](https://dom.spec.whatwg.org/#dom-node-nodetype)-compatible
1727
- * node {@link type}.
1728
- */
1729
- abstract readonly nodeType: number;
1730
- /**
1731
- * Same as {@link parent}.
1732
- * [DOM spec](https://dom.spec.whatwg.org)-compatible alias.
1733
- */
1734
- get parentNode(): ParentNode | null;
1735
- set parentNode(parent: ParentNode | null);
1736
- /**
1737
- * Same as {@link prev}.
1738
- * [DOM spec](https://dom.spec.whatwg.org)-compatible alias.
1739
- */
1740
- get previousSibling(): ChildNode | null;
1741
- set previousSibling(prev: ChildNode | null);
1742
- /**
1743
- * Same as {@link next}.
1744
- * [DOM spec](https://dom.spec.whatwg.org)-compatible alias.
1745
- */
1746
- get nextSibling(): ChildNode | null;
1747
- set nextSibling(next: ChildNode | null);
1748
- /**
1749
- * Clone this node, and optionally its children.
1750
- *
1751
- * @param recursive Clone child nodes as well.
1752
- * @returns A clone of the node.
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
- data: string;
1761
- /**
1762
- * @param data The content of the data node
1763
- */
1764
- constructor(data: string);
1765
- /**
1766
- * Same as {@link data}.
1767
- * [DOM spec](https://dom.spec.whatwg.org)-compatible alias.
1768
- */
1769
- get nodeValue(): string;
1770
- set nodeValue(data: string);
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
- type: ElementType.Text;
1777
- get nodeType(): 3;
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
- type: ElementType.Comment;
1784
- get nodeType(): 8;
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
- name: string;
1791
- type: ElementType.Directive;
1792
- constructor(name: string, data: string);
1793
- get nodeType(): 1;
1794
- /** If this is a doctype, the document type name (parse5 only). */
1795
- "x-name"?: string;
1796
- /** If this is a doctype, the document type public identifier (parse5 only). */
1797
- "x-publicId"?: string;
1798
- /** If this is a doctype, the document type system identifier (parse5 only). */
1799
- "x-systemId"?: string;
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 `Node` that can have children.
1870
+ * A node that can have children.
1803
1871
  */
1804
1872
  declare abstract class NodeWithChildren extends Node {
1805
- children: ChildNode[];
1806
- /**
1807
- * @param children Children of the node. Only certain node types can have children.
1808
- */
1809
- constructor(children: ChildNode[]);
1810
- /** First child of the node. */
1811
- get firstChild(): ChildNode | null;
1812
- /** Last child of the node. */
1813
- get lastChild(): ChildNode | null;
1814
- /**
1815
- * Same as {@link children}.
1816
- * [DOM spec](https://dom.spec.whatwg.org)-compatible alias.
1817
- */
1818
- get childNodes(): ChildNode[];
1819
- set childNodes(children: ChildNode[]);
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
- type: ElementType.CDATA;
1823
- get nodeType(): 4;
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
- type: ElementType.Root;
1830
- get nodeType(): 9;
1831
- /** [Document mode](https://dom.spec.whatwg.org/#concept-document-limited-quirks) (parse5 only). */
1832
- "x-mode"?: "no-quirks" | "quirks" | "limited-quirks";
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
- name: string;
1839
- value: string;
1840
- namespace?: string;
1841
- prefix?: string;
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
- name: string;
1848
- attribs: {
1849
- [name: string]: string;
1850
- };
1851
- type: ElementType.Tag | ElementType.Script | ElementType.Style;
1852
- /**
1853
- * @param name Name of the tag, eg. `div`, `span`.
1854
- * @param attribs Object mapping attribute names to attribute values.
1855
- * @param children Children of the node.
1856
- */
1857
- constructor(name: string, attribs: {
1858
- [name: string]: string;
1859
- }, children?: ChildNode[], type?: ElementType.Tag | ElementType.Script | ElementType.Style);
1860
- get nodeType(): 1;
1861
- /**
1862
- * `parse5` source code location info, with start & end tags.
1863
- *
1864
- * Available if parsing with parse5 and location info is enabled.
1865
- */
1866
- sourceCodeLocation?: TagSourceCodeLocation | null;
1867
- /**
1868
- * Same as {@link name}.
1869
- * [DOM spec](https://dom.spec.whatwg.org)-compatible alias.
1870
- */
1871
- get tagName(): string;
1872
- set tagName(name: string);
1873
- get attributes(): Attribute[];
1874
- /** Element namespace (parse5 only). */
1875
- namespace?: string;
1876
- /** Element attribute namespaces (parse5 only). */
1877
- "x-attribsNamespace"?: Record<string, string>;
1878
- /** Element attribute namespace-related prefixes (parse5 only). */
1879
- "x-attribsPrefix"?: Record<string, string>;
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
- type: "node";
1887
- name: string;
1888
- attrs?: Record<string, string>;
1889
- children?: RichTextNode[];
1965
+ type: "node";
1966
+ name: string;
1967
+ attrs?: Record<string, string>;
1968
+ children?: RichTextNode[];
1890
1969
  }
1891
1970
  interface TextNode {
1892
- type: "text";
1893
- text: string;
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
- * 是否附加标签名到 class
1901
- *
1902
- * @default true
1903
- */
1904
- appendClass?: boolean;
1905
- /**
1906
- * 处理 Tag
1907
- */
1908
- transform?: Partial<Record<AllowTag, NodeHandler>>;
1909
- }
1910
-
1911
- declare const getRichTextNodes: (content: string | AnyNode[], { appendClass, transform }?: ParserOptions) => Promise<RichTextNode[]>;
1912
-
1913
- /** SVG 转换 */
1914
- declare const convertSVGToDataURI: (content: string) => string;
1915
-
1916
- declare const getText: (content: string | AnyNode[]) => string;
1917
-
1918
- export { $App, $Component, $Config, $Page, ALLOWED_TAGS, Cookie, CookieStore, Emitter, Headers, MpError$1 as MpError, Queue, URLSearchParams, 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, ls, mkdir, normalizeDomain, once, openDocument, parseCookieHeader, parseHTML, parseUrl, put, 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 };
1919
- export type { AllowTag, AppConfigCommonOptions, AppConfigOptions, AppConstructor, AppInstance, AppOptions, ComponentConstructor, ComponentInstance, ComponentLifetimes, ComponentOptions, Config, ConvertedTag, CookieMap, CookieOptions, CookieStoreType, CookieType, DeprecatedTag, ElementNode, EmitterInstance, Env, EventHandlerList, EventHandlerMap, EventType, ExtendedAppMethods, ExtendedComponentMethods, ExtendedComponentProperty, ExtendedPageLifeCycles, ExtendedPageMethods, ExtendedPageProperties, ExtendsAppOptions, Handler, HeadersInit, InferFromType, InferPropType, InferPropTypes, MpErrorOptions$1 as MpErrorOptions, PageConstructor, PageInstance, PageOptions, PageQuery, PageState, PropItem, PropOption, PropType, Props, PropsOptions, RefMap, RequestBody, RequestFactory, RequestInitOptions, RequestOptions, RequestResponse, RequestType, RichTextNode, RouteCustomConfig, RoutePathConfig, SetCookieOptions, StorageData, Task, TextNode, TrivialComponentInstance, TrivialComponentOptions, TrivialPageInstance, TrivialPageOptions, UpdateInfo, UrlInfo, WildCardEventHandlerList, WildcardHandler };
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.mts.map