zmp-sdk 2.15.2 → 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.2";
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
  });
@@ -38653,10 +38567,10 @@
38653
38567
  }
38654
38568
  }
38655
38569
 
38656
- 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;
38657
38571
  class ZaloMiniProgramSDK extends ZJSBridgeProvider {
38658
38572
  constructor() {
38659
- var _a, _b, _c, _d;
38573
+ var _a, _b, _c, _d, _e, _f, _g, _h;
38660
38574
  super();
38661
38575
  _ZaloMiniProgramSDK_zAppId.set(this, window.zAppID);
38662
38576
  _ZaloMiniProgramSDK_appId.set(this, window.APP_ID);
@@ -38674,47 +38588,13 @@
38674
38588
  _ZaloMiniProgramSDK_tokenExpiresIn.set(this, void 0);
38675
38589
  _ZaloMiniProgramSDK_cookies.set(this, null);
38676
38590
  this.events = ZMPEEmitter.getInstance();
38677
- _ZaloMiniProgramSDK_configWindow.set(this, () => {
38678
- const appConfig = __classPrivateFieldGet(this, _ZaloMiniProgramSDK_appConfig).app || null;
38679
- if (appConfig) {
38680
- const navbarTitle = appConfig.title;
38681
- const actionBarColor = appConfig.headerColor;
38682
- const textColor = appConfig.textColor;
38683
- const statusBarColor = appConfig.statusBarColor;
38684
- const navbarLeftButton = appConfig.leftButton;
38685
- if (lodash.isString(navbarTitle)) {
38686
- this.setNavigationBarTitle({
38687
- title: navbarTitle
38688
- });
38689
- }
38690
- if (lodash.isString(actionBarColor)) {
38691
- const data = {
38692
- color: actionBarColor
38693
- };
38694
- if (lodash.isString(textColor) &&
38695
- (textColor === 'black' || textColor === 'white')) {
38696
- data.textColor = textColor;
38697
- }
38698
- if (lodash.isString(statusBarColor)) {
38699
- data.statusBarColor = statusBarColor;
38700
- }
38701
- this.setNavigationBarColor(data);
38702
- }
38703
- if (lodash.isString(navbarLeftButton)) {
38704
- this.setNavigationBarLeftButton({
38705
- type: navbarLeftButton
38706
- });
38707
- }
38708
- }
38709
- });
38710
- _ZaloMiniProgramSDK_configApp.set(this, () => {
38711
- try {
38712
- __classPrivateFieldGet(this, _ZaloMiniProgramSDK_configWindow, "f").call(this);
38713
- }
38714
- catch (_error) {
38715
- console.error(_error);
38716
- }
38717
- });
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
+ };
38718
38598
  _ZaloMiniProgramSDK_callJump.set(this, () => {
38719
38599
  return new Promise((resolve, reject) => {
38720
38600
  if (!lodash.isUndefined(__classPrivateFieldGet(this, _ZaloMiniProgramSDK_cookies)) && !lodash.isNull(__classPrivateFieldGet(this, _ZaloMiniProgramSDK_cookies))) {
@@ -38804,7 +38684,33 @@
38804
38684
  this.isShowNavBar = true;
38805
38685
  __classPrivateFieldSet(this, _ZaloMiniProgramSDK_prevGetTokenTimestamp, 0);
38806
38686
  __classPrivateFieldSet(this, _ZaloMiniProgramSDK_tokenExpiresIn, 0);
38807
- this.isShowHomeButton = ((_b = (_a = __classPrivateFieldGet(this, _ZaloMiniProgramSDK_appConfig)) === null || _a === void 0 ? void 0 : _a.app) === null || _b === void 0 ? void 0 : _b.leftButton) === 'home' || ((_d = (_c = __classPrivateFieldGet(this, _ZaloMiniProgramSDK_appConfig)) === null || _c === void 0 ? void 0 : _c.app) === null || _d === void 0 ? void 0 : _d.leftButton) === 'both';
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
+ });
38808
38714
  }
38809
38715
  static getInstance() {
38810
38716
  if (!ZaloMiniProgramSDK.instance) {
@@ -38925,7 +38831,7 @@
38925
38831
  });
38926
38832
  }
38927
38833
  }
38928
- _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();
38929
38835
 
38930
38836
  var _MockSDK_appId, _MockSDK_appConfig, _MockSDK_zOAuth, _MockSDK_accessToken, _MockSDK_cache, _MockSDK_loggedId;
38931
38837
  class MockSDK {
package/dist/index.es.js CHANGED
@@ -21875,7 +21875,15 @@ const ZALO_IOS_ACTIONS_SUPPORTED_BEFORE_VER_402 = [
21875
21875
  ACTION.CHANGE_ACTIONBAR.name,
21876
21876
  ACTION.INTERACTIVE_VIBRATION.name,
21877
21877
  ACTION.ZBROWSER_MPDS.name
21878
- ];
21878
+ ];
21879
+ const ACTION_LEFT_BUTTON_TYPE = {
21880
+ SHOW_BACK: 0,
21881
+ HIDE_BACK: 3,
21882
+ SHOW_HOME: 1,
21883
+ HIDE_HOME: 0
21884
+ };
21885
+ const SHOW_ACTION_BAR = 5;
21886
+ const HIDE_ACTION_BAR = 6;
21879
21887
 
21880
21888
  const REGEXP_SPECIAL_UNICODE = new RegExp('[\\u0300-\\u036f]', 'g');
21881
21889
  const REGEXP_ACCENT_D = new RegExp('[đ|Đ]', 'g');
@@ -36519,6 +36527,7 @@ var _ZJSBridgeProvider_bridge;
36519
36527
  class ZJSBridgeProvider {
36520
36528
  /** @ignore */
36521
36529
  constructor() {
36530
+ this.debug = src('zmp:ZJSBridgeProvider');
36522
36531
  _ZJSBridgeProvider_bridge.set(this, void 0);
36523
36532
  __classPrivateFieldSet(this, _ZJSBridgeProvider_bridge, ZaloJSBridge.getInstance());
36524
36533
  }
@@ -36529,6 +36538,7 @@ class ZJSBridgeProvider {
36529
36538
  __classPrivateFieldGet(this, _ZJSBridgeProvider_bridge).jsAccessTk = value;
36530
36539
  }
36531
36540
  callNative(action, data, option) {
36541
+ this.debug(action, data);
36532
36542
  return new Promise((resolve, reject) => {
36533
36543
  const fn = (cb) => __awaiter(this, void 0, void 0, function* () {
36534
36544
  try {
@@ -36586,7 +36596,7 @@ const apiResponse = {
36586
36596
  }
36587
36597
  };
36588
36598
 
36589
- var version = "2.15.2";
36599
+ var version = "2.15.3";
36590
36600
 
36591
36601
  class Basics {
36592
36602
  /**
@@ -36721,75 +36731,27 @@ class NavigationBar {
36721
36731
  */
36722
36732
  static setNavigationBarColor(object) {
36723
36733
  return __awaiter(this, void 0, void 0, function* () {
36734
+ const dataConfig = {};
36735
+ let actionBarType;
36736
+ if (!lodash.isEmpty(object.textColor)) {
36737
+ dataConfig.textColor = object.textColor;
36738
+ }
36724
36739
  if (lodash.isString(object.color) && object.color.length > 0) {
36725
- // if (!this.isShowNavBar) {
36726
- // const dataConfig: {
36727
- // backgroundColor?: string;
36728
- // textColor?: 'black' | 'white';
36729
- // } = {};
36730
- // if (!_.isEmpty(object.color)) {
36731
- // dataConfig.backgroundColor = object.color;
36732
- // }
36733
- // if (!_.isEmpty(object.textColor)) {
36734
- // dataConfig.textColor = object.textColor;
36735
- // }
36736
- // await this.callNative(ACTION.CHANGE_ACTIONBAR.name, {
36737
- // actionbarType: 5,
36738
- // dataConfig: dataConfig,
36739
- // homeConfig: {
36740
- // enable: this.isShowHomeButton ? 1 : 0,
36741
- // url: `${config.MINI_APP_INTERNAL_LINK}/${this.getAppId()}/`
36742
- // }
36743
- // });
36744
- // this.isShowNavBar = true;
36745
- // } else {
36746
- // const dataConfig: {
36747
- // data?: string;
36748
- // textColor?: 'black' | 'white';
36749
- // } = {};
36750
- // if (!_.isEmpty(object.color)) {
36751
- // dataConfig.data = object.color;
36752
- // }
36753
- // if (!_.isEmpty(object.textColor)) {
36754
- // dataConfig.textColor = object.textColor;
36755
- // }
36756
- // await this.callNative(ACTION.CHANGE_ACTIONBAR_COLOR.name, dataConfig);
36757
- // }
36758
- const dataConfig = {};
36759
36740
  if (!lodash.isEmpty(object.color)) {
36760
36741
  dataConfig.backgroundColor = object.color;
36761
36742
  }
36762
- if (!lodash.isEmpty(object.textColor)) {
36763
- dataConfig.textColor = object.textColor;
36764
- }
36765
- yield this.callNative(ACTION.CHANGE_ACTIONBAR.name, {
36766
- actionbarType: 5,
36767
- dataConfig: dataConfig,
36768
- homeConfig: {
36769
- enable: this.isShowHomeButton ? 1 : 0,
36770
- url: `${CONFIG.MINI_APP_INTERNAL_LINK}/${this.getAppId()}/`
36771
- }
36772
- }, {
36773
- haveTimeout: false
36774
- });
36775
- this.isShowNavBar = true;
36743
+ actionBarType = SHOW_ACTION_BAR;
36776
36744
  }
36777
36745
  else {
36778
- const dataConfig = {};
36779
36746
  if (!lodash.isEmpty(object.statusBarColor)) {
36780
36747
  dataConfig.backgroundColor = object.statusBarColor;
36781
36748
  }
36782
- if (!lodash.isEmpty(object.textColor)) {
36783
- dataConfig.textColor = object.textColor;
36784
- }
36785
- yield this.callNative(ACTION.CHANGE_ACTIONBAR.name, {
36786
- actionbarType: 6,
36787
- dataConfig: dataConfig
36788
- }, {
36789
- haveTimeout: false
36790
- });
36791
- this.isShowNavBar = false;
36749
+ actionBarType = HIDE_ACTION_BAR;
36792
36750
  }
36751
+ this.setActionBarConfig((state) => (Object.assign(Object.assign({}, state), { actionbarType: actionBarType, dataConfig: Object.assign(Object.assign({}, state.dataConfig), dataConfig) })));
36752
+ yield this.callNative(ACTION.CHANGE_ACTIONBAR.name, Object.assign({}, this.getActionBarConfig()), {
36753
+ haveTimeout: false
36754
+ });
36793
36755
  });
36794
36756
  }
36795
36757
  /**
@@ -36824,62 +36786,14 @@ class NavigationBar {
36824
36786
  */
36825
36787
  static setNavigationBarLeftButton(object) {
36826
36788
  return __awaiter(this, void 0, void 0, function* () {
36827
- let reqData = {};
36828
- switch (object.type) {
36829
- case 'none':
36830
- this.isShowHomeButton = false;
36831
- reqData = {
36832
- buttonType: 3,
36833
- dataConfig: {
36834
- confirmToExit: 1
36835
- },
36836
- homeConfig: {
36837
- enable: 0,
36838
- url: `${CONFIG.MINI_APP_INTERNAL_LINK}/${this.getAppId()}/`
36839
- }
36840
- };
36841
- break;
36842
- case 'back':
36843
- this.isShowHomeButton = false;
36844
- reqData = {
36845
- buttonType: 0,
36846
- dataConfig: {
36847
- confirmToExit: 1
36848
- },
36849
- homeConfig: {
36850
- enable: 0,
36851
- url: `${CONFIG.MINI_APP_INTERNAL_LINK}/${this.getAppId()}/`
36852
- }
36853
- };
36854
- break;
36855
- case 'home':
36856
- this.isShowHomeButton = true;
36857
- reqData = {
36858
- buttonType: 3,
36859
- dataConfig: {
36860
- confirmToExit: 1
36861
- },
36862
- homeConfig: {
36863
- enable: 1,
36864
- url: `${CONFIG.MINI_APP_INTERNAL_LINK}/${this.getAppId()}/`
36865
- }
36866
- };
36867
- break;
36868
- case 'both':
36869
- this.isShowHomeButton = true;
36870
- reqData = {
36871
- buttonType: 0,
36872
- dataConfig: {
36873
- confirmToExit: 1
36874
- },
36875
- homeConfig: {
36876
- enable: 1,
36877
- url: `${CONFIG.MINI_APP_INTERNAL_LINK}/${this.getAppId()}/`
36878
- }
36879
- };
36880
- break;
36881
- }
36882
- yield this.callNative(ACTION.CHANGE_ACTIONBAR_LEFTBUTTON_TYPE.name, Object.assign({}, reqData), {
36789
+ const leftButtonType = object.type === 'none' || object.type === 'home'
36790
+ ? ACTION_LEFT_BUTTON_TYPE.HIDE_BACK
36791
+ : ACTION_LEFT_BUTTON_TYPE.SHOW_BACK;
36792
+ const showHomeButton = object.type === 'home' || object.type === 'both'
36793
+ ? ACTION_LEFT_BUTTON_TYPE.SHOW_HOME
36794
+ : ACTION_LEFT_BUTTON_TYPE.HIDE_HOME;
36795
+ 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 }) })));
36796
+ yield this.callNative(ACTION.CHANGE_ACTIONBAR_LEFTBUTTON_TYPE.name, Object.assign({}, this.getActionBarConfig()), {
36883
36797
  haveTimeout: false
36884
36798
  });
36885
36799
  });
@@ -38650,10 +38564,10 @@ class Routing {
38650
38564
  }
38651
38565
  }
38652
38566
 
38653
- 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;
38567
+ 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;
38654
38568
  class ZaloMiniProgramSDK extends ZJSBridgeProvider {
38655
38569
  constructor() {
38656
- var _a, _b, _c, _d;
38570
+ var _a, _b, _c, _d, _e, _f, _g, _h;
38657
38571
  super();
38658
38572
  _ZaloMiniProgramSDK_zAppId.set(this, window.zAppID);
38659
38573
  _ZaloMiniProgramSDK_appId.set(this, window.APP_ID);
@@ -38671,47 +38585,13 @@ class ZaloMiniProgramSDK extends ZJSBridgeProvider {
38671
38585
  _ZaloMiniProgramSDK_tokenExpiresIn.set(this, void 0);
38672
38586
  _ZaloMiniProgramSDK_cookies.set(this, null);
38673
38587
  this.events = ZMPEEmitter.getInstance();
38674
- _ZaloMiniProgramSDK_configWindow.set(this, () => {
38675
- const appConfig = __classPrivateFieldGet(this, _ZaloMiniProgramSDK_appConfig).app || null;
38676
- if (appConfig) {
38677
- const navbarTitle = appConfig.title;
38678
- const actionBarColor = appConfig.headerColor;
38679
- const textColor = appConfig.textColor;
38680
- const statusBarColor = appConfig.statusBarColor;
38681
- const navbarLeftButton = appConfig.leftButton;
38682
- if (lodash.isString(navbarTitle)) {
38683
- this.setNavigationBarTitle({
38684
- title: navbarTitle
38685
- });
38686
- }
38687
- if (lodash.isString(actionBarColor)) {
38688
- const data = {
38689
- color: actionBarColor
38690
- };
38691
- if (lodash.isString(textColor) &&
38692
- (textColor === 'black' || textColor === 'white')) {
38693
- data.textColor = textColor;
38694
- }
38695
- if (lodash.isString(statusBarColor)) {
38696
- data.statusBarColor = statusBarColor;
38697
- }
38698
- this.setNavigationBarColor(data);
38699
- }
38700
- if (lodash.isString(navbarLeftButton)) {
38701
- this.setNavigationBarLeftButton({
38702
- type: navbarLeftButton
38703
- });
38704
- }
38705
- }
38706
- });
38707
- _ZaloMiniProgramSDK_configApp.set(this, () => {
38708
- try {
38709
- __classPrivateFieldGet(this, _ZaloMiniProgramSDK_configWindow, "f").call(this);
38710
- }
38711
- catch (_error) {
38712
- console.error(_error);
38713
- }
38714
- });
38588
+ _ZaloMiniProgramSDK_actionBarConfig.set(this, void 0);
38589
+ this.getActionBarConfig = () => {
38590
+ return __classPrivateFieldGet(this, _ZaloMiniProgramSDK_actionBarConfig);
38591
+ };
38592
+ this.setActionBarConfig = (setState) => {
38593
+ __classPrivateFieldSet(this, _ZaloMiniProgramSDK_actionBarConfig, setState(__classPrivateFieldGet(this, _ZaloMiniProgramSDK_actionBarConfig)));
38594
+ };
38715
38595
  _ZaloMiniProgramSDK_callJump.set(this, () => {
38716
38596
  return new Promise((resolve, reject) => {
38717
38597
  if (!lodash.isUndefined(__classPrivateFieldGet(this, _ZaloMiniProgramSDK_cookies)) && !lodash.isNull(__classPrivateFieldGet(this, _ZaloMiniProgramSDK_cookies))) {
@@ -38801,7 +38681,33 @@ class ZaloMiniProgramSDK extends ZJSBridgeProvider {
38801
38681
  this.isShowNavBar = true;
38802
38682
  __classPrivateFieldSet(this, _ZaloMiniProgramSDK_prevGetTokenTimestamp, 0);
38803
38683
  __classPrivateFieldSet(this, _ZaloMiniProgramSDK_tokenExpiresIn, 0);
38804
- this.isShowHomeButton = ((_b = (_a = __classPrivateFieldGet(this, _ZaloMiniProgramSDK_appConfig)) === null || _a === void 0 ? void 0 : _a.app) === null || _b === void 0 ? void 0 : _b.leftButton) === 'home' || ((_d = (_c = __classPrivateFieldGet(this, _ZaloMiniProgramSDK_appConfig)) === null || _c === void 0 ? void 0 : _c.app) === null || _d === void 0 ? void 0 : _d.leftButton) === 'both';
38684
+ 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' ||
38685
+ ((_d = (_c = __classPrivateFieldGet(this, _ZaloMiniProgramSDK_appConfig)) === null || _c === void 0 ? void 0 : _c.app) === null || _d === void 0 ? void 0 : _d.leftButton) === 'both'
38686
+ ? ACTION_LEFT_BUTTON_TYPE.SHOW_HOME
38687
+ : ACTION_LEFT_BUTTON_TYPE.HIDE_HOME;
38688
+ const currentUrl = new URL(location.href);
38689
+ const actionBarType = lodash.isString(__classPrivateFieldGet(this, _ZaloMiniProgramSDK_appConfig).app.headerColor) &&
38690
+ __classPrivateFieldGet(this, _ZaloMiniProgramSDK_appConfig).app.headerColor.length > 0
38691
+ ? SHOW_ACTION_BAR
38692
+ : HIDE_ACTION_BAR;
38693
+ 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' ||
38694
+ ((_h = (_g = __classPrivateFieldGet(this, _ZaloMiniProgramSDK_appConfig)) === null || _g === void 0 ? void 0 : _g.app) === null || _h === void 0 ? void 0 : _h.leftButton) === 'home'
38695
+ ? ACTION_LEFT_BUTTON_TYPE.HIDE_BACK
38696
+ : ACTION_LEFT_BUTTON_TYPE.SHOW_BACK;
38697
+ __classPrivateFieldSet(this, _ZaloMiniProgramSDK_actionBarConfig, {
38698
+ actionbarType: actionBarType,
38699
+ buttonType: leftButtonType,
38700
+ dataConfig: {
38701
+ backgroundColor: __classPrivateFieldGet(this, _ZaloMiniProgramSDK_appConfig).app.headerColor || '',
38702
+ textColor: __classPrivateFieldGet(this, _ZaloMiniProgramSDK_appConfig).app.textColor || '',
38703
+ viewInLeftType: leftButtonType,
38704
+ confirmToExit: 1
38705
+ },
38706
+ homeConfig: {
38707
+ enable: showHomeButton,
38708
+ url: `${CONFIG.MINI_APP_INTERNAL_LINK}/${this.getAppId()}/${currentUrl.search}`
38709
+ }
38710
+ });
38805
38711
  }
38806
38712
  static getInstance() {
38807
38713
  if (!ZaloMiniProgramSDK.instance) {
@@ -38922,7 +38828,7 @@ class ZaloMiniProgramSDK extends ZJSBridgeProvider {
38922
38828
  });
38923
38829
  }
38924
38830
  }
38925
- _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();
38831
+ _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();
38926
38832
 
38927
38833
  var _MockSDK_appId, _MockSDK_appConfig, _MockSDK_zOAuth, _MockSDK_accessToken, _MockSDK_cache, _MockSDK_loggedId;
38928
38834
  class MockSDK {