@hylid/types 4.0.0-alpha.0 → 4.0.0-alpha.11
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/mp.d.ts +34 -5
- package/package.json +1 -1
package/lib/mp.d.ts
CHANGED
|
@@ -22,6 +22,11 @@ export interface getCurrentPagesOptions {
|
|
|
22
22
|
}[]) => void;
|
|
23
23
|
fail: (err: any) => void;
|
|
24
24
|
}
|
|
25
|
+
export interface AsyncCallback<T = any> {
|
|
26
|
+
success?: ((res: T) => void) | undefined;
|
|
27
|
+
fail?: ((err: AsyncCallbackFailObject) => void) | undefined;
|
|
28
|
+
complete?: ((res?: any) => any) | undefined;
|
|
29
|
+
}
|
|
25
30
|
export interface MPApi extends Omit<MiniprogramApi, 'request'> {
|
|
26
31
|
authorize: (opt: any) => void;
|
|
27
32
|
getAuthUserInfo: (opt: any) => void;
|
|
@@ -90,7 +95,7 @@ export interface MPApi extends Omit<MiniprogramApi, 'request'> {
|
|
|
90
95
|
defaultGateway: string;
|
|
91
96
|
defaultHeaders?: Record<string, string>;
|
|
92
97
|
request: PickMPAttr<'request'>;
|
|
93
|
-
}) => PickMPAttr<'rpc'
|
|
98
|
+
}) => PickPromiseAttr<PickMPAttr<'rpc'>>;
|
|
94
99
|
rpcWithAuth: PickMPAttr<'rpc'>;
|
|
95
100
|
rpcWithAuthAPlus: PickMPAttr<'rpc'>;
|
|
96
101
|
defineRuntimeConfig: (args: Record<string, any>) => Record<string, any>;
|
|
@@ -108,7 +113,10 @@ export interface MPApi extends Omit<MiniprogramApi, 'request'> {
|
|
|
108
113
|
imageUrl?: string;
|
|
109
114
|
image?: string;
|
|
110
115
|
url: string;
|
|
111
|
-
}
|
|
116
|
+
} & AsyncCallback<{
|
|
117
|
+
succeed: boolean;
|
|
118
|
+
channelName: string;
|
|
119
|
+
}>) => void;
|
|
112
120
|
homeAddAppToMyApps: (args: {
|
|
113
121
|
appId: string;
|
|
114
122
|
}) => void;
|
|
@@ -123,8 +131,8 @@ export interface MPApi extends Omit<MiniprogramApi, 'request'> {
|
|
|
123
131
|
addNotifyListener: (args: {
|
|
124
132
|
name: string;
|
|
125
133
|
keep?: boolean;
|
|
126
|
-
callback
|
|
127
|
-
} & AsyncCallback<
|
|
134
|
+
callback?: (res: any) => void;
|
|
135
|
+
} & AsyncCallback<any>) => void;
|
|
128
136
|
postNotification: (args: {
|
|
129
137
|
name: string;
|
|
130
138
|
data: object;
|
|
@@ -176,6 +184,27 @@ export interface MPApi extends Omit<MiniprogramApi, 'request'> {
|
|
|
176
184
|
adCode: string;
|
|
177
185
|
ext: string;
|
|
178
186
|
}>) => void;
|
|
187
|
+
popWindow: () => void;
|
|
188
|
+
setTransparentTitle: (args: AsyncCallback<{
|
|
189
|
+
transparentTitle: 'none' | 'auto' | 'always' | 'custom';
|
|
190
|
+
}>) => void;
|
|
191
|
+
getLocation: (args: {
|
|
192
|
+
bizType?: string;
|
|
193
|
+
requestType?: number;
|
|
194
|
+
timeout?: number;
|
|
195
|
+
horizontalAccuracy?: number;
|
|
196
|
+
} & GetLocationArgs) => void;
|
|
197
|
+
showAuthGuide: (args: AsyncCallback<{
|
|
198
|
+
/**
|
|
199
|
+
* When shown is true, it indicates the permission guide
|
|
200
|
+
* pop-up will be shown; when it is false, it indicates
|
|
201
|
+
* the user has allowed the permission.
|
|
202
|
+
*/
|
|
203
|
+
shown: boolean;
|
|
204
|
+
}> & {
|
|
205
|
+
authType: string;
|
|
206
|
+
bizType?: string;
|
|
207
|
+
}) => void;
|
|
179
208
|
}
|
|
180
209
|
export declare type HeadModel = {
|
|
181
210
|
/**
|
|
@@ -223,5 +252,5 @@ export declare type ItemModel = {
|
|
|
223
252
|
export declare type PickMPAttr<Attr extends keyof MPApi> = PickAttr<Attr, MPApi>;
|
|
224
253
|
export declare type PickMPArgs<Attr extends keyof MPApi> = Parameters<PickMPAttr<Attr>>[0];
|
|
225
254
|
export declare type PickMpReturns<Attr extends keyof MPApi> = ReturnType<PickMPAttr<Attr>>;
|
|
226
|
-
export declare type ReturnTypePromise<T> = T extends AsyncCallback<infer S> ? (args?:
|
|
255
|
+
export declare type ReturnTypePromise<T> = T extends AsyncCallback<infer S> ? (args?: T | undefined) => Promise<S> : never;
|
|
227
256
|
export declare type PickPromiseAttr<T> = T extends (args: infer S) => void ? ReturnTypePromise<S> : never;
|