zmp-sdk 2.15.3 → 2.16.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.
@@ -21,5 +21,7 @@ declare const _default: {
21
21
  '3G': number;
22
22
  '4G': number;
23
23
  };
24
+ MEDIA_PICKER_LIMIT: number;
25
+ MEDIA_PICKER_UPLOAD_SERVER: string;
24
26
  };
25
27
  export default _default;
@@ -1,3 +1,6 @@
1
+ export declare const ZAPP_ID: string;
2
+ export declare const APP_ID: string;
3
+ export declare const APP_CONFIG: import(".").SDKConfig;
1
4
  export declare const ACTION: {
2
5
  [key: string]: {
3
6
  name: string;
@@ -93,6 +93,7 @@ export declare abstract class SDKCreator {
93
93
  openSMS(object: InputDataType.OpenSMS): Promise<void>;
94
94
  viewOAQr(object: InputDataType.ViewOAQr): Promise<void>;
95
95
  keepScreen(object: InputDataType.KeepScreen): Promise<void>;
96
+ saveImageToGallery(object: InputDataType.SaveImageToPhotosAlbumType): Promise<void>;
96
97
  saveImageToPhotosAlbum(object: InputDataType.SaveImageToPhotosAlbumType): Promise<void>;
97
98
  openMiniApp(object: InputDataType.OpenMiniApp): Promise<void>;
98
99
  vibrate(object: InputDataType.VibrateInput): Promise<void>;
@@ -105,6 +106,9 @@ export declare abstract class SDKCreator {
105
106
  onCallbackData(callback: (res: InputDataType.OnCallbackData) => void): Promise<void>;
106
107
  getPhoneNumber(object?: InputDataType.CallbackType<CallbackDataType.GetPhoneNumberSuccessCallBack>): Promise<CallbackDataType.GetPhoneNumberSuccessCallBack>;
107
108
  openProfilePicker(object: InputDataType.OpenProfilePicker<CallbackDataType.OpenProfilePickerSuccessCallBack>): Promise<CallbackDataType.OpenProfilePickerSuccessCallBack>;
109
+ connectWifi(object: InputDataType.ConnectWifi): Promise<void>;
110
+ openMediaPicker(object: InputDataType.OpenMediaPicker<CallbackDataType.OpenMediaPickerSuccessCallBack>): Promise<CallbackDataType.OpenMediaPickerSuccessCallBack>;
111
+ getShareableLink(object: InputDataType.GetShareableLink<string>): Promise<string>;
108
112
  }
109
113
  export declare class ZaloMiniAppSDKCreator extends SDKCreator {
110
114
  protected getInstance(): SDKInterface;
@@ -1,6 +1,7 @@
1
1
  import * as InputDataType from '../types/inputData';
2
2
  import * as CallbackDataType from '../types/callbackData';
3
3
  import { systemInfo } from '../types/entity';
4
+ import { MediaPickerType } from '../types/enum';
4
5
  export interface SDKInterface {
5
6
  getAppId: () => string;
6
7
  login: (object?: InputDataType.CallbackType) => Promise<string>;
@@ -71,4 +72,9 @@ export interface SDKInterface {
71
72
  onCallbackData: (callback: (res: InputDataType.OnCallbackData) => void) => Promise<void>;
72
73
  getPhoneNumber: (object?: InputDataType.CallbackType<CallbackDataType.GetPhoneNumberSuccessCallBack>) => Promise<CallbackDataType.GetPhoneNumberSuccessCallBack>;
73
74
  openProfilePicker: (object?: InputDataType.OpenProfilePicker<CallbackDataType.OpenProfilePickerSuccessCallBack>) => Promise<CallbackDataType.OpenProfilePickerSuccessCallBack>;
75
+ connectWifi: (object: InputDataType.ConnectWifi) => Promise<void>;
76
+ openMediaPicker: (type: keyof typeof MediaPickerType, editView?: {
77
+ enable?: 0 | 1;
78
+ aspect_ratio?: string;
79
+ }, silentRequest?: 0 | 1, maxSelectItem?: number) => Promise<CallbackDataType.OpenMediaPickerSuccessCallBack>;
74
80
  }
@@ -2,6 +2,7 @@ import * as InputDataType from '../types/inputData';
2
2
  import * as CallbackDataType from '../types/callbackData';
3
3
  import { Basics } from '../services/basic';
4
4
  import { Routing } from '../services/routing';
5
+ import * as Enum from '../types/enum';
5
6
  import { SDKInterface } from './interface';
6
7
  export default class MockSDK implements SDKInterface {
7
8
  #private;
@@ -75,4 +76,9 @@ export default class MockSDK implements SDKInterface {
75
76
  off<T extends string>(event: T, fn?: (...args: any[]) => void, context?: any, once?: boolean): void;
76
77
  removeAllListeners(event?: string): void;
77
78
  openProfilePicker: (object?: InputDataType.CallbackType) => Promise<CallbackDataType.OpenProfilePickerSuccessCallBack>;
79
+ connectWifi: (object?: InputDataType.ConnectWifi) => Promise<void>;
80
+ openMediaPicker(type: keyof typeof Enum.MediaPickerType, editView?: {
81
+ enable?: 0 | 1;
82
+ aspect_ratio?: string;
83
+ }, silentRequest?: 0 | 1, maxSelectItem?: number): Promise<CallbackDataType.OpenMediaPickerSuccessCallBack>;
78
84
  }
@@ -86,4 +86,6 @@ export default class ZaloMiniProgramSDK extends ZJSBridgeProvider implements SDK
86
86
  onCallbackData: typeof Routing.onCallbackData;
87
87
  getPhoneNumber: typeof OpenApi.getPhoneNumber;
88
88
  openProfilePicker: typeof Zalo.openProfilePicker;
89
+ connectWifi: typeof Device.connectWifi;
90
+ openMediaPicker: typeof Zalo.openMediaPicker;
89
91
  }
@@ -1,6 +1,9 @@
1
1
  import 'reflect-metadata';
2
- export declare const required: (...args: string[]) => (target: Object, propertyKey: string | symbol, parameterIndex: number) => void;
2
+ export declare const required: (fields: string[], option?: {
3
+ if?: Object | undefined;
4
+ defaultValue?: Object | undefined;
5
+ } | undefined) => (target: Object, propertyKey: string | symbol, parameterIndex: number) => void;
3
6
  export declare const checkType: (type: string, properties?: {
4
7
  [key: string]: any;
5
- } | undefined, key?: string | undefined) => (target: Object, propertyKey: string | symbol, parameterIndex: number) => void;
8
+ } | undefined, defaultValue?: any) => (target: Object, propertyKey: string | symbol, parameterIndex: number) => void;
6
9
  export declare const validate: (target: any, propertyName: string, descriptor: TypedPropertyDescriptor<any>) => TypedPropertyDescriptor<any>;
@@ -310,4 +310,12 @@ export declare class Device {
310
310
  *
311
311
  */
312
312
  static vibrate(this: ZaloMiniProgramSDK, object: InputDataType.VibrateInput): Promise<void>;
313
+ /**
314
+ * Connect Wifi.
315
+ * @async
316
+ * @function connectWifi
317
+ * @category Device
318
+ *
319
+ */
320
+ static connectWifi(this: ZaloMiniProgramSDK, object: InputDataType.ConnectWifi): Promise<void>;
313
321
  }
@@ -1,5 +1,6 @@
1
1
  import * as InputDataType from '../types/inputData';
2
2
  import * as CallbackDataType from '../types/callbackData';
3
+ import { MediaPickerType } from '../types/enum';
3
4
  import ZaloMiniProgramSDK from '../controller/zalo-mp-manager';
4
5
  export declare class Zalo {
5
6
  /**
@@ -89,4 +90,16 @@ export declare class Zalo {
89
90
  *
90
91
  */
91
92
  static getActionsSupported(this: ZaloMiniProgramSDK, object?: InputDataType.CallbackType<CallbackDataType.GetActionsSupportedSuccessCallBack>): Promise<CallbackDataType.GetActionsSupportedSuccessCallBack>;
93
+ /**
94
+ * Cho phép ứng dụng mở giao diện chọn media và get về list media url
95
+ *
96
+ * @async
97
+ * @function openMediaPicker
98
+ * @category Zalo
99
+ *
100
+ */
101
+ static openMediaPicker(this: ZaloMiniProgramSDK, type: keyof typeof MediaPickerType, editView?: {
102
+ enable?: 0 | 1;
103
+ aspect_ratio?: string;
104
+ }, silentRequest?: 0 | 1, maxSelectItem?: number): Promise<CallbackDataType.OpenMediaPickerSuccessCallBack>;
92
105
  }
@@ -137,3 +137,10 @@ export declare type OpenProfilePickerSuccessCallBack = {
137
137
  export declare type GetActionsSupportedSuccessCallBack = {
138
138
  actions: Array<string>;
139
139
  };
140
+ /**
141
+ * open media picker success callback
142
+ * @typedef OpenMediaPickerSuccessCallBack
143
+ */
144
+ export declare type OpenMediaPickerSuccessCallBack = {
145
+ urls: Array<string>;
146
+ };
@@ -60,5 +60,13 @@ export declare enum Events {
60
60
  AppPaused = "h5.event.paused",
61
61
  AppResumed = "h5.event.resumed",
62
62
  NetworkChanged = "h5.event.connection.changed",
63
- OnDataCallback = "h5.event.webview.result"
63
+ OnDataCallback = "h5.event.webview.result",
64
+ OpenApp = "h5.event.open.mp"
65
+ }
66
+ export declare enum MediaPickerType {
67
+ photo = 4,
68
+ video = 5,
69
+ file = 6,
70
+ multi_photo = 7,
71
+ multi_video = 8
64
72
  }
@@ -1,4 +1,4 @@
1
- import { NetworkType, ProfileType, ChatType, PostFeedType, ShareSheetType, OrientationType, VibrateType } from './enum';
1
+ import { NetworkType, ProfileType, ChatType, PostFeedType, ShareSheetType, OrientationType, VibrateType, MediaPickerType } from './enum';
2
2
  export declare type CallbackType<SuccessCallBackRes = any> = {
3
3
  success?: (res: SuccessCallBackRes) => void;
4
4
  fail?: (res: any) => void;
@@ -282,10 +282,7 @@ export declare type OpenShareSheet<T> = CallbackType<T> & {
282
282
  chatOnly: boolean;
283
283
  id: string;
284
284
  title: string;
285
- description: string | {
286
- vi?: string;
287
- en?: string;
288
- };
285
+ description: string;
289
286
  thumbnail: string;
290
287
  path: string;
291
288
  };
@@ -411,6 +408,20 @@ export declare type GetUserInfoDataType<T> = CallbackType<T> & {
411
408
  export declare type OpenProfilePicker<T> = CallbackType<T> & {
412
409
  maxProfile?: number;
413
410
  };
411
+ export declare type ConnectWifi = CallbackType & {
412
+ SSID: string;
413
+ password?: string;
414
+ hiddenSSID?: boolean;
415
+ };
416
+ export declare type OpenMediaPicker<T> = CallbackType<T> & {
417
+ type: keyof typeof MediaPickerType;
418
+ editView: {
419
+ enable: boolean;
420
+ aspectRatio: string;
421
+ };
422
+ silentRequest: boolean;
423
+ maxSelectItem: number;
424
+ };
414
425
  export declare type ActionBarConfig = {
415
426
  actionbarType: number;
416
427
  buttonType: number;
@@ -425,4 +436,13 @@ export declare type ActionBarConfig = {
425
436
  url: string;
426
437
  };
427
438
  };
439
+ /**
440
+ * get zmp shareable link
441
+ */
442
+ export declare type GetShareableLink<T> = CallbackType<T> & {
443
+ title: string;
444
+ description: string;
445
+ thumbnail: string;
446
+ path: string;
447
+ };
428
448
  export {};
@@ -62,3 +62,22 @@ export declare const isSupportNativeStorage: () => boolean;
62
62
  export declare const stringifyData: (data: any) => string;
63
63
  export declare const stringToData: (data: string | null) => any;
64
64
  export declare const checkIOSSupportAction: (action: string) => boolean;
65
+ export declare const getZMPShareInfo: (appID: string, accessToken: string, shareTitle: string, shareDescription: string, shareThumbnail: string, sharePath?: string | undefined) => Promise<{
66
+ zinstantApi: string;
67
+ shareId: string;
68
+ shareableLink: string;
69
+ }>;
70
+ export declare const checkData: (types: string | Array<string>, option?: {
71
+ min?: number | undefined;
72
+ max?: number | undefined;
73
+ maxLength?: number | undefined;
74
+ values?: any[] | undefined;
75
+ default?: any;
76
+ regex?: RegExp | undefined;
77
+ } | undefined) => (data: any) => {
78
+ error: boolean;
79
+ errorMessage: string | string[];
80
+ } | {
81
+ error: boolean;
82
+ errorMessage?: undefined;
83
+ };
@@ -18,6 +18,7 @@ export default class ZaloJSBridge extends EventEmitter {
18
18
  onJSCall(key: string, data: any): void;
19
19
  onMultiJSCall(key: string, data: any): void;
20
20
  nativeEventHandler(eventId: string, eventName: string, eventData: string): void;
21
+ handleEventData(eventName: string, data: any): any;
21
22
  defaultCallback(data: any): void;
22
23
  jsCall(action: string, options: object, callback: any, isMultiCallback?: boolean, nRetry?: number, haveTimeout?: boolean): any;
23
24
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "zmp-sdk",
3
- "version": "2.15.3",
3
+ "version": "2.16.1",
4
4
  "description": "Zalo Mini App SDK",
5
5
  "license": "MIT",
6
6
  "main": "dist/index.js",