zmp-sdk 2.20.0 → 2.21.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/browser.min.js +1340 -1299
- package/dist/index.es.js +1341 -1300
- package/dist/index.js +1 -1
- package/dist/index.umd.js +1 -1
- package/dist/types/src/apis/payment.d.ts +14 -14
- package/dist/types/src/constants.d.ts +95 -20
- package/dist/types/src/decorator.d.ts +22 -0
- package/dist/types/src/errorHandler.d.ts +12 -0
- package/dist/types/src/services/zalo-mp-service.d.ts +3 -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/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) {
|
|
@@ -2136,6 +2140,7 @@ var ShareSheetType;
|
|
|
2136
2140
|
ShareSheetType[ShareSheetType["link"] = 4] = "link";
|
|
2137
2141
|
ShareSheetType[ShareSheetType["oa"] = 5] = "oa";
|
|
2138
2142
|
ShareSheetType[ShareSheetType["zmp"] = 20] = "zmp";
|
|
2143
|
+
ShareSheetType[ShareSheetType["multi_image"] = 21] = "multi_image";
|
|
2139
2144
|
})(ShareSheetType || (ShareSheetType = {}));
|
|
2140
2145
|
var OrientationType;
|
|
2141
2146
|
(function (OrientationType) {
|
|
@@ -2147,13 +2152,6 @@ var VibrateType;
|
|
|
2147
2152
|
(function (VibrateType) {
|
|
2148
2153
|
VibrateType[VibrateType["oneShot"] = 0] = "oneShot";
|
|
2149
2154
|
})(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
2155
|
var Events;
|
|
2158
2156
|
(function (Events) {
|
|
2159
2157
|
Events["AppPaused"] = "h5.event.paused";
|
|
@@ -2242,7 +2240,7 @@ const COOKIE_NAME = {
|
|
|
2242
2240
|
ZACC_SESSiON: `h5.zdn.vn_zacc_session`,
|
|
2243
2241
|
JS_TOKEN: `h5.zdn.vn_zlink3rd`,
|
|
2244
2242
|
ZOAUTH_VRF: `h5.zdn.vn_zoauth_vrf`,
|
|
2245
|
-
DEVICE_ID: `h5.zdn.vn_deviceID
|
|
2243
|
+
DEVICE_ID: `h5.zdn.vn_deviceID`
|
|
2246
2244
|
};
|
|
2247
2245
|
const APIS = {
|
|
2248
2246
|
GET_USER_INFO: 'https://graph.zalo.me/v2.0/me',
|
|
@@ -2250,6 +2248,8 @@ const APIS = {
|
|
|
2250
2248
|
GET_ACCESS_TOKEN_V3: 'https://oauth.zaloapp.com/v3/access_token',
|
|
2251
2249
|
GET_LIST_USER_INFO: 'https://graph.zalo.me/v2.0/me/friends/list',
|
|
2252
2250
|
CREATE_ORDER: 'https://payment-mini.zalo.me/api/order/create',
|
|
2251
|
+
GET_APP_INFO: 'https://h5.zalo.me/apps/get-info',
|
|
2252
|
+
SEND_ACTION_LOG: 'https://h5.zalo.me/log/async'
|
|
2253
2253
|
};
|
|
2254
2254
|
const STORAGE_LIMIT = 5 * MB;
|
|
2255
2255
|
const NETWORK_TYPE = (isAndroid) => ({
|
|
@@ -2260,6 +2260,78 @@ const NETWORK_TYPE = (isAndroid) => ({
|
|
|
2260
2260
|
'4G': isAndroid ? 13 : 2
|
|
2261
2261
|
});
|
|
2262
2262
|
const MEDIA_PICKER_LIMIT = 1 * MB;
|
|
2263
|
+
const RESPONSE_CODE = {
|
|
2264
|
+
SUCCESS: 0,
|
|
2265
|
+
UNKNOWN_ERROR: -2000,
|
|
2266
|
+
BAD_REQUEST: -1400,
|
|
2267
|
+
INTERNAL_SERVER_ERROR: -1500,
|
|
2268
|
+
UNAUTHORIZED: -1401,
|
|
2269
|
+
FORBIDDEN: -1403,
|
|
2270
|
+
CLIENT_NOT_SUPPORT: -1404,
|
|
2271
|
+
TIME_OUT: -1408,
|
|
2272
|
+
DECODE_FAILED: -2001,
|
|
2273
|
+
USER_DENIED: -2002,
|
|
2274
|
+
USER_CANCEL: -2003,
|
|
2275
|
+
// Media picker
|
|
2276
|
+
MEDIA_PICKER_FAIL: -2004,
|
|
2277
|
+
// Save image to gallery
|
|
2278
|
+
SAVE_IMAGE_FAIL: -2005
|
|
2279
|
+
};
|
|
2280
|
+
const MESSAGES = {
|
|
2281
|
+
SUCCESS: 'Success',
|
|
2282
|
+
UNKNOWN_ERROR: 'Unknown error. Please try again later.',
|
|
2283
|
+
TIME_OUT: 'Request timeout. Please try again later.',
|
|
2284
|
+
LOGIN_REQUIRED: 'Please login (https://miniapp.zalo.me/docs/api/login) before to call this api',
|
|
2285
|
+
LOGIN_FAILED: 'Login failed',
|
|
2286
|
+
NOT_PERMISSION: `You don't have permission to call this api`,
|
|
2287
|
+
CLIENT_NOT_SUPPORT: `This API is not supported in this Zalo version`,
|
|
2288
|
+
DECODE_FAILED: 'Can not decode id. Please check your params again.',
|
|
2289
|
+
INVALID_PARAM: 'Invalid parameter',
|
|
2290
|
+
USER_DENIED: 'User denied',
|
|
2291
|
+
USER_CANCEL: 'User cancel',
|
|
2292
|
+
// Media picker
|
|
2293
|
+
MEDIA_PICKER_FAIL: 'Unable to pick media',
|
|
2294
|
+
// Save image to gallery
|
|
2295
|
+
SAVE_IMAGE_FAIL: 'Unable to save image'
|
|
2296
|
+
};
|
|
2297
|
+
const RESPONSE = {
|
|
2298
|
+
SUCCESS: {
|
|
2299
|
+
code: RESPONSE_CODE.SUCCESS,
|
|
2300
|
+
message: MESSAGES.SUCCESS
|
|
2301
|
+
},
|
|
2302
|
+
UNKNOWN_ERROR: {
|
|
2303
|
+
code: RESPONSE_CODE.UNKNOWN_ERROR,
|
|
2304
|
+
message: MESSAGES.UNKNOWN_ERROR
|
|
2305
|
+
},
|
|
2306
|
+
UNAUTHORIZED: {
|
|
2307
|
+
code: RESPONSE_CODE.UNAUTHORIZED,
|
|
2308
|
+
message: MESSAGES.LOGIN_REQUIRED
|
|
2309
|
+
},
|
|
2310
|
+
FORBIDDEN: {
|
|
2311
|
+
code: RESPONSE_CODE.FORBIDDEN,
|
|
2312
|
+
message: MESSAGES.NOT_PERMISSION
|
|
2313
|
+
},
|
|
2314
|
+
CLIENT_NOT_SUPPORT: {
|
|
2315
|
+
code: RESPONSE_CODE.CLIENT_NOT_SUPPORT,
|
|
2316
|
+
message: MESSAGES.CLIENT_NOT_SUPPORT
|
|
2317
|
+
},
|
|
2318
|
+
DECODE_FAILED: {
|
|
2319
|
+
code: RESPONSE_CODE.DECODE_FAILED,
|
|
2320
|
+
message: MESSAGES.DECODE_FAILED
|
|
2321
|
+
},
|
|
2322
|
+
TIME_OUT: {
|
|
2323
|
+
code: RESPONSE_CODE.TIME_OUT,
|
|
2324
|
+
message: MESSAGES.TIME_OUT
|
|
2325
|
+
},
|
|
2326
|
+
USER_DENIED: {
|
|
2327
|
+
code: RESPONSE_CODE.USER_DENIED,
|
|
2328
|
+
message: MESSAGES.USER_DENIED
|
|
2329
|
+
},
|
|
2330
|
+
USER_CANCEL: {
|
|
2331
|
+
code: RESPONSE_CODE.USER_CANCEL,
|
|
2332
|
+
message: MESSAGES.USER_CANCEL
|
|
2333
|
+
}
|
|
2334
|
+
};
|
|
2263
2335
|
const ACTION = {
|
|
2264
2336
|
GET_DOWNLOADED_STICKER: {
|
|
2265
2337
|
name: 'action.get.downloaded.sticker',
|
|
@@ -2372,7 +2444,19 @@ const ACTION = {
|
|
|
2372
2444
|
have_callback: true
|
|
2373
2445
|
},
|
|
2374
2446
|
REQUEST_PERMISSION_CAMERA: {
|
|
2375
|
-
name: 'action.request.permission.camera'
|
|
2447
|
+
name: 'action.request.permission.camera',
|
|
2448
|
+
error_list: {
|
|
2449
|
+
android: {
|
|
2450
|
+
'-2': {
|
|
2451
|
+
map_to: RESPONSE.USER_DENIED
|
|
2452
|
+
}
|
|
2453
|
+
},
|
|
2454
|
+
iOS: {
|
|
2455
|
+
'-2': {
|
|
2456
|
+
map_to: RESPONSE.USER_DENIED
|
|
2457
|
+
}
|
|
2458
|
+
}
|
|
2459
|
+
}
|
|
2376
2460
|
},
|
|
2377
2461
|
CHANGE_TITLE_HEADER: {
|
|
2378
2462
|
name: 'action.change.title.header',
|
|
@@ -2441,7 +2525,19 @@ const ACTION = {
|
|
|
2441
2525
|
},
|
|
2442
2526
|
GET_LOCATION: {
|
|
2443
2527
|
name: 'action.get.location',
|
|
2444
|
-
have_callback: true
|
|
2528
|
+
have_callback: true,
|
|
2529
|
+
error_list: {
|
|
2530
|
+
android: {
|
|
2531
|
+
'-1': {
|
|
2532
|
+
map_to: RESPONSE.USER_DENIED
|
|
2533
|
+
}
|
|
2534
|
+
},
|
|
2535
|
+
iOS: {
|
|
2536
|
+
'-1': {
|
|
2537
|
+
map_to: RESPONSE.USER_DENIED
|
|
2538
|
+
}
|
|
2539
|
+
}
|
|
2540
|
+
}
|
|
2445
2541
|
},
|
|
2446
2542
|
QUERY_LOCATION_HIDE: {
|
|
2447
2543
|
name: 'action.query.location.hide',
|
|
@@ -2539,7 +2635,34 @@ const ACTION = {
|
|
|
2539
2635
|
},
|
|
2540
2636
|
SAVE_IMAGE_GALLERY: {
|
|
2541
2637
|
name: 'action.save.image.gallery',
|
|
2542
|
-
version_live: { iOS: 408 }
|
|
2638
|
+
version_live: { iOS: 408 },
|
|
2639
|
+
error_list: {
|
|
2640
|
+
android: {
|
|
2641
|
+
'-101': {
|
|
2642
|
+
map_to: {
|
|
2643
|
+
code: RESPONSE_CODE.SAVE_IMAGE_FAIL,
|
|
2644
|
+
message: MESSAGES.SAVE_IMAGE_FAIL
|
|
2645
|
+
},
|
|
2646
|
+
need_more_detail: true
|
|
2647
|
+
},
|
|
2648
|
+
'-102': {
|
|
2649
|
+
map_to: {
|
|
2650
|
+
code: RESPONSE_CODE.SAVE_IMAGE_FAIL,
|
|
2651
|
+
message: MESSAGES.SAVE_IMAGE_FAIL
|
|
2652
|
+
},
|
|
2653
|
+
need_more_detail: true
|
|
2654
|
+
}
|
|
2655
|
+
},
|
|
2656
|
+
iOS: {
|
|
2657
|
+
'-10': {
|
|
2658
|
+
map_to: {
|
|
2659
|
+
code: RESPONSE_CODE.SAVE_IMAGE_FAIL,
|
|
2660
|
+
message: MESSAGES.SAVE_IMAGE_FAIL
|
|
2661
|
+
},
|
|
2662
|
+
need_more_detail: true
|
|
2663
|
+
}
|
|
2664
|
+
}
|
|
2665
|
+
}
|
|
2543
2666
|
},
|
|
2544
2667
|
OPEN_MP: {
|
|
2545
2668
|
name: 'action.open.mp',
|
|
@@ -2560,11 +2683,41 @@ const ACTION = {
|
|
|
2560
2683
|
},
|
|
2561
2684
|
MP_GET_NUMBER: {
|
|
2562
2685
|
name: 'action.mp.get.number',
|
|
2563
|
-
version_live: { iOS: 416 }
|
|
2686
|
+
version_live: { iOS: 416 },
|
|
2687
|
+
error_list: {
|
|
2688
|
+
android: {
|
|
2689
|
+
'-1': {
|
|
2690
|
+
map_to: RESPONSE.USER_DENIED
|
|
2691
|
+
},
|
|
2692
|
+
'-101': {
|
|
2693
|
+
map_to: RESPONSE.USER_DENIED
|
|
2694
|
+
}
|
|
2695
|
+
},
|
|
2696
|
+
iOS: {
|
|
2697
|
+
'-1': {
|
|
2698
|
+
map_to: RESPONSE.USER_DENIED
|
|
2699
|
+
},
|
|
2700
|
+
'-10': {
|
|
2701
|
+
map_to: RESPONSE.USER_DENIED
|
|
2702
|
+
}
|
|
2703
|
+
}
|
|
2704
|
+
}
|
|
2564
2705
|
},
|
|
2565
2706
|
MP_OPEN_PROFILE_PICKER: {
|
|
2566
2707
|
name: 'action.mp.open.profile.picker',
|
|
2567
|
-
version_live: { iOS: 432 }
|
|
2708
|
+
version_live: { iOS: 432 },
|
|
2709
|
+
error_list: {
|
|
2710
|
+
android: {
|
|
2711
|
+
'-101': {
|
|
2712
|
+
map_to: RESPONSE.USER_CANCEL
|
|
2713
|
+
}
|
|
2714
|
+
},
|
|
2715
|
+
iOS: {
|
|
2716
|
+
'-101': {
|
|
2717
|
+
map_to: RESPONSE.USER_CANCEL
|
|
2718
|
+
}
|
|
2719
|
+
}
|
|
2720
|
+
}
|
|
2568
2721
|
},
|
|
2569
2722
|
GET_SUPPORTED_ACTIONS: {
|
|
2570
2723
|
name: 'action.get.supported.actions',
|
|
@@ -2578,32 +2731,45 @@ const ACTION = {
|
|
|
2578
2731
|
},
|
|
2579
2732
|
PICK_MEDIA: {
|
|
2580
2733
|
name: 'action.pick.media',
|
|
2581
|
-
version_live: { iOS: 440 }
|
|
2734
|
+
version_live: { iOS: 440 },
|
|
2735
|
+
error_list: {
|
|
2736
|
+
android: {
|
|
2737
|
+
'-101': {
|
|
2738
|
+
map_to: RESPONSE.USER_CANCEL
|
|
2739
|
+
},
|
|
2740
|
+
'999': {
|
|
2741
|
+
map_to: {
|
|
2742
|
+
code: RESPONSE_CODE.MEDIA_PICKER_FAIL,
|
|
2743
|
+
message: MESSAGES.MEDIA_PICKER_FAIL
|
|
2744
|
+
},
|
|
2745
|
+
need_more_detail: true
|
|
2746
|
+
}
|
|
2747
|
+
},
|
|
2748
|
+
iOS: {
|
|
2749
|
+
'-10': {
|
|
2750
|
+
map_to: {
|
|
2751
|
+
code: RESPONSE_CODE.MEDIA_PICKER_FAIL,
|
|
2752
|
+
message: MESSAGES.MEDIA_PICKER_FAIL
|
|
2753
|
+
}
|
|
2754
|
+
}
|
|
2755
|
+
}
|
|
2756
|
+
}
|
|
2582
2757
|
},
|
|
2583
2758
|
MP_CLOSE_LOADINGVIEW: {
|
|
2584
2759
|
name: 'action.mp.close.loadingview'
|
|
2585
2760
|
}
|
|
2586
2761
|
};
|
|
2587
|
-
const
|
|
2588
|
-
|
|
2589
|
-
|
|
2590
|
-
|
|
2591
|
-
|
|
2592
|
-
|
|
2593
|
-
|
|
2594
|
-
|
|
2595
|
-
|
|
2596
|
-
|
|
2597
|
-
|
|
2598
|
-
LOGIN_REQUIRED: 'Please login before to call this api. Read more at: https://miniapp.zalo.me/docs/api/login',
|
|
2599
|
-
LOGIN_FAILED: 'Login failed.',
|
|
2600
|
-
NOT_PERMISSION: `You don't have permission to call this api`,
|
|
2601
|
-
CLIENT_NOT_SUPPORT: `This API is not supported in this Zalo version`,
|
|
2602
|
-
DECODE_FAILED: 'Can not decode your data. Read more at: https://miniapp.zalo.me/docs/api/error'
|
|
2603
|
-
};
|
|
2604
|
-
const API_DOMAIN = 'https://h5.zalo.me/';
|
|
2605
|
-
const H5_API = {
|
|
2606
|
-
GET_APP_INFO: 'apps/get-info'
|
|
2762
|
+
const COMMON_NATIVE_ERROR_CODE = {
|
|
2763
|
+
android: {
|
|
2764
|
+
'-4': RESPONSE.DECODE_FAILED,
|
|
2765
|
+
'-5': RESPONSE.CLIENT_NOT_SUPPORT,
|
|
2766
|
+
'-14': RESPONSE.TIME_OUT
|
|
2767
|
+
},
|
|
2768
|
+
iOS: {
|
|
2769
|
+
'-9': RESPONSE.DECODE_FAILED,
|
|
2770
|
+
'-5': RESPONSE.CLIENT_NOT_SUPPORT,
|
|
2771
|
+
'-14': RESPONSE.TIME_OUT
|
|
2772
|
+
}
|
|
2607
2773
|
};
|
|
2608
2774
|
const ZALO_SUPPORT_STORAGE_VERSION = {
|
|
2609
2775
|
android: 12100571,
|
|
@@ -2611,6 +2777,12 @@ const ZALO_SUPPORT_STORAGE_VERSION = {
|
|
|
2611
2777
|
wp: 0,
|
|
2612
2778
|
unknown: 0
|
|
2613
2779
|
};
|
|
2780
|
+
const ZALO_SUPPORT_SHARE_MULTI_IMAGE_VERSION = {
|
|
2781
|
+
android: 12220401,
|
|
2782
|
+
iOS: 460,
|
|
2783
|
+
wp: 0,
|
|
2784
|
+
unknown: 0
|
|
2785
|
+
};
|
|
2614
2786
|
// List actions supported before support action action.get.supported.actions
|
|
2615
2787
|
const ZALO_IOS_ACTIONS_SUPPORTED_BEFORE_VER_402 = [
|
|
2616
2788
|
ACTION.GET_DOWNLOADED_STICKER.name,
|
|
@@ -2715,124 +2887,36 @@ const PAYMENT_APIS = {
|
|
|
2715
2887
|
};
|
|
2716
2888
|
const PAYMENT_H5_URL = 'https://payment-mini.zalo.me';
|
|
2717
2889
|
|
|
2718
|
-
class
|
|
2890
|
+
class AppError {
|
|
2719
2891
|
constructor(code, msg, api) {
|
|
2720
2892
|
this.code = code;
|
|
2721
2893
|
this.message = msg;
|
|
2722
2894
|
this.api = api;
|
|
2723
2895
|
}
|
|
2724
2896
|
toString() {
|
|
2725
|
-
return `api: ${this.api}; code: ${this.code}; message: ${this.message}`;
|
|
2897
|
+
return `api: ${String(this.api)}; code: ${this.code}; message: ${this.message}`;
|
|
2726
2898
|
}
|
|
2727
|
-
|
|
2728
|
-
|
|
2729
|
-
|
|
2730
|
-
|
|
2731
|
-
|
|
2732
|
-
|
|
2733
|
-
}
|
|
2734
|
-
handler() {
|
|
2735
|
-
switch (this.code) {
|
|
2736
|
-
case NativeCode.token_invalid:
|
|
2737
|
-
this.code = RESPONSE_CODE.UNAUTHORIZED;
|
|
2738
|
-
this.message = MESSAGES.LOGIN_REQUIRED;
|
|
2739
|
-
break;
|
|
2740
|
-
case NativeCode.not_permission:
|
|
2741
|
-
this.code = RESPONSE_CODE.FORBIDDEN;
|
|
2742
|
-
this.message = MESSAGES.NOT_PERMISSION;
|
|
2743
|
-
break;
|
|
2744
|
-
case NativeCode.client_not_support:
|
|
2745
|
-
this.code = RESPONSE_CODE.CLIENT_NOT_SUPPORT;
|
|
2746
|
-
this.message = MESSAGES.CLIENT_NOT_SUPPORT;
|
|
2747
|
-
break;
|
|
2748
|
-
case NativeCode.decode_failed:
|
|
2749
|
-
this.message = MESSAGES.DECODE_FAILED;
|
|
2750
|
-
break;
|
|
2751
|
-
}
|
|
2899
|
+
toJSON() {
|
|
2900
|
+
return {
|
|
2901
|
+
code: this.code,
|
|
2902
|
+
message: this.message,
|
|
2903
|
+
api: this.api
|
|
2904
|
+
};
|
|
2752
2905
|
}
|
|
2753
2906
|
}
|
|
2754
|
-
const
|
|
2755
|
-
|
|
2756
|
-
|
|
2757
|
-
this.handler = handler;
|
|
2758
|
-
}
|
|
2907
|
+
const handleKnownExceptions = (error, api) => {
|
|
2908
|
+
error.api = api;
|
|
2909
|
+
return error.toJSON();
|
|
2759
2910
|
};
|
|
2760
|
-
const
|
|
2761
|
-
if (error instanceof
|
|
2762
|
-
error.
|
|
2763
|
-
return error;
|
|
2911
|
+
const handleUnknownExceptions = (error, api) => {
|
|
2912
|
+
if (error instanceof Error) {
|
|
2913
|
+
return new AppError(RESPONSE_CODE.UNKNOWN_ERROR, error.message, api).toJSON();
|
|
2764
2914
|
}
|
|
2765
|
-
return new
|
|
2766
|
-
};
|
|
2767
|
-
catchDecoratorStore.setHandler(errorHandler);
|
|
2768
|
-
const handleError = (target, propertyName, descriptor) => {
|
|
2769
|
-
const fn = descriptor.value;
|
|
2770
|
-
descriptor.value = function (...args) {
|
|
2771
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
2772
|
-
const { success, fail } = Array.isArray(args) && args.length > 0 && args[0];
|
|
2773
|
-
return new Promise((resolve, reject) => __awaiter(this, void 0, void 0, function* () {
|
|
2774
|
-
try {
|
|
2775
|
-
const res = yield fn.apply(this, args);
|
|
2776
|
-
if (!_.isNull(success) && _.isFunction(success)) {
|
|
2777
|
-
success.call(null, res, this);
|
|
2778
|
-
}
|
|
2779
|
-
else {
|
|
2780
|
-
resolve(res);
|
|
2781
|
-
}
|
|
2782
|
-
}
|
|
2783
|
-
catch (error) {
|
|
2784
|
-
if ((error === null || error === void 0 ? void 0 : error.api) !== 'login' && // login is not error
|
|
2785
|
-
((error === null || error === void 0 ? void 0 : error.code) === RESPONSE_CODE.UNAUTHORIZED ||
|
|
2786
|
-
(error === null || error === void 0 ? void 0 : error.code) === RESPONSE_CODE.FORBIDDEN)) {
|
|
2787
|
-
let loggedIn = false;
|
|
2788
|
-
if (this instanceof SDKCreator) {
|
|
2789
|
-
loggedIn = this.getLoginStatus();
|
|
2790
|
-
}
|
|
2791
|
-
if (!loggedIn) {
|
|
2792
|
-
error = new CommonError(RESPONSE_CODE.UNAUTHORIZED, MESSAGES.LOGIN_REQUIRED);
|
|
2793
|
-
}
|
|
2794
|
-
}
|
|
2795
|
-
const { handler } = catchDecoratorStore;
|
|
2796
|
-
const errorParsed = handler.call(null, propertyName, error, this);
|
|
2797
|
-
window.zmpSentry && window.zmpSentry.throwError(errorParsed.toString());
|
|
2798
|
-
if (!_.isNull(fail) && _.isFunction(fail)) {
|
|
2799
|
-
fail.call(null, errorParsed, this);
|
|
2800
|
-
}
|
|
2801
|
-
else {
|
|
2802
|
-
reject(errorParsed);
|
|
2803
|
-
}
|
|
2804
|
-
}
|
|
2805
|
-
}));
|
|
2806
|
-
});
|
|
2807
|
-
};
|
|
2808
|
-
return descriptor;
|
|
2915
|
+
return new AppError(RESPONSE_CODE.UNKNOWN_ERROR, MESSAGES.UNKNOWN_ERROR, api).toJSON();
|
|
2809
2916
|
};
|
|
2810
|
-
const
|
|
2811
|
-
|
|
2812
|
-
|
|
2813
|
-
try {
|
|
2814
|
-
return fn.apply(this, args);
|
|
2815
|
-
}
|
|
2816
|
-
catch (error) {
|
|
2817
|
-
if ((error === null || error === void 0 ? void 0 : error.api) !== 'login' && // login is not error
|
|
2818
|
-
((error === null || error === void 0 ? void 0 : error.code) === RESPONSE_CODE.UNAUTHORIZED ||
|
|
2819
|
-
(error === null || error === void 0 ? void 0 : error.code) === RESPONSE_CODE.FORBIDDEN)) {
|
|
2820
|
-
let loggedIn = false;
|
|
2821
|
-
if (this instanceof SDKCreator) {
|
|
2822
|
-
loggedIn = this.getLoginStatus();
|
|
2823
|
-
}
|
|
2824
|
-
if (!loggedIn) {
|
|
2825
|
-
error = new CommonError(RESPONSE_CODE.UNAUTHORIZED, MESSAGES.LOGIN_REQUIRED);
|
|
2826
|
-
}
|
|
2827
|
-
}
|
|
2828
|
-
const { handler } = catchDecoratorStore;
|
|
2829
|
-
const errorParsed = handler.call(null, key, error, this);
|
|
2830
|
-
window.zmpSentry && window.zmpSentry.throwError(errorParsed.toString());
|
|
2831
|
-
throw errorParsed;
|
|
2832
|
-
}
|
|
2833
|
-
};
|
|
2834
|
-
return descriptor;
|
|
2835
|
-
};
|
|
2917
|
+
const errorHandler = (error, api) => error instanceof AppError
|
|
2918
|
+
? handleKnownExceptions(error, api)
|
|
2919
|
+
: handleUnknownExceptions(error, api);
|
|
2836
2920
|
|
|
2837
2921
|
const apiResponse = {
|
|
2838
2922
|
success: (data, message) => ({
|
|
@@ -2841,13 +2925,13 @@ const apiResponse = {
|
|
|
2841
2925
|
data: data || {}
|
|
2842
2926
|
}),
|
|
2843
2927
|
error: {
|
|
2844
|
-
badRequest: (message) => new
|
|
2845
|
-
loginFailed: () => new
|
|
2846
|
-
loginRequired: () => new
|
|
2847
|
-
missingParam: (params) => new
|
|
2848
|
-
wrongTypeParam: (arg, expected, got) => new
|
|
2849
|
-
cannotGetShareInfo: () => new
|
|
2850
|
-
lengthInvalid: (arg) => new
|
|
2928
|
+
badRequest: (message) => new AppError(RESPONSE_CODE.BAD_REQUEST, message),
|
|
2929
|
+
loginFailed: (message) => new AppError(RESPONSE_CODE.UNAUTHORIZED, `${MESSAGES.LOGIN_FAILED}: ${message}`),
|
|
2930
|
+
loginRequired: () => new AppError(RESPONSE_CODE.UNAUTHORIZED, MESSAGES.LOGIN_REQUIRED),
|
|
2931
|
+
missingParam: (params) => new AppError(RESPONSE_CODE.BAD_REQUEST, `Missing required argument: ${params}`),
|
|
2932
|
+
wrongTypeParam: (arg, expected, got) => new AppError(RESPONSE_CODE.BAD_REQUEST, `Wrong type of parameter '${arg}'. Expected ${expected}, but got ${got}`),
|
|
2933
|
+
cannotGetShareInfo: () => new AppError(RESPONSE_CODE.INTERNAL_SERVER_ERROR, `Can not get app info to share`),
|
|
2934
|
+
lengthInvalid: (arg) => new AppError(RESPONSE_CODE.BAD_REQUEST, `${arg} length is invalid.`)
|
|
2851
2935
|
}
|
|
2852
2936
|
};
|
|
2853
2937
|
|
|
@@ -3262,7 +3346,7 @@ const getAppInfo = (appId, versionStatus, currentVersion) => __awaiter(void 0, v
|
|
|
3262
3346
|
if (!_.isUndefined(currentVersion)) {
|
|
3263
3347
|
inputData.currentVersion = currentVersion;
|
|
3264
3348
|
}
|
|
3265
|
-
const api = QueryString.appendToUrl(
|
|
3349
|
+
const api = QueryString.appendToUrl(APIS.GET_APP_INFO, inputData);
|
|
3266
3350
|
const msgApi = yield fetch(api, {
|
|
3267
3351
|
credentials: 'include'
|
|
3268
3352
|
});
|
|
@@ -3654,504 +3738,97 @@ class ZMPEEmitter extends eventemitter3 {
|
|
|
3654
3738
|
}
|
|
3655
3739
|
}
|
|
3656
3740
|
|
|
3657
|
-
var
|
|
3658
|
-
|
|
3659
|
-
|
|
3660
|
-
|
|
3661
|
-
|
|
3662
|
-
|
|
3663
|
-
|
|
3664
|
-
|
|
3665
|
-
|
|
3666
|
-
|
|
3667
|
-
|
|
3668
|
-
|
|
3669
|
-
wrappers[type] = fn;
|
|
3670
|
-
};
|
|
3671
|
-
var ERROR = {
|
|
3672
|
-
error: {
|
|
3673
|
-
code: 1,
|
|
3674
|
-
error_subcode: 1357046,
|
|
3675
|
-
message: 'Received Invalid JSON reply.',
|
|
3676
|
-
type: 'http'
|
|
3677
|
-
}
|
|
3678
|
-
};
|
|
3679
|
-
function safelyParseResponse(rawResponse) {
|
|
3680
|
-
try {
|
|
3681
|
-
return rawResponse === null ? ERROR : JSON.parse(rawResponse);
|
|
3682
|
-
}
|
|
3683
|
-
catch (ex) {
|
|
3684
|
-
return ERROR;
|
|
3741
|
+
var version$1 = "2.21.1";
|
|
3742
|
+
|
|
3743
|
+
class Basics {
|
|
3744
|
+
/**
|
|
3745
|
+
* Lấy version hiện tại của Zalo Mini Program SDK
|
|
3746
|
+
*
|
|
3747
|
+
* @category Basics
|
|
3748
|
+
*
|
|
3749
|
+
* @returns {string} Version hiện tại của Zalo Mini Program SDK.
|
|
3750
|
+
*/
|
|
3751
|
+
static getVersion() {
|
|
3752
|
+
return version$1;
|
|
3685
3753
|
}
|
|
3686
|
-
|
|
3687
|
-
|
|
3688
|
-
|
|
3689
|
-
|
|
3754
|
+
/**
|
|
3755
|
+
* Gets system information.
|
|
3756
|
+
*
|
|
3757
|
+
* @function getSystemInfo
|
|
3758
|
+
* @category Basics
|
|
3759
|
+
*
|
|
3760
|
+
*
|
|
3761
|
+
*
|
|
3762
|
+
*/
|
|
3763
|
+
static getSystemInfo() {
|
|
3764
|
+
const system = {
|
|
3765
|
+
version: getMetaValue('version-id') || '',
|
|
3766
|
+
apiVersion: version$1,
|
|
3767
|
+
zaloVersion: getZaloVersion(),
|
|
3768
|
+
platform: getPlatform(),
|
|
3769
|
+
language: navigator.language,
|
|
3770
|
+
zaloLanguage: window.zLanguage || 'vi',
|
|
3771
|
+
zaloTheme: window.zTheme || 'light'
|
|
3772
|
+
};
|
|
3773
|
+
return system;
|
|
3690
3774
|
}
|
|
3691
|
-
|
|
3692
|
-
|
|
3693
|
-
|
|
3694
|
-
|
|
3695
|
-
|
|
3775
|
+
/**
|
|
3776
|
+
* Lấy thông tin mini app
|
|
3777
|
+
*
|
|
3778
|
+
* @async
|
|
3779
|
+
* @function getAppInfo
|
|
3780
|
+
* @category Device
|
|
3781
|
+
*
|
|
3782
|
+
*/
|
|
3783
|
+
static getAppInfo() {
|
|
3784
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
3785
|
+
const appId = this.getAppId();
|
|
3786
|
+
const systemInfo = this.getSystemInfo();
|
|
3787
|
+
return yield getAppInfo(appId, 0, systemInfo.version);
|
|
3788
|
+
});
|
|
3696
3789
|
}
|
|
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
|
-
|
|
3738
|
-
|
|
3739
|
-
url = QueryString.appendToUrl(url, data);
|
|
3740
|
-
data = '';
|
|
3741
|
-
}
|
|
3742
|
-
var request = createCORSRequest(method, url);
|
|
3743
|
-
if (!request) {
|
|
3744
|
-
return false;
|
|
3745
|
-
}
|
|
3746
|
-
request.onload = function (xhr) {
|
|
3747
|
-
cb(safelyParseResponse(xhr.responseText));
|
|
3748
|
-
};
|
|
3749
|
-
request.onerror = function (xhr) {
|
|
3750
|
-
if (xhr.responseText) {
|
|
3751
|
-
cb(safelyParseResponse(xhr.responseText));
|
|
3752
|
-
}
|
|
3753
|
-
else {
|
|
3754
|
-
cb({
|
|
3755
|
-
error: {
|
|
3756
|
-
code: 1,
|
|
3757
|
-
error_subcode: 1357045,
|
|
3758
|
-
message: 'unknown error (empty response)',
|
|
3759
|
-
status: xhr.status,
|
|
3760
|
-
type: 'http'
|
|
3761
|
-
}
|
|
3762
|
-
});
|
|
3763
|
-
}
|
|
3764
|
-
};
|
|
3765
|
-
request.send(data);
|
|
3766
|
-
return true;
|
|
3767
|
-
}
|
|
3768
|
-
var CORSRequest = {
|
|
3769
|
-
execute: execute
|
|
3770
|
-
};
|
|
3771
|
-
|
|
3772
|
-
class ZaloJSBridge extends eventemitter3 {
|
|
3773
|
-
constructor() {
|
|
3774
|
-
super();
|
|
3775
|
-
this.debug = Debug('zmp:ZaloJSBridge');
|
|
3776
|
-
this.events = ZMPEEmitter.getInstance();
|
|
3777
|
-
this._accessTk = getToken('zacc_session') || 'DEFAULT_ACCESS_TOKEN';
|
|
3778
|
-
this._jsAccessTk = getToken('zlink3rd') || 'DEFAULT_JS_TOKEN';
|
|
3779
|
-
this.results = [];
|
|
3780
|
-
this._userAgent = getUserAgent();
|
|
3781
|
-
this._device = checkPlatform();
|
|
3782
|
-
this._jsCallFuncCallbacks = {};
|
|
3783
|
-
this.events.on(Events.AppPaused, () => {
|
|
3784
|
-
if (this.results.length > 0) {
|
|
3785
|
-
let array = this.results;
|
|
3786
|
-
this.results = [];
|
|
3787
|
-
try {
|
|
3788
|
-
this.sendLogData(array);
|
|
3789
|
-
}
|
|
3790
|
-
catch (error) { }
|
|
3791
|
-
}
|
|
3792
|
-
});
|
|
3793
|
-
if (this.sendLogTimer) {
|
|
3794
|
-
clearInterval(this.sendLogTimer);
|
|
3795
|
-
}
|
|
3796
|
-
else {
|
|
3797
|
-
this.sendLogTimer = setInterval(() => {
|
|
3798
|
-
if (this.results.length > 0) {
|
|
3799
|
-
let array = this.results;
|
|
3800
|
-
this.results = [];
|
|
3801
|
-
try {
|
|
3802
|
-
this.sendLogData(array);
|
|
3803
|
-
}
|
|
3804
|
-
catch (error) { }
|
|
3805
|
-
}
|
|
3806
|
-
}, 5000);
|
|
3807
|
-
}
|
|
3808
|
-
}
|
|
3809
|
-
static getInstance() {
|
|
3810
|
-
if (!ZaloJSBridge.instance) {
|
|
3811
|
-
ZaloJSBridge.instance = new ZaloJSBridge();
|
|
3812
|
-
}
|
|
3813
|
-
return ZaloJSBridge.instance;
|
|
3814
|
-
}
|
|
3815
|
-
set accessTk(value) {
|
|
3816
|
-
this._accessTk = value;
|
|
3817
|
-
}
|
|
3818
|
-
set jsAccessTk(value) {
|
|
3819
|
-
this._jsAccessTk = value;
|
|
3820
|
-
}
|
|
3821
|
-
sendLogData(data) {
|
|
3822
|
-
try {
|
|
3823
|
-
CORSRequest.execute('https://h5.zalo.me/log/async', 'post', {
|
|
3824
|
-
appId: window.APP_ID,
|
|
3825
|
-
data: JSON.stringify(data)
|
|
3826
|
-
}, (response) => { });
|
|
3827
|
-
}
|
|
3828
|
-
catch (error) { }
|
|
3829
|
-
}
|
|
3830
|
-
onJSCall(key, data) {
|
|
3831
|
-
try {
|
|
3832
|
-
this.debug('onJSCall', key, data);
|
|
3833
|
-
const parsedData = parseJSON(data);
|
|
3834
|
-
if (this._jsCallFuncCallbacks[key]) {
|
|
3835
|
-
const callback = this._jsCallFuncCallbacks[key].callback;
|
|
3836
|
-
const timeout = this._jsCallFuncCallbacks[key].timeout;
|
|
3837
|
-
if (!!callback) {
|
|
3838
|
-
try {
|
|
3839
|
-
callback.call(this, parsedData);
|
|
3840
|
-
}
|
|
3841
|
-
catch (error) {
|
|
3842
|
-
console.error('Call callback error', error);
|
|
3843
|
-
}
|
|
3844
|
-
!!timeout && clearTimeout(timeout);
|
|
3845
|
-
this._jsCallFuncCallbacks[key] = null;
|
|
3846
|
-
delete this._jsCallFuncCallbacks[key];
|
|
3847
|
-
}
|
|
3848
|
-
}
|
|
3849
|
-
this.results.push({
|
|
3850
|
-
action: parsedData.action,
|
|
3851
|
-
error: parsedData.error_code
|
|
3852
|
-
});
|
|
3853
|
-
}
|
|
3854
|
-
catch (e) {
|
|
3855
|
-
console.log('onJSCall', 'error', e);
|
|
3856
|
-
}
|
|
3857
|
-
}
|
|
3858
|
-
onMultiJSCall(key, data) {
|
|
3859
|
-
try {
|
|
3860
|
-
this.debug('onMultiJSCall', key, data);
|
|
3861
|
-
const parsedData = parseJSON(data);
|
|
3862
|
-
if (this._jsCallFuncCallbacks[key]) {
|
|
3863
|
-
const callback = this._jsCallFuncCallbacks[key].callback;
|
|
3864
|
-
const timeout = this._jsCallFuncCallbacks[key].timeout;
|
|
3865
|
-
if (!!callback) {
|
|
3866
|
-
try {
|
|
3867
|
-
callback.call(this, parsedData);
|
|
3868
|
-
}
|
|
3869
|
-
catch (error) {
|
|
3870
|
-
console.error('Call callback error', error);
|
|
3871
|
-
}
|
|
3872
|
-
!!timeout && clearTimeout(timeout);
|
|
3873
|
-
}
|
|
3874
|
-
}
|
|
3875
|
-
this.results.push({
|
|
3876
|
-
action: parsedData.action,
|
|
3877
|
-
error: parsedData.error_code
|
|
3878
|
-
});
|
|
3879
|
-
}
|
|
3880
|
-
catch (e) {
|
|
3881
|
-
console.log('onMultiJSCall', 'error', e);
|
|
3882
|
-
}
|
|
3883
|
-
}
|
|
3884
|
-
nativeEventHandler(eventId, eventName, eventData) {
|
|
3885
|
-
this.debug(`eventId: ${eventId}, eventName: ${eventName}, eventData: ${eventData}`);
|
|
3886
|
-
const data = stringToData(eventData);
|
|
3887
|
-
this.debug(data);
|
|
3888
|
-
const convertedData = this.handleEventData(eventName, data);
|
|
3889
|
-
this.events.emit(eventName, eventId, convertedData);
|
|
3890
|
-
}
|
|
3891
|
-
handleEventData(eventName, data) {
|
|
3892
|
-
try {
|
|
3893
|
-
switch (eventName) {
|
|
3894
|
-
case Events.OpenApp:
|
|
3895
|
-
const { url } = data;
|
|
3896
|
-
const validUrl = new URL(url);
|
|
3897
|
-
const path = validUrl.pathname.split(`/zapps/${APP_ID}`)[1];
|
|
3898
|
-
return {
|
|
3899
|
-
path: `${path ? path : '/'}${validUrl.search}`
|
|
3900
|
-
};
|
|
3901
|
-
break;
|
|
3902
|
-
default:
|
|
3903
|
-
return data;
|
|
3904
|
-
break;
|
|
3905
|
-
}
|
|
3906
|
-
}
|
|
3907
|
-
catch (error) {
|
|
3908
|
-
return data;
|
|
3909
|
-
}
|
|
3910
|
-
}
|
|
3911
|
-
defaultCallback(data) {
|
|
3912
|
-
if (data !== null && data !== undefined) {
|
|
3913
|
-
data = parseJSON(data);
|
|
3914
|
-
}
|
|
3915
|
-
}
|
|
3916
|
-
jsCall(action, options, callback, isMultiCallback = false, nRetry = 3, haveTimeout = true) {
|
|
3917
|
-
try {
|
|
3918
|
-
const actionName = action.name;
|
|
3919
|
-
const key = generateUniqueString(actionName);
|
|
3920
|
-
if (!this._device.isMobile || _.isEmpty(actionName)) {
|
|
3921
|
-
this.onJSCall(key, {
|
|
3922
|
-
error_code: -13,
|
|
3923
|
-
error_message: 'params invalid!',
|
|
3924
|
-
data: {
|
|
3925
|
-
device: this._device.isMobile,
|
|
3926
|
-
jsToken: this._jsAccessTk,
|
|
3927
|
-
access_token: this._accessTk
|
|
3928
|
-
},
|
|
3929
|
-
action: actionName
|
|
3930
|
-
});
|
|
3931
|
-
return false;
|
|
3932
|
-
}
|
|
3933
|
-
if (options === undefined || options === null) {
|
|
3934
|
-
options = {};
|
|
3935
|
-
}
|
|
3936
|
-
if (!callback) {
|
|
3937
|
-
callback = this.defaultCallback;
|
|
3938
|
-
}
|
|
3939
|
-
const timeoutCallback = {
|
|
3940
|
-
error_code: -14,
|
|
3941
|
-
error_message: 'Request Timeout!',
|
|
3942
|
-
data: {},
|
|
3943
|
-
action: actionName
|
|
3944
|
-
};
|
|
3945
|
-
this._jsCallFuncCallbacks[key] = {
|
|
3946
|
-
timeout: haveTimeout &&
|
|
3947
|
-
action.have_callback &&
|
|
3948
|
-
setTimeout(() => {
|
|
3949
|
-
this.onJSCall(key, timeoutCallback);
|
|
3950
|
-
}, 8000),
|
|
3951
|
-
callback: callback
|
|
3952
|
-
};
|
|
3953
|
-
try {
|
|
3954
|
-
options = serialize(options);
|
|
3955
|
-
if (isMultiCallback) {
|
|
3956
|
-
if (this._device.isIOS) {
|
|
3957
|
-
return ZaloJavaScriptInterface.jsCall(this._jsAccessTk, actionName, this._accessTk, options, window.onMultiJSCall(key));
|
|
3958
|
-
}
|
|
3959
|
-
return ZaloJavaScriptInterface.jsCall(this._jsAccessTk, actionName, this._accessTk, options, `window.onMultiJSCall('${key}')`);
|
|
3960
|
-
}
|
|
3961
|
-
if (this._device.isIOS) {
|
|
3962
|
-
return ZaloJavaScriptInterface.jsCall(this._jsAccessTk, actionName, this._accessTk, options, window.onJSCall(key));
|
|
3963
|
-
}
|
|
3964
|
-
return ZaloJavaScriptInterface.jsCall(this._jsAccessTk, actionName, this._accessTk, options, `window.onJSCall('${key}')`);
|
|
3965
|
-
}
|
|
3966
|
-
catch (error) {
|
|
3967
|
-
if (nRetry-- > 0) {
|
|
3968
|
-
setTimeout(() => {
|
|
3969
|
-
this.jsCall(action, options, callback, isMultiCallback, nRetry);
|
|
3970
|
-
}, 500);
|
|
3971
|
-
}
|
|
3972
|
-
else {
|
|
3973
|
-
const errorCallback = {
|
|
3974
|
-
error_code: -5,
|
|
3975
|
-
error_message: 'Not ready!',
|
|
3976
|
-
data: {
|
|
3977
|
-
userAgent: this._userAgent,
|
|
3978
|
-
options: options,
|
|
3979
|
-
jsToken: this._jsAccessTk,
|
|
3980
|
-
access_token: this._accessTk
|
|
3981
|
-
},
|
|
3982
|
-
action: actionName,
|
|
3983
|
-
js_error: error
|
|
3984
|
-
};
|
|
3985
|
-
this.onJSCall(key, errorCallback);
|
|
3986
|
-
return false;
|
|
3987
|
-
}
|
|
3988
|
-
}
|
|
3989
|
-
}
|
|
3990
|
-
catch (error) {
|
|
3991
|
-
console.log('jsCall', 'error', error);
|
|
3992
|
-
}
|
|
3993
|
-
return false;
|
|
3994
|
-
}
|
|
3995
|
-
}
|
|
3996
|
-
|
|
3997
|
-
var _ZJSBridgeProvider_bridge;
|
|
3998
|
-
/** @ignore */
|
|
3999
|
-
class ZJSBridgeProvider {
|
|
4000
|
-
/** @ignore */
|
|
4001
|
-
constructor() {
|
|
4002
|
-
this.debug = Debug('zmp:ZJSBridgeProvider');
|
|
4003
|
-
_ZJSBridgeProvider_bridge.set(this, void 0);
|
|
4004
|
-
__classPrivateFieldSet(this, _ZJSBridgeProvider_bridge, ZaloJSBridge.getInstance(), "f");
|
|
4005
|
-
}
|
|
4006
|
-
setZAccSession(value) {
|
|
4007
|
-
__classPrivateFieldGet(this, _ZJSBridgeProvider_bridge, "f").accessTk = value;
|
|
4008
|
-
}
|
|
4009
|
-
setJSToken(value) {
|
|
4010
|
-
__classPrivateFieldGet(this, _ZJSBridgeProvider_bridge, "f").jsAccessTk = value;
|
|
4011
|
-
}
|
|
4012
|
-
callNative(action, data, option) {
|
|
4013
|
-
this.debug(action.name, data);
|
|
4014
|
-
return new Promise((resolve, reject) => {
|
|
4015
|
-
const fn = (cb) => __awaiter(this, void 0, void 0, function* () {
|
|
4016
|
-
try {
|
|
4017
|
-
const error = new NativeError(cb.error_code, `${cb.action}: ${cb.error_message}`);
|
|
4018
|
-
if (option === null || option === void 0 ? void 0 : option.callback) {
|
|
4019
|
-
const res = yield option.callback(cb, error);
|
|
4020
|
-
return resolve(res);
|
|
4021
|
-
}
|
|
4022
|
-
else {
|
|
4023
|
-
if (cb && cb.error_code >= 0) {
|
|
4024
|
-
resolve(cb.data || {});
|
|
4025
|
-
}
|
|
4026
|
-
else if (cb && cb.error_code < 0) {
|
|
4027
|
-
try {
|
|
4028
|
-
window.zmpSentry &&
|
|
4029
|
-
window.zmpSentry.captureMessage(`${action.name}: call native fail`, {
|
|
4030
|
-
extra: {
|
|
4031
|
-
data: data,
|
|
4032
|
-
rs: cb
|
|
4033
|
-
}
|
|
4034
|
-
});
|
|
4035
|
-
}
|
|
4036
|
-
catch (error) { }
|
|
4037
|
-
return reject(error);
|
|
4038
|
-
}
|
|
4039
|
-
}
|
|
4040
|
-
}
|
|
4041
|
-
catch (error) {
|
|
4042
|
-
return reject(error);
|
|
4043
|
-
}
|
|
4044
|
-
});
|
|
4045
|
-
const isIOS = checkPlatform().isIOS;
|
|
4046
|
-
const isSupportAction = checkIOSSupportAction(action);
|
|
4047
|
-
if (isIOS && !isSupportAction) {
|
|
4048
|
-
const error = new NativeError(-5, `${action}: Client isn't support this action`);
|
|
4049
|
-
return reject(error);
|
|
4050
|
-
}
|
|
4051
|
-
else if (option === null || option === void 0 ? void 0 : option.delay) {
|
|
4052
|
-
setTimeout(() => {
|
|
4053
|
-
__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);
|
|
4054
|
-
}, option.delay);
|
|
4055
|
-
}
|
|
4056
|
-
else {
|
|
4057
|
-
__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);
|
|
4058
|
-
}
|
|
4059
|
-
});
|
|
4060
|
-
}
|
|
4061
|
-
}
|
|
4062
|
-
_ZJSBridgeProvider_bridge = new WeakMap();
|
|
4063
|
-
|
|
4064
|
-
var version$1 = "2.20.0";
|
|
4065
|
-
|
|
4066
|
-
class Basics {
|
|
4067
|
-
/**
|
|
4068
|
-
* Lấy version hiện tại của Zalo Mini Program SDK
|
|
4069
|
-
*
|
|
4070
|
-
* @category Basics
|
|
4071
|
-
*
|
|
4072
|
-
* @returns {string} Version hiện tại của Zalo Mini Program SDK.
|
|
4073
|
-
*/
|
|
4074
|
-
static getVersion() {
|
|
4075
|
-
return version$1;
|
|
4076
|
-
}
|
|
4077
|
-
/**
|
|
4078
|
-
* Gets system information.
|
|
4079
|
-
*
|
|
4080
|
-
* @function getSystemInfo
|
|
4081
|
-
* @category Basics
|
|
4082
|
-
*
|
|
4083
|
-
*
|
|
4084
|
-
*
|
|
4085
|
-
*/
|
|
4086
|
-
static getSystemInfo() {
|
|
4087
|
-
const system = {
|
|
4088
|
-
version: getMetaValue('version-id') || '',
|
|
4089
|
-
apiVersion: version$1,
|
|
4090
|
-
zaloVersion: getZaloVersion(),
|
|
4091
|
-
platform: getPlatform(),
|
|
4092
|
-
language: navigator.language,
|
|
4093
|
-
zaloLanguage: window.zLanguage || 'vi',
|
|
4094
|
-
zaloTheme: window.zTheme || 'light'
|
|
4095
|
-
};
|
|
4096
|
-
return system;
|
|
4097
|
-
}
|
|
4098
|
-
/**
|
|
4099
|
-
* Lấy thông tin mini app
|
|
4100
|
-
*
|
|
4101
|
-
* @async
|
|
4102
|
-
* @function getAppInfo
|
|
4103
|
-
* @category Device
|
|
4104
|
-
*
|
|
4105
|
-
*/
|
|
4106
|
-
static getAppInfo() {
|
|
4107
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
4108
|
-
const appId = this.getAppId();
|
|
4109
|
-
const systemInfo = this.getSystemInfo();
|
|
4110
|
-
return yield getAppInfo(appId, 0, systemInfo.version);
|
|
4111
|
-
});
|
|
4112
|
-
}
|
|
4113
|
-
}
|
|
4114
|
-
|
|
4115
|
-
class NavigationBar {
|
|
4116
|
-
/**
|
|
4117
|
-
* A promise for the user's favorite color.
|
|
4118
|
-
*
|
|
4119
|
-
* @promise FavoriteColorPromise
|
|
4120
|
-
* @fulfill {string} The user's favorite color.
|
|
4121
|
-
* @reject {TypeError} The user's favorite color is an invalid type.
|
|
4122
|
-
* @reject {MissingColorError} The user has not specified a favorite color.
|
|
4123
|
-
*/
|
|
4124
|
-
/**
|
|
4125
|
-
* Dynamically sets the title of the current page.
|
|
4126
|
-
*
|
|
4127
|
-
* @async
|
|
4128
|
-
* @function setNavigationBarTitle
|
|
4129
|
-
* @category Navigation Bar
|
|
4130
|
-
*
|
|
4131
|
-
* @example
|
|
4132
|
-
*
|
|
4133
|
-
* zmpApis.setNavigationBarTitle({
|
|
4134
|
-
* title: "Current Page"
|
|
4135
|
-
* }).then((res) => {
|
|
4136
|
-
* console.log("Success");
|
|
4137
|
-
* }).catch((error) => {
|
|
4138
|
-
* console.log("Fail");
|
|
4139
|
-
* });
|
|
4140
|
-
*
|
|
4141
|
-
* @param {Object} object
|
|
4142
|
-
* @param {string} object.title - The title of the page
|
|
4143
|
-
*
|
|
4144
|
-
* @return {Promise}
|
|
4145
|
-
*
|
|
4146
|
-
*/
|
|
4147
|
-
static setNavigationBarTitle(object) {
|
|
4148
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
4149
|
-
yield this.callNative(ACTION.CHANGE_TITLE_HEADER, {
|
|
4150
|
-
title: object.title
|
|
4151
|
-
}, {
|
|
4152
|
-
haveTimeout: false
|
|
4153
|
-
});
|
|
4154
|
-
});
|
|
3790
|
+
}
|
|
3791
|
+
|
|
3792
|
+
class NavigationBar {
|
|
3793
|
+
/**
|
|
3794
|
+
* A promise for the user's favorite color.
|
|
3795
|
+
*
|
|
3796
|
+
* @promise FavoriteColorPromise
|
|
3797
|
+
* @fulfill {string} The user's favorite color.
|
|
3798
|
+
* @reject {TypeError} The user's favorite color is an invalid type.
|
|
3799
|
+
* @reject {MissingColorError} The user has not specified a favorite color.
|
|
3800
|
+
*/
|
|
3801
|
+
/**
|
|
3802
|
+
* Dynamically sets the title of the current page.
|
|
3803
|
+
*
|
|
3804
|
+
* @async
|
|
3805
|
+
* @function setNavigationBarTitle
|
|
3806
|
+
* @category Navigation Bar
|
|
3807
|
+
*
|
|
3808
|
+
* @example
|
|
3809
|
+
*
|
|
3810
|
+
* zmpApis.setNavigationBarTitle({
|
|
3811
|
+
* title: "Current Page"
|
|
3812
|
+
* }).then((res) => {
|
|
3813
|
+
* console.log("Success");
|
|
3814
|
+
* }).catch((error) => {
|
|
3815
|
+
* console.log("Fail");
|
|
3816
|
+
* });
|
|
3817
|
+
*
|
|
3818
|
+
* @param {Object} object
|
|
3819
|
+
* @param {string} object.title - The title of the page
|
|
3820
|
+
*
|
|
3821
|
+
* @return {Promise}
|
|
3822
|
+
*
|
|
3823
|
+
*/
|
|
3824
|
+
static setNavigationBarTitle(object) {
|
|
3825
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
3826
|
+
yield this.getJSBridge().callNative(ACTION.CHANGE_TITLE_HEADER, {
|
|
3827
|
+
title: object.title
|
|
3828
|
+
}, {
|
|
3829
|
+
haveTimeout: false
|
|
3830
|
+
});
|
|
3831
|
+
});
|
|
4155
3832
|
}
|
|
4156
3833
|
/**
|
|
4157
3834
|
* Sets the color of the navigation bar in the page.
|
|
@@ -4194,7 +3871,7 @@ class NavigationBar {
|
|
|
4194
3871
|
actionBarType = HIDE_ACTION_BAR;
|
|
4195
3872
|
}
|
|
4196
3873
|
this.setActionBarConfig((state) => (Object.assign(Object.assign({}, state), { actionbarType: actionBarType, dataConfig: Object.assign(Object.assign({}, state.dataConfig), dataConfig) })));
|
|
4197
|
-
yield this.callNative(ACTION.CHANGE_ACTIONBAR, Object.assign({}, this.getActionBarConfig()), {
|
|
3874
|
+
yield this.getJSBridge().callNative(ACTION.CHANGE_ACTIONBAR, Object.assign({}, this.getActionBarConfig()), {
|
|
4198
3875
|
haveTimeout: false
|
|
4199
3876
|
});
|
|
4200
3877
|
});
|
|
@@ -4244,14 +3921,14 @@ class NavigationBar {
|
|
|
4244
3921
|
: ACTION_LEFT_BUTTON_TYPE.HIDE_HOME;
|
|
4245
3922
|
}
|
|
4246
3923
|
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 }) })));
|
|
4247
|
-
yield this.callNative(ACTION.CHANGE_ACTIONBAR_LEFTBUTTON_TYPE, Object.assign({}, this.getActionBarConfig()), {
|
|
3924
|
+
yield this.getJSBridge().callNative(ACTION.CHANGE_ACTIONBAR_LEFTBUTTON_TYPE, Object.assign({}, this.getActionBarConfig()), {
|
|
4248
3925
|
haveTimeout: false
|
|
4249
3926
|
});
|
|
4250
3927
|
});
|
|
4251
3928
|
}
|
|
4252
3929
|
static setNavigationBar(data) {
|
|
4253
3930
|
return __awaiter(this, void 0, void 0, function* () {
|
|
4254
|
-
yield this.callNative(ACTION.CHANGE_ACTIONBAR, {
|
|
3931
|
+
yield this.getJSBridge().callNative(ACTION.CHANGE_ACTIONBAR, {
|
|
4255
3932
|
data
|
|
4256
3933
|
}, {
|
|
4257
3934
|
haveTimeout: false
|
|
@@ -4286,7 +3963,7 @@ class Background {
|
|
|
4286
3963
|
return __awaiter(this, void 0, void 0, function* () {
|
|
4287
3964
|
if (_.isString(object.backgroundColor) &&
|
|
4288
3965
|
object.backgroundColor.length > 0) {
|
|
4289
|
-
yield this.callNative(ACTION.CHANGE_ACTIONBAR, {
|
|
3966
|
+
yield this.getJSBridge().callNative(ACTION.CHANGE_ACTIONBAR, {
|
|
4290
3967
|
actionbarType: this.isShowNavBar ? 5 : 6,
|
|
4291
3968
|
dataConfig: {
|
|
4292
3969
|
backgroundColor: object.backgroundColor,
|
|
@@ -4398,7 +4075,7 @@ class Device {
|
|
|
4398
4075
|
*/
|
|
4399
4076
|
static setDeviceOrientation(object) {
|
|
4400
4077
|
return __awaiter(this, void 0, void 0, function* () {
|
|
4401
|
-
yield this.callNative(ACTION.CHANGE_AUTOROTATE, {
|
|
4078
|
+
yield this.getJSBridge().callNative(ACTION.CHANGE_AUTOROTATE, {
|
|
4402
4079
|
autoRotate: OrientationType[object.rotate]
|
|
4403
4080
|
});
|
|
4404
4081
|
});
|
|
@@ -4422,7 +4099,7 @@ class Device {
|
|
|
4422
4099
|
*/
|
|
4423
4100
|
static getNetworkType(object) {
|
|
4424
4101
|
return __awaiter(this, void 0, void 0, function* () {
|
|
4425
|
-
const resData = yield this.callNative(ACTION.WEBVIEW_NETWORKTYPE, {
|
|
4102
|
+
const resData = yield this.getJSBridge().callNative(ACTION.WEBVIEW_NETWORKTYPE, {
|
|
4426
4103
|
url: window.location.href,
|
|
4427
4104
|
featureId: ''
|
|
4428
4105
|
}).then((data) => {
|
|
@@ -4536,7 +4213,7 @@ class Device {
|
|
|
4536
4213
|
items: Array.isArray(object === null || object === void 0 ? void 0 : object.items) ? object === null || object === void 0 ? void 0 : object.items : []
|
|
4537
4214
|
}
|
|
4538
4215
|
};
|
|
4539
|
-
yield this.callNative(ACTION.SCAN_IBEACON, Object.assign({}, data));
|
|
4216
|
+
yield this.getJSBridge().callNative(ACTION.SCAN_IBEACON, Object.assign({}, data));
|
|
4540
4217
|
return true;
|
|
4541
4218
|
});
|
|
4542
4219
|
}
|
|
@@ -4555,7 +4232,7 @@ class Device {
|
|
|
4555
4232
|
const data = {
|
|
4556
4233
|
subaction: 2
|
|
4557
4234
|
};
|
|
4558
|
-
yield this.callNative(ACTION.SCAN_IBEACON, Object.assign({}, data));
|
|
4235
|
+
yield this.getJSBridge().callNative(ACTION.SCAN_IBEACON, Object.assign({}, data));
|
|
4559
4236
|
return true;
|
|
4560
4237
|
});
|
|
4561
4238
|
}
|
|
@@ -4576,7 +4253,7 @@ class Device {
|
|
|
4576
4253
|
const data = {
|
|
4577
4254
|
subaction: 1
|
|
4578
4255
|
};
|
|
4579
|
-
const resData = yield this.callNative(ACTION.SCAN_IBEACON, Object.assign({}, data), {
|
|
4256
|
+
const resData = yield this.getJSBridge().callNative(ACTION.SCAN_IBEACON, Object.assign({}, data), {
|
|
4580
4257
|
isMultiCallback: true
|
|
4581
4258
|
}).then((resData) => {
|
|
4582
4259
|
const res = {
|
|
@@ -4618,7 +4295,7 @@ class Device {
|
|
|
4618
4295
|
*/
|
|
4619
4296
|
static stopBluetoothDevicesDiscovery() {
|
|
4620
4297
|
return __awaiter(this, void 0, void 0, function* () {
|
|
4621
|
-
return this.callNative({
|
|
4298
|
+
return this.getJSBridge().callNative({
|
|
4622
4299
|
name: ''
|
|
4623
4300
|
}, {});
|
|
4624
4301
|
});
|
|
@@ -4645,7 +4322,7 @@ class Device {
|
|
|
4645
4322
|
*/
|
|
4646
4323
|
static startBluetoothDevicesDiscovery(object) {
|
|
4647
4324
|
return __awaiter(this, void 0, void 0, function* () {
|
|
4648
|
-
return this.callNative({
|
|
4325
|
+
return this.getJSBridge().callNative({
|
|
4649
4326
|
name: ''
|
|
4650
4327
|
}, Object.assign({}, object));
|
|
4651
4328
|
});
|
|
@@ -4669,7 +4346,7 @@ class Device {
|
|
|
4669
4346
|
*/
|
|
4670
4347
|
static openBluetoothAdapter() {
|
|
4671
4348
|
return __awaiter(this, void 0, void 0, function* () {
|
|
4672
|
-
return this.callNative({
|
|
4349
|
+
return this.getJSBridge().callNative({
|
|
4673
4350
|
name: ''
|
|
4674
4351
|
}, {});
|
|
4675
4352
|
});
|
|
@@ -4689,7 +4366,7 @@ class Device {
|
|
|
4689
4366
|
*/
|
|
4690
4367
|
static onBluetoothDeviceFound() {
|
|
4691
4368
|
return __awaiter(this, void 0, void 0, function* () {
|
|
4692
|
-
return this.callNative({
|
|
4369
|
+
return this.getJSBridge().callNative({
|
|
4693
4370
|
name: ''
|
|
4694
4371
|
}, {});
|
|
4695
4372
|
});
|
|
@@ -4737,7 +4414,7 @@ class Device {
|
|
|
4737
4414
|
const data = {
|
|
4738
4415
|
services: object.services || []
|
|
4739
4416
|
};
|
|
4740
|
-
return this.callNative({
|
|
4417
|
+
return this.getJSBridge().callNative({
|
|
4741
4418
|
name: ''
|
|
4742
4419
|
}, data);
|
|
4743
4420
|
});
|
|
@@ -4758,7 +4435,7 @@ class Device {
|
|
|
4758
4435
|
*/
|
|
4759
4436
|
static getBluetoothDevices() {
|
|
4760
4437
|
return __awaiter(this, void 0, void 0, function* () {
|
|
4761
|
-
return this.callNative({
|
|
4438
|
+
return this.getJSBridge().callNative({
|
|
4762
4439
|
name: ''
|
|
4763
4440
|
}, {});
|
|
4764
4441
|
});
|
|
@@ -4779,7 +4456,7 @@ class Device {
|
|
|
4779
4456
|
*/
|
|
4780
4457
|
static getBluetoothAdapterState() {
|
|
4781
4458
|
return __awaiter(this, void 0, void 0, function* () {
|
|
4782
|
-
return this.callNative({
|
|
4459
|
+
return this.getJSBridge().callNative({
|
|
4783
4460
|
name: ''
|
|
4784
4461
|
}, {});
|
|
4785
4462
|
});
|
|
@@ -4800,7 +4477,7 @@ class Device {
|
|
|
4800
4477
|
*/
|
|
4801
4478
|
static closeBluetoothAdapter() {
|
|
4802
4479
|
return __awaiter(this, void 0, void 0, function* () {
|
|
4803
|
-
return this.callNative({
|
|
4480
|
+
return this.getJSBridge().callNative({
|
|
4804
4481
|
name: ''
|
|
4805
4482
|
}, {});
|
|
4806
4483
|
});
|
|
@@ -4814,7 +4491,7 @@ class Device {
|
|
|
4814
4491
|
*/
|
|
4815
4492
|
static scanQRCode(object) {
|
|
4816
4493
|
return __awaiter(this, void 0, void 0, function* () {
|
|
4817
|
-
return yield this.callNative(ACTION.OPEN_QR, {
|
|
4494
|
+
return yield this.getJSBridge().callNative(ACTION.OPEN_QR, {
|
|
4818
4495
|
skipOpenLink: true
|
|
4819
4496
|
});
|
|
4820
4497
|
});
|
|
@@ -4828,308 +4505,770 @@ class Device {
|
|
|
4828
4505
|
*/
|
|
4829
4506
|
static showToast(object) {
|
|
4830
4507
|
return __awaiter(this, void 0, void 0, function* () {
|
|
4831
|
-
yield this.callNative(ACTION.SHOW_TOAST, {
|
|
4832
|
-
toast: object.message
|
|
4508
|
+
yield this.getJSBridge().callNative(ACTION.SHOW_TOAST, {
|
|
4509
|
+
toast: object.message
|
|
4510
|
+
});
|
|
4511
|
+
});
|
|
4512
|
+
}
|
|
4513
|
+
/**
|
|
4514
|
+
* Ẩn keyboard
|
|
4515
|
+
* @async
|
|
4516
|
+
* @function hideKeyboard
|
|
4517
|
+
* @category Device
|
|
4518
|
+
*
|
|
4519
|
+
*/
|
|
4520
|
+
static hideKeyboard(object) {
|
|
4521
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
4522
|
+
yield this.getJSBridge().callNative(ACTION.HIDE_KEYBOARD, {});
|
|
4523
|
+
});
|
|
4524
|
+
}
|
|
4525
|
+
/**
|
|
4526
|
+
* Open phone
|
|
4527
|
+
* @async
|
|
4528
|
+
* @function openPhone
|
|
4529
|
+
* @category Device
|
|
4530
|
+
*
|
|
4531
|
+
*/
|
|
4532
|
+
static openPhone(object) {
|
|
4533
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
4534
|
+
yield this.getJSBridge().callNative(ACTION.OPEN_PHONE, {
|
|
4535
|
+
phoneNum: object.phoneNumber,
|
|
4536
|
+
phoneCode: object.phoneNumber
|
|
4537
|
+
});
|
|
4538
|
+
});
|
|
4539
|
+
}
|
|
4540
|
+
/**
|
|
4541
|
+
* Open SMS
|
|
4542
|
+
* @async
|
|
4543
|
+
* @function openSMS
|
|
4544
|
+
* @category Device
|
|
4545
|
+
*
|
|
4546
|
+
*/
|
|
4547
|
+
static openSMS(object) {
|
|
4548
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
4549
|
+
yield this.getJSBridge().callNative(ACTION.OPEN_SMS, {
|
|
4550
|
+
content: object.content,
|
|
4551
|
+
phoneCode: object.phoneNumber
|
|
4552
|
+
});
|
|
4553
|
+
});
|
|
4554
|
+
}
|
|
4555
|
+
/**
|
|
4556
|
+
* Keep screen.
|
|
4557
|
+
* @async
|
|
4558
|
+
* @function keepScreen
|
|
4559
|
+
* @category Device
|
|
4560
|
+
*
|
|
4561
|
+
*/
|
|
4562
|
+
static keepScreen(object) {
|
|
4563
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
4564
|
+
return yield this.getJSBridge().callNative(ACTION.KEEP_SCREEN, {
|
|
4565
|
+
data: {
|
|
4566
|
+
keep_screen_on: object.keepScreenOn ? 1 : 0
|
|
4567
|
+
}
|
|
4568
|
+
});
|
|
4569
|
+
});
|
|
4570
|
+
}
|
|
4571
|
+
/**
|
|
4572
|
+
* Xác thực bằng sinh trắc học
|
|
4573
|
+
* @async
|
|
4574
|
+
* @function openBioAuthentication
|
|
4575
|
+
* @category Authentication
|
|
4576
|
+
*
|
|
4577
|
+
*/
|
|
4578
|
+
static openBioAuthentication(object) {
|
|
4579
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
4580
|
+
return yield this.getJSBridge().callNative(ACTION.PROMPT_AUTHENTICATION, {
|
|
4581
|
+
secret_data: object.secretData,
|
|
4582
|
+
app_id: this.getZAppId(),
|
|
4583
|
+
ui: {
|
|
4584
|
+
title: object.ui.title,
|
|
4585
|
+
sub_title: object.ui.subTitle,
|
|
4586
|
+
negative_text: object.ui.negativeButtonText
|
|
4587
|
+
},
|
|
4588
|
+
require_fingerprint: object.requireFingerprint ? 1 : 0
|
|
4589
|
+
}).then((data) => {
|
|
4590
|
+
var _a, _b, _c, _d;
|
|
4591
|
+
return {
|
|
4592
|
+
code: data === null || data === void 0 ? void 0 : data.error_code,
|
|
4593
|
+
message: data === null || data === void 0 ? void 0 : data.error_message,
|
|
4594
|
+
data: {
|
|
4595
|
+
domain: (_a = data === null || data === void 0 ? void 0 : data.data) === null || _a === void 0 ? void 0 : _a.domain,
|
|
4596
|
+
code: (_b = data === null || data === void 0 ? void 0 : data.data) === null || _b === void 0 ? void 0 : _b.error_code,
|
|
4597
|
+
message: (_c = data === null || data === void 0 ? void 0 : data.data) === null || _c === void 0 ? void 0 : _c.error_message,
|
|
4598
|
+
payToken: (_d = data === null || data === void 0 ? void 0 : data.data) === null || _d === void 0 ? void 0 : _d.pay_token
|
|
4599
|
+
}
|
|
4600
|
+
};
|
|
4601
|
+
});
|
|
4602
|
+
});
|
|
4603
|
+
}
|
|
4604
|
+
/**
|
|
4605
|
+
* 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...)
|
|
4606
|
+
* @async
|
|
4607
|
+
* @function checkStateBioAuthentication
|
|
4608
|
+
* @category Authentication
|
|
4609
|
+
*
|
|
4610
|
+
* @example
|
|
4611
|
+
* api.checkStateAuthen({
|
|
4612
|
+
* success: (res) => {},
|
|
4613
|
+
* fail: (err) => {}
|
|
4614
|
+
* })
|
|
4615
|
+
* @param {InputDataType.CallbackType} object
|
|
4616
|
+
*/
|
|
4617
|
+
static checkStateBioAuthentication(object) {
|
|
4618
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
4619
|
+
return yield this.getJSBridge().callNative(ACTION.PROMPT_AUTHENTICATION_CHECK_STATE, {}).then((data) => {
|
|
4620
|
+
return {
|
|
4621
|
+
bioState: data === null || data === void 0 ? void 0 : data.bio_state
|
|
4622
|
+
};
|
|
4623
|
+
});
|
|
4624
|
+
});
|
|
4625
|
+
}
|
|
4626
|
+
/**
|
|
4627
|
+
* Vibrate.
|
|
4628
|
+
* @async
|
|
4629
|
+
* @function vibrate
|
|
4630
|
+
* @category Device
|
|
4631
|
+
*
|
|
4632
|
+
*/
|
|
4633
|
+
static vibrate(object) {
|
|
4634
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
4635
|
+
return yield this.getJSBridge().callNative(ACTION.INTERACTIVE_VIBRATION, {
|
|
4636
|
+
type: VibrateType[object.type],
|
|
4637
|
+
vibrate_time: object.milliseconds
|
|
4638
|
+
});
|
|
4639
|
+
});
|
|
4640
|
+
}
|
|
4641
|
+
/**
|
|
4642
|
+
* Connect Wifi.
|
|
4643
|
+
* @async
|
|
4644
|
+
* @function connectWifi
|
|
4645
|
+
* @category Device
|
|
4646
|
+
*
|
|
4647
|
+
*/
|
|
4648
|
+
static connectWifi(object) {
|
|
4649
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
4650
|
+
let securityType = 'open';
|
|
4651
|
+
if (_.isString(object.password) && object.password.length > 0) {
|
|
4652
|
+
securityType = 'wpa_wpa2';
|
|
4653
|
+
}
|
|
4654
|
+
return yield this.getJSBridge().callNative(ACTION.MP_JOIN_WIFI, {
|
|
4655
|
+
ssid: object.SSID,
|
|
4656
|
+
securityType: securityType,
|
|
4657
|
+
password: object.password,
|
|
4658
|
+
hiddenSsid: object.hiddenSSID
|
|
4659
|
+
});
|
|
4660
|
+
});
|
|
4661
|
+
}
|
|
4662
|
+
/**
|
|
4663
|
+
* Open App Store.
|
|
4664
|
+
* @async
|
|
4665
|
+
* @function openAppStore
|
|
4666
|
+
* @category Device
|
|
4667
|
+
*
|
|
4668
|
+
*/
|
|
4669
|
+
static openAppStore(object) {
|
|
4670
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
4671
|
+
return yield this.getJSBridge().callNative(ACTION.OPEN_APPSTORE, object);
|
|
4672
|
+
});
|
|
4673
|
+
}
|
|
4674
|
+
}
|
|
4675
|
+
|
|
4676
|
+
var _LocalResourceStorage_storage, _LocalResourceStorage_prefix, _LocalResourceStorage_resourceInfo;
|
|
4677
|
+
class LocalResourceStorage {
|
|
4678
|
+
constructor(prefix) {
|
|
4679
|
+
_LocalResourceStorage_storage.set(this, localStorage);
|
|
4680
|
+
_LocalResourceStorage_prefix.set(this, void 0);
|
|
4681
|
+
_LocalResourceStorage_resourceInfo.set(this, void 0);
|
|
4682
|
+
checkPlatform();
|
|
4683
|
+
// if (platform.isMobile && platform.isZalo) {
|
|
4684
|
+
// Object.defineProperty(window, 'localStorage', {
|
|
4685
|
+
// value: null,
|
|
4686
|
+
// configurable: true,
|
|
4687
|
+
// enumerable: true,
|
|
4688
|
+
// writable: false
|
|
4689
|
+
// });
|
|
4690
|
+
// }
|
|
4691
|
+
__classPrivateFieldSet(this, _LocalResourceStorage_resourceInfo, {
|
|
4692
|
+
keys: new Set(),
|
|
4693
|
+
currentSize: 0,
|
|
4694
|
+
limitSize: STORAGE_LIMIT
|
|
4695
|
+
}, "f");
|
|
4696
|
+
__classPrivateFieldSet(this, _LocalResourceStorage_prefix, prefix, "f");
|
|
4697
|
+
this.findAllCurrentDataByApp(prefix);
|
|
4698
|
+
}
|
|
4699
|
+
findAllCurrentDataByApp(prefix) {
|
|
4700
|
+
try {
|
|
4701
|
+
let _x;
|
|
4702
|
+
for (_x in __classPrivateFieldGet(this, _LocalResourceStorage_storage, "f")) {
|
|
4703
|
+
if (prefix) {
|
|
4704
|
+
const _prefix = _x.split('_')[0];
|
|
4705
|
+
if (_prefix !== prefix) {
|
|
4706
|
+
continue;
|
|
4707
|
+
}
|
|
4708
|
+
}
|
|
4709
|
+
__classPrivateFieldGet(this, _LocalResourceStorage_resourceInfo, "f").keys.add(_x);
|
|
4710
|
+
}
|
|
4711
|
+
}
|
|
4712
|
+
catch (error) {
|
|
4713
|
+
logger.error(error, 'LocalResourceStorage > findAllCurrentDataByApp');
|
|
4714
|
+
}
|
|
4715
|
+
}
|
|
4716
|
+
get(keys) {
|
|
4717
|
+
let res = new Map();
|
|
4718
|
+
keys.forEach((key) => {
|
|
4719
|
+
res.set(key, this.getSync(key));
|
|
4720
|
+
});
|
|
4721
|
+
return Promise.resolve(res);
|
|
4722
|
+
}
|
|
4723
|
+
getSync(key) {
|
|
4724
|
+
if (__classPrivateFieldGet(this, _LocalResourceStorage_prefix, "f")) {
|
|
4725
|
+
key = `${__classPrivateFieldGet(this, _LocalResourceStorage_prefix, "f")}_${key}`;
|
|
4726
|
+
}
|
|
4727
|
+
if (!__classPrivateFieldGet(this, _LocalResourceStorage_resourceInfo, "f").keys.has(key))
|
|
4728
|
+
return null;
|
|
4729
|
+
return __classPrivateFieldGet(this, _LocalResourceStorage_storage, "f").getItem(key);
|
|
4730
|
+
}
|
|
4731
|
+
set(data) {
|
|
4732
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
4733
|
+
Object.entries(data).forEach(([key, value]) => {
|
|
4734
|
+
this.setSync(key, value.replace(/\\"/g, '"'));
|
|
4833
4735
|
});
|
|
4736
|
+
return Promise.resolve({ errorKeys: [] });
|
|
4834
4737
|
});
|
|
4835
4738
|
}
|
|
4836
|
-
|
|
4837
|
-
|
|
4838
|
-
|
|
4839
|
-
|
|
4840
|
-
|
|
4841
|
-
|
|
4842
|
-
|
|
4843
|
-
|
|
4739
|
+
setSync(key, value) {
|
|
4740
|
+
if (__classPrivateFieldGet(this, _LocalResourceStorage_prefix, "f")) {
|
|
4741
|
+
key = `${__classPrivateFieldGet(this, _LocalResourceStorage_prefix, "f")}_${key}`;
|
|
4742
|
+
}
|
|
4743
|
+
__classPrivateFieldGet(this, _LocalResourceStorage_storage, "f").setItem(key, value);
|
|
4744
|
+
__classPrivateFieldGet(this, _LocalResourceStorage_resourceInfo, "f").keys.add(key);
|
|
4745
|
+
}
|
|
4746
|
+
getInfo() {
|
|
4844
4747
|
return __awaiter(this, void 0, void 0, function* () {
|
|
4845
|
-
|
|
4748
|
+
return Promise.resolve(this.getInfoSync());
|
|
4846
4749
|
});
|
|
4847
4750
|
}
|
|
4848
|
-
|
|
4849
|
-
|
|
4850
|
-
|
|
4851
|
-
|
|
4852
|
-
|
|
4853
|
-
|
|
4854
|
-
|
|
4855
|
-
|
|
4751
|
+
getInfoSync() {
|
|
4752
|
+
const currentSize = calcLocalStorageSize(__classPrivateFieldGet(this, _LocalResourceStorage_storage, "f"), __classPrivateFieldGet(this, _LocalResourceStorage_prefix, "f"));
|
|
4753
|
+
return {
|
|
4754
|
+
currentSize: _.isNumber(currentSize)
|
|
4755
|
+
? Number((currentSize / 1024).toFixed(2))
|
|
4756
|
+
: 0,
|
|
4757
|
+
limitSize: Number((STORAGE_LIMIT / 1024).toFixed(2))
|
|
4758
|
+
};
|
|
4759
|
+
}
|
|
4760
|
+
remove(keys) {
|
|
4856
4761
|
return __awaiter(this, void 0, void 0, function* () {
|
|
4857
|
-
|
|
4858
|
-
|
|
4859
|
-
phoneCode: object.phoneNumber
|
|
4762
|
+
keys.forEach((key) => {
|
|
4763
|
+
this.removeSync(key);
|
|
4860
4764
|
});
|
|
4765
|
+
return Promise.resolve({ errorKeys: [] });
|
|
4861
4766
|
});
|
|
4862
4767
|
}
|
|
4863
|
-
|
|
4864
|
-
|
|
4865
|
-
|
|
4866
|
-
|
|
4867
|
-
|
|
4868
|
-
|
|
4869
|
-
|
|
4870
|
-
|
|
4768
|
+
removeSync(key) {
|
|
4769
|
+
if (__classPrivateFieldGet(this, _LocalResourceStorage_prefix, "f")) {
|
|
4770
|
+
key = `${__classPrivateFieldGet(this, _LocalResourceStorage_prefix, "f")}_${key}`;
|
|
4771
|
+
}
|
|
4772
|
+
if (__classPrivateFieldGet(this, _LocalResourceStorage_resourceInfo, "f").keys.has(key)) {
|
|
4773
|
+
__classPrivateFieldGet(this, _LocalResourceStorage_storage, "f").removeItem(key);
|
|
4774
|
+
__classPrivateFieldGet(this, _LocalResourceStorage_resourceInfo, "f").keys.delete(key);
|
|
4775
|
+
}
|
|
4776
|
+
}
|
|
4777
|
+
clear() {
|
|
4871
4778
|
return __awaiter(this, void 0, void 0, function* () {
|
|
4872
|
-
|
|
4873
|
-
content: object.content,
|
|
4874
|
-
phoneCode: object.phoneNumber
|
|
4875
|
-
});
|
|
4779
|
+
return Promise.resolve(this.clearSync());
|
|
4876
4780
|
});
|
|
4877
4781
|
}
|
|
4878
|
-
|
|
4879
|
-
|
|
4880
|
-
|
|
4881
|
-
|
|
4882
|
-
|
|
4883
|
-
|
|
4884
|
-
|
|
4885
|
-
static keepScreen(object) {
|
|
4886
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
4887
|
-
return yield this.callNative(ACTION.KEEP_SCREEN, {
|
|
4888
|
-
data: {
|
|
4889
|
-
keep_screen_on: object.keepScreenOn ? 1 : 0
|
|
4890
|
-
}
|
|
4891
|
-
});
|
|
4782
|
+
clearSync() {
|
|
4783
|
+
__classPrivateFieldGet(this, _LocalResourceStorage_resourceInfo, "f").keys.forEach((key) => {
|
|
4784
|
+
if (__classPrivateFieldGet(this, _LocalResourceStorage_prefix, "f") && key.indexOf(__classPrivateFieldGet(this, _LocalResourceStorage_prefix, "f")) < 0) {
|
|
4785
|
+
return;
|
|
4786
|
+
}
|
|
4787
|
+
__classPrivateFieldGet(this, _LocalResourceStorage_storage, "f").removeItem(key);
|
|
4788
|
+
__classPrivateFieldGet(this, _LocalResourceStorage_resourceInfo, "f").keys.delete(key);
|
|
4892
4789
|
});
|
|
4893
4790
|
}
|
|
4894
|
-
|
|
4895
|
-
|
|
4896
|
-
|
|
4897
|
-
|
|
4898
|
-
|
|
4899
|
-
|
|
4900
|
-
|
|
4901
|
-
|
|
4902
|
-
return
|
|
4903
|
-
|
|
4904
|
-
|
|
4905
|
-
|
|
4906
|
-
|
|
4907
|
-
|
|
4908
|
-
|
|
4909
|
-
|
|
4910
|
-
|
|
4911
|
-
|
|
4912
|
-
|
|
4913
|
-
|
|
4914
|
-
|
|
4915
|
-
|
|
4916
|
-
|
|
4917
|
-
|
|
4918
|
-
|
|
4919
|
-
|
|
4920
|
-
|
|
4921
|
-
|
|
4922
|
-
|
|
4923
|
-
|
|
4791
|
+
}
|
|
4792
|
+
_LocalResourceStorage_storage = new WeakMap(), _LocalResourceStorage_prefix = new WeakMap(), _LocalResourceStorage_resourceInfo = new WeakMap();
|
|
4793
|
+
|
|
4794
|
+
var wrappers = {};
|
|
4795
|
+
var WrapperFn = function wrapFunction(fn, type, source) {
|
|
4796
|
+
var t = type || 'default';
|
|
4797
|
+
return function () {
|
|
4798
|
+
var callee = t in wrappers ? wrappers[t](fn, source) : fn;
|
|
4799
|
+
return callee.apply(this, arguments);
|
|
4800
|
+
};
|
|
4801
|
+
};
|
|
4802
|
+
WrapperFn.setWrapper = function (fn) {
|
|
4803
|
+
var type = arguments.length <= 1 || arguments[1] === undefined
|
|
4804
|
+
? 'default'
|
|
4805
|
+
: arguments[1];
|
|
4806
|
+
wrappers[type] = fn;
|
|
4807
|
+
};
|
|
4808
|
+
var ERROR = {
|
|
4809
|
+
error: {
|
|
4810
|
+
code: 1,
|
|
4811
|
+
error_subcode: 1357046,
|
|
4812
|
+
message: 'Received Invalid JSON reply.',
|
|
4813
|
+
type: 'http'
|
|
4814
|
+
}
|
|
4815
|
+
};
|
|
4816
|
+
function safelyParseResponse(rawResponse) {
|
|
4817
|
+
try {
|
|
4818
|
+
return rawResponse === null ? ERROR : JSON.parse(rawResponse);
|
|
4819
|
+
}
|
|
4820
|
+
catch (ex) {
|
|
4821
|
+
return ERROR;
|
|
4822
|
+
}
|
|
4823
|
+
}
|
|
4824
|
+
function createCORSRequest(method, url) {
|
|
4825
|
+
if (!self.XMLHttpRequest) {
|
|
4826
|
+
return null;
|
|
4827
|
+
}
|
|
4828
|
+
var xhr = new XMLHttpRequest();
|
|
4829
|
+
var noop = function noop() { };
|
|
4830
|
+
if ('withCredentials' in xhr) {
|
|
4831
|
+
xhr.open(method, url, true);
|
|
4832
|
+
xhr.setRequestHeader('Content-type', 'application/x-www-form-urlencoded');
|
|
4833
|
+
}
|
|
4834
|
+
else {
|
|
4835
|
+
return null;
|
|
4836
|
+
}
|
|
4837
|
+
var wrapper = {
|
|
4838
|
+
send: function send(data) {
|
|
4839
|
+
xhr.send(data);
|
|
4840
|
+
}
|
|
4841
|
+
};
|
|
4842
|
+
var onload = WrapperFn(function () {
|
|
4843
|
+
onload = noop;
|
|
4844
|
+
if ('onload' in wrapper) {
|
|
4845
|
+
wrapper.onload(xhr);
|
|
4846
|
+
}
|
|
4847
|
+
}, 'entry', 'XMLHttpRequest:load');
|
|
4848
|
+
var onerror = WrapperFn(function () {
|
|
4849
|
+
onerror = noop;
|
|
4850
|
+
if ('onerror' in wrapper) {
|
|
4851
|
+
wrapper.onerror(xhr);
|
|
4852
|
+
}
|
|
4853
|
+
}, 'entry', 'XMLHttpRequest:error');
|
|
4854
|
+
xhr.onload = function () {
|
|
4855
|
+
onload();
|
|
4856
|
+
};
|
|
4857
|
+
xhr.onerror = function () {
|
|
4858
|
+
onerror();
|
|
4859
|
+
};
|
|
4860
|
+
xhr.onreadystatechange = function () {
|
|
4861
|
+
if (xhr.readyState == 4) {
|
|
4862
|
+
if (xhr.status == 200) {
|
|
4863
|
+
onload();
|
|
4864
|
+
}
|
|
4865
|
+
else {
|
|
4866
|
+
onerror();
|
|
4867
|
+
}
|
|
4868
|
+
}
|
|
4869
|
+
};
|
|
4870
|
+
return wrapper;
|
|
4871
|
+
}
|
|
4872
|
+
function execute(url, method, params, cb) {
|
|
4873
|
+
params.suppress_http_code = 1;
|
|
4874
|
+
var data = QueryString.encode(params);
|
|
4875
|
+
if (method != 'post') {
|
|
4876
|
+
url = QueryString.appendToUrl(url, data);
|
|
4877
|
+
data = '';
|
|
4878
|
+
}
|
|
4879
|
+
var request = createCORSRequest(method, url);
|
|
4880
|
+
if (!request) {
|
|
4881
|
+
return false;
|
|
4882
|
+
}
|
|
4883
|
+
request.onload = function (xhr) {
|
|
4884
|
+
cb(safelyParseResponse(xhr.responseText));
|
|
4885
|
+
};
|
|
4886
|
+
request.onerror = function (xhr) {
|
|
4887
|
+
if (xhr.responseText) {
|
|
4888
|
+
cb(safelyParseResponse(xhr.responseText));
|
|
4889
|
+
}
|
|
4890
|
+
else {
|
|
4891
|
+
cb({
|
|
4892
|
+
error: {
|
|
4893
|
+
code: 1,
|
|
4894
|
+
error_subcode: 1357045,
|
|
4895
|
+
message: 'unknown error (empty response)',
|
|
4896
|
+
status: xhr.status,
|
|
4897
|
+
type: 'http'
|
|
4898
|
+
}
|
|
4899
|
+
});
|
|
4900
|
+
}
|
|
4901
|
+
};
|
|
4902
|
+
request.send(data);
|
|
4903
|
+
return true;
|
|
4904
|
+
}
|
|
4905
|
+
var CORSRequest = {
|
|
4906
|
+
execute: execute
|
|
4907
|
+
};
|
|
4908
|
+
|
|
4909
|
+
var _ZaloJSBridge_instances, _ZaloJSBridge_cookies, _ZaloJSBridge_actionRuntimeInfo, _ZaloJSBridge_jsCall;
|
|
4910
|
+
class ZaloJSBridge extends eventemitter3 {
|
|
4911
|
+
constructor() {
|
|
4912
|
+
super();
|
|
4913
|
+
_ZaloJSBridge_instances.add(this);
|
|
4914
|
+
this.debug = Debug('zmp:ZaloJSBridge');
|
|
4915
|
+
this.events = ZMPEEmitter.getInstance();
|
|
4916
|
+
this._accessTk = getToken('zacc_session') || 'DEFAULT_ACCESS_TOKEN';
|
|
4917
|
+
this._jsAccessTk = getToken('zlink3rd') || 'DEFAULT_JS_TOKEN';
|
|
4918
|
+
this.results = [];
|
|
4919
|
+
this._userAgent = getUserAgent();
|
|
4920
|
+
this._device = checkPlatform();
|
|
4921
|
+
this.isJumped = false;
|
|
4922
|
+
_ZaloJSBridge_cookies.set(this, null);
|
|
4923
|
+
_ZaloJSBridge_actionRuntimeInfo.set(this, void 0);
|
|
4924
|
+
this.jump = () => {
|
|
4925
|
+
return new Promise((resolve, reject) => {
|
|
4926
|
+
if (!_.isUndefined(__classPrivateFieldGet(this, _ZaloJSBridge_cookies, "f")) && !_.isNull(__classPrivateFieldGet(this, _ZaloJSBridge_cookies, "f"))) {
|
|
4927
|
+
resolve(__classPrivateFieldGet(this, _ZaloJSBridge_cookies, "f"));
|
|
4928
|
+
}
|
|
4929
|
+
else {
|
|
4930
|
+
this.callNative(ACTION.JUMP_LOGIN, {})
|
|
4931
|
+
.then((data) => {
|
|
4932
|
+
const cookies = (data && data.cookiesOAuthLogins) || [];
|
|
4933
|
+
const actionPermission = (data && data.actionPermission) || [];
|
|
4934
|
+
Object.entries(actionPermission).forEach((item) => {
|
|
4935
|
+
const key = item[0];
|
|
4936
|
+
const value = item[1] || { perm: 0, decode: 0 };
|
|
4937
|
+
if (!__classPrivateFieldGet(this, _ZaloJSBridge_actionRuntimeInfo, "f")[key]) {
|
|
4938
|
+
__classPrivateFieldGet(this, _ZaloJSBridge_actionRuntimeInfo, "f")[key] = {
|
|
4939
|
+
permission: false,
|
|
4940
|
+
support: false
|
|
4941
|
+
};
|
|
4942
|
+
}
|
|
4943
|
+
__classPrivateFieldGet(this, _ZaloJSBridge_actionRuntimeInfo, "f")[key].permission = value.perm === 1;
|
|
4944
|
+
});
|
|
4945
|
+
const jsToken = cookies.find((cookie) => cookie.name === COOKIE_NAME.JS_TOKEN);
|
|
4946
|
+
if (jsToken) {
|
|
4947
|
+
this.jsAccessTk = jsToken.value;
|
|
4948
|
+
window.ZJSBridge.setJSToken &&
|
|
4949
|
+
window.ZJSBridge.setJSToken(jsToken.value);
|
|
4950
|
+
}
|
|
4951
|
+
__classPrivateFieldSet(this, _ZaloJSBridge_cookies, cookies, "f");
|
|
4952
|
+
this.isJumped = true;
|
|
4953
|
+
resolve(cookies);
|
|
4954
|
+
})
|
|
4955
|
+
.catch((error) => {
|
|
4956
|
+
this.isJumped = false;
|
|
4957
|
+
reject(error);
|
|
4958
|
+
});
|
|
4959
|
+
}
|
|
4924
4960
|
});
|
|
4961
|
+
};
|
|
4962
|
+
this._jsCallFuncCallbacks = {};
|
|
4963
|
+
__classPrivateFieldSet(this, _ZaloJSBridge_actionRuntimeInfo, {}, "f");
|
|
4964
|
+
this.events.on(Events.AppPaused, () => {
|
|
4965
|
+
if (this.results.length > 0) {
|
|
4966
|
+
let array = this.results;
|
|
4967
|
+
this.results = [];
|
|
4968
|
+
try {
|
|
4969
|
+
this.sendLogData(array);
|
|
4970
|
+
}
|
|
4971
|
+
catch (error) { }
|
|
4972
|
+
}
|
|
4925
4973
|
});
|
|
4974
|
+
if (this.sendLogTimer) {
|
|
4975
|
+
clearInterval(this.sendLogTimer);
|
|
4976
|
+
}
|
|
4977
|
+
else {
|
|
4978
|
+
this.sendLogTimer = setInterval(() => {
|
|
4979
|
+
if (this.results.length > 0) {
|
|
4980
|
+
let array = this.results;
|
|
4981
|
+
this.results = [];
|
|
4982
|
+
try {
|
|
4983
|
+
this.sendLogData(array);
|
|
4984
|
+
}
|
|
4985
|
+
catch (error) { }
|
|
4986
|
+
}
|
|
4987
|
+
}, 5000);
|
|
4988
|
+
}
|
|
4926
4989
|
}
|
|
4927
|
-
|
|
4928
|
-
|
|
4929
|
-
|
|
4930
|
-
|
|
4931
|
-
|
|
4932
|
-
|
|
4933
|
-
|
|
4934
|
-
|
|
4935
|
-
|
|
4936
|
-
|
|
4937
|
-
|
|
4938
|
-
|
|
4939
|
-
|
|
4940
|
-
|
|
4941
|
-
|
|
4942
|
-
return yield this.callNative(ACTION.PROMPT_AUTHENTICATION_CHECK_STATE, {}).then((data) => {
|
|
4990
|
+
static getInstance() {
|
|
4991
|
+
if (!ZaloJSBridge.instance) {
|
|
4992
|
+
ZaloJSBridge.instance = new ZaloJSBridge();
|
|
4993
|
+
}
|
|
4994
|
+
return ZaloJSBridge.instance;
|
|
4995
|
+
}
|
|
4996
|
+
set accessTk(value) {
|
|
4997
|
+
this._accessTk = value;
|
|
4998
|
+
}
|
|
4999
|
+
set jsAccessTk(value) {
|
|
5000
|
+
this._jsAccessTk = value;
|
|
5001
|
+
}
|
|
5002
|
+
sendLogData(data) {
|
|
5003
|
+
try {
|
|
5004
|
+
const logData = data.map((item) => {
|
|
4943
5005
|
return {
|
|
4944
|
-
|
|
5006
|
+
action: item.action,
|
|
5007
|
+
error: item.error
|
|
4945
5008
|
};
|
|
4946
5009
|
});
|
|
4947
|
-
|
|
5010
|
+
CORSRequest.execute(APIS.SEND_ACTION_LOG, 'post', {
|
|
5011
|
+
appId: window.APP_ID,
|
|
5012
|
+
data: JSON.stringify(logData)
|
|
5013
|
+
}, (response) => { });
|
|
5014
|
+
window.zmpSentry &&
|
|
5015
|
+
window.zmpSentry.captureMessage('Result from native', {
|
|
5016
|
+
extra: {
|
|
5017
|
+
data: data
|
|
5018
|
+
}
|
|
5019
|
+
});
|
|
5020
|
+
}
|
|
5021
|
+
catch (error) { }
|
|
4948
5022
|
}
|
|
4949
|
-
|
|
4950
|
-
|
|
4951
|
-
|
|
4952
|
-
|
|
4953
|
-
|
|
4954
|
-
|
|
4955
|
-
|
|
4956
|
-
|
|
4957
|
-
|
|
4958
|
-
|
|
4959
|
-
|
|
4960
|
-
|
|
5023
|
+
onJSCall(key, data) {
|
|
5024
|
+
try {
|
|
5025
|
+
this.debug('onJSCall', key, data);
|
|
5026
|
+
const parsedData = parseJSON(data);
|
|
5027
|
+
if (this._jsCallFuncCallbacks[key]) {
|
|
5028
|
+
const callback = this._jsCallFuncCallbacks[key].callback;
|
|
5029
|
+
const timeout = this._jsCallFuncCallbacks[key].timeout;
|
|
5030
|
+
if (!!callback) {
|
|
5031
|
+
try {
|
|
5032
|
+
callback.call(this, parsedData);
|
|
5033
|
+
}
|
|
5034
|
+
catch (error) {
|
|
5035
|
+
console.error('Call callback error', error);
|
|
5036
|
+
}
|
|
5037
|
+
!!timeout && clearTimeout(timeout);
|
|
5038
|
+
this._jsCallFuncCallbacks[key] = null;
|
|
5039
|
+
delete this._jsCallFuncCallbacks[key];
|
|
5040
|
+
}
|
|
5041
|
+
}
|
|
5042
|
+
this.results.push({
|
|
5043
|
+
action: parsedData.action,
|
|
5044
|
+
error: parsedData.error_code,
|
|
5045
|
+
message: parsedData.error_message
|
|
4961
5046
|
});
|
|
4962
|
-
}
|
|
5047
|
+
}
|
|
5048
|
+
catch (e) {
|
|
5049
|
+
console.log('onJSCall', 'error', e);
|
|
5050
|
+
}
|
|
4963
5051
|
}
|
|
4964
|
-
|
|
4965
|
-
|
|
4966
|
-
|
|
4967
|
-
|
|
4968
|
-
|
|
4969
|
-
|
|
4970
|
-
|
|
4971
|
-
|
|
4972
|
-
|
|
4973
|
-
|
|
4974
|
-
|
|
4975
|
-
|
|
5052
|
+
onMultiJSCall(key, data) {
|
|
5053
|
+
try {
|
|
5054
|
+
this.debug('onMultiJSCall', key, data);
|
|
5055
|
+
const parsedData = parseJSON(data);
|
|
5056
|
+
if (this._jsCallFuncCallbacks[key]) {
|
|
5057
|
+
const callback = this._jsCallFuncCallbacks[key].callback;
|
|
5058
|
+
const timeout = this._jsCallFuncCallbacks[key].timeout;
|
|
5059
|
+
if (!!callback) {
|
|
5060
|
+
try {
|
|
5061
|
+
callback.call(this, parsedData);
|
|
5062
|
+
}
|
|
5063
|
+
catch (error) {
|
|
5064
|
+
console.error('Call callback error', error);
|
|
5065
|
+
}
|
|
5066
|
+
!!timeout && clearTimeout(timeout);
|
|
5067
|
+
}
|
|
4976
5068
|
}
|
|
4977
|
-
|
|
4978
|
-
|
|
4979
|
-
|
|
4980
|
-
|
|
4981
|
-
hiddenSsid: object.hiddenSSID
|
|
5069
|
+
this.results.push({
|
|
5070
|
+
action: parsedData.action,
|
|
5071
|
+
error: parsedData.error_code,
|
|
5072
|
+
message: parsedData.error_message
|
|
4982
5073
|
});
|
|
4983
|
-
}
|
|
4984
|
-
|
|
4985
|
-
|
|
4986
|
-
|
|
4987
|
-
* @async
|
|
4988
|
-
* @function openAppStore
|
|
4989
|
-
* @category Device
|
|
4990
|
-
*
|
|
4991
|
-
*/
|
|
4992
|
-
static openAppStore(object) {
|
|
4993
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
4994
|
-
return yield this.callNative(ACTION.OPEN_APPSTORE, object);
|
|
4995
|
-
});
|
|
5074
|
+
}
|
|
5075
|
+
catch (e) {
|
|
5076
|
+
console.log('onMultiJSCall', 'error', e);
|
|
5077
|
+
}
|
|
4996
5078
|
}
|
|
4997
|
-
|
|
4998
|
-
|
|
4999
|
-
|
|
5000
|
-
|
|
5001
|
-
|
|
5002
|
-
|
|
5003
|
-
_LocalResourceStorage_prefix.set(this, void 0);
|
|
5004
|
-
_LocalResourceStorage_resourceInfo.set(this, void 0);
|
|
5005
|
-
checkPlatform();
|
|
5006
|
-
// if (platform.isMobile && platform.isZalo) {
|
|
5007
|
-
// Object.defineProperty(window, 'localStorage', {
|
|
5008
|
-
// value: null,
|
|
5009
|
-
// configurable: true,
|
|
5010
|
-
// enumerable: true,
|
|
5011
|
-
// writable: false
|
|
5012
|
-
// });
|
|
5013
|
-
// }
|
|
5014
|
-
__classPrivateFieldSet(this, _LocalResourceStorage_resourceInfo, {
|
|
5015
|
-
keys: new Set(),
|
|
5016
|
-
currentSize: 0,
|
|
5017
|
-
limitSize: STORAGE_LIMIT
|
|
5018
|
-
}, "f");
|
|
5019
|
-
__classPrivateFieldSet(this, _LocalResourceStorage_prefix, prefix, "f");
|
|
5020
|
-
this.findAllCurrentDataByApp(prefix);
|
|
5079
|
+
nativeEventHandler(eventId, eventName, eventData) {
|
|
5080
|
+
this.debug(`eventId: ${eventId}, eventName: ${eventName}, eventData: ${eventData}`);
|
|
5081
|
+
const data = stringToData(eventData);
|
|
5082
|
+
this.debug(data);
|
|
5083
|
+
const convertedData = this.handleEventData(eventName, data);
|
|
5084
|
+
this.events.emit(eventName, eventId, convertedData);
|
|
5021
5085
|
}
|
|
5022
|
-
|
|
5086
|
+
handleEventData(eventName, data) {
|
|
5023
5087
|
try {
|
|
5024
|
-
|
|
5025
|
-
|
|
5026
|
-
|
|
5027
|
-
const
|
|
5028
|
-
|
|
5029
|
-
|
|
5030
|
-
|
|
5031
|
-
|
|
5032
|
-
|
|
5088
|
+
switch (eventName) {
|
|
5089
|
+
case Events.OpenApp:
|
|
5090
|
+
const { url } = data;
|
|
5091
|
+
const validUrl = new URL(url);
|
|
5092
|
+
const path = validUrl.pathname.split(`/zapps/${APP_ID}`)[1];
|
|
5093
|
+
return {
|
|
5094
|
+
path: `${path ? path : '/'}${validUrl.search}`
|
|
5095
|
+
};
|
|
5096
|
+
break;
|
|
5097
|
+
default:
|
|
5098
|
+
return data;
|
|
5099
|
+
break;
|
|
5033
5100
|
}
|
|
5034
5101
|
}
|
|
5035
5102
|
catch (error) {
|
|
5036
|
-
|
|
5103
|
+
return data;
|
|
5037
5104
|
}
|
|
5038
5105
|
}
|
|
5039
|
-
|
|
5040
|
-
|
|
5041
|
-
|
|
5042
|
-
res.set(key, this.getSync(key));
|
|
5043
|
-
});
|
|
5044
|
-
return Promise.resolve(res);
|
|
5045
|
-
}
|
|
5046
|
-
getSync(key) {
|
|
5047
|
-
if (__classPrivateFieldGet(this, _LocalResourceStorage_prefix, "f")) {
|
|
5048
|
-
key = `${__classPrivateFieldGet(this, _LocalResourceStorage_prefix, "f")}_${key}`;
|
|
5106
|
+
defaultCallback(data) {
|
|
5107
|
+
if (data !== null && data !== undefined) {
|
|
5108
|
+
data = parseJSON(data);
|
|
5049
5109
|
}
|
|
5050
|
-
if (!__classPrivateFieldGet(this, _LocalResourceStorage_resourceInfo, "f").keys.has(key))
|
|
5051
|
-
return null;
|
|
5052
|
-
return __classPrivateFieldGet(this, _LocalResourceStorage_storage, "f").getItem(key);
|
|
5053
5110
|
}
|
|
5054
|
-
|
|
5055
|
-
|
|
5056
|
-
|
|
5057
|
-
|
|
5111
|
+
callNative(action, data, option) {
|
|
5112
|
+
this.debug(action.name, data);
|
|
5113
|
+
return new Promise((resolve, reject) => {
|
|
5114
|
+
const handleNativeCallback = (cb) => __awaiter(this, void 0, void 0, function* () {
|
|
5115
|
+
var _a, _b, _c, _d, _e, _f, _g, _h;
|
|
5116
|
+
try {
|
|
5117
|
+
if (_.isUndefined(cb) || _.isNull(cb)) {
|
|
5118
|
+
return reject(new Error('Native callback is null'));
|
|
5119
|
+
}
|
|
5120
|
+
if (cb.error_code !== 0) {
|
|
5121
|
+
let error = new AppError(cb.error_code, cb.error_message);
|
|
5122
|
+
const platform = getPlatform();
|
|
5123
|
+
if (action === ACTION.JUMP_LOGIN) {
|
|
5124
|
+
error = new AppError(RESPONSE_CODE.UNKNOWN_ERROR, `Can not get auth code: ${cb.error_message}`);
|
|
5125
|
+
}
|
|
5126
|
+
else if (!this.isJumped && !action.skip_jump) {
|
|
5127
|
+
error = new AppError(RESPONSE.UNAUTHORIZED.code, RESPONSE.UNAUTHORIZED.message);
|
|
5128
|
+
}
|
|
5129
|
+
else if (String(error.message).toLowerCase() === 'permission required!' ||
|
|
5130
|
+
String(error.message).toLowerCase() === 'no permission!') {
|
|
5131
|
+
error = new AppError(RESPONSE.FORBIDDEN.code, RESPONSE.FORBIDDEN.message);
|
|
5132
|
+
}
|
|
5133
|
+
else if (COMMON_NATIVE_ERROR_CODE[platform][cb.error_code]) {
|
|
5134
|
+
error = new AppError(COMMON_NATIVE_ERROR_CODE[platform][cb.error_code].code, COMMON_NATIVE_ERROR_CODE[platform][cb.error_code].message);
|
|
5135
|
+
}
|
|
5136
|
+
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)]) {
|
|
5137
|
+
let error_message = action.error_list[platform][String(cb.error_code)].map_to.message;
|
|
5138
|
+
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) {
|
|
5139
|
+
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}`;
|
|
5140
|
+
}
|
|
5141
|
+
error = new AppError(action.error_list[platform][String(cb.error_code)].map_to.code, error_message);
|
|
5142
|
+
}
|
|
5143
|
+
return reject(error);
|
|
5144
|
+
}
|
|
5145
|
+
if (option === null || option === void 0 ? void 0 : option.successCallback) {
|
|
5146
|
+
const res = yield option.successCallback(cb.data);
|
|
5147
|
+
return resolve(res);
|
|
5148
|
+
}
|
|
5149
|
+
else {
|
|
5150
|
+
resolve(cb.data || {});
|
|
5151
|
+
}
|
|
5152
|
+
}
|
|
5153
|
+
catch (error) {
|
|
5154
|
+
return reject(error);
|
|
5155
|
+
}
|
|
5058
5156
|
});
|
|
5059
|
-
|
|
5157
|
+
const isIOS = checkPlatform().isIOS;
|
|
5158
|
+
const isSupportAction = checkIOSSupportAction(action);
|
|
5159
|
+
if (isIOS && !isSupportAction) {
|
|
5160
|
+
const error = new AppError(-5, `Client isn't support this action`);
|
|
5161
|
+
return reject(error);
|
|
5162
|
+
}
|
|
5163
|
+
else if (option === null || option === void 0 ? void 0 : option.delay) {
|
|
5164
|
+
setTimeout(() => {
|
|
5165
|
+
__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);
|
|
5166
|
+
}, option.delay);
|
|
5167
|
+
}
|
|
5168
|
+
else {
|
|
5169
|
+
__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);
|
|
5170
|
+
}
|
|
5060
5171
|
});
|
|
5061
5172
|
}
|
|
5062
|
-
|
|
5063
|
-
|
|
5064
|
-
|
|
5173
|
+
}
|
|
5174
|
+
_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) {
|
|
5175
|
+
try {
|
|
5176
|
+
const actionName = action.name;
|
|
5177
|
+
const key = generateUniqueString(actionName);
|
|
5178
|
+
if (!this._device.isMobile || _.isEmpty(actionName)) {
|
|
5179
|
+
this.onJSCall(key, {
|
|
5180
|
+
error_code: -13,
|
|
5181
|
+
error_message: 'params invalid!',
|
|
5182
|
+
data: {
|
|
5183
|
+
device: this._device.isMobile,
|
|
5184
|
+
jsToken: this._jsAccessTk,
|
|
5185
|
+
access_token: this._accessTk
|
|
5186
|
+
},
|
|
5187
|
+
action: actionName
|
|
5188
|
+
});
|
|
5189
|
+
return false;
|
|
5065
5190
|
}
|
|
5066
|
-
|
|
5067
|
-
|
|
5068
|
-
|
|
5069
|
-
|
|
5070
|
-
|
|
5071
|
-
|
|
5072
|
-
|
|
5073
|
-
|
|
5074
|
-
|
|
5075
|
-
|
|
5076
|
-
|
|
5077
|
-
currentSize: _.isNumber(currentSize)
|
|
5078
|
-
? Number((currentSize / 1024).toFixed(2))
|
|
5079
|
-
: 0,
|
|
5080
|
-
limitSize: Number((STORAGE_LIMIT / 1024).toFixed(2))
|
|
5191
|
+
if (options === undefined || options === null) {
|
|
5192
|
+
options = {};
|
|
5193
|
+
}
|
|
5194
|
+
if (!callback) {
|
|
5195
|
+
callback = this.defaultCallback;
|
|
5196
|
+
}
|
|
5197
|
+
const timeoutCallback = {
|
|
5198
|
+
error_code: -14,
|
|
5199
|
+
error_message: 'Request Timeout!',
|
|
5200
|
+
data: {},
|
|
5201
|
+
action: actionName
|
|
5081
5202
|
};
|
|
5082
|
-
|
|
5083
|
-
|
|
5084
|
-
|
|
5085
|
-
|
|
5086
|
-
|
|
5087
|
-
|
|
5088
|
-
|
|
5089
|
-
}
|
|
5090
|
-
|
|
5091
|
-
|
|
5092
|
-
|
|
5093
|
-
|
|
5203
|
+
this._jsCallFuncCallbacks[key] = {
|
|
5204
|
+
timeout: haveTimeout &&
|
|
5205
|
+
action.have_callback &&
|
|
5206
|
+
setTimeout(() => {
|
|
5207
|
+
this.onJSCall(key, timeoutCallback);
|
|
5208
|
+
}, 8000),
|
|
5209
|
+
callback: callback
|
|
5210
|
+
};
|
|
5211
|
+
try {
|
|
5212
|
+
options = serialize(options);
|
|
5213
|
+
if (isMultiCallback) {
|
|
5214
|
+
if (this._device.isIOS) {
|
|
5215
|
+
return ZaloJavaScriptInterface.jsCall(this._jsAccessTk, actionName, this._accessTk, options, window.onMultiJSCall(key));
|
|
5216
|
+
}
|
|
5217
|
+
return ZaloJavaScriptInterface.jsCall(this._jsAccessTk, actionName, this._accessTk, options, `window.onMultiJSCall('${key}')`);
|
|
5218
|
+
}
|
|
5219
|
+
if (this._device.isIOS) {
|
|
5220
|
+
return ZaloJavaScriptInterface.jsCall(this._jsAccessTk, actionName, this._accessTk, options, window.onJSCall(key));
|
|
5221
|
+
}
|
|
5222
|
+
return ZaloJavaScriptInterface.jsCall(this._jsAccessTk, actionName, this._accessTk, options, `window.onJSCall('${key}')`);
|
|
5094
5223
|
}
|
|
5095
|
-
|
|
5096
|
-
|
|
5097
|
-
|
|
5224
|
+
catch (error) {
|
|
5225
|
+
if (nRetry-- > 0) {
|
|
5226
|
+
setTimeout(() => {
|
|
5227
|
+
__classPrivateFieldGet(this, _ZaloJSBridge_instances, "m", _ZaloJSBridge_jsCall).call(this, action, options, callback, isMultiCallback, nRetry);
|
|
5228
|
+
}, 500);
|
|
5229
|
+
}
|
|
5230
|
+
else {
|
|
5231
|
+
const errorCallback = {
|
|
5232
|
+
error_code: -5,
|
|
5233
|
+
error_message: 'Not ready!',
|
|
5234
|
+
data: {
|
|
5235
|
+
userAgent: this._userAgent,
|
|
5236
|
+
options: options,
|
|
5237
|
+
jsToken: this._jsAccessTk,
|
|
5238
|
+
access_token: this._accessTk
|
|
5239
|
+
},
|
|
5240
|
+
action: actionName,
|
|
5241
|
+
js_error: error
|
|
5242
|
+
};
|
|
5243
|
+
this.onJSCall(key, errorCallback);
|
|
5244
|
+
return false;
|
|
5245
|
+
}
|
|
5098
5246
|
}
|
|
5099
5247
|
}
|
|
5100
|
-
|
|
5101
|
-
|
|
5102
|
-
return Promise.resolve(this.clearSync());
|
|
5103
|
-
});
|
|
5104
|
-
}
|
|
5105
|
-
clearSync() {
|
|
5106
|
-
__classPrivateFieldGet(this, _LocalResourceStorage_resourceInfo, "f").keys.forEach((key) => {
|
|
5107
|
-
if (__classPrivateFieldGet(this, _LocalResourceStorage_prefix, "f") && key.indexOf(__classPrivateFieldGet(this, _LocalResourceStorage_prefix, "f")) < 0) {
|
|
5108
|
-
return;
|
|
5109
|
-
}
|
|
5110
|
-
__classPrivateFieldGet(this, _LocalResourceStorage_storage, "f").removeItem(key);
|
|
5111
|
-
__classPrivateFieldGet(this, _LocalResourceStorage_resourceInfo, "f").keys.delete(key);
|
|
5112
|
-
});
|
|
5248
|
+
catch (error) {
|
|
5249
|
+
console.log('jsCall', 'error', error);
|
|
5113
5250
|
}
|
|
5114
|
-
|
|
5115
|
-
|
|
5251
|
+
return false;
|
|
5252
|
+
};
|
|
5116
5253
|
|
|
5117
|
-
var _NativeResourceStorage_appId, _NativeResourceStorage_resourceInfo;
|
|
5118
|
-
class NativeResourceStorage
|
|
5254
|
+
var _NativeResourceStorage_appId, _NativeResourceStorage_resourceInfo, _NativeResourceStorage_bridge;
|
|
5255
|
+
class NativeResourceStorage {
|
|
5119
5256
|
constructor(appId) {
|
|
5120
|
-
super();
|
|
5121
5257
|
_NativeResourceStorage_appId.set(this, void 0);
|
|
5122
5258
|
_NativeResourceStorage_resourceInfo.set(this, void 0);
|
|
5259
|
+
_NativeResourceStorage_bridge.set(this, void 0);
|
|
5123
5260
|
__classPrivateFieldSet(this, _NativeResourceStorage_resourceInfo, {
|
|
5124
5261
|
keys: new Set(),
|
|
5125
5262
|
currentSize: 0,
|
|
5126
5263
|
limitSize: STORAGE_LIMIT
|
|
5127
5264
|
}, "f");
|
|
5128
5265
|
__classPrivateFieldSet(this, _NativeResourceStorage_appId, appId, "f");
|
|
5266
|
+
__classPrivateFieldSet(this, _NativeResourceStorage_bridge, ZaloJSBridge.getInstance(), "f");
|
|
5129
5267
|
}
|
|
5130
5268
|
get(keys) {
|
|
5131
5269
|
return __awaiter(this, void 0, void 0, function* () {
|
|
5132
|
-
return yield this
|
|
5270
|
+
return yield __classPrivateFieldGet(this, _NativeResourceStorage_bridge, "f")
|
|
5271
|
+
.callNative(ACTION.ZBROWSER_MPDS, {
|
|
5133
5272
|
mpds_action: 'mpds.get',
|
|
5134
5273
|
mpds_data: {
|
|
5135
5274
|
keys
|
|
@@ -5137,7 +5276,8 @@ class NativeResourceStorage extends ZJSBridgeProvider {
|
|
|
5137
5276
|
appId: __classPrivateFieldGet(this, _NativeResourceStorage_appId, "f")
|
|
5138
5277
|
}, {
|
|
5139
5278
|
isMultiCallback: false
|
|
5140
|
-
})
|
|
5279
|
+
})
|
|
5280
|
+
.then((data) => {
|
|
5141
5281
|
let res = new Map();
|
|
5142
5282
|
if (data && data.mpds_data && data.mpds_data.map) {
|
|
5143
5283
|
res = new Map(Object.entries(data.mpds_data.map));
|
|
@@ -5148,7 +5288,8 @@ class NativeResourceStorage extends ZJSBridgeProvider {
|
|
|
5148
5288
|
}
|
|
5149
5289
|
set(data) {
|
|
5150
5290
|
return __awaiter(this, void 0, void 0, function* () {
|
|
5151
|
-
const errorKeys = yield this
|
|
5291
|
+
const errorKeys = yield __classPrivateFieldGet(this, _NativeResourceStorage_bridge, "f")
|
|
5292
|
+
.callNative(ACTION.ZBROWSER_MPDS, {
|
|
5152
5293
|
mpds_action: 'mpds.set',
|
|
5153
5294
|
mpds_data: {
|
|
5154
5295
|
map: data
|
|
@@ -5156,7 +5297,8 @@ class NativeResourceStorage extends ZJSBridgeProvider {
|
|
|
5156
5297
|
appId: __classPrivateFieldGet(this, _NativeResourceStorage_appId, "f")
|
|
5157
5298
|
}, {
|
|
5158
5299
|
isMultiCallback: false
|
|
5159
|
-
})
|
|
5300
|
+
})
|
|
5301
|
+
.then((data) => {
|
|
5160
5302
|
let res = [];
|
|
5161
5303
|
if (data && data.mpds_data && data.mpds_data.error_keys) {
|
|
5162
5304
|
res = data.mpds_data.error_keys;
|
|
@@ -5168,13 +5310,15 @@ class NativeResourceStorage extends ZJSBridgeProvider {
|
|
|
5168
5310
|
}
|
|
5169
5311
|
getInfo() {
|
|
5170
5312
|
return __awaiter(this, void 0, void 0, function* () {
|
|
5171
|
-
const currentSize = yield this
|
|
5313
|
+
const currentSize = yield __classPrivateFieldGet(this, _NativeResourceStorage_bridge, "f")
|
|
5314
|
+
.callNative(ACTION.ZBROWSER_MPDS, {
|
|
5172
5315
|
mpds_action: 'mpds.get.size',
|
|
5173
5316
|
mpds_data: {},
|
|
5174
5317
|
appId: __classPrivateFieldGet(this, _NativeResourceStorage_appId, "f")
|
|
5175
5318
|
}, {
|
|
5176
5319
|
isMultiCallback: false
|
|
5177
|
-
})
|
|
5320
|
+
})
|
|
5321
|
+
.then((data) => {
|
|
5178
5322
|
let res = 0;
|
|
5179
5323
|
if (data && data.mpds_data && data.mpds_data.size) {
|
|
5180
5324
|
res = data.mpds_data.size;
|
|
@@ -5189,7 +5333,8 @@ class NativeResourceStorage extends ZJSBridgeProvider {
|
|
|
5189
5333
|
}
|
|
5190
5334
|
remove(keys) {
|
|
5191
5335
|
return __awaiter(this, void 0, void 0, function* () {
|
|
5192
|
-
const errorKeys = yield this
|
|
5336
|
+
const errorKeys = yield __classPrivateFieldGet(this, _NativeResourceStorage_bridge, "f")
|
|
5337
|
+
.callNative(ACTION.ZBROWSER_MPDS, {
|
|
5193
5338
|
mpds_action: 'mpds.remove.key',
|
|
5194
5339
|
mpds_data: {
|
|
5195
5340
|
keys: keys
|
|
@@ -5197,7 +5342,8 @@ class NativeResourceStorage extends ZJSBridgeProvider {
|
|
|
5197
5342
|
appId: __classPrivateFieldGet(this, _NativeResourceStorage_appId, "f")
|
|
5198
5343
|
}, {
|
|
5199
5344
|
isMultiCallback: false
|
|
5200
|
-
})
|
|
5345
|
+
})
|
|
5346
|
+
.then((data) => {
|
|
5201
5347
|
let res = [];
|
|
5202
5348
|
if (data && data.mpds_data && data.mpds_data.error_keys) {
|
|
5203
5349
|
res = data.mpds_data.error_keys;
|
|
@@ -5209,7 +5355,7 @@ class NativeResourceStorage extends ZJSBridgeProvider {
|
|
|
5209
5355
|
}
|
|
5210
5356
|
clear() {
|
|
5211
5357
|
return __awaiter(this, void 0, void 0, function* () {
|
|
5212
|
-
yield this.callNative(ACTION.ZBROWSER_MPDS, {
|
|
5358
|
+
yield __classPrivateFieldGet(this, _NativeResourceStorage_bridge, "f").callNative(ACTION.ZBROWSER_MPDS, {
|
|
5213
5359
|
mpds_action: 'mpds.clear.appData',
|
|
5214
5360
|
mpds_data: {},
|
|
5215
5361
|
appId: __classPrivateFieldGet(this, _NativeResourceStorage_appId, "f")
|
|
@@ -5217,7 +5363,7 @@ class NativeResourceStorage extends ZJSBridgeProvider {
|
|
|
5217
5363
|
});
|
|
5218
5364
|
}
|
|
5219
5365
|
}
|
|
5220
|
-
_NativeResourceStorage_appId = new WeakMap(), _NativeResourceStorage_resourceInfo = new WeakMap();
|
|
5366
|
+
_NativeResourceStorage_appId = new WeakMap(), _NativeResourceStorage_resourceInfo = new WeakMap(), _NativeResourceStorage_bridge = new WeakMap();
|
|
5221
5367
|
|
|
5222
5368
|
var _LocalStorageCreator_appId, _NativeStorageCreator_appId;
|
|
5223
5369
|
class StorageCreator {
|
|
@@ -5469,18 +5615,13 @@ class OpenApi {
|
|
|
5469
5615
|
*/
|
|
5470
5616
|
static getPhoneNumber(object) {
|
|
5471
5617
|
return __awaiter(this, void 0, void 0, function* () {
|
|
5472
|
-
return yield this.callNative(ACTION.MP_GET_NUMBER, {}, {
|
|
5618
|
+
return yield this.getJSBridge().callNative(ACTION.MP_GET_NUMBER, {}, {
|
|
5473
5619
|
isMultiCallback: true,
|
|
5474
|
-
|
|
5475
|
-
|
|
5476
|
-
|
|
5477
|
-
|
|
5478
|
-
|
|
5479
|
-
return Promise.resolve(res);
|
|
5480
|
-
}
|
|
5481
|
-
else {
|
|
5482
|
-
return Promise.reject(error);
|
|
5483
|
-
}
|
|
5620
|
+
successCallback: (data) => {
|
|
5621
|
+
const res = {
|
|
5622
|
+
number: data
|
|
5623
|
+
};
|
|
5624
|
+
return Promise.resolve(res);
|
|
5484
5625
|
},
|
|
5485
5626
|
delay: this.isIOS ? 400 : 0
|
|
5486
5627
|
});
|
|
@@ -5499,7 +5640,7 @@ class Window {
|
|
|
5499
5640
|
*/
|
|
5500
5641
|
static closeApp(object) {
|
|
5501
5642
|
return __awaiter(this, void 0, void 0, function* () {
|
|
5502
|
-
yield this.callNative(ACTION.WINDOW_CLOSE, {});
|
|
5643
|
+
yield this.getJSBridge().callNative(ACTION.WINDOW_CLOSE, {});
|
|
5503
5644
|
});
|
|
5504
5645
|
}
|
|
5505
5646
|
/**
|
|
@@ -5531,7 +5672,7 @@ class Window {
|
|
|
5531
5672
|
mpInfo.appName = appInfo.name;
|
|
5532
5673
|
mpInfo.appAvtUrl = appInfo.logoUrl;
|
|
5533
5674
|
}
|
|
5534
|
-
yield this.callNative(ACTION.OPEN_MP, {
|
|
5675
|
+
yield this.getJSBridge().callNative(ACTION.OPEN_MP, {
|
|
5535
5676
|
mpUrl: `${MINI_APP_INTERNAL_LINK}/${appId}/${queryParamString.length > 0 ? '?' + queryParamString : ''}`,
|
|
5536
5677
|
mpInfo: mpInfo
|
|
5537
5678
|
});
|
|
@@ -5547,7 +5688,7 @@ class Window {
|
|
|
5547
5688
|
*/
|
|
5548
5689
|
static openWebview(url) {
|
|
5549
5690
|
return __awaiter(this, void 0, void 0, function* () {
|
|
5550
|
-
yield this.callNative(ACTION.OPEN_INAPP, {
|
|
5691
|
+
yield this.getJSBridge().callNative(ACTION.OPEN_INAPP, {
|
|
5551
5692
|
url: url
|
|
5552
5693
|
});
|
|
5553
5694
|
});
|
|
@@ -5562,7 +5703,7 @@ class Window {
|
|
|
5562
5703
|
*/
|
|
5563
5704
|
static closeLoading(when) {
|
|
5564
5705
|
return __awaiter(this, void 0, void 0, function* () {
|
|
5565
|
-
yield this.callNative(ACTION.MP_CLOSE_LOADINGVIEW, {
|
|
5706
|
+
yield this.getJSBridge().callNative(ACTION.MP_CLOSE_LOADINGVIEW, {
|
|
5566
5707
|
at: new Date().getTime(),
|
|
5567
5708
|
when: when,
|
|
5568
5709
|
url: location.href
|
|
@@ -5589,30 +5730,24 @@ class Location {
|
|
|
5589
5730
|
*/
|
|
5590
5731
|
static getLocation(object) {
|
|
5591
5732
|
return __awaiter(this, void 0, void 0, function* () {
|
|
5592
|
-
return yield this.callNative(ACTION.GET_LOCATION, {
|
|
5733
|
+
return yield this.getJSBridge().callNative(ACTION.GET_LOCATION, {
|
|
5593
5734
|
silent_request: false,
|
|
5594
5735
|
permission_description: 'Cho phép Zalo truy cập vào vị trí của thiết bị này?'
|
|
5595
5736
|
}, {
|
|
5596
5737
|
isMultiCallback: true,
|
|
5597
5738
|
haveTimeout: false,
|
|
5598
|
-
|
|
5599
|
-
|
|
5600
|
-
|
|
5601
|
-
|
|
5602
|
-
|
|
5603
|
-
|
|
5604
|
-
|
|
5605
|
-
|
|
5606
|
-
|
|
5607
|
-
|
|
5608
|
-
|
|
5609
|
-
|
|
5610
|
-
};
|
|
5611
|
-
return Promise.resolve(res);
|
|
5612
|
-
}
|
|
5613
|
-
else {
|
|
5614
|
-
return Promise.reject(error);
|
|
5615
|
-
}
|
|
5739
|
+
successCallback: (data) => {
|
|
5740
|
+
const res = {
|
|
5741
|
+
/** latitude */
|
|
5742
|
+
latitude: data.latitude,
|
|
5743
|
+
/** longitude */
|
|
5744
|
+
longitude: data.longitude,
|
|
5745
|
+
/** timestamp */
|
|
5746
|
+
timestamp: data.timestamp,
|
|
5747
|
+
/** provider */
|
|
5748
|
+
provider: data.provider
|
|
5749
|
+
};
|
|
5750
|
+
return Promise.resolve(res);
|
|
5616
5751
|
},
|
|
5617
5752
|
delay: this.isIOS ? 400 : 0
|
|
5618
5753
|
});
|
|
@@ -5628,7 +5763,7 @@ class Location {
|
|
|
5628
5763
|
*/
|
|
5629
5764
|
static sendLocation(object) {
|
|
5630
5765
|
return __awaiter(this, void 0, void 0, function* () {
|
|
5631
|
-
yield this.callNative(ACTION.QUERY_LOCATION_HIDE, {
|
|
5766
|
+
yield this.getJSBridge().callNative(ACTION.QUERY_LOCATION_HIDE, {
|
|
5632
5767
|
title: object.title,
|
|
5633
5768
|
touserid: object.toUserId,
|
|
5634
5769
|
zapp: this.getZAppId()
|
|
@@ -5648,17 +5783,12 @@ class Media {
|
|
|
5648
5783
|
*/
|
|
5649
5784
|
static requestCameraPermission(object) {
|
|
5650
5785
|
return __awaiter(this, void 0, void 0, function* () {
|
|
5651
|
-
return yield this.callNative(ACTION.REQUEST_PERMISSION_CAMERA, {}, {
|
|
5652
|
-
|
|
5653
|
-
|
|
5654
|
-
|
|
5655
|
-
|
|
5656
|
-
|
|
5657
|
-
});
|
|
5658
|
-
}
|
|
5659
|
-
else {
|
|
5660
|
-
return Promise.reject(error);
|
|
5661
|
-
}
|
|
5786
|
+
return yield this.getJSBridge().callNative(ACTION.REQUEST_PERMISSION_CAMERA, {}, {
|
|
5787
|
+
successCallback: () => {
|
|
5788
|
+
return Promise.resolve({
|
|
5789
|
+
userAllow: true,
|
|
5790
|
+
message: 'User Allow'
|
|
5791
|
+
});
|
|
5662
5792
|
}
|
|
5663
5793
|
});
|
|
5664
5794
|
});
|
|
@@ -5684,7 +5814,7 @@ class Media {
|
|
|
5684
5814
|
imageUrl: object.imageUrl
|
|
5685
5815
|
};
|
|
5686
5816
|
}
|
|
5687
|
-
return yield this.callNative(ACTION.SAVE_IMAGE_GALLERY, Object.assign({}, data));
|
|
5817
|
+
return yield this.getJSBridge().callNative(ACTION.SAVE_IMAGE_GALLERY, Object.assign({}, data));
|
|
5688
5818
|
});
|
|
5689
5819
|
}
|
|
5690
5820
|
}
|
|
@@ -5699,7 +5829,7 @@ class Zalo {
|
|
|
5699
5829
|
*/
|
|
5700
5830
|
static viewOAQr(object) {
|
|
5701
5831
|
return __awaiter(this, void 0, void 0, function* () {
|
|
5702
|
-
yield this.callNative(ACTION.VIEW_MYQR, {
|
|
5832
|
+
yield this.getJSBridge().callNative(ACTION.VIEW_MYQR, {
|
|
5703
5833
|
dpn: object.displayName,
|
|
5704
5834
|
uid: object.id,
|
|
5705
5835
|
zapp: this.getZAppId()
|
|
@@ -5718,7 +5848,7 @@ class Zalo {
|
|
|
5718
5848
|
*/
|
|
5719
5849
|
static openProfile(object) {
|
|
5720
5850
|
return __awaiter(this, void 0, void 0, function* () {
|
|
5721
|
-
return yield this.callNative(ACTION.OPEN_PROFILE, {
|
|
5851
|
+
return yield this.getJSBridge().callNative(ACTION.OPEN_PROFILE, {
|
|
5722
5852
|
uId: object.id,
|
|
5723
5853
|
type: ProfileType[object.type],
|
|
5724
5854
|
zapp: this.getZAppId(),
|
|
@@ -5736,7 +5866,7 @@ class Zalo {
|
|
|
5736
5866
|
*/
|
|
5737
5867
|
static openChat(object) {
|
|
5738
5868
|
return __awaiter(this, void 0, void 0, function* () {
|
|
5739
|
-
return yield this.callNative(ACTION.OPEN_CHAT, {
|
|
5869
|
+
return yield this.getJSBridge().callNative(ACTION.OPEN_CHAT, {
|
|
5740
5870
|
uId: object.id,
|
|
5741
5871
|
type: ChatType[object.type],
|
|
5742
5872
|
msg: object.message || '',
|
|
@@ -5778,7 +5908,9 @@ class Zalo {
|
|
|
5778
5908
|
};
|
|
5779
5909
|
break;
|
|
5780
5910
|
}
|
|
5781
|
-
return yield this.
|
|
5911
|
+
return yield this.getJSBridge()
|
|
5912
|
+
.callNative(ACTION.OPEN_POSTFEED, Object.assign(Object.assign({ type: PostFeedType[object.type] }, reqData), { zapp: this.getZAppId() }))
|
|
5913
|
+
.then((res) => {
|
|
5782
5914
|
return {
|
|
5783
5915
|
status: res.status,
|
|
5784
5916
|
shareType: res.share_type,
|
|
@@ -5797,7 +5929,7 @@ class Zalo {
|
|
|
5797
5929
|
*/
|
|
5798
5930
|
static followOA(object) {
|
|
5799
5931
|
return __awaiter(this, void 0, void 0, function* () {
|
|
5800
|
-
yield this.callNative(ACTION.FOLLOW_OA, {
|
|
5932
|
+
yield this.getJSBridge().callNative(ACTION.FOLLOW_OA, {
|
|
5801
5933
|
uid: object.id,
|
|
5802
5934
|
showDialogConfirm: true,
|
|
5803
5935
|
zapp: this.getZAppId()
|
|
@@ -5816,7 +5948,7 @@ class Zalo {
|
|
|
5816
5948
|
*/
|
|
5817
5949
|
static unfollowOA(object) {
|
|
5818
5950
|
return __awaiter(this, void 0, void 0, function* () {
|
|
5819
|
-
yield this.callNative(ACTION.UNFOLLOW_OA, {
|
|
5951
|
+
yield this.getJSBridge().callNative(ACTION.UNFOLLOW_OA, {
|
|
5820
5952
|
uid: object.id,
|
|
5821
5953
|
zapp: this.getZAppId()
|
|
5822
5954
|
}, {
|
|
@@ -5835,10 +5967,17 @@ class Zalo {
|
|
|
5835
5967
|
static openShareSheet(object) {
|
|
5836
5968
|
return __awaiter(this, void 0, void 0, function* () {
|
|
5837
5969
|
let reqData = {};
|
|
5970
|
+
let type = object.type;
|
|
5838
5971
|
switch (object.type) {
|
|
5839
5972
|
case 'image':
|
|
5840
5973
|
let photoUrls = [];
|
|
5841
|
-
|
|
5974
|
+
const zaloVersion = getZaloVersion();
|
|
5975
|
+
const platform = getPlatform();
|
|
5976
|
+
if (zaloVersion >= ZALO_SUPPORT_SHARE_MULTI_IMAGE_VERSION[platform]) {
|
|
5977
|
+
type = 'multi_image';
|
|
5978
|
+
}
|
|
5979
|
+
if (Array.isArray(object.data.imageUrls) &&
|
|
5980
|
+
object.data.imageUrls.length > 0) {
|
|
5842
5981
|
photoUrls = object.data.imageUrls;
|
|
5843
5982
|
}
|
|
5844
5983
|
else {
|
|
@@ -5905,9 +6044,11 @@ class Zalo {
|
|
|
5905
6044
|
object.type = 'link';
|
|
5906
6045
|
}
|
|
5907
6046
|
}
|
|
5908
|
-
return yield this.
|
|
6047
|
+
return yield this.getJSBridge()
|
|
6048
|
+
.callNative(ACTION.OPEN_SHARESHEET, Object.assign(Object.assign({ type: ShareSheetType[type] }, reqData), { zapp: this.getZAppId() }), {
|
|
5909
6049
|
haveTimeout: false
|
|
5910
|
-
})
|
|
6050
|
+
})
|
|
6051
|
+
.then((res) => {
|
|
5911
6052
|
return {
|
|
5912
6053
|
status: res.status,
|
|
5913
6054
|
shareType: res.share_type,
|
|
@@ -5926,7 +6067,7 @@ class Zalo {
|
|
|
5926
6067
|
*/
|
|
5927
6068
|
static createShortcut(url, title, icon) {
|
|
5928
6069
|
return __awaiter(this, void 0, void 0, function* () {
|
|
5929
|
-
return yield this.callNative(ACTION.CREATE_SHORTCUT, {
|
|
6070
|
+
return yield this.getJSBridge().callNative(ACTION.CREATE_SHORTCUT, {
|
|
5930
6071
|
url: url,
|
|
5931
6072
|
title: title,
|
|
5932
6073
|
iconUrl: icon
|
|
@@ -5943,15 +6084,14 @@ class Zalo {
|
|
|
5943
6084
|
*/
|
|
5944
6085
|
static openProfilePicker(maxProfile) {
|
|
5945
6086
|
return __awaiter(this, void 0, void 0, function* () {
|
|
5946
|
-
return yield this.callNative(ACTION.MP_OPEN_PROFILE_PICKER, {
|
|
6087
|
+
return yield this.getJSBridge().callNative(ACTION.MP_OPEN_PROFILE_PICKER, {
|
|
5947
6088
|
maxProfile: maxProfile
|
|
5948
6089
|
}, {
|
|
5949
6090
|
isMultiCallback: true,
|
|
5950
|
-
|
|
5951
|
-
if (
|
|
5952
|
-
return Promise.resolve(
|
|
6091
|
+
successCallback: (data) => {
|
|
6092
|
+
if (Array.isArray(data)) {
|
|
6093
|
+
return Promise.resolve(data.map((item) => item.id));
|
|
5953
6094
|
}
|
|
5954
|
-
return Promise.reject(error);
|
|
5955
6095
|
}
|
|
5956
6096
|
});
|
|
5957
6097
|
});
|
|
@@ -5966,15 +6106,15 @@ class Zalo {
|
|
|
5966
6106
|
*/
|
|
5967
6107
|
static getActionsSupported(object) {
|
|
5968
6108
|
return __awaiter(this, void 0, void 0, function* () {
|
|
5969
|
-
return yield this.callNative(ACTION.GET_SUPPORTED_ACTIONS, {}, {
|
|
6109
|
+
return yield this.getJSBridge().callNative(ACTION.GET_SUPPORTED_ACTIONS, {}, {
|
|
5970
6110
|
isMultiCallback: false,
|
|
5971
|
-
|
|
6111
|
+
successCallback: (data) => {
|
|
5972
6112
|
const platform = getPlatform();
|
|
5973
|
-
if (Array.isArray(
|
|
5974
|
-
|
|
6113
|
+
if (Array.isArray(data.actions) &&
|
|
6114
|
+
data.actions.length > 0) {
|
|
5975
6115
|
const skipJumpActions = Object.keys(ACTION).filter((item) => ACTION[item].skip_jump);
|
|
5976
6116
|
const res = {
|
|
5977
|
-
actions: [...
|
|
6117
|
+
actions: [...data.actions, ...skipJumpActions]
|
|
5978
6118
|
};
|
|
5979
6119
|
return Promise.resolve(res);
|
|
5980
6120
|
}
|
|
@@ -5984,7 +6124,6 @@ class Zalo {
|
|
|
5984
6124
|
};
|
|
5985
6125
|
return Promise.resolve(res);
|
|
5986
6126
|
}
|
|
5987
|
-
return Promise.reject(error);
|
|
5988
6127
|
}
|
|
5989
6128
|
});
|
|
5990
6129
|
});
|
|
@@ -6008,7 +6147,7 @@ class Zalo {
|
|
|
6008
6147
|
enable: 1,
|
|
6009
6148
|
aspect_ratio: '1:1'
|
|
6010
6149
|
};
|
|
6011
|
-
return yield this.callNative(ACTION.PICK_MEDIA, {
|
|
6150
|
+
return yield this.getJSBridge().callNative(ACTION.PICK_MEDIA, {
|
|
6012
6151
|
media_type: MediaPickerType[type],
|
|
6013
6152
|
edit_view: Object.assign(Object.assign({}, defaultEditView), editView),
|
|
6014
6153
|
silent_request: silentRequest,
|
|
@@ -6016,15 +6155,11 @@ class Zalo {
|
|
|
6016
6155
|
max_select_items: maxSelectItem
|
|
6017
6156
|
}, {
|
|
6018
6157
|
isMultiCallback: true,
|
|
6019
|
-
|
|
6020
|
-
|
|
6021
|
-
|
|
6022
|
-
|
|
6023
|
-
|
|
6024
|
-
};
|
|
6025
|
-
return Promise.resolve(res);
|
|
6026
|
-
}
|
|
6027
|
-
return Promise.reject(error);
|
|
6158
|
+
successCallback: (data) => {
|
|
6159
|
+
const res = {
|
|
6160
|
+
data: data === null || data === void 0 ? void 0 : data.result_content
|
|
6161
|
+
};
|
|
6162
|
+
return Promise.resolve(res);
|
|
6028
6163
|
}
|
|
6029
6164
|
});
|
|
6030
6165
|
});
|
|
@@ -6039,7 +6174,7 @@ class Zalo {
|
|
|
6039
6174
|
*/
|
|
6040
6175
|
static openOutApp(url) {
|
|
6041
6176
|
return __awaiter(this, void 0, void 0, function* () {
|
|
6042
|
-
return yield this.callNative(ACTION.OPEN_OUTAPP, {
|
|
6177
|
+
return yield this.getJSBridge().callNative(ACTION.OPEN_OUTAPP, {
|
|
6043
6178
|
url: url
|
|
6044
6179
|
});
|
|
6045
6180
|
});
|
|
@@ -6078,7 +6213,7 @@ class Routing {
|
|
|
6078
6213
|
*/
|
|
6079
6214
|
static sendDataToPreviousMiniApp(object) {
|
|
6080
6215
|
return __awaiter(this, void 0, void 0, function* () {
|
|
6081
|
-
return yield this.callNative(ACTION.WEBVIEW_SET_RESULT, {
|
|
6216
|
+
return yield this.getJSBridge().callNative(ACTION.WEBVIEW_SET_RESULT, {
|
|
6082
6217
|
result: stringifyData(object.data)
|
|
6083
6218
|
});
|
|
6084
6219
|
});
|
|
@@ -6103,11 +6238,10 @@ class Routing {
|
|
|
6103
6238
|
}
|
|
6104
6239
|
}
|
|
6105
6240
|
|
|
6106
|
-
var _ZaloMiniProgramSDKService_zAppId, _ZaloMiniProgramSDKService_appId, _ZaloMiniProgramSDKService_appConfig, _ZaloMiniProgramSDKService_zOAuth, _ZaloMiniProgramSDKService_zOAuthVrf, _ZaloMiniProgramSDKService_accessToken, _ZaloMiniProgramSDKService_refreshToken, _ZaloMiniProgramSDKService_cache, _ZaloMiniProgramSDKService_prevGetTokenTimestamp, _ZaloMiniProgramSDKService_tokenExpiresIn,
|
|
6107
|
-
class ZaloMiniProgramSDKService
|
|
6241
|
+
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;
|
|
6242
|
+
class ZaloMiniProgramSDKService {
|
|
6108
6243
|
constructor() {
|
|
6109
6244
|
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s;
|
|
6110
|
-
super();
|
|
6111
6245
|
_ZaloMiniProgramSDKService_zAppId.set(this, ZAPP_ID);
|
|
6112
6246
|
_ZaloMiniProgramSDKService_appId.set(this, APP_ID);
|
|
6113
6247
|
_ZaloMiniProgramSDKService_appConfig.set(this, APP_CONFIG);
|
|
@@ -6120,9 +6254,9 @@ class ZaloMiniProgramSDKService extends ZJSBridgeProvider {
|
|
|
6120
6254
|
getToken: 0
|
|
6121
6255
|
}
|
|
6122
6256
|
});
|
|
6257
|
+
_ZaloMiniProgramSDKService_bridge.set(this, void 0);
|
|
6123
6258
|
_ZaloMiniProgramSDKService_prevGetTokenTimestamp.set(this, void 0);
|
|
6124
6259
|
_ZaloMiniProgramSDKService_tokenExpiresIn.set(this, void 0);
|
|
6125
|
-
_ZaloMiniProgramSDKService_cookies.set(this, null);
|
|
6126
6260
|
_ZaloMiniProgramSDKService_deviceId.set(this, void 0);
|
|
6127
6261
|
this.events = ZMPEEmitter.getInstance();
|
|
6128
6262
|
this.isIOS = checkPlatform().isIOS;
|
|
@@ -6133,34 +6267,6 @@ class ZaloMiniProgramSDKService extends ZJSBridgeProvider {
|
|
|
6133
6267
|
this.setActionBarConfig = (setState) => {
|
|
6134
6268
|
__classPrivateFieldSet(this, _ZaloMiniProgramSDKService_actionBarConfig, setState(__classPrivateFieldGet(this, _ZaloMiniProgramSDKService_actionBarConfig, "f")), "f");
|
|
6135
6269
|
};
|
|
6136
|
-
_ZaloMiniProgramSDKService_callJump.set(this, () => {
|
|
6137
|
-
return new Promise((resolve, reject) => {
|
|
6138
|
-
if (!_.isUndefined(__classPrivateFieldGet(this, _ZaloMiniProgramSDKService_cookies, "f")) && !_.isNull(__classPrivateFieldGet(this, _ZaloMiniProgramSDKService_cookies, "f"))) {
|
|
6139
|
-
resolve(__classPrivateFieldGet(this, _ZaloMiniProgramSDKService_cookies, "f"));
|
|
6140
|
-
}
|
|
6141
|
-
else {
|
|
6142
|
-
this.callNative(ACTION.JUMP_LOGIN, {})
|
|
6143
|
-
.then((data) => {
|
|
6144
|
-
const cookies = (data && data.cookiesOAuthLogins) || [];
|
|
6145
|
-
const jsToken = cookies.find((cookie) => cookie.name === COOKIE_NAME.JS_TOKEN);
|
|
6146
|
-
const deviceId = cookies.find((cookie) => cookie.name === COOKIE_NAME.DEVICE_ID);
|
|
6147
|
-
if (jsToken) {
|
|
6148
|
-
this.setJSToken(jsToken.value);
|
|
6149
|
-
window.ZJSBridge.setJSToken &&
|
|
6150
|
-
window.ZJSBridge.setJSToken(jsToken.value);
|
|
6151
|
-
}
|
|
6152
|
-
__classPrivateFieldSet(this, _ZaloMiniProgramSDKService_cookies, cookies, "f");
|
|
6153
|
-
if (deviceId) {
|
|
6154
|
-
__classPrivateFieldSet(this, _ZaloMiniProgramSDKService_deviceId, deviceId.value, "f");
|
|
6155
|
-
}
|
|
6156
|
-
resolve(cookies);
|
|
6157
|
-
})
|
|
6158
|
-
.catch((error) => {
|
|
6159
|
-
reject(error);
|
|
6160
|
-
});
|
|
6161
|
-
}
|
|
6162
|
-
});
|
|
6163
|
-
});
|
|
6164
6270
|
this.getVersion = Basics.getVersion;
|
|
6165
6271
|
this.getSystemInfo = Basics.getSystemInfo;
|
|
6166
6272
|
this.setNavigationBarTitle = NavigationBar.setNavigationBarTitle;
|
|
@@ -6231,6 +6337,7 @@ class ZaloMiniProgramSDKService extends ZJSBridgeProvider {
|
|
|
6231
6337
|
__classPrivateFieldSet(this, _ZaloMiniProgramSDKService_prevGetTokenTimestamp, 0, "f");
|
|
6232
6338
|
__classPrivateFieldSet(this, _ZaloMiniProgramSDKService_tokenExpiresIn, 0, "f");
|
|
6233
6339
|
__classPrivateFieldSet(this, _ZaloMiniProgramSDKService_deviceId, '', "f");
|
|
6340
|
+
__classPrivateFieldSet(this, _ZaloMiniProgramSDKService_bridge, ZaloJSBridge.getInstance(), "f");
|
|
6234
6341
|
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' ||
|
|
6235
6342
|
((_d = (_c = __classPrivateFieldGet(this, _ZaloMiniProgramSDKService_appConfig, "f")) === null || _c === void 0 ? void 0 : _c.app) === null || _d === void 0 ? void 0 : _d.leftButton) === 'both'
|
|
6236
6343
|
? ACTION_LEFT_BUTTON_TYPE.SHOW_HOME
|
|
@@ -6277,9 +6384,16 @@ class ZaloMiniProgramSDKService extends ZJSBridgeProvider {
|
|
|
6277
6384
|
getDeviceId() {
|
|
6278
6385
|
return __classPrivateFieldGet(this, _ZaloMiniProgramSDKService_deviceId, "f");
|
|
6279
6386
|
}
|
|
6387
|
+
getJSBridge() {
|
|
6388
|
+
return __classPrivateFieldGet(this, _ZaloMiniProgramSDKService_bridge, "f");
|
|
6389
|
+
}
|
|
6280
6390
|
login(object) {
|
|
6281
6391
|
return __awaiter(this, void 0, void 0, function* () {
|
|
6282
|
-
const cookies = yield __classPrivateFieldGet(this,
|
|
6392
|
+
const cookies = yield __classPrivateFieldGet(this, _ZaloMiniProgramSDKService_bridge, "f").jump();
|
|
6393
|
+
const deviceId = cookies.find((cookie) => cookie.name === COOKIE_NAME.DEVICE_ID);
|
|
6394
|
+
if (deviceId) {
|
|
6395
|
+
__classPrivateFieldSet(this, _ZaloMiniProgramSDKService_deviceId, deviceId.value, "f");
|
|
6396
|
+
}
|
|
6283
6397
|
const zOAuthCookie = cookies.find((cookie) => cookie.name === COOKIE_NAME.ZOAUTH);
|
|
6284
6398
|
const zOAuthVrfCookie = cookies.find((cookie) => cookie.name === COOKIE_NAME.ZOAUTH_VRF);
|
|
6285
6399
|
if (!_.isUndefined(zOAuthCookie) &&
|
|
@@ -6296,23 +6410,23 @@ class ZaloMiniProgramSDKService extends ZJSBridgeProvider {
|
|
|
6296
6410
|
yield this.loginZaloV3();
|
|
6297
6411
|
}
|
|
6298
6412
|
if (!__classPrivateFieldGet(this, _ZaloMiniProgramSDKService_accessToken, "f")) {
|
|
6299
|
-
throw apiResponse.error.loginFailed();
|
|
6413
|
+
throw apiResponse.error.loginFailed('Invalid authorization code');
|
|
6300
6414
|
}
|
|
6301
6415
|
return __classPrivateFieldGet(this, _ZaloMiniProgramSDKService_accessToken, "f");
|
|
6302
6416
|
}
|
|
6303
|
-
throw apiResponse.error.loginFailed();
|
|
6417
|
+
throw apiResponse.error.loginFailed('Zalo app has not been activated');
|
|
6304
6418
|
});
|
|
6305
6419
|
}
|
|
6306
6420
|
loginZaloV3() {
|
|
6307
6421
|
return __awaiter(this, void 0, void 0, function* () {
|
|
6308
|
-
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=
|
|
6422
|
+
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* () {
|
|
6309
6423
|
let resData = yield response.json();
|
|
6310
6424
|
if (resData.access_token) {
|
|
6311
6425
|
__classPrivateFieldSet(this, _ZaloMiniProgramSDKService_accessToken, resData.access_token, "f");
|
|
6312
6426
|
const expiresIn = parseInt(resData.expires_in) * 1000;
|
|
6313
6427
|
__classPrivateFieldSet(this, _ZaloMiniProgramSDKService_tokenExpiresIn, expiresIn, "f");
|
|
6314
6428
|
__classPrivateFieldSet(this, _ZaloMiniProgramSDKService_prevGetTokenTimestamp, new Date().getTime(), "f");
|
|
6315
|
-
this.
|
|
6429
|
+
__classPrivateFieldGet(this, _ZaloMiniProgramSDKService_bridge, "f").accessTk = __classPrivateFieldGet(this, _ZaloMiniProgramSDKService_accessToken, "f") || '';
|
|
6316
6430
|
window.ZJSBridge.setZAccSession &&
|
|
6317
6431
|
window.ZJSBridge.setZAccSession(__classPrivateFieldGet(this, _ZaloMiniProgramSDKService_accessToken, "f") || '');
|
|
6318
6432
|
return __classPrivateFieldGet(this, _ZaloMiniProgramSDKService_accessToken, "f");
|
|
@@ -6349,7 +6463,7 @@ class ZaloMiniProgramSDKService extends ZJSBridgeProvider {
|
|
|
6349
6463
|
const expiresIn = parseInt(resData.expires_in) * 1000;
|
|
6350
6464
|
__classPrivateFieldSet(this, _ZaloMiniProgramSDKService_tokenExpiresIn, expiresIn, "f");
|
|
6351
6465
|
__classPrivateFieldSet(this, _ZaloMiniProgramSDKService_prevGetTokenTimestamp, new Date().getTime(), "f");
|
|
6352
|
-
this.
|
|
6466
|
+
__classPrivateFieldGet(this, _ZaloMiniProgramSDKService_bridge, "f").accessTk = __classPrivateFieldGet(this, _ZaloMiniProgramSDKService_accessToken, "f") || '';
|
|
6353
6467
|
window.ZJSBridge.setZAccSession &&
|
|
6354
6468
|
window.ZJSBridge.setZAccSession(__classPrivateFieldGet(this, _ZaloMiniProgramSDKService_accessToken, "f") || '');
|
|
6355
6469
|
return __classPrivateFieldGet(this, _ZaloMiniProgramSDKService_accessToken, "f");
|
|
@@ -6370,7 +6484,7 @@ class ZaloMiniProgramSDKService extends ZJSBridgeProvider {
|
|
|
6370
6484
|
});
|
|
6371
6485
|
}
|
|
6372
6486
|
}
|
|
6373
|
-
_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(),
|
|
6487
|
+
_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();
|
|
6374
6488
|
|
|
6375
6489
|
var _MockSDKService_appId, _MockSDKService_appConfig, _MockSDKService_zOAuth, _MockSDKService_accessToken, _MockSDKService_cache, _MockSDKService_loggedId;
|
|
6376
6490
|
class MockSDKService {
|
|
@@ -8104,90 +8218,175 @@ function getFnParamNames(fn) {
|
|
|
8104
8218
|
.replace(/\s/gi, '')
|
|
8105
8219
|
.split(',');
|
|
8106
8220
|
}
|
|
8107
|
-
|
|
8108
|
-
|
|
8109
|
-
|
|
8110
|
-
|
|
8111
|
-
|
|
8112
|
-
|
|
8113
|
-
|
|
8114
|
-
|
|
8115
|
-
|
|
8116
|
-
|
|
8117
|
-
|
|
8118
|
-
|
|
8119
|
-
|
|
8120
|
-
|
|
8121
|
-
|
|
8122
|
-
|
|
8123
|
-
|
|
8124
|
-
|
|
8125
|
-
|
|
8221
|
+
/**
|
|
8222
|
+
* Copies all metadata from one object to another.
|
|
8223
|
+
* Useful for overwriting function definition in
|
|
8224
|
+
* decorators while keeping all previously
|
|
8225
|
+
* attached metadata
|
|
8226
|
+
*
|
|
8227
|
+
* @param from object to copy metadata from
|
|
8228
|
+
* @param to object to copy metadata to
|
|
8229
|
+
*/
|
|
8230
|
+
function copyMetadata(from, to) {
|
|
8231
|
+
const metadataKeys = Reflect.getMetadataKeys(from);
|
|
8232
|
+
metadataKeys.map((key) => {
|
|
8233
|
+
const value = Reflect.getMetadata(key, from);
|
|
8234
|
+
Reflect.defineMetadata(key, value, to);
|
|
8235
|
+
});
|
|
8236
|
+
}
|
|
8237
|
+
/**
|
|
8238
|
+
* Apply the given decorator to all class methods
|
|
8239
|
+
*
|
|
8240
|
+
* @param decorator Method decorator to apply to all methods of a class
|
|
8241
|
+
* @param {string[]} options.exclude array of method names that won't be decorated
|
|
8242
|
+
* @param {boolean} options.deep if true, also decorates methods of the extended classes (recusrively)
|
|
8243
|
+
*/
|
|
8244
|
+
const DecorateAll = (decorator, options = {}) => {
|
|
8245
|
+
return (target) => {
|
|
8246
|
+
var _a;
|
|
8247
|
+
let descriptors = Object.getOwnPropertyDescriptors(target.prototype);
|
|
8248
|
+
if (options.deep) {
|
|
8249
|
+
let base = Object.getPrototypeOf(target);
|
|
8250
|
+
while (base.prototype) {
|
|
8251
|
+
const baseDescriptors = Object.getOwnPropertyDescriptors(base.prototype);
|
|
8252
|
+
descriptors = Object.assign(Object.assign({}, baseDescriptors), descriptors);
|
|
8253
|
+
base = Object.getPrototypeOf(base);
|
|
8254
|
+
}
|
|
8255
|
+
}
|
|
8256
|
+
for (const [propName, descriptor] of Object.entries(descriptors)) {
|
|
8257
|
+
const isMethod = typeof descriptor.value == 'function' && propName != 'constructor';
|
|
8258
|
+
if ((_a = options.exclude) === null || _a === void 0 ? void 0 : _a.includes(propName))
|
|
8259
|
+
continue;
|
|
8260
|
+
if (options.excludePrefix && propName.startsWith(options.excludePrefix))
|
|
8261
|
+
continue;
|
|
8262
|
+
if (!isMethod)
|
|
8263
|
+
continue;
|
|
8264
|
+
const originalMethod = descriptor.value;
|
|
8265
|
+
decorator(target, propName, descriptor);
|
|
8266
|
+
if (originalMethod != descriptor.value) {
|
|
8267
|
+
copyMetadata(originalMethod, descriptor.value);
|
|
8268
|
+
}
|
|
8269
|
+
Object.defineProperty(target.prototype, propName, descriptor);
|
|
8270
|
+
}
|
|
8271
|
+
};
|
|
8272
|
+
};
|
|
8273
|
+
const centralizedFunctionHandler = (target, propertyName, descriptor) => {
|
|
8274
|
+
const fn = descriptor.value;
|
|
8275
|
+
const argsName = getFnParamNames(fn);
|
|
8276
|
+
descriptor.value = function (...args) {
|
|
8277
|
+
try {
|
|
8278
|
+
// begin validation
|
|
8279
|
+
const requiredParameters = Reflect.getOwnMetadata(requiredMetadataKey, target.prototype, propertyName);
|
|
8280
|
+
const checkTypeParameters = Reflect.getOwnMetadata(checkTypeMetadataKey, target.prototype, propertyName);
|
|
8281
|
+
if (checkTypeParameters) {
|
|
8282
|
+
checkTypeParameters.forEach((parameter) => {
|
|
8283
|
+
const { parameterIndex, type, properties, defaultValue } = parameter;
|
|
8284
|
+
let argument = args[parameterIndex];
|
|
8285
|
+
let argumentName = argsName[parameterIndex];
|
|
8286
|
+
const parameterType = typeof argument;
|
|
8287
|
+
if (!_.isUndefined(argument)) {
|
|
8288
|
+
if (!isType(argument, type)) {
|
|
8289
|
+
throw apiResponse.error.wrongTypeParam(argumentName, type, Array.isArray(argument)
|
|
8290
|
+
? 'array'
|
|
8291
|
+
: argument === null
|
|
8292
|
+
? 'null'
|
|
8293
|
+
: parameterType);
|
|
8294
|
+
}
|
|
8295
|
+
if (type === 'object') {
|
|
8296
|
+
Object.entries(properties).forEach(([propKey, propType]) => {
|
|
8297
|
+
const key = propKey.split('?')[0];
|
|
8298
|
+
const propValue = _.get(argument, key);
|
|
8299
|
+
if (!_.isUndefined(propValue) && !_.isNull(propValue)) {
|
|
8300
|
+
if (_.isFunction(propType)) {
|
|
8301
|
+
const res = propType(propValue);
|
|
8302
|
+
if (res && res.error) {
|
|
8303
|
+
throw apiResponse.error.wrongTypeParam(`${argumentName}.${key}`, res.errorMessage, typeof propValue);
|
|
8304
|
+
}
|
|
8305
|
+
}
|
|
8306
|
+
}
|
|
8307
|
+
else if (!propKey.includes('?')) {
|
|
8308
|
+
throw apiResponse.error.missingParam(propKey);
|
|
8309
|
+
}
|
|
8310
|
+
else if (!_.get(argument, key.split('.')[0]) &&
|
|
8311
|
+
defaultValue &&
|
|
8312
|
+
!_.isUndefined(_.get(defaultValue, key))) {
|
|
8313
|
+
_.set(args[parameterIndex], key, _.get(defaultValue, key));
|
|
8314
|
+
}
|
|
8315
|
+
});
|
|
8316
|
+
}
|
|
8317
|
+
}
|
|
8318
|
+
});
|
|
8319
|
+
}
|
|
8320
|
+
if (requiredParameters) {
|
|
8321
|
+
requiredParameters.forEach((parameter) => {
|
|
8322
|
+
const { parameterIndex, option, fields } = parameter;
|
|
8323
|
+
const argument = args[parameterIndex];
|
|
8324
|
+
const condition = option === null || option === void 0 ? void 0 : option.if;
|
|
8325
|
+
const defaultValue = option === null || option === void 0 ? void 0 : option.defaultValue;
|
|
8326
|
+
let isMeetCondition = true;
|
|
8327
|
+
if (condition) {
|
|
8328
|
+
isMeetCondition = Object.keys(condition).every((key) => _.get(argument, key) === condition[key]);
|
|
8126
8329
|
}
|
|
8127
|
-
if (
|
|
8128
|
-
|
|
8129
|
-
const
|
|
8130
|
-
|
|
8131
|
-
|
|
8132
|
-
|
|
8133
|
-
|
|
8134
|
-
if (res && res.error) {
|
|
8135
|
-
throw apiResponse.error.wrongTypeParam(`${argumentName}.${key}`, res.errorMessage, typeof propValue);
|
|
8330
|
+
if (isMeetCondition) {
|
|
8331
|
+
fields.forEach((item) => {
|
|
8332
|
+
const isInValidField = (field) => {
|
|
8333
|
+
let isInValid = false;
|
|
8334
|
+
if (_.isEmpty(_.get(argument, field))) {
|
|
8335
|
+
if (!_.isUndefined(_.get(defaultValue, field))) {
|
|
8336
|
+
_.set(args[parameterIndex], field, _.get(defaultValue, field));
|
|
8136
8337
|
}
|
|
8338
|
+
isInValid = true;
|
|
8137
8339
|
}
|
|
8340
|
+
return isInValid;
|
|
8341
|
+
};
|
|
8342
|
+
if (Array.isArray(item) &&
|
|
8343
|
+
item.length > 0 &&
|
|
8344
|
+
item.every(isInValidField)) {
|
|
8345
|
+
throw apiResponse.error.missingParam(item.join(' or '));
|
|
8138
8346
|
}
|
|
8139
|
-
else if (
|
|
8140
|
-
throw apiResponse.error.missingParam(
|
|
8141
|
-
}
|
|
8142
|
-
else if (_.isObject(_.get(argument, key.split('.')[0])) &&
|
|
8143
|
-
defaultValue &&
|
|
8144
|
-
!_.isUndefined(_.get(defaultValue, key))) {
|
|
8145
|
-
_.set(arguments[parameterIndex], key, _.get(defaultValue, key));
|
|
8347
|
+
else if (_.isString(item) && isInValidField(item)) {
|
|
8348
|
+
throw apiResponse.error.missingParam(item);
|
|
8146
8349
|
}
|
|
8147
8350
|
});
|
|
8148
8351
|
}
|
|
8149
|
-
}
|
|
8150
|
-
}
|
|
8151
|
-
|
|
8152
|
-
|
|
8153
|
-
|
|
8154
|
-
const {
|
|
8155
|
-
|
|
8156
|
-
|
|
8157
|
-
|
|
8158
|
-
|
|
8159
|
-
|
|
8160
|
-
|
|
8161
|
-
|
|
8162
|
-
|
|
8163
|
-
|
|
8164
|
-
|
|
8165
|
-
|
|
8166
|
-
|
|
8167
|
-
|
|
8168
|
-
|
|
8169
|
-
}
|
|
8170
|
-
isInValid = true;
|
|
8171
|
-
}
|
|
8172
|
-
return isInValid;
|
|
8173
|
-
};
|
|
8174
|
-
if (Array.isArray(item) && item.length > 0 && item.every(isInValidField)) {
|
|
8175
|
-
throw apiResponse.error.missingParam(item.join(' or '));
|
|
8352
|
+
});
|
|
8353
|
+
}
|
|
8354
|
+
// end validation
|
|
8355
|
+
const res = fn.call(this, ...args);
|
|
8356
|
+
if (_.isPromise(res)) {
|
|
8357
|
+
const { success, fail } = Array.isArray(args) && args.length > 0 && args[0];
|
|
8358
|
+
return new Promise((resolve, reject) => {
|
|
8359
|
+
res
|
|
8360
|
+
.then((data) => {
|
|
8361
|
+
if (!_.isNull(success) && _.isFunction(success)) {
|
|
8362
|
+
success.call(null, data, this);
|
|
8363
|
+
}
|
|
8364
|
+
else {
|
|
8365
|
+
resolve(res);
|
|
8366
|
+
}
|
|
8367
|
+
})
|
|
8368
|
+
.catch((error) => {
|
|
8369
|
+
const errorParsed = errorHandler(error, propertyName);
|
|
8370
|
+
if (!_.isNull(fail) && _.isFunction(fail)) {
|
|
8371
|
+
fail.call(null, errorParsed, this);
|
|
8176
8372
|
}
|
|
8177
|
-
else
|
|
8178
|
-
|
|
8373
|
+
else {
|
|
8374
|
+
reject(errorParsed);
|
|
8179
8375
|
}
|
|
8180
8376
|
});
|
|
8181
|
-
}
|
|
8182
|
-
}
|
|
8377
|
+
});
|
|
8378
|
+
}
|
|
8379
|
+
return res;
|
|
8380
|
+
}
|
|
8381
|
+
catch (error) {
|
|
8382
|
+
throw errorHandler(error, propertyName);
|
|
8183
8383
|
}
|
|
8184
|
-
return method.apply(this, arguments);
|
|
8185
8384
|
};
|
|
8186
8385
|
return descriptor;
|
|
8187
8386
|
};
|
|
8188
8387
|
|
|
8189
8388
|
var _SDKCreator_sdkService;
|
|
8190
|
-
class SDKCreator {
|
|
8389
|
+
let SDKCreator = class SDKCreator {
|
|
8191
8390
|
constructor() {
|
|
8192
8391
|
this.events = ZMPEEmitter.getInstance();
|
|
8193
8392
|
_SDKCreator_sdkService.set(this, void 0);
|
|
@@ -8248,7 +8447,7 @@ class SDKCreator {
|
|
|
8248
8447
|
}
|
|
8249
8448
|
setNavigationBarTitle(object) {
|
|
8250
8449
|
return __awaiter(this, void 0, void 0, function* () {
|
|
8251
|
-
return __classPrivateFieldGet(this, _SDKCreator_sdkService, "f").setNavigationBarTitle(object);
|
|
8450
|
+
return yield __classPrivateFieldGet(this, _SDKCreator_sdkService, "f").setNavigationBarTitle(object);
|
|
8252
8451
|
});
|
|
8253
8452
|
}
|
|
8254
8453
|
setNavigationBarColor(object) {
|
|
@@ -8518,6 +8717,7 @@ class SDKCreator {
|
|
|
8518
8717
|
}
|
|
8519
8718
|
vibrate(object) {
|
|
8520
8719
|
return __awaiter(this, void 0, void 0, function* () {
|
|
8720
|
+
console.log(object);
|
|
8521
8721
|
yield __classPrivateFieldGet(this, _SDKCreator_sdkService, "f").vibrate(object);
|
|
8522
8722
|
});
|
|
8523
8723
|
}
|
|
@@ -8673,33 +8873,14 @@ class SDKCreator {
|
|
|
8673
8873
|
getDeviceId() {
|
|
8674
8874
|
return __classPrivateFieldGet(this, _SDKCreator_sdkService, "f").getDeviceId();
|
|
8675
8875
|
}
|
|
8676
|
-
}
|
|
8876
|
+
};
|
|
8677
8877
|
_SDKCreator_sdkService = new WeakMap();
|
|
8678
8878
|
__decorate([
|
|
8679
|
-
handleError
|
|
8680
|
-
], SDKCreator.prototype, "login", null);
|
|
8681
|
-
__decorate([
|
|
8682
|
-
handleErrorSync
|
|
8683
|
-
], SDKCreator.prototype, "getLoginStatus", null);
|
|
8684
|
-
__decorate([
|
|
8685
|
-
handleError
|
|
8686
|
-
], SDKCreator.prototype, "getAccessToken", null);
|
|
8687
|
-
__decorate([
|
|
8688
|
-
handleErrorSync
|
|
8689
|
-
], SDKCreator.prototype, "getVersion", null);
|
|
8690
|
-
__decorate([
|
|
8691
|
-
handleErrorSync
|
|
8692
|
-
], SDKCreator.prototype, "getSystemInfo", null);
|
|
8693
|
-
__decorate([
|
|
8694
|
-
handleError,
|
|
8695
|
-
validate,
|
|
8696
8879
|
__param(0, checkType('object', {
|
|
8697
8880
|
title: checkData('string')
|
|
8698
8881
|
}))
|
|
8699
8882
|
], SDKCreator.prototype, "setNavigationBarTitle", null);
|
|
8700
8883
|
__decorate([
|
|
8701
|
-
handleError,
|
|
8702
|
-
validate,
|
|
8703
8884
|
__param(0, checkType('object', {
|
|
8704
8885
|
color: checkData('string'),
|
|
8705
8886
|
'textColor?': checkData('string', { values: ['white', 'black'] }),
|
|
@@ -8707,57 +8888,37 @@ __decorate([
|
|
|
8707
8888
|
}))
|
|
8708
8889
|
], SDKCreator.prototype, "setNavigationBarColor", null);
|
|
8709
8890
|
__decorate([
|
|
8710
|
-
handleError,
|
|
8711
|
-
validate,
|
|
8712
8891
|
__param(0, checkType('object', {
|
|
8713
8892
|
backgroundColor: checkData('string'),
|
|
8714
8893
|
'textColor?': checkData('string', { values: ['white', 'black'] })
|
|
8715
8894
|
}))
|
|
8716
8895
|
], SDKCreator.prototype, "setBackgroundColor", null);
|
|
8717
8896
|
__decorate([
|
|
8718
|
-
handleError,
|
|
8719
|
-
validate,
|
|
8720
8897
|
__param(0, checkType('object', {
|
|
8721
8898
|
type: checkData('string', { values: ['none', 'back', 'home', 'both'] })
|
|
8722
8899
|
}))
|
|
8723
8900
|
], SDKCreator.prototype, "setNavigationBarLeftButton", null);
|
|
8724
8901
|
__decorate([
|
|
8725
|
-
handleError,
|
|
8726
|
-
validate,
|
|
8727
8902
|
__param(0, checkType('object', {
|
|
8728
8903
|
rotate: checkData('string', { values: ['auto', 'portrait', 'landscape'] })
|
|
8729
8904
|
}))
|
|
8730
8905
|
], SDKCreator.prototype, "setDeviceOrientation", null);
|
|
8731
8906
|
__decorate([
|
|
8732
|
-
handleError,
|
|
8733
|
-
validate,
|
|
8734
8907
|
__param(0, checkType('object', {
|
|
8735
8908
|
data: checkData('object')
|
|
8736
8909
|
}))
|
|
8737
8910
|
], SDKCreator.prototype, "setStorage", null);
|
|
8738
8911
|
__decorate([
|
|
8739
|
-
handleError,
|
|
8740
|
-
validate,
|
|
8741
8912
|
__param(0, checkType('object', {
|
|
8742
8913
|
keys: checkData('array<string>')
|
|
8743
8914
|
}))
|
|
8744
8915
|
], SDKCreator.prototype, "getStorage", null);
|
|
8745
8916
|
__decorate([
|
|
8746
|
-
handleError
|
|
8747
|
-
], SDKCreator.prototype, "getStorageInfo", null);
|
|
8748
|
-
__decorate([
|
|
8749
|
-
handleError,
|
|
8750
|
-
validate,
|
|
8751
8917
|
__param(0, checkType('object', {
|
|
8752
8918
|
keys: checkData('array<string>')
|
|
8753
8919
|
}))
|
|
8754
8920
|
], SDKCreator.prototype, "removeStorage", null);
|
|
8755
8921
|
__decorate([
|
|
8756
|
-
handleError
|
|
8757
|
-
], SDKCreator.prototype, "clearStorage", null);
|
|
8758
|
-
__decorate([
|
|
8759
|
-
handleError,
|
|
8760
|
-
validate,
|
|
8761
8922
|
__param(0, checkType('object', {
|
|
8762
8923
|
'avatarType?': checkData('string', {
|
|
8763
8924
|
values: ['small', 'normal', 'large']
|
|
@@ -8765,67 +8926,12 @@ __decorate([
|
|
|
8765
8926
|
}))
|
|
8766
8927
|
], SDKCreator.prototype, "getUserInfo", null);
|
|
8767
8928
|
__decorate([
|
|
8768
|
-
handleError
|
|
8769
|
-
], SDKCreator.prototype, "getNetworkType", null);
|
|
8770
|
-
__decorate([
|
|
8771
|
-
handleError
|
|
8772
|
-
], SDKCreator.prototype, "onNetworkStatusChange", null);
|
|
8773
|
-
__decorate([
|
|
8774
|
-
handleError
|
|
8775
|
-
], SDKCreator.prototype, "startBeaconDiscovery", null);
|
|
8776
|
-
__decorate([
|
|
8777
|
-
handleError
|
|
8778
|
-
], SDKCreator.prototype, "stopBeaconDiscovery", null);
|
|
8779
|
-
__decorate([
|
|
8780
|
-
handleError
|
|
8781
|
-
], SDKCreator.prototype, "getBeacons", null);
|
|
8782
|
-
__decorate([
|
|
8783
|
-
handleError
|
|
8784
|
-
], SDKCreator.prototype, "closeApp", null);
|
|
8785
|
-
__decorate([
|
|
8786
|
-
handleError
|
|
8787
|
-
], SDKCreator.prototype, "getLocation", null);
|
|
8788
|
-
__decorate([
|
|
8789
|
-
handleError
|
|
8790
|
-
], SDKCreator.prototype, "stopBluetoothDevicesDiscovery", null);
|
|
8791
|
-
__decorate([
|
|
8792
|
-
handleError
|
|
8793
|
-
], SDKCreator.prototype, "startBluetoothDevicesDiscovery", null);
|
|
8794
|
-
__decorate([
|
|
8795
|
-
handleError
|
|
8796
|
-
], SDKCreator.prototype, "openBluetoothAdapter", null);
|
|
8797
|
-
__decorate([
|
|
8798
|
-
handleError
|
|
8799
|
-
], SDKCreator.prototype, "onBluetoothDeviceFound", null);
|
|
8800
|
-
__decorate([
|
|
8801
|
-
handleError
|
|
8802
|
-
], SDKCreator.prototype, "onBluetoothAdapterStateChange", null);
|
|
8803
|
-
__decorate([
|
|
8804
|
-
handleError
|
|
8805
|
-
], SDKCreator.prototype, "getConnectedBluetoothDevices", null);
|
|
8806
|
-
__decorate([
|
|
8807
|
-
handleError
|
|
8808
|
-
], SDKCreator.prototype, "getBluetoothDevices", null);
|
|
8809
|
-
__decorate([
|
|
8810
|
-
handleError
|
|
8811
|
-
], SDKCreator.prototype, "getBluetoothAdapterState", null);
|
|
8812
|
-
__decorate([
|
|
8813
|
-
handleError
|
|
8814
|
-
], SDKCreator.prototype, "closeBluetoothAdapter", null);
|
|
8815
|
-
__decorate([
|
|
8816
|
-
handleError
|
|
8817
|
-
], SDKCreator.prototype, "scanQRCode", null);
|
|
8818
|
-
__decorate([
|
|
8819
|
-
handleError,
|
|
8820
|
-
validate,
|
|
8821
8929
|
__param(0, checkType('object', {
|
|
8822
8930
|
type: checkData('string', { values: ['user', 'oa', 'aliasOA'] }),
|
|
8823
8931
|
id: checkData('string')
|
|
8824
8932
|
}))
|
|
8825
8933
|
], SDKCreator.prototype, "openProfile", null);
|
|
8826
8934
|
__decorate([
|
|
8827
|
-
handleError,
|
|
8828
|
-
validate,
|
|
8829
8935
|
__param(0, checkType('object', {
|
|
8830
8936
|
type: checkData('string', { values: ['user', 'oa'] }),
|
|
8831
8937
|
id: checkData('string'),
|
|
@@ -8833,8 +8939,6 @@ __decorate([
|
|
|
8833
8939
|
}))
|
|
8834
8940
|
], SDKCreator.prototype, "openChat", null);
|
|
8835
8941
|
__decorate([
|
|
8836
|
-
handleError,
|
|
8837
|
-
validate,
|
|
8838
8942
|
__param(0, required(['data.imageUrl'], { if: { type: 'image' } })),
|
|
8839
8943
|
__param(0, required(['data.link'], { if: { type: 'link' } })),
|
|
8840
8944
|
__param(0, required(['data.id'], { if: { type: 'profile' } })),
|
|
@@ -8852,23 +8956,17 @@ __decorate([
|
|
|
8852
8956
|
}))
|
|
8853
8957
|
], SDKCreator.prototype, "openPostFeed", null);
|
|
8854
8958
|
__decorate([
|
|
8855
|
-
handleError,
|
|
8856
|
-
validate,
|
|
8857
8959
|
__param(0, checkType('object', {
|
|
8858
8960
|
id: checkData('string'),
|
|
8859
8961
|
'showDialogConfirm?': checkData('boolean')
|
|
8860
8962
|
}))
|
|
8861
8963
|
], SDKCreator.prototype, "followOA", null);
|
|
8862
8964
|
__decorate([
|
|
8863
|
-
handleError,
|
|
8864
|
-
validate,
|
|
8865
8965
|
__param(0, checkType('object', {
|
|
8866
8966
|
id: checkData('string')
|
|
8867
8967
|
}))
|
|
8868
8968
|
], SDKCreator.prototype, "unfollowOA", null);
|
|
8869
8969
|
__decorate([
|
|
8870
|
-
handleError,
|
|
8871
|
-
validate,
|
|
8872
8970
|
__param(0, required([['data.imageUrl', 'data.imageUrls']], { if: { type: 'image' } })),
|
|
8873
8971
|
__param(0, required(['data.link'], { if: { type: 'link' } })),
|
|
8874
8972
|
__param(0, required(['data.id'], { if: { type: 'oa' } })),
|
|
@@ -8907,14 +9005,6 @@ __decorate([
|
|
|
8907
9005
|
}))
|
|
8908
9006
|
], SDKCreator.prototype, "openShareSheet", null);
|
|
8909
9007
|
__decorate([
|
|
8910
|
-
handleError
|
|
8911
|
-
], SDKCreator.prototype, "requestCameraPermission", null);
|
|
8912
|
-
__decorate([
|
|
8913
|
-
handleError
|
|
8914
|
-
], SDKCreator.prototype, "createShortcut", null);
|
|
8915
|
-
__decorate([
|
|
8916
|
-
handleError,
|
|
8917
|
-
validate,
|
|
8918
9008
|
__param(0, checkType('object', {
|
|
8919
9009
|
secretData: checkData('string'),
|
|
8920
9010
|
'ui?': checkData('object'),
|
|
@@ -8932,44 +9022,28 @@ __decorate([
|
|
|
8932
9022
|
}))
|
|
8933
9023
|
], SDKCreator.prototype, "openBioAuthentication", null);
|
|
8934
9024
|
__decorate([
|
|
8935
|
-
handleError
|
|
8936
|
-
], SDKCreator.prototype, "checkStateBioAuthentication", null);
|
|
8937
|
-
__decorate([
|
|
8938
|
-
handleError,
|
|
8939
|
-
validate,
|
|
8940
9025
|
__param(0, checkType('object', {
|
|
8941
9026
|
toUserId: checkData('string'),
|
|
8942
9027
|
'title?': checkData('string')
|
|
8943
9028
|
}))
|
|
8944
9029
|
], SDKCreator.prototype, "sendLocation", null);
|
|
8945
9030
|
__decorate([
|
|
8946
|
-
handleError,
|
|
8947
|
-
validate,
|
|
8948
9031
|
__param(0, checkType('object', {
|
|
8949
9032
|
message: checkData('string')
|
|
8950
9033
|
}))
|
|
8951
9034
|
], SDKCreator.prototype, "showToast", null);
|
|
8952
9035
|
__decorate([
|
|
8953
|
-
handleError
|
|
8954
|
-
], SDKCreator.prototype, "hideKeyboard", null);
|
|
8955
|
-
__decorate([
|
|
8956
|
-
handleError,
|
|
8957
|
-
validate,
|
|
8958
9036
|
__param(0, checkType('object', {
|
|
8959
9037
|
phoneNumber: checkData('string')
|
|
8960
9038
|
}))
|
|
8961
9039
|
], SDKCreator.prototype, "openPhone", null);
|
|
8962
9040
|
__decorate([
|
|
8963
|
-
handleError,
|
|
8964
|
-
validate,
|
|
8965
9041
|
__param(0, checkType('object', {
|
|
8966
9042
|
content: checkData('string'),
|
|
8967
9043
|
phoneNumber: checkData('string', { regex: /^\+?\d+$/ })
|
|
8968
9044
|
}))
|
|
8969
9045
|
], SDKCreator.prototype, "openSMS", null);
|
|
8970
9046
|
__decorate([
|
|
8971
|
-
handleError,
|
|
8972
|
-
validate,
|
|
8973
9047
|
__param(0, checkType('object', {
|
|
8974
9048
|
id: checkData('string'),
|
|
8975
9049
|
'displayName?': checkData('string')
|
|
@@ -8978,35 +9052,24 @@ __decorate([
|
|
|
8978
9052
|
}))
|
|
8979
9053
|
], SDKCreator.prototype, "viewOAQr", null);
|
|
8980
9054
|
__decorate([
|
|
8981
|
-
handleError
|
|
8982
|
-
], SDKCreator.prototype, "keepScreen", null);
|
|
8983
|
-
__decorate([
|
|
8984
|
-
handleError,
|
|
8985
|
-
validate,
|
|
8986
9055
|
__param(0, checkType('object', {
|
|
8987
9056
|
'imageBase64Data?': checkData('string'),
|
|
8988
9057
|
'imageUrl?': checkData('url')
|
|
8989
9058
|
}))
|
|
8990
9059
|
], SDKCreator.prototype, "saveImageToGallery", null);
|
|
8991
9060
|
__decorate([
|
|
8992
|
-
handleError,
|
|
8993
|
-
validate,
|
|
8994
9061
|
__param(0, checkType('object', {
|
|
8995
9062
|
'imageBase64Data?': checkData('string'),
|
|
8996
9063
|
'imageUrl?': checkData('url')
|
|
8997
9064
|
}))
|
|
8998
9065
|
], SDKCreator.prototype, "saveImageToPhotosAlbum", null);
|
|
8999
9066
|
__decorate([
|
|
9000
|
-
handleError,
|
|
9001
|
-
validate,
|
|
9002
9067
|
__param(0, checkType('object', {
|
|
9003
9068
|
appId: checkData('string'),
|
|
9004
9069
|
'params?': checkData('object')
|
|
9005
9070
|
}))
|
|
9006
9071
|
], SDKCreator.prototype, "openMiniApp", null);
|
|
9007
9072
|
__decorate([
|
|
9008
|
-
handleError,
|
|
9009
|
-
validate,
|
|
9010
9073
|
__param(0, checkType('object', {
|
|
9011
9074
|
'type?': checkData('string', { values: ['oneShot'] }),
|
|
9012
9075
|
'milliseconds?': checkData('number')
|
|
@@ -9016,30 +9079,11 @@ __decorate([
|
|
|
9016
9079
|
}))
|
|
9017
9080
|
], SDKCreator.prototype, "vibrate", null);
|
|
9018
9081
|
__decorate([
|
|
9019
|
-
handleError,
|
|
9020
|
-
validate,
|
|
9021
9082
|
__param(0, checkType('object', {
|
|
9022
9083
|
url: checkData('url')
|
|
9023
9084
|
}))
|
|
9024
9085
|
], SDKCreator.prototype, "openWebview", null);
|
|
9025
9086
|
__decorate([
|
|
9026
|
-
handleErrorSync
|
|
9027
|
-
], SDKCreator.prototype, "getRouteParams", null);
|
|
9028
|
-
__decorate([
|
|
9029
|
-
handleError
|
|
9030
|
-
], SDKCreator.prototype, "getAppInfo", null);
|
|
9031
|
-
__decorate([
|
|
9032
|
-
handleError
|
|
9033
|
-
], SDKCreator.prototype, "sendDataToPreviousMiniApp", null);
|
|
9034
|
-
__decorate([
|
|
9035
|
-
handleError
|
|
9036
|
-
], SDKCreator.prototype, "onCallbackData", null);
|
|
9037
|
-
__decorate([
|
|
9038
|
-
handleError
|
|
9039
|
-
], SDKCreator.prototype, "getPhoneNumber", null);
|
|
9040
|
-
__decorate([
|
|
9041
|
-
handleError,
|
|
9042
|
-
validate,
|
|
9043
9087
|
__param(0, checkType('object', {
|
|
9044
9088
|
'maxProfile?': checkData('number', { min: 1, max: 10 })
|
|
9045
9089
|
}, {
|
|
@@ -9047,8 +9091,6 @@ __decorate([
|
|
|
9047
9091
|
}))
|
|
9048
9092
|
], SDKCreator.prototype, "openProfilePicker", null);
|
|
9049
9093
|
__decorate([
|
|
9050
|
-
handleError,
|
|
9051
|
-
validate,
|
|
9052
9094
|
__param(0, required(['SSID'])),
|
|
9053
9095
|
__param(0, checkType('object', {
|
|
9054
9096
|
SSID: checkData('string'),
|
|
@@ -9057,8 +9099,6 @@ __decorate([
|
|
|
9057
9099
|
}))
|
|
9058
9100
|
], SDKCreator.prototype, "connectWifi", null);
|
|
9059
9101
|
__decorate([
|
|
9060
|
-
handleError,
|
|
9061
|
-
validate,
|
|
9062
9102
|
__param(0, checkType('object', {
|
|
9063
9103
|
type: checkData('string', {
|
|
9064
9104
|
values: ['photo', 'video', 'file']
|
|
@@ -9073,8 +9113,6 @@ __decorate([
|
|
|
9073
9113
|
}))
|
|
9074
9114
|
], SDKCreator.prototype, "openMediaPicker", null);
|
|
9075
9115
|
__decorate([
|
|
9076
|
-
handleError,
|
|
9077
|
-
validate,
|
|
9078
9116
|
__param(0, checkType('object', {
|
|
9079
9117
|
title: checkData('string', { maxLength: 100 }),
|
|
9080
9118
|
'thumbnail?': checkData('url'),
|
|
@@ -9084,14 +9122,9 @@ __decorate([
|
|
|
9084
9122
|
description: ''
|
|
9085
9123
|
}))
|
|
9086
9124
|
], SDKCreator.prototype, "getShareableLink", null);
|
|
9087
|
-
__decorate([
|
|
9088
|
-
|
|
9089
|
-
|
|
9090
|
-
], SDKCreator.prototype, "closeLoading", null);
|
|
9091
|
-
__decorate([
|
|
9092
|
-
handleError,
|
|
9093
|
-
validate
|
|
9094
|
-
], SDKCreator.prototype, "requestUpdateZalo", null);
|
|
9125
|
+
SDKCreator = __decorate([
|
|
9126
|
+
DecorateAll(centralizedFunctionHandler)
|
|
9127
|
+
], SDKCreator);
|
|
9095
9128
|
class ZaloMiniAppSDKCreator extends SDKCreator {
|
|
9096
9129
|
getServiceInstance() {
|
|
9097
9130
|
return ZaloMiniProgramSDKService.getInstance();
|
|
@@ -9287,7 +9320,7 @@ class MockPaymentService {
|
|
|
9287
9320
|
_MockPaymentService_appId = new WeakMap();
|
|
9288
9321
|
|
|
9289
9322
|
var _PaymentCreator_instance, _PaymentCreator_sdk;
|
|
9290
|
-
class PaymentCreator {
|
|
9323
|
+
let PaymentCreator = class PaymentCreator {
|
|
9291
9324
|
constructor(sdk) {
|
|
9292
9325
|
_PaymentCreator_instance.set(this, void 0);
|
|
9293
9326
|
_PaymentCreator_sdk.set(this, void 0);
|
|
@@ -9295,42 +9328,50 @@ class PaymentCreator {
|
|
|
9295
9328
|
__classPrivateFieldSet(this, _PaymentCreator_sdk, sdk, "f");
|
|
9296
9329
|
}
|
|
9297
9330
|
/**
|
|
9298
|
-
|
|
9299
|
-
|
|
9300
|
-
|
|
9301
|
-
|
|
9302
|
-
|
|
9303
|
-
|
|
9304
|
-
|
|
9331
|
+
* Tạo đơn hàng
|
|
9332
|
+
*
|
|
9333
|
+
* @async
|
|
9334
|
+
* @function createOrder
|
|
9335
|
+
* @category Payment
|
|
9336
|
+
* @returns {Promise<CallbackDataType.CreateOrderCallBack>}
|
|
9337
|
+
*/
|
|
9305
9338
|
createOrder(object) {
|
|
9306
9339
|
return __classPrivateFieldGet(this, _PaymentCreator_instance, "f").createOrder(__classPrivateFieldGet(this, _PaymentCreator_sdk, "f"), object);
|
|
9307
9340
|
}
|
|
9308
9341
|
/**
|
|
9309
|
-
|
|
9310
|
-
|
|
9311
|
-
|
|
9312
|
-
|
|
9313
|
-
|
|
9314
|
-
|
|
9315
|
-
|
|
9342
|
+
* Lấy thông tin transaction
|
|
9343
|
+
*
|
|
9344
|
+
* @async
|
|
9345
|
+
* @function checkTransaction
|
|
9346
|
+
* @category Payment
|
|
9347
|
+
* @returns {Promise<CallbackDataType.CheckTransactionSuccessCallBack>}
|
|
9348
|
+
*/
|
|
9316
9349
|
checkTransaction(object) {
|
|
9317
9350
|
return __classPrivateFieldGet(this, _PaymentCreator_instance, "f").checkTransaction(__classPrivateFieldGet(this, _PaymentCreator_sdk, "f"), object);
|
|
9318
9351
|
}
|
|
9319
|
-
}
|
|
9352
|
+
};
|
|
9320
9353
|
_PaymentCreator_instance = new WeakMap(), _PaymentCreator_sdk = new WeakMap();
|
|
9321
9354
|
__decorate([
|
|
9322
|
-
handleError,
|
|
9323
|
-
validate,
|
|
9324
9355
|
__param(0, checkType('object', {
|
|
9325
|
-
|
|
9326
|
-
|
|
9327
|
-
'method?': checkData('string', {
|
|
9356
|
+
amount: checkData(['string', 'number']),
|
|
9357
|
+
desc: checkData('string'),
|
|
9358
|
+
'method?': checkData('string', {
|
|
9359
|
+
values: [
|
|
9360
|
+
'MOMO',
|
|
9361
|
+
'ZALOPAY',
|
|
9362
|
+
'MOMO_SANDBOX',
|
|
9363
|
+
'ZALOPAY_SANDBOX',
|
|
9364
|
+
'CC',
|
|
9365
|
+
'CC_SANDBOX',
|
|
9366
|
+
'ATM',
|
|
9367
|
+
'ATM_SANDBOX'
|
|
9368
|
+
]
|
|
9369
|
+
})
|
|
9328
9370
|
}))
|
|
9329
9371
|
], PaymentCreator.prototype, "createOrder", null);
|
|
9330
|
-
__decorate([
|
|
9331
|
-
|
|
9332
|
-
|
|
9333
|
-
], PaymentCreator.prototype, "checkTransaction", null);
|
|
9372
|
+
PaymentCreator = __decorate([
|
|
9373
|
+
DecorateAll(centralizedFunctionHandler)
|
|
9374
|
+
], PaymentCreator);
|
|
9334
9375
|
class ZaloMiniAppPaymentCreator extends PaymentCreator {
|
|
9335
9376
|
getInstance() {
|
|
9336
9377
|
return PaymentService.getInstance();
|
|
@@ -9372,4 +9413,4 @@ else {
|
|
|
9372
9413
|
window.ZaloMiniAppSDK = app;
|
|
9373
9414
|
|
|
9374
9415
|
export default app;
|
|
9375
|
-
export { ChatType, Events, MediaPickerType,
|
|
9416
|
+
export { ChatType, Events, MediaPickerType, NetworkType, OrientationType, payment as Payment, PlatformType, PostFeedType, ProfileType, SDKCreator, ShareSheetType, VibrateType };
|