ewm
Version:
小程序原生插件
1,201 lines (1,143 loc) • 70.2 kB
TypeScript
import { IReactionDisposer } from 'mobx';
/**
* 纯对象 不是函数或数组的对象
* @bug 接口类型对象不能继承PureObject
* ```ts
* interface User {name:string}
* type test = User extends PureObject ? 1 : 0 // ==> 0
* ```
* @template
* ```ts
* type test0 = string extends PureObject ? 1 : 0; // => 0
* type test1 = `${number}px` extends PureObject ? 1 : 0; // => 0
* type test2 = `100` extends PureObject ? 1 : 0; // => 0
* type test3 = `${number}px` extends PureObject ? 1 : 0; // => 0
* type test4 = boolean extends PureObject ? 1 : 0; // => 0
* type test5 = unknown[] extends PureObject ? 1 : 0; // => 0
* type test6 = ((...arg: unknown[]) => void) extends PureObject ? 1 : 0; // => 0
* type test7 = bigint extends PureObject ? 1 : 0; // => 0
* type test8 = symbol extends PureObject ? 1 : 0; // => 0
* type test9 = { name: "zhao" } extends PureObject ? 1 : 0; // => 1
* ```
*/
type PureObject = Record<PropertyKey, unknown>;
declare type WMTriggerEventOption = WechatMiniprogram.Component.TriggerEventOption;
declare type WMBaseEvent<Mark = object, CurrentTargetDataset = object, TargetDataset = CurrentTargetDataset> = WechatMiniprogram.BaseEvent<Mark, CurrentTargetDataset, TargetDataset>;
declare type WMCustomEvent<Detail = object, Mark = object, CurrentTargetDataset = object, TargetDataset = CurrentTargetDataset> = WechatMiniprogram.CustomEvent<Detail, Mark, CurrentTargetDataset, TargetDataset>;
declare type WMPageLifetimesShow = WechatMiniprogram.Component.PageLifetimes["show"];
declare type WMPageLifetimesHide = WechatMiniprogram.Component.PageLifetimes["hide"];
declare type WMPageLifetimesResize = WechatMiniprogram.Component.PageLifetimes["resize"];
declare type WMInstanceProperties = WechatMiniprogram.Component.InstanceProperties;
declare type WMInstanceMethods<T> = WechatMiniprogram.Component.InstanceMethods<T>;
declare type WMCompLifetimes = WechatMiniprogram.Component.Lifetimes;
declare type WMCompOtherOption = WechatMiniprogram.Component.OtherOption;
declare type WMPageLifetime = WechatMiniprogram.Page.ILifetime;
declare type WMComponentOption = WechatMiniprogram.Component.ComponentOptions;
/**
* Check whether `A1` is equal to `A2` or not.
* @param A1
* @param A2
* @returns [[Boolean]]
* @example
* ```ts
* import {A} from 'ts-toolbelt'
*
* type test0 = A.Equals<42 | 0, 42 | 0> // true
* type test1 = A.Equals<{a: string}, {b: string}> // false
* type test3 = A.Equals<{a: string}, {readonly a: string}> // false
* ```
*/
declare type Equals<A1 , A2 > = (<A>() => A extends A2 ? 1 : 0) extends (<A>() => A extends A1 ? 1 : 0) ? 1 : 0;
/**
* T 若与 TCompare 类型相同 返回Then 否则返回Else
* @param T
* @param TCompare (可以是联合类型)
* @return Then or Else
* @test
* ```ts
import { Test } from "./src/TypeTools";
const { checks, check } = Test
checks([
check<IfEquals<never, never>, unknown, Test.Pass>(),
check<IfEquals<unknown, unknown>, unknown, Test.Pass>(),
check<IfEquals<{}, {}>, unknown, Test.Pass>(),
check<IfEquals<{}, never, 1, 2>, 2, Test.Pass>(),
check<IfEquals<never[], never[] >, unknown, Test.Pass>(),
check<IfEquals<[], [] , 1>, 1, Test.Pass>(),
])
* ```
*/
declare type IfEquals<T, TCompare, Then = unknown, Else = T> = Equals<T, TCompare> extends 1 ? Then
: Else;
declare type InjectMethodsConstraint = Record<string, AnyFunction>;
declare abstract class IInject {
options?: WMComponentOption;
methods?: InjectMethodsConstraint;
data?: DataConstraint;
}
declare class InstanceInject extends IInject {
private static _injectOption;
static get InjectOption(): IInject;
static set InjectOption(options: IInject);
}
declare type IinjectMethods = IfEquals<NonNullable<InstanceInject["methods"]>, InjectMethodsConstraint, unknown, IfEquals<InstanceInject["methods"], {}>>;
declare type IinjectData = IfEquals<NonNullable<InstanceInject["data"]>, DataConstraint>;
declare enum EInternalKey {
urlData = "miss_annil",
defUrl = "/xx&xx"
}
declare function auxEvent<T extends IPageDoc[] | IPageDoc>(opt: DefineEmitEvent<T>): DefineEmitEvent<T>;
declare type Boolean = 0 | 1;
declare type If<B extends Boolean, Then, Else = never> = B extends 1 ? Then : Else;
declare type IsNever<T> = [T] extends [never] ? 1 : 0;
declare type IsUnion<T, O = T> = If<
IsNever<T>,
0,
O extends T ? ([T] extends [O] ? 0 : 1) : never
>;
/**
* Describes index keys for any type
*/
declare type Key = string | number | symbol;
/**
* A [[List]]
* @param A its type
* @returns [[List]]
* @example
* ```ts
* type list0 = [1, 2, 3]
* type list1 = number[]
* ```
*/
declare type List<A = any> = ReadonlyArray<A>;
/**
* Ask TS to re-check that `A1` extends `A2`.
* And if it fails, `A2` will be enforced anyway.
* Can also be used to add constraints on parameters.
* @param A1 to check against
* @param A2 to cast to
* @returns `A1 | A2`
* @example
* ```ts
* import {A} from 'ts-toolbelt'
*
* type test0 = A.Cast<'42', string> // '42'
* type test1 = A.Cast<'42', number> // number
* ```
*/
declare type Cast<A1 , A2 > = A1 extends A2 ? A1 : A2;
/**
* Check whether `A1` is part of `A2` or not. The difference with
* `extends` is that it forces a [[Boolean]] return.
* @param A1
* @param A2
* @returns [[Boolean]]
* @example
* ```ts
* import {A} from 'ts-toolbelt'
*
* type test0 = A.Extends<'a' | 'b', 'b'> // Boolean
* type test1 = A.Extends<'a', 'a' | 'b'> // True
*
* type test2 = A.Extends<{a: string}, {a: any}> // True
* type test3 = A.Extends<{a: any}, {a: any, b: any}> // False
*
* type test4 = A.Extends<never, never> // False
* /// Nothing cannot extend nothing, use `A.Equals`
* ```
*/
declare type Extends<A1 , A2 > = [
A1
] extends [never] ? 0 : A1 extends A2 ? 1 : 0;
/**
* Check whether `A1` is part of `A2` or not. It works like
* [[Extends]] but [[Boolean]] results are narrowed to [[False]].
* @param A1
* @param A2
* @returns [[Boolean]]
* @example
* ```ts
* type test0 = A.Contains<'a' | 'b', 'b'> // False
* type test1 = A.Contains<'a', 'a' | 'b'> // True
*
* type test2 = A.Contains<{a: string}, {a: string, b: number}> // False
* type test3 = A.Contains<{a: string, b: number}, {a: string}> // True
*
* type test4 = A.Contains<never, never> // False
* /// Nothing cannot contain nothing, use `A.Equals`
* ```
*/
declare type Contains<A1 , A2 > = Extends<A1, A2> extends 1 ? 1 : 0;
/**
* Describes the match strategy when matching types
* * `default` : `extends->`
* * `contains->` : X contains Y ([[Contains]]<X, Y>)
* * `extends->` : X extends Y ([[Extends]]<X, Y>)
* * `<-contains` : Y contains X ([[Contains]]<Y, X>)
* * `<-extends` : Y extends X ([[Extends]]<Y, X>)
* * `equals` : X equals Y (([[Equals]]<X, Y>))
*/
declare type Match = 'default' | 'contains->' | 'extends->' | '<-contains' | '<-extends' | 'equals';
/**
* Check whether `A` is similar to `A1` or not. In other words, it is a compact
* type that bundles [[Equals]], [[Extends]], [[Contains]], comparison types.
* @param A to be compared
* @param A1 to compare to
* @param match (?=`'default'`) to change precision
* @returns [[Boolean]]
* @example
* ```ts
* import {A} from 'ts-toolbelt'
*
* type test0 = A.Is<'a', 'a' | 'b', 'extends->'> // True
* type test1 = A.Is<'a' | 'b', 'a', 'extends->'> // Boolean
*
* type test2 = A.Is<'a', 'a' | 'b', '<-extends'> // Boolean
* type test3 = A.Is<'a' | 'b', 'a', '<-extends'> // True
*
* type test4 = A.Is<'a', 'a' | 'b', 'contains->'> // True
* type test5 = A.Is<'a' | 'b', 'a', 'contains->'> // False
*
* type test6 = A.Is<'a', 'a' | 'b', '<-contains'> // False
* type test7 = A.Is<'a' | 'b', 'a', '<-contains'> // True
*
* type test8 = A.Is<'a', 'a' | 'b', 'equals'> // False
* type test9 = A.Is<'b' |'a', 'a' | 'b', 'equals'> // True
* ```
*/
declare type Is<A , A1 , match extends Match = 'default'> = {
'default': Extends<A, A1>;
'contains->': Contains<A, A1>;
'extends->': Extends<A, A1>;
'<-contains': Contains<A1, A>;
'<-extends': Extends<A1, A>;
'equals': Equals<A1, A>;
}[match];
/**
* An entry of `IterationMap`
*/
declare type Iteration = [
value: number,
sign: '-' | '0' | '+',
prev: keyof IterationMap,
next: keyof IterationMap,
oppo: keyof IterationMap
];
declare type IterationMap = {
'__': [number, '-' | '0' | '+', '__', '__', '__'];
'-100': [-100, '-', '__', '-99', '100'];
'-99': [-99, '-', '-100', '-98', '99'];
'-98': [-98, '-', '-99', '-97', '98'];
'-97': [-97, '-', '-98', '-96', '97'];
'-96': [-96, '-', '-97', '-95', '96'];
'-95': [-95, '-', '-96', '-94', '95'];
'-94': [-94, '-', '-95', '-93', '94'];
'-93': [-93, '-', '-94', '-92', '93'];
'-92': [-92, '-', '-93', '-91', '92'];
'-91': [-91, '-', '-92', '-90', '91'];
'-90': [-90, '-', '-91', '-89', '90'];
'-89': [-89, '-', '-90', '-88', '89'];
'-88': [-88, '-', '-89', '-87', '88'];
'-87': [-87, '-', '-88', '-86', '87'];
'-86': [-86, '-', '-87', '-85', '86'];
'-85': [-85, '-', '-86', '-84', '85'];
'-84': [-84, '-', '-85', '-83', '84'];
'-83': [-83, '-', '-84', '-82', '83'];
'-82': [-82, '-', '-83', '-81', '82'];
'-81': [-81, '-', '-82', '-80', '81'];
'-80': [-80, '-', '-81', '-79', '80'];
'-79': [-79, '-', '-80', '-78', '79'];
'-78': [-78, '-', '-79', '-77', '78'];
'-77': [-77, '-', '-78', '-76', '77'];
'-76': [-76, '-', '-77', '-75', '76'];
'-75': [-75, '-', '-76', '-74', '75'];
'-74': [-74, '-', '-75', '-73', '74'];
'-73': [-73, '-', '-74', '-72', '73'];
'-72': [-72, '-', '-73', '-71', '72'];
'-71': [-71, '-', '-72', '-70', '71'];
'-70': [-70, '-', '-71', '-69', '70'];
'-69': [-69, '-', '-70', '-68', '69'];
'-68': [-68, '-', '-69', '-67', '68'];
'-67': [-67, '-', '-68', '-66', '67'];
'-66': [-66, '-', '-67', '-65', '66'];
'-65': [-65, '-', '-66', '-64', '65'];
'-64': [-64, '-', '-65', '-63', '64'];
'-63': [-63, '-', '-64', '-62', '63'];
'-62': [-62, '-', '-63', '-61', '62'];
'-61': [-61, '-', '-62', '-60', '61'];
'-60': [-60, '-', '-61', '-59', '60'];
'-59': [-59, '-', '-60', '-58', '59'];
'-58': [-58, '-', '-59', '-57', '58'];
'-57': [-57, '-', '-58', '-56', '57'];
'-56': [-56, '-', '-57', '-55', '56'];
'-55': [-55, '-', '-56', '-54', '55'];
'-54': [-54, '-', '-55', '-53', '54'];
'-53': [-53, '-', '-54', '-52', '53'];
'-52': [-52, '-', '-53', '-51', '52'];
'-51': [-51, '-', '-52', '-50', '51'];
'-50': [-50, '-', '-51', '-49', '50'];
'-49': [-49, '-', '-50', '-48', '49'];
'-48': [-48, '-', '-49', '-47', '48'];
'-47': [-47, '-', '-48', '-46', '47'];
'-46': [-46, '-', '-47', '-45', '46'];
'-45': [-45, '-', '-46', '-44', '45'];
'-44': [-44, '-', '-45', '-43', '44'];
'-43': [-43, '-', '-44', '-42', '43'];
'-42': [-42, '-', '-43', '-41', '42'];
'-41': [-41, '-', '-42', '-40', '41'];
'-40': [-40, '-', '-41', '-39', '40'];
'-39': [-39, '-', '-40', '-38', '39'];
'-38': [-38, '-', '-39', '-37', '38'];
'-37': [-37, '-', '-38', '-36', '37'];
'-36': [-36, '-', '-37', '-35', '36'];
'-35': [-35, '-', '-36', '-34', '35'];
'-34': [-34, '-', '-35', '-33', '34'];
'-33': [-33, '-', '-34', '-32', '33'];
'-32': [-32, '-', '-33', '-31', '32'];
'-31': [-31, '-', '-32', '-30', '31'];
'-30': [-30, '-', '-31', '-29', '30'];
'-29': [-29, '-', '-30', '-28', '29'];
'-28': [-28, '-', '-29', '-27', '28'];
'-27': [-27, '-', '-28', '-26', '27'];
'-26': [-26, '-', '-27', '-25', '26'];
'-25': [-25, '-', '-26', '-24', '25'];
'-24': [-24, '-', '-25', '-23', '24'];
'-23': [-23, '-', '-24', '-22', '23'];
'-22': [-22, '-', '-23', '-21', '22'];
'-21': [-21, '-', '-22', '-20', '21'];
'-20': [-20, '-', '-21', '-19', '20'];
'-19': [-19, '-', '-20', '-18', '19'];
'-18': [-18, '-', '-19', '-17', '18'];
'-17': [-17, '-', '-18', '-16', '17'];
'-16': [-16, '-', '-17', '-15', '16'];
'-15': [-15, '-', '-16', '-14', '15'];
'-14': [-14, '-', '-15', '-13', '14'];
'-13': [-13, '-', '-14', '-12', '13'];
'-12': [-12, '-', '-13', '-11', '12'];
'-11': [-11, '-', '-12', '-10', '11'];
'-10': [-10, '-', '-11', '-9', '10'];
'-9': [-9, '-', '-10', '-8', '9'];
'-8': [-8, '-', '-9', '-7', '8'];
'-7': [-7, '-', '-8', '-6', '7'];
'-6': [-6, '-', '-7', '-5', '6'];
'-5': [-5, '-', '-6', '-4', '5'];
'-4': [-4, '-', '-5', '-3', '4'];
'-3': [-3, '-', '-4', '-2', '3'];
'-2': [-2, '-', '-3', '-1', '2'];
'-1': [-1, '-', '-2', '0', '1'];
'0': [0, '0', '-1', '1', '0'];
'1': [1, '+', '0', '2', '-1'];
'2': [2, '+', '1', '3', '-2'];
'3': [3, '+', '2', '4', '-3'];
'4': [4, '+', '3', '5', '-4'];
'5': [5, '+', '4', '6', '-5'];
'6': [6, '+', '5', '7', '-6'];
'7': [7, '+', '6', '8', '-7'];
'8': [8, '+', '7', '9', '-8'];
'9': [9, '+', '8', '10', '-9'];
'10': [10, '+', '9', '11', '-10'];
'11': [11, '+', '10', '12', '-11'];
'12': [12, '+', '11', '13', '-12'];
'13': [13, '+', '12', '14', '-13'];
'14': [14, '+', '13', '15', '-14'];
'15': [15, '+', '14', '16', '-15'];
'16': [16, '+', '15', '17', '-16'];
'17': [17, '+', '16', '18', '-17'];
'18': [18, '+', '17', '19', '-18'];
'19': [19, '+', '18', '20', '-19'];
'20': [20, '+', '19', '21', '-20'];
'21': [21, '+', '20', '22', '-21'];
'22': [22, '+', '21', '23', '-22'];
'23': [23, '+', '22', '24', '-23'];
'24': [24, '+', '23', '25', '-24'];
'25': [25, '+', '24', '26', '-25'];
'26': [26, '+', '25', '27', '-26'];
'27': [27, '+', '26', '28', '-27'];
'28': [28, '+', '27', '29', '-28'];
'29': [29, '+', '28', '30', '-29'];
'30': [30, '+', '29', '31', '-30'];
'31': [31, '+', '30', '32', '-31'];
'32': [32, '+', '31', '33', '-32'];
'33': [33, '+', '32', '34', '-33'];
'34': [34, '+', '33', '35', '-34'];
'35': [35, '+', '34', '36', '-35'];
'36': [36, '+', '35', '37', '-36'];
'37': [37, '+', '36', '38', '-37'];
'38': [38, '+', '37', '39', '-38'];
'39': [39, '+', '38', '40', '-39'];
'40': [40, '+', '39', '41', '-40'];
'41': [41, '+', '40', '42', '-41'];
'42': [42, '+', '41', '43', '-42'];
'43': [43, '+', '42', '44', '-43'];
'44': [44, '+', '43', '45', '-44'];
'45': [45, '+', '44', '46', '-45'];
'46': [46, '+', '45', '47', '-46'];
'47': [47, '+', '46', '48', '-47'];
'48': [48, '+', '47', '49', '-48'];
'49': [49, '+', '48', '50', '-49'];
'50': [50, '+', '49', '51', '-50'];
'51': [51, '+', '50', '52', '-51'];
'52': [52, '+', '51', '53', '-52'];
'53': [53, '+', '52', '54', '-53'];
'54': [54, '+', '53', '55', '-54'];
'55': [55, '+', '54', '56', '-55'];
'56': [56, '+', '55', '57', '-56'];
'57': [57, '+', '56', '58', '-57'];
'58': [58, '+', '57', '59', '-58'];
'59': [59, '+', '58', '60', '-59'];
'60': [60, '+', '59', '61', '-60'];
'61': [61, '+', '60', '62', '-61'];
'62': [62, '+', '61', '63', '-62'];
'63': [63, '+', '62', '64', '-63'];
'64': [64, '+', '63', '65', '-64'];
'65': [65, '+', '64', '66', '-65'];
'66': [66, '+', '65', '67', '-66'];
'67': [67, '+', '66', '68', '-67'];
'68': [68, '+', '67', '69', '-68'];
'69': [69, '+', '68', '70', '-69'];
'70': [70, '+', '69', '71', '-70'];
'71': [71, '+', '70', '72', '-71'];
'72': [72, '+', '71', '73', '-72'];
'73': [73, '+', '72', '74', '-73'];
'74': [74, '+', '73', '75', '-74'];
'75': [75, '+', '74', '76', '-75'];
'76': [76, '+', '75', '77', '-76'];
'77': [77, '+', '76', '78', '-77'];
'78': [78, '+', '77', '79', '-78'];
'79': [79, '+', '78', '80', '-79'];
'80': [80, '+', '79', '81', '-80'];
'81': [81, '+', '80', '82', '-81'];
'82': [82, '+', '81', '83', '-82'];
'83': [83, '+', '82', '84', '-83'];
'84': [84, '+', '83', '85', '-84'];
'85': [85, '+', '84', '86', '-85'];
'86': [86, '+', '85', '87', '-86'];
'87': [87, '+', '86', '88', '-87'];
'88': [88, '+', '87', '89', '-88'];
'89': [89, '+', '88', '90', '-89'];
'90': [90, '+', '89', '91', '-90'];
'91': [91, '+', '90', '92', '-91'];
'92': [92, '+', '91', '93', '-92'];
'93': [93, '+', '92', '94', '-93'];
'94': [94, '+', '93', '95', '-94'];
'95': [95, '+', '94', '96', '-95'];
'96': [96, '+', '95', '97', '-96'];
'97': [97, '+', '96', '98', '-97'];
'98': [98, '+', '97', '99', '-98'];
'99': [99, '+', '98', '100', '-99'];
'100': [100, '+', '99', '__', '-100'];
};
/**
* Move `I`'s position backwards
* @param I to move
* @returns [[Iteration]]
* @example
* ```ts
* import {I} from 'ts-toolbelt'
*
* type i = I.IterationOf<'20'>
*
* type test0 = I.Pos<i> // 20
* type test1 = I.Pos<I.Prev<i>> // 19
* ```
*/
declare type Prev<I extends Iteration> = IterationMap[I[2]];
/**
* Transform a number into an [[Iteration]]
* (to use [[Prev]], [[Next]], & [[Pos]])
* @param N to transform
* @returns [[Iteration]]
* @example
* ```ts
* import {I} from 'ts-toolbelt'
*
* type i = I.IterationOf<0> // ["-1", "1", "0", 0, "0"]
*
* type next = I.Next<i> // ["0", "2", "1", 1, "+"]
* type prev = I.Prev<i> // ["-2", "0", "-1", -1, "-"]
*
* type nnext = I.Pos<next> // +1
* type nprev = I.Pos<prev> // -1
* ```
*/
declare type IterationOf<N extends number> = `${N}` extends keyof IterationMap ? IterationMap[`${N}`] : IterationMap['__'];
/**
* Get the position of `I` (**number**)
* @param I to query
* @returns `number`
* @example
* ```ts
* import {I} from 'ts-toolbelt'
*
* type i = I.IterationOf<'20'>
*
* type test0 = I.Pos<i> // 20
* type test1 = I.Pos<I.Next<i>> // 21
* ```
*/
declare type Pos<I extends Iteration> = I[0];
/**
* Transform a [[Union]] to an * *intersection**
* @param U to transform
* @returns `&`
* @example
* ```ts
* ```
*/
declare type IntersectOf<U > = (U extends unknown ? (k: U) => void : never) extends ((k: infer I) => void) ? I : never;
/**
* Alias to create a [[Function]]
* @param P parameters
* @param R return type
* @returns [[Function]]
* @example
* ```ts
* import {F} from 'ts-toolbelt'
*
* type test0 = F.Function<[string, number], boolean>
* /// (args_0: string, args_1: number) => boolean
* ```
*/
declare type Function<P extends List = unknown[], R = any> = (...args: P) => R;
/**
* Get the length of `L`
* @param L to get length
* @returns [[String]] or `number`
* @example
* ```ts
* ```
*/
declare type Length<L extends List> = L['length'];
/**
* Remove `M` out of `U`
* @param U to remove from
* @param M to remove out
* @returns [[Union]]
* @example
* ```ts
* ```
*/
declare type Exclude$1<U , M > = U extends M ? never : U;
/**
* @hidden
*/
declare type __Pick<O extends object, K extends keyof O> = {
[P in K]: O[P];
} & {};
/**
* @hidden
*/
declare type _Pick<O extends object, K extends Key> = __Pick<O, keyof O & K>;
/**
* Extract out of `O` the fields of key `K`
* @param O to extract from
* @param K to chose fields
* @returns [[Object]]
* @example
* ```ts
* ```
*/
declare type Pick$1<O extends object, K extends Key> = O extends unknown ? _Pick<O, K> : never;
/**
* @hidden
*/
declare type _Omit<O extends object, K extends Key> = _Pick<O, Exclude$1<keyof O, K>>;
/**
* Remove the first item out of a [[List]]
* @param L
* @returns [[List]]
* @example
* ```ts
* ```
*/
declare type Tail<L extends List> = L extends readonly [] ? L : L extends readonly [any?, ...infer LTail] ? LTail : L;
/**
* Get the keys of `O` that are required
* @param O
* @returns [[Key]]
* @example
* ```ts
* ```
*/
declare type RequiredKeys<O extends object> = O extends unknown ? {
[K in keyof O]-?: {} extends Pick<O, K> ? never : K;
}[keyof O] : never;
/**
* Transform a [[List]] into an [[Object]] equivalent
* @param L to transform
* @returns [[Object]]
* @example
* ```ts
* ```
*/
declare type ObjectOf<O extends List> = O extends unknown ? number extends Length<O> ? _Pick<O, number> : _Omit<O, keyof any[]> : never;
/**
* Explain to TS which function parameter has priority for generic inference
* @param A to de-prioritize
* @returns `A`
* @example
* ```ts
* import {F} from 'ts-toolbelt'
*
* const fn0 = <A >(a0: A, a1: F.NoInfer<A>): A => {
* return {} as unknown as A // just for the example
* }
*
* const fn1 = <A >(a0: F.NoInfer<A>, a1: A): A => {
* return {} as unknown as A // just for the example
* }
*
* const fn2 = <A >(a0: F.NoInfer<A>, a1: F.NoInfer<A>): A => {
* return {} as unknown as A // just for the example
* }
*
* const test0 = fn0('b', 'a') // error: infer priority is `a0`
* const test1 = fn1('b', 'a') // error: infer priority is `a1`
* const test2 = fn2('b', 'a') // works: infer priority is `a0` | `a1`
* ```
* @see https://stackoverflow.com/questions/56687668
*/
declare type NoInfer<A = unknown> = [
A,
][A extends unknown ? 0 : never];
/**
* Update the fields of `O` with the ones of `O1`
* (only the existing fields will be updated)
* @param O to update
* @param O1 to update with
* @returns [[Object]]
* @example
* ```ts
* ```
*/
declare type Overwrite<O extends object, O1 extends object> = {
[K in keyof O]: K extends keyof O1 ? O1[K] : O[K];
} & {};
/** @ignore */ /** */
/**
* Remove `?` & `readonly` from a [[List]]
*/
declare type Naked<L extends List> = Overwrite<Required<L>, L>;
/**
* All primitive types
*/
declare type Primitive = boolean | string | number | bigint | symbol | undefined | null;
/**
* Add an element `A` at the beginning of `L`
* @param L to append to
* @param A to be added to
* @returns [[List]]
* @example
* ```ts
* ```
*/
declare type Prepend<L extends List, A > = [
A,
...L
];
/**
* Describes how to perform iterations
*/
declare type Way = '->' | '<-';
/**
* Add an element `A` at the end of `L`.
* @param L to append to
* @param A to be added to
* @returns [[List]]
* @example
* ```ts
* import {L} from 'ts-toolbelt'
*
* type test0 = L.Append<[1, 2, 3], 4> // [1, 2, 3, 4]
* type test1 = L.Append<[], 'a'> // ['a']
* type test2 = L.Append<readonly ['a', 'b'], 'c'> // ['a', 'b', 'c']
* type test3 = L.Append<[1, 2], [3, 4]> // [1, 2, [3, 4]]
* ```
*/
declare type Append<L extends List, A > = [
...L,
A
];
/**
* @hidden
*/
declare type _FilterKeys<O extends object, M , match extends Match> = {
[K in keyof O]-?: {
1: never;
0: K;
}[Is<O[K], M, match>];
}[keyof O];
/**
* Filter out the keys of `O` which fields match `M`
* @param O to remove from
* @param M to select fields
* @param match (?=`'default'`) to change precision
* @returns [[Key]]
* @example
* ```ts
* ```
*/
declare type FilterKeys<O extends object, M , match extends Match = 'default'> = O extends unknown ? _FilterKeys<O, M, match> : never;
/**
* Filter out of `O` the fields that match `M`
* @param O to remove from
* @param M to select fields
* @param match (?=`'default'`) to change precision
* @returns [[Object]]
* @example
* ```ts
* ```
*/
declare type Filter<O extends object, M , match extends Match = 'default'> = Pick$1<O, FilterKeys<O, M, match>>;
/**
* @hidden
*/
declare type _SelectKeys<O extends object, M , match extends Match> = {
[K in keyof O]-?: {
1: K;
0: never;
}[Is<O[K], M, match>];
}[keyof O];
/**
* Get the keys of `O` which fields match `M`
* @param O to extract from
* @param M to select fields
* @param match (?=`'default'`) to change precision
* @returns [[Key]]
* @example
* ```ts
* ```
*/
declare type SelectKeys$1<O extends object, M , match extends Match = 'default'> = O extends unknown ? _SelectKeys<O, M, match> : never;
declare type FuncReturnType<O extends object> = {
[k in keyof O]: O[k] extends Function ? ReturnType<O[k]> : O[k];
};
/**
* Extract the fields of `O` that match `M`
* @param O to extract from
* @param M to select fields
* @param match (?=`'default'`) to change precision
* @returns [[Object]]
* @example
* ```ts
* ```
*/
declare type Select<O extends object, M , match extends Match = 'default'> = Pick$1<O, SelectKeys$1<O, M, match>>;
declare type Literal$1 = string | number | bigint | boolean;
/**
* @hidden
*/
declare type _Join<T extends List, D extends string> = T extends [] ? '' : T extends [Literal$1] ? `${T[0]}` : T extends [Literal$1, ...infer R] ? `${T[0]}${D}${_Join<R, D>}` : string;
/**
* Concat many literals together
* @param T to concat
* @param D to delimit
*/
declare type Join<T extends List<Literal$1>, D extends string = ''> = _Join<T, D> extends infer X ? Cast<X, string> : never;
/**
* @hidden
*/
declare type DropForth<L extends List, N extends Iteration> = {
0: DropForth<Tail<L>, Prev<N>>;
1: L;
}[Extends<0, Pos<N>>];
/**
* @hidden
*/
declare type DropBack<L extends List, N extends Iteration, I extends Iteration = Prev<N>, LN extends List = []> = {
0: DropBack<L, N, Prev<I>, Prepend<LN, L[Pos<I>]>>;
1: LN;
}[Extends<-1, Pos<I>>];
/**
* @hidden
*/
declare type __Drop<L extends List, N extends Iteration, way extends Way> = {
'->': DropForth<L, N>;
'<-': DropBack<L, N>;
}[way];
/**
* @hidden
*/
declare type _Drop<L extends List, N extends number, way extends Way = '->'> = __Drop<Naked<L>, IterationOf<N>, way> extends infer X ? Cast<X, List> : never;
/**
* Remove `N` entries out of `L`
* @param L to remove from
* @param N to remove out
* @param way (?=`'->'`) from front: '->', from end: '<-'
* @returns [[List]]
* @example
* ```ts
* ```
*/
declare type Drop<L extends List, N extends number, way extends Way = '->'> = L extends unknown ? N extends unknown ? _Drop<L, N, way> : never : never;
/**
* 除去List中的never
* @example
* type test = RemoveNever<[1,never,2]>
* //=> test = [1,2]
*/
declare type RemoveNever<T extends unknown[]> = T extends [
infer A,
...infer B
]
? [A] extends [never]
? RemoveNever<B>
: [A, ...RemoveNever<B>]
: T;
/**
* Get the keys of `L` which entries match `M`
* @param L to extract from
* @param M to select entries
* @param match (?=`'default'`) to change precision
* @returns [[Key]]
* @example
* ```ts
* ```
*/
declare type SelectKeys<L extends List, M , match extends Match = 'default'> = SelectKeys$1<ObjectOf<L>, M, match>;
/**
* Get the last item within an [[Union]]
* (⚠️ it might not preserve order)
* @param U
* @returns [[Any]]
* @example
* ```ts
* ```
*/
declare type Last<U > = IntersectOf<U extends unknown ? (x: U) => void : never> extends (x: infer P) => void ? P : never;
/**
* @hidden
*/
declare type _ListOf<U, LN extends List = [], LastU = Last<U>> = {
0: _ListOf<Exclude$1<U, LastU>, Prepend<LN, LastU>>;
1: LN;
}[Extends<[U], [never]>];
/**
* Transform a [[Union]] into a [[List]]
* (⚠️ it might not preserve order)
* @param U to transform
* @returns [[List]]
* @example
* ```ts
* ```
*/
declare type ListOf<U > = _ListOf<U> extends infer X ? Cast<X, List> : never;
/**
* 提取联合类型中相同原始类型为数组的一项
* @example
* type test = ListOfSamePrimitive< 1 | 2 | "a" | "b" | { name: string } | { age: number } | string[] | number[]>
* //=> ["a" | "b", 1 | 2, string[] | number[], {name: string;} | {age: number;}]
*/
declare type ListOfSamePrimitive<U> = RemoveNever<
[
Extract<U, string>,
Extract<U, number>,
Extract<U, boolean>,
Extract<U, unknown[]>,
// Extract<U, PureObject>, 因为 PureObject 不能继承 接口类型的对象,所以改用下面的方式,
U extends unknown[] ? never : Extract<U, object>,
]
>;
declare type ResponseData<T = unknown> = T extends unknown ? () => T : never;
declare type AddResponseData<T extends object> = {
[k in keyof T]: ResponseData<T[k]> | T[k];
};
declare type Instance$2<TMethod, DataWithoutFunc, DataFuncReturn, DataFunc, PropertiesDoc, ComputedDoc, TMainMethods extends MainMethodsConstraint, DocProperties, InheritData, MainMethodsDoc = ExtractMainMethods<TMainMethods>> = ComputeObj<Omit<WMInstanceMethods<{}>, "setData"> & CusTomSetData<TransformTypetoProperties<DataWithoutFunc, DocProperties>> & {
_applySetData: (callBack?: AnyFunction) => void;
} & IfEquals<TMethod, {}> & IinjectMethods & {
[k in keyof MainMethodsDoc]: (data: MainMethodsDoc[k]) => void;
} & {
data: ComputeObj<DataFuncReturn & InheritData & Required<PropertiesDoc> & ComputedDoc & IfEquals<IinjectData, unknown, unknown, FuncReturnType<IinjectData & {}>>>;
} & IfEquals<DataFunc, unknown, unknown, {
_disposer: {
[k in keyof DataFunc]: IReactionDisposer;
};
}>>;
declare type Options$2<TComponentDoc extends IComponentDoc, TProperties, TData extends PureObject, TComputed extends ComputedConstraint<TPrefix>, TMethod extends MethodsConstraint, TMethodsCalledbyMain extends MethodsCalledbyMainConstraint, TInherit extends object, TMainMethods extends MainMethodsConstraint, TPrefix extends string, PropertiesDoc, DataFuncReturn, DataWithoutFunc, DataFunc, ComputedDoc, InheritDoc, DocCustomEvents, AllMainData, MethodsDoc = IfEquals<TMethod, {}>, DataDoc = GetDataDoc<TData, {}>, MainMethods = IfEquals<TMainMethods, {}>, MethodsCalledbyMain = IfEquals<TMethodsCalledbyMain, {}>, EventsRepeatCheck = ComputeObj<MethodsDoc & MainMethods & MethodsCalledbyMain>> = Partial<PropertiesOption<TProperties, TPrefix, TComponentDoc["properties"], AllMainData>> & Partial<DataOption<TData, PropertiesDoc & InheritDoc, TPrefix, TComponentDoc>> & InheritOption<TInherit, TComponentDoc["properties"], TPrefix> & ComputedOption<TComputed, PropertiesDoc & DataFuncReturn & InheritDoc & AllMainData, TPrefix, TComponentDoc> & Partial<MethodOption<TMethod, DocCustomEvents, TPrefix>> & MainMethodsOption<TMainMethods, DocCustomEvents & MethodsDoc, TPrefix> & MethodsCalledbyMainOption<TMethodsCalledbyMain, MethodsDoc & MainMethods & DocCustomEvents, TPrefix> & {
events?: ComputeObj<IfEquals<DocCustomEvents, unknown, BaseEvent<TPrefix>, ComputeObj<CustomEventDocToFunc<DocCustomEvents & {}>> & BaseEvent<TPrefix>> & IfEquals<EventsRepeatCheck, unknown, unknown, {
[k in keyof EventsRepeatCheck]?: () => "⚠️重复字段⚠️";
}>>;
} & Partial<Omit<WMCompOtherOption, "pageLifetimes" | "options" | "externalClasses" | "export">> & {
pageLifetimes?: Partial<CompPageLifetimes>;
} & Partial<WechatMiniprogram.Component.Lifetimes> & {
watch?: WatchConstraint<ComputeObj<TransformTypetoProperties<Required<PropertiesDoc> & ComputedDoc & DataDoc, Required<TComponentDoc["properties"]>> & GetInjectData<"onlyFuncType">>>;
} & ThisType<Instance$2<TMethod, DataWithoutFunc, DataFuncReturn, DataFunc, PropertiesDoc, ComputedDoc, TMainMethods, TComponentDoc["properties"], AllMainData>>;
interface Constructor$2<TMainData extends IMainDataDoc, TComponentDoc extends IComponentDoc, TPrefix extends string, AllMainData extends PureObject = ComputeObj<Required<TMainData["properties"]> & GetDataDoc<NonNullable<TMainData["data"]>, unknown> & TMainData["computed"] & GetInjectData> & {}, DocCustomEvents = TComponentDoc["customEvents"]> {
<Literal extends string | number | boolean | [Literal] | Literal[] | Record<string, Literal>, TInherit extends TInheritConstraint<AllMainData, TComponentDoc, TPrefix>, TProperties extends SubPropertiesConstraint<TComponentDoc, InheritDoc, Literal>, TData extends SubDataConstraint<TComponentDoc, InheritDoc & PropertiesDoc>, TComputed extends ComputedConstraint<TPrefix> = any, TMethod extends MethodsConstraint = {}, TMainMethods extends MainMethodsConstraint = {}, TMethodsCalledbyMain extends MethodsCalledbyMainConstraint = {}, InheritDoc = IfEquals<TInherit, TInheritConstraint<AllMainData, TComponentDoc, TPrefix>>, PropertiesDoc = GetPropertiesDoc<TProperties, SubPropertiesConstraint<TComponentDoc, InheritDoc, Literal>>, DataFuncReturn = GetDataDoc<TData, SubDataConstraint<TComponentDoc, InheritDoc & PropertiesDoc>, "函数类型变为函数返回类型">, DataWithoutFunc = GetDataDoc<TData, SubDataConstraint<TComponentDoc, InheritDoc & PropertiesDoc>, "去掉函数字段">, DataFunc = GetDataDoc<TData, SubDataConstraint<TComponentDoc, InheritDoc & PropertiesDoc>, "返回函数字段">, ComputedDoc = GetComputedDoc<TComputed, any>, AllData = ComputedDoc & DataFuncReturn & PropertiesDoc & InheritDoc>(options: Options$2<TComponentDoc, TProperties, TData, TComputed, TMethod, TMethodsCalledbyMain, TInherit, TMainMethods, TPrefix, PropertiesDoc, DataFuncReturn, DataWithoutFunc, DataFunc, ComputedDoc, InheritDoc, DocCustomEvents, AllMainData>): IfEquals<TComponentDoc, {}, CreateSubComponentDoc<PropertiesDoc, DocCustomEvents, TMethodsCalledbyMain, TMainMethods>, IfEquals<TComponentDoc["properties"], unknown, CreateSubComponentDoc<PropertiesDoc, DocCustomEvents, TMethodsCalledbyMain, TMainMethods>, RequiredKeys<NonNullable<TComponentDoc["properties"]>> extends keyof AllData ? CreateSubComponentDoc<PropertiesDoc, DocCustomEvents, TMethodsCalledbyMain, TMainMethods> : `${Exclude<RequiredKeys<NonNullable<TComponentDoc["properties"]>>, keyof AllData> & string}` extends infer R ? `缺少组件必传字段${Join<ListOf<R>, IfEquals<IsUnion<R>, 1, ",", "">>}` : never>>;
}
declare type CreateSubComponentDoc<PropertiesDoc, DocCustomEvents, TMethodsCalledbyMain extends MethodsCalledbyMainConstraint = {}, TMainMethods extends MainMethodsConstraint = {}, BubbleEvents = ComputeObj<ExtractSubDocCustomEventBubble<DocCustomEvents>>> = IfEquals<ComputeObj<IfEquals<PropertiesDoc, unknown, unknown, {
properties: PropertiesDoc;
}> & IfEquals<BubbleEvents, unknown, unknown, {
customEvents: BubbleEvents;
}> & IfEquals<TMainMethods, {}, unknown, {
mainMethods: ExtractMainMethods<TMainMethods>;
}> & IfEquals<TMethodsCalledbyMain, {}, unknown, {
methodsCalledByMain: TMethodsCalledbyMain;
}>>, unknown, never>;
declare function CreateSubComponent<TMainData extends IMainDataDoc, TComponentDoc extends IComponentDoc, TPrefix extends string = "">(): Constructor$2<TMainData, ConcatPrefix<TComponentDoc, TPrefix>, ExtractPrefix<TComponentDoc, TPrefix>>;
/**
* @param K 指定的key
* @param Type 指定的类型 默认never
* @returns 返回Key为k值为Type类型的对象
* @template
* ```ts
* type test0 = OverwirteKey<'name'|'age'>
* // type test0 = { name: never;age: never;}
* type test1 = OverwirteKey<never>
* // type test1 = unknown
* type test2 = OverwirteKey<'name','重复字段'>
* // type test2 = {name:'重复字段'}
* ```
*/
type OverwirteKey<K extends Key,Type = never > = IfEquals<
K,
never,
unknown,
{
[P in K]: Type;
}
>;
declare type AuxType<T = unknown> = {
new (...arg: unknown[]): T;
} | {
(): T;
};
declare type ShortProperties = AuxType;
declare type FullProperties<L = unknown> = {
type: AuxType;
value?: L;
optionalTypes?: AuxType[];
};
declare type AllProperties<L = unknown> = FullProperties<L> | ShortProperties;
declare type PropertiesConstraint<L = unknown> = Record<string, AllProperties<L>>;
declare type WXMLMark = "wxml";
declare type Prefix<O extends object, TPrefix extends string = "", TFront extends boolean = false> = IfEquals<TPrefix, "", O, IfEquals<TFront, false, {
[k in keyof O as k extends `${infer P}_${infer L}` ? `${P}${TPrefix}_${L}` : `${TPrefix}_${k & string}`]: O[k];
}, {
[k in keyof O as k extends `${infer P}_${infer L}` ? `${TPrefix}_${P}_${L}` : `${TPrefix}_${k & string}`]: O[k];
}>>;
declare type AnyFunction$1 = Function;
declare type CustomEventDoc = Record<string, _NoOptionsCustomEventDoc | _HasOptionsCustomEventDoc>;
declare type ExtractSubComponents<TSubComponents extends SubComponentConstraint, k extends keyof ISubComponentDoc, TConstraint = [], ReturnType = unknown, TVar extends ISubComponentDoc = TSubComponents[number]> = IfEquals<TSubComponents, TConstraint, ReturnType, ComputeObj<IntersectOf<TVar extends unknown ? unknown extends TVar[k] ? never : TVar[k] : never>>>;
declare type _ExtractSubCustomEvent<T, TTyped extends "composed" | ""> = IfEquals<{
[k in keyof T as IfEquals<TTyped, "composed", T[k] extends {
options: {
composed: true;
};
} ? k : never, k>]: T[k];
}, {}>;
declare type MethodsConstraint = {
[k: string]: AnyFunction$1;
};
declare type ExtractSubCustomEvents<TSubComponent extends SubComponentConstraint, TTyped extends "composed" | "" = ""> = IfEquals<ExtractSubComponents<TSubComponent, "customEvents">, unknown, unknown, _ExtractSubCustomEvent<ExtractSubComponents<TSubComponent, "customEvents">, TTyped>>;
declare type TransformTypetoProperties<O, P> = IfEquals<O, unknown, unknown, {
[k in keyof O]: k extends keyof P ? P[k] : O[k];
}>;
declare type CustomEventDocToFunc<TDoc extends object> = {
[k in keyof TDoc]?: TDoc[k] extends {
detailType: infer P;
options?: WMTriggerEventOption;
} ? (e: WMCustomEvent<P>) => void : (e: WMCustomEvent<TDoc[k]>) => void;
};
declare type CustomEventConstraint = Record<Key, {
detailType: AuxType | AuxType[];
options?: WMTriggerEventOption;
} | AuxType | AuxType[]>;
declare type MainMethodsConstraint = Record<string, AuxType | AuxType[]>;
declare type SubComponentOption<TSubComp extends SubComponentConstraint> = {
subComponent?: TSubComp;
};
declare type DefineEmitEvent<T extends IPageDoc[] | IPageDoc> = T extends IPageDoc[] ? {
[k in T[number]["path"]]?: {
[D in keyof T[SelectKeys<T, {
path: k;
}>]["publishEvents"]]: (data: T[SelectKeys<T, {
path: k;
}>]["publishEvents"][D]) => void;
};
} : T extends IPageDoc ? {
[k in T["path"]]: {
[d in keyof T["publishEvents"]]?: (data: T["publishEvents"][d]) => void;
};
} : never;
declare type DataConstraint = PureObject;
declare type PublishEventConstaint = {
[k in string]: AuxType | AuxType[];
};
declare type _NoOptionsCustomEventDoc = object | Primitive;
declare type _HasOptionsCustomEventDoc = {
detailType: object | Primitive;
options?: WMTriggerEventOption;
};
declare type MethodsDoc = {
[k: string]: AnyFunction$1;
};
interface MethodOption<M extends MethodsConstraint, TRepeated = unknown, TPrefix extends string = ""> {
methods?: M & ValidationRepeated<M, TRepeated> & ValidationInjectMethods<M> & ValidationPrefix<M, TPrefix>;
}
interface MethodsCalledbyMainOption<M extends MethodsCalledbyMainConstraint, TRepeated = unknown, TPrefix extends string = ""> {
methodsCalledByMain?: M & ValidationRepeated<M, TRepeated> & ValidationInjectMethods<M> & ValidationPrefix<M, TPrefix, "standard">;
}
interface CompPageLifetimes {
onShow: WMPageLifetimesShow;
onHide: WMPageLifetimesHide;
onResize: WMPageLifetimesResize;
}
declare type publishEventDoc = object;
declare type IPropertiesDoc = PureObject;
declare type IDataDoc = PureObject;
declare type IComputedDoc = PureObject;
interface IComponentDoc {
properties?: IPropertiesDoc;
customEvents?: CustomEventDoc;
}
interface IMainDataDoc {
properties?: IPropertiesDoc;
data?: IDataDoc;
computed?: IComputedDoc;
}
interface ISubComponentDoc {
properties?: PureObject;
customEvents?: CustomEventDoc;
methodsCalledByMain?: MethodsDoc;
mainMethods?: PureObject;
}
interface IPageDoc {
path: Path;
properties?: object;
publishEvents?: publishEventDoc;
}
declare type SubComponentConstraint = ISubComponentDoc[];
declare type Path = `/${string}`;
declare type ComputedConstraint<TPrefix extends string = ""> = IfEquals<TPrefix, "", Record<string, AnyFunction$1>, Record<`${TPrefix}_${string}`, AnyFunction$1>>;
declare type PropertiesRequiredField<T extends object> = {
[k in keyof T as T[k] extends ShortProperties | {
type: AuxType;
value?: never;
optionalTypes?: AuxType[];
} ? k : never]: T[k] extends ShortProperties ? InferAuxType<T[k]> : T[k] extends {
type: AuxType;
value?: never;
optionalTypes?: AuxType[];
} ? unknown extends T[k]["optionalTypes"] ? InferAuxType<T[k]["type"]> : InferAuxType<T[k]["type"] | NonNullable<T[k]["optionalTypes"]>[number]> : unknown;
};
declare type PropertitesOptionalField<T extends object> = {
[k in keyof T as T[k] extends {
type: AuxType;
value: unknown;
optionalTypes?: AuxType[];
} ? k : never]?: T[k] extends {
type: AuxType;
value: unknown;
optionalTypes?: AuxType[];
} ? unknown extends T[k]["optionalTypes"] ? InferAuxType<T[k]["type"]> : InferAuxType<T[k]["type"] | NonNullable<T[k]["optionalTypes"]>[number]> : unknown;
};
declare type GetDataDoc<TData extends DataConstraint, TConstraint, TType extends "去掉函数字段" | "返回函数字段" | "函数类型变为函数返回类型" = "函数类型变为函数返回类型", TReturn = unknown> = IfEquals<TData, TConstraint, TReturn, IfEquals<TData, {}, TReturn, ComputeObj<IfEquals<TType, "函数类型变为函数返回类型", FuncReturnType<TData>, IfEquals<TType, "去掉函数字段", Filter<TData, AnyFunction$1>, Select<TData, AnyFunction$1>>>>>>;
declare type UnknownToEmptyObj<T> = IfEquals<T, unknown, {}, T & object>;
declare type GetComputedDoc<TComputed extends Record<string, AnyFunction$1>, TConstraint, TReturn = unknown> = IfEquals<TComputed, TConstraint, TReturn, IfEquals<TComputed, {}, TReturn, {
[k in keyof TComputed]: ReturnType<TComputed[k]>;
}>>;
declare type GetInjectData<TCondition extends "FuncReturnType" | "onlyFuncType" = "FuncReturnType"> = IfEquals<IinjectData, unknown, unknown, IfEquals<TCondition, "FuncReturnType", {
[k in keyof IinjectData]: IinjectData[k] extends AnyFunction$1 ? ReturnType<IinjectData[k]> : IinjectData[k];
}, {
[k in keyof IinjectData as IinjectData[k] extends AnyFunction$1 ? k : never]: IinjectData[k] extends AnyFunction$1 ? ReturnType<IinjectData[k]> : never;
}>>;
declare type _OverWriteWatchValue<Keys, T> = {
[k in Keys as k extends `${string}.${string}.**` ? k : k extends `${string}.**` ? never : k extends `${string}.${string}` ? k : never]?: (newValue: k extends `${infer L}.${infer R}` | `${infer L}.${infer R}.**` ? L extends keyof T ? R extends keyof T[L] ? T[L][R] : never : never : never, oldValue: k extends `${infer L}.${infer R}` | `${infer L}.${infer R}.**` ? L extends keyof T ? R extends keyof T[L] ? T[L][R] : never : never : never) => void;
};
declare type WatchConstraint<TAllData, StandardWatch = _StandardWatch<TAllData>> = IfEquals<TAllData, unknown, never, ComputeObj<StandardWatch & _OverWriteWatchValue<keyof StandardWatch, TAllData>>>;
declare type ObjFieldSecondFloor<T> = {
[k in keyof T]: T[k] extends object ? `${k & string}.**` : k;
}[keyof T];
declare type _StandardWatch<T> = ComputeObj<{
[k in keyof T as T[k] extends object ? never : k]?: (newValue: T[k], oldValue: T[k]) => void;
} & {
[k in keyof T as T[k] extends object ? `${k & string}.**` : never]?: (newValue: T[k], oldValue: T[k]) => void;
} & {
[k in keyof T as T[k] extends infer U ? U extends any[] ? never : U extends object ? `${k & string}.${ObjFieldSecondFloor<U> & string}` : never : never]?: unknown;
}>;
declare type _overWriteObjFields<Keys, T> = {
[k in Keys as k extends `${any}.${infer R}` ? (R extends "**" ? never : k) : never]: k extends `${infer L}.${infer R}` ? L extends keyof T ? R extends keyof T[L] ? T[L][R] : never : never : never;
};
declare type _SetDataField<T> = {
[k in keyof T]: T[k];
} & {
[k in keyof T as T[k] extends unknown[] ? never : T[k] extends object ? `${k & string}.${keyof T[k] & string}` : never]: unknown;
};
declare type SetDataField<TData> = _SetDataField<TData> & _overWriteObjFields<keyof _SetDataField<TData>, TData>;
declare type CusTomSetData<TAllData extends object | unknown> = IfEquals<TAllData, unknown, unknown, {
setData(options: ComputeObj<Partial<SetDataField<TAllData>>>, callback?: () => void): void;
}>;
interface PathOption<TPath extends Path> {
path?: TPath;
}
interface MainDataOption<TMainData> {
mainData?: TMainData;
}
declare type CloseDataField<TMainData extends IMainDataDoc> = IfEquals<TMainData, IMainDataDoc, unknown, {
properties?: never;
data?: never;
computed?: never;
}>;
declare type InferAuxType<T> = T extends StringConstructor ? string : T extends NumberConstructor ? number : T extends BooleanConstructor ? boolean : T extends ArrayConstructor ? unknown[] : T extends ObjectConstructor ? object : T extends AuxType<infer R> ? R : never;
interface PropertiesOption<TProperties, TPrefix extends string = "", TOverField = unknown, TRepeated = unknown> {
properties?: TProperties & ValidationValue<TProperties> & ValidationRepeatedInjectData<TProperties> & ValidationPrefix<TProperties, TPrefix, "standard"> & ValidationOver<TProperties, TOverField> & ValidationRepeated<TProperties, TRepeated>;
}
declare type ValidationValue<T> = {
[k in keyof T]: T[k] extends {
type: infer R;
value: infer V;
optionalTypes: (infer L)[];
} ? V extends InferAuxType<R | L> ? unknown : {
value: (() => "⚠️value类型不正确");
} : T[k] extends {
type: infer R;
value: infer V;
} ? V extends InferAuxType<R> ? unknown : {
value: (() => "⚠️value类型不正确");
} : unknown;
};
declare type ComputedOption<C extends PureObject, TRepeated, TPrefix extends string = "", TDoc extends IComponentDoc = {}, standardData = {
[k in keyof C as k extends `_${string}` ? never : k]: () => "⚠️组件无Properties字段时,只允许内部字段(_key)⚠️";
}, InnerData extends PureObject = {
[k in keyof C as k extends `_${string}` ? k : never]: C[k];
}> = {
computed?: C & ValidationRepeated<C, TRepeated> & ValidationRepeatedInjectData<C> & IfEquals<TDoc, {}, ValidationPrefix<C, TPrefix>, IfEquals<TDoc["properties"], unknown, standardData & ValidationPrefix<InnerData, TPrefix, "inner">, ValidationOver<standardData, TDoc["properties"]> & ValidationPrefix<C, TPrefix>>>;
};
interface DataOption<D extends PureObject, TRepeated = unknown, TPrefix extends string = "", TComponentDoc extends IComponentDoc = {}, ExceptInnerData = {
[k in keyof D as k extends `_${string}` ? never : k]: D[k];
}, InnerData extends PureObject = {
[k in keyof D as k extends `_${string}` ? k : never]: D[k];
}> {
data?: D & ValidationRepeated<D, TRepeated> & ValidationRepeatedInjectData<D> & IfEquals<TComponentDoc, {}, unknown, IfEquals<TComponentDoc["properties"], unknown, {
[k in keyof ExceptInnerData]: () => "组件无Properties字段只可写内部字段(_key)";
} & ValidationPrefix<InnerData, TPrefix>, ValidationOver<ExceptInnerData, TComponentDoc["properties"]> & ValidationPrefix<D, TPrefix>>>;
}
declare type CustomPageLifetimes<TUrl, AllpropertiesDoc> = {
pageLifetimes?: IfEquals<TUrl, EInternalKey.defUrl, Partial<CompPageLifetimes>, Partial<ComputeObj<Omit<WMPageLifetime, "onLoad"> & {
onLoad: (data: AllpropertiesDoc) => void;
}>>>;
};
declare type ValidationRepeated<TGeneric, TAllFields> = OverwirteKey<Extract<keyof TGeneric, keyof TAllFields>, () => "⚠️重复字段⚠️">;
declare type ValidationRepeatedInjectData<T, O = IinjectData> = OverwirteKey<Extract<keyof T, keyof O>, "⚠️与注入的data字段重复⚠️">;
declare type ValidationInjectMethods<T, O = IinjectMethods> = OverwirteKey<Extract<keyof T, keyof O>, "⚠️与注入的methods字段重复⚠️">;
declare type ValidationOver<TCurrentObj, TBaseField> = IfEquals<TBaseField, unknown, unknown, OverwirteKey<Exclude<keyof TCurrentObj, keyof TBaseField>, () => `⚠️此字段超出约束范围⚠️`>>;
declare type ValidationPrefix<T, TPrefix extends string, type extends "inner" | "standard" | "all" = "all", NonPrefixKeys extends string = GetNonPrefixKeys<keyof T & string, TPrefix, type>> = IfEquals<NonPrefixKeys, never, unknown, {
[k in NonPrefixKeys]: k extends keyof T ? T[k] extends ObjectConstructor ? `⚠️此字段要求前缀为${TPrefix}⚠️` : IfEquals<type, "standard", () => `⚠️此字段要求前缀为 ${TPrefix} ⚠️`, IfEquals<type, "inner", () => (`⚠️此字段要求前缀为 _${TPrefix} ⚠️`), () => (`⚠️此字段要求前缀为 ${TPrefix} 或 _${TPrefix} ⚠️`)>> : never;
}>;
declare type GetNonPrefixKeys<U extends string, TPrefix extends string, type extends "inner" | "standard" | "all" = "all"> = IfEquals<TPrefix, "", never, IfEquals<type, "standard", U extends `${TPrefix}_${string}` ? never : U, IfEquals<type, "inner", U extends `_${TPrefix}_${string}` ? never : U, U extends `${TPrefix}_${string}` | `_${TPrefix}_${string}` ? never : U>>>;
declare type Suffix<T extends object, TLabel extends string> = {
[k in keyof T as `${k & string}_${TLabel}`]: T[k];
};
declare type ComputeObj<O> = IfEquals<O, unknown, unknown, O extends unknown ? {
[k in keyof O]: O[k];
} : never>;
declare type CompilePageDocForNavigateTo<T extends IPageDoc> = {
url: T["path"];
} & IfEquals<T["properties"], unknown, unknown, IfEquals<RequiredKeys<NonNullable<T["properties"]>>, never, {
data?: T["properties"];
}, {
data: T["properties"];
}>>;
declare type NavigateTo = <TDoc extends IPageDoc = never>(this: any, obj: NoInfer<CompilePageDocForNavigateTo<TDoc>>) => Promise<WechatMiniprogram.NavigateToSuccessCallbackResult>;
declare type GetPublishEventDoc<T extends PublishEventConstaint> = {