zmp-sdk 2.19.2 → 2.21.0
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/dist/browser.min.js +1370 -1346
- package/dist/index.es.js +1371 -1347
- package/dist/index.js +1 -1
- package/dist/index.umd.js +1 -1
- package/dist/types/src/apis/index.d.ts +3 -0
- package/dist/types/src/apis/payment.d.ts +14 -14
- package/dist/types/src/constants.d.ts +90 -20
- package/dist/types/src/decorator.d.ts +22 -0
- package/dist/types/src/errorHandler.d.ts +12 -0
- package/dist/types/src/services/mock-mp-service.d.ts +2 -1
- package/dist/types/src/services/navigationBar.d.ts +2 -37
- package/dist/types/src/services/zalo-mp-service.d.ts +4 -2
- package/dist/types/src/storage/nativeStorage.d.ts +1 -2
- package/dist/types/src/types/enum.d.ts +2 -7
- package/dist/types/src/types/inputData.d.ts +5 -0
- package/dist/types/src/types/interface.d.ts +2 -1
- package/dist/types/src/utils/lodash.d.ts +1 -0
- package/dist/types/src/utils/response.d.ts +8 -8
- package/dist/types/src/zaloJsBridge.d.ts +16 -2
- package/package.json +1 -1
- package/dist/types/src/bridgeProvider.d.ts +0 -19
- package/dist/types/src/middleware/error.middleware.d.ts +0 -18
- package/dist/types/src/middleware/validate.middleware.d.ts +0 -9
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { PlatformType } from './types/enum';
|
|
1
2
|
export declare const ZAPP_ID: string;
|
|
2
3
|
export declare const APP_ID: string;
|
|
3
4
|
export declare const APP_CONFIG: import(".").SDKConfig;
|
|
@@ -8,6 +9,7 @@ export declare const COOKIE_NAME: {
|
|
|
8
9
|
ZACC_SESSiON: string;
|
|
9
10
|
JS_TOKEN: string;
|
|
10
11
|
ZOAUTH_VRF: string;
|
|
12
|
+
DEVICE_ID: string;
|
|
11
13
|
};
|
|
12
14
|
export declare const APIS: {
|
|
13
15
|
GET_USER_INFO: string;
|
|
@@ -15,6 +17,8 @@ export declare const APIS: {
|
|
|
15
17
|
GET_ACCESS_TOKEN_V3: string;
|
|
16
18
|
GET_LIST_USER_INFO: string;
|
|
17
19
|
CREATE_ORDER: string;
|
|
20
|
+
GET_APP_INFO: string;
|
|
21
|
+
SEND_ACTION_LOG: string;
|
|
18
22
|
};
|
|
19
23
|
export declare const STORAGE_DATA_LIMIT: number;
|
|
20
24
|
export declare const STORAGE_LIMIT: number;
|
|
@@ -26,42 +30,108 @@ export declare const NETWORK_TYPE: (isAndroid: boolean) => {
|
|
|
26
30
|
'4G': number;
|
|
27
31
|
};
|
|
28
32
|
export declare const MEDIA_PICKER_LIMIT: number;
|
|
29
|
-
export declare const MEDIA_PICKER_UPLOAD_SERVER = "https://zapi-server.tungnt.xyz/upload/photos";
|
|
30
|
-
export declare const ACTION: {
|
|
31
|
-
[key: string]: {
|
|
32
|
-
name: string;
|
|
33
|
-
version_live?: {
|
|
34
|
-
android?: number;
|
|
35
|
-
iOS?: number;
|
|
36
|
-
};
|
|
37
|
-
app_support?: boolean;
|
|
38
|
-
have_permission?: boolean;
|
|
39
|
-
skip_jump?: boolean;
|
|
40
|
-
white_list?: boolean;
|
|
41
|
-
have_callback?: boolean;
|
|
42
|
-
};
|
|
43
|
-
};
|
|
44
33
|
export declare const RESPONSE_CODE: {
|
|
45
34
|
SUCCESS: number;
|
|
35
|
+
UNKNOWN_ERROR: number;
|
|
46
36
|
BAD_REQUEST: number;
|
|
47
37
|
INTERNAL_SERVER_ERROR: number;
|
|
48
38
|
UNAUTHORIZED: number;
|
|
49
39
|
FORBIDDEN: number;
|
|
50
40
|
CLIENT_NOT_SUPPORT: number;
|
|
41
|
+
TIME_OUT: number;
|
|
42
|
+
DECODE_FAILED: number;
|
|
43
|
+
USER_DENIED: number;
|
|
44
|
+
USER_CANCEL: number;
|
|
45
|
+
MEDIA_PICKER_FAIL: number;
|
|
46
|
+
SAVE_IMAGE_FAIL: number;
|
|
51
47
|
};
|
|
52
48
|
export declare const MESSAGES: {
|
|
53
49
|
SUCCESS: string;
|
|
54
|
-
|
|
50
|
+
UNKNOWN_ERROR: string;
|
|
51
|
+
TIME_OUT: string;
|
|
55
52
|
LOGIN_REQUIRED: string;
|
|
56
53
|
LOGIN_FAILED: string;
|
|
57
54
|
NOT_PERMISSION: string;
|
|
58
55
|
CLIENT_NOT_SUPPORT: string;
|
|
59
56
|
DECODE_FAILED: string;
|
|
57
|
+
INVALID_PARAM: string;
|
|
58
|
+
USER_DENIED: string;
|
|
59
|
+
USER_CANCEL: string;
|
|
60
|
+
MEDIA_PICKER_FAIL: string;
|
|
61
|
+
SAVE_IMAGE_FAIL: string;
|
|
60
62
|
};
|
|
61
|
-
export declare const
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
63
|
+
export declare const RESPONSE: {
|
|
64
|
+
SUCCESS: {
|
|
65
|
+
code: number;
|
|
66
|
+
message: string;
|
|
67
|
+
};
|
|
68
|
+
UNKNOWN_ERROR: {
|
|
69
|
+
code: number;
|
|
70
|
+
message: string;
|
|
71
|
+
};
|
|
72
|
+
UNAUTHORIZED: {
|
|
73
|
+
code: number;
|
|
74
|
+
message: string;
|
|
75
|
+
};
|
|
76
|
+
FORBIDDEN: {
|
|
77
|
+
code: number;
|
|
78
|
+
message: string;
|
|
79
|
+
};
|
|
80
|
+
CLIENT_NOT_SUPPORT: {
|
|
81
|
+
code: number;
|
|
82
|
+
message: string;
|
|
83
|
+
};
|
|
84
|
+
DECODE_FAILED: {
|
|
85
|
+
code: number;
|
|
86
|
+
message: string;
|
|
87
|
+
};
|
|
88
|
+
TIME_OUT: {
|
|
89
|
+
code: number;
|
|
90
|
+
message: string;
|
|
91
|
+
};
|
|
92
|
+
USER_DENIED: {
|
|
93
|
+
code: number;
|
|
94
|
+
message: string;
|
|
95
|
+
};
|
|
96
|
+
USER_CANCEL: {
|
|
97
|
+
code: number;
|
|
98
|
+
message: string;
|
|
99
|
+
};
|
|
100
|
+
};
|
|
101
|
+
export declare type ACTION_KEY = 'GET_DOWNLOADED_STICKER' | 'OPEN_SHARE_STICKER' | 'OPEN_PROFILE' | 'OPEN_FEED_DETAIL' | 'OPEN_FRIEND_RADA' | 'OPEN_INAPP' | 'OPEN_OUTAPP' | 'OPEN_PAGE' | 'OPEN_PHOTODETAIL' | 'OPEN_GALARY' | 'OPEN_GAMECENTER' | 'OPEN_GAMENEWS' | 'OPEN_TAB_CONTACT' | 'OPEN_TAB_SOCIAL' | 'OPEN_FRIENDSUGGEST' | 'OPEN_GROUPLIST' | 'OPEN_NEARBY' | 'OPEN_ROOM' | 'OPEN_STICKERSTORE' | 'OPEN_CREATECHAT' | 'COPY_LINK_CATESTICKER' | 'REQUEST_BUY_STICKER' | 'OPEN_CHAT' | 'OPEN_TAB_CHAT' | 'OPEN_CHATGROUP' | 'OPEN_ADDFRIEND' | 'OPEN_TAB_MORE' | 'OPEN_POSTFEED' | 'OPEN_LOGINDEVICES' | 'OPEN_SENDSTICKER' | 'REPORT_ABUSE' | 'FOLLOW_OA' | 'UNFOLLOW_OA' | 'OPEN_GAMEDETAIL' | 'OPEN_SHARESHEET' | 'REQUEST_PERMISSION_CAMERA' | 'CHANGE_TITLE_HEADER' | 'WEBVIEW_CLEARCACHE' | 'WEBVIEW_CONFIRMCACHE' | 'WEBVIEW_ISVISIBLE' | 'WEBVIEW_NETWORKTYPE' | 'CHANGE_BUTTON_HEADER' | 'CREATE_OPTIONS_MENU' | 'CREATE_SHORTCUT' | 'CHANGE_ACTIONBAR_LEFTBUTTON_TYPE' | 'WINDOW_CLOSE' | 'WEBVIEW_CHECKRESERROR' | 'IAP_REQUESTPAYMENT' | 'ZBROWSER_GETSTATS' | 'ZBROWSER_JSBRIDGE' | 'PROMPT_AUTHENTICATION' | 'CHANGE_ACTIONBAR_COLOR' | 'PROMPT_AUTHENTICATION_CHECK_STATE' | 'OPEN_APPSTORE' | 'GET_LOCATION' | 'QUERY_LOCATION_HIDE' | 'SHOW_TOAST' | 'OPEN_APP' | 'HIDE_KEYBOARD' | 'OPEN_PHONE' | 'OPEN_QR' | 'OPEN_SMS' | 'VIEW_MYQR' | 'KEEP_SCREEN' | 'CHANGE_AUTOROTATE' | 'CHECK_APP_INSTALLED' | 'QUERY_SHOW' | 'QUERY_HIDE' | 'OPEN_INAPPRW' | 'ZALORUN_GETTRACKINGSTATUS' | 'ZALORUN_SETTRACKINGSTATUS' | 'ZALORUN_GETDAYSTEP' | 'ZALORUN_FORCESUBMITDATA' | 'ZALORUN_SETWEIGHT' | 'OPEN_PROFILE_EXT' | 'DOWNLOAD_CATE' | 'JUMP_LOGIN' | 'OPEN_ADTIMA_ADS_INTERSTITIAL' | 'OPEN_ADTIMA_ADS' | 'GET_ADIDCLIENT' | 'SCAN_IBEACON' | 'INTERACTIVE_VIBRATION' | 'SAVE_IMAGE_GALLERY' | 'OPEN_MP' | 'CHANGE_ACTIONBAR' | 'ZBROWSER_MPDS' | 'WEBVIEW_SET_RESULT' | 'MP_GET_NUMBER' | 'MP_OPEN_PROFILE_PICKER' | 'GET_SUPPORTED_ACTIONS' | 'MP_JOIN_WIFI' | 'PICK_MEDIA' | 'MP_CLOSE_LOADINGVIEW';
|
|
102
|
+
export declare const ACTION: {
|
|
103
|
+
[K in any as ACTION_KEY]: {
|
|
104
|
+
name: string;
|
|
105
|
+
version_live?: {
|
|
106
|
+
android?: number;
|
|
107
|
+
iOS?: number;
|
|
108
|
+
};
|
|
109
|
+
app_support?: boolean;
|
|
110
|
+
have_permission?: boolean;
|
|
111
|
+
skip_jump?: boolean;
|
|
112
|
+
white_list?: boolean;
|
|
113
|
+
have_callback?: boolean;
|
|
114
|
+
error_list?: {
|
|
115
|
+
[K in any as PlatformType]?: {
|
|
116
|
+
[code: string]: {
|
|
117
|
+
map_to: {
|
|
118
|
+
code: number;
|
|
119
|
+
message: string;
|
|
120
|
+
};
|
|
121
|
+
message?: string;
|
|
122
|
+
need_more_detail?: boolean;
|
|
123
|
+
};
|
|
124
|
+
};
|
|
125
|
+
};
|
|
126
|
+
};
|
|
127
|
+
};
|
|
128
|
+
export declare const COMMON_NATIVE_ERROR_CODE: {
|
|
129
|
+
[key: string]: {
|
|
130
|
+
[key: string]: {
|
|
131
|
+
message: string;
|
|
132
|
+
code: number;
|
|
133
|
+
};
|
|
134
|
+
};
|
|
65
135
|
};
|
|
66
136
|
export declare const ZALO_SUPPORT_STORAGE_VERSION: {
|
|
67
137
|
android: number;
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import 'reflect-metadata';
|
|
2
|
+
export declare const required: (fields: string[] | Array<string>[], option?: {
|
|
3
|
+
if?: Object | undefined;
|
|
4
|
+
defaultValue?: Object | undefined;
|
|
5
|
+
} | undefined) => (target: Object, propertyKey: string | symbol, parameterIndex: number) => void;
|
|
6
|
+
export declare const checkType: (type: string, properties?: {
|
|
7
|
+
[key: string]: any;
|
|
8
|
+
} | undefined, defaultValue?: any) => (target: Object, propertyKey: string | symbol, parameterIndex: number) => void;
|
|
9
|
+
export interface DecorateAllOptions {
|
|
10
|
+
deep?: boolean;
|
|
11
|
+
exclude?: string[];
|
|
12
|
+
excludePrefix?: string;
|
|
13
|
+
}
|
|
14
|
+
/**
|
|
15
|
+
* Apply the given decorator to all class methods
|
|
16
|
+
*
|
|
17
|
+
* @param decorator Method decorator to apply to all methods of a class
|
|
18
|
+
* @param {string[]} options.exclude array of method names that won't be decorated
|
|
19
|
+
* @param {boolean} options.deep if true, also decorates methods of the extended classes (recusrively)
|
|
20
|
+
*/
|
|
21
|
+
export declare const DecorateAll: (decorator: MethodDecorator, options?: DecorateAllOptions) => (target: any) => void;
|
|
22
|
+
export declare const centralizedFunctionHandler: MethodDecorator;
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { ACTION } from './constants';
|
|
2
|
+
export declare class AppError {
|
|
3
|
+
code: number;
|
|
4
|
+
message: string;
|
|
5
|
+
api?: string | symbol;
|
|
6
|
+
isNativeError?: boolean;
|
|
7
|
+
action?: typeof ACTION[keyof typeof ACTION];
|
|
8
|
+
constructor(code: number, msg: string, api?: string | symbol);
|
|
9
|
+
toString(): string;
|
|
10
|
+
toJSON(): object;
|
|
11
|
+
}
|
|
12
|
+
export declare const errorHandler: (error: any, api?: string | symbol | undefined) => object;
|
|
@@ -8,6 +8,7 @@ export default class MockSDKService implements SDKServiceInterface {
|
|
|
8
8
|
#private;
|
|
9
9
|
getLoginStatus: () => boolean;
|
|
10
10
|
getAppId: () => string;
|
|
11
|
+
getDeviceId: () => string;
|
|
11
12
|
login: (object?: InputDataType.CallbackType | undefined) => Promise<string>;
|
|
12
13
|
getAccessToken: (object?: InputDataType.CallbackType | undefined) => Promise<string | null>;
|
|
13
14
|
getVersion: typeof Basics.getVersion;
|
|
@@ -15,7 +16,7 @@ export default class MockSDKService implements SDKServiceInterface {
|
|
|
15
16
|
setNavigationBarTitle: (object: InputDataType.NavBarTitleType) => Promise<any>;
|
|
16
17
|
setNavigationBarColor: (object: InputDataType.NavBarColorType) => Promise<any>;
|
|
17
18
|
setBackgroundColor: (object: InputDataType.BackgroundColorType) => Promise<any>;
|
|
18
|
-
setNavigationBarLeftButton: (
|
|
19
|
+
setNavigationBarLeftButton: (type?: "none" | "back" | "home" | "both", confirmToExit?: 0 | 2) => Promise<any>;
|
|
19
20
|
setDeviceOrientation: (object: InputDataType.DeviceOrientationType) => Promise<void>;
|
|
20
21
|
setStorage: (object: InputDataType.SetStorageDataType) => Promise<{
|
|
21
22
|
errorKeys: Array<string>;
|
|
@@ -85,41 +85,6 @@ export declare class NavigationBar {
|
|
|
85
85
|
* @param {string} [object.dialogMessage="Bạn có muốn thoát?"] - Specifies a message that will be shown on native dialog. Only when ```confirmToExit``` is 1
|
|
86
86
|
* @param {Function} [object.handleCloseEvent] - Specifies a function that will be called when user click close button. Only when ```confirmToExit``` is 2
|
|
87
87
|
*/
|
|
88
|
-
static setNavigationBarLeftButton(this: ZaloMiniProgramSDK,
|
|
89
|
-
|
|
90
|
-
* @ignore
|
|
91
|
-
* Dynamically sets the right button of the current page.
|
|
92
|
-
*
|
|
93
|
-
* @ignore
|
|
94
|
-
* @category Navigation Bar
|
|
95
|
-
*
|
|
96
|
-
* @example
|
|
97
|
-
* zmpApis.setNavigationBarRightButton({
|
|
98
|
-
* supportToolBar: 1,
|
|
99
|
-
* reset: 0,
|
|
100
|
-
* menuListItems: [{
|
|
101
|
-
* title: "Post on timeline",
|
|
102
|
-
* action: "zalo.web.internal.postfeed",
|
|
103
|
-
* showAsAction: 0,
|
|
104
|
-
* iconUrl: "https://cdn3.iconfinder.com/data/icons/user-interface-3-3/34/251-512.png",
|
|
105
|
-
* type: 0,
|
|
106
|
-
* data: {}
|
|
107
|
-
* }],
|
|
108
|
-
* }).then((res) => {
|
|
109
|
-
* console.log("Success");
|
|
110
|
-
* }).catch((error) => {
|
|
111
|
-
* console.log("Fail");
|
|
112
|
-
* });
|
|
113
|
-
*
|
|
114
|
-
* @param {Object} object
|
|
115
|
-
* @param {Number} object.title - Title of a menu item
|
|
116
|
-
* @param {Number} object.action - Native action
|
|
117
|
-
* @param {string} object.showAsAction
|
|
118
|
-
* If ```showAsAction``` is 1 and ```iconUrl``` can load,
|
|
119
|
-
* this item will be shown outside and next to more-button. Maximum 2 item will be shown
|
|
120
|
-
* @param {Function} object.iconUrl - Specifies icon of a menu item
|
|
121
|
-
* @param {0} object.type
|
|
122
|
-
* @param {Object} object.data - Data depends on ```action```
|
|
123
|
-
*/
|
|
124
|
-
static setNavigationBarRightButton(this: ZaloMiniProgramSDK, object: DataType.NavBarRightMenuType): Promise<any>;
|
|
88
|
+
static setNavigationBarLeftButton(this: ZaloMiniProgramSDK, type?: 'none' | 'back' | 'home' | 'both', confirmToExit?: 0 | 2): Promise<any>;
|
|
89
|
+
static setNavigationBar(this: ZaloMiniProgramSDK, data: DataType.ActionBarConfig): Promise<any>;
|
|
125
90
|
}
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import { ZJSBridgeProvider } from '../bridgeProvider';
|
|
2
1
|
import * as InputDataType from '../types/inputData';
|
|
3
2
|
import { Basics } from './basic';
|
|
4
3
|
import { NavigationBar } from './navigationBar';
|
|
@@ -11,9 +10,10 @@ import { Location } from './location';
|
|
|
11
10
|
import { Media } from './media';
|
|
12
11
|
import { Zalo } from './zalo';
|
|
13
12
|
import { Routing } from './routing';
|
|
13
|
+
import ZJSBridge from '../zaloJsBridge';
|
|
14
14
|
import { SDKServiceInterface } from '../types/interface';
|
|
15
15
|
import { ZMPEEmitter } from '../event-emitter';
|
|
16
|
-
export default class ZaloMiniProgramSDKService
|
|
16
|
+
export default class ZaloMiniProgramSDKService implements SDKServiceInterface {
|
|
17
17
|
#private;
|
|
18
18
|
events: ZMPEEmitter;
|
|
19
19
|
isShowNavBar: boolean;
|
|
@@ -26,6 +26,8 @@ export default class ZaloMiniProgramSDKService extends ZJSBridgeProvider impleme
|
|
|
26
26
|
getLoginStatus(): boolean;
|
|
27
27
|
getAppId(): string;
|
|
28
28
|
getZAppId(): string;
|
|
29
|
+
getDeviceId(): string;
|
|
30
|
+
getJSBridge(): ZJSBridge;
|
|
29
31
|
login(object?: InputDataType.CallbackType): Promise<string>;
|
|
30
32
|
loginZaloV3(): Promise<string | null>;
|
|
31
33
|
loginZaloV4(): Promise<string | null>;
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import { ResourceStorage } from './storage';
|
|
2
|
-
|
|
3
|
-
export declare class NativeResourceStorage extends ZJSBridgeProvider implements ResourceStorage {
|
|
2
|
+
export declare class NativeResourceStorage implements ResourceStorage {
|
|
4
3
|
#private;
|
|
5
4
|
constructor(appId: string);
|
|
6
5
|
get(keys: Array<string>): Promise<Map<string, string | null>>;
|
|
@@ -50,18 +50,13 @@ export declare enum OrientationType {
|
|
|
50
50
|
export declare enum VibrateType {
|
|
51
51
|
oneShot = 0
|
|
52
52
|
}
|
|
53
|
-
export declare enum NativeCode {
|
|
54
|
-
token_invalid = -2,
|
|
55
|
-
not_permission = -1,
|
|
56
|
-
client_not_support = -5,
|
|
57
|
-
decode_failed = -4
|
|
58
|
-
}
|
|
59
53
|
export declare enum Events {
|
|
60
54
|
AppPaused = "h5.event.paused",
|
|
61
55
|
AppResumed = "h5.event.resumed",
|
|
62
56
|
NetworkChanged = "h5.event.connection.changed",
|
|
63
57
|
OnDataCallback = "h5.event.webview.result",
|
|
64
|
-
OpenApp = "h5.event.open.mp"
|
|
58
|
+
OpenApp = "h5.event.open.mp",
|
|
59
|
+
AppClose = "h5.event.action.close"
|
|
65
60
|
}
|
|
66
61
|
export declare enum MediaPickerType {
|
|
67
62
|
photo = 4,
|
|
@@ -242,6 +242,7 @@ export declare type OpenChatData = CallbackType & {
|
|
|
242
242
|
type: keyof typeof ChatType;
|
|
243
243
|
sourceId?: any;
|
|
244
244
|
sourceIndex?: any;
|
|
245
|
+
message?: string;
|
|
245
246
|
};
|
|
246
247
|
/**
|
|
247
248
|
* Open Post feed input data
|
|
@@ -479,4 +480,8 @@ export declare type CheckTransaction = CallbackType & {
|
|
|
479
480
|
[key: string]: string;
|
|
480
481
|
};
|
|
481
482
|
};
|
|
483
|
+
export declare type ConfigCloseButtonRequest<T> = CallbackType<T> & {
|
|
484
|
+
confirmToExit?: boolean;
|
|
485
|
+
onExit?: () => void;
|
|
486
|
+
};
|
|
482
487
|
export {};
|
|
@@ -5,6 +5,7 @@ import { MediaPickerType } from './enum';
|
|
|
5
5
|
import { SDKCreator } from '..';
|
|
6
6
|
export interface SDKServiceInterface {
|
|
7
7
|
getAppId: () => string;
|
|
8
|
+
getDeviceId: () => string;
|
|
8
9
|
login: (object?: InputDataType.CallbackType) => Promise<string>;
|
|
9
10
|
getLoginStatus: () => boolean;
|
|
10
11
|
getAccessToken: (object?: InputDataType.CallbackType) => Promise<string | null>;
|
|
@@ -13,7 +14,7 @@ export interface SDKServiceInterface {
|
|
|
13
14
|
setNavigationBarTitle: (object: InputDataType.NavBarTitleType) => Promise<any>;
|
|
14
15
|
setNavigationBarColor: (object: InputDataType.NavBarColorType) => Promise<any>;
|
|
15
16
|
setBackgroundColor: (object: InputDataType.BackgroundColorType) => Promise<any>;
|
|
16
|
-
setNavigationBarLeftButton: (
|
|
17
|
+
setNavigationBarLeftButton: (type?: "none" | "back" | "home" | "both", confirmToExit?: 0 | 2) => Promise<any>;
|
|
17
18
|
setDeviceOrientation: (object: InputDataType.DeviceOrientationType) => Promise<void>;
|
|
18
19
|
setStorage: (object: InputDataType.SetStorageDataType) => Promise<{
|
|
19
20
|
errorKeys: Array<string>;
|
|
@@ -35,5 +35,6 @@ declare const _default: {
|
|
|
35
35
|
<T_4 extends object>(object: T_4, path: import("lodash").PropertyPath, value: any): T_4;
|
|
36
36
|
<TResult>(object: object, path: import("lodash").PropertyPath, value: any): TResult;
|
|
37
37
|
};
|
|
38
|
+
isPromise: (obj: any) => boolean;
|
|
38
39
|
};
|
|
39
40
|
export default _default;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { AppError } from '../errorHandler';
|
|
2
2
|
export declare const apiResponse: {
|
|
3
3
|
success: (data?: any, message?: string | undefined) => {
|
|
4
4
|
code: number;
|
|
@@ -6,12 +6,12 @@ export declare const apiResponse: {
|
|
|
6
6
|
data: any;
|
|
7
7
|
};
|
|
8
8
|
error: {
|
|
9
|
-
badRequest: (message: string) =>
|
|
10
|
-
loginFailed: () =>
|
|
11
|
-
loginRequired: () =>
|
|
12
|
-
missingParam: (params: string[] | string) =>
|
|
13
|
-
wrongTypeParam: (arg: string, expected: string, got: string) =>
|
|
14
|
-
cannotGetShareInfo: () =>
|
|
15
|
-
lengthInvalid: (arg: string) =>
|
|
9
|
+
badRequest: (message: string) => AppError;
|
|
10
|
+
loginFailed: (message: string) => AppError;
|
|
11
|
+
loginRequired: () => AppError;
|
|
12
|
+
missingParam: (params: string[] | string) => AppError;
|
|
13
|
+
wrongTypeParam: (arg: string, expected: string, got: string) => AppError;
|
|
14
|
+
cannotGetShareInfo: () => AppError;
|
|
15
|
+
lengthInvalid: (arg: string) => AppError;
|
|
16
16
|
};
|
|
17
17
|
};
|
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
import { ACTION } from './constants';
|
|
2
2
|
import EventEmitter from 'eventemitter3';
|
|
3
|
+
import { NativeCallBackData } from './types/callbackData';
|
|
3
4
|
export default class ZaloJSBridge extends EventEmitter {
|
|
5
|
+
#private;
|
|
4
6
|
private static instance;
|
|
5
7
|
private readonly debug;
|
|
6
8
|
private readonly events;
|
|
@@ -12,14 +14,26 @@ export default class ZaloJSBridge extends EventEmitter {
|
|
|
12
14
|
private _userAgent;
|
|
13
15
|
private _device;
|
|
14
16
|
private sendLogTimer;
|
|
17
|
+
private isJumped;
|
|
15
18
|
constructor();
|
|
16
19
|
set accessTk(value: string);
|
|
17
20
|
set jsAccessTk(value: string);
|
|
18
|
-
|
|
21
|
+
jump: () => Promise<any>;
|
|
22
|
+
sendLogData(data: {
|
|
23
|
+
action: string;
|
|
24
|
+
error: number;
|
|
25
|
+
message: string;
|
|
26
|
+
}[]): void;
|
|
19
27
|
onJSCall(key: string, data: any): void;
|
|
20
28
|
onMultiJSCall(key: string, data: any): void;
|
|
21
29
|
nativeEventHandler(eventId: string, eventName: string, eventData: string): void;
|
|
22
30
|
handleEventData(eventName: string, data: any): any;
|
|
23
31
|
defaultCallback(data: any): void;
|
|
24
|
-
|
|
32
|
+
callNative(action: typeof ACTION[keyof typeof ACTION], data: object, option?: {
|
|
33
|
+
isMultiCallback?: boolean;
|
|
34
|
+
nRetry?: number;
|
|
35
|
+
haveTimeout?: boolean;
|
|
36
|
+
successCallback?: (data: NativeCallBackData) => void;
|
|
37
|
+
delay?: number;
|
|
38
|
+
}): Promise<any>;
|
|
25
39
|
}
|
package/package.json
CHANGED
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
import { NativeCallBackData } from './types/callbackData';
|
|
2
|
-
import { NativeError } from './middleware/error.middleware';
|
|
3
|
-
import { ACTION } from './constants';
|
|
4
|
-
/** @ignore */
|
|
5
|
-
export declare abstract class ZJSBridgeProvider {
|
|
6
|
-
#private;
|
|
7
|
-
private readonly debug;
|
|
8
|
-
/** @ignore */
|
|
9
|
-
constructor();
|
|
10
|
-
protected setZAccSession(value: string): void;
|
|
11
|
-
protected setJSToken(value: string): void;
|
|
12
|
-
protected callNative(action: typeof ACTION[keyof typeof ACTION], data: object, option?: {
|
|
13
|
-
isMultiCallback?: boolean;
|
|
14
|
-
nRetry?: number;
|
|
15
|
-
haveTimeout?: boolean;
|
|
16
|
-
callback?: (data: NativeCallBackData, error: NativeError | null) => void;
|
|
17
|
-
delay?: number;
|
|
18
|
-
}): Promise<any>;
|
|
19
|
-
}
|
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
export declare class CommonError {
|
|
2
|
-
code: number;
|
|
3
|
-
message: string;
|
|
4
|
-
api?: string;
|
|
5
|
-
constructor(code: number, msg: string, api?: string);
|
|
6
|
-
toString(): string;
|
|
7
|
-
}
|
|
8
|
-
export declare class NativeError extends CommonError {
|
|
9
|
-
constructor(code: number, msg: string);
|
|
10
|
-
handler(): void;
|
|
11
|
-
}
|
|
12
|
-
export declare const catchDecoratorStore: {
|
|
13
|
-
handler: any;
|
|
14
|
-
setHandler: Function;
|
|
15
|
-
};
|
|
16
|
-
export declare const errorHandler: (api: string, error: any) => CommonError;
|
|
17
|
-
export declare const handleError: (target: any, propertyName: string, descriptor: TypedPropertyDescriptor<any>) => TypedPropertyDescriptor<any>;
|
|
18
|
-
export declare const handleErrorSync: (target: any, key: string, descriptor: any) => any;
|
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
import 'reflect-metadata';
|
|
2
|
-
export declare const required: (fields: string[] | Array<string>[], option?: {
|
|
3
|
-
if?: Object | undefined;
|
|
4
|
-
defaultValue?: Object | undefined;
|
|
5
|
-
} | undefined) => (target: Object, propertyKey: string | symbol, parameterIndex: number) => void;
|
|
6
|
-
export declare const checkType: (type: string, properties?: {
|
|
7
|
-
[key: string]: any;
|
|
8
|
-
} | undefined, defaultValue?: any) => (target: Object, propertyKey: string | symbol, parameterIndex: number) => void;
|
|
9
|
-
export declare const validate: (target: any, propertyName: string, descriptor: TypedPropertyDescriptor<any>) => TypedPropertyDescriptor<any>;
|