@mptool/all 0.6.4 → 0.7.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 CHANGED
@@ -97,6 +97,7 @@ declare namespace query {
97
97
  * @returns 对象的类型
98
98
  */
99
99
  declare const type: (obj: unknown) => string;
100
+ declare const isFunction: <T extends Function>(obj: unknown) => obj is T;
100
101
 
101
102
  /**
102
103
  * 包装函数,先执行 wrapper ,然后执行原函数
@@ -232,6 +233,7 @@ type PropMethod<Type, TypeConstructor = any> = Type extends (...args: any) => an
232
233
  } : never;
233
234
  type PropConstructor<Type = any> = (new (...args: any[]) => Type & {}) | (() => Type) | PropMethod<Type>;
234
235
  type PropType<T> = PropConstructor<T> | PropConstructor<T>[];
236
+ 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;
235
237
  type RequiredKeys<T> = {
236
238
  [K in keyof T]: T[K] extends {
237
239
  required: true;
@@ -357,21 +359,22 @@ interface ExtendedComponentMethods extends InstanceEmitterMethods {
357
359
  */
358
360
  _$attached(parent: TrivialComponentInstance | TrivialPageInstance): void;
359
361
  }
360
- type ComponentInstance<Data extends WechatMiniprogram.Component.DataOption, Property extends PropsOptions, Method extends Partial<WechatMiniprogram.Component.MethodOption>, CustomInstanceProperty extends WechatMiniprogram.IAnyObject = {}, IsPage extends boolean = false> = WechatMiniprogram.Component.InstanceProperties & WechatMiniprogram.Component.InstanceMethods<Data> & ExtendedComponentMethods & Method & (IsPage extends true ? WechatMiniprogram.Page.ILifetime : {}) & CustomInstanceProperty & ExtendedComponentProperty & ExtendedPageMethods<Data & InferPropTypes<Property>, CustomInstanceProperty & Method & (IsPage extends true ? WechatMiniprogram.Page.ILifetime : {})> & {
362
+ type ComponentInstance<Data extends WechatMiniprogram.Component.DataOption, Props extends PropsOptions, Method extends Partial<WechatMiniprogram.Component.MethodOption>, InstanceProps extends WechatMiniprogram.IAnyObject = {}, IsPage extends boolean = false> = WechatMiniprogram.Component.InstanceProperties & WechatMiniprogram.Component.InstanceMethods<Data> & ExtendedComponentMethods & Method & (IsPage extends true ? WechatMiniprogram.Page.ILifetime : {}) & InstanceProps & ExtendedComponentProperty & ExtendedPageMethods<Data & InferPropTypes<Props>, InstanceProps & Method & (IsPage extends true ? WechatMiniprogram.Page.ILifetime : {})> & {
361
363
  /** 组件数据,**包括内部数据和属性值** */
362
- data: Data & InferPropTypes<Property>;
364
+ data: Data & InferPropTypes<Props>;
363
365
  /** 组件数据,**包括内部数据和属性值**(与 `data` 一致) */
364
- properties: Data & InferPropTypes<Property>;
366
+ properties: Data & InferPropTypes<Props>;
365
367
  };
366
- type ComponentOptions<Data extends WechatMiniprogram.Component.DataOption, Property extends PropsOptions, Method extends WechatMiniprogram.Component.MethodOption, CustomInstanceProperty extends WechatMiniprogram.IAnyObject = {}, IsPage extends boolean = false> = Partial<WechatMiniprogram.Component.Data<Data>> & Partial<{
368
+ type ComponentOptions<Data extends WechatMiniprogram.Component.DataOption, Props extends PropsOptions, Method extends WechatMiniprogram.Component.MethodOption, InstanceProps extends WechatMiniprogram.IAnyObject = {}, IsPage extends boolean = false> = Partial<WechatMiniprogram.Component.Data<Data>> & Partial<{
367
369
  /** 组件属性 */
368
- properties: Property;
369
- }> & Partial<WechatMiniprogram.Component.Method<Method, IsPage>> & Partial<WechatMiniprogram.Component.OtherOption> & Partial<ComponentLifetimes> & ThisType<ComponentInstance<Data, Property, Method, CustomInstanceProperty, IsPage>>;
370
- type ComponentConstructor = <Data extends WechatMiniprogram.Component.DataOption, Property extends PropsOptions, Method extends WechatMiniprogram.Component.MethodOption, CustomInstanceProperty extends WechatMiniprogram.IAnyObject = {}, IsPage extends boolean = false>(options: ComponentOptions<Data, Property, Method, CustomInstanceProperty, IsPage>) => string;
370
+ props: Props;
371
+ }> & 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 = {}, IsPage extends boolean = false>(options: ComponentOptions<Data, Props, Method, InstanceProps, IsPage>) => string;
371
373
  type TrivialComponentInstance = ComponentInstance<WechatMiniprogram.IAnyObject, Record<string, null>, Record<string, (...args: unknown[]) => any>>;
372
374
  type TrivialComponentOptions = ComponentInstance<WechatMiniprogram.IAnyObject, Record<string, null>, Record<string, (...args: any[]) => any>>;
373
375
  type RefMap = Record<string, TrivialComponentInstance>;
374
376
 
377
+ declare const handleProperties: (oldProps?: PropsOptions) => WechatMiniprogram.Component.PropertyOption;
375
378
  /**
376
379
  * 组件注册器
377
380
  *
@@ -379,6 +382,10 @@ type RefMap = Record<string, TrivialComponentInstance>;
379
382
  */
380
383
  declare const $Component: ComponentConstructor;
381
384
 
385
+ declare const getRef: (id: number) => TrivialComponentInstance;
386
+ declare const setRef: (id: number, value: TrivialComponentInstance) => void;
387
+ declare const removeRef: (id: number) => void;
388
+
382
389
  declare function bind(this: TrivialComponentInstance, touchEvent: WechatMiniprogram.Touch<{
383
390
  id: number;
384
391
  event: string;
@@ -732,6 +739,14 @@ type AppOptions<Custom> = ExtendsAppOptions & Partial<WechatMiniprogram.App.Opti
732
739
  type AppInstance<Custom> = AppOptions<Custom> & Custom & ExtendedAppMethods;
733
740
  type AppConstructor = <Custom extends WechatMiniprogram.IAnyObject>(appOptions: AppOptions<Custom>) => void;
734
741
 
742
+ declare const appState: {
743
+ /** 是否已启动 */
744
+ launch: boolean;
745
+ /** 启动参数 */
746
+ lOpt: {};
747
+ /** 切入后台时的时间戳 */
748
+ hide: number;
749
+ };
735
750
  /**
736
751
  * Application wrapper
737
752
  *
@@ -739,18 +754,59 @@ type AppConstructor = <Custom extends WechatMiniprogram.IAnyObject>(appOptions:
739
754
  */
740
755
  declare const $App: AppConstructor;
741
756
 
742
- interface AppConfig {
757
+ interface AppConfigCommonOptions {
743
758
  /**
744
- * 当你给出的页面路径或简称无法通过 routeMap 解析时,会回退到此路径
759
+ * 主页页面名称或路径
760
+ */
761
+ home?: string;
762
+ /**
763
+ * 跳转延迟执行的最长时间,单位 ms
745
764
  *
746
- * 填入小程序路径模式,小程序路径模式是一个路径字符串,用 `$name` 表示小程序简称的位置
765
+ * @description 异步 onNavigate 方法用时过久会直接调转
747
766
  *
748
- * 例子: 你可以填入 `/pages/$name/$name` 来表达:
767
+ * @default 200
768
+ */
769
+ maxDelay?: number;
770
+ /**
771
+ * 允许进行跳转据页面首屏渲染后的最小间隔时间,单位 ms
749
772
  *
750
- * - `main': '/pages/main/main`
751
- * - `user': '/pages/user/user`
773
+ * @default 100
752
774
  */
753
- defaultRoute: string;
775
+ minInterval?: number;
776
+ /**
777
+ * 自定义扩展组件
778
+ *
779
+ * 时机在框架执行扩展之前,可为每个组件挂载实例方法
780
+ *
781
+ * @param options 组件选项
782
+ */
783
+ extendComponent?(options: TrivialComponentOptions): void;
784
+ /**
785
+ * 自定义注入组件
786
+ *
787
+ * 时机在框架执行扩展之后,这意味着你可以覆盖框架的方法
788
+ *
789
+ * @param options 组件选项
790
+ */
791
+ injectComponent?(options: TrivialComponentOptions): void;
792
+ /**
793
+ * 自定义扩展页面,在框架执行扩展之前
794
+ *
795
+ * @param name 页面名称
796
+ * @param options 页面选项
797
+ */
798
+ extendPage?(name: string, options: TrivialPageOptions): void;
799
+ /**
800
+ * 自定义注入页面
801
+ *
802
+ * 在框架执行扩展之后,这意味着你可以覆盖框架的方法
803
+ *
804
+ * @param name 页面名称
805
+ * @param options 页面选项
806
+ */
807
+ injectPage?(name: string, options: TrivialPageOptions): void;
808
+ }
809
+ interface RoutePathConfig {
754
810
  /**
755
811
  * 你可以直接以对象形式表示简称到路径的映射。如:
756
812
  *
@@ -798,58 +854,47 @@ interface AppConfig {
798
854
  */
799
855
  routes?: Record<string, string> | [string | string[], string][];
800
856
  /**
801
- * 主页页面名称或路径
802
- */
803
- home?: string;
804
- /**
805
- * 跳转延迟执行的最长时间,单位 ms
857
+ * 当你给出的页面路径或简称无法通过 routeMap 解析时,会回退到此路径
806
858
  *
807
- * @description 异步 onNavigate 方法用时过久会直接调转
859
+ * 填入小程序路径模式,小程序路径模式是一个路径字符串,用 `$name` 表示小程序简称的位置
808
860
  *
809
- * @default 200
810
- */
811
- maxDelay?: number;
812
- /**
813
- * 允许进行跳转据页面首屏渲染后的最小间隔时间,单位 ms
861
+ * 例子: 你可以填入 `/pages/$name/$name` 来表达:
814
862
  *
815
- * @default 100
863
+ * - `main': '/pages/main/main`
864
+ * - `user': '/pages/user/user`
816
865
  */
817
- minInterval?: number;
866
+ defaultRoute: string;
867
+ }
868
+ interface RouteCustomConfig {
818
869
  /**
819
- * 自定义扩展组件
820
- *
821
- * 时机在框架执行扩展之前,可为每个组件挂载实例方法
870
+ * 获得页面简称
822
871
  *
823
- * @param options 组件选项
872
+ * @param url 页面路径
873
+ * @returns 页面名称
824
874
  */
825
- extendComponent?(options: TrivialComponentOptions): void;
875
+ getName: (url: string) => string;
826
876
  /**
827
- * 自定义注入组件
828
- *
829
- * 时机在框架执行扩展之后,这意味着你可以覆盖框架的方法
877
+ * 获得页面路径
830
878
  *
831
- * @param options 组件选项
879
+ * @param pageName 页面简称
880
+ * @returns 页面路径
832
881
  */
833
- injectComponent?(options: TrivialComponentOptions): void;
882
+ getRoute: (pageName: string) => string;
883
+ }
884
+ type AppConfigOptions = AppConfigCommonOptions & (RoutePathConfig | RouteCustomConfig);
885
+
886
+ interface Config extends Omit<AppConfigOptions, "defaultRoute" | "routeMap"> {
834
887
  /**
835
- * 自定义扩展页面,在框架执行扩展之前
836
- *
837
- * @param name 页面名称
838
- * @param options 页面选项
888
+ * @returns name
839
889
  */
840
- extendPage?(name: string, options: TrivialPageOptions): void;
890
+ getName: (url: string) => string;
841
891
  /**
842
- * 自定义注入页面
843
- *
844
- * 在框架执行扩展之后,这意味着你可以覆盖框架的方法
845
- *
846
- * @param name 页面名称
847
- * @param options 页面选项
892
+ * @returns route
848
893
  */
849
- injectPage?(name: string, options: TrivialPageOptions): void;
894
+ getRoute: (pageName: string) => string;
850
895
  }
851
-
852
- declare const $Config: (config: AppConfig) => void;
896
+ declare const $Config: (config: AppConfigOptions) => void;
897
+ declare const getConfig: () => Config;
853
898
 
854
899
  /** 文件编码 */
855
900
  type FileEncoding = "utf-8" | "ascii" | "base64" | "binary" | "hex" | "ucs2" | "ucs-2" | "utf16le" | "utf-16le" | "utf8" | "latin1";
@@ -1059,9 +1104,10 @@ interface CookieType {
1059
1104
  /**
1060
1105
  * indicates a cookie ought not to be sent along with cross-site requests
1061
1106
  */
1062
- sameSite?: string | undefined;
1107
+ sameSite?: boolean | "lax" | "strict" | "none" | undefined;
1063
1108
  }
1064
1109
 
1110
+ declare const getCookieScopeDomain: (domain?: string) => string[];
1065
1111
  /**
1066
1112
  * Cookie 类
1067
1113
  */
@@ -1099,7 +1145,6 @@ declare class Cookie {
1099
1145
  * @see RFC 6265
1100
1146
  */
1101
1147
  declare const normalizeDomain: (domain?: string) => string;
1102
- declare const getCookieScopeDomain: (domain?: string) => string[];
1103
1148
  interface UrlInfo {
1104
1149
  domain: string;
1105
1150
  path: string;
@@ -1746,4 +1791,4 @@ declare const getRichTextNodes: (content: string | AnyNode[], { appendClass, tra
1746
1791
 
1747
1792
  declare const getText: (content: string | AnyNode[]) => string;
1748
1793
 
1749
- export { $App, $Component, $Config, $Page, ALLOWED_TAGS, type AllowTag, type AppConfig, type AppConstructor, type AppInstance, type AppOptions, type ComponentConstructor, type ComponentInstance, type ComponentLifetimes, type ComponentOptions, 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 ExtendsAppOptions, type Handler, Headers, type HeadersInit, type PageConstructor, type PageInstance, type PageOptions, type PageQuery, type PageState, type PropType, Queue, type RefMap, type RequestBody, type RequestError, type RequestFactory, type RequestInitOptions, type RequestOptions, type RequestResponse, type RequestType, type RichTextNode, type SetCookieOptions, type StorageData, type Task, type TextNode, type TrivialComponentInstance, type TrivialComponentOptions, type TrivialPageInstance, type TrivialPageOptions, URLSearchParams, type UrlInfo, type WildCardEventHandlerList, type WildcardHandler, check, checkAsync, createRequest, decode as decodeBase64, dirname, userEmitter as emitter, encode as encodeBase64, exists, funcQueue, get, getAsync, getCookieOptions, getCookieScopeDomain, getDomain, getRichTextNodes, getText, isDir, isFile, isMp, isQQ, isWx, lock, logger, ls, mkdir, normalizeDomain, once, parseCookieHeader, parseHTML, parseUrl, put, query, readFile, readJSON, remove, removeAsync, request, requestCookieStore, rm, saveFile, saveOnlineFile, set, setAsync, storage, take, type, unzip, wrapFunction, writeFile, writeJSON };
1794
+ 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 RequestError, 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, getCookieOptions, getCookieScopeDomain, getDomain, getRef, getRichTextNodes, getText, 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
@@ -97,6 +97,7 @@ declare namespace query {
97
97
  * @returns 对象的类型
98
98
  */
99
99
  declare const type: (obj: unknown) => string;
100
+ declare const isFunction: <T extends Function>(obj: unknown) => obj is T;
100
101
 
101
102
  /**
102
103
  * 包装函数,先执行 wrapper ,然后执行原函数
@@ -232,6 +233,7 @@ type PropMethod<Type, TypeConstructor = any> = Type extends (...args: any) => an
232
233
  } : never;
233
234
  type PropConstructor<Type = any> = (new (...args: any[]) => Type & {}) | (() => Type) | PropMethod<Type>;
234
235
  type PropType<T> = PropConstructor<T> | PropConstructor<T>[];
236
+ 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;
235
237
  type RequiredKeys<T> = {
236
238
  [K in keyof T]: T[K] extends {
237
239
  required: true;
@@ -357,21 +359,22 @@ interface ExtendedComponentMethods extends InstanceEmitterMethods {
357
359
  */
358
360
  _$attached(parent: TrivialComponentInstance | TrivialPageInstance): void;
359
361
  }
360
- type ComponentInstance<Data extends WechatMiniprogram.Component.DataOption, Property extends PropsOptions, Method extends Partial<WechatMiniprogram.Component.MethodOption>, CustomInstanceProperty extends WechatMiniprogram.IAnyObject = {}, IsPage extends boolean = false> = WechatMiniprogram.Component.InstanceProperties & WechatMiniprogram.Component.InstanceMethods<Data> & ExtendedComponentMethods & Method & (IsPage extends true ? WechatMiniprogram.Page.ILifetime : {}) & CustomInstanceProperty & ExtendedComponentProperty & ExtendedPageMethods<Data & InferPropTypes<Property>, CustomInstanceProperty & Method & (IsPage extends true ? WechatMiniprogram.Page.ILifetime : {})> & {
362
+ type ComponentInstance<Data extends WechatMiniprogram.Component.DataOption, Props extends PropsOptions, Method extends Partial<WechatMiniprogram.Component.MethodOption>, InstanceProps extends WechatMiniprogram.IAnyObject = {}, IsPage extends boolean = false> = WechatMiniprogram.Component.InstanceProperties & WechatMiniprogram.Component.InstanceMethods<Data> & ExtendedComponentMethods & Method & (IsPage extends true ? WechatMiniprogram.Page.ILifetime : {}) & InstanceProps & ExtendedComponentProperty & ExtendedPageMethods<Data & InferPropTypes<Props>, InstanceProps & Method & (IsPage extends true ? WechatMiniprogram.Page.ILifetime : {})> & {
361
363
  /** 组件数据,**包括内部数据和属性值** */
362
- data: Data & InferPropTypes<Property>;
364
+ data: Data & InferPropTypes<Props>;
363
365
  /** 组件数据,**包括内部数据和属性值**(与 `data` 一致) */
364
- properties: Data & InferPropTypes<Property>;
366
+ properties: Data & InferPropTypes<Props>;
365
367
  };
366
- type ComponentOptions<Data extends WechatMiniprogram.Component.DataOption, Property extends PropsOptions, Method extends WechatMiniprogram.Component.MethodOption, CustomInstanceProperty extends WechatMiniprogram.IAnyObject = {}, IsPage extends boolean = false> = Partial<WechatMiniprogram.Component.Data<Data>> & Partial<{
368
+ type ComponentOptions<Data extends WechatMiniprogram.Component.DataOption, Props extends PropsOptions, Method extends WechatMiniprogram.Component.MethodOption, InstanceProps extends WechatMiniprogram.IAnyObject = {}, IsPage extends boolean = false> = Partial<WechatMiniprogram.Component.Data<Data>> & Partial<{
367
369
  /** 组件属性 */
368
- properties: Property;
369
- }> & Partial<WechatMiniprogram.Component.Method<Method, IsPage>> & Partial<WechatMiniprogram.Component.OtherOption> & Partial<ComponentLifetimes> & ThisType<ComponentInstance<Data, Property, Method, CustomInstanceProperty, IsPage>>;
370
- type ComponentConstructor = <Data extends WechatMiniprogram.Component.DataOption, Property extends PropsOptions, Method extends WechatMiniprogram.Component.MethodOption, CustomInstanceProperty extends WechatMiniprogram.IAnyObject = {}, IsPage extends boolean = false>(options: ComponentOptions<Data, Property, Method, CustomInstanceProperty, IsPage>) => string;
370
+ props: Props;
371
+ }> & 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 = {}, IsPage extends boolean = false>(options: ComponentOptions<Data, Props, Method, InstanceProps, IsPage>) => string;
371
373
  type TrivialComponentInstance = ComponentInstance<WechatMiniprogram.IAnyObject, Record<string, null>, Record<string, (...args: unknown[]) => any>>;
372
374
  type TrivialComponentOptions = ComponentInstance<WechatMiniprogram.IAnyObject, Record<string, null>, Record<string, (...args: any[]) => any>>;
373
375
  type RefMap = Record<string, TrivialComponentInstance>;
374
376
 
377
+ declare const handleProperties: (oldProps?: PropsOptions) => WechatMiniprogram.Component.PropertyOption;
375
378
  /**
376
379
  * 组件注册器
377
380
  *
@@ -379,6 +382,10 @@ type RefMap = Record<string, TrivialComponentInstance>;
379
382
  */
380
383
  declare const $Component: ComponentConstructor;
381
384
 
385
+ declare const getRef: (id: number) => TrivialComponentInstance;
386
+ declare const setRef: (id: number, value: TrivialComponentInstance) => void;
387
+ declare const removeRef: (id: number) => void;
388
+
382
389
  declare function bind(this: TrivialComponentInstance, touchEvent: WechatMiniprogram.Touch<{
383
390
  id: number;
384
391
  event: string;
@@ -732,6 +739,14 @@ type AppOptions<Custom> = ExtendsAppOptions & Partial<WechatMiniprogram.App.Opti
732
739
  type AppInstance<Custom> = AppOptions<Custom> & Custom & ExtendedAppMethods;
733
740
  type AppConstructor = <Custom extends WechatMiniprogram.IAnyObject>(appOptions: AppOptions<Custom>) => void;
734
741
 
742
+ declare const appState: {
743
+ /** 是否已启动 */
744
+ launch: boolean;
745
+ /** 启动参数 */
746
+ lOpt: {};
747
+ /** 切入后台时的时间戳 */
748
+ hide: number;
749
+ };
735
750
  /**
736
751
  * Application wrapper
737
752
  *
@@ -739,18 +754,59 @@ type AppConstructor = <Custom extends WechatMiniprogram.IAnyObject>(appOptions:
739
754
  */
740
755
  declare const $App: AppConstructor;
741
756
 
742
- interface AppConfig {
757
+ interface AppConfigCommonOptions {
743
758
  /**
744
- * 当你给出的页面路径或简称无法通过 routeMap 解析时,会回退到此路径
759
+ * 主页页面名称或路径
760
+ */
761
+ home?: string;
762
+ /**
763
+ * 跳转延迟执行的最长时间,单位 ms
745
764
  *
746
- * 填入小程序路径模式,小程序路径模式是一个路径字符串,用 `$name` 表示小程序简称的位置
765
+ * @description 异步 onNavigate 方法用时过久会直接调转
747
766
  *
748
- * 例子: 你可以填入 `/pages/$name/$name` 来表达:
767
+ * @default 200
768
+ */
769
+ maxDelay?: number;
770
+ /**
771
+ * 允许进行跳转据页面首屏渲染后的最小间隔时间,单位 ms
749
772
  *
750
- * - `main': '/pages/main/main`
751
- * - `user': '/pages/user/user`
773
+ * @default 100
752
774
  */
753
- defaultRoute: string;
775
+ minInterval?: number;
776
+ /**
777
+ * 自定义扩展组件
778
+ *
779
+ * 时机在框架执行扩展之前,可为每个组件挂载实例方法
780
+ *
781
+ * @param options 组件选项
782
+ */
783
+ extendComponent?(options: TrivialComponentOptions): void;
784
+ /**
785
+ * 自定义注入组件
786
+ *
787
+ * 时机在框架执行扩展之后,这意味着你可以覆盖框架的方法
788
+ *
789
+ * @param options 组件选项
790
+ */
791
+ injectComponent?(options: TrivialComponentOptions): void;
792
+ /**
793
+ * 自定义扩展页面,在框架执行扩展之前
794
+ *
795
+ * @param name 页面名称
796
+ * @param options 页面选项
797
+ */
798
+ extendPage?(name: string, options: TrivialPageOptions): void;
799
+ /**
800
+ * 自定义注入页面
801
+ *
802
+ * 在框架执行扩展之后,这意味着你可以覆盖框架的方法
803
+ *
804
+ * @param name 页面名称
805
+ * @param options 页面选项
806
+ */
807
+ injectPage?(name: string, options: TrivialPageOptions): void;
808
+ }
809
+ interface RoutePathConfig {
754
810
  /**
755
811
  * 你可以直接以对象形式表示简称到路径的映射。如:
756
812
  *
@@ -798,58 +854,47 @@ interface AppConfig {
798
854
  */
799
855
  routes?: Record<string, string> | [string | string[], string][];
800
856
  /**
801
- * 主页页面名称或路径
802
- */
803
- home?: string;
804
- /**
805
- * 跳转延迟执行的最长时间,单位 ms
857
+ * 当你给出的页面路径或简称无法通过 routeMap 解析时,会回退到此路径
806
858
  *
807
- * @description 异步 onNavigate 方法用时过久会直接调转
859
+ * 填入小程序路径模式,小程序路径模式是一个路径字符串,用 `$name` 表示小程序简称的位置
808
860
  *
809
- * @default 200
810
- */
811
- maxDelay?: number;
812
- /**
813
- * 允许进行跳转据页面首屏渲染后的最小间隔时间,单位 ms
861
+ * 例子: 你可以填入 `/pages/$name/$name` 来表达:
814
862
  *
815
- * @default 100
863
+ * - `main': '/pages/main/main`
864
+ * - `user': '/pages/user/user`
816
865
  */
817
- minInterval?: number;
866
+ defaultRoute: string;
867
+ }
868
+ interface RouteCustomConfig {
818
869
  /**
819
- * 自定义扩展组件
820
- *
821
- * 时机在框架执行扩展之前,可为每个组件挂载实例方法
870
+ * 获得页面简称
822
871
  *
823
- * @param options 组件选项
872
+ * @param url 页面路径
873
+ * @returns 页面名称
824
874
  */
825
- extendComponent?(options: TrivialComponentOptions): void;
875
+ getName: (url: string) => string;
826
876
  /**
827
- * 自定义注入组件
828
- *
829
- * 时机在框架执行扩展之后,这意味着你可以覆盖框架的方法
877
+ * 获得页面路径
830
878
  *
831
- * @param options 组件选项
879
+ * @param pageName 页面简称
880
+ * @returns 页面路径
832
881
  */
833
- injectComponent?(options: TrivialComponentOptions): void;
882
+ getRoute: (pageName: string) => string;
883
+ }
884
+ type AppConfigOptions = AppConfigCommonOptions & (RoutePathConfig | RouteCustomConfig);
885
+
886
+ interface Config extends Omit<AppConfigOptions, "defaultRoute" | "routeMap"> {
834
887
  /**
835
- * 自定义扩展页面,在框架执行扩展之前
836
- *
837
- * @param name 页面名称
838
- * @param options 页面选项
888
+ * @returns name
839
889
  */
840
- extendPage?(name: string, options: TrivialPageOptions): void;
890
+ getName: (url: string) => string;
841
891
  /**
842
- * 自定义注入页面
843
- *
844
- * 在框架执行扩展之后,这意味着你可以覆盖框架的方法
845
- *
846
- * @param name 页面名称
847
- * @param options 页面选项
892
+ * @returns route
848
893
  */
849
- injectPage?(name: string, options: TrivialPageOptions): void;
894
+ getRoute: (pageName: string) => string;
850
895
  }
851
-
852
- declare const $Config: (config: AppConfig) => void;
896
+ declare const $Config: (config: AppConfigOptions) => void;
897
+ declare const getConfig: () => Config;
853
898
 
854
899
  /** 文件编码 */
855
900
  type FileEncoding = "utf-8" | "ascii" | "base64" | "binary" | "hex" | "ucs2" | "ucs-2" | "utf16le" | "utf-16le" | "utf8" | "latin1";
@@ -1059,9 +1104,10 @@ interface CookieType {
1059
1104
  /**
1060
1105
  * indicates a cookie ought not to be sent along with cross-site requests
1061
1106
  */
1062
- sameSite?: string | undefined;
1107
+ sameSite?: boolean | "lax" | "strict" | "none" | undefined;
1063
1108
  }
1064
1109
 
1110
+ declare const getCookieScopeDomain: (domain?: string) => string[];
1065
1111
  /**
1066
1112
  * Cookie 类
1067
1113
  */
@@ -1099,7 +1145,6 @@ declare class Cookie {
1099
1145
  * @see RFC 6265
1100
1146
  */
1101
1147
  declare const normalizeDomain: (domain?: string) => string;
1102
- declare const getCookieScopeDomain: (domain?: string) => string[];
1103
1148
  interface UrlInfo {
1104
1149
  domain: string;
1105
1150
  path: string;
@@ -1746,4 +1791,4 @@ declare const getRichTextNodes: (content: string | AnyNode[], { appendClass, tra
1746
1791
 
1747
1792
  declare const getText: (content: string | AnyNode[]) => string;
1748
1793
 
1749
- export { $App, $Component, $Config, $Page, ALLOWED_TAGS, type AllowTag, type AppConfig, type AppConstructor, type AppInstance, type AppOptions, type ComponentConstructor, type ComponentInstance, type ComponentLifetimes, type ComponentOptions, 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 ExtendsAppOptions, type Handler, Headers, type HeadersInit, type PageConstructor, type PageInstance, type PageOptions, type PageQuery, type PageState, type PropType, Queue, type RefMap, type RequestBody, type RequestError, type RequestFactory, type RequestInitOptions, type RequestOptions, type RequestResponse, type RequestType, type RichTextNode, type SetCookieOptions, type StorageData, type Task, type TextNode, type TrivialComponentInstance, type TrivialComponentOptions, type TrivialPageInstance, type TrivialPageOptions, URLSearchParams, type UrlInfo, type WildCardEventHandlerList, type WildcardHandler, check, checkAsync, createRequest, decode as decodeBase64, dirname, userEmitter as emitter, encode as encodeBase64, exists, funcQueue, get, getAsync, getCookieOptions, getCookieScopeDomain, getDomain, getRichTextNodes, getText, isDir, isFile, isMp, isQQ, isWx, lock, logger, ls, mkdir, normalizeDomain, once, parseCookieHeader, parseHTML, parseUrl, put, query, readFile, readJSON, remove, removeAsync, request, requestCookieStore, rm, saveFile, saveOnlineFile, set, setAsync, storage, take, type, unzip, wrapFunction, writeFile, writeJSON };
1794
+ 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 RequestError, 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, getCookieOptions, getCookieScopeDomain, getDomain, getRef, getRichTextNodes, getText, 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 };