zmp-sdk 2.20.0 → 2.21.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.
@@ -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;
@@ -16,6 +17,8 @@ export declare const APIS: {
16
17
  GET_ACCESS_TOKEN_V3: string;
17
18
  GET_LIST_USER_INFO: string;
18
19
  CREATE_ORDER: string;
20
+ GET_APP_INFO: string;
21
+ SEND_ACTION_LOG: string;
19
22
  };
20
23
  export declare const STORAGE_DATA_LIMIT: number;
21
24
  export declare const STORAGE_LIMIT: number;
@@ -27,42 +30,108 @@ export declare const NETWORK_TYPE: (isAndroid: boolean) => {
27
30
  '4G': number;
28
31
  };
29
32
  export declare const MEDIA_PICKER_LIMIT: number;
30
- export declare const MEDIA_PICKER_UPLOAD_SERVER = "https://zapi-server.tungnt.xyz/upload/photos";
31
- export declare const ACTION: {
32
- [key: string]: {
33
- name: string;
34
- version_live?: {
35
- android?: number;
36
- iOS?: number;
37
- };
38
- app_support?: boolean;
39
- have_permission?: boolean;
40
- skip_jump?: boolean;
41
- white_list?: boolean;
42
- have_callback?: boolean;
43
- };
44
- };
45
33
  export declare const RESPONSE_CODE: {
46
34
  SUCCESS: number;
35
+ UNKNOWN_ERROR: number;
47
36
  BAD_REQUEST: number;
48
37
  INTERNAL_SERVER_ERROR: number;
49
38
  UNAUTHORIZED: number;
50
39
  FORBIDDEN: number;
51
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;
52
47
  };
53
48
  export declare const MESSAGES: {
54
49
  SUCCESS: string;
55
- READ_MORE: string;
50
+ UNKNOWN_ERROR: string;
51
+ TIME_OUT: string;
56
52
  LOGIN_REQUIRED: string;
57
53
  LOGIN_FAILED: string;
58
54
  NOT_PERMISSION: string;
59
55
  CLIENT_NOT_SUPPORT: string;
60
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;
61
62
  };
62
- export declare const API_DOMAIN = "https://h5.zalo.me/";
63
- export declare const MINIAPP_URL = "https://zalo.me/app/link/zapps";
64
- export declare const H5_API: {
65
- GET_APP_INFO: string;
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
+ };
66
135
  };
67
136
  export declare const ZALO_SUPPORT_STORAGE_VERSION: {
68
137
  android: number;
@@ -70,6 +139,12 @@ export declare const ZALO_SUPPORT_STORAGE_VERSION: {
70
139
  wp: number;
71
140
  unknown: number;
72
141
  };
142
+ export declare const ZALO_SUPPORT_SHARE_MULTI_IMAGE_VERSION: {
143
+ android: number;
144
+ iOS: number;
145
+ wp: number;
146
+ unknown: number;
147
+ };
73
148
  export declare const ZALO_IOS_ACTIONS_SUPPORTED_BEFORE_VER_402: string[];
74
149
  export declare const ACTION_LEFT_BUTTON_TYPE: {
75
150
  SHOW_BACK: 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;
@@ -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 extends ZJSBridgeProvider implements SDKServiceInterface {
16
+ export default class ZaloMiniProgramSDKService implements SDKServiceInterface {
17
17
  #private;
18
18
  events: ZMPEEmitter;
19
19
  isShowNavBar: boolean;
@@ -27,6 +27,7 @@ export default class ZaloMiniProgramSDKService extends ZJSBridgeProvider impleme
27
27
  getAppId(): string;
28
28
  getZAppId(): string;
29
29
  getDeviceId(): string;
30
+ getJSBridge(): ZJSBridge;
30
31
  login(object?: InputDataType.CallbackType): Promise<string>;
31
32
  loginZaloV3(): Promise<string | null>;
32
33
  loginZaloV4(): Promise<string | null>;
@@ -1,6 +1,5 @@
1
1
  import { ResourceStorage } from './storage';
2
- import { ZJSBridgeProvider } from '../bridgeProvider';
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>>;
@@ -40,7 +40,8 @@ export declare enum ShareSheetType {
40
40
  video = 12,
41
41
  link = 4,
42
42
  oa = 5,
43
- zmp = 20
43
+ zmp = 20,
44
+ multi_image = 21
44
45
  }
45
46
  export declare enum OrientationType {
46
47
  auto = 1,
@@ -50,12 +51,6 @@ export declare enum OrientationType {
50
51
  export declare enum VibrateType {
51
52
  oneShot = 0
52
53
  }
53
- export declare enum NativeCode {
54
- token_invalid = -2,
55
- not_permission = -1,
56
- client_not_support = -5,
57
- decode_failed = -4
58
- }
59
54
  export declare enum Events {
60
55
  AppPaused = "h5.event.paused",
61
56
  AppResumed = "h5.event.resumed",
@@ -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 { CommonError } from '../middleware/error.middleware';
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) => CommonError;
10
- loginFailed: () => CommonError;
11
- loginRequired: () => CommonError;
12
- missingParam: (params: string[] | string) => CommonError;
13
- wrongTypeParam: (arg: string, expected: string, got: string) => CommonError;
14
- cannotGetShareInfo: () => CommonError;
15
- lengthInvalid: (arg: string) => CommonError;
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
- sendLogData(data: any): void;
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
- jsCall(action: typeof ACTION[keyof typeof ACTION], options: object, callback: any, isMultiCallback?: boolean, nRetry?: number, haveTimeout?: boolean): any;
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,6 +1,6 @@
1
1
  {
2
2
  "name": "zmp-sdk",
3
- "version": "2.20.0",
3
+ "version": "2.21.1",
4
4
  "description": "Zalo Mini App SDK",
5
5
  "license": "MIT",
6
6
  "main": "dist/index.js",
@@ -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>;