zmp-sdk 2.15.0-rc.5 → 2.15.3

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.
@@ -21878,7 +21878,15 @@
21878
21878
  ACTION.CHANGE_ACTIONBAR.name,
21879
21879
  ACTION.INTERACTIVE_VIBRATION.name,
21880
21880
  ACTION.ZBROWSER_MPDS.name
21881
- ];
21881
+ ];
21882
+ const ACTION_LEFT_BUTTON_TYPE = {
21883
+ SHOW_BACK: 0,
21884
+ HIDE_BACK: 3,
21885
+ SHOW_HOME: 1,
21886
+ HIDE_HOME: 0
21887
+ };
21888
+ const SHOW_ACTION_BAR = 5;
21889
+ const HIDE_ACTION_BAR = 6;
21882
21890
 
21883
21891
  const REGEXP_SPECIAL_UNICODE = new RegExp('[\\u0300-\\u036f]', 'g');
21884
21892
  const REGEXP_ACCENT_D = new RegExp('[đ|Đ]', 'g');
@@ -36522,6 +36530,7 @@
36522
36530
  class ZJSBridgeProvider {
36523
36531
  /** @ignore */
36524
36532
  constructor() {
36533
+ this.debug = src('zmp:ZJSBridgeProvider');
36525
36534
  _ZJSBridgeProvider_bridge.set(this, void 0);
36526
36535
  __classPrivateFieldSet(this, _ZJSBridgeProvider_bridge, ZaloJSBridge.getInstance());
36527
36536
  }
@@ -36532,6 +36541,7 @@
36532
36541
  __classPrivateFieldGet(this, _ZJSBridgeProvider_bridge).jsAccessTk = value;
36533
36542
  }
36534
36543
  callNative(action, data, option) {
36544
+ this.debug(action, data);
36535
36545
  return new Promise((resolve, reject) => {
36536
36546
  const fn = (cb) => __awaiter(this, void 0, void 0, function* () {
36537
36547
  try {
@@ -36589,7 +36599,7 @@
36589
36599
  }
36590
36600
  };
36591
36601
 
36592
- var version = "2.15.0-rc.5";
36602
+ var version = "2.15.3";
36593
36603
 
36594
36604
  class Basics {
36595
36605
  /**
@@ -36724,75 +36734,27 @@
36724
36734
  */
36725
36735
  static setNavigationBarColor(object) {
36726
36736
  return __awaiter(this, void 0, void 0, function* () {
36737
+ const dataConfig = {};
36738
+ let actionBarType;
36739
+ if (!lodash.isEmpty(object.textColor)) {
36740
+ dataConfig.textColor = object.textColor;
36741
+ }
36727
36742
  if (lodash.isString(object.color) && object.color.length > 0) {
36728
- // if (!this.isShowNavBar) {
36729
- // const dataConfig: {
36730
- // backgroundColor?: string;
36731
- // textColor?: 'black' | 'white';
36732
- // } = {};
36733
- // if (!_.isEmpty(object.color)) {
36734
- // dataConfig.backgroundColor = object.color;
36735
- // }
36736
- // if (!_.isEmpty(object.textColor)) {
36737
- // dataConfig.textColor = object.textColor;
36738
- // }
36739
- // await this.callNative(ACTION.CHANGE_ACTIONBAR.name, {
36740
- // actionbarType: 5,
36741
- // dataConfig: dataConfig,
36742
- // homeConfig: {
36743
- // enable: this.isShowHomeButton ? 1 : 0,
36744
- // url: `${config.MINI_APP_INTERNAL_LINK}/${this.getAppId()}/`
36745
- // }
36746
- // });
36747
- // this.isShowNavBar = true;
36748
- // } else {
36749
- // const dataConfig: {
36750
- // data?: string;
36751
- // textColor?: 'black' | 'white';
36752
- // } = {};
36753
- // if (!_.isEmpty(object.color)) {
36754
- // dataConfig.data = object.color;
36755
- // }
36756
- // if (!_.isEmpty(object.textColor)) {
36757
- // dataConfig.textColor = object.textColor;
36758
- // }
36759
- // await this.callNative(ACTION.CHANGE_ACTIONBAR_COLOR.name, dataConfig);
36760
- // }
36761
- const dataConfig = {};
36762
36743
  if (!lodash.isEmpty(object.color)) {
36763
36744
  dataConfig.backgroundColor = object.color;
36764
36745
  }
36765
- if (!lodash.isEmpty(object.textColor)) {
36766
- dataConfig.textColor = object.textColor;
36767
- }
36768
- yield this.callNative(ACTION.CHANGE_ACTIONBAR.name, {
36769
- actionbarType: 5,
36770
- dataConfig: dataConfig,
36771
- homeConfig: {
36772
- enable: this.isShowHomeButton ? 1 : 0,
36773
- url: `${CONFIG.MINI_APP_INTERNAL_LINK}/${this.getAppId()}/`
36774
- }
36775
- }, {
36776
- haveTimeout: false
36777
- });
36778
- this.isShowNavBar = true;
36746
+ actionBarType = SHOW_ACTION_BAR;
36779
36747
  }
36780
36748
  else {
36781
- const dataConfig = {};
36782
36749
  if (!lodash.isEmpty(object.statusBarColor)) {
36783
36750
  dataConfig.backgroundColor = object.statusBarColor;
36784
36751
  }
36785
- if (!lodash.isEmpty(object.textColor)) {
36786
- dataConfig.textColor = object.textColor;
36787
- }
36788
- yield this.callNative(ACTION.CHANGE_ACTIONBAR.name, {
36789
- actionbarType: 6,
36790
- dataConfig: dataConfig
36791
- }, {
36792
- haveTimeout: false
36793
- });
36794
- this.isShowNavBar = false;
36752
+ actionBarType = HIDE_ACTION_BAR;
36795
36753
  }
36754
+ this.setActionBarConfig((state) => (Object.assign(Object.assign({}, state), { actionbarType: actionBarType, dataConfig: Object.assign(Object.assign({}, state.dataConfig), dataConfig) })));
36755
+ yield this.callNative(ACTION.CHANGE_ACTIONBAR.name, Object.assign({}, this.getActionBarConfig()), {
36756
+ haveTimeout: false
36757
+ });
36796
36758
  });
36797
36759
  }
36798
36760
  /**
@@ -36827,62 +36789,14 @@
36827
36789
  */
36828
36790
  static setNavigationBarLeftButton(object) {
36829
36791
  return __awaiter(this, void 0, void 0, function* () {
36830
- let reqData = {};
36831
- switch (object.type) {
36832
- case 'none':
36833
- this.isShowHomeButton = false;
36834
- reqData = {
36835
- buttonType: 3,
36836
- dataConfig: {
36837
- confirmToExit: 1
36838
- },
36839
- homeConfig: {
36840
- enable: 0,
36841
- url: `${CONFIG.MINI_APP_INTERNAL_LINK}/${this.getAppId()}/`
36842
- }
36843
- };
36844
- break;
36845
- case 'back':
36846
- this.isShowHomeButton = false;
36847
- reqData = {
36848
- buttonType: 0,
36849
- dataConfig: {
36850
- confirmToExit: 1
36851
- },
36852
- homeConfig: {
36853
- enable: 0,
36854
- url: `${CONFIG.MINI_APP_INTERNAL_LINK}/${this.getAppId()}/`
36855
- }
36856
- };
36857
- break;
36858
- case 'home':
36859
- this.isShowHomeButton = true;
36860
- reqData = {
36861
- buttonType: 3,
36862
- dataConfig: {
36863
- confirmToExit: 1
36864
- },
36865
- homeConfig: {
36866
- enable: 1,
36867
- url: `${CONFIG.MINI_APP_INTERNAL_LINK}/${this.getAppId()}/`
36868
- }
36869
- };
36870
- break;
36871
- case 'both':
36872
- this.isShowHomeButton = true;
36873
- reqData = {
36874
- buttonType: 0,
36875
- dataConfig: {
36876
- confirmToExit: 1
36877
- },
36878
- homeConfig: {
36879
- enable: 1,
36880
- url: `${CONFIG.MINI_APP_INTERNAL_LINK}/${this.getAppId()}/`
36881
- }
36882
- };
36883
- break;
36884
- }
36885
- yield this.callNative(ACTION.CHANGE_ACTIONBAR_LEFTBUTTON_TYPE.name, Object.assign({}, reqData), {
36792
+ const leftButtonType = object.type === 'none' || object.type === 'home'
36793
+ ? ACTION_LEFT_BUTTON_TYPE.HIDE_BACK
36794
+ : ACTION_LEFT_BUTTON_TYPE.SHOW_BACK;
36795
+ const showHomeButton = object.type === 'home' || object.type === 'both'
36796
+ ? ACTION_LEFT_BUTTON_TYPE.SHOW_HOME
36797
+ : ACTION_LEFT_BUTTON_TYPE.HIDE_HOME;
36798
+ this.setActionBarConfig((state) => (Object.assign(Object.assign({}, state), { buttonType: leftButtonType, dataConfig: Object.assign(Object.assign({}, state.dataConfig), { viewInLeftType: leftButtonType }), homeConfig: Object.assign(Object.assign({}, state.homeConfig), { enable: showHomeButton }) })));
36799
+ yield this.callNative(ACTION.CHANGE_ACTIONBAR_LEFTBUTTON_TYPE.name, Object.assign({}, this.getActionBarConfig()), {
36886
36800
  haveTimeout: false
36887
36801
  });
36888
36802
  });
@@ -38496,10 +38410,9 @@
38496
38410
  if (!resData || resData.err !== 0) {
38497
38411
  throw apiResponse.error.cannotGetShareInfo();
38498
38412
  }
38499
- const zaloVersion = getZaloVersion();
38500
- const platform = checkPlatform();
38501
- if ((platform.isAndroid && zaloVersion % 100000 <= 593) ||
38502
- (platform.isIOS && zaloVersion <= 424)) {
38413
+ getZaloVersion();
38414
+ checkPlatform();
38415
+ {
38503
38416
  validUrl.search = `${validUrl.search}&zshareId=${resData.data.shareId}`;
38504
38417
  reqData = {
38505
38418
  link: validUrl.href,
@@ -38507,23 +38420,6 @@
38507
38420
  };
38508
38421
  object.type = 'link';
38509
38422
  }
38510
- else {
38511
- reqData = {
38512
- data: {
38513
- ZInstantAPIInfo: {
38514
- url: `${resData.data.zinstantApi}`,
38515
- zinstantdata_id: `templateId=11412&appId=${this.getAppId()}&shareId=${resData.data.shareId}`
38516
- },
38517
- previewMsgText: {
38518
- msg: {
38519
- en: description.en,
38520
- vi: description.vi
38521
- }
38522
- },
38523
- enableReactions: 1
38524
- }
38525
- };
38526
- }
38527
38423
  }
38528
38424
  return yield this.callNative(ACTION.OPEN_SHARESHEET.name, Object.assign(Object.assign({ type: ShareSheetType[object.type] }, reqData), { zapp: this.getZAppId() }), {
38529
38425
  haveTimeout: false
@@ -38671,9 +38567,10 @@
38671
38567
  }
38672
38568
  }
38673
38569
 
38674
- var _ZaloMiniProgramSDK_zAppId, _ZaloMiniProgramSDK_appId, _ZaloMiniProgramSDK_appConfig, _ZaloMiniProgramSDK_zOAuth, _ZaloMiniProgramSDK_zOAuthVrf, _ZaloMiniProgramSDK_accessToken, _ZaloMiniProgramSDK_refreshToken, _ZaloMiniProgramSDK_cache, _ZaloMiniProgramSDK_prevGetTokenTimestamp, _ZaloMiniProgramSDK_tokenExpiresIn, _ZaloMiniProgramSDK_cookies, _ZaloMiniProgramSDK_configWindow, _ZaloMiniProgramSDK_configApp, _ZaloMiniProgramSDK_callJump, _ZaloMiniProgramSDK_setNavigationBarRightButton, _ZaloMiniProgramSDK_getActionsSupported;
38570
+ var _ZaloMiniProgramSDK_zAppId, _ZaloMiniProgramSDK_appId, _ZaloMiniProgramSDK_appConfig, _ZaloMiniProgramSDK_zOAuth, _ZaloMiniProgramSDK_zOAuthVrf, _ZaloMiniProgramSDK_accessToken, _ZaloMiniProgramSDK_refreshToken, _ZaloMiniProgramSDK_cache, _ZaloMiniProgramSDK_prevGetTokenTimestamp, _ZaloMiniProgramSDK_tokenExpiresIn, _ZaloMiniProgramSDK_cookies, _ZaloMiniProgramSDK_actionBarConfig, _ZaloMiniProgramSDK_callJump, _ZaloMiniProgramSDK_setNavigationBarRightButton, _ZaloMiniProgramSDK_getActionsSupported;
38675
38571
  class ZaloMiniProgramSDK extends ZJSBridgeProvider {
38676
38572
  constructor() {
38573
+ var _a, _b, _c, _d, _e, _f, _g, _h;
38677
38574
  super();
38678
38575
  _ZaloMiniProgramSDK_zAppId.set(this, window.zAppID);
38679
38576
  _ZaloMiniProgramSDK_appId.set(this, window.APP_ID);
@@ -38691,47 +38588,13 @@
38691
38588
  _ZaloMiniProgramSDK_tokenExpiresIn.set(this, void 0);
38692
38589
  _ZaloMiniProgramSDK_cookies.set(this, null);
38693
38590
  this.events = ZMPEEmitter.getInstance();
38694
- _ZaloMiniProgramSDK_configWindow.set(this, () => {
38695
- const appConfig = __classPrivateFieldGet(this, _ZaloMiniProgramSDK_appConfig).app || null;
38696
- if (appConfig) {
38697
- const navbarTitle = appConfig.title;
38698
- const actionBarColor = appConfig.headerColor;
38699
- const textColor = appConfig.textColor;
38700
- const statusBarColor = appConfig.statusBarColor;
38701
- const navbarLeftButton = appConfig.leftButton;
38702
- if (lodash.isString(navbarTitle)) {
38703
- this.setNavigationBarTitle({
38704
- title: navbarTitle
38705
- });
38706
- }
38707
- if (lodash.isString(actionBarColor)) {
38708
- const data = {
38709
- color: actionBarColor
38710
- };
38711
- if (lodash.isString(textColor) &&
38712
- (textColor === 'black' || textColor === 'white')) {
38713
- data.textColor = textColor;
38714
- }
38715
- if (lodash.isString(statusBarColor)) {
38716
- data.statusBarColor = statusBarColor;
38717
- }
38718
- this.setNavigationBarColor(data);
38719
- }
38720
- if (lodash.isString(navbarLeftButton)) {
38721
- this.setNavigationBarLeftButton({
38722
- type: navbarLeftButton
38723
- });
38724
- }
38725
- }
38726
- });
38727
- _ZaloMiniProgramSDK_configApp.set(this, () => {
38728
- try {
38729
- __classPrivateFieldGet(this, _ZaloMiniProgramSDK_configWindow, "f").call(this);
38730
- }
38731
- catch (_error) {
38732
- console.error(_error);
38733
- }
38734
- });
38591
+ _ZaloMiniProgramSDK_actionBarConfig.set(this, void 0);
38592
+ this.getActionBarConfig = () => {
38593
+ return __classPrivateFieldGet(this, _ZaloMiniProgramSDK_actionBarConfig);
38594
+ };
38595
+ this.setActionBarConfig = (setState) => {
38596
+ __classPrivateFieldSet(this, _ZaloMiniProgramSDK_actionBarConfig, setState(__classPrivateFieldGet(this, _ZaloMiniProgramSDK_actionBarConfig)));
38597
+ };
38735
38598
  _ZaloMiniProgramSDK_callJump.set(this, () => {
38736
38599
  return new Promise((resolve, reject) => {
38737
38600
  if (!lodash.isUndefined(__classPrivateFieldGet(this, _ZaloMiniProgramSDK_cookies)) && !lodash.isNull(__classPrivateFieldGet(this, _ZaloMiniProgramSDK_cookies))) {
@@ -38819,10 +38682,35 @@
38819
38682
  __classPrivateFieldSet(this, _ZaloMiniProgramSDK_zOAuthVrf, null);
38820
38683
  __classPrivateFieldSet(this, _ZaloMiniProgramSDK_accessToken, null);
38821
38684
  this.isShowNavBar = true;
38822
- this.isShowHomeButton = true;
38823
38685
  __classPrivateFieldSet(this, _ZaloMiniProgramSDK_prevGetTokenTimestamp, 0);
38824
38686
  __classPrivateFieldSet(this, _ZaloMiniProgramSDK_tokenExpiresIn, 0);
38825
- // this.#configApp();
38687
+ const showHomeButton = ((_b = (_a = __classPrivateFieldGet(this, _ZaloMiniProgramSDK_appConfig)) === null || _a === void 0 ? void 0 : _a.app) === null || _b === void 0 ? void 0 : _b.leftButton) === 'home' ||
38688
+ ((_d = (_c = __classPrivateFieldGet(this, _ZaloMiniProgramSDK_appConfig)) === null || _c === void 0 ? void 0 : _c.app) === null || _d === void 0 ? void 0 : _d.leftButton) === 'both'
38689
+ ? ACTION_LEFT_BUTTON_TYPE.SHOW_HOME
38690
+ : ACTION_LEFT_BUTTON_TYPE.HIDE_HOME;
38691
+ const currentUrl = new URL(location.href);
38692
+ const actionBarType = lodash.isString(__classPrivateFieldGet(this, _ZaloMiniProgramSDK_appConfig).app.headerColor) &&
38693
+ __classPrivateFieldGet(this, _ZaloMiniProgramSDK_appConfig).app.headerColor.length > 0
38694
+ ? SHOW_ACTION_BAR
38695
+ : HIDE_ACTION_BAR;
38696
+ const leftButtonType = ((_f = (_e = __classPrivateFieldGet(this, _ZaloMiniProgramSDK_appConfig)) === null || _e === void 0 ? void 0 : _e.app) === null || _f === void 0 ? void 0 : _f.leftButton) === 'none' ||
38697
+ ((_h = (_g = __classPrivateFieldGet(this, _ZaloMiniProgramSDK_appConfig)) === null || _g === void 0 ? void 0 : _g.app) === null || _h === void 0 ? void 0 : _h.leftButton) === 'home'
38698
+ ? ACTION_LEFT_BUTTON_TYPE.HIDE_BACK
38699
+ : ACTION_LEFT_BUTTON_TYPE.SHOW_BACK;
38700
+ __classPrivateFieldSet(this, _ZaloMiniProgramSDK_actionBarConfig, {
38701
+ actionbarType: actionBarType,
38702
+ buttonType: leftButtonType,
38703
+ dataConfig: {
38704
+ backgroundColor: __classPrivateFieldGet(this, _ZaloMiniProgramSDK_appConfig).app.headerColor || '',
38705
+ textColor: __classPrivateFieldGet(this, _ZaloMiniProgramSDK_appConfig).app.textColor || '',
38706
+ viewInLeftType: leftButtonType,
38707
+ confirmToExit: 1
38708
+ },
38709
+ homeConfig: {
38710
+ enable: showHomeButton,
38711
+ url: `${CONFIG.MINI_APP_INTERNAL_LINK}/${this.getAppId()}/${currentUrl.search}`
38712
+ }
38713
+ });
38826
38714
  }
38827
38715
  static getInstance() {
38828
38716
  if (!ZaloMiniProgramSDK.instance) {
@@ -38943,7 +38831,7 @@
38943
38831
  });
38944
38832
  }
38945
38833
  }
38946
- _ZaloMiniProgramSDK_zAppId = new WeakMap(), _ZaloMiniProgramSDK_appId = new WeakMap(), _ZaloMiniProgramSDK_appConfig = new WeakMap(), _ZaloMiniProgramSDK_zOAuth = new WeakMap(), _ZaloMiniProgramSDK_zOAuthVrf = new WeakMap(), _ZaloMiniProgramSDK_accessToken = new WeakMap(), _ZaloMiniProgramSDK_refreshToken = new WeakMap(), _ZaloMiniProgramSDK_cache = new WeakMap(), _ZaloMiniProgramSDK_prevGetTokenTimestamp = new WeakMap(), _ZaloMiniProgramSDK_tokenExpiresIn = new WeakMap(), _ZaloMiniProgramSDK_cookies = new WeakMap(), _ZaloMiniProgramSDK_configWindow = new WeakMap(), _ZaloMiniProgramSDK_configApp = new WeakMap(), _ZaloMiniProgramSDK_callJump = new WeakMap(), _ZaloMiniProgramSDK_setNavigationBarRightButton = new WeakMap(), _ZaloMiniProgramSDK_getActionsSupported = new WeakMap();
38834
+ _ZaloMiniProgramSDK_zAppId = new WeakMap(), _ZaloMiniProgramSDK_appId = new WeakMap(), _ZaloMiniProgramSDK_appConfig = new WeakMap(), _ZaloMiniProgramSDK_zOAuth = new WeakMap(), _ZaloMiniProgramSDK_zOAuthVrf = new WeakMap(), _ZaloMiniProgramSDK_accessToken = new WeakMap(), _ZaloMiniProgramSDK_refreshToken = new WeakMap(), _ZaloMiniProgramSDK_cache = new WeakMap(), _ZaloMiniProgramSDK_prevGetTokenTimestamp = new WeakMap(), _ZaloMiniProgramSDK_tokenExpiresIn = new WeakMap(), _ZaloMiniProgramSDK_cookies = new WeakMap(), _ZaloMiniProgramSDK_actionBarConfig = new WeakMap(), _ZaloMiniProgramSDK_callJump = new WeakMap(), _ZaloMiniProgramSDK_setNavigationBarRightButton = new WeakMap(), _ZaloMiniProgramSDK_getActionsSupported = new WeakMap();
38947
38835
 
38948
38836
  var _MockSDK_appId, _MockSDK_appConfig, _MockSDK_zOAuth, _MockSDK_accessToken, _MockSDK_cache, _MockSDK_loggedId;
38949
38837
  class MockSDK {