@sunggang/ui-lib 0.4.41 → 0.4.42

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.
@@ -709,9 +709,9 @@ var LiffProvider = function(param) {
709
709
  case 0:
710
710
  _state.trys.push([
711
711
  0,
712
- 9,
712
+ 12,
713
713
  ,
714
- 10
714
+ 13
715
715
  ]);
716
716
  customFetch = // 自訂 fetch 函數,避免每次請求都改變 URL
717
717
  // eslint-disable-next-line no-inner-declarations
@@ -730,19 +730,10 @@ var LiffProvider = function(param) {
730
730
  originalFetch = window.fetch;
731
731
  window.fetch = customFetch;
732
732
  if (openInApp && !(liff === null || liff === void 0 ? void 0 : liff.isInClient()) && (liff === null || liff === void 0 ? void 0 : liff.getOS()) !== "web") window.location.href = "line://app/".concat(liffId);
733
- return [
734
- 4,
735
- liff.init({
736
- liffId: liffId,
737
- withLoginOnExternalBrowser: false
738
- })
739
- ];
740
- case 2:
741
- _state.sent();
742
733
  console.log("LIFF init succeeded.");
743
734
  setLiffObject(liff);
744
735
  lineToken = liff === null || liff === void 0 ? void 0 : liff.getAccessToken();
745
- // 未登入先進行登入
736
+ // 未登入先進行登入(呼叫 login 後立即 return,避免後續執行 init)
746
737
  if (!liff.isLoggedIn()) {
747
738
  redirectUri = customerRedirectUrl || "".concat(window.location.href);
748
739
  if (liffLogin) {
@@ -759,42 +750,72 @@ var LiffProvider = function(param) {
759
750
  liff.login({
760
751
  redirectUri: redirectUri
761
752
  });
753
+ return [
754
+ 2
755
+ ];
762
756
  }
757
+ if (!!liff.isLoggedIn()) return [
758
+ 3,
759
+ 3
760
+ ];
761
+ return [
762
+ 4,
763
+ liff.init({
764
+ liffId: liffId,
765
+ withLoginOnExternalBrowser: false
766
+ })
767
+ ];
768
+ case 2:
769
+ _state.sent();
770
+ return [
771
+ 3,
772
+ 4
773
+ ];
774
+ case 3:
775
+ console.log("LIFF 已登入,跳過 liff.init() 以避免重複的 verify/profile 呼叫。");
776
+ _state.label = 4;
777
+ case 4:
763
778
  tempFriendship = null;
764
779
  if (!lineToken) return [
765
780
  3,
766
- 8
781
+ 11
767
782
  ];
768
- _state.label = 3;
769
- case 3:
783
+ _state.label = 5;
784
+ case 5:
770
785
  _state.trys.push([
771
- 3,
772
786
  5,
787
+ 8,
773
788
  ,
774
- 6
789
+ 9
775
790
  ]);
791
+ if (!!liff.isLoggedIn()) return [
792
+ 3,
793
+ 7
794
+ ];
776
795
  return [
777
796
  4,
778
797
  liff.getFriendship()
779
798
  ];
780
- case 4:
799
+ case 6:
781
800
  friendship = _state.sent();
782
801
  friendFlag = friendship === null || friendship === void 0 ? void 0 : friendship.friendFlag;
783
802
  setFriendship(friendFlag);
784
803
  tempFriendship = friendFlag;
785
804
  console.log("isFriendship", friendFlag);
805
+ _state.label = 7;
806
+ case 7:
786
807
  return [
787
808
  3,
788
- 6
809
+ 9
789
810
  ];
790
- case 5:
811
+ case 8:
791
812
  error = _state.sent();
792
813
  console.error("Error in liff.getFriendship():", error);
793
814
  return [
794
815
  3,
795
- 6
816
+ 9
796
817
  ];
797
- case 6:
818
+ case 9:
798
819
  console.log("isValid", isValid);
799
820
  if (tempFriendship && isValid) return [
800
821
  2
@@ -803,23 +824,23 @@ var LiffProvider = function(param) {
803
824
  4,
804
825
  loginInit(lineToken)
805
826
  ];
806
- case 7:
827
+ case 10:
807
828
  _state.sent();
808
- _state.label = 8;
809
- case 8:
829
+ _state.label = 11;
830
+ case 11:
810
831
  return [
811
832
  3,
812
- 10
833
+ 13
813
834
  ];
814
- case 9:
835
+ case 12:
815
836
  err = _state.sent();
816
837
  setLiffError(err.toString());
817
838
  console.log("LIFF init failed.", err);
818
839
  return [
819
840
  3,
820
- 10
841
+ 13
821
842
  ];
822
- case 10:
843
+ case 13:
823
844
  return [
824
845
  2
825
846
  ];
@@ -705,9 +705,9 @@ var LiffProvider = function(param) {
705
705
  case 0:
706
706
  _state.trys.push([
707
707
  0,
708
- 9,
708
+ 12,
709
709
  ,
710
- 10
710
+ 13
711
711
  ]);
712
712
  customFetch = // 自訂 fetch 函數,避免每次請求都改變 URL
713
713
  // eslint-disable-next-line no-inner-declarations
@@ -726,19 +726,10 @@ var LiffProvider = function(param) {
726
726
  originalFetch = window.fetch;
727
727
  window.fetch = customFetch;
728
728
  if (openInApp && !(liff === null || liff === void 0 ? void 0 : liff.isInClient()) && (liff === null || liff === void 0 ? void 0 : liff.getOS()) !== "web") window.location.href = "line://app/".concat(liffId);
729
- return [
730
- 4,
731
- liff.init({
732
- liffId: liffId,
733
- withLoginOnExternalBrowser: false
734
- })
735
- ];
736
- case 2:
737
- _state.sent();
738
729
  console.log("LIFF init succeeded.");
739
730
  setLiffObject(liff);
740
731
  lineToken = liff === null || liff === void 0 ? void 0 : liff.getAccessToken();
741
- // 未登入先進行登入
732
+ // 未登入先進行登入(呼叫 login 後立即 return,避免後續執行 init)
742
733
  if (!liff.isLoggedIn()) {
743
734
  redirectUri = customerRedirectUrl || "".concat(window.location.href);
744
735
  if (liffLogin) {
@@ -755,42 +746,72 @@ var LiffProvider = function(param) {
755
746
  liff.login({
756
747
  redirectUri: redirectUri
757
748
  });
749
+ return [
750
+ 2
751
+ ];
758
752
  }
753
+ if (!!liff.isLoggedIn()) return [
754
+ 3,
755
+ 3
756
+ ];
757
+ return [
758
+ 4,
759
+ liff.init({
760
+ liffId: liffId,
761
+ withLoginOnExternalBrowser: false
762
+ })
763
+ ];
764
+ case 2:
765
+ _state.sent();
766
+ return [
767
+ 3,
768
+ 4
769
+ ];
770
+ case 3:
771
+ console.log("LIFF 已登入,跳過 liff.init() 以避免重複的 verify/profile 呼叫。");
772
+ _state.label = 4;
773
+ case 4:
759
774
  tempFriendship = null;
760
775
  if (!lineToken) return [
761
776
  3,
762
- 8
777
+ 11
763
778
  ];
764
- _state.label = 3;
765
- case 3:
779
+ _state.label = 5;
780
+ case 5:
766
781
  _state.trys.push([
767
- 3,
768
782
  5,
783
+ 8,
769
784
  ,
770
- 6
785
+ 9
771
786
  ]);
787
+ if (!!liff.isLoggedIn()) return [
788
+ 3,
789
+ 7
790
+ ];
772
791
  return [
773
792
  4,
774
793
  liff.getFriendship()
775
794
  ];
776
- case 4:
795
+ case 6:
777
796
  friendship = _state.sent();
778
797
  friendFlag = friendship === null || friendship === void 0 ? void 0 : friendship.friendFlag;
779
798
  setFriendship(friendFlag);
780
799
  tempFriendship = friendFlag;
781
800
  console.log("isFriendship", friendFlag);
801
+ _state.label = 7;
802
+ case 7:
782
803
  return [
783
804
  3,
784
- 6
805
+ 9
785
806
  ];
786
- case 5:
807
+ case 8:
787
808
  error = _state.sent();
788
809
  console.error("Error in liff.getFriendship():", error);
789
810
  return [
790
811
  3,
791
- 6
812
+ 9
792
813
  ];
793
- case 6:
814
+ case 9:
794
815
  console.log("isValid", isValid);
795
816
  if (tempFriendship && isValid) return [
796
817
  2
@@ -799,23 +820,23 @@ var LiffProvider = function(param) {
799
820
  4,
800
821
  loginInit(lineToken)
801
822
  ];
802
- case 7:
823
+ case 10:
803
824
  _state.sent();
804
- _state.label = 8;
805
- case 8:
825
+ _state.label = 11;
826
+ case 11:
806
827
  return [
807
828
  3,
808
- 10
829
+ 13
809
830
  ];
810
- case 9:
831
+ case 12:
811
832
  err = _state.sent();
812
833
  setLiffError(err.toString());
813
834
  console.log("LIFF init failed.", err);
814
835
  return [
815
836
  3,
816
- 10
837
+ 13
817
838
  ];
818
- case 10:
839
+ case 13:
819
840
  return [
820
841
  2
821
842
  ];
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@sunggang/ui-lib",
3
- "version": "0.4.41",
3
+ "version": "0.4.42",
4
4
  "sideEffects": [
5
5
  "*.css",
6
6
  "./src/style.css",