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
package/dist/index.es.js
CHANGED
|
@@ -2064,6 +2064,9 @@ function set(object, path, value) {
|
|
|
2064
2064
|
|
|
2065
2065
|
var set_1 = set;
|
|
2066
2066
|
|
|
2067
|
+
const isPromise = (obj) => !!obj &&
|
|
2068
|
+
(typeof obj === 'object' || typeof obj === 'function') &&
|
|
2069
|
+
typeof obj.then === 'function';
|
|
2067
2070
|
var _ = {
|
|
2068
2071
|
isEmpty: isEmpty_1,
|
|
2069
2072
|
isNull: isNull_1,
|
|
@@ -2075,7 +2078,8 @@ var _ = {
|
|
|
2075
2078
|
isArray: isArray_1,
|
|
2076
2079
|
isRegExp: isRegExp_1,
|
|
2077
2080
|
get: get_1,
|
|
2078
|
-
set: set_1
|
|
2081
|
+
set: set_1,
|
|
2082
|
+
isPromise,
|
|
2079
2083
|
};
|
|
2080
2084
|
|
|
2081
2085
|
function Debug(name) {
|
|
@@ -2147,13 +2151,6 @@ var VibrateType;
|
|
|
2147
2151
|
(function (VibrateType) {
|
|
2148
2152
|
VibrateType[VibrateType["oneShot"] = 0] = "oneShot";
|
|
2149
2153
|
})(VibrateType || (VibrateType = {}));
|
|
2150
|
-
var NativeCode;
|
|
2151
|
-
(function (NativeCode) {
|
|
2152
|
-
NativeCode[NativeCode["token_invalid"] = -2] = "token_invalid";
|
|
2153
|
-
NativeCode[NativeCode["not_permission"] = -1] = "not_permission";
|
|
2154
|
-
NativeCode[NativeCode["client_not_support"] = -5] = "client_not_support";
|
|
2155
|
-
NativeCode[NativeCode["decode_failed"] = -4] = "decode_failed";
|
|
2156
|
-
})(NativeCode || (NativeCode = {}));
|
|
2157
2154
|
var Events;
|
|
2158
2155
|
(function (Events) {
|
|
2159
2156
|
Events["AppPaused"] = "h5.event.paused";
|
|
@@ -2161,6 +2158,7 @@ var Events;
|
|
|
2161
2158
|
Events["NetworkChanged"] = "h5.event.connection.changed";
|
|
2162
2159
|
Events["OnDataCallback"] = "h5.event.webview.result";
|
|
2163
2160
|
Events["OpenApp"] = "h5.event.open.mp";
|
|
2161
|
+
Events["AppClose"] = "h5.event.action.close";
|
|
2164
2162
|
})(Events || (Events = {}));
|
|
2165
2163
|
var MediaPickerType;
|
|
2166
2164
|
(function (MediaPickerType) {
|
|
@@ -2240,7 +2238,8 @@ const COOKIE_NAME = {
|
|
|
2240
2238
|
ZOAUTH: `h5.zdn.vn_zoauth`,
|
|
2241
2239
|
ZACC_SESSiON: `h5.zdn.vn_zacc_session`,
|
|
2242
2240
|
JS_TOKEN: `h5.zdn.vn_zlink3rd`,
|
|
2243
|
-
ZOAUTH_VRF: `h5.zdn.vn_zoauth_vrf
|
|
2241
|
+
ZOAUTH_VRF: `h5.zdn.vn_zoauth_vrf`,
|
|
2242
|
+
DEVICE_ID: `h5.zdn.vn_deviceID`
|
|
2244
2243
|
};
|
|
2245
2244
|
const APIS = {
|
|
2246
2245
|
GET_USER_INFO: 'https://graph.zalo.me/v2.0/me',
|
|
@@ -2248,6 +2247,8 @@ const APIS = {
|
|
|
2248
2247
|
GET_ACCESS_TOKEN_V3: 'https://oauth.zaloapp.com/v3/access_token',
|
|
2249
2248
|
GET_LIST_USER_INFO: 'https://graph.zalo.me/v2.0/me/friends/list',
|
|
2250
2249
|
CREATE_ORDER: 'https://payment-mini.zalo.me/api/order/create',
|
|
2250
|
+
GET_APP_INFO: 'https://h5.zalo.me/apps/get-info',
|
|
2251
|
+
SEND_ACTION_LOG: 'https://h5.zalo.me/log/async'
|
|
2251
2252
|
};
|
|
2252
2253
|
const STORAGE_LIMIT = 5 * MB;
|
|
2253
2254
|
const NETWORK_TYPE = (isAndroid) => ({
|
|
@@ -2258,6 +2259,78 @@ const NETWORK_TYPE = (isAndroid) => ({
|
|
|
2258
2259
|
'4G': isAndroid ? 13 : 2
|
|
2259
2260
|
});
|
|
2260
2261
|
const MEDIA_PICKER_LIMIT = 1 * MB;
|
|
2262
|
+
const RESPONSE_CODE = {
|
|
2263
|
+
SUCCESS: 0,
|
|
2264
|
+
UNKNOWN_ERROR: -2000,
|
|
2265
|
+
BAD_REQUEST: -1400,
|
|
2266
|
+
INTERNAL_SERVER_ERROR: -1500,
|
|
2267
|
+
UNAUTHORIZED: -1401,
|
|
2268
|
+
FORBIDDEN: -1403,
|
|
2269
|
+
CLIENT_NOT_SUPPORT: -1404,
|
|
2270
|
+
TIME_OUT: -1408,
|
|
2271
|
+
DECODE_FAILED: -2001,
|
|
2272
|
+
USER_DENIED: -2002,
|
|
2273
|
+
USER_CANCEL: -2003,
|
|
2274
|
+
// Media picker
|
|
2275
|
+
MEDIA_PICKER_FAIL: -2004,
|
|
2276
|
+
// Save image to gallery
|
|
2277
|
+
SAVE_IMAGE_FAIL: -2005
|
|
2278
|
+
};
|
|
2279
|
+
const MESSAGES = {
|
|
2280
|
+
SUCCESS: 'Success',
|
|
2281
|
+
UNKNOWN_ERROR: 'Unknown error. Please try again later.',
|
|
2282
|
+
TIME_OUT: 'Request timeout. Please try again later.',
|
|
2283
|
+
LOGIN_REQUIRED: 'Please login (https://miniapp.zalo.me/docs/api/login) before to call this api',
|
|
2284
|
+
LOGIN_FAILED: 'Login failed',
|
|
2285
|
+
NOT_PERMISSION: `You don't have permission to call this api`,
|
|
2286
|
+
CLIENT_NOT_SUPPORT: `This API is not supported in this Zalo version`,
|
|
2287
|
+
DECODE_FAILED: 'Can not decode id. Please check your params again.',
|
|
2288
|
+
INVALID_PARAM: 'Invalid parameter',
|
|
2289
|
+
USER_DENIED: 'User denied',
|
|
2290
|
+
USER_CANCEL: 'User cancel',
|
|
2291
|
+
// Media picker
|
|
2292
|
+
MEDIA_PICKER_FAIL: 'Unable to pick media',
|
|
2293
|
+
// Save image to gallery
|
|
2294
|
+
SAVE_IMAGE_FAIL: 'Unable to save image'
|
|
2295
|
+
};
|
|
2296
|
+
const RESPONSE = {
|
|
2297
|
+
SUCCESS: {
|
|
2298
|
+
code: RESPONSE_CODE.SUCCESS,
|
|
2299
|
+
message: MESSAGES.SUCCESS
|
|
2300
|
+
},
|
|
2301
|
+
UNKNOWN_ERROR: {
|
|
2302
|
+
code: RESPONSE_CODE.UNKNOWN_ERROR,
|
|
2303
|
+
message: MESSAGES.UNKNOWN_ERROR
|
|
2304
|
+
},
|
|
2305
|
+
UNAUTHORIZED: {
|
|
2306
|
+
code: RESPONSE_CODE.UNAUTHORIZED,
|
|
2307
|
+
message: MESSAGES.LOGIN_REQUIRED
|
|
2308
|
+
},
|
|
2309
|
+
FORBIDDEN: {
|
|
2310
|
+
code: RESPONSE_CODE.FORBIDDEN,
|
|
2311
|
+
message: MESSAGES.NOT_PERMISSION
|
|
2312
|
+
},
|
|
2313
|
+
CLIENT_NOT_SUPPORT: {
|
|
2314
|
+
code: RESPONSE_CODE.CLIENT_NOT_SUPPORT,
|
|
2315
|
+
message: MESSAGES.CLIENT_NOT_SUPPORT
|
|
2316
|
+
},
|
|
2317
|
+
DECODE_FAILED: {
|
|
2318
|
+
code: RESPONSE_CODE.DECODE_FAILED,
|
|
2319
|
+
message: MESSAGES.DECODE_FAILED
|
|
2320
|
+
},
|
|
2321
|
+
TIME_OUT: {
|
|
2322
|
+
code: RESPONSE_CODE.TIME_OUT,
|
|
2323
|
+
message: MESSAGES.TIME_OUT
|
|
2324
|
+
},
|
|
2325
|
+
USER_DENIED: {
|
|
2326
|
+
code: RESPONSE_CODE.USER_DENIED,
|
|
2327
|
+
message: MESSAGES.USER_DENIED
|
|
2328
|
+
},
|
|
2329
|
+
USER_CANCEL: {
|
|
2330
|
+
code: RESPONSE_CODE.USER_CANCEL,
|
|
2331
|
+
message: MESSAGES.USER_CANCEL
|
|
2332
|
+
}
|
|
2333
|
+
};
|
|
2261
2334
|
const ACTION = {
|
|
2262
2335
|
GET_DOWNLOADED_STICKER: {
|
|
2263
2336
|
name: 'action.get.downloaded.sticker',
|
|
@@ -2370,7 +2443,19 @@ const ACTION = {
|
|
|
2370
2443
|
have_callback: true
|
|
2371
2444
|
},
|
|
2372
2445
|
REQUEST_PERMISSION_CAMERA: {
|
|
2373
|
-
name: 'action.request.permission.camera'
|
|
2446
|
+
name: 'action.request.permission.camera',
|
|
2447
|
+
error_list: {
|
|
2448
|
+
android: {
|
|
2449
|
+
'-2': {
|
|
2450
|
+
map_to: RESPONSE.USER_DENIED
|
|
2451
|
+
}
|
|
2452
|
+
},
|
|
2453
|
+
iOS: {
|
|
2454
|
+
'-2': {
|
|
2455
|
+
map_to: RESPONSE.USER_DENIED
|
|
2456
|
+
}
|
|
2457
|
+
}
|
|
2458
|
+
}
|
|
2374
2459
|
},
|
|
2375
2460
|
CHANGE_TITLE_HEADER: {
|
|
2376
2461
|
name: 'action.change.title.header',
|
|
@@ -2439,7 +2524,19 @@ const ACTION = {
|
|
|
2439
2524
|
},
|
|
2440
2525
|
GET_LOCATION: {
|
|
2441
2526
|
name: 'action.get.location',
|
|
2442
|
-
have_callback: true
|
|
2527
|
+
have_callback: true,
|
|
2528
|
+
error_list: {
|
|
2529
|
+
android: {
|
|
2530
|
+
'-1': {
|
|
2531
|
+
map_to: RESPONSE.USER_DENIED
|
|
2532
|
+
}
|
|
2533
|
+
},
|
|
2534
|
+
iOS: {
|
|
2535
|
+
'-1': {
|
|
2536
|
+
map_to: RESPONSE.USER_DENIED
|
|
2537
|
+
}
|
|
2538
|
+
}
|
|
2539
|
+
}
|
|
2443
2540
|
},
|
|
2444
2541
|
QUERY_LOCATION_HIDE: {
|
|
2445
2542
|
name: 'action.query.location.hide',
|
|
@@ -2537,7 +2634,34 @@ const ACTION = {
|
|
|
2537
2634
|
},
|
|
2538
2635
|
SAVE_IMAGE_GALLERY: {
|
|
2539
2636
|
name: 'action.save.image.gallery',
|
|
2540
|
-
version_live: { iOS: 408 }
|
|
2637
|
+
version_live: { iOS: 408 },
|
|
2638
|
+
error_list: {
|
|
2639
|
+
android: {
|
|
2640
|
+
'-101': {
|
|
2641
|
+
map_to: {
|
|
2642
|
+
code: RESPONSE_CODE.SAVE_IMAGE_FAIL,
|
|
2643
|
+
message: MESSAGES.SAVE_IMAGE_FAIL
|
|
2644
|
+
},
|
|
2645
|
+
need_more_detail: true
|
|
2646
|
+
},
|
|
2647
|
+
'-102': {
|
|
2648
|
+
map_to: {
|
|
2649
|
+
code: RESPONSE_CODE.SAVE_IMAGE_FAIL,
|
|
2650
|
+
message: MESSAGES.SAVE_IMAGE_FAIL
|
|
2651
|
+
},
|
|
2652
|
+
need_more_detail: true
|
|
2653
|
+
}
|
|
2654
|
+
},
|
|
2655
|
+
iOS: {
|
|
2656
|
+
'-10': {
|
|
2657
|
+
map_to: {
|
|
2658
|
+
code: RESPONSE_CODE.SAVE_IMAGE_FAIL,
|
|
2659
|
+
message: MESSAGES.SAVE_IMAGE_FAIL
|
|
2660
|
+
},
|
|
2661
|
+
need_more_detail: true
|
|
2662
|
+
}
|
|
2663
|
+
}
|
|
2664
|
+
}
|
|
2541
2665
|
},
|
|
2542
2666
|
OPEN_MP: {
|
|
2543
2667
|
name: 'action.open.mp',
|
|
@@ -2558,11 +2682,41 @@ const ACTION = {
|
|
|
2558
2682
|
},
|
|
2559
2683
|
MP_GET_NUMBER: {
|
|
2560
2684
|
name: 'action.mp.get.number',
|
|
2561
|
-
version_live: { iOS: 416 }
|
|
2685
|
+
version_live: { iOS: 416 },
|
|
2686
|
+
error_list: {
|
|
2687
|
+
android: {
|
|
2688
|
+
'-1': {
|
|
2689
|
+
map_to: RESPONSE.USER_DENIED
|
|
2690
|
+
},
|
|
2691
|
+
'-101': {
|
|
2692
|
+
map_to: RESPONSE.USER_DENIED
|
|
2693
|
+
}
|
|
2694
|
+
},
|
|
2695
|
+
iOS: {
|
|
2696
|
+
'-1': {
|
|
2697
|
+
map_to: RESPONSE.USER_DENIED
|
|
2698
|
+
},
|
|
2699
|
+
'-10': {
|
|
2700
|
+
map_to: RESPONSE.USER_DENIED
|
|
2701
|
+
}
|
|
2702
|
+
}
|
|
2703
|
+
}
|
|
2562
2704
|
},
|
|
2563
2705
|
MP_OPEN_PROFILE_PICKER: {
|
|
2564
2706
|
name: 'action.mp.open.profile.picker',
|
|
2565
|
-
version_live: { iOS: 432 }
|
|
2707
|
+
version_live: { iOS: 432 },
|
|
2708
|
+
error_list: {
|
|
2709
|
+
android: {
|
|
2710
|
+
'-101': {
|
|
2711
|
+
map_to: RESPONSE.USER_CANCEL
|
|
2712
|
+
}
|
|
2713
|
+
},
|
|
2714
|
+
iOS: {
|
|
2715
|
+
'-101': {
|
|
2716
|
+
map_to: RESPONSE.USER_CANCEL
|
|
2717
|
+
}
|
|
2718
|
+
}
|
|
2719
|
+
}
|
|
2566
2720
|
},
|
|
2567
2721
|
GET_SUPPORTED_ACTIONS: {
|
|
2568
2722
|
name: 'action.get.supported.actions',
|
|
@@ -2576,32 +2730,45 @@ const ACTION = {
|
|
|
2576
2730
|
},
|
|
2577
2731
|
PICK_MEDIA: {
|
|
2578
2732
|
name: 'action.pick.media',
|
|
2579
|
-
version_live: { iOS: 440 }
|
|
2733
|
+
version_live: { iOS: 440 },
|
|
2734
|
+
error_list: {
|
|
2735
|
+
android: {
|
|
2736
|
+
'-101': {
|
|
2737
|
+
map_to: RESPONSE.USER_CANCEL
|
|
2738
|
+
},
|
|
2739
|
+
'999': {
|
|
2740
|
+
map_to: {
|
|
2741
|
+
code: RESPONSE_CODE.MEDIA_PICKER_FAIL,
|
|
2742
|
+
message: MESSAGES.MEDIA_PICKER_FAIL
|
|
2743
|
+
},
|
|
2744
|
+
need_more_detail: true
|
|
2745
|
+
}
|
|
2746
|
+
},
|
|
2747
|
+
iOS: {
|
|
2748
|
+
'-10': {
|
|
2749
|
+
map_to: {
|
|
2750
|
+
code: RESPONSE_CODE.MEDIA_PICKER_FAIL,
|
|
2751
|
+
message: MESSAGES.MEDIA_PICKER_FAIL
|
|
2752
|
+
}
|
|
2753
|
+
}
|
|
2754
|
+
}
|
|
2755
|
+
}
|
|
2580
2756
|
},
|
|
2581
2757
|
MP_CLOSE_LOADINGVIEW: {
|
|
2582
2758
|
name: 'action.mp.close.loadingview'
|
|
2583
2759
|
}
|
|
2584
2760
|
};
|
|
2585
|
-
const
|
|
2586
|
-
|
|
2587
|
-
|
|
2588
|
-
|
|
2589
|
-
|
|
2590
|
-
|
|
2591
|
-
|
|
2592
|
-
|
|
2593
|
-
|
|
2594
|
-
|
|
2595
|
-
|
|
2596
|
-
LOGIN_REQUIRED: 'Please login before to call this api. Read more at: https://miniapp.zalo.me/docs/api/login',
|
|
2597
|
-
LOGIN_FAILED: 'Login failed.',
|
|
2598
|
-
NOT_PERMISSION: `You don't have permission to call this api`,
|
|
2599
|
-
CLIENT_NOT_SUPPORT: `This API is not supported in this Zalo version`,
|
|
2600
|
-
DECODE_FAILED: 'Can not decode your data. Read more at: https://miniapp.zalo.me/docs/api/error'
|
|
2601
|
-
};
|
|
2602
|
-
const API_DOMAIN = 'https://h5.zalo.me/';
|
|
2603
|
-
const H5_API = {
|
|
2604
|
-
GET_APP_INFO: 'apps/get-info'
|
|
2761
|
+
const COMMON_NATIVE_ERROR_CODE = {
|
|
2762
|
+
android: {
|
|
2763
|
+
'-4': RESPONSE.DECODE_FAILED,
|
|
2764
|
+
'-5': RESPONSE.CLIENT_NOT_SUPPORT,
|
|
2765
|
+
'-14': RESPONSE.TIME_OUT
|
|
2766
|
+
},
|
|
2767
|
+
iOS: {
|
|
2768
|
+
'-9': RESPONSE.DECODE_FAILED,
|
|
2769
|
+
'-5': RESPONSE.CLIENT_NOT_SUPPORT,
|
|
2770
|
+
'-14': RESPONSE.TIME_OUT
|
|
2771
|
+
}
|
|
2605
2772
|
};
|
|
2606
2773
|
const ZALO_SUPPORT_STORAGE_VERSION = {
|
|
2607
2774
|
android: 12100571,
|
|
@@ -2713,124 +2880,36 @@ const PAYMENT_APIS = {
|
|
|
2713
2880
|
};
|
|
2714
2881
|
const PAYMENT_H5_URL = 'https://payment-mini.zalo.me';
|
|
2715
2882
|
|
|
2716
|
-
class
|
|
2883
|
+
class AppError {
|
|
2717
2884
|
constructor(code, msg, api) {
|
|
2718
2885
|
this.code = code;
|
|
2719
2886
|
this.message = msg;
|
|
2720
2887
|
this.api = api;
|
|
2721
2888
|
}
|
|
2722
2889
|
toString() {
|
|
2723
|
-
return `api: ${this.api}; code: ${this.code}; message: ${this.message}`;
|
|
2890
|
+
return `api: ${String(this.api)}; code: ${this.code}; message: ${this.message}`;
|
|
2724
2891
|
}
|
|
2725
|
-
|
|
2726
|
-
|
|
2727
|
-
|
|
2728
|
-
|
|
2729
|
-
|
|
2730
|
-
|
|
2731
|
-
}
|
|
2732
|
-
handler() {
|
|
2733
|
-
switch (this.code) {
|
|
2734
|
-
case NativeCode.token_invalid:
|
|
2735
|
-
this.code = RESPONSE_CODE.UNAUTHORIZED;
|
|
2736
|
-
this.message = MESSAGES.LOGIN_REQUIRED;
|
|
2737
|
-
break;
|
|
2738
|
-
case NativeCode.not_permission:
|
|
2739
|
-
this.code = RESPONSE_CODE.FORBIDDEN;
|
|
2740
|
-
this.message = MESSAGES.NOT_PERMISSION;
|
|
2741
|
-
break;
|
|
2742
|
-
case NativeCode.client_not_support:
|
|
2743
|
-
this.code = RESPONSE_CODE.CLIENT_NOT_SUPPORT;
|
|
2744
|
-
this.message = MESSAGES.CLIENT_NOT_SUPPORT;
|
|
2745
|
-
break;
|
|
2746
|
-
case NativeCode.decode_failed:
|
|
2747
|
-
this.message = MESSAGES.DECODE_FAILED;
|
|
2748
|
-
break;
|
|
2749
|
-
}
|
|
2892
|
+
toJSON() {
|
|
2893
|
+
return {
|
|
2894
|
+
code: this.code,
|
|
2895
|
+
message: this.message,
|
|
2896
|
+
api: this.api
|
|
2897
|
+
};
|
|
2750
2898
|
}
|
|
2751
2899
|
}
|
|
2752
|
-
const
|
|
2753
|
-
|
|
2754
|
-
|
|
2755
|
-
this.handler = handler;
|
|
2756
|
-
}
|
|
2900
|
+
const handleKnownExceptions = (error, api) => {
|
|
2901
|
+
error.api = api;
|
|
2902
|
+
return error.toJSON();
|
|
2757
2903
|
};
|
|
2758
|
-
const
|
|
2759
|
-
if (error instanceof
|
|
2760
|
-
error.
|
|
2761
|
-
return error;
|
|
2904
|
+
const handleUnknownExceptions = (error, api) => {
|
|
2905
|
+
if (error instanceof Error) {
|
|
2906
|
+
return new AppError(RESPONSE_CODE.UNKNOWN_ERROR, error.message, api).toJSON();
|
|
2762
2907
|
}
|
|
2763
|
-
return new
|
|
2764
|
-
};
|
|
2765
|
-
catchDecoratorStore.setHandler(errorHandler);
|
|
2766
|
-
const handleError = (target, propertyName, descriptor) => {
|
|
2767
|
-
const fn = descriptor.value;
|
|
2768
|
-
descriptor.value = function (...args) {
|
|
2769
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
2770
|
-
const { success, fail } = Array.isArray(args) && args.length > 0 && args[0];
|
|
2771
|
-
return new Promise((resolve, reject) => __awaiter(this, void 0, void 0, function* () {
|
|
2772
|
-
try {
|
|
2773
|
-
const res = yield fn.apply(this, args);
|
|
2774
|
-
if (!_.isNull(success) && _.isFunction(success)) {
|
|
2775
|
-
success.call(null, res, this);
|
|
2776
|
-
}
|
|
2777
|
-
else {
|
|
2778
|
-
resolve(res);
|
|
2779
|
-
}
|
|
2780
|
-
}
|
|
2781
|
-
catch (error) {
|
|
2782
|
-
if ((error === null || error === void 0 ? void 0 : error.api) !== 'login' && // login is not error
|
|
2783
|
-
((error === null || error === void 0 ? void 0 : error.code) === RESPONSE_CODE.UNAUTHORIZED ||
|
|
2784
|
-
(error === null || error === void 0 ? void 0 : error.code) === RESPONSE_CODE.FORBIDDEN)) {
|
|
2785
|
-
let loggedIn = false;
|
|
2786
|
-
if (this instanceof SDKCreator) {
|
|
2787
|
-
loggedIn = this.getLoginStatus();
|
|
2788
|
-
}
|
|
2789
|
-
if (!loggedIn) {
|
|
2790
|
-
error = new CommonError(RESPONSE_CODE.UNAUTHORIZED, MESSAGES.LOGIN_REQUIRED);
|
|
2791
|
-
}
|
|
2792
|
-
}
|
|
2793
|
-
const { handler } = catchDecoratorStore;
|
|
2794
|
-
const errorParsed = handler.call(null, propertyName, error, this);
|
|
2795
|
-
window.zmpSentry && window.zmpSentry.throwError(errorParsed.toString());
|
|
2796
|
-
if (!_.isNull(fail) && _.isFunction(fail)) {
|
|
2797
|
-
fail.call(null, errorParsed, this);
|
|
2798
|
-
}
|
|
2799
|
-
else {
|
|
2800
|
-
reject(errorParsed);
|
|
2801
|
-
}
|
|
2802
|
-
}
|
|
2803
|
-
}));
|
|
2804
|
-
});
|
|
2805
|
-
};
|
|
2806
|
-
return descriptor;
|
|
2908
|
+
return new AppError(RESPONSE_CODE.UNKNOWN_ERROR, MESSAGES.UNKNOWN_ERROR, api).toJSON();
|
|
2807
2909
|
};
|
|
2808
|
-
const
|
|
2809
|
-
|
|
2810
|
-
|
|
2811
|
-
try {
|
|
2812
|
-
return fn.apply(this, args);
|
|
2813
|
-
}
|
|
2814
|
-
catch (error) {
|
|
2815
|
-
if ((error === null || error === void 0 ? void 0 : error.api) !== 'login' && // login is not error
|
|
2816
|
-
((error === null || error === void 0 ? void 0 : error.code) === RESPONSE_CODE.UNAUTHORIZED ||
|
|
2817
|
-
(error === null || error === void 0 ? void 0 : error.code) === RESPONSE_CODE.FORBIDDEN)) {
|
|
2818
|
-
let loggedIn = false;
|
|
2819
|
-
if (this instanceof SDKCreator) {
|
|
2820
|
-
loggedIn = this.getLoginStatus();
|
|
2821
|
-
}
|
|
2822
|
-
if (!loggedIn) {
|
|
2823
|
-
error = new CommonError(RESPONSE_CODE.UNAUTHORIZED, MESSAGES.LOGIN_REQUIRED);
|
|
2824
|
-
}
|
|
2825
|
-
}
|
|
2826
|
-
const { handler } = catchDecoratorStore;
|
|
2827
|
-
const errorParsed = handler.call(null, key, error, this);
|
|
2828
|
-
window.zmpSentry && window.zmpSentry.throwError(errorParsed.toString());
|
|
2829
|
-
throw errorParsed;
|
|
2830
|
-
}
|
|
2831
|
-
};
|
|
2832
|
-
return descriptor;
|
|
2833
|
-
};
|
|
2910
|
+
const errorHandler = (error, api) => error instanceof AppError
|
|
2911
|
+
? handleKnownExceptions(error, api)
|
|
2912
|
+
: handleUnknownExceptions(error, api);
|
|
2834
2913
|
|
|
2835
2914
|
const apiResponse = {
|
|
2836
2915
|
success: (data, message) => ({
|
|
@@ -2839,13 +2918,13 @@ const apiResponse = {
|
|
|
2839
2918
|
data: data || {}
|
|
2840
2919
|
}),
|
|
2841
2920
|
error: {
|
|
2842
|
-
badRequest: (message) => new
|
|
2843
|
-
loginFailed: () => new
|
|
2844
|
-
loginRequired: () => new
|
|
2845
|
-
missingParam: (params) => new
|
|
2846
|
-
wrongTypeParam: (arg, expected, got) => new
|
|
2847
|
-
cannotGetShareInfo: () => new
|
|
2848
|
-
lengthInvalid: (arg) => new
|
|
2921
|
+
badRequest: (message) => new AppError(RESPONSE_CODE.BAD_REQUEST, message),
|
|
2922
|
+
loginFailed: (message) => new AppError(RESPONSE_CODE.UNAUTHORIZED, `${MESSAGES.LOGIN_FAILED}: ${message}`),
|
|
2923
|
+
loginRequired: () => new AppError(RESPONSE_CODE.UNAUTHORIZED, MESSAGES.LOGIN_REQUIRED),
|
|
2924
|
+
missingParam: (params) => new AppError(RESPONSE_CODE.BAD_REQUEST, `Missing required argument: ${params}`),
|
|
2925
|
+
wrongTypeParam: (arg, expected, got) => new AppError(RESPONSE_CODE.BAD_REQUEST, `Wrong type of parameter '${arg}'. Expected ${expected}, but got ${got}`),
|
|
2926
|
+
cannotGetShareInfo: () => new AppError(RESPONSE_CODE.INTERNAL_SERVER_ERROR, `Can not get app info to share`),
|
|
2927
|
+
lengthInvalid: (arg) => new AppError(RESPONSE_CODE.BAD_REQUEST, `${arg} length is invalid.`)
|
|
2849
2928
|
}
|
|
2850
2929
|
};
|
|
2851
2930
|
|
|
@@ -3260,7 +3339,7 @@ const getAppInfo = (appId, versionStatus, currentVersion) => __awaiter(void 0, v
|
|
|
3260
3339
|
if (!_.isUndefined(currentVersion)) {
|
|
3261
3340
|
inputData.currentVersion = currentVersion;
|
|
3262
3341
|
}
|
|
3263
|
-
const api = QueryString.appendToUrl(
|
|
3342
|
+
const api = QueryString.appendToUrl(APIS.GET_APP_INFO, inputData);
|
|
3264
3343
|
const msgApi = yield fetch(api, {
|
|
3265
3344
|
credentials: 'include'
|
|
3266
3345
|
});
|
|
@@ -3652,504 +3731,97 @@ class ZMPEEmitter extends eventemitter3 {
|
|
|
3652
3731
|
}
|
|
3653
3732
|
}
|
|
3654
3733
|
|
|
3655
|
-
var
|
|
3656
|
-
|
|
3657
|
-
|
|
3658
|
-
|
|
3659
|
-
|
|
3660
|
-
|
|
3661
|
-
|
|
3662
|
-
|
|
3663
|
-
|
|
3664
|
-
|
|
3665
|
-
|
|
3666
|
-
|
|
3667
|
-
wrappers[type] = fn;
|
|
3668
|
-
};
|
|
3669
|
-
var ERROR = {
|
|
3670
|
-
error: {
|
|
3671
|
-
code: 1,
|
|
3672
|
-
error_subcode: 1357046,
|
|
3673
|
-
message: 'Received Invalid JSON reply.',
|
|
3674
|
-
type: 'http'
|
|
3675
|
-
}
|
|
3676
|
-
};
|
|
3677
|
-
function safelyParseResponse(rawResponse) {
|
|
3678
|
-
try {
|
|
3679
|
-
return rawResponse === null ? ERROR : JSON.parse(rawResponse);
|
|
3680
|
-
}
|
|
3681
|
-
catch (ex) {
|
|
3682
|
-
return ERROR;
|
|
3734
|
+
var version$1 = "2.21.0";
|
|
3735
|
+
|
|
3736
|
+
class Basics {
|
|
3737
|
+
/**
|
|
3738
|
+
* Lấy version hiện tại của Zalo Mini Program SDK
|
|
3739
|
+
*
|
|
3740
|
+
* @category Basics
|
|
3741
|
+
*
|
|
3742
|
+
* @returns {string} Version hiện tại của Zalo Mini Program SDK.
|
|
3743
|
+
*/
|
|
3744
|
+
static getVersion() {
|
|
3745
|
+
return version$1;
|
|
3683
3746
|
}
|
|
3684
|
-
|
|
3685
|
-
|
|
3686
|
-
|
|
3687
|
-
|
|
3747
|
+
/**
|
|
3748
|
+
* Gets system information.
|
|
3749
|
+
*
|
|
3750
|
+
* @function getSystemInfo
|
|
3751
|
+
* @category Basics
|
|
3752
|
+
*
|
|
3753
|
+
*
|
|
3754
|
+
*
|
|
3755
|
+
*/
|
|
3756
|
+
static getSystemInfo() {
|
|
3757
|
+
const system = {
|
|
3758
|
+
version: getMetaValue('version-id') || '',
|
|
3759
|
+
apiVersion: version$1,
|
|
3760
|
+
zaloVersion: getZaloVersion(),
|
|
3761
|
+
platform: getPlatform(),
|
|
3762
|
+
language: navigator.language,
|
|
3763
|
+
zaloLanguage: window.zLanguage || 'vi',
|
|
3764
|
+
zaloTheme: window.zTheme || 'light'
|
|
3765
|
+
};
|
|
3766
|
+
return system;
|
|
3688
3767
|
}
|
|
3689
|
-
|
|
3690
|
-
|
|
3691
|
-
|
|
3692
|
-
|
|
3693
|
-
|
|
3768
|
+
/**
|
|
3769
|
+
* Lấy thông tin mini app
|
|
3770
|
+
*
|
|
3771
|
+
* @async
|
|
3772
|
+
* @function getAppInfo
|
|
3773
|
+
* @category Device
|
|
3774
|
+
*
|
|
3775
|
+
*/
|
|
3776
|
+
static getAppInfo() {
|
|
3777
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
3778
|
+
const appId = this.getAppId();
|
|
3779
|
+
const systemInfo = this.getSystemInfo();
|
|
3780
|
+
return yield getAppInfo(appId, 0, systemInfo.version);
|
|
3781
|
+
});
|
|
3694
3782
|
}
|
|
3695
|
-
|
|
3696
|
-
|
|
3697
|
-
|
|
3698
|
-
|
|
3699
|
-
|
|
3700
|
-
|
|
3701
|
-
|
|
3702
|
-
|
|
3703
|
-
|
|
3704
|
-
|
|
3705
|
-
|
|
3706
|
-
|
|
3707
|
-
|
|
3708
|
-
|
|
3709
|
-
|
|
3710
|
-
|
|
3711
|
-
|
|
3712
|
-
|
|
3713
|
-
|
|
3714
|
-
|
|
3715
|
-
|
|
3716
|
-
|
|
3717
|
-
|
|
3718
|
-
|
|
3719
|
-
|
|
3720
|
-
|
|
3721
|
-
|
|
3722
|
-
|
|
3723
|
-
|
|
3724
|
-
|
|
3725
|
-
|
|
3726
|
-
|
|
3727
|
-
|
|
3728
|
-
|
|
3729
|
-
|
|
3730
|
-
|
|
3731
|
-
|
|
3732
|
-
|
|
3733
|
-
|
|
3734
|
-
|
|
3735
|
-
|
|
3736
|
-
|
|
3737
|
-
url = QueryString.appendToUrl(url, data);
|
|
3738
|
-
data = '';
|
|
3739
|
-
}
|
|
3740
|
-
var request = createCORSRequest(method, url);
|
|
3741
|
-
if (!request) {
|
|
3742
|
-
return false;
|
|
3743
|
-
}
|
|
3744
|
-
request.onload = function (xhr) {
|
|
3745
|
-
cb(safelyParseResponse(xhr.responseText));
|
|
3746
|
-
};
|
|
3747
|
-
request.onerror = function (xhr) {
|
|
3748
|
-
if (xhr.responseText) {
|
|
3749
|
-
cb(safelyParseResponse(xhr.responseText));
|
|
3750
|
-
}
|
|
3751
|
-
else {
|
|
3752
|
-
cb({
|
|
3753
|
-
error: {
|
|
3754
|
-
code: 1,
|
|
3755
|
-
error_subcode: 1357045,
|
|
3756
|
-
message: 'unknown error (empty response)',
|
|
3757
|
-
status: xhr.status,
|
|
3758
|
-
type: 'http'
|
|
3759
|
-
}
|
|
3760
|
-
});
|
|
3761
|
-
}
|
|
3762
|
-
};
|
|
3763
|
-
request.send(data);
|
|
3764
|
-
return true;
|
|
3765
|
-
}
|
|
3766
|
-
var CORSRequest = {
|
|
3767
|
-
execute: execute
|
|
3768
|
-
};
|
|
3769
|
-
|
|
3770
|
-
class ZaloJSBridge extends eventemitter3 {
|
|
3771
|
-
constructor() {
|
|
3772
|
-
super();
|
|
3773
|
-
this.debug = Debug('zmp:ZaloJSBridge');
|
|
3774
|
-
this.events = ZMPEEmitter.getInstance();
|
|
3775
|
-
this._accessTk = getToken('zacc_session') || 'DEFAULT_ACCESS_TOKEN';
|
|
3776
|
-
this._jsAccessTk = getToken('zlink3rd') || 'DEFAULT_JS_TOKEN';
|
|
3777
|
-
this.results = [];
|
|
3778
|
-
this._userAgent = getUserAgent();
|
|
3779
|
-
this._device = checkPlatform();
|
|
3780
|
-
this._jsCallFuncCallbacks = {};
|
|
3781
|
-
this.events.on(Events.AppPaused, () => {
|
|
3782
|
-
if (this.results.length > 0) {
|
|
3783
|
-
let array = this.results;
|
|
3784
|
-
this.results = [];
|
|
3785
|
-
try {
|
|
3786
|
-
this.sendLogData(array);
|
|
3787
|
-
}
|
|
3788
|
-
catch (error) { }
|
|
3789
|
-
}
|
|
3790
|
-
});
|
|
3791
|
-
if (this.sendLogTimer) {
|
|
3792
|
-
clearInterval(this.sendLogTimer);
|
|
3793
|
-
}
|
|
3794
|
-
else {
|
|
3795
|
-
this.sendLogTimer = setInterval(() => {
|
|
3796
|
-
if (this.results.length > 0) {
|
|
3797
|
-
let array = this.results;
|
|
3798
|
-
this.results = [];
|
|
3799
|
-
try {
|
|
3800
|
-
this.sendLogData(array);
|
|
3801
|
-
}
|
|
3802
|
-
catch (error) { }
|
|
3803
|
-
}
|
|
3804
|
-
}, 5000);
|
|
3805
|
-
}
|
|
3806
|
-
}
|
|
3807
|
-
static getInstance() {
|
|
3808
|
-
if (!ZaloJSBridge.instance) {
|
|
3809
|
-
ZaloJSBridge.instance = new ZaloJSBridge();
|
|
3810
|
-
}
|
|
3811
|
-
return ZaloJSBridge.instance;
|
|
3812
|
-
}
|
|
3813
|
-
set accessTk(value) {
|
|
3814
|
-
this._accessTk = value;
|
|
3815
|
-
}
|
|
3816
|
-
set jsAccessTk(value) {
|
|
3817
|
-
this._jsAccessTk = value;
|
|
3818
|
-
}
|
|
3819
|
-
sendLogData(data) {
|
|
3820
|
-
try {
|
|
3821
|
-
CORSRequest.execute('https://h5.zalo.me/log/async', 'post', {
|
|
3822
|
-
appId: window.APP_ID,
|
|
3823
|
-
data: JSON.stringify(data)
|
|
3824
|
-
}, (response) => { });
|
|
3825
|
-
}
|
|
3826
|
-
catch (error) { }
|
|
3827
|
-
}
|
|
3828
|
-
onJSCall(key, data) {
|
|
3829
|
-
try {
|
|
3830
|
-
this.debug('onJSCall', key, data);
|
|
3831
|
-
const parsedData = parseJSON(data);
|
|
3832
|
-
if (this._jsCallFuncCallbacks[key]) {
|
|
3833
|
-
const callback = this._jsCallFuncCallbacks[key].callback;
|
|
3834
|
-
const timeout = this._jsCallFuncCallbacks[key].timeout;
|
|
3835
|
-
if (!!callback) {
|
|
3836
|
-
try {
|
|
3837
|
-
callback.call(this, parsedData);
|
|
3838
|
-
}
|
|
3839
|
-
catch (error) {
|
|
3840
|
-
console.error('Call callback error', error);
|
|
3841
|
-
}
|
|
3842
|
-
!!timeout && clearTimeout(timeout);
|
|
3843
|
-
this._jsCallFuncCallbacks[key] = null;
|
|
3844
|
-
delete this._jsCallFuncCallbacks[key];
|
|
3845
|
-
}
|
|
3846
|
-
}
|
|
3847
|
-
this.results.push({
|
|
3848
|
-
action: parsedData.action,
|
|
3849
|
-
error: parsedData.error_code
|
|
3850
|
-
});
|
|
3851
|
-
}
|
|
3852
|
-
catch (e) {
|
|
3853
|
-
console.log('onJSCall', 'error', e);
|
|
3854
|
-
}
|
|
3855
|
-
}
|
|
3856
|
-
onMultiJSCall(key, data) {
|
|
3857
|
-
try {
|
|
3858
|
-
this.debug('onMultiJSCall', key, data);
|
|
3859
|
-
const parsedData = parseJSON(data);
|
|
3860
|
-
if (this._jsCallFuncCallbacks[key]) {
|
|
3861
|
-
const callback = this._jsCallFuncCallbacks[key].callback;
|
|
3862
|
-
const timeout = this._jsCallFuncCallbacks[key].timeout;
|
|
3863
|
-
if (!!callback) {
|
|
3864
|
-
try {
|
|
3865
|
-
callback.call(this, parsedData);
|
|
3866
|
-
}
|
|
3867
|
-
catch (error) {
|
|
3868
|
-
console.error('Call callback error', error);
|
|
3869
|
-
}
|
|
3870
|
-
!!timeout && clearTimeout(timeout);
|
|
3871
|
-
}
|
|
3872
|
-
}
|
|
3873
|
-
this.results.push({
|
|
3874
|
-
action: parsedData.action,
|
|
3875
|
-
error: parsedData.error_code
|
|
3876
|
-
});
|
|
3877
|
-
}
|
|
3878
|
-
catch (e) {
|
|
3879
|
-
console.log('onMultiJSCall', 'error', e);
|
|
3880
|
-
}
|
|
3881
|
-
}
|
|
3882
|
-
nativeEventHandler(eventId, eventName, eventData) {
|
|
3883
|
-
this.debug(`eventId: ${eventId}, eventName: ${eventName}, eventData: ${eventData}`);
|
|
3884
|
-
const data = stringToData(eventData);
|
|
3885
|
-
this.debug(data);
|
|
3886
|
-
const convertedData = this.handleEventData(eventName, data);
|
|
3887
|
-
this.events.emit(eventName, eventId, convertedData);
|
|
3888
|
-
}
|
|
3889
|
-
handleEventData(eventName, data) {
|
|
3890
|
-
try {
|
|
3891
|
-
switch (eventName) {
|
|
3892
|
-
case Events.OpenApp:
|
|
3893
|
-
const { url } = data;
|
|
3894
|
-
const validUrl = new URL(url);
|
|
3895
|
-
const path = validUrl.pathname.split(`/zapps/${APP_ID}`)[1];
|
|
3896
|
-
return {
|
|
3897
|
-
path: `${path ? path : '/'}${validUrl.search}`
|
|
3898
|
-
};
|
|
3899
|
-
break;
|
|
3900
|
-
default:
|
|
3901
|
-
return data;
|
|
3902
|
-
break;
|
|
3903
|
-
}
|
|
3904
|
-
}
|
|
3905
|
-
catch (error) {
|
|
3906
|
-
return data;
|
|
3907
|
-
}
|
|
3908
|
-
}
|
|
3909
|
-
defaultCallback(data) {
|
|
3910
|
-
if (data !== null && data !== undefined) {
|
|
3911
|
-
data = parseJSON(data);
|
|
3912
|
-
}
|
|
3913
|
-
}
|
|
3914
|
-
jsCall(action, options, callback, isMultiCallback = false, nRetry = 3, haveTimeout = true) {
|
|
3915
|
-
try {
|
|
3916
|
-
const actionName = action.name;
|
|
3917
|
-
const key = generateUniqueString(actionName);
|
|
3918
|
-
if (!this._device.isMobile || _.isEmpty(actionName)) {
|
|
3919
|
-
this.onJSCall(key, {
|
|
3920
|
-
error_code: -13,
|
|
3921
|
-
error_message: 'params invalid!',
|
|
3922
|
-
data: {
|
|
3923
|
-
device: this._device.isMobile,
|
|
3924
|
-
jsToken: this._jsAccessTk,
|
|
3925
|
-
access_token: this._accessTk
|
|
3926
|
-
},
|
|
3927
|
-
action: actionName
|
|
3928
|
-
});
|
|
3929
|
-
return false;
|
|
3930
|
-
}
|
|
3931
|
-
if (options === undefined || options === null) {
|
|
3932
|
-
options = {};
|
|
3933
|
-
}
|
|
3934
|
-
if (!callback) {
|
|
3935
|
-
callback = this.defaultCallback;
|
|
3936
|
-
}
|
|
3937
|
-
const timeoutCallback = {
|
|
3938
|
-
error_code: -14,
|
|
3939
|
-
error_message: 'Request Timeout!',
|
|
3940
|
-
data: {},
|
|
3941
|
-
action: actionName
|
|
3942
|
-
};
|
|
3943
|
-
this._jsCallFuncCallbacks[key] = {
|
|
3944
|
-
timeout: haveTimeout &&
|
|
3945
|
-
action.have_callback &&
|
|
3946
|
-
setTimeout(() => {
|
|
3947
|
-
this.onJSCall(key, timeoutCallback);
|
|
3948
|
-
}, 8000),
|
|
3949
|
-
callback: callback
|
|
3950
|
-
};
|
|
3951
|
-
try {
|
|
3952
|
-
options = serialize(options);
|
|
3953
|
-
if (isMultiCallback) {
|
|
3954
|
-
if (this._device.isIOS) {
|
|
3955
|
-
return ZaloJavaScriptInterface.jsCall(this._jsAccessTk, actionName, this._accessTk, options, window.onMultiJSCall(key));
|
|
3956
|
-
}
|
|
3957
|
-
return ZaloJavaScriptInterface.jsCall(this._jsAccessTk, actionName, this._accessTk, options, `window.onMultiJSCall('${key}')`);
|
|
3958
|
-
}
|
|
3959
|
-
if (this._device.isIOS) {
|
|
3960
|
-
return ZaloJavaScriptInterface.jsCall(this._jsAccessTk, actionName, this._accessTk, options, window.onJSCall(key));
|
|
3961
|
-
}
|
|
3962
|
-
return ZaloJavaScriptInterface.jsCall(this._jsAccessTk, actionName, this._accessTk, options, `window.onJSCall('${key}')`);
|
|
3963
|
-
}
|
|
3964
|
-
catch (error) {
|
|
3965
|
-
if (nRetry-- > 0) {
|
|
3966
|
-
setTimeout(() => {
|
|
3967
|
-
this.jsCall(action, options, callback, isMultiCallback, nRetry);
|
|
3968
|
-
}, 500);
|
|
3969
|
-
}
|
|
3970
|
-
else {
|
|
3971
|
-
const errorCallback = {
|
|
3972
|
-
error_code: -5,
|
|
3973
|
-
error_message: 'Not ready!',
|
|
3974
|
-
data: {
|
|
3975
|
-
userAgent: this._userAgent,
|
|
3976
|
-
options: options,
|
|
3977
|
-
jsToken: this._jsAccessTk,
|
|
3978
|
-
access_token: this._accessTk
|
|
3979
|
-
},
|
|
3980
|
-
action: actionName,
|
|
3981
|
-
js_error: error
|
|
3982
|
-
};
|
|
3983
|
-
this.onJSCall(key, errorCallback);
|
|
3984
|
-
return false;
|
|
3985
|
-
}
|
|
3986
|
-
}
|
|
3987
|
-
}
|
|
3988
|
-
catch (error) {
|
|
3989
|
-
console.log('jsCall', 'error', error);
|
|
3990
|
-
}
|
|
3991
|
-
return false;
|
|
3992
|
-
}
|
|
3993
|
-
}
|
|
3994
|
-
|
|
3995
|
-
var _ZJSBridgeProvider_bridge;
|
|
3996
|
-
/** @ignore */
|
|
3997
|
-
class ZJSBridgeProvider {
|
|
3998
|
-
/** @ignore */
|
|
3999
|
-
constructor() {
|
|
4000
|
-
this.debug = Debug('zmp:ZJSBridgeProvider');
|
|
4001
|
-
_ZJSBridgeProvider_bridge.set(this, void 0);
|
|
4002
|
-
__classPrivateFieldSet(this, _ZJSBridgeProvider_bridge, ZaloJSBridge.getInstance(), "f");
|
|
4003
|
-
}
|
|
4004
|
-
setZAccSession(value) {
|
|
4005
|
-
__classPrivateFieldGet(this, _ZJSBridgeProvider_bridge, "f").accessTk = value;
|
|
4006
|
-
}
|
|
4007
|
-
setJSToken(value) {
|
|
4008
|
-
__classPrivateFieldGet(this, _ZJSBridgeProvider_bridge, "f").jsAccessTk = value;
|
|
4009
|
-
}
|
|
4010
|
-
callNative(action, data, option) {
|
|
4011
|
-
this.debug(action.name, data);
|
|
4012
|
-
return new Promise((resolve, reject) => {
|
|
4013
|
-
const fn = (cb) => __awaiter(this, void 0, void 0, function* () {
|
|
4014
|
-
try {
|
|
4015
|
-
const error = new NativeError(cb.error_code, `${cb.action}: ${cb.error_message}`);
|
|
4016
|
-
if (option === null || option === void 0 ? void 0 : option.callback) {
|
|
4017
|
-
const res = yield option.callback(cb, error);
|
|
4018
|
-
return resolve(res);
|
|
4019
|
-
}
|
|
4020
|
-
else {
|
|
4021
|
-
if (cb && cb.error_code >= 0) {
|
|
4022
|
-
resolve(cb.data || {});
|
|
4023
|
-
}
|
|
4024
|
-
else if (cb && cb.error_code < 0) {
|
|
4025
|
-
try {
|
|
4026
|
-
window.zmpSentry &&
|
|
4027
|
-
window.zmpSentry.captureMessage(`${action.name}: call native fail`, {
|
|
4028
|
-
extra: {
|
|
4029
|
-
data: data,
|
|
4030
|
-
rs: cb
|
|
4031
|
-
}
|
|
4032
|
-
});
|
|
4033
|
-
}
|
|
4034
|
-
catch (error) { }
|
|
4035
|
-
return reject(error);
|
|
4036
|
-
}
|
|
4037
|
-
}
|
|
4038
|
-
}
|
|
4039
|
-
catch (error) {
|
|
4040
|
-
return reject(error);
|
|
4041
|
-
}
|
|
4042
|
-
});
|
|
4043
|
-
const isIOS = checkPlatform().isIOS;
|
|
4044
|
-
const isSupportAction = checkIOSSupportAction(action);
|
|
4045
|
-
if (isIOS && !isSupportAction) {
|
|
4046
|
-
const error = new NativeError(-5, `${action}: Client isn't support this action`);
|
|
4047
|
-
return reject(error);
|
|
4048
|
-
}
|
|
4049
|
-
else if (option === null || option === void 0 ? void 0 : option.delay) {
|
|
4050
|
-
setTimeout(() => {
|
|
4051
|
-
__classPrivateFieldGet(this, _ZJSBridgeProvider_bridge, "f").jsCall(action, data, fn, option === null || option === void 0 ? void 0 : option.isMultiCallback, option === null || option === void 0 ? void 0 : option.nRetry, option === null || option === void 0 ? void 0 : option.haveTimeout);
|
|
4052
|
-
}, option.delay);
|
|
4053
|
-
}
|
|
4054
|
-
else {
|
|
4055
|
-
__classPrivateFieldGet(this, _ZJSBridgeProvider_bridge, "f").jsCall(action, data, fn, option === null || option === void 0 ? void 0 : option.isMultiCallback, option === null || option === void 0 ? void 0 : option.nRetry, option === null || option === void 0 ? void 0 : option.haveTimeout);
|
|
4056
|
-
}
|
|
4057
|
-
});
|
|
4058
|
-
}
|
|
4059
|
-
}
|
|
4060
|
-
_ZJSBridgeProvider_bridge = new WeakMap();
|
|
4061
|
-
|
|
4062
|
-
var version$1 = "2.19.2";
|
|
4063
|
-
|
|
4064
|
-
class Basics {
|
|
4065
|
-
/**
|
|
4066
|
-
* Lấy version hiện tại của Zalo Mini Program SDK
|
|
4067
|
-
*
|
|
4068
|
-
* @category Basics
|
|
4069
|
-
*
|
|
4070
|
-
* @returns {string} Version hiện tại của Zalo Mini Program SDK.
|
|
4071
|
-
*/
|
|
4072
|
-
static getVersion() {
|
|
4073
|
-
return version$1;
|
|
4074
|
-
}
|
|
4075
|
-
/**
|
|
4076
|
-
* Gets system information.
|
|
4077
|
-
*
|
|
4078
|
-
* @function getSystemInfo
|
|
4079
|
-
* @category Basics
|
|
4080
|
-
*
|
|
4081
|
-
*
|
|
4082
|
-
*
|
|
4083
|
-
*/
|
|
4084
|
-
static getSystemInfo() {
|
|
4085
|
-
const system = {
|
|
4086
|
-
version: getMetaValue('version-id') || '',
|
|
4087
|
-
apiVersion: version$1,
|
|
4088
|
-
zaloVersion: getZaloVersion(),
|
|
4089
|
-
platform: getPlatform(),
|
|
4090
|
-
language: navigator.language,
|
|
4091
|
-
zaloLanguage: window.zLanguage || 'vi',
|
|
4092
|
-
zaloTheme: window.zTheme || 'light'
|
|
4093
|
-
};
|
|
4094
|
-
return system;
|
|
4095
|
-
}
|
|
4096
|
-
/**
|
|
4097
|
-
* Lấy thông tin mini app
|
|
4098
|
-
*
|
|
4099
|
-
* @async
|
|
4100
|
-
* @function getAppInfo
|
|
4101
|
-
* @category Device
|
|
4102
|
-
*
|
|
4103
|
-
*/
|
|
4104
|
-
static getAppInfo() {
|
|
4105
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
4106
|
-
const appId = this.getAppId();
|
|
4107
|
-
const systemInfo = this.getSystemInfo();
|
|
4108
|
-
return yield getAppInfo(appId, 0, systemInfo.version);
|
|
4109
|
-
});
|
|
4110
|
-
}
|
|
4111
|
-
}
|
|
4112
|
-
|
|
4113
|
-
class NavigationBar {
|
|
4114
|
-
/**
|
|
4115
|
-
* A promise for the user's favorite color.
|
|
4116
|
-
*
|
|
4117
|
-
* @promise FavoriteColorPromise
|
|
4118
|
-
* @fulfill {string} The user's favorite color.
|
|
4119
|
-
* @reject {TypeError} The user's favorite color is an invalid type.
|
|
4120
|
-
* @reject {MissingColorError} The user has not specified a favorite color.
|
|
4121
|
-
*/
|
|
4122
|
-
/**
|
|
4123
|
-
* Dynamically sets the title of the current page.
|
|
4124
|
-
*
|
|
4125
|
-
* @async
|
|
4126
|
-
* @function setNavigationBarTitle
|
|
4127
|
-
* @category Navigation Bar
|
|
4128
|
-
*
|
|
4129
|
-
* @example
|
|
4130
|
-
*
|
|
4131
|
-
* zmpApis.setNavigationBarTitle({
|
|
4132
|
-
* title: "Current Page"
|
|
4133
|
-
* }).then((res) => {
|
|
4134
|
-
* console.log("Success");
|
|
4135
|
-
* }).catch((error) => {
|
|
4136
|
-
* console.log("Fail");
|
|
4137
|
-
* });
|
|
4138
|
-
*
|
|
4139
|
-
* @param {Object} object
|
|
4140
|
-
* @param {string} object.title - The title of the page
|
|
4141
|
-
*
|
|
4142
|
-
* @return {Promise}
|
|
4143
|
-
*
|
|
4144
|
-
*/
|
|
4145
|
-
static setNavigationBarTitle(object) {
|
|
4146
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
4147
|
-
yield this.callNative(ACTION.CHANGE_TITLE_HEADER, {
|
|
4148
|
-
title: object.title
|
|
4149
|
-
}, {
|
|
4150
|
-
haveTimeout: false
|
|
4151
|
-
});
|
|
4152
|
-
});
|
|
3783
|
+
}
|
|
3784
|
+
|
|
3785
|
+
class NavigationBar {
|
|
3786
|
+
/**
|
|
3787
|
+
* A promise for the user's favorite color.
|
|
3788
|
+
*
|
|
3789
|
+
* @promise FavoriteColorPromise
|
|
3790
|
+
* @fulfill {string} The user's favorite color.
|
|
3791
|
+
* @reject {TypeError} The user's favorite color is an invalid type.
|
|
3792
|
+
* @reject {MissingColorError} The user has not specified a favorite color.
|
|
3793
|
+
*/
|
|
3794
|
+
/**
|
|
3795
|
+
* Dynamically sets the title of the current page.
|
|
3796
|
+
*
|
|
3797
|
+
* @async
|
|
3798
|
+
* @function setNavigationBarTitle
|
|
3799
|
+
* @category Navigation Bar
|
|
3800
|
+
*
|
|
3801
|
+
* @example
|
|
3802
|
+
*
|
|
3803
|
+
* zmpApis.setNavigationBarTitle({
|
|
3804
|
+
* title: "Current Page"
|
|
3805
|
+
* }).then((res) => {
|
|
3806
|
+
* console.log("Success");
|
|
3807
|
+
* }).catch((error) => {
|
|
3808
|
+
* console.log("Fail");
|
|
3809
|
+
* });
|
|
3810
|
+
*
|
|
3811
|
+
* @param {Object} object
|
|
3812
|
+
* @param {string} object.title - The title of the page
|
|
3813
|
+
*
|
|
3814
|
+
* @return {Promise}
|
|
3815
|
+
*
|
|
3816
|
+
*/
|
|
3817
|
+
static setNavigationBarTitle(object) {
|
|
3818
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
3819
|
+
yield this.getJSBridge().callNative(ACTION.CHANGE_TITLE_HEADER, {
|
|
3820
|
+
title: object.title
|
|
3821
|
+
}, {
|
|
3822
|
+
haveTimeout: false
|
|
3823
|
+
});
|
|
3824
|
+
});
|
|
4153
3825
|
}
|
|
4154
3826
|
/**
|
|
4155
3827
|
* Sets the color of the navigation bar in the page.
|
|
@@ -4192,7 +3864,7 @@ class NavigationBar {
|
|
|
4192
3864
|
actionBarType = HIDE_ACTION_BAR;
|
|
4193
3865
|
}
|
|
4194
3866
|
this.setActionBarConfig((state) => (Object.assign(Object.assign({}, state), { actionbarType: actionBarType, dataConfig: Object.assign(Object.assign({}, state.dataConfig), dataConfig) })));
|
|
4195
|
-
yield this.callNative(ACTION.CHANGE_ACTIONBAR, Object.assign({}, this.getActionBarConfig()), {
|
|
3867
|
+
yield this.getJSBridge().callNative(ACTION.CHANGE_ACTIONBAR, Object.assign({}, this.getActionBarConfig()), {
|
|
4196
3868
|
haveTimeout: false
|
|
4197
3869
|
});
|
|
4198
3870
|
});
|
|
@@ -4227,62 +3899,32 @@ class NavigationBar {
|
|
|
4227
3899
|
* @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
|
|
4228
3900
|
* @param {Function} [object.handleCloseEvent] - Specifies a function that will be called when user click close button. Only when ```confirmToExit``` is 2
|
|
4229
3901
|
*/
|
|
4230
|
-
static setNavigationBarLeftButton(
|
|
4231
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
4232
|
-
|
|
4233
|
-
|
|
4234
|
-
|
|
4235
|
-
|
|
4236
|
-
|
|
4237
|
-
|
|
4238
|
-
|
|
4239
|
-
|
|
3902
|
+
static setNavigationBarLeftButton(type, confirmToExit) {
|
|
3903
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
3904
|
+
let leftButtonType;
|
|
3905
|
+
let showHomeButton;
|
|
3906
|
+
if (_.isString(type)) {
|
|
3907
|
+
leftButtonType =
|
|
3908
|
+
type === 'none' || type === 'home'
|
|
3909
|
+
? ACTION_LEFT_BUTTON_TYPE.HIDE_BACK
|
|
3910
|
+
: ACTION_LEFT_BUTTON_TYPE.SHOW_BACK;
|
|
3911
|
+
showHomeButton =
|
|
3912
|
+
type === 'home' || type === 'both'
|
|
3913
|
+
? ACTION_LEFT_BUTTON_TYPE.SHOW_HOME
|
|
3914
|
+
: ACTION_LEFT_BUTTON_TYPE.HIDE_HOME;
|
|
3915
|
+
}
|
|
3916
|
+
this.setActionBarConfig((state) => (Object.assign(Object.assign({}, state), { buttonType: _.isNumber(leftButtonType) ? leftButtonType : state.buttonType, dataConfig: Object.assign(Object.assign({}, state.dataConfig), { confirmToExit: _.isNumber(confirmToExit) ? confirmToExit : state.dataConfig.confirmToExit, viewInLeftType: _.isNumber(leftButtonType) ? leftButtonType : state.dataConfig.viewInLeftType }), homeConfig: Object.assign(Object.assign({}, state.homeConfig), { enable: _.isNumber(showHomeButton) ? showHomeButton : state.homeConfig.enable }) })));
|
|
3917
|
+
yield this.getJSBridge().callNative(ACTION.CHANGE_ACTIONBAR_LEFTBUTTON_TYPE, Object.assign({}, this.getActionBarConfig()), {
|
|
4240
3918
|
haveTimeout: false
|
|
4241
3919
|
});
|
|
4242
3920
|
});
|
|
4243
3921
|
}
|
|
4244
|
-
|
|
4245
|
-
* @ignore
|
|
4246
|
-
* Dynamically sets the right button of the current page.
|
|
4247
|
-
*
|
|
4248
|
-
* @ignore
|
|
4249
|
-
* @category Navigation Bar
|
|
4250
|
-
*
|
|
4251
|
-
* @example
|
|
4252
|
-
* zmpApis.setNavigationBarRightButton({
|
|
4253
|
-
* supportToolBar: 1,
|
|
4254
|
-
* reset: 0,
|
|
4255
|
-
* menuListItems: [{
|
|
4256
|
-
* title: "Post on timeline",
|
|
4257
|
-
* action: "zalo.web.internal.postfeed",
|
|
4258
|
-
* showAsAction: 0,
|
|
4259
|
-
* iconUrl: "https://cdn3.iconfinder.com/data/icons/user-interface-3-3/34/251-512.png",
|
|
4260
|
-
* type: 0,
|
|
4261
|
-
* data: {}
|
|
4262
|
-
* }],
|
|
4263
|
-
* }).then((res) => {
|
|
4264
|
-
* console.log("Success");
|
|
4265
|
-
* }).catch((error) => {
|
|
4266
|
-
* console.log("Fail");
|
|
4267
|
-
* });
|
|
4268
|
-
*
|
|
4269
|
-
* @param {Object} object
|
|
4270
|
-
* @param {Number} object.title - Title of a menu item
|
|
4271
|
-
* @param {Number} object.action - Native action
|
|
4272
|
-
* @param {string} object.showAsAction
|
|
4273
|
-
* If ```showAsAction``` is 1 and ```iconUrl``` can load,
|
|
4274
|
-
* this item will be shown outside and next to more-button. Maximum 2 item will be shown
|
|
4275
|
-
* @param {Function} object.iconUrl - Specifies icon of a menu item
|
|
4276
|
-
* @param {0} object.type
|
|
4277
|
-
* @param {Object} object.data - Data depends on ```action```
|
|
4278
|
-
*/
|
|
4279
|
-
static setNavigationBarRightButton(object) {
|
|
3922
|
+
static setNavigationBar(data) {
|
|
4280
3923
|
return __awaiter(this, void 0, void 0, function* () {
|
|
4281
|
-
yield this.callNative(ACTION.
|
|
4282
|
-
|
|
4283
|
-
|
|
4284
|
-
|
|
4285
|
-
zapp: this.getAppId()
|
|
3924
|
+
yield this.getJSBridge().callNative(ACTION.CHANGE_ACTIONBAR, {
|
|
3925
|
+
data
|
|
3926
|
+
}, {
|
|
3927
|
+
haveTimeout: false
|
|
4286
3928
|
});
|
|
4287
3929
|
});
|
|
4288
3930
|
}
|
|
@@ -4314,7 +3956,7 @@ class Background {
|
|
|
4314
3956
|
return __awaiter(this, void 0, void 0, function* () {
|
|
4315
3957
|
if (_.isString(object.backgroundColor) &&
|
|
4316
3958
|
object.backgroundColor.length > 0) {
|
|
4317
|
-
yield this.callNative(ACTION.CHANGE_ACTIONBAR, {
|
|
3959
|
+
yield this.getJSBridge().callNative(ACTION.CHANGE_ACTIONBAR, {
|
|
4318
3960
|
actionbarType: this.isShowNavBar ? 5 : 6,
|
|
4319
3961
|
dataConfig: {
|
|
4320
3962
|
backgroundColor: object.backgroundColor,
|
|
@@ -4426,7 +4068,7 @@ class Device {
|
|
|
4426
4068
|
*/
|
|
4427
4069
|
static setDeviceOrientation(object) {
|
|
4428
4070
|
return __awaiter(this, void 0, void 0, function* () {
|
|
4429
|
-
yield this.callNative(ACTION.CHANGE_AUTOROTATE, {
|
|
4071
|
+
yield this.getJSBridge().callNative(ACTION.CHANGE_AUTOROTATE, {
|
|
4430
4072
|
autoRotate: OrientationType[object.rotate]
|
|
4431
4073
|
});
|
|
4432
4074
|
});
|
|
@@ -4450,7 +4092,7 @@ class Device {
|
|
|
4450
4092
|
*/
|
|
4451
4093
|
static getNetworkType(object) {
|
|
4452
4094
|
return __awaiter(this, void 0, void 0, function* () {
|
|
4453
|
-
const resData = yield this.callNative(ACTION.WEBVIEW_NETWORKTYPE, {
|
|
4095
|
+
const resData = yield this.getJSBridge().callNative(ACTION.WEBVIEW_NETWORKTYPE, {
|
|
4454
4096
|
url: window.location.href,
|
|
4455
4097
|
featureId: ''
|
|
4456
4098
|
}).then((data) => {
|
|
@@ -4564,7 +4206,7 @@ class Device {
|
|
|
4564
4206
|
items: Array.isArray(object === null || object === void 0 ? void 0 : object.items) ? object === null || object === void 0 ? void 0 : object.items : []
|
|
4565
4207
|
}
|
|
4566
4208
|
};
|
|
4567
|
-
yield this.callNative(ACTION.SCAN_IBEACON, Object.assign({}, data));
|
|
4209
|
+
yield this.getJSBridge().callNative(ACTION.SCAN_IBEACON, Object.assign({}, data));
|
|
4568
4210
|
return true;
|
|
4569
4211
|
});
|
|
4570
4212
|
}
|
|
@@ -4583,7 +4225,7 @@ class Device {
|
|
|
4583
4225
|
const data = {
|
|
4584
4226
|
subaction: 2
|
|
4585
4227
|
};
|
|
4586
|
-
yield this.callNative(ACTION.SCAN_IBEACON, Object.assign({}, data));
|
|
4228
|
+
yield this.getJSBridge().callNative(ACTION.SCAN_IBEACON, Object.assign({}, data));
|
|
4587
4229
|
return true;
|
|
4588
4230
|
});
|
|
4589
4231
|
}
|
|
@@ -4604,7 +4246,7 @@ class Device {
|
|
|
4604
4246
|
const data = {
|
|
4605
4247
|
subaction: 1
|
|
4606
4248
|
};
|
|
4607
|
-
const resData = yield this.callNative(ACTION.SCAN_IBEACON, Object.assign({}, data), {
|
|
4249
|
+
const resData = yield this.getJSBridge().callNative(ACTION.SCAN_IBEACON, Object.assign({}, data), {
|
|
4608
4250
|
isMultiCallback: true
|
|
4609
4251
|
}).then((resData) => {
|
|
4610
4252
|
const res = {
|
|
@@ -4646,7 +4288,7 @@ class Device {
|
|
|
4646
4288
|
*/
|
|
4647
4289
|
static stopBluetoothDevicesDiscovery() {
|
|
4648
4290
|
return __awaiter(this, void 0, void 0, function* () {
|
|
4649
|
-
return this.callNative({
|
|
4291
|
+
return this.getJSBridge().callNative({
|
|
4650
4292
|
name: ''
|
|
4651
4293
|
}, {});
|
|
4652
4294
|
});
|
|
@@ -4673,7 +4315,7 @@ class Device {
|
|
|
4673
4315
|
*/
|
|
4674
4316
|
static startBluetoothDevicesDiscovery(object) {
|
|
4675
4317
|
return __awaiter(this, void 0, void 0, function* () {
|
|
4676
|
-
return this.callNative({
|
|
4318
|
+
return this.getJSBridge().callNative({
|
|
4677
4319
|
name: ''
|
|
4678
4320
|
}, Object.assign({}, object));
|
|
4679
4321
|
});
|
|
@@ -4697,7 +4339,7 @@ class Device {
|
|
|
4697
4339
|
*/
|
|
4698
4340
|
static openBluetoothAdapter() {
|
|
4699
4341
|
return __awaiter(this, void 0, void 0, function* () {
|
|
4700
|
-
return this.callNative({
|
|
4342
|
+
return this.getJSBridge().callNative({
|
|
4701
4343
|
name: ''
|
|
4702
4344
|
}, {});
|
|
4703
4345
|
});
|
|
@@ -4717,7 +4359,7 @@ class Device {
|
|
|
4717
4359
|
*/
|
|
4718
4360
|
static onBluetoothDeviceFound() {
|
|
4719
4361
|
return __awaiter(this, void 0, void 0, function* () {
|
|
4720
|
-
return this.callNative({
|
|
4362
|
+
return this.getJSBridge().callNative({
|
|
4721
4363
|
name: ''
|
|
4722
4364
|
}, {});
|
|
4723
4365
|
});
|
|
@@ -4765,7 +4407,7 @@ class Device {
|
|
|
4765
4407
|
const data = {
|
|
4766
4408
|
services: object.services || []
|
|
4767
4409
|
};
|
|
4768
|
-
return this.callNative({
|
|
4410
|
+
return this.getJSBridge().callNative({
|
|
4769
4411
|
name: ''
|
|
4770
4412
|
}, data);
|
|
4771
4413
|
});
|
|
@@ -4786,7 +4428,7 @@ class Device {
|
|
|
4786
4428
|
*/
|
|
4787
4429
|
static getBluetoothDevices() {
|
|
4788
4430
|
return __awaiter(this, void 0, void 0, function* () {
|
|
4789
|
-
return this.callNative({
|
|
4431
|
+
return this.getJSBridge().callNative({
|
|
4790
4432
|
name: ''
|
|
4791
4433
|
}, {});
|
|
4792
4434
|
});
|
|
@@ -4807,7 +4449,7 @@ class Device {
|
|
|
4807
4449
|
*/
|
|
4808
4450
|
static getBluetoothAdapterState() {
|
|
4809
4451
|
return __awaiter(this, void 0, void 0, function* () {
|
|
4810
|
-
return this.callNative({
|
|
4452
|
+
return this.getJSBridge().callNative({
|
|
4811
4453
|
name: ''
|
|
4812
4454
|
}, {});
|
|
4813
4455
|
});
|
|
@@ -4828,7 +4470,7 @@ class Device {
|
|
|
4828
4470
|
*/
|
|
4829
4471
|
static closeBluetoothAdapter() {
|
|
4830
4472
|
return __awaiter(this, void 0, void 0, function* () {
|
|
4831
|
-
return this.callNative({
|
|
4473
|
+
return this.getJSBridge().callNative({
|
|
4832
4474
|
name: ''
|
|
4833
4475
|
}, {});
|
|
4834
4476
|
});
|
|
@@ -4842,7 +4484,7 @@ class Device {
|
|
|
4842
4484
|
*/
|
|
4843
4485
|
static scanQRCode(object) {
|
|
4844
4486
|
return __awaiter(this, void 0, void 0, function* () {
|
|
4845
|
-
return yield this.callNative(ACTION.OPEN_QR, {
|
|
4487
|
+
return yield this.getJSBridge().callNative(ACTION.OPEN_QR, {
|
|
4846
4488
|
skipOpenLink: true
|
|
4847
4489
|
});
|
|
4848
4490
|
});
|
|
@@ -4856,308 +4498,770 @@ class Device {
|
|
|
4856
4498
|
*/
|
|
4857
4499
|
static showToast(object) {
|
|
4858
4500
|
return __awaiter(this, void 0, void 0, function* () {
|
|
4859
|
-
yield this.callNative(ACTION.SHOW_TOAST, {
|
|
4501
|
+
yield this.getJSBridge().callNative(ACTION.SHOW_TOAST, {
|
|
4860
4502
|
toast: object.message
|
|
4861
4503
|
});
|
|
4862
4504
|
});
|
|
4863
4505
|
}
|
|
4864
|
-
/**
|
|
4865
|
-
* Ẩn keyboard
|
|
4866
|
-
* @async
|
|
4867
|
-
* @function hideKeyboard
|
|
4868
|
-
* @category Device
|
|
4869
|
-
*
|
|
4870
|
-
*/
|
|
4871
|
-
static hideKeyboard(object) {
|
|
4506
|
+
/**
|
|
4507
|
+
* Ẩn keyboard
|
|
4508
|
+
* @async
|
|
4509
|
+
* @function hideKeyboard
|
|
4510
|
+
* @category Device
|
|
4511
|
+
*
|
|
4512
|
+
*/
|
|
4513
|
+
static hideKeyboard(object) {
|
|
4514
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
4515
|
+
yield this.getJSBridge().callNative(ACTION.HIDE_KEYBOARD, {});
|
|
4516
|
+
});
|
|
4517
|
+
}
|
|
4518
|
+
/**
|
|
4519
|
+
* Open phone
|
|
4520
|
+
* @async
|
|
4521
|
+
* @function openPhone
|
|
4522
|
+
* @category Device
|
|
4523
|
+
*
|
|
4524
|
+
*/
|
|
4525
|
+
static openPhone(object) {
|
|
4526
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
4527
|
+
yield this.getJSBridge().callNative(ACTION.OPEN_PHONE, {
|
|
4528
|
+
phoneNum: object.phoneNumber,
|
|
4529
|
+
phoneCode: object.phoneNumber
|
|
4530
|
+
});
|
|
4531
|
+
});
|
|
4532
|
+
}
|
|
4533
|
+
/**
|
|
4534
|
+
* Open SMS
|
|
4535
|
+
* @async
|
|
4536
|
+
* @function openSMS
|
|
4537
|
+
* @category Device
|
|
4538
|
+
*
|
|
4539
|
+
*/
|
|
4540
|
+
static openSMS(object) {
|
|
4541
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
4542
|
+
yield this.getJSBridge().callNative(ACTION.OPEN_SMS, {
|
|
4543
|
+
content: object.content,
|
|
4544
|
+
phoneCode: object.phoneNumber
|
|
4545
|
+
});
|
|
4546
|
+
});
|
|
4547
|
+
}
|
|
4548
|
+
/**
|
|
4549
|
+
* Keep screen.
|
|
4550
|
+
* @async
|
|
4551
|
+
* @function keepScreen
|
|
4552
|
+
* @category Device
|
|
4553
|
+
*
|
|
4554
|
+
*/
|
|
4555
|
+
static keepScreen(object) {
|
|
4556
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
4557
|
+
return yield this.getJSBridge().callNative(ACTION.KEEP_SCREEN, {
|
|
4558
|
+
data: {
|
|
4559
|
+
keep_screen_on: object.keepScreenOn ? 1 : 0
|
|
4560
|
+
}
|
|
4561
|
+
});
|
|
4562
|
+
});
|
|
4563
|
+
}
|
|
4564
|
+
/**
|
|
4565
|
+
* Xác thực bằng sinh trắc học
|
|
4566
|
+
* @async
|
|
4567
|
+
* @function openBioAuthentication
|
|
4568
|
+
* @category Authentication
|
|
4569
|
+
*
|
|
4570
|
+
*/
|
|
4571
|
+
static openBioAuthentication(object) {
|
|
4572
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
4573
|
+
return yield this.getJSBridge().callNative(ACTION.PROMPT_AUTHENTICATION, {
|
|
4574
|
+
secret_data: object.secretData,
|
|
4575
|
+
app_id: this.getZAppId(),
|
|
4576
|
+
ui: {
|
|
4577
|
+
title: object.ui.title,
|
|
4578
|
+
sub_title: object.ui.subTitle,
|
|
4579
|
+
negative_text: object.ui.negativeButtonText
|
|
4580
|
+
},
|
|
4581
|
+
require_fingerprint: object.requireFingerprint ? 1 : 0
|
|
4582
|
+
}).then((data) => {
|
|
4583
|
+
var _a, _b, _c, _d;
|
|
4584
|
+
return {
|
|
4585
|
+
code: data === null || data === void 0 ? void 0 : data.error_code,
|
|
4586
|
+
message: data === null || data === void 0 ? void 0 : data.error_message,
|
|
4587
|
+
data: {
|
|
4588
|
+
domain: (_a = data === null || data === void 0 ? void 0 : data.data) === null || _a === void 0 ? void 0 : _a.domain,
|
|
4589
|
+
code: (_b = data === null || data === void 0 ? void 0 : data.data) === null || _b === void 0 ? void 0 : _b.error_code,
|
|
4590
|
+
message: (_c = data === null || data === void 0 ? void 0 : data.data) === null || _c === void 0 ? void 0 : _c.error_message,
|
|
4591
|
+
payToken: (_d = data === null || data === void 0 ? void 0 : data.data) === null || _d === void 0 ? void 0 : _d.pay_token
|
|
4592
|
+
}
|
|
4593
|
+
};
|
|
4594
|
+
});
|
|
4595
|
+
});
|
|
4596
|
+
}
|
|
4597
|
+
/**
|
|
4598
|
+
* Một phần của flow H5-Bio-Authentication. Dùng cho H5 kiểm tra xem bio-factor có bị thay đổi gì so với trước đây ko (thêm vân tay, reset...)
|
|
4599
|
+
* @async
|
|
4600
|
+
* @function checkStateBioAuthentication
|
|
4601
|
+
* @category Authentication
|
|
4602
|
+
*
|
|
4603
|
+
* @example
|
|
4604
|
+
* api.checkStateAuthen({
|
|
4605
|
+
* success: (res) => {},
|
|
4606
|
+
* fail: (err) => {}
|
|
4607
|
+
* })
|
|
4608
|
+
* @param {InputDataType.CallbackType} object
|
|
4609
|
+
*/
|
|
4610
|
+
static checkStateBioAuthentication(object) {
|
|
4611
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
4612
|
+
return yield this.getJSBridge().callNative(ACTION.PROMPT_AUTHENTICATION_CHECK_STATE, {}).then((data) => {
|
|
4613
|
+
return {
|
|
4614
|
+
bioState: data === null || data === void 0 ? void 0 : data.bio_state
|
|
4615
|
+
};
|
|
4616
|
+
});
|
|
4617
|
+
});
|
|
4618
|
+
}
|
|
4619
|
+
/**
|
|
4620
|
+
* Vibrate.
|
|
4621
|
+
* @async
|
|
4622
|
+
* @function vibrate
|
|
4623
|
+
* @category Device
|
|
4624
|
+
*
|
|
4625
|
+
*/
|
|
4626
|
+
static vibrate(object) {
|
|
4627
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
4628
|
+
return yield this.getJSBridge().callNative(ACTION.INTERACTIVE_VIBRATION, {
|
|
4629
|
+
type: VibrateType[object.type],
|
|
4630
|
+
vibrate_time: object.milliseconds
|
|
4631
|
+
});
|
|
4632
|
+
});
|
|
4633
|
+
}
|
|
4634
|
+
/**
|
|
4635
|
+
* Connect Wifi.
|
|
4636
|
+
* @async
|
|
4637
|
+
* @function connectWifi
|
|
4638
|
+
* @category Device
|
|
4639
|
+
*
|
|
4640
|
+
*/
|
|
4641
|
+
static connectWifi(object) {
|
|
4642
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
4643
|
+
let securityType = 'open';
|
|
4644
|
+
if (_.isString(object.password) && object.password.length > 0) {
|
|
4645
|
+
securityType = 'wpa_wpa2';
|
|
4646
|
+
}
|
|
4647
|
+
return yield this.getJSBridge().callNative(ACTION.MP_JOIN_WIFI, {
|
|
4648
|
+
ssid: object.SSID,
|
|
4649
|
+
securityType: securityType,
|
|
4650
|
+
password: object.password,
|
|
4651
|
+
hiddenSsid: object.hiddenSSID
|
|
4652
|
+
});
|
|
4653
|
+
});
|
|
4654
|
+
}
|
|
4655
|
+
/**
|
|
4656
|
+
* Open App Store.
|
|
4657
|
+
* @async
|
|
4658
|
+
* @function openAppStore
|
|
4659
|
+
* @category Device
|
|
4660
|
+
*
|
|
4661
|
+
*/
|
|
4662
|
+
static openAppStore(object) {
|
|
4663
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
4664
|
+
return yield this.getJSBridge().callNative(ACTION.OPEN_APPSTORE, object);
|
|
4665
|
+
});
|
|
4666
|
+
}
|
|
4667
|
+
}
|
|
4668
|
+
|
|
4669
|
+
var _LocalResourceStorage_storage, _LocalResourceStorage_prefix, _LocalResourceStorage_resourceInfo;
|
|
4670
|
+
class LocalResourceStorage {
|
|
4671
|
+
constructor(prefix) {
|
|
4672
|
+
_LocalResourceStorage_storage.set(this, localStorage);
|
|
4673
|
+
_LocalResourceStorage_prefix.set(this, void 0);
|
|
4674
|
+
_LocalResourceStorage_resourceInfo.set(this, void 0);
|
|
4675
|
+
checkPlatform();
|
|
4676
|
+
// if (platform.isMobile && platform.isZalo) {
|
|
4677
|
+
// Object.defineProperty(window, 'localStorage', {
|
|
4678
|
+
// value: null,
|
|
4679
|
+
// configurable: true,
|
|
4680
|
+
// enumerable: true,
|
|
4681
|
+
// writable: false
|
|
4682
|
+
// });
|
|
4683
|
+
// }
|
|
4684
|
+
__classPrivateFieldSet(this, _LocalResourceStorage_resourceInfo, {
|
|
4685
|
+
keys: new Set(),
|
|
4686
|
+
currentSize: 0,
|
|
4687
|
+
limitSize: STORAGE_LIMIT
|
|
4688
|
+
}, "f");
|
|
4689
|
+
__classPrivateFieldSet(this, _LocalResourceStorage_prefix, prefix, "f");
|
|
4690
|
+
this.findAllCurrentDataByApp(prefix);
|
|
4691
|
+
}
|
|
4692
|
+
findAllCurrentDataByApp(prefix) {
|
|
4693
|
+
try {
|
|
4694
|
+
let _x;
|
|
4695
|
+
for (_x in __classPrivateFieldGet(this, _LocalResourceStorage_storage, "f")) {
|
|
4696
|
+
if (prefix) {
|
|
4697
|
+
const _prefix = _x.split('_')[0];
|
|
4698
|
+
if (_prefix !== prefix) {
|
|
4699
|
+
continue;
|
|
4700
|
+
}
|
|
4701
|
+
}
|
|
4702
|
+
__classPrivateFieldGet(this, _LocalResourceStorage_resourceInfo, "f").keys.add(_x);
|
|
4703
|
+
}
|
|
4704
|
+
}
|
|
4705
|
+
catch (error) {
|
|
4706
|
+
logger.error(error, 'LocalResourceStorage > findAllCurrentDataByApp');
|
|
4707
|
+
}
|
|
4708
|
+
}
|
|
4709
|
+
get(keys) {
|
|
4710
|
+
let res = new Map();
|
|
4711
|
+
keys.forEach((key) => {
|
|
4712
|
+
res.set(key, this.getSync(key));
|
|
4713
|
+
});
|
|
4714
|
+
return Promise.resolve(res);
|
|
4715
|
+
}
|
|
4716
|
+
getSync(key) {
|
|
4717
|
+
if (__classPrivateFieldGet(this, _LocalResourceStorage_prefix, "f")) {
|
|
4718
|
+
key = `${__classPrivateFieldGet(this, _LocalResourceStorage_prefix, "f")}_${key}`;
|
|
4719
|
+
}
|
|
4720
|
+
if (!__classPrivateFieldGet(this, _LocalResourceStorage_resourceInfo, "f").keys.has(key))
|
|
4721
|
+
return null;
|
|
4722
|
+
return __classPrivateFieldGet(this, _LocalResourceStorage_storage, "f").getItem(key);
|
|
4723
|
+
}
|
|
4724
|
+
set(data) {
|
|
4725
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
4726
|
+
Object.entries(data).forEach(([key, value]) => {
|
|
4727
|
+
this.setSync(key, value.replace(/\\"/g, '"'));
|
|
4728
|
+
});
|
|
4729
|
+
return Promise.resolve({ errorKeys: [] });
|
|
4730
|
+
});
|
|
4731
|
+
}
|
|
4732
|
+
setSync(key, value) {
|
|
4733
|
+
if (__classPrivateFieldGet(this, _LocalResourceStorage_prefix, "f")) {
|
|
4734
|
+
key = `${__classPrivateFieldGet(this, _LocalResourceStorage_prefix, "f")}_${key}`;
|
|
4735
|
+
}
|
|
4736
|
+
__classPrivateFieldGet(this, _LocalResourceStorage_storage, "f").setItem(key, value);
|
|
4737
|
+
__classPrivateFieldGet(this, _LocalResourceStorage_resourceInfo, "f").keys.add(key);
|
|
4738
|
+
}
|
|
4739
|
+
getInfo() {
|
|
4872
4740
|
return __awaiter(this, void 0, void 0, function* () {
|
|
4873
|
-
|
|
4741
|
+
return Promise.resolve(this.getInfoSync());
|
|
4874
4742
|
});
|
|
4875
4743
|
}
|
|
4876
|
-
|
|
4877
|
-
|
|
4878
|
-
|
|
4879
|
-
|
|
4880
|
-
|
|
4881
|
-
|
|
4882
|
-
|
|
4883
|
-
|
|
4744
|
+
getInfoSync() {
|
|
4745
|
+
const currentSize = calcLocalStorageSize(__classPrivateFieldGet(this, _LocalResourceStorage_storage, "f"), __classPrivateFieldGet(this, _LocalResourceStorage_prefix, "f"));
|
|
4746
|
+
return {
|
|
4747
|
+
currentSize: _.isNumber(currentSize)
|
|
4748
|
+
? Number((currentSize / 1024).toFixed(2))
|
|
4749
|
+
: 0,
|
|
4750
|
+
limitSize: Number((STORAGE_LIMIT / 1024).toFixed(2))
|
|
4751
|
+
};
|
|
4752
|
+
}
|
|
4753
|
+
remove(keys) {
|
|
4884
4754
|
return __awaiter(this, void 0, void 0, function* () {
|
|
4885
|
-
|
|
4886
|
-
|
|
4887
|
-
phoneCode: object.phoneNumber
|
|
4755
|
+
keys.forEach((key) => {
|
|
4756
|
+
this.removeSync(key);
|
|
4888
4757
|
});
|
|
4758
|
+
return Promise.resolve({ errorKeys: [] });
|
|
4889
4759
|
});
|
|
4890
4760
|
}
|
|
4891
|
-
|
|
4892
|
-
|
|
4893
|
-
|
|
4894
|
-
|
|
4895
|
-
|
|
4896
|
-
|
|
4897
|
-
|
|
4898
|
-
|
|
4761
|
+
removeSync(key) {
|
|
4762
|
+
if (__classPrivateFieldGet(this, _LocalResourceStorage_prefix, "f")) {
|
|
4763
|
+
key = `${__classPrivateFieldGet(this, _LocalResourceStorage_prefix, "f")}_${key}`;
|
|
4764
|
+
}
|
|
4765
|
+
if (__classPrivateFieldGet(this, _LocalResourceStorage_resourceInfo, "f").keys.has(key)) {
|
|
4766
|
+
__classPrivateFieldGet(this, _LocalResourceStorage_storage, "f").removeItem(key);
|
|
4767
|
+
__classPrivateFieldGet(this, _LocalResourceStorage_resourceInfo, "f").keys.delete(key);
|
|
4768
|
+
}
|
|
4769
|
+
}
|
|
4770
|
+
clear() {
|
|
4899
4771
|
return __awaiter(this, void 0, void 0, function* () {
|
|
4900
|
-
|
|
4901
|
-
content: object.content,
|
|
4902
|
-
phoneCode: object.phoneNumber
|
|
4903
|
-
});
|
|
4772
|
+
return Promise.resolve(this.clearSync());
|
|
4904
4773
|
});
|
|
4905
4774
|
}
|
|
4906
|
-
|
|
4907
|
-
|
|
4908
|
-
|
|
4909
|
-
|
|
4910
|
-
|
|
4911
|
-
|
|
4912
|
-
|
|
4913
|
-
static keepScreen(object) {
|
|
4914
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
4915
|
-
return yield this.callNative(ACTION.KEEP_SCREEN, {
|
|
4916
|
-
data: {
|
|
4917
|
-
keep_screen_on: object.keepScreenOn ? 1 : 0
|
|
4918
|
-
}
|
|
4919
|
-
});
|
|
4775
|
+
clearSync() {
|
|
4776
|
+
__classPrivateFieldGet(this, _LocalResourceStorage_resourceInfo, "f").keys.forEach((key) => {
|
|
4777
|
+
if (__classPrivateFieldGet(this, _LocalResourceStorage_prefix, "f") && key.indexOf(__classPrivateFieldGet(this, _LocalResourceStorage_prefix, "f")) < 0) {
|
|
4778
|
+
return;
|
|
4779
|
+
}
|
|
4780
|
+
__classPrivateFieldGet(this, _LocalResourceStorage_storage, "f").removeItem(key);
|
|
4781
|
+
__classPrivateFieldGet(this, _LocalResourceStorage_resourceInfo, "f").keys.delete(key);
|
|
4920
4782
|
});
|
|
4921
4783
|
}
|
|
4922
|
-
|
|
4923
|
-
|
|
4924
|
-
|
|
4925
|
-
|
|
4926
|
-
|
|
4927
|
-
|
|
4928
|
-
|
|
4929
|
-
|
|
4930
|
-
return
|
|
4931
|
-
|
|
4932
|
-
|
|
4933
|
-
|
|
4934
|
-
|
|
4935
|
-
|
|
4936
|
-
|
|
4937
|
-
|
|
4938
|
-
|
|
4939
|
-
|
|
4940
|
-
|
|
4941
|
-
|
|
4942
|
-
|
|
4943
|
-
|
|
4944
|
-
|
|
4945
|
-
|
|
4946
|
-
|
|
4947
|
-
|
|
4948
|
-
|
|
4949
|
-
|
|
4950
|
-
|
|
4951
|
-
|
|
4784
|
+
}
|
|
4785
|
+
_LocalResourceStorage_storage = new WeakMap(), _LocalResourceStorage_prefix = new WeakMap(), _LocalResourceStorage_resourceInfo = new WeakMap();
|
|
4786
|
+
|
|
4787
|
+
var wrappers = {};
|
|
4788
|
+
var WrapperFn = function wrapFunction(fn, type, source) {
|
|
4789
|
+
var t = type || 'default';
|
|
4790
|
+
return function () {
|
|
4791
|
+
var callee = t in wrappers ? wrappers[t](fn, source) : fn;
|
|
4792
|
+
return callee.apply(this, arguments);
|
|
4793
|
+
};
|
|
4794
|
+
};
|
|
4795
|
+
WrapperFn.setWrapper = function (fn) {
|
|
4796
|
+
var type = arguments.length <= 1 || arguments[1] === undefined
|
|
4797
|
+
? 'default'
|
|
4798
|
+
: arguments[1];
|
|
4799
|
+
wrappers[type] = fn;
|
|
4800
|
+
};
|
|
4801
|
+
var ERROR = {
|
|
4802
|
+
error: {
|
|
4803
|
+
code: 1,
|
|
4804
|
+
error_subcode: 1357046,
|
|
4805
|
+
message: 'Received Invalid JSON reply.',
|
|
4806
|
+
type: 'http'
|
|
4807
|
+
}
|
|
4808
|
+
};
|
|
4809
|
+
function safelyParseResponse(rawResponse) {
|
|
4810
|
+
try {
|
|
4811
|
+
return rawResponse === null ? ERROR : JSON.parse(rawResponse);
|
|
4812
|
+
}
|
|
4813
|
+
catch (ex) {
|
|
4814
|
+
return ERROR;
|
|
4815
|
+
}
|
|
4816
|
+
}
|
|
4817
|
+
function createCORSRequest(method, url) {
|
|
4818
|
+
if (!self.XMLHttpRequest) {
|
|
4819
|
+
return null;
|
|
4820
|
+
}
|
|
4821
|
+
var xhr = new XMLHttpRequest();
|
|
4822
|
+
var noop = function noop() { };
|
|
4823
|
+
if ('withCredentials' in xhr) {
|
|
4824
|
+
xhr.open(method, url, true);
|
|
4825
|
+
xhr.setRequestHeader('Content-type', 'application/x-www-form-urlencoded');
|
|
4826
|
+
}
|
|
4827
|
+
else {
|
|
4828
|
+
return null;
|
|
4829
|
+
}
|
|
4830
|
+
var wrapper = {
|
|
4831
|
+
send: function send(data) {
|
|
4832
|
+
xhr.send(data);
|
|
4833
|
+
}
|
|
4834
|
+
};
|
|
4835
|
+
var onload = WrapperFn(function () {
|
|
4836
|
+
onload = noop;
|
|
4837
|
+
if ('onload' in wrapper) {
|
|
4838
|
+
wrapper.onload(xhr);
|
|
4839
|
+
}
|
|
4840
|
+
}, 'entry', 'XMLHttpRequest:load');
|
|
4841
|
+
var onerror = WrapperFn(function () {
|
|
4842
|
+
onerror = noop;
|
|
4843
|
+
if ('onerror' in wrapper) {
|
|
4844
|
+
wrapper.onerror(xhr);
|
|
4845
|
+
}
|
|
4846
|
+
}, 'entry', 'XMLHttpRequest:error');
|
|
4847
|
+
xhr.onload = function () {
|
|
4848
|
+
onload();
|
|
4849
|
+
};
|
|
4850
|
+
xhr.onerror = function () {
|
|
4851
|
+
onerror();
|
|
4852
|
+
};
|
|
4853
|
+
xhr.onreadystatechange = function () {
|
|
4854
|
+
if (xhr.readyState == 4) {
|
|
4855
|
+
if (xhr.status == 200) {
|
|
4856
|
+
onload();
|
|
4857
|
+
}
|
|
4858
|
+
else {
|
|
4859
|
+
onerror();
|
|
4860
|
+
}
|
|
4861
|
+
}
|
|
4862
|
+
};
|
|
4863
|
+
return wrapper;
|
|
4864
|
+
}
|
|
4865
|
+
function execute(url, method, params, cb) {
|
|
4866
|
+
params.suppress_http_code = 1;
|
|
4867
|
+
var data = QueryString.encode(params);
|
|
4868
|
+
if (method != 'post') {
|
|
4869
|
+
url = QueryString.appendToUrl(url, data);
|
|
4870
|
+
data = '';
|
|
4871
|
+
}
|
|
4872
|
+
var request = createCORSRequest(method, url);
|
|
4873
|
+
if (!request) {
|
|
4874
|
+
return false;
|
|
4875
|
+
}
|
|
4876
|
+
request.onload = function (xhr) {
|
|
4877
|
+
cb(safelyParseResponse(xhr.responseText));
|
|
4878
|
+
};
|
|
4879
|
+
request.onerror = function (xhr) {
|
|
4880
|
+
if (xhr.responseText) {
|
|
4881
|
+
cb(safelyParseResponse(xhr.responseText));
|
|
4882
|
+
}
|
|
4883
|
+
else {
|
|
4884
|
+
cb({
|
|
4885
|
+
error: {
|
|
4886
|
+
code: 1,
|
|
4887
|
+
error_subcode: 1357045,
|
|
4888
|
+
message: 'unknown error (empty response)',
|
|
4889
|
+
status: xhr.status,
|
|
4890
|
+
type: 'http'
|
|
4891
|
+
}
|
|
4892
|
+
});
|
|
4893
|
+
}
|
|
4894
|
+
};
|
|
4895
|
+
request.send(data);
|
|
4896
|
+
return true;
|
|
4897
|
+
}
|
|
4898
|
+
var CORSRequest = {
|
|
4899
|
+
execute: execute
|
|
4900
|
+
};
|
|
4901
|
+
|
|
4902
|
+
var _ZaloJSBridge_instances, _ZaloJSBridge_cookies, _ZaloJSBridge_actionRuntimeInfo, _ZaloJSBridge_jsCall;
|
|
4903
|
+
class ZaloJSBridge extends eventemitter3 {
|
|
4904
|
+
constructor() {
|
|
4905
|
+
super();
|
|
4906
|
+
_ZaloJSBridge_instances.add(this);
|
|
4907
|
+
this.debug = Debug('zmp:ZaloJSBridge');
|
|
4908
|
+
this.events = ZMPEEmitter.getInstance();
|
|
4909
|
+
this._accessTk = getToken('zacc_session') || 'DEFAULT_ACCESS_TOKEN';
|
|
4910
|
+
this._jsAccessTk = getToken('zlink3rd') || 'DEFAULT_JS_TOKEN';
|
|
4911
|
+
this.results = [];
|
|
4912
|
+
this._userAgent = getUserAgent();
|
|
4913
|
+
this._device = checkPlatform();
|
|
4914
|
+
this.isJumped = false;
|
|
4915
|
+
_ZaloJSBridge_cookies.set(this, null);
|
|
4916
|
+
_ZaloJSBridge_actionRuntimeInfo.set(this, void 0);
|
|
4917
|
+
this.jump = () => {
|
|
4918
|
+
return new Promise((resolve, reject) => {
|
|
4919
|
+
if (!_.isUndefined(__classPrivateFieldGet(this, _ZaloJSBridge_cookies, "f")) && !_.isNull(__classPrivateFieldGet(this, _ZaloJSBridge_cookies, "f"))) {
|
|
4920
|
+
resolve(__classPrivateFieldGet(this, _ZaloJSBridge_cookies, "f"));
|
|
4921
|
+
}
|
|
4922
|
+
else {
|
|
4923
|
+
this.callNative(ACTION.JUMP_LOGIN, {})
|
|
4924
|
+
.then((data) => {
|
|
4925
|
+
const cookies = (data && data.cookiesOAuthLogins) || [];
|
|
4926
|
+
const actionPermission = (data && data.actionPermission) || [];
|
|
4927
|
+
Object.entries(actionPermission).forEach((item) => {
|
|
4928
|
+
const key = item[0];
|
|
4929
|
+
const value = item[1] || { perm: 0, decode: 0 };
|
|
4930
|
+
if (!__classPrivateFieldGet(this, _ZaloJSBridge_actionRuntimeInfo, "f")[key]) {
|
|
4931
|
+
__classPrivateFieldGet(this, _ZaloJSBridge_actionRuntimeInfo, "f")[key] = {
|
|
4932
|
+
permission: false,
|
|
4933
|
+
support: false
|
|
4934
|
+
};
|
|
4935
|
+
}
|
|
4936
|
+
__classPrivateFieldGet(this, _ZaloJSBridge_actionRuntimeInfo, "f")[key].permission = value.perm === 1;
|
|
4937
|
+
});
|
|
4938
|
+
const jsToken = cookies.find((cookie) => cookie.name === COOKIE_NAME.JS_TOKEN);
|
|
4939
|
+
if (jsToken) {
|
|
4940
|
+
this.jsAccessTk = jsToken.value;
|
|
4941
|
+
window.ZJSBridge.setJSToken &&
|
|
4942
|
+
window.ZJSBridge.setJSToken(jsToken.value);
|
|
4943
|
+
}
|
|
4944
|
+
__classPrivateFieldSet(this, _ZaloJSBridge_cookies, cookies, "f");
|
|
4945
|
+
this.isJumped = true;
|
|
4946
|
+
resolve(cookies);
|
|
4947
|
+
})
|
|
4948
|
+
.catch((error) => {
|
|
4949
|
+
this.isJumped = false;
|
|
4950
|
+
reject(error);
|
|
4951
|
+
});
|
|
4952
|
+
}
|
|
4952
4953
|
});
|
|
4954
|
+
};
|
|
4955
|
+
this._jsCallFuncCallbacks = {};
|
|
4956
|
+
__classPrivateFieldSet(this, _ZaloJSBridge_actionRuntimeInfo, {}, "f");
|
|
4957
|
+
this.events.on(Events.AppPaused, () => {
|
|
4958
|
+
if (this.results.length > 0) {
|
|
4959
|
+
let array = this.results;
|
|
4960
|
+
this.results = [];
|
|
4961
|
+
try {
|
|
4962
|
+
this.sendLogData(array);
|
|
4963
|
+
}
|
|
4964
|
+
catch (error) { }
|
|
4965
|
+
}
|
|
4953
4966
|
});
|
|
4967
|
+
if (this.sendLogTimer) {
|
|
4968
|
+
clearInterval(this.sendLogTimer);
|
|
4969
|
+
}
|
|
4970
|
+
else {
|
|
4971
|
+
this.sendLogTimer = setInterval(() => {
|
|
4972
|
+
if (this.results.length > 0) {
|
|
4973
|
+
let array = this.results;
|
|
4974
|
+
this.results = [];
|
|
4975
|
+
try {
|
|
4976
|
+
this.sendLogData(array);
|
|
4977
|
+
}
|
|
4978
|
+
catch (error) { }
|
|
4979
|
+
}
|
|
4980
|
+
}, 5000);
|
|
4981
|
+
}
|
|
4954
4982
|
}
|
|
4955
|
-
|
|
4956
|
-
|
|
4957
|
-
|
|
4958
|
-
|
|
4959
|
-
|
|
4960
|
-
|
|
4961
|
-
|
|
4962
|
-
|
|
4963
|
-
|
|
4964
|
-
|
|
4965
|
-
|
|
4966
|
-
|
|
4967
|
-
|
|
4968
|
-
|
|
4969
|
-
|
|
4970
|
-
return yield this.callNative(ACTION.PROMPT_AUTHENTICATION_CHECK_STATE, {}).then((data) => {
|
|
4983
|
+
static getInstance() {
|
|
4984
|
+
if (!ZaloJSBridge.instance) {
|
|
4985
|
+
ZaloJSBridge.instance = new ZaloJSBridge();
|
|
4986
|
+
}
|
|
4987
|
+
return ZaloJSBridge.instance;
|
|
4988
|
+
}
|
|
4989
|
+
set accessTk(value) {
|
|
4990
|
+
this._accessTk = value;
|
|
4991
|
+
}
|
|
4992
|
+
set jsAccessTk(value) {
|
|
4993
|
+
this._jsAccessTk = value;
|
|
4994
|
+
}
|
|
4995
|
+
sendLogData(data) {
|
|
4996
|
+
try {
|
|
4997
|
+
const logData = data.map((item) => {
|
|
4971
4998
|
return {
|
|
4972
|
-
|
|
4999
|
+
action: item.action,
|
|
5000
|
+
error: item.error
|
|
4973
5001
|
};
|
|
4974
5002
|
});
|
|
4975
|
-
|
|
5003
|
+
CORSRequest.execute(APIS.SEND_ACTION_LOG, 'post', {
|
|
5004
|
+
appId: window.APP_ID,
|
|
5005
|
+
data: JSON.stringify(logData)
|
|
5006
|
+
}, (response) => { });
|
|
5007
|
+
window.zmpSentry &&
|
|
5008
|
+
window.zmpSentry.captureMessage('Result from native', {
|
|
5009
|
+
extra: {
|
|
5010
|
+
data: data
|
|
5011
|
+
}
|
|
5012
|
+
});
|
|
5013
|
+
}
|
|
5014
|
+
catch (error) { }
|
|
4976
5015
|
}
|
|
4977
|
-
|
|
4978
|
-
|
|
4979
|
-
|
|
4980
|
-
|
|
4981
|
-
|
|
4982
|
-
|
|
4983
|
-
|
|
4984
|
-
|
|
4985
|
-
|
|
4986
|
-
|
|
4987
|
-
|
|
4988
|
-
|
|
5016
|
+
onJSCall(key, data) {
|
|
5017
|
+
try {
|
|
5018
|
+
this.debug('onJSCall', key, data);
|
|
5019
|
+
const parsedData = parseJSON(data);
|
|
5020
|
+
if (this._jsCallFuncCallbacks[key]) {
|
|
5021
|
+
const callback = this._jsCallFuncCallbacks[key].callback;
|
|
5022
|
+
const timeout = this._jsCallFuncCallbacks[key].timeout;
|
|
5023
|
+
if (!!callback) {
|
|
5024
|
+
try {
|
|
5025
|
+
callback.call(this, parsedData);
|
|
5026
|
+
}
|
|
5027
|
+
catch (error) {
|
|
5028
|
+
console.error('Call callback error', error);
|
|
5029
|
+
}
|
|
5030
|
+
!!timeout && clearTimeout(timeout);
|
|
5031
|
+
this._jsCallFuncCallbacks[key] = null;
|
|
5032
|
+
delete this._jsCallFuncCallbacks[key];
|
|
5033
|
+
}
|
|
5034
|
+
}
|
|
5035
|
+
this.results.push({
|
|
5036
|
+
action: parsedData.action,
|
|
5037
|
+
error: parsedData.error_code,
|
|
5038
|
+
message: parsedData.error_message
|
|
4989
5039
|
});
|
|
4990
|
-
}
|
|
5040
|
+
}
|
|
5041
|
+
catch (e) {
|
|
5042
|
+
console.log('onJSCall', 'error', e);
|
|
5043
|
+
}
|
|
4991
5044
|
}
|
|
4992
|
-
|
|
4993
|
-
|
|
4994
|
-
|
|
4995
|
-
|
|
4996
|
-
|
|
4997
|
-
|
|
4998
|
-
|
|
4999
|
-
|
|
5000
|
-
|
|
5001
|
-
|
|
5002
|
-
|
|
5003
|
-
|
|
5045
|
+
onMultiJSCall(key, data) {
|
|
5046
|
+
try {
|
|
5047
|
+
this.debug('onMultiJSCall', key, data);
|
|
5048
|
+
const parsedData = parseJSON(data);
|
|
5049
|
+
if (this._jsCallFuncCallbacks[key]) {
|
|
5050
|
+
const callback = this._jsCallFuncCallbacks[key].callback;
|
|
5051
|
+
const timeout = this._jsCallFuncCallbacks[key].timeout;
|
|
5052
|
+
if (!!callback) {
|
|
5053
|
+
try {
|
|
5054
|
+
callback.call(this, parsedData);
|
|
5055
|
+
}
|
|
5056
|
+
catch (error) {
|
|
5057
|
+
console.error('Call callback error', error);
|
|
5058
|
+
}
|
|
5059
|
+
!!timeout && clearTimeout(timeout);
|
|
5060
|
+
}
|
|
5004
5061
|
}
|
|
5005
|
-
|
|
5006
|
-
|
|
5007
|
-
|
|
5008
|
-
|
|
5009
|
-
hiddenSsid: object.hiddenSSID
|
|
5062
|
+
this.results.push({
|
|
5063
|
+
action: parsedData.action,
|
|
5064
|
+
error: parsedData.error_code,
|
|
5065
|
+
message: parsedData.error_message
|
|
5010
5066
|
});
|
|
5011
|
-
}
|
|
5012
|
-
|
|
5013
|
-
|
|
5014
|
-
|
|
5015
|
-
* @async
|
|
5016
|
-
* @function openAppStore
|
|
5017
|
-
* @category Device
|
|
5018
|
-
*
|
|
5019
|
-
*/
|
|
5020
|
-
static openAppStore(object) {
|
|
5021
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
5022
|
-
return yield this.callNative(ACTION.OPEN_APPSTORE, object);
|
|
5023
|
-
});
|
|
5067
|
+
}
|
|
5068
|
+
catch (e) {
|
|
5069
|
+
console.log('onMultiJSCall', 'error', e);
|
|
5070
|
+
}
|
|
5024
5071
|
}
|
|
5025
|
-
|
|
5026
|
-
|
|
5027
|
-
|
|
5028
|
-
|
|
5029
|
-
|
|
5030
|
-
|
|
5031
|
-
_LocalResourceStorage_prefix.set(this, void 0);
|
|
5032
|
-
_LocalResourceStorage_resourceInfo.set(this, void 0);
|
|
5033
|
-
checkPlatform();
|
|
5034
|
-
// if (platform.isMobile && platform.isZalo) {
|
|
5035
|
-
// Object.defineProperty(window, 'localStorage', {
|
|
5036
|
-
// value: null,
|
|
5037
|
-
// configurable: true,
|
|
5038
|
-
// enumerable: true,
|
|
5039
|
-
// writable: false
|
|
5040
|
-
// });
|
|
5041
|
-
// }
|
|
5042
|
-
__classPrivateFieldSet(this, _LocalResourceStorage_resourceInfo, {
|
|
5043
|
-
keys: new Set(),
|
|
5044
|
-
currentSize: 0,
|
|
5045
|
-
limitSize: STORAGE_LIMIT
|
|
5046
|
-
}, "f");
|
|
5047
|
-
__classPrivateFieldSet(this, _LocalResourceStorage_prefix, prefix, "f");
|
|
5048
|
-
this.findAllCurrentDataByApp(prefix);
|
|
5072
|
+
nativeEventHandler(eventId, eventName, eventData) {
|
|
5073
|
+
this.debug(`eventId: ${eventId}, eventName: ${eventName}, eventData: ${eventData}`);
|
|
5074
|
+
const data = stringToData(eventData);
|
|
5075
|
+
this.debug(data);
|
|
5076
|
+
const convertedData = this.handleEventData(eventName, data);
|
|
5077
|
+
this.events.emit(eventName, eventId, convertedData);
|
|
5049
5078
|
}
|
|
5050
|
-
|
|
5079
|
+
handleEventData(eventName, data) {
|
|
5051
5080
|
try {
|
|
5052
|
-
|
|
5053
|
-
|
|
5054
|
-
|
|
5055
|
-
const
|
|
5056
|
-
|
|
5057
|
-
|
|
5058
|
-
|
|
5059
|
-
|
|
5060
|
-
|
|
5081
|
+
switch (eventName) {
|
|
5082
|
+
case Events.OpenApp:
|
|
5083
|
+
const { url } = data;
|
|
5084
|
+
const validUrl = new URL(url);
|
|
5085
|
+
const path = validUrl.pathname.split(`/zapps/${APP_ID}`)[1];
|
|
5086
|
+
return {
|
|
5087
|
+
path: `${path ? path : '/'}${validUrl.search}`
|
|
5088
|
+
};
|
|
5089
|
+
break;
|
|
5090
|
+
default:
|
|
5091
|
+
return data;
|
|
5092
|
+
break;
|
|
5061
5093
|
}
|
|
5062
5094
|
}
|
|
5063
5095
|
catch (error) {
|
|
5064
|
-
|
|
5096
|
+
return data;
|
|
5065
5097
|
}
|
|
5066
5098
|
}
|
|
5067
|
-
|
|
5068
|
-
|
|
5069
|
-
|
|
5070
|
-
res.set(key, this.getSync(key));
|
|
5071
|
-
});
|
|
5072
|
-
return Promise.resolve(res);
|
|
5073
|
-
}
|
|
5074
|
-
getSync(key) {
|
|
5075
|
-
if (__classPrivateFieldGet(this, _LocalResourceStorage_prefix, "f")) {
|
|
5076
|
-
key = `${__classPrivateFieldGet(this, _LocalResourceStorage_prefix, "f")}_${key}`;
|
|
5099
|
+
defaultCallback(data) {
|
|
5100
|
+
if (data !== null && data !== undefined) {
|
|
5101
|
+
data = parseJSON(data);
|
|
5077
5102
|
}
|
|
5078
|
-
if (!__classPrivateFieldGet(this, _LocalResourceStorage_resourceInfo, "f").keys.has(key))
|
|
5079
|
-
return null;
|
|
5080
|
-
return __classPrivateFieldGet(this, _LocalResourceStorage_storage, "f").getItem(key);
|
|
5081
5103
|
}
|
|
5082
|
-
|
|
5083
|
-
|
|
5084
|
-
|
|
5085
|
-
|
|
5104
|
+
callNative(action, data, option) {
|
|
5105
|
+
this.debug(action.name, data);
|
|
5106
|
+
return new Promise((resolve, reject) => {
|
|
5107
|
+
const handleNativeCallback = (cb) => __awaiter(this, void 0, void 0, function* () {
|
|
5108
|
+
var _a, _b, _c, _d, _e, _f, _g, _h;
|
|
5109
|
+
try {
|
|
5110
|
+
if (_.isUndefined(cb) || _.isNull(cb)) {
|
|
5111
|
+
return reject(new Error('Native callback is null'));
|
|
5112
|
+
}
|
|
5113
|
+
if (cb.error_code !== 0) {
|
|
5114
|
+
let error = new AppError(cb.error_code, cb.error_message);
|
|
5115
|
+
const platform = getPlatform();
|
|
5116
|
+
if (action === ACTION.JUMP_LOGIN) {
|
|
5117
|
+
error = new AppError(RESPONSE_CODE.UNKNOWN_ERROR, `Can not get auth code: ${cb.error_message}`);
|
|
5118
|
+
}
|
|
5119
|
+
else if (!this.isJumped && !action.skip_jump) {
|
|
5120
|
+
error = new AppError(RESPONSE.UNAUTHORIZED.code, RESPONSE.UNAUTHORIZED.message);
|
|
5121
|
+
}
|
|
5122
|
+
else if (String(error.message).toLowerCase() === 'permission required!' ||
|
|
5123
|
+
String(error.message).toLowerCase() === 'no permission!') {
|
|
5124
|
+
error = new AppError(RESPONSE.FORBIDDEN.code, RESPONSE.FORBIDDEN.message);
|
|
5125
|
+
}
|
|
5126
|
+
else if (COMMON_NATIVE_ERROR_CODE[platform][cb.error_code]) {
|
|
5127
|
+
error = new AppError(COMMON_NATIVE_ERROR_CODE[platform][cb.error_code].code, COMMON_NATIVE_ERROR_CODE[platform][cb.error_code].message);
|
|
5128
|
+
}
|
|
5129
|
+
else if ((_b = (_a = action.error_list) === null || _a === void 0 ? void 0 : _a[platform]) === null || _b === void 0 ? void 0 : _b[String(cb.error_code)]) {
|
|
5130
|
+
let error_message = action.error_list[platform][String(cb.error_code)].map_to.message;
|
|
5131
|
+
if ((_e = (_d = (_c = action.error_list) === null || _c === void 0 ? void 0 : _c[platform]) === null || _d === void 0 ? void 0 : _d[String(cb.error_code)]) === null || _e === void 0 ? void 0 : _e.need_more_detail) {
|
|
5132
|
+
error_message = `${(_h = (_g = (_f = action.error_list) === null || _f === void 0 ? void 0 : _f[platform]) === null || _g === void 0 ? void 0 : _g[String(cb.error_code)]) === null || _h === void 0 ? void 0 : _h.map_to.message}: ${cb.error_message}`;
|
|
5133
|
+
}
|
|
5134
|
+
error = new AppError(action.error_list[platform][String(cb.error_code)].map_to.code, error_message);
|
|
5135
|
+
}
|
|
5136
|
+
return reject(error);
|
|
5137
|
+
}
|
|
5138
|
+
if (option === null || option === void 0 ? void 0 : option.successCallback) {
|
|
5139
|
+
const res = yield option.successCallback(cb.data);
|
|
5140
|
+
return resolve(res);
|
|
5141
|
+
}
|
|
5142
|
+
else {
|
|
5143
|
+
resolve(cb.data || {});
|
|
5144
|
+
}
|
|
5145
|
+
}
|
|
5146
|
+
catch (error) {
|
|
5147
|
+
return reject(error);
|
|
5148
|
+
}
|
|
5086
5149
|
});
|
|
5087
|
-
|
|
5150
|
+
const isIOS = checkPlatform().isIOS;
|
|
5151
|
+
const isSupportAction = checkIOSSupportAction(action);
|
|
5152
|
+
if (isIOS && !isSupportAction) {
|
|
5153
|
+
const error = new AppError(-5, `Client isn't support this action`);
|
|
5154
|
+
return reject(error);
|
|
5155
|
+
}
|
|
5156
|
+
else if (option === null || option === void 0 ? void 0 : option.delay) {
|
|
5157
|
+
setTimeout(() => {
|
|
5158
|
+
__classPrivateFieldGet(this, _ZaloJSBridge_instances, "m", _ZaloJSBridge_jsCall).call(this, action, data, handleNativeCallback, option === null || option === void 0 ? void 0 : option.isMultiCallback, option === null || option === void 0 ? void 0 : option.nRetry, option === null || option === void 0 ? void 0 : option.haveTimeout);
|
|
5159
|
+
}, option.delay);
|
|
5160
|
+
}
|
|
5161
|
+
else {
|
|
5162
|
+
__classPrivateFieldGet(this, _ZaloJSBridge_instances, "m", _ZaloJSBridge_jsCall).call(this, action, data, handleNativeCallback, option === null || option === void 0 ? void 0 : option.isMultiCallback, option === null || option === void 0 ? void 0 : option.nRetry, option === null || option === void 0 ? void 0 : option.haveTimeout);
|
|
5163
|
+
}
|
|
5088
5164
|
});
|
|
5089
5165
|
}
|
|
5090
|
-
|
|
5091
|
-
|
|
5092
|
-
|
|
5166
|
+
}
|
|
5167
|
+
_ZaloJSBridge_cookies = new WeakMap(), _ZaloJSBridge_actionRuntimeInfo = new WeakMap(), _ZaloJSBridge_instances = new WeakSet(), _ZaloJSBridge_jsCall = function _ZaloJSBridge_jsCall(action, options, callback, isMultiCallback = false, nRetry = 3, haveTimeout = true) {
|
|
5168
|
+
try {
|
|
5169
|
+
const actionName = action.name;
|
|
5170
|
+
const key = generateUniqueString(actionName);
|
|
5171
|
+
if (!this._device.isMobile || _.isEmpty(actionName)) {
|
|
5172
|
+
this.onJSCall(key, {
|
|
5173
|
+
error_code: -13,
|
|
5174
|
+
error_message: 'params invalid!',
|
|
5175
|
+
data: {
|
|
5176
|
+
device: this._device.isMobile,
|
|
5177
|
+
jsToken: this._jsAccessTk,
|
|
5178
|
+
access_token: this._accessTk
|
|
5179
|
+
},
|
|
5180
|
+
action: actionName
|
|
5181
|
+
});
|
|
5182
|
+
return false;
|
|
5093
5183
|
}
|
|
5094
|
-
|
|
5095
|
-
|
|
5096
|
-
|
|
5097
|
-
|
|
5098
|
-
|
|
5099
|
-
|
|
5100
|
-
|
|
5101
|
-
|
|
5102
|
-
|
|
5103
|
-
|
|
5104
|
-
|
|
5105
|
-
currentSize: _.isNumber(currentSize)
|
|
5106
|
-
? Number((currentSize / 1024).toFixed(2))
|
|
5107
|
-
: 0,
|
|
5108
|
-
limitSize: Number((STORAGE_LIMIT / 1024).toFixed(2))
|
|
5184
|
+
if (options === undefined || options === null) {
|
|
5185
|
+
options = {};
|
|
5186
|
+
}
|
|
5187
|
+
if (!callback) {
|
|
5188
|
+
callback = this.defaultCallback;
|
|
5189
|
+
}
|
|
5190
|
+
const timeoutCallback = {
|
|
5191
|
+
error_code: -14,
|
|
5192
|
+
error_message: 'Request Timeout!',
|
|
5193
|
+
data: {},
|
|
5194
|
+
action: actionName
|
|
5109
5195
|
};
|
|
5110
|
-
|
|
5111
|
-
|
|
5112
|
-
|
|
5113
|
-
|
|
5114
|
-
|
|
5115
|
-
|
|
5116
|
-
|
|
5117
|
-
}
|
|
5118
|
-
|
|
5119
|
-
|
|
5120
|
-
|
|
5121
|
-
|
|
5196
|
+
this._jsCallFuncCallbacks[key] = {
|
|
5197
|
+
timeout: haveTimeout &&
|
|
5198
|
+
action.have_callback &&
|
|
5199
|
+
setTimeout(() => {
|
|
5200
|
+
this.onJSCall(key, timeoutCallback);
|
|
5201
|
+
}, 8000),
|
|
5202
|
+
callback: callback
|
|
5203
|
+
};
|
|
5204
|
+
try {
|
|
5205
|
+
options = serialize(options);
|
|
5206
|
+
if (isMultiCallback) {
|
|
5207
|
+
if (this._device.isIOS) {
|
|
5208
|
+
return ZaloJavaScriptInterface.jsCall(this._jsAccessTk, actionName, this._accessTk, options, window.onMultiJSCall(key));
|
|
5209
|
+
}
|
|
5210
|
+
return ZaloJavaScriptInterface.jsCall(this._jsAccessTk, actionName, this._accessTk, options, `window.onMultiJSCall('${key}')`);
|
|
5211
|
+
}
|
|
5212
|
+
if (this._device.isIOS) {
|
|
5213
|
+
return ZaloJavaScriptInterface.jsCall(this._jsAccessTk, actionName, this._accessTk, options, window.onJSCall(key));
|
|
5214
|
+
}
|
|
5215
|
+
return ZaloJavaScriptInterface.jsCall(this._jsAccessTk, actionName, this._accessTk, options, `window.onJSCall('${key}')`);
|
|
5122
5216
|
}
|
|
5123
|
-
|
|
5124
|
-
|
|
5125
|
-
|
|
5217
|
+
catch (error) {
|
|
5218
|
+
if (nRetry-- > 0) {
|
|
5219
|
+
setTimeout(() => {
|
|
5220
|
+
__classPrivateFieldGet(this, _ZaloJSBridge_instances, "m", _ZaloJSBridge_jsCall).call(this, action, options, callback, isMultiCallback, nRetry);
|
|
5221
|
+
}, 500);
|
|
5222
|
+
}
|
|
5223
|
+
else {
|
|
5224
|
+
const errorCallback = {
|
|
5225
|
+
error_code: -5,
|
|
5226
|
+
error_message: 'Not ready!',
|
|
5227
|
+
data: {
|
|
5228
|
+
userAgent: this._userAgent,
|
|
5229
|
+
options: options,
|
|
5230
|
+
jsToken: this._jsAccessTk,
|
|
5231
|
+
access_token: this._accessTk
|
|
5232
|
+
},
|
|
5233
|
+
action: actionName,
|
|
5234
|
+
js_error: error
|
|
5235
|
+
};
|
|
5236
|
+
this.onJSCall(key, errorCallback);
|
|
5237
|
+
return false;
|
|
5238
|
+
}
|
|
5126
5239
|
}
|
|
5127
5240
|
}
|
|
5128
|
-
|
|
5129
|
-
|
|
5130
|
-
return Promise.resolve(this.clearSync());
|
|
5131
|
-
});
|
|
5132
|
-
}
|
|
5133
|
-
clearSync() {
|
|
5134
|
-
__classPrivateFieldGet(this, _LocalResourceStorage_resourceInfo, "f").keys.forEach((key) => {
|
|
5135
|
-
if (__classPrivateFieldGet(this, _LocalResourceStorage_prefix, "f") && key.indexOf(__classPrivateFieldGet(this, _LocalResourceStorage_prefix, "f")) < 0) {
|
|
5136
|
-
return;
|
|
5137
|
-
}
|
|
5138
|
-
__classPrivateFieldGet(this, _LocalResourceStorage_storage, "f").removeItem(key);
|
|
5139
|
-
__classPrivateFieldGet(this, _LocalResourceStorage_resourceInfo, "f").keys.delete(key);
|
|
5140
|
-
});
|
|
5241
|
+
catch (error) {
|
|
5242
|
+
console.log('jsCall', 'error', error);
|
|
5141
5243
|
}
|
|
5142
|
-
|
|
5143
|
-
|
|
5244
|
+
return false;
|
|
5245
|
+
};
|
|
5144
5246
|
|
|
5145
|
-
var _NativeResourceStorage_appId, _NativeResourceStorage_resourceInfo;
|
|
5146
|
-
class NativeResourceStorage
|
|
5247
|
+
var _NativeResourceStorage_appId, _NativeResourceStorage_resourceInfo, _NativeResourceStorage_bridge;
|
|
5248
|
+
class NativeResourceStorage {
|
|
5147
5249
|
constructor(appId) {
|
|
5148
|
-
super();
|
|
5149
5250
|
_NativeResourceStorage_appId.set(this, void 0);
|
|
5150
5251
|
_NativeResourceStorage_resourceInfo.set(this, void 0);
|
|
5252
|
+
_NativeResourceStorage_bridge.set(this, void 0);
|
|
5151
5253
|
__classPrivateFieldSet(this, _NativeResourceStorage_resourceInfo, {
|
|
5152
5254
|
keys: new Set(),
|
|
5153
5255
|
currentSize: 0,
|
|
5154
5256
|
limitSize: STORAGE_LIMIT
|
|
5155
5257
|
}, "f");
|
|
5156
5258
|
__classPrivateFieldSet(this, _NativeResourceStorage_appId, appId, "f");
|
|
5259
|
+
__classPrivateFieldSet(this, _NativeResourceStorage_bridge, ZaloJSBridge.getInstance(), "f");
|
|
5157
5260
|
}
|
|
5158
5261
|
get(keys) {
|
|
5159
5262
|
return __awaiter(this, void 0, void 0, function* () {
|
|
5160
|
-
return yield this
|
|
5263
|
+
return yield __classPrivateFieldGet(this, _NativeResourceStorage_bridge, "f")
|
|
5264
|
+
.callNative(ACTION.ZBROWSER_MPDS, {
|
|
5161
5265
|
mpds_action: 'mpds.get',
|
|
5162
5266
|
mpds_data: {
|
|
5163
5267
|
keys
|
|
@@ -5165,7 +5269,8 @@ class NativeResourceStorage extends ZJSBridgeProvider {
|
|
|
5165
5269
|
appId: __classPrivateFieldGet(this, _NativeResourceStorage_appId, "f")
|
|
5166
5270
|
}, {
|
|
5167
5271
|
isMultiCallback: false
|
|
5168
|
-
})
|
|
5272
|
+
})
|
|
5273
|
+
.then((data) => {
|
|
5169
5274
|
let res = new Map();
|
|
5170
5275
|
if (data && data.mpds_data && data.mpds_data.map) {
|
|
5171
5276
|
res = new Map(Object.entries(data.mpds_data.map));
|
|
@@ -5176,7 +5281,8 @@ class NativeResourceStorage extends ZJSBridgeProvider {
|
|
|
5176
5281
|
}
|
|
5177
5282
|
set(data) {
|
|
5178
5283
|
return __awaiter(this, void 0, void 0, function* () {
|
|
5179
|
-
const errorKeys = yield this
|
|
5284
|
+
const errorKeys = yield __classPrivateFieldGet(this, _NativeResourceStorage_bridge, "f")
|
|
5285
|
+
.callNative(ACTION.ZBROWSER_MPDS, {
|
|
5180
5286
|
mpds_action: 'mpds.set',
|
|
5181
5287
|
mpds_data: {
|
|
5182
5288
|
map: data
|
|
@@ -5184,7 +5290,8 @@ class NativeResourceStorage extends ZJSBridgeProvider {
|
|
|
5184
5290
|
appId: __classPrivateFieldGet(this, _NativeResourceStorage_appId, "f")
|
|
5185
5291
|
}, {
|
|
5186
5292
|
isMultiCallback: false
|
|
5187
|
-
})
|
|
5293
|
+
})
|
|
5294
|
+
.then((data) => {
|
|
5188
5295
|
let res = [];
|
|
5189
5296
|
if (data && data.mpds_data && data.mpds_data.error_keys) {
|
|
5190
5297
|
res = data.mpds_data.error_keys;
|
|
@@ -5196,13 +5303,15 @@ class NativeResourceStorage extends ZJSBridgeProvider {
|
|
|
5196
5303
|
}
|
|
5197
5304
|
getInfo() {
|
|
5198
5305
|
return __awaiter(this, void 0, void 0, function* () {
|
|
5199
|
-
const currentSize = yield this
|
|
5306
|
+
const currentSize = yield __classPrivateFieldGet(this, _NativeResourceStorage_bridge, "f")
|
|
5307
|
+
.callNative(ACTION.ZBROWSER_MPDS, {
|
|
5200
5308
|
mpds_action: 'mpds.get.size',
|
|
5201
5309
|
mpds_data: {},
|
|
5202
5310
|
appId: __classPrivateFieldGet(this, _NativeResourceStorage_appId, "f")
|
|
5203
5311
|
}, {
|
|
5204
5312
|
isMultiCallback: false
|
|
5205
|
-
})
|
|
5313
|
+
})
|
|
5314
|
+
.then((data) => {
|
|
5206
5315
|
let res = 0;
|
|
5207
5316
|
if (data && data.mpds_data && data.mpds_data.size) {
|
|
5208
5317
|
res = data.mpds_data.size;
|
|
@@ -5217,7 +5326,8 @@ class NativeResourceStorage extends ZJSBridgeProvider {
|
|
|
5217
5326
|
}
|
|
5218
5327
|
remove(keys) {
|
|
5219
5328
|
return __awaiter(this, void 0, void 0, function* () {
|
|
5220
|
-
const errorKeys = yield this
|
|
5329
|
+
const errorKeys = yield __classPrivateFieldGet(this, _NativeResourceStorage_bridge, "f")
|
|
5330
|
+
.callNative(ACTION.ZBROWSER_MPDS, {
|
|
5221
5331
|
mpds_action: 'mpds.remove.key',
|
|
5222
5332
|
mpds_data: {
|
|
5223
5333
|
keys: keys
|
|
@@ -5225,7 +5335,8 @@ class NativeResourceStorage extends ZJSBridgeProvider {
|
|
|
5225
5335
|
appId: __classPrivateFieldGet(this, _NativeResourceStorage_appId, "f")
|
|
5226
5336
|
}, {
|
|
5227
5337
|
isMultiCallback: false
|
|
5228
|
-
})
|
|
5338
|
+
})
|
|
5339
|
+
.then((data) => {
|
|
5229
5340
|
let res = [];
|
|
5230
5341
|
if (data && data.mpds_data && data.mpds_data.error_keys) {
|
|
5231
5342
|
res = data.mpds_data.error_keys;
|
|
@@ -5237,7 +5348,7 @@ class NativeResourceStorage extends ZJSBridgeProvider {
|
|
|
5237
5348
|
}
|
|
5238
5349
|
clear() {
|
|
5239
5350
|
return __awaiter(this, void 0, void 0, function* () {
|
|
5240
|
-
yield this.callNative(ACTION.ZBROWSER_MPDS, {
|
|
5351
|
+
yield __classPrivateFieldGet(this, _NativeResourceStorage_bridge, "f").callNative(ACTION.ZBROWSER_MPDS, {
|
|
5241
5352
|
mpds_action: 'mpds.clear.appData',
|
|
5242
5353
|
mpds_data: {},
|
|
5243
5354
|
appId: __classPrivateFieldGet(this, _NativeResourceStorage_appId, "f")
|
|
@@ -5245,7 +5356,7 @@ class NativeResourceStorage extends ZJSBridgeProvider {
|
|
|
5245
5356
|
});
|
|
5246
5357
|
}
|
|
5247
5358
|
}
|
|
5248
|
-
_NativeResourceStorage_appId = new WeakMap(), _NativeResourceStorage_resourceInfo = new WeakMap();
|
|
5359
|
+
_NativeResourceStorage_appId = new WeakMap(), _NativeResourceStorage_resourceInfo = new WeakMap(), _NativeResourceStorage_bridge = new WeakMap();
|
|
5249
5360
|
|
|
5250
5361
|
var _LocalStorageCreator_appId, _NativeStorageCreator_appId;
|
|
5251
5362
|
class StorageCreator {
|
|
@@ -5497,18 +5608,13 @@ class OpenApi {
|
|
|
5497
5608
|
*/
|
|
5498
5609
|
static getPhoneNumber(object) {
|
|
5499
5610
|
return __awaiter(this, void 0, void 0, function* () {
|
|
5500
|
-
return yield this.callNative(ACTION.MP_GET_NUMBER, {}, {
|
|
5611
|
+
return yield this.getJSBridge().callNative(ACTION.MP_GET_NUMBER, {}, {
|
|
5501
5612
|
isMultiCallback: true,
|
|
5502
|
-
|
|
5503
|
-
|
|
5504
|
-
|
|
5505
|
-
|
|
5506
|
-
|
|
5507
|
-
return Promise.resolve(res);
|
|
5508
|
-
}
|
|
5509
|
-
else {
|
|
5510
|
-
return Promise.reject(error);
|
|
5511
|
-
}
|
|
5613
|
+
successCallback: (data) => {
|
|
5614
|
+
const res = {
|
|
5615
|
+
number: data
|
|
5616
|
+
};
|
|
5617
|
+
return Promise.resolve(res);
|
|
5512
5618
|
},
|
|
5513
5619
|
delay: this.isIOS ? 400 : 0
|
|
5514
5620
|
});
|
|
@@ -5527,7 +5633,7 @@ class Window {
|
|
|
5527
5633
|
*/
|
|
5528
5634
|
static closeApp(object) {
|
|
5529
5635
|
return __awaiter(this, void 0, void 0, function* () {
|
|
5530
|
-
yield this.callNative(ACTION.WINDOW_CLOSE, {});
|
|
5636
|
+
yield this.getJSBridge().callNative(ACTION.WINDOW_CLOSE, {});
|
|
5531
5637
|
});
|
|
5532
5638
|
}
|
|
5533
5639
|
/**
|
|
@@ -5559,7 +5665,7 @@ class Window {
|
|
|
5559
5665
|
mpInfo.appName = appInfo.name;
|
|
5560
5666
|
mpInfo.appAvtUrl = appInfo.logoUrl;
|
|
5561
5667
|
}
|
|
5562
|
-
yield this.callNative(ACTION.OPEN_MP, {
|
|
5668
|
+
yield this.getJSBridge().callNative(ACTION.OPEN_MP, {
|
|
5563
5669
|
mpUrl: `${MINI_APP_INTERNAL_LINK}/${appId}/${queryParamString.length > 0 ? '?' + queryParamString : ''}`,
|
|
5564
5670
|
mpInfo: mpInfo
|
|
5565
5671
|
});
|
|
@@ -5575,7 +5681,7 @@ class Window {
|
|
|
5575
5681
|
*/
|
|
5576
5682
|
static openWebview(url) {
|
|
5577
5683
|
return __awaiter(this, void 0, void 0, function* () {
|
|
5578
|
-
yield this.callNative(ACTION.OPEN_INAPP, {
|
|
5684
|
+
yield this.getJSBridge().callNative(ACTION.OPEN_INAPP, {
|
|
5579
5685
|
url: url
|
|
5580
5686
|
});
|
|
5581
5687
|
});
|
|
@@ -5590,7 +5696,7 @@ class Window {
|
|
|
5590
5696
|
*/
|
|
5591
5697
|
static closeLoading(when) {
|
|
5592
5698
|
return __awaiter(this, void 0, void 0, function* () {
|
|
5593
|
-
yield this.callNative(ACTION.MP_CLOSE_LOADINGVIEW, {
|
|
5699
|
+
yield this.getJSBridge().callNative(ACTION.MP_CLOSE_LOADINGVIEW, {
|
|
5594
5700
|
at: new Date().getTime(),
|
|
5595
5701
|
when: when,
|
|
5596
5702
|
url: location.href
|
|
@@ -5617,30 +5723,24 @@ class Location {
|
|
|
5617
5723
|
*/
|
|
5618
5724
|
static getLocation(object) {
|
|
5619
5725
|
return __awaiter(this, void 0, void 0, function* () {
|
|
5620
|
-
return yield this.callNative(ACTION.GET_LOCATION, {
|
|
5726
|
+
return yield this.getJSBridge().callNative(ACTION.GET_LOCATION, {
|
|
5621
5727
|
silent_request: false,
|
|
5622
5728
|
permission_description: 'Cho phép Zalo truy cập vào vị trí của thiết bị này?'
|
|
5623
5729
|
}, {
|
|
5624
5730
|
isMultiCallback: true,
|
|
5625
5731
|
haveTimeout: false,
|
|
5626
|
-
|
|
5627
|
-
|
|
5628
|
-
|
|
5629
|
-
|
|
5630
|
-
|
|
5631
|
-
|
|
5632
|
-
|
|
5633
|
-
|
|
5634
|
-
|
|
5635
|
-
|
|
5636
|
-
|
|
5637
|
-
|
|
5638
|
-
};
|
|
5639
|
-
return Promise.resolve(res);
|
|
5640
|
-
}
|
|
5641
|
-
else {
|
|
5642
|
-
return Promise.reject(error);
|
|
5643
|
-
}
|
|
5732
|
+
successCallback: (data) => {
|
|
5733
|
+
const res = {
|
|
5734
|
+
/** latitude */
|
|
5735
|
+
latitude: data.latitude,
|
|
5736
|
+
/** longitude */
|
|
5737
|
+
longitude: data.longitude,
|
|
5738
|
+
/** timestamp */
|
|
5739
|
+
timestamp: data.timestamp,
|
|
5740
|
+
/** provider */
|
|
5741
|
+
provider: data.provider
|
|
5742
|
+
};
|
|
5743
|
+
return Promise.resolve(res);
|
|
5644
5744
|
},
|
|
5645
5745
|
delay: this.isIOS ? 400 : 0
|
|
5646
5746
|
});
|
|
@@ -5656,7 +5756,7 @@ class Location {
|
|
|
5656
5756
|
*/
|
|
5657
5757
|
static sendLocation(object) {
|
|
5658
5758
|
return __awaiter(this, void 0, void 0, function* () {
|
|
5659
|
-
yield this.callNative(ACTION.QUERY_LOCATION_HIDE, {
|
|
5759
|
+
yield this.getJSBridge().callNative(ACTION.QUERY_LOCATION_HIDE, {
|
|
5660
5760
|
title: object.title,
|
|
5661
5761
|
touserid: object.toUserId,
|
|
5662
5762
|
zapp: this.getZAppId()
|
|
@@ -5676,17 +5776,12 @@ class Media {
|
|
|
5676
5776
|
*/
|
|
5677
5777
|
static requestCameraPermission(object) {
|
|
5678
5778
|
return __awaiter(this, void 0, void 0, function* () {
|
|
5679
|
-
return yield this.callNative(ACTION.REQUEST_PERMISSION_CAMERA, {}, {
|
|
5680
|
-
|
|
5681
|
-
|
|
5682
|
-
|
|
5683
|
-
|
|
5684
|
-
|
|
5685
|
-
});
|
|
5686
|
-
}
|
|
5687
|
-
else {
|
|
5688
|
-
return Promise.reject(error);
|
|
5689
|
-
}
|
|
5779
|
+
return yield this.getJSBridge().callNative(ACTION.REQUEST_PERMISSION_CAMERA, {}, {
|
|
5780
|
+
successCallback: () => {
|
|
5781
|
+
return Promise.resolve({
|
|
5782
|
+
userAllow: true,
|
|
5783
|
+
message: 'User Allow'
|
|
5784
|
+
});
|
|
5690
5785
|
}
|
|
5691
5786
|
});
|
|
5692
5787
|
});
|
|
@@ -5712,7 +5807,7 @@ class Media {
|
|
|
5712
5807
|
imageUrl: object.imageUrl
|
|
5713
5808
|
};
|
|
5714
5809
|
}
|
|
5715
|
-
return yield this.callNative(ACTION.SAVE_IMAGE_GALLERY, Object.assign({}, data));
|
|
5810
|
+
return yield this.getJSBridge().callNative(ACTION.SAVE_IMAGE_GALLERY, Object.assign({}, data));
|
|
5716
5811
|
});
|
|
5717
5812
|
}
|
|
5718
5813
|
}
|
|
@@ -5727,7 +5822,7 @@ class Zalo {
|
|
|
5727
5822
|
*/
|
|
5728
5823
|
static viewOAQr(object) {
|
|
5729
5824
|
return __awaiter(this, void 0, void 0, function* () {
|
|
5730
|
-
yield this.callNative(ACTION.VIEW_MYQR, {
|
|
5825
|
+
yield this.getJSBridge().callNative(ACTION.VIEW_MYQR, {
|
|
5731
5826
|
dpn: object.displayName,
|
|
5732
5827
|
uid: object.id,
|
|
5733
5828
|
zapp: this.getZAppId()
|
|
@@ -5746,7 +5841,7 @@ class Zalo {
|
|
|
5746
5841
|
*/
|
|
5747
5842
|
static openProfile(object) {
|
|
5748
5843
|
return __awaiter(this, void 0, void 0, function* () {
|
|
5749
|
-
return yield this.callNative(ACTION.OPEN_PROFILE, {
|
|
5844
|
+
return yield this.getJSBridge().callNative(ACTION.OPEN_PROFILE, {
|
|
5750
5845
|
uId: object.id,
|
|
5751
5846
|
type: ProfileType[object.type],
|
|
5752
5847
|
zapp: this.getZAppId(),
|
|
@@ -5764,9 +5859,10 @@ class Zalo {
|
|
|
5764
5859
|
*/
|
|
5765
5860
|
static openChat(object) {
|
|
5766
5861
|
return __awaiter(this, void 0, void 0, function* () {
|
|
5767
|
-
return yield this.callNative(ACTION.OPEN_CHAT, {
|
|
5862
|
+
return yield this.getJSBridge().callNative(ACTION.OPEN_CHAT, {
|
|
5768
5863
|
uId: object.id,
|
|
5769
5864
|
type: ChatType[object.type],
|
|
5865
|
+
msg: object.message || '',
|
|
5770
5866
|
zapp: this.getZAppId(),
|
|
5771
5867
|
sourceId: object.sourceId,
|
|
5772
5868
|
sourceIndex: object.sourceIndex
|
|
@@ -5805,7 +5901,9 @@ class Zalo {
|
|
|
5805
5901
|
};
|
|
5806
5902
|
break;
|
|
5807
5903
|
}
|
|
5808
|
-
return yield this.
|
|
5904
|
+
return yield this.getJSBridge()
|
|
5905
|
+
.callNative(ACTION.OPEN_POSTFEED, Object.assign(Object.assign({ type: PostFeedType[object.type] }, reqData), { zapp: this.getZAppId() }))
|
|
5906
|
+
.then((res) => {
|
|
5809
5907
|
return {
|
|
5810
5908
|
status: res.status,
|
|
5811
5909
|
shareType: res.share_type,
|
|
@@ -5824,7 +5922,7 @@ class Zalo {
|
|
|
5824
5922
|
*/
|
|
5825
5923
|
static followOA(object) {
|
|
5826
5924
|
return __awaiter(this, void 0, void 0, function* () {
|
|
5827
|
-
yield this.callNative(ACTION.FOLLOW_OA, {
|
|
5925
|
+
yield this.getJSBridge().callNative(ACTION.FOLLOW_OA, {
|
|
5828
5926
|
uid: object.id,
|
|
5829
5927
|
showDialogConfirm: true,
|
|
5830
5928
|
zapp: this.getZAppId()
|
|
@@ -5843,7 +5941,7 @@ class Zalo {
|
|
|
5843
5941
|
*/
|
|
5844
5942
|
static unfollowOA(object) {
|
|
5845
5943
|
return __awaiter(this, void 0, void 0, function* () {
|
|
5846
|
-
yield this.callNative(ACTION.UNFOLLOW_OA, {
|
|
5944
|
+
yield this.getJSBridge().callNative(ACTION.UNFOLLOW_OA, {
|
|
5847
5945
|
uid: object.id,
|
|
5848
5946
|
zapp: this.getZAppId()
|
|
5849
5947
|
}, {
|
|
@@ -5865,7 +5963,8 @@ class Zalo {
|
|
|
5865
5963
|
switch (object.type) {
|
|
5866
5964
|
case 'image':
|
|
5867
5965
|
let photoUrls = [];
|
|
5868
|
-
if (Array.isArray(object.data.imageUrls) &&
|
|
5966
|
+
if (Array.isArray(object.data.imageUrls) &&
|
|
5967
|
+
object.data.imageUrls.length > 0) {
|
|
5869
5968
|
photoUrls = object.data.imageUrls;
|
|
5870
5969
|
}
|
|
5871
5970
|
else {
|
|
@@ -5932,9 +6031,11 @@ class Zalo {
|
|
|
5932
6031
|
object.type = 'link';
|
|
5933
6032
|
}
|
|
5934
6033
|
}
|
|
5935
|
-
return yield this.
|
|
6034
|
+
return yield this.getJSBridge()
|
|
6035
|
+
.callNative(ACTION.OPEN_SHARESHEET, Object.assign(Object.assign({ type: ShareSheetType[object.type] }, reqData), { zapp: this.getZAppId() }), {
|
|
5936
6036
|
haveTimeout: false
|
|
5937
|
-
})
|
|
6037
|
+
})
|
|
6038
|
+
.then((res) => {
|
|
5938
6039
|
return {
|
|
5939
6040
|
status: res.status,
|
|
5940
6041
|
shareType: res.share_type,
|
|
@@ -5953,7 +6054,7 @@ class Zalo {
|
|
|
5953
6054
|
*/
|
|
5954
6055
|
static createShortcut(url, title, icon) {
|
|
5955
6056
|
return __awaiter(this, void 0, void 0, function* () {
|
|
5956
|
-
return yield this.callNative(ACTION.CREATE_SHORTCUT, {
|
|
6057
|
+
return yield this.getJSBridge().callNative(ACTION.CREATE_SHORTCUT, {
|
|
5957
6058
|
url: url,
|
|
5958
6059
|
title: title,
|
|
5959
6060
|
iconUrl: icon
|
|
@@ -5970,15 +6071,14 @@ class Zalo {
|
|
|
5970
6071
|
*/
|
|
5971
6072
|
static openProfilePicker(maxProfile) {
|
|
5972
6073
|
return __awaiter(this, void 0, void 0, function* () {
|
|
5973
|
-
return yield this.callNative(ACTION.MP_OPEN_PROFILE_PICKER, {
|
|
6074
|
+
return yield this.getJSBridge().callNative(ACTION.MP_OPEN_PROFILE_PICKER, {
|
|
5974
6075
|
maxProfile: maxProfile
|
|
5975
6076
|
}, {
|
|
5976
6077
|
isMultiCallback: true,
|
|
5977
|
-
|
|
5978
|
-
if (
|
|
5979
|
-
return Promise.resolve(
|
|
6078
|
+
successCallback: (data) => {
|
|
6079
|
+
if (Array.isArray(data)) {
|
|
6080
|
+
return Promise.resolve(data.map((item) => item.id));
|
|
5980
6081
|
}
|
|
5981
|
-
return Promise.reject(error);
|
|
5982
6082
|
}
|
|
5983
6083
|
});
|
|
5984
6084
|
});
|
|
@@ -5993,15 +6093,15 @@ class Zalo {
|
|
|
5993
6093
|
*/
|
|
5994
6094
|
static getActionsSupported(object) {
|
|
5995
6095
|
return __awaiter(this, void 0, void 0, function* () {
|
|
5996
|
-
return yield this.callNative(ACTION.GET_SUPPORTED_ACTIONS, {}, {
|
|
6096
|
+
return yield this.getJSBridge().callNative(ACTION.GET_SUPPORTED_ACTIONS, {}, {
|
|
5997
6097
|
isMultiCallback: false,
|
|
5998
|
-
|
|
6098
|
+
successCallback: (data) => {
|
|
5999
6099
|
const platform = getPlatform();
|
|
6000
|
-
if (Array.isArray(
|
|
6001
|
-
|
|
6100
|
+
if (Array.isArray(data.actions) &&
|
|
6101
|
+
data.actions.length > 0) {
|
|
6002
6102
|
const skipJumpActions = Object.keys(ACTION).filter((item) => ACTION[item].skip_jump);
|
|
6003
6103
|
const res = {
|
|
6004
|
-
actions: [...
|
|
6104
|
+
actions: [...data.actions, ...skipJumpActions]
|
|
6005
6105
|
};
|
|
6006
6106
|
return Promise.resolve(res);
|
|
6007
6107
|
}
|
|
@@ -6011,7 +6111,6 @@ class Zalo {
|
|
|
6011
6111
|
};
|
|
6012
6112
|
return Promise.resolve(res);
|
|
6013
6113
|
}
|
|
6014
|
-
return Promise.reject(error);
|
|
6015
6114
|
}
|
|
6016
6115
|
});
|
|
6017
6116
|
});
|
|
@@ -6035,7 +6134,7 @@ class Zalo {
|
|
|
6035
6134
|
enable: 1,
|
|
6036
6135
|
aspect_ratio: '1:1'
|
|
6037
6136
|
};
|
|
6038
|
-
return yield this.callNative(ACTION.PICK_MEDIA, {
|
|
6137
|
+
return yield this.getJSBridge().callNative(ACTION.PICK_MEDIA, {
|
|
6039
6138
|
media_type: MediaPickerType[type],
|
|
6040
6139
|
edit_view: Object.assign(Object.assign({}, defaultEditView), editView),
|
|
6041
6140
|
silent_request: silentRequest,
|
|
@@ -6043,15 +6142,11 @@ class Zalo {
|
|
|
6043
6142
|
max_select_items: maxSelectItem
|
|
6044
6143
|
}, {
|
|
6045
6144
|
isMultiCallback: true,
|
|
6046
|
-
|
|
6047
|
-
|
|
6048
|
-
|
|
6049
|
-
|
|
6050
|
-
|
|
6051
|
-
};
|
|
6052
|
-
return Promise.resolve(res);
|
|
6053
|
-
}
|
|
6054
|
-
return Promise.reject(error);
|
|
6145
|
+
successCallback: (data) => {
|
|
6146
|
+
const res = {
|
|
6147
|
+
data: data === null || data === void 0 ? void 0 : data.result_content
|
|
6148
|
+
};
|
|
6149
|
+
return Promise.resolve(res);
|
|
6055
6150
|
}
|
|
6056
6151
|
});
|
|
6057
6152
|
});
|
|
@@ -6066,7 +6161,7 @@ class Zalo {
|
|
|
6066
6161
|
*/
|
|
6067
6162
|
static openOutApp(url) {
|
|
6068
6163
|
return __awaiter(this, void 0, void 0, function* () {
|
|
6069
|
-
return yield this.callNative(ACTION.OPEN_OUTAPP, {
|
|
6164
|
+
return yield this.getJSBridge().callNative(ACTION.OPEN_OUTAPP, {
|
|
6070
6165
|
url: url
|
|
6071
6166
|
});
|
|
6072
6167
|
});
|
|
@@ -6105,7 +6200,7 @@ class Routing {
|
|
|
6105
6200
|
*/
|
|
6106
6201
|
static sendDataToPreviousMiniApp(object) {
|
|
6107
6202
|
return __awaiter(this, void 0, void 0, function* () {
|
|
6108
|
-
return yield this.callNative(ACTION.WEBVIEW_SET_RESULT, {
|
|
6203
|
+
return yield this.getJSBridge().callNative(ACTION.WEBVIEW_SET_RESULT, {
|
|
6109
6204
|
result: stringifyData(object.data)
|
|
6110
6205
|
});
|
|
6111
6206
|
});
|
|
@@ -6130,11 +6225,10 @@ class Routing {
|
|
|
6130
6225
|
}
|
|
6131
6226
|
}
|
|
6132
6227
|
|
|
6133
|
-
var _ZaloMiniProgramSDKService_zAppId, _ZaloMiniProgramSDKService_appId, _ZaloMiniProgramSDKService_appConfig, _ZaloMiniProgramSDKService_zOAuth, _ZaloMiniProgramSDKService_zOAuthVrf, _ZaloMiniProgramSDKService_accessToken, _ZaloMiniProgramSDKService_refreshToken, _ZaloMiniProgramSDKService_cache, _ZaloMiniProgramSDKService_prevGetTokenTimestamp, _ZaloMiniProgramSDKService_tokenExpiresIn,
|
|
6134
|
-
class ZaloMiniProgramSDKService
|
|
6228
|
+
var _ZaloMiniProgramSDKService_zAppId, _ZaloMiniProgramSDKService_appId, _ZaloMiniProgramSDKService_appConfig, _ZaloMiniProgramSDKService_zOAuth, _ZaloMiniProgramSDKService_zOAuthVrf, _ZaloMiniProgramSDKService_accessToken, _ZaloMiniProgramSDKService_refreshToken, _ZaloMiniProgramSDKService_cache, _ZaloMiniProgramSDKService_bridge, _ZaloMiniProgramSDKService_prevGetTokenTimestamp, _ZaloMiniProgramSDKService_tokenExpiresIn, _ZaloMiniProgramSDKService_deviceId, _ZaloMiniProgramSDKService_actionBarConfig, _ZaloMiniProgramSDKService_getActionsSupported;
|
|
6229
|
+
class ZaloMiniProgramSDKService {
|
|
6135
6230
|
constructor() {
|
|
6136
6231
|
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s;
|
|
6137
|
-
super();
|
|
6138
6232
|
_ZaloMiniProgramSDKService_zAppId.set(this, ZAPP_ID);
|
|
6139
6233
|
_ZaloMiniProgramSDKService_appId.set(this, APP_ID);
|
|
6140
6234
|
_ZaloMiniProgramSDKService_appConfig.set(this, APP_CONFIG);
|
|
@@ -6147,9 +6241,10 @@ class ZaloMiniProgramSDKService extends ZJSBridgeProvider {
|
|
|
6147
6241
|
getToken: 0
|
|
6148
6242
|
}
|
|
6149
6243
|
});
|
|
6244
|
+
_ZaloMiniProgramSDKService_bridge.set(this, void 0);
|
|
6150
6245
|
_ZaloMiniProgramSDKService_prevGetTokenTimestamp.set(this, void 0);
|
|
6151
6246
|
_ZaloMiniProgramSDKService_tokenExpiresIn.set(this, void 0);
|
|
6152
|
-
|
|
6247
|
+
_ZaloMiniProgramSDKService_deviceId.set(this, void 0);
|
|
6153
6248
|
this.events = ZMPEEmitter.getInstance();
|
|
6154
6249
|
this.isIOS = checkPlatform().isIOS;
|
|
6155
6250
|
_ZaloMiniProgramSDKService_actionBarConfig.set(this, void 0);
|
|
@@ -6159,31 +6254,6 @@ class ZaloMiniProgramSDKService extends ZJSBridgeProvider {
|
|
|
6159
6254
|
this.setActionBarConfig = (setState) => {
|
|
6160
6255
|
__classPrivateFieldSet(this, _ZaloMiniProgramSDKService_actionBarConfig, setState(__classPrivateFieldGet(this, _ZaloMiniProgramSDKService_actionBarConfig, "f")), "f");
|
|
6161
6256
|
};
|
|
6162
|
-
_ZaloMiniProgramSDKService_callJump.set(this, () => {
|
|
6163
|
-
return new Promise((resolve, reject) => {
|
|
6164
|
-
if (!_.isUndefined(__classPrivateFieldGet(this, _ZaloMiniProgramSDKService_cookies, "f")) && !_.isNull(__classPrivateFieldGet(this, _ZaloMiniProgramSDKService_cookies, "f"))) {
|
|
6165
|
-
resolve(__classPrivateFieldGet(this, _ZaloMiniProgramSDKService_cookies, "f"));
|
|
6166
|
-
}
|
|
6167
|
-
else {
|
|
6168
|
-
this.callNative(ACTION.JUMP_LOGIN, {})
|
|
6169
|
-
.then((data) => {
|
|
6170
|
-
const cookies = (data && data.cookiesOAuthLogins) || [];
|
|
6171
|
-
const jsToken = cookies.find((cookie) => cookie.name === COOKIE_NAME.JS_TOKEN);
|
|
6172
|
-
if (jsToken) {
|
|
6173
|
-
this.setJSToken(jsToken.value);
|
|
6174
|
-
window.ZJSBridge.setJSToken &&
|
|
6175
|
-
window.ZJSBridge.setJSToken(jsToken.value);
|
|
6176
|
-
}
|
|
6177
|
-
__classPrivateFieldSet(this, _ZaloMiniProgramSDKService_cookies, cookies, "f");
|
|
6178
|
-
resolve(cookies);
|
|
6179
|
-
})
|
|
6180
|
-
.catch((error) => {
|
|
6181
|
-
reject(error);
|
|
6182
|
-
});
|
|
6183
|
-
}
|
|
6184
|
-
});
|
|
6185
|
-
});
|
|
6186
|
-
_ZaloMiniProgramSDKService_setNavigationBarRightButton.set(this, NavigationBar.setNavigationBarRightButton);
|
|
6187
6257
|
this.getVersion = Basics.getVersion;
|
|
6188
6258
|
this.getSystemInfo = Basics.getSystemInfo;
|
|
6189
6259
|
this.setNavigationBarTitle = NavigationBar.setNavigationBarTitle;
|
|
@@ -6253,6 +6323,8 @@ class ZaloMiniProgramSDKService extends ZJSBridgeProvider {
|
|
|
6253
6323
|
this.isShowNavBar = true;
|
|
6254
6324
|
__classPrivateFieldSet(this, _ZaloMiniProgramSDKService_prevGetTokenTimestamp, 0, "f");
|
|
6255
6325
|
__classPrivateFieldSet(this, _ZaloMiniProgramSDKService_tokenExpiresIn, 0, "f");
|
|
6326
|
+
__classPrivateFieldSet(this, _ZaloMiniProgramSDKService_deviceId, '', "f");
|
|
6327
|
+
__classPrivateFieldSet(this, _ZaloMiniProgramSDKService_bridge, ZaloJSBridge.getInstance(), "f");
|
|
6256
6328
|
const showHomeButton = ((_b = (_a = __classPrivateFieldGet(this, _ZaloMiniProgramSDKService_appConfig, "f")) === null || _a === void 0 ? void 0 : _a.app) === null || _b === void 0 ? void 0 : _b.leftButton) === 'home' ||
|
|
6257
6329
|
((_d = (_c = __classPrivateFieldGet(this, _ZaloMiniProgramSDKService_appConfig, "f")) === null || _c === void 0 ? void 0 : _c.app) === null || _d === void 0 ? void 0 : _d.leftButton) === 'both'
|
|
6258
6330
|
? ACTION_LEFT_BUTTON_TYPE.SHOW_HOME
|
|
@@ -6296,9 +6368,19 @@ class ZaloMiniProgramSDKService extends ZJSBridgeProvider {
|
|
|
6296
6368
|
getZAppId() {
|
|
6297
6369
|
return __classPrivateFieldGet(this, _ZaloMiniProgramSDKService_zAppId, "f");
|
|
6298
6370
|
}
|
|
6371
|
+
getDeviceId() {
|
|
6372
|
+
return __classPrivateFieldGet(this, _ZaloMiniProgramSDKService_deviceId, "f");
|
|
6373
|
+
}
|
|
6374
|
+
getJSBridge() {
|
|
6375
|
+
return __classPrivateFieldGet(this, _ZaloMiniProgramSDKService_bridge, "f");
|
|
6376
|
+
}
|
|
6299
6377
|
login(object) {
|
|
6300
6378
|
return __awaiter(this, void 0, void 0, function* () {
|
|
6301
|
-
const cookies = yield __classPrivateFieldGet(this,
|
|
6379
|
+
const cookies = yield __classPrivateFieldGet(this, _ZaloMiniProgramSDKService_bridge, "f").jump();
|
|
6380
|
+
const deviceId = cookies.find((cookie) => cookie.name === COOKIE_NAME.DEVICE_ID);
|
|
6381
|
+
if (deviceId) {
|
|
6382
|
+
__classPrivateFieldSet(this, _ZaloMiniProgramSDKService_deviceId, deviceId.value, "f");
|
|
6383
|
+
}
|
|
6302
6384
|
const zOAuthCookie = cookies.find((cookie) => cookie.name === COOKIE_NAME.ZOAUTH);
|
|
6303
6385
|
const zOAuthVrfCookie = cookies.find((cookie) => cookie.name === COOKIE_NAME.ZOAUTH_VRF);
|
|
6304
6386
|
if (!_.isUndefined(zOAuthCookie) &&
|
|
@@ -6315,23 +6397,23 @@ class ZaloMiniProgramSDKService extends ZJSBridgeProvider {
|
|
|
6315
6397
|
yield this.loginZaloV3();
|
|
6316
6398
|
}
|
|
6317
6399
|
if (!__classPrivateFieldGet(this, _ZaloMiniProgramSDKService_accessToken, "f")) {
|
|
6318
|
-
throw apiResponse.error.loginFailed();
|
|
6400
|
+
throw apiResponse.error.loginFailed('Invalid authorization code');
|
|
6319
6401
|
}
|
|
6320
6402
|
return __classPrivateFieldGet(this, _ZaloMiniProgramSDKService_accessToken, "f");
|
|
6321
6403
|
}
|
|
6322
|
-
throw apiResponse.error.loginFailed();
|
|
6404
|
+
throw apiResponse.error.loginFailed('Zalo app has not been activated');
|
|
6323
6405
|
});
|
|
6324
6406
|
}
|
|
6325
6407
|
loginZaloV3() {
|
|
6326
6408
|
return __awaiter(this, void 0, void 0, function* () {
|
|
6327
|
-
return yield fetch(`${APIS.GET_ACCESS_TOKEN_V3}?app_id=${__classPrivateFieldGet(this, _ZaloMiniProgramSDKService_zAppId, "f")}&redirect_uri=${MINI_APP_INTERNAL_LINK}/${__classPrivateFieldGet(this, _ZaloMiniProgramSDKService_appId, "f")}/&code=${__classPrivateFieldGet(this, _ZaloMiniProgramSDKService_zOAuth, "f")}&isSDK=
|
|
6409
|
+
return yield fetch(`${APIS.GET_ACCESS_TOKEN_V3}?app_id=${__classPrivateFieldGet(this, _ZaloMiniProgramSDKService_zAppId, "f")}&redirect_uri=${MINI_APP_INTERNAL_LINK}/${__classPrivateFieldGet(this, _ZaloMiniProgramSDKService_appId, "f")}/&code=${__classPrivateFieldGet(this, _ZaloMiniProgramSDKService_zOAuth, "f")}&isSDK=true`).then((response) => __awaiter(this, void 0, void 0, function* () {
|
|
6328
6410
|
let resData = yield response.json();
|
|
6329
6411
|
if (resData.access_token) {
|
|
6330
6412
|
__classPrivateFieldSet(this, _ZaloMiniProgramSDKService_accessToken, resData.access_token, "f");
|
|
6331
6413
|
const expiresIn = parseInt(resData.expires_in) * 1000;
|
|
6332
6414
|
__classPrivateFieldSet(this, _ZaloMiniProgramSDKService_tokenExpiresIn, expiresIn, "f");
|
|
6333
6415
|
__classPrivateFieldSet(this, _ZaloMiniProgramSDKService_prevGetTokenTimestamp, new Date().getTime(), "f");
|
|
6334
|
-
this.
|
|
6416
|
+
__classPrivateFieldGet(this, _ZaloMiniProgramSDKService_bridge, "f").accessTk = __classPrivateFieldGet(this, _ZaloMiniProgramSDKService_accessToken, "f") || '';
|
|
6335
6417
|
window.ZJSBridge.setZAccSession &&
|
|
6336
6418
|
window.ZJSBridge.setZAccSession(__classPrivateFieldGet(this, _ZaloMiniProgramSDKService_accessToken, "f") || '');
|
|
6337
6419
|
return __classPrivateFieldGet(this, _ZaloMiniProgramSDKService_accessToken, "f");
|
|
@@ -6368,7 +6450,7 @@ class ZaloMiniProgramSDKService extends ZJSBridgeProvider {
|
|
|
6368
6450
|
const expiresIn = parseInt(resData.expires_in) * 1000;
|
|
6369
6451
|
__classPrivateFieldSet(this, _ZaloMiniProgramSDKService_tokenExpiresIn, expiresIn, "f");
|
|
6370
6452
|
__classPrivateFieldSet(this, _ZaloMiniProgramSDKService_prevGetTokenTimestamp, new Date().getTime(), "f");
|
|
6371
|
-
this.
|
|
6453
|
+
__classPrivateFieldGet(this, _ZaloMiniProgramSDKService_bridge, "f").accessTk = __classPrivateFieldGet(this, _ZaloMiniProgramSDKService_accessToken, "f") || '';
|
|
6372
6454
|
window.ZJSBridge.setZAccSession &&
|
|
6373
6455
|
window.ZJSBridge.setZAccSession(__classPrivateFieldGet(this, _ZaloMiniProgramSDKService_accessToken, "f") || '');
|
|
6374
6456
|
return __classPrivateFieldGet(this, _ZaloMiniProgramSDKService_accessToken, "f");
|
|
@@ -6389,7 +6471,7 @@ class ZaloMiniProgramSDKService extends ZJSBridgeProvider {
|
|
|
6389
6471
|
});
|
|
6390
6472
|
}
|
|
6391
6473
|
}
|
|
6392
|
-
_ZaloMiniProgramSDKService_zAppId = new WeakMap(), _ZaloMiniProgramSDKService_appId = new WeakMap(), _ZaloMiniProgramSDKService_appConfig = new WeakMap(), _ZaloMiniProgramSDKService_zOAuth = new WeakMap(), _ZaloMiniProgramSDKService_zOAuthVrf = new WeakMap(), _ZaloMiniProgramSDKService_accessToken = new WeakMap(), _ZaloMiniProgramSDKService_refreshToken = new WeakMap(), _ZaloMiniProgramSDKService_cache = new WeakMap(),
|
|
6474
|
+
_ZaloMiniProgramSDKService_zAppId = new WeakMap(), _ZaloMiniProgramSDKService_appId = new WeakMap(), _ZaloMiniProgramSDKService_appConfig = new WeakMap(), _ZaloMiniProgramSDKService_zOAuth = new WeakMap(), _ZaloMiniProgramSDKService_zOAuthVrf = new WeakMap(), _ZaloMiniProgramSDKService_accessToken = new WeakMap(), _ZaloMiniProgramSDKService_refreshToken = new WeakMap(), _ZaloMiniProgramSDKService_cache = new WeakMap(), _ZaloMiniProgramSDKService_bridge = new WeakMap(), _ZaloMiniProgramSDKService_prevGetTokenTimestamp = new WeakMap(), _ZaloMiniProgramSDKService_tokenExpiresIn = new WeakMap(), _ZaloMiniProgramSDKService_deviceId = new WeakMap(), _ZaloMiniProgramSDKService_actionBarConfig = new WeakMap(), _ZaloMiniProgramSDKService_getActionsSupported = new WeakMap();
|
|
6393
6475
|
|
|
6394
6476
|
var _MockSDKService_appId, _MockSDKService_appConfig, _MockSDKService_zOAuth, _MockSDKService_accessToken, _MockSDKService_cache, _MockSDKService_loggedId;
|
|
6395
6477
|
class MockSDKService {
|
|
@@ -6410,6 +6492,9 @@ class MockSDKService {
|
|
|
6410
6492
|
this.getAppId = () => {
|
|
6411
6493
|
return __classPrivateFieldGet(this, _MockSDKService_appId, "f");
|
|
6412
6494
|
};
|
|
6495
|
+
this.getDeviceId = () => {
|
|
6496
|
+
return '';
|
|
6497
|
+
};
|
|
6413
6498
|
this.login = () => {
|
|
6414
6499
|
__classPrivateFieldSet(this, _MockSDKService_loggedId, true, "f");
|
|
6415
6500
|
return Promise.resolve(__classPrivateFieldGet(this, _MockSDKService_zOAuth, "f"));
|
|
@@ -8120,90 +8205,175 @@ function getFnParamNames(fn) {
|
|
|
8120
8205
|
.replace(/\s/gi, '')
|
|
8121
8206
|
.split(',');
|
|
8122
8207
|
}
|
|
8123
|
-
|
|
8124
|
-
|
|
8125
|
-
|
|
8126
|
-
|
|
8127
|
-
|
|
8128
|
-
|
|
8129
|
-
|
|
8130
|
-
|
|
8131
|
-
|
|
8132
|
-
|
|
8133
|
-
|
|
8134
|
-
|
|
8135
|
-
|
|
8136
|
-
|
|
8137
|
-
|
|
8138
|
-
|
|
8139
|
-
|
|
8140
|
-
|
|
8141
|
-
|
|
8208
|
+
/**
|
|
8209
|
+
* Copies all metadata from one object to another.
|
|
8210
|
+
* Useful for overwriting function definition in
|
|
8211
|
+
* decorators while keeping all previously
|
|
8212
|
+
* attached metadata
|
|
8213
|
+
*
|
|
8214
|
+
* @param from object to copy metadata from
|
|
8215
|
+
* @param to object to copy metadata to
|
|
8216
|
+
*/
|
|
8217
|
+
function copyMetadata(from, to) {
|
|
8218
|
+
const metadataKeys = Reflect.getMetadataKeys(from);
|
|
8219
|
+
metadataKeys.map((key) => {
|
|
8220
|
+
const value = Reflect.getMetadata(key, from);
|
|
8221
|
+
Reflect.defineMetadata(key, value, to);
|
|
8222
|
+
});
|
|
8223
|
+
}
|
|
8224
|
+
/**
|
|
8225
|
+
* Apply the given decorator to all class methods
|
|
8226
|
+
*
|
|
8227
|
+
* @param decorator Method decorator to apply to all methods of a class
|
|
8228
|
+
* @param {string[]} options.exclude array of method names that won't be decorated
|
|
8229
|
+
* @param {boolean} options.deep if true, also decorates methods of the extended classes (recusrively)
|
|
8230
|
+
*/
|
|
8231
|
+
const DecorateAll = (decorator, options = {}) => {
|
|
8232
|
+
return (target) => {
|
|
8233
|
+
var _a;
|
|
8234
|
+
let descriptors = Object.getOwnPropertyDescriptors(target.prototype);
|
|
8235
|
+
if (options.deep) {
|
|
8236
|
+
let base = Object.getPrototypeOf(target);
|
|
8237
|
+
while (base.prototype) {
|
|
8238
|
+
const baseDescriptors = Object.getOwnPropertyDescriptors(base.prototype);
|
|
8239
|
+
descriptors = Object.assign(Object.assign({}, baseDescriptors), descriptors);
|
|
8240
|
+
base = Object.getPrototypeOf(base);
|
|
8241
|
+
}
|
|
8242
|
+
}
|
|
8243
|
+
for (const [propName, descriptor] of Object.entries(descriptors)) {
|
|
8244
|
+
const isMethod = typeof descriptor.value == 'function' && propName != 'constructor';
|
|
8245
|
+
if ((_a = options.exclude) === null || _a === void 0 ? void 0 : _a.includes(propName))
|
|
8246
|
+
continue;
|
|
8247
|
+
if (options.excludePrefix && propName.startsWith(options.excludePrefix))
|
|
8248
|
+
continue;
|
|
8249
|
+
if (!isMethod)
|
|
8250
|
+
continue;
|
|
8251
|
+
const originalMethod = descriptor.value;
|
|
8252
|
+
decorator(target, propName, descriptor);
|
|
8253
|
+
if (originalMethod != descriptor.value) {
|
|
8254
|
+
copyMetadata(originalMethod, descriptor.value);
|
|
8255
|
+
}
|
|
8256
|
+
Object.defineProperty(target.prototype, propName, descriptor);
|
|
8257
|
+
}
|
|
8258
|
+
};
|
|
8259
|
+
};
|
|
8260
|
+
const centralizedFunctionHandler = (target, propertyName, descriptor) => {
|
|
8261
|
+
const fn = descriptor.value;
|
|
8262
|
+
const argsName = getFnParamNames(fn);
|
|
8263
|
+
descriptor.value = function (...args) {
|
|
8264
|
+
try {
|
|
8265
|
+
// begin validation
|
|
8266
|
+
const requiredParameters = Reflect.getOwnMetadata(requiredMetadataKey, target.prototype, propertyName);
|
|
8267
|
+
const checkTypeParameters = Reflect.getOwnMetadata(checkTypeMetadataKey, target.prototype, propertyName);
|
|
8268
|
+
if (checkTypeParameters) {
|
|
8269
|
+
checkTypeParameters.forEach((parameter) => {
|
|
8270
|
+
const { parameterIndex, type, properties, defaultValue } = parameter;
|
|
8271
|
+
let argument = args[parameterIndex];
|
|
8272
|
+
let argumentName = argsName[parameterIndex];
|
|
8273
|
+
const parameterType = typeof argument;
|
|
8274
|
+
if (!_.isUndefined(argument)) {
|
|
8275
|
+
if (!isType(argument, type)) {
|
|
8276
|
+
throw apiResponse.error.wrongTypeParam(argumentName, type, Array.isArray(argument)
|
|
8277
|
+
? 'array'
|
|
8278
|
+
: argument === null
|
|
8279
|
+
? 'null'
|
|
8280
|
+
: parameterType);
|
|
8281
|
+
}
|
|
8282
|
+
if (type === 'object') {
|
|
8283
|
+
Object.entries(properties).forEach(([propKey, propType]) => {
|
|
8284
|
+
const key = propKey.split('?')[0];
|
|
8285
|
+
const propValue = _.get(argument, key);
|
|
8286
|
+
if (!_.isUndefined(propValue) && !_.isNull(propValue)) {
|
|
8287
|
+
if (_.isFunction(propType)) {
|
|
8288
|
+
const res = propType(propValue);
|
|
8289
|
+
if (res && res.error) {
|
|
8290
|
+
throw apiResponse.error.wrongTypeParam(`${argumentName}.${key}`, res.errorMessage, typeof propValue);
|
|
8291
|
+
}
|
|
8292
|
+
}
|
|
8293
|
+
}
|
|
8294
|
+
else if (!propKey.includes('?')) {
|
|
8295
|
+
throw apiResponse.error.missingParam(propKey);
|
|
8296
|
+
}
|
|
8297
|
+
else if (!_.get(argument, key.split('.')[0]) &&
|
|
8298
|
+
defaultValue &&
|
|
8299
|
+
!_.isUndefined(_.get(defaultValue, key))) {
|
|
8300
|
+
_.set(args[parameterIndex], key, _.get(defaultValue, key));
|
|
8301
|
+
}
|
|
8302
|
+
});
|
|
8303
|
+
}
|
|
8304
|
+
}
|
|
8305
|
+
});
|
|
8306
|
+
}
|
|
8307
|
+
if (requiredParameters) {
|
|
8308
|
+
requiredParameters.forEach((parameter) => {
|
|
8309
|
+
const { parameterIndex, option, fields } = parameter;
|
|
8310
|
+
const argument = args[parameterIndex];
|
|
8311
|
+
const condition = option === null || option === void 0 ? void 0 : option.if;
|
|
8312
|
+
const defaultValue = option === null || option === void 0 ? void 0 : option.defaultValue;
|
|
8313
|
+
let isMeetCondition = true;
|
|
8314
|
+
if (condition) {
|
|
8315
|
+
isMeetCondition = Object.keys(condition).every((key) => _.get(argument, key) === condition[key]);
|
|
8142
8316
|
}
|
|
8143
|
-
if (
|
|
8144
|
-
|
|
8145
|
-
const
|
|
8146
|
-
|
|
8147
|
-
|
|
8148
|
-
|
|
8149
|
-
|
|
8150
|
-
if (res && res.error) {
|
|
8151
|
-
throw apiResponse.error.wrongTypeParam(`${argumentName}.${key}`, res.errorMessage, typeof propValue);
|
|
8317
|
+
if (isMeetCondition) {
|
|
8318
|
+
fields.forEach((item) => {
|
|
8319
|
+
const isInValidField = (field) => {
|
|
8320
|
+
let isInValid = false;
|
|
8321
|
+
if (_.isEmpty(_.get(argument, field))) {
|
|
8322
|
+
if (!_.isUndefined(_.get(defaultValue, field))) {
|
|
8323
|
+
_.set(args[parameterIndex], field, _.get(defaultValue, field));
|
|
8152
8324
|
}
|
|
8325
|
+
isInValid = true;
|
|
8153
8326
|
}
|
|
8327
|
+
return isInValid;
|
|
8328
|
+
};
|
|
8329
|
+
if (Array.isArray(item) &&
|
|
8330
|
+
item.length > 0 &&
|
|
8331
|
+
item.every(isInValidField)) {
|
|
8332
|
+
throw apiResponse.error.missingParam(item.join(' or '));
|
|
8154
8333
|
}
|
|
8155
|
-
else if (
|
|
8156
|
-
throw apiResponse.error.missingParam(
|
|
8157
|
-
}
|
|
8158
|
-
else if (_.isObject(_.get(argument, key.split('.')[0])) &&
|
|
8159
|
-
defaultValue &&
|
|
8160
|
-
!_.isUndefined(_.get(defaultValue, key))) {
|
|
8161
|
-
_.set(arguments[parameterIndex], key, _.get(defaultValue, key));
|
|
8334
|
+
else if (_.isString(item) && isInValidField(item)) {
|
|
8335
|
+
throw apiResponse.error.missingParam(item);
|
|
8162
8336
|
}
|
|
8163
8337
|
});
|
|
8164
8338
|
}
|
|
8165
|
-
}
|
|
8166
|
-
}
|
|
8167
|
-
|
|
8168
|
-
|
|
8169
|
-
|
|
8170
|
-
const {
|
|
8171
|
-
|
|
8172
|
-
|
|
8173
|
-
|
|
8174
|
-
|
|
8175
|
-
|
|
8176
|
-
|
|
8177
|
-
|
|
8178
|
-
|
|
8179
|
-
|
|
8180
|
-
|
|
8181
|
-
|
|
8182
|
-
|
|
8183
|
-
|
|
8184
|
-
|
|
8185
|
-
}
|
|
8186
|
-
isInValid = true;
|
|
8187
|
-
}
|
|
8188
|
-
return isInValid;
|
|
8189
|
-
};
|
|
8190
|
-
if (Array.isArray(item) && item.length > 0 && item.every(isInValidField)) {
|
|
8191
|
-
throw apiResponse.error.missingParam(item.join(' or '));
|
|
8339
|
+
});
|
|
8340
|
+
}
|
|
8341
|
+
// end validation
|
|
8342
|
+
const res = fn.call(this, ...args);
|
|
8343
|
+
if (_.isPromise(res)) {
|
|
8344
|
+
const { success, fail } = Array.isArray(args) && args.length > 0 && args[0];
|
|
8345
|
+
return new Promise((resolve, reject) => {
|
|
8346
|
+
res
|
|
8347
|
+
.then((data) => {
|
|
8348
|
+
if (!_.isNull(success) && _.isFunction(success)) {
|
|
8349
|
+
success.call(null, data, this);
|
|
8350
|
+
}
|
|
8351
|
+
else {
|
|
8352
|
+
resolve(res);
|
|
8353
|
+
}
|
|
8354
|
+
})
|
|
8355
|
+
.catch((error) => {
|
|
8356
|
+
const errorParsed = errorHandler(error, propertyName);
|
|
8357
|
+
if (!_.isNull(fail) && _.isFunction(fail)) {
|
|
8358
|
+
fail.call(null, errorParsed, this);
|
|
8192
8359
|
}
|
|
8193
|
-
else
|
|
8194
|
-
|
|
8360
|
+
else {
|
|
8361
|
+
reject(errorParsed);
|
|
8195
8362
|
}
|
|
8196
8363
|
});
|
|
8197
|
-
}
|
|
8198
|
-
}
|
|
8364
|
+
});
|
|
8365
|
+
}
|
|
8366
|
+
return res;
|
|
8367
|
+
}
|
|
8368
|
+
catch (error) {
|
|
8369
|
+
throw errorHandler(error, propertyName);
|
|
8199
8370
|
}
|
|
8200
|
-
return method.apply(this, arguments);
|
|
8201
8371
|
};
|
|
8202
8372
|
return descriptor;
|
|
8203
8373
|
};
|
|
8204
8374
|
|
|
8205
8375
|
var _SDKCreator_sdkService;
|
|
8206
|
-
class SDKCreator {
|
|
8376
|
+
let SDKCreator = class SDKCreator {
|
|
8207
8377
|
constructor() {
|
|
8208
8378
|
this.events = ZMPEEmitter.getInstance();
|
|
8209
8379
|
_SDKCreator_sdkService.set(this, void 0);
|
|
@@ -8264,7 +8434,7 @@ class SDKCreator {
|
|
|
8264
8434
|
}
|
|
8265
8435
|
setNavigationBarTitle(object) {
|
|
8266
8436
|
return __awaiter(this, void 0, void 0, function* () {
|
|
8267
|
-
return __classPrivateFieldGet(this, _SDKCreator_sdkService, "f").setNavigationBarTitle(object);
|
|
8437
|
+
return yield __classPrivateFieldGet(this, _SDKCreator_sdkService, "f").setNavigationBarTitle(object);
|
|
8268
8438
|
});
|
|
8269
8439
|
}
|
|
8270
8440
|
setNavigationBarColor(object) {
|
|
@@ -8279,7 +8449,7 @@ class SDKCreator {
|
|
|
8279
8449
|
}
|
|
8280
8450
|
setNavigationBarLeftButton(object) {
|
|
8281
8451
|
return __awaiter(this, void 0, void 0, function* () {
|
|
8282
|
-
return yield __classPrivateFieldGet(this, _SDKCreator_sdkService, "f").setNavigationBarLeftButton(object);
|
|
8452
|
+
return yield __classPrivateFieldGet(this, _SDKCreator_sdkService, "f").setNavigationBarLeftButton(object.type);
|
|
8283
8453
|
});
|
|
8284
8454
|
}
|
|
8285
8455
|
setDeviceOrientation(object) {
|
|
@@ -8534,6 +8704,7 @@ class SDKCreator {
|
|
|
8534
8704
|
}
|
|
8535
8705
|
vibrate(object) {
|
|
8536
8706
|
return __awaiter(this, void 0, void 0, function* () {
|
|
8707
|
+
console.log(object);
|
|
8537
8708
|
yield __classPrivateFieldGet(this, _SDKCreator_sdkService, "f").vibrate(object);
|
|
8538
8709
|
});
|
|
8539
8710
|
}
|
|
@@ -8678,33 +8849,25 @@ class SDKCreator {
|
|
|
8678
8849
|
return yield __classPrivateFieldGet(this, _SDKCreator_sdkService, "f").openOutApp(appStoreURL);
|
|
8679
8850
|
});
|
|
8680
8851
|
}
|
|
8681
|
-
|
|
8852
|
+
onConfirmToExit(callback) {
|
|
8853
|
+
this.events.on(Events.AppClose, callback, '{"handle_h5": 1}');
|
|
8854
|
+
__classPrivateFieldGet(this, _SDKCreator_sdkService, "f").setNavigationBarLeftButton(undefined, 2);
|
|
8855
|
+
}
|
|
8856
|
+
offConfirmToExit() {
|
|
8857
|
+
this.events.off(Events.AppClose);
|
|
8858
|
+
__classPrivateFieldGet(this, _SDKCreator_sdkService, "f").setNavigationBarLeftButton(undefined, 0);
|
|
8859
|
+
}
|
|
8860
|
+
getDeviceId() {
|
|
8861
|
+
return __classPrivateFieldGet(this, _SDKCreator_sdkService, "f").getDeviceId();
|
|
8862
|
+
}
|
|
8863
|
+
};
|
|
8682
8864
|
_SDKCreator_sdkService = new WeakMap();
|
|
8683
8865
|
__decorate([
|
|
8684
|
-
handleError
|
|
8685
|
-
], SDKCreator.prototype, "login", null);
|
|
8686
|
-
__decorate([
|
|
8687
|
-
handleErrorSync
|
|
8688
|
-
], SDKCreator.prototype, "getLoginStatus", null);
|
|
8689
|
-
__decorate([
|
|
8690
|
-
handleError
|
|
8691
|
-
], SDKCreator.prototype, "getAccessToken", null);
|
|
8692
|
-
__decorate([
|
|
8693
|
-
handleErrorSync
|
|
8694
|
-
], SDKCreator.prototype, "getVersion", null);
|
|
8695
|
-
__decorate([
|
|
8696
|
-
handleErrorSync
|
|
8697
|
-
], SDKCreator.prototype, "getSystemInfo", null);
|
|
8698
|
-
__decorate([
|
|
8699
|
-
handleError,
|
|
8700
|
-
validate,
|
|
8701
8866
|
__param(0, checkType('object', {
|
|
8702
8867
|
title: checkData('string')
|
|
8703
8868
|
}))
|
|
8704
8869
|
], SDKCreator.prototype, "setNavigationBarTitle", null);
|
|
8705
8870
|
__decorate([
|
|
8706
|
-
handleError,
|
|
8707
|
-
validate,
|
|
8708
8871
|
__param(0, checkType('object', {
|
|
8709
8872
|
color: checkData('string'),
|
|
8710
8873
|
'textColor?': checkData('string', { values: ['white', 'black'] }),
|
|
@@ -8712,57 +8875,37 @@ __decorate([
|
|
|
8712
8875
|
}))
|
|
8713
8876
|
], SDKCreator.prototype, "setNavigationBarColor", null);
|
|
8714
8877
|
__decorate([
|
|
8715
|
-
handleError,
|
|
8716
|
-
validate,
|
|
8717
8878
|
__param(0, checkType('object', {
|
|
8718
8879
|
backgroundColor: checkData('string'),
|
|
8719
8880
|
'textColor?': checkData('string', { values: ['white', 'black'] })
|
|
8720
8881
|
}))
|
|
8721
8882
|
], SDKCreator.prototype, "setBackgroundColor", null);
|
|
8722
8883
|
__decorate([
|
|
8723
|
-
handleError,
|
|
8724
|
-
validate,
|
|
8725
8884
|
__param(0, checkType('object', {
|
|
8726
8885
|
type: checkData('string', { values: ['none', 'back', 'home', 'both'] })
|
|
8727
8886
|
}))
|
|
8728
8887
|
], SDKCreator.prototype, "setNavigationBarLeftButton", null);
|
|
8729
8888
|
__decorate([
|
|
8730
|
-
handleError,
|
|
8731
|
-
validate,
|
|
8732
8889
|
__param(0, checkType('object', {
|
|
8733
8890
|
rotate: checkData('string', { values: ['auto', 'portrait', 'landscape'] })
|
|
8734
8891
|
}))
|
|
8735
8892
|
], SDKCreator.prototype, "setDeviceOrientation", null);
|
|
8736
8893
|
__decorate([
|
|
8737
|
-
handleError,
|
|
8738
|
-
validate,
|
|
8739
8894
|
__param(0, checkType('object', {
|
|
8740
8895
|
data: checkData('object')
|
|
8741
8896
|
}))
|
|
8742
8897
|
], SDKCreator.prototype, "setStorage", null);
|
|
8743
8898
|
__decorate([
|
|
8744
|
-
handleError,
|
|
8745
|
-
validate,
|
|
8746
8899
|
__param(0, checkType('object', {
|
|
8747
8900
|
keys: checkData('array<string>')
|
|
8748
8901
|
}))
|
|
8749
8902
|
], SDKCreator.prototype, "getStorage", null);
|
|
8750
8903
|
__decorate([
|
|
8751
|
-
handleError
|
|
8752
|
-
], SDKCreator.prototype, "getStorageInfo", null);
|
|
8753
|
-
__decorate([
|
|
8754
|
-
handleError,
|
|
8755
|
-
validate,
|
|
8756
8904
|
__param(0, checkType('object', {
|
|
8757
8905
|
keys: checkData('array<string>')
|
|
8758
8906
|
}))
|
|
8759
8907
|
], SDKCreator.prototype, "removeStorage", null);
|
|
8760
8908
|
__decorate([
|
|
8761
|
-
handleError
|
|
8762
|
-
], SDKCreator.prototype, "clearStorage", null);
|
|
8763
|
-
__decorate([
|
|
8764
|
-
handleError,
|
|
8765
|
-
validate,
|
|
8766
8909
|
__param(0, checkType('object', {
|
|
8767
8910
|
'avatarType?': checkData('string', {
|
|
8768
8911
|
values: ['small', 'normal', 'large']
|
|
@@ -8770,75 +8913,19 @@ __decorate([
|
|
|
8770
8913
|
}))
|
|
8771
8914
|
], SDKCreator.prototype, "getUserInfo", null);
|
|
8772
8915
|
__decorate([
|
|
8773
|
-
handleError
|
|
8774
|
-
], SDKCreator.prototype, "getNetworkType", null);
|
|
8775
|
-
__decorate([
|
|
8776
|
-
handleError
|
|
8777
|
-
], SDKCreator.prototype, "onNetworkStatusChange", null);
|
|
8778
|
-
__decorate([
|
|
8779
|
-
handleError
|
|
8780
|
-
], SDKCreator.prototype, "startBeaconDiscovery", null);
|
|
8781
|
-
__decorate([
|
|
8782
|
-
handleError
|
|
8783
|
-
], SDKCreator.prototype, "stopBeaconDiscovery", null);
|
|
8784
|
-
__decorate([
|
|
8785
|
-
handleError
|
|
8786
|
-
], SDKCreator.prototype, "getBeacons", null);
|
|
8787
|
-
__decorate([
|
|
8788
|
-
handleError
|
|
8789
|
-
], SDKCreator.prototype, "closeApp", null);
|
|
8790
|
-
__decorate([
|
|
8791
|
-
handleError
|
|
8792
|
-
], SDKCreator.prototype, "getLocation", null);
|
|
8793
|
-
__decorate([
|
|
8794
|
-
handleError
|
|
8795
|
-
], SDKCreator.prototype, "stopBluetoothDevicesDiscovery", null);
|
|
8796
|
-
__decorate([
|
|
8797
|
-
handleError
|
|
8798
|
-
], SDKCreator.prototype, "startBluetoothDevicesDiscovery", null);
|
|
8799
|
-
__decorate([
|
|
8800
|
-
handleError
|
|
8801
|
-
], SDKCreator.prototype, "openBluetoothAdapter", null);
|
|
8802
|
-
__decorate([
|
|
8803
|
-
handleError
|
|
8804
|
-
], SDKCreator.prototype, "onBluetoothDeviceFound", null);
|
|
8805
|
-
__decorate([
|
|
8806
|
-
handleError
|
|
8807
|
-
], SDKCreator.prototype, "onBluetoothAdapterStateChange", null);
|
|
8808
|
-
__decorate([
|
|
8809
|
-
handleError
|
|
8810
|
-
], SDKCreator.prototype, "getConnectedBluetoothDevices", null);
|
|
8811
|
-
__decorate([
|
|
8812
|
-
handleError
|
|
8813
|
-
], SDKCreator.prototype, "getBluetoothDevices", null);
|
|
8814
|
-
__decorate([
|
|
8815
|
-
handleError
|
|
8816
|
-
], SDKCreator.prototype, "getBluetoothAdapterState", null);
|
|
8817
|
-
__decorate([
|
|
8818
|
-
handleError
|
|
8819
|
-
], SDKCreator.prototype, "closeBluetoothAdapter", null);
|
|
8820
|
-
__decorate([
|
|
8821
|
-
handleError
|
|
8822
|
-
], SDKCreator.prototype, "scanQRCode", null);
|
|
8823
|
-
__decorate([
|
|
8824
|
-
handleError,
|
|
8825
|
-
validate,
|
|
8826
8916
|
__param(0, checkType('object', {
|
|
8827
8917
|
type: checkData('string', { values: ['user', 'oa', 'aliasOA'] }),
|
|
8828
8918
|
id: checkData('string')
|
|
8829
8919
|
}))
|
|
8830
8920
|
], SDKCreator.prototype, "openProfile", null);
|
|
8831
8921
|
__decorate([
|
|
8832
|
-
handleError,
|
|
8833
|
-
validate,
|
|
8834
8922
|
__param(0, checkType('object', {
|
|
8835
8923
|
type: checkData('string', { values: ['user', 'oa'] }),
|
|
8836
|
-
id: checkData('string')
|
|
8924
|
+
id: checkData('string'),
|
|
8925
|
+
'message?': checkData('string')
|
|
8837
8926
|
}))
|
|
8838
8927
|
], SDKCreator.prototype, "openChat", null);
|
|
8839
8928
|
__decorate([
|
|
8840
|
-
handleError,
|
|
8841
|
-
validate,
|
|
8842
8929
|
__param(0, required(['data.imageUrl'], { if: { type: 'image' } })),
|
|
8843
8930
|
__param(0, required(['data.link'], { if: { type: 'link' } })),
|
|
8844
8931
|
__param(0, required(['data.id'], { if: { type: 'profile' } })),
|
|
@@ -8856,23 +8943,17 @@ __decorate([
|
|
|
8856
8943
|
}))
|
|
8857
8944
|
], SDKCreator.prototype, "openPostFeed", null);
|
|
8858
8945
|
__decorate([
|
|
8859
|
-
handleError,
|
|
8860
|
-
validate,
|
|
8861
8946
|
__param(0, checkType('object', {
|
|
8862
8947
|
id: checkData('string'),
|
|
8863
8948
|
'showDialogConfirm?': checkData('boolean')
|
|
8864
8949
|
}))
|
|
8865
8950
|
], SDKCreator.prototype, "followOA", null);
|
|
8866
8951
|
__decorate([
|
|
8867
|
-
handleError,
|
|
8868
|
-
validate,
|
|
8869
8952
|
__param(0, checkType('object', {
|
|
8870
8953
|
id: checkData('string')
|
|
8871
8954
|
}))
|
|
8872
8955
|
], SDKCreator.prototype, "unfollowOA", null);
|
|
8873
8956
|
__decorate([
|
|
8874
|
-
handleError,
|
|
8875
|
-
validate,
|
|
8876
8957
|
__param(0, required([['data.imageUrl', 'data.imageUrls']], { if: { type: 'image' } })),
|
|
8877
8958
|
__param(0, required(['data.link'], { if: { type: 'link' } })),
|
|
8878
8959
|
__param(0, required(['data.id'], { if: { type: 'oa' } })),
|
|
@@ -8911,14 +8992,6 @@ __decorate([
|
|
|
8911
8992
|
}))
|
|
8912
8993
|
], SDKCreator.prototype, "openShareSheet", null);
|
|
8913
8994
|
__decorate([
|
|
8914
|
-
handleError
|
|
8915
|
-
], SDKCreator.prototype, "requestCameraPermission", null);
|
|
8916
|
-
__decorate([
|
|
8917
|
-
handleError
|
|
8918
|
-
], SDKCreator.prototype, "createShortcut", null);
|
|
8919
|
-
__decorate([
|
|
8920
|
-
handleError,
|
|
8921
|
-
validate,
|
|
8922
8995
|
__param(0, checkType('object', {
|
|
8923
8996
|
secretData: checkData('string'),
|
|
8924
8997
|
'ui?': checkData('object'),
|
|
@@ -8936,44 +9009,28 @@ __decorate([
|
|
|
8936
9009
|
}))
|
|
8937
9010
|
], SDKCreator.prototype, "openBioAuthentication", null);
|
|
8938
9011
|
__decorate([
|
|
8939
|
-
handleError
|
|
8940
|
-
], SDKCreator.prototype, "checkStateBioAuthentication", null);
|
|
8941
|
-
__decorate([
|
|
8942
|
-
handleError,
|
|
8943
|
-
validate,
|
|
8944
9012
|
__param(0, checkType('object', {
|
|
8945
9013
|
toUserId: checkData('string'),
|
|
8946
9014
|
'title?': checkData('string')
|
|
8947
9015
|
}))
|
|
8948
9016
|
], SDKCreator.prototype, "sendLocation", null);
|
|
8949
9017
|
__decorate([
|
|
8950
|
-
handleError,
|
|
8951
|
-
validate,
|
|
8952
9018
|
__param(0, checkType('object', {
|
|
8953
9019
|
message: checkData('string')
|
|
8954
9020
|
}))
|
|
8955
9021
|
], SDKCreator.prototype, "showToast", null);
|
|
8956
9022
|
__decorate([
|
|
8957
|
-
handleError
|
|
8958
|
-
], SDKCreator.prototype, "hideKeyboard", null);
|
|
8959
|
-
__decorate([
|
|
8960
|
-
handleError,
|
|
8961
|
-
validate,
|
|
8962
9023
|
__param(0, checkType('object', {
|
|
8963
9024
|
phoneNumber: checkData('string')
|
|
8964
9025
|
}))
|
|
8965
9026
|
], SDKCreator.prototype, "openPhone", null);
|
|
8966
9027
|
__decorate([
|
|
8967
|
-
handleError,
|
|
8968
|
-
validate,
|
|
8969
9028
|
__param(0, checkType('object', {
|
|
8970
9029
|
content: checkData('string'),
|
|
8971
9030
|
phoneNumber: checkData('string', { regex: /^\+?\d+$/ })
|
|
8972
9031
|
}))
|
|
8973
9032
|
], SDKCreator.prototype, "openSMS", null);
|
|
8974
9033
|
__decorate([
|
|
8975
|
-
handleError,
|
|
8976
|
-
validate,
|
|
8977
9034
|
__param(0, checkType('object', {
|
|
8978
9035
|
id: checkData('string'),
|
|
8979
9036
|
'displayName?': checkData('string')
|
|
@@ -8982,35 +9039,24 @@ __decorate([
|
|
|
8982
9039
|
}))
|
|
8983
9040
|
], SDKCreator.prototype, "viewOAQr", null);
|
|
8984
9041
|
__decorate([
|
|
8985
|
-
handleError
|
|
8986
|
-
], SDKCreator.prototype, "keepScreen", null);
|
|
8987
|
-
__decorate([
|
|
8988
|
-
handleError,
|
|
8989
|
-
validate,
|
|
8990
9042
|
__param(0, checkType('object', {
|
|
8991
9043
|
'imageBase64Data?': checkData('string'),
|
|
8992
9044
|
'imageUrl?': checkData('url')
|
|
8993
9045
|
}))
|
|
8994
9046
|
], SDKCreator.prototype, "saveImageToGallery", null);
|
|
8995
9047
|
__decorate([
|
|
8996
|
-
handleError,
|
|
8997
|
-
validate,
|
|
8998
9048
|
__param(0, checkType('object', {
|
|
8999
9049
|
'imageBase64Data?': checkData('string'),
|
|
9000
9050
|
'imageUrl?': checkData('url')
|
|
9001
9051
|
}))
|
|
9002
9052
|
], SDKCreator.prototype, "saveImageToPhotosAlbum", null);
|
|
9003
9053
|
__decorate([
|
|
9004
|
-
handleError,
|
|
9005
|
-
validate,
|
|
9006
9054
|
__param(0, checkType('object', {
|
|
9007
9055
|
appId: checkData('string'),
|
|
9008
9056
|
'params?': checkData('object')
|
|
9009
9057
|
}))
|
|
9010
9058
|
], SDKCreator.prototype, "openMiniApp", null);
|
|
9011
9059
|
__decorate([
|
|
9012
|
-
handleError,
|
|
9013
|
-
validate,
|
|
9014
9060
|
__param(0, checkType('object', {
|
|
9015
9061
|
'type?': checkData('string', { values: ['oneShot'] }),
|
|
9016
9062
|
'milliseconds?': checkData('number')
|
|
@@ -9020,30 +9066,11 @@ __decorate([
|
|
|
9020
9066
|
}))
|
|
9021
9067
|
], SDKCreator.prototype, "vibrate", null);
|
|
9022
9068
|
__decorate([
|
|
9023
|
-
handleError,
|
|
9024
|
-
validate,
|
|
9025
9069
|
__param(0, checkType('object', {
|
|
9026
9070
|
url: checkData('url')
|
|
9027
9071
|
}))
|
|
9028
9072
|
], SDKCreator.prototype, "openWebview", null);
|
|
9029
9073
|
__decorate([
|
|
9030
|
-
handleErrorSync
|
|
9031
|
-
], SDKCreator.prototype, "getRouteParams", null);
|
|
9032
|
-
__decorate([
|
|
9033
|
-
handleError
|
|
9034
|
-
], SDKCreator.prototype, "getAppInfo", null);
|
|
9035
|
-
__decorate([
|
|
9036
|
-
handleError
|
|
9037
|
-
], SDKCreator.prototype, "sendDataToPreviousMiniApp", null);
|
|
9038
|
-
__decorate([
|
|
9039
|
-
handleError
|
|
9040
|
-
], SDKCreator.prototype, "onCallbackData", null);
|
|
9041
|
-
__decorate([
|
|
9042
|
-
handleError
|
|
9043
|
-
], SDKCreator.prototype, "getPhoneNumber", null);
|
|
9044
|
-
__decorate([
|
|
9045
|
-
handleError,
|
|
9046
|
-
validate,
|
|
9047
9074
|
__param(0, checkType('object', {
|
|
9048
9075
|
'maxProfile?': checkData('number', { min: 1, max: 10 })
|
|
9049
9076
|
}, {
|
|
@@ -9051,8 +9078,6 @@ __decorate([
|
|
|
9051
9078
|
}))
|
|
9052
9079
|
], SDKCreator.prototype, "openProfilePicker", null);
|
|
9053
9080
|
__decorate([
|
|
9054
|
-
handleError,
|
|
9055
|
-
validate,
|
|
9056
9081
|
__param(0, required(['SSID'])),
|
|
9057
9082
|
__param(0, checkType('object', {
|
|
9058
9083
|
SSID: checkData('string'),
|
|
@@ -9061,8 +9086,6 @@ __decorate([
|
|
|
9061
9086
|
}))
|
|
9062
9087
|
], SDKCreator.prototype, "connectWifi", null);
|
|
9063
9088
|
__decorate([
|
|
9064
|
-
handleError,
|
|
9065
|
-
validate,
|
|
9066
9089
|
__param(0, checkType('object', {
|
|
9067
9090
|
type: checkData('string', {
|
|
9068
9091
|
values: ['photo', 'video', 'file']
|
|
@@ -9077,8 +9100,6 @@ __decorate([
|
|
|
9077
9100
|
}))
|
|
9078
9101
|
], SDKCreator.prototype, "openMediaPicker", null);
|
|
9079
9102
|
__decorate([
|
|
9080
|
-
handleError,
|
|
9081
|
-
validate,
|
|
9082
9103
|
__param(0, checkType('object', {
|
|
9083
9104
|
title: checkData('string', { maxLength: 100 }),
|
|
9084
9105
|
'thumbnail?': checkData('url'),
|
|
@@ -9088,14 +9109,9 @@ __decorate([
|
|
|
9088
9109
|
description: ''
|
|
9089
9110
|
}))
|
|
9090
9111
|
], SDKCreator.prototype, "getShareableLink", null);
|
|
9091
|
-
__decorate([
|
|
9092
|
-
|
|
9093
|
-
|
|
9094
|
-
], SDKCreator.prototype, "closeLoading", null);
|
|
9095
|
-
__decorate([
|
|
9096
|
-
handleError,
|
|
9097
|
-
validate
|
|
9098
|
-
], SDKCreator.prototype, "requestUpdateZalo", null);
|
|
9112
|
+
SDKCreator = __decorate([
|
|
9113
|
+
DecorateAll(centralizedFunctionHandler)
|
|
9114
|
+
], SDKCreator);
|
|
9099
9115
|
class ZaloMiniAppSDKCreator extends SDKCreator {
|
|
9100
9116
|
getServiceInstance() {
|
|
9101
9117
|
return ZaloMiniProgramSDKService.getInstance();
|
|
@@ -9291,7 +9307,7 @@ class MockPaymentService {
|
|
|
9291
9307
|
_MockPaymentService_appId = new WeakMap();
|
|
9292
9308
|
|
|
9293
9309
|
var _PaymentCreator_instance, _PaymentCreator_sdk;
|
|
9294
|
-
class PaymentCreator {
|
|
9310
|
+
let PaymentCreator = class PaymentCreator {
|
|
9295
9311
|
constructor(sdk) {
|
|
9296
9312
|
_PaymentCreator_instance.set(this, void 0);
|
|
9297
9313
|
_PaymentCreator_sdk.set(this, void 0);
|
|
@@ -9299,42 +9315,50 @@ class PaymentCreator {
|
|
|
9299
9315
|
__classPrivateFieldSet(this, _PaymentCreator_sdk, sdk, "f");
|
|
9300
9316
|
}
|
|
9301
9317
|
/**
|
|
9302
|
-
|
|
9303
|
-
|
|
9304
|
-
|
|
9305
|
-
|
|
9306
|
-
|
|
9307
|
-
|
|
9308
|
-
|
|
9318
|
+
* Tạo đơn hàng
|
|
9319
|
+
*
|
|
9320
|
+
* @async
|
|
9321
|
+
* @function createOrder
|
|
9322
|
+
* @category Payment
|
|
9323
|
+
* @returns {Promise<CallbackDataType.CreateOrderCallBack>}
|
|
9324
|
+
*/
|
|
9309
9325
|
createOrder(object) {
|
|
9310
9326
|
return __classPrivateFieldGet(this, _PaymentCreator_instance, "f").createOrder(__classPrivateFieldGet(this, _PaymentCreator_sdk, "f"), object);
|
|
9311
9327
|
}
|
|
9312
9328
|
/**
|
|
9313
|
-
|
|
9314
|
-
|
|
9315
|
-
|
|
9316
|
-
|
|
9317
|
-
|
|
9318
|
-
|
|
9319
|
-
|
|
9329
|
+
* Lấy thông tin transaction
|
|
9330
|
+
*
|
|
9331
|
+
* @async
|
|
9332
|
+
* @function checkTransaction
|
|
9333
|
+
* @category Payment
|
|
9334
|
+
* @returns {Promise<CallbackDataType.CheckTransactionSuccessCallBack>}
|
|
9335
|
+
*/
|
|
9320
9336
|
checkTransaction(object) {
|
|
9321
9337
|
return __classPrivateFieldGet(this, _PaymentCreator_instance, "f").checkTransaction(__classPrivateFieldGet(this, _PaymentCreator_sdk, "f"), object);
|
|
9322
9338
|
}
|
|
9323
|
-
}
|
|
9339
|
+
};
|
|
9324
9340
|
_PaymentCreator_instance = new WeakMap(), _PaymentCreator_sdk = new WeakMap();
|
|
9325
9341
|
__decorate([
|
|
9326
|
-
handleError,
|
|
9327
|
-
validate,
|
|
9328
9342
|
__param(0, checkType('object', {
|
|
9329
|
-
|
|
9330
|
-
|
|
9331
|
-
'method?': checkData('string', {
|
|
9343
|
+
amount: checkData(['string', 'number']),
|
|
9344
|
+
desc: checkData('string'),
|
|
9345
|
+
'method?': checkData('string', {
|
|
9346
|
+
values: [
|
|
9347
|
+
'MOMO',
|
|
9348
|
+
'ZALOPAY',
|
|
9349
|
+
'MOMO_SANDBOX',
|
|
9350
|
+
'ZALOPAY_SANDBOX',
|
|
9351
|
+
'CC',
|
|
9352
|
+
'CC_SANDBOX',
|
|
9353
|
+
'ATM',
|
|
9354
|
+
'ATM_SANDBOX'
|
|
9355
|
+
]
|
|
9356
|
+
})
|
|
9332
9357
|
}))
|
|
9333
9358
|
], PaymentCreator.prototype, "createOrder", null);
|
|
9334
|
-
__decorate([
|
|
9335
|
-
|
|
9336
|
-
|
|
9337
|
-
], PaymentCreator.prototype, "checkTransaction", null);
|
|
9359
|
+
PaymentCreator = __decorate([
|
|
9360
|
+
DecorateAll(centralizedFunctionHandler)
|
|
9361
|
+
], PaymentCreator);
|
|
9338
9362
|
class ZaloMiniAppPaymentCreator extends PaymentCreator {
|
|
9339
9363
|
getInstance() {
|
|
9340
9364
|
return PaymentService.getInstance();
|
|
@@ -9376,4 +9400,4 @@ else {
|
|
|
9376
9400
|
window.ZaloMiniAppSDK = app;
|
|
9377
9401
|
|
|
9378
9402
|
export default app;
|
|
9379
|
-
export { ChatType, Events, MediaPickerType,
|
|
9403
|
+
export { ChatType, Events, MediaPickerType, NetworkType, OrientationType, payment as Payment, PlatformType, PostFeedType, ProfileType, SDKCreator, ShareSheetType, VibrateType };
|