@mptool/all 0.8.6 → 0.9.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/lib/index.d.mts +25 -12
- package/lib/index.d.ts +25 -12
- package/lib/index.js +7 -7
- package/lib/index.js.map +1 -1
- package/lib/index.mjs +7 -7
- package/lib/index.mjs.map +1 -1
- package/package.json +7 -7
package/lib/index.d.mts
CHANGED
|
@@ -29,6 +29,15 @@ interface EmitterInstance<Events> {
|
|
|
29
29
|
*/
|
|
30
30
|
declare function Emitter<Events>(all?: EventHandlerMap<Events>): EmitterInstance<Events>;
|
|
31
31
|
|
|
32
|
+
interface MpErrorOptions$1 {
|
|
33
|
+
code?: number;
|
|
34
|
+
message?: string;
|
|
35
|
+
}
|
|
36
|
+
declare class MpError$1 extends Error {
|
|
37
|
+
code: number | null;
|
|
38
|
+
constructor({ code, message }: MpErrorOptions$1);
|
|
39
|
+
}
|
|
40
|
+
|
|
32
41
|
/** 写入普通日志 */
|
|
33
42
|
declare const debug: (...args: any[]) => void;
|
|
34
43
|
/** 写入信息日志 */
|
|
@@ -359,17 +368,17 @@ interface ExtendedComponentMethods extends InstanceEmitterMethods {
|
|
|
359
368
|
*/
|
|
360
369
|
_$attached(parent: TrivialComponentInstance | TrivialPageInstance): void;
|
|
361
370
|
}
|
|
362
|
-
type ComponentInstance<Data extends WechatMiniprogram.Component.DataOption, Props extends PropsOptions, Method extends Partial<WechatMiniprogram.Component.MethodOption>, InstanceProps extends WechatMiniprogram.IAnyObject =
|
|
371
|
+
type ComponentInstance<Data extends WechatMiniprogram.Component.DataOption, Props extends PropsOptions, Method extends Partial<WechatMiniprogram.Component.MethodOption>, 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 & (IsPage extends true ? WechatMiniprogram.Page.ILifetime : Record<never, never>)> & {
|
|
363
372
|
/** 组件数据,**包括内部数据和属性值** */
|
|
364
373
|
data: Data & InferPropTypes<Props>;
|
|
365
374
|
/** 组件数据,**包括内部数据和属性值**(与 `data` 一致) */
|
|
366
375
|
properties: Data & InferPropTypes<Props>;
|
|
367
376
|
};
|
|
368
|
-
type ComponentOptions<Data extends WechatMiniprogram.Component.DataOption, Props extends PropsOptions, Method extends WechatMiniprogram.Component.MethodOption, InstanceProps extends WechatMiniprogram.IAnyObject =
|
|
377
|
+
type ComponentOptions<Data extends WechatMiniprogram.Component.DataOption, Props extends PropsOptions, Method extends WechatMiniprogram.Component.MethodOption, InstanceProps extends WechatMiniprogram.IAnyObject = Record<never, never>, IsPage extends boolean = false> = Partial<WechatMiniprogram.Component.Data<Data>> & Partial<{
|
|
369
378
|
/** 组件属性 */
|
|
370
379
|
props: Props;
|
|
371
380
|
}> & Partial<WechatMiniprogram.Component.Method<Method, IsPage>> & Partial<WechatMiniprogram.Component.OtherOption> & Partial<ComponentLifetimes> & ThisType<ComponentInstance<Data, Props, Method, InstanceProps, IsPage>>;
|
|
372
|
-
type ComponentConstructor = <Data extends WechatMiniprogram.Component.DataOption, Props extends PropsOptions, Method extends WechatMiniprogram.Component.MethodOption, InstanceProps extends WechatMiniprogram.IAnyObject =
|
|
381
|
+
type ComponentConstructor = <Data extends WechatMiniprogram.Component.DataOption, Props extends PropsOptions, Method extends WechatMiniprogram.Component.MethodOption, InstanceProps extends WechatMiniprogram.IAnyObject = Record<never, never>, IsPage extends boolean = false>(options: ComponentOptions<Data, Props, Method, InstanceProps, IsPage>) => string;
|
|
373
382
|
type TrivialComponentInstance = ComponentInstance<WechatMiniprogram.IAnyObject, Record<string, null>, Record<string, (...args: unknown[]) => any>>;
|
|
374
383
|
type TrivialComponentOptions = ComponentInstance<WechatMiniprogram.IAnyObject, Record<string, null>, Record<string, (...args: any[]) => any>>;
|
|
375
384
|
type RefMap = Record<string, TrivialComponentInstance>;
|
|
@@ -1126,6 +1135,15 @@ declare class Cookie {
|
|
|
1126
1135
|
toJSON(): CookieType;
|
|
1127
1136
|
}
|
|
1128
1137
|
|
|
1138
|
+
interface MpErrorOptions {
|
|
1139
|
+
code?: number;
|
|
1140
|
+
message?: string;
|
|
1141
|
+
}
|
|
1142
|
+
declare class MpError extends Error {
|
|
1143
|
+
code: number | null;
|
|
1144
|
+
constructor({ code, message }: MpErrorOptions);
|
|
1145
|
+
}
|
|
1146
|
+
|
|
1129
1147
|
/**
|
|
1130
1148
|
* @see RFC 6265
|
|
1131
1149
|
*/
|
|
@@ -1455,11 +1473,6 @@ interface RequestResponse<T extends Record<never, never> | unknown[] | string |
|
|
|
1455
1473
|
/** Response data */
|
|
1456
1474
|
data: T;
|
|
1457
1475
|
}
|
|
1458
|
-
interface RequestError extends Error {
|
|
1459
|
-
/** 错误码 */
|
|
1460
|
-
errno?: number;
|
|
1461
|
-
status?: number;
|
|
1462
|
-
}
|
|
1463
1476
|
type RequestType = <T extends Record<never, never> | unknown[] | string | ArrayBuffer = Record<string, any>>(url: string, options?: RequestOptions<T>) => Promise<RequestResponse<T>>;
|
|
1464
1477
|
declare const request: <T extends Record<never, never> | unknown[] | string | ArrayBuffer = Record<string, any>>(url: string, { method, headers, body, cookieScope, cookieStore, ...options }?: RequestOptions<T>) => Promise<RequestResponse<T>>;
|
|
1465
1478
|
interface RequestInitOptions extends Pick<WechatMiniprogram.RequestOption, "redirect" | "enableCache" | "enableChunked" | "enableHttp2" | "enableHttpDNS" | "enableQuic" | "httpDNSServiceId" | "forceCellularNetwork" | "timeout"> {
|
|
@@ -1482,7 +1495,7 @@ interface RequestInitOptions extends Pick<WechatMiniprogram.RequestOption, "redi
|
|
|
1482
1495
|
/**
|
|
1483
1496
|
* 响应处理器
|
|
1484
1497
|
*
|
|
1485
|
-
* @throws {
|
|
1498
|
+
* @throws {MpError} 自定义的错误数据
|
|
1486
1499
|
*/
|
|
1487
1500
|
responseHandler?: <T extends Record<never, never> | unknown[] | string | ArrayBuffer = Record<string, any>>(
|
|
1488
1501
|
/** 响应数据 */
|
|
@@ -1494,11 +1507,11 @@ interface RequestInitOptions extends Pick<WechatMiniprogram.RequestOption, "redi
|
|
|
1494
1507
|
/**
|
|
1495
1508
|
* 错误处理器
|
|
1496
1509
|
*
|
|
1497
|
-
* @throws {
|
|
1510
|
+
* @throws {MpError} 自定义的错误数据
|
|
1498
1511
|
*/
|
|
1499
1512
|
errorHandler?: <T extends Record<never, never> | unknown[] | string | ArrayBuffer = Record<string, any>>(
|
|
1500
1513
|
/** 错误信息 */
|
|
1501
|
-
error:
|
|
1514
|
+
error: MpError,
|
|
1502
1515
|
/** 请求地址 */
|
|
1503
1516
|
url: string,
|
|
1504
1517
|
/** 请求配置 */
|
|
@@ -1780,4 +1793,4 @@ declare const getRichTextNodes: (content: string | AnyNode[], { appendClass, tra
|
|
|
1780
1793
|
|
|
1781
1794
|
declare const getText: (content: string | AnyNode[]) => string;
|
|
1782
1795
|
|
|
1783
|
-
export { $App, $Component, $Config, $Page, ALLOWED_TAGS, type AllowTag, type AppConfigCommonOptions, type AppConfigOptions, type AppConstructor, type AppInstance, type AppOptions, type ComponentConstructor, type ComponentInstance, type ComponentLifetimes, type ComponentOptions, type Config, Cookie, type CookieMap, type CookieOptions, CookieStore, type CookieStoreType, type CookieType, type ElementNode, Emitter, type EmitterInstance, type EventHandlerList, type EventHandlerMap, type EventType, type ExtendedAppMethods, type ExtendedComponentMethods, type ExtendedComponentProperty, type ExtendedPageLifeCycles, type ExtendedPageMethods, type ExtendedPageProperties, type ExtendsAppOptions, type Handler, Headers, type HeadersInit, type InferFromType, type InferPropType, type InferPropTypes, type PageConstructor, type PageInstance, type PageOptions, type PageQuery, type PageState, type PropItem, type PropOption, type PropType, type Props, type PropsOptions, Queue, type RefMap, type RequestBody, type
|
|
1796
|
+
export { $App, $Component, $Config, $Page, ALLOWED_TAGS, type AllowTag, type AppConfigCommonOptions, type AppConfigOptions, type AppConstructor, type AppInstance, type AppOptions, type ComponentConstructor, type ComponentInstance, type ComponentLifetimes, type ComponentOptions, type Config, Cookie, type CookieMap, type CookieOptions, CookieStore, type CookieStoreType, type CookieType, type ElementNode, Emitter, type EmitterInstance, type EventHandlerList, type EventHandlerMap, type EventType, type ExtendedAppMethods, type ExtendedComponentMethods, type ExtendedComponentProperty, type ExtendedPageLifeCycles, type ExtendedPageMethods, type ExtendedPageProperties, type ExtendsAppOptions, type Handler, Headers, type HeadersInit, type InferFromType, type InferPropType, type InferPropTypes, MpError$1 as MpError, type MpErrorOptions$1 as MpErrorOptions, type PageConstructor, type PageInstance, type PageOptions, type PageQuery, type PageState, type PropItem, type PropOption, type PropType, type Props, type PropsOptions, Queue, type RefMap, type RequestBody, type RequestFactory, type RequestInitOptions, type RequestOptions, type RequestResponse, type RequestType, type RichTextNode, type RouteCustomConfig, type RoutePathConfig, type SetCookieOptions, type StorageData, type Task, type TextNode, type TrivialComponentInstance, type TrivialComponentOptions, type TrivialPageInstance, type TrivialPageOptions, URLSearchParams, type UrlInfo, type WildCardEventHandlerList, type WildcardHandler, appState, check, checkAsync, createRequest, decode as decodeBase64, dirname, userEmitter as emitter, encode as encodeBase64, exists, funcQueue, get, getAsync, getConfig, getCookieScopeDomain, getDomain, getRef, getRichTextNodes, getText, getUrlInfo, handleProperties, isDir, isFile, isFunction, isMp, isQQ, isWx, lock, logger, ls, mkdir, normalizeDomain, once, parseCookieHeader, parseHTML, parseUrl, put, query, readFile, readJSON, remove, removeAsync, removeRef, request, requestCookieStore, rm, saveFile, saveOnlineFile, set, setAsync, setRef, storage, take, type, unzip, wrapFunction, writeFile, writeJSON };
|
package/lib/index.d.ts
CHANGED
|
@@ -29,6 +29,15 @@ interface EmitterInstance<Events> {
|
|
|
29
29
|
*/
|
|
30
30
|
declare function Emitter<Events>(all?: EventHandlerMap<Events>): EmitterInstance<Events>;
|
|
31
31
|
|
|
32
|
+
interface MpErrorOptions$1 {
|
|
33
|
+
code?: number;
|
|
34
|
+
message?: string;
|
|
35
|
+
}
|
|
36
|
+
declare class MpError$1 extends Error {
|
|
37
|
+
code: number | null;
|
|
38
|
+
constructor({ code, message }: MpErrorOptions$1);
|
|
39
|
+
}
|
|
40
|
+
|
|
32
41
|
/** 写入普通日志 */
|
|
33
42
|
declare const debug: (...args: any[]) => void;
|
|
34
43
|
/** 写入信息日志 */
|
|
@@ -359,17 +368,17 @@ interface ExtendedComponentMethods extends InstanceEmitterMethods {
|
|
|
359
368
|
*/
|
|
360
369
|
_$attached(parent: TrivialComponentInstance | TrivialPageInstance): void;
|
|
361
370
|
}
|
|
362
|
-
type ComponentInstance<Data extends WechatMiniprogram.Component.DataOption, Props extends PropsOptions, Method extends Partial<WechatMiniprogram.Component.MethodOption>, InstanceProps extends WechatMiniprogram.IAnyObject =
|
|
371
|
+
type ComponentInstance<Data extends WechatMiniprogram.Component.DataOption, Props extends PropsOptions, Method extends Partial<WechatMiniprogram.Component.MethodOption>, 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 & (IsPage extends true ? WechatMiniprogram.Page.ILifetime : Record<never, never>)> & {
|
|
363
372
|
/** 组件数据,**包括内部数据和属性值** */
|
|
364
373
|
data: Data & InferPropTypes<Props>;
|
|
365
374
|
/** 组件数据,**包括内部数据和属性值**(与 `data` 一致) */
|
|
366
375
|
properties: Data & InferPropTypes<Props>;
|
|
367
376
|
};
|
|
368
|
-
type ComponentOptions<Data extends WechatMiniprogram.Component.DataOption, Props extends PropsOptions, Method extends WechatMiniprogram.Component.MethodOption, InstanceProps extends WechatMiniprogram.IAnyObject =
|
|
377
|
+
type ComponentOptions<Data extends WechatMiniprogram.Component.DataOption, Props extends PropsOptions, Method extends WechatMiniprogram.Component.MethodOption, InstanceProps extends WechatMiniprogram.IAnyObject = Record<never, never>, IsPage extends boolean = false> = Partial<WechatMiniprogram.Component.Data<Data>> & Partial<{
|
|
369
378
|
/** 组件属性 */
|
|
370
379
|
props: Props;
|
|
371
380
|
}> & Partial<WechatMiniprogram.Component.Method<Method, IsPage>> & Partial<WechatMiniprogram.Component.OtherOption> & Partial<ComponentLifetimes> & ThisType<ComponentInstance<Data, Props, Method, InstanceProps, IsPage>>;
|
|
372
|
-
type ComponentConstructor = <Data extends WechatMiniprogram.Component.DataOption, Props extends PropsOptions, Method extends WechatMiniprogram.Component.MethodOption, InstanceProps extends WechatMiniprogram.IAnyObject =
|
|
381
|
+
type ComponentConstructor = <Data extends WechatMiniprogram.Component.DataOption, Props extends PropsOptions, Method extends WechatMiniprogram.Component.MethodOption, InstanceProps extends WechatMiniprogram.IAnyObject = Record<never, never>, IsPage extends boolean = false>(options: ComponentOptions<Data, Props, Method, InstanceProps, IsPage>) => string;
|
|
373
382
|
type TrivialComponentInstance = ComponentInstance<WechatMiniprogram.IAnyObject, Record<string, null>, Record<string, (...args: unknown[]) => any>>;
|
|
374
383
|
type TrivialComponentOptions = ComponentInstance<WechatMiniprogram.IAnyObject, Record<string, null>, Record<string, (...args: any[]) => any>>;
|
|
375
384
|
type RefMap = Record<string, TrivialComponentInstance>;
|
|
@@ -1126,6 +1135,15 @@ declare class Cookie {
|
|
|
1126
1135
|
toJSON(): CookieType;
|
|
1127
1136
|
}
|
|
1128
1137
|
|
|
1138
|
+
interface MpErrorOptions {
|
|
1139
|
+
code?: number;
|
|
1140
|
+
message?: string;
|
|
1141
|
+
}
|
|
1142
|
+
declare class MpError extends Error {
|
|
1143
|
+
code: number | null;
|
|
1144
|
+
constructor({ code, message }: MpErrorOptions);
|
|
1145
|
+
}
|
|
1146
|
+
|
|
1129
1147
|
/**
|
|
1130
1148
|
* @see RFC 6265
|
|
1131
1149
|
*/
|
|
@@ -1455,11 +1473,6 @@ interface RequestResponse<T extends Record<never, never> | unknown[] | string |
|
|
|
1455
1473
|
/** Response data */
|
|
1456
1474
|
data: T;
|
|
1457
1475
|
}
|
|
1458
|
-
interface RequestError extends Error {
|
|
1459
|
-
/** 错误码 */
|
|
1460
|
-
errno?: number;
|
|
1461
|
-
status?: number;
|
|
1462
|
-
}
|
|
1463
1476
|
type RequestType = <T extends Record<never, never> | unknown[] | string | ArrayBuffer = Record<string, any>>(url: string, options?: RequestOptions<T>) => Promise<RequestResponse<T>>;
|
|
1464
1477
|
declare const request: <T extends Record<never, never> | unknown[] | string | ArrayBuffer = Record<string, any>>(url: string, { method, headers, body, cookieScope, cookieStore, ...options }?: RequestOptions<T>) => Promise<RequestResponse<T>>;
|
|
1465
1478
|
interface RequestInitOptions extends Pick<WechatMiniprogram.RequestOption, "redirect" | "enableCache" | "enableChunked" | "enableHttp2" | "enableHttpDNS" | "enableQuic" | "httpDNSServiceId" | "forceCellularNetwork" | "timeout"> {
|
|
@@ -1482,7 +1495,7 @@ interface RequestInitOptions extends Pick<WechatMiniprogram.RequestOption, "redi
|
|
|
1482
1495
|
/**
|
|
1483
1496
|
* 响应处理器
|
|
1484
1497
|
*
|
|
1485
|
-
* @throws {
|
|
1498
|
+
* @throws {MpError} 自定义的错误数据
|
|
1486
1499
|
*/
|
|
1487
1500
|
responseHandler?: <T extends Record<never, never> | unknown[] | string | ArrayBuffer = Record<string, any>>(
|
|
1488
1501
|
/** 响应数据 */
|
|
@@ -1494,11 +1507,11 @@ interface RequestInitOptions extends Pick<WechatMiniprogram.RequestOption, "redi
|
|
|
1494
1507
|
/**
|
|
1495
1508
|
* 错误处理器
|
|
1496
1509
|
*
|
|
1497
|
-
* @throws {
|
|
1510
|
+
* @throws {MpError} 自定义的错误数据
|
|
1498
1511
|
*/
|
|
1499
1512
|
errorHandler?: <T extends Record<never, never> | unknown[] | string | ArrayBuffer = Record<string, any>>(
|
|
1500
1513
|
/** 错误信息 */
|
|
1501
|
-
error:
|
|
1514
|
+
error: MpError,
|
|
1502
1515
|
/** 请求地址 */
|
|
1503
1516
|
url: string,
|
|
1504
1517
|
/** 请求配置 */
|
|
@@ -1780,4 +1793,4 @@ declare const getRichTextNodes: (content: string | AnyNode[], { appendClass, tra
|
|
|
1780
1793
|
|
|
1781
1794
|
declare const getText: (content: string | AnyNode[]) => string;
|
|
1782
1795
|
|
|
1783
|
-
export { $App, $Component, $Config, $Page, ALLOWED_TAGS, type AllowTag, type AppConfigCommonOptions, type AppConfigOptions, type AppConstructor, type AppInstance, type AppOptions, type ComponentConstructor, type ComponentInstance, type ComponentLifetimes, type ComponentOptions, type Config, Cookie, type CookieMap, type CookieOptions, CookieStore, type CookieStoreType, type CookieType, type ElementNode, Emitter, type EmitterInstance, type EventHandlerList, type EventHandlerMap, type EventType, type ExtendedAppMethods, type ExtendedComponentMethods, type ExtendedComponentProperty, type ExtendedPageLifeCycles, type ExtendedPageMethods, type ExtendedPageProperties, type ExtendsAppOptions, type Handler, Headers, type HeadersInit, type InferFromType, type InferPropType, type InferPropTypes, type PageConstructor, type PageInstance, type PageOptions, type PageQuery, type PageState, type PropItem, type PropOption, type PropType, type Props, type PropsOptions, Queue, type RefMap, type RequestBody, type
|
|
1796
|
+
export { $App, $Component, $Config, $Page, ALLOWED_TAGS, type AllowTag, type AppConfigCommonOptions, type AppConfigOptions, type AppConstructor, type AppInstance, type AppOptions, type ComponentConstructor, type ComponentInstance, type ComponentLifetimes, type ComponentOptions, type Config, Cookie, type CookieMap, type CookieOptions, CookieStore, type CookieStoreType, type CookieType, type ElementNode, Emitter, type EmitterInstance, type EventHandlerList, type EventHandlerMap, type EventType, type ExtendedAppMethods, type ExtendedComponentMethods, type ExtendedComponentProperty, type ExtendedPageLifeCycles, type ExtendedPageMethods, type ExtendedPageProperties, type ExtendsAppOptions, type Handler, Headers, type HeadersInit, type InferFromType, type InferPropType, type InferPropTypes, MpError$1 as MpError, type MpErrorOptions$1 as MpErrorOptions, type PageConstructor, type PageInstance, type PageOptions, type PageQuery, type PageState, type PropItem, type PropOption, type PropType, type Props, type PropsOptions, Queue, type RefMap, type RequestBody, type RequestFactory, type RequestInitOptions, type RequestOptions, type RequestResponse, type RequestType, type RichTextNode, type RouteCustomConfig, type RoutePathConfig, type SetCookieOptions, type StorageData, type Task, type TextNode, type TrivialComponentInstance, type TrivialComponentOptions, type TrivialPageInstance, type TrivialPageOptions, URLSearchParams, type UrlInfo, type WildCardEventHandlerList, type WildcardHandler, appState, check, checkAsync, createRequest, decode as decodeBase64, dirname, userEmitter as emitter, encode as encodeBase64, exists, funcQueue, get, getAsync, getConfig, getCookieScopeDomain, getDomain, getRef, getRichTextNodes, getText, getUrlInfo, handleProperties, isDir, isFile, isFunction, isMp, isQQ, isWx, lock, logger, ls, mkdir, normalizeDomain, once, parseCookieHeader, parseHTML, parseUrl, put, query, readFile, readJSON, remove, removeAsync, removeRef, request, requestCookieStore, rm, saveFile, saveOnlineFile, set, setAsync, setRef, storage, take, type, unzip, wrapFunction, writeFile, writeJSON };
|