///
declare namespace TiniTypes.App {
interface ReferrerInfo {
appId: string;
sourceServiceId: string;
extraData: Record;
}
interface LaunchShowOption {
path: string;
/**
* Khi sử dụng my.navigateTo, my.redirectTo, params sẽ truyền vào trong query.
* query là object parse từ URLSearchParams, xem thêm tại https://developer.mozilla.org/en-US/docs/Web/API/URLSearchParams
*/
query: Record;
referrerInfo?: ReferrerInfo;
}
/**
* see more at https://developer.mozilla.org/en-US/docs/Web/API/Window/unhandledrejection_event
*/
interface OnUnhandledRejectionEvent {
promise: Promise;
reason: string;
}
interface OnUnhandledRejectionCallback {
(this: R, event: OnUnhandledRejectionEvent): void;
}
type AnyObject = Record;
type Instance = Omit;
type BANNED_KEYS =
| 'onLaunch'
| 'onShow'
| 'onHide'
| 'onError'
| 'onUnhandledRejection';
type TCustom = Omit;
type Options = (Partial>> &
Partial>>) &
ThisType>;
interface Constructor {
(options: Options): void;
}
interface AppEventHandlers {
/**
* *App lifecycle*。
*
* `onLaunch` sẽ được trigger khi lần đầu init app.
*
* AppCreate(`onLanch` => `onShow`) => PageCreate(`onLoad` => `onShow` => `onReady`)
* https://developers.tiki.vn/docs/framework/miniapp-page/life-cycle
*/
onLaunch(this: R, options: LaunchShowOption): void | Promise;
/**
* *App lifecycle*。
*
* `onShow` sẽ được trigger sau khi hàm `onLaunch`
* và trước khi khởi tạo Page.
*
* AppCreate(`onLanch` => `onShow`) => PageCreate(`onLoad` => `onShow` => `onReady`)
* https://developers.tiki.vn/docs/framework/miniapp-page/life-cycle
*/
onShow(this: R, options: LaunchShowOption): void | Promise;
/**
* *App lifecycle*。
*
* `onShow` sẽ được trigger khi app bị ẩn.
*
*/
onHide(this: R): void | Promise;
/**
*
* @param error error detail/ error name
*/
onError(this: R, error: string): void;
onUnhandledRejection: OnUnhandledRejectionCallback;
}
interface GetApp {
(): Omit, keyof AppEventHandlers>;
}
}