@sunggang/ui-lib 0.4.45 → 0.4.46

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.
@@ -456,20 +456,17 @@ var LiffContext = /*#__PURE__*/ React.createContext(undefined);
456
456
  var LiffProvider = function(param) {
457
457
  var children = param.children, liffId = param.liffId, _param_localStorageKey = param.localStorageKey, localStorageKey = _param_localStorageKey === void 0 ? "one-gobo-global-login" : _param_localStorageKey, checkTokenUrl = param.checkTokenUrl, loginUrl = param.loginUrl, accountLoginUrl = param.accountLoginUrl, memberInfoUrl = param.memberInfoUrl, _param_openInApp = param.openInApp, openInApp = _param_openInApp === void 0 ? false : _param_openInApp, _param_ignoreCheckAddFriend = param.ignoreCheckAddFriend, ignoreCheckAddFriend = _param_ignoreCheckAddFriend === void 0 ? false : _param_ignoreCheckAddFriend, _param_ignoreRoute = param.ignoreRoute, ignoreRoute = _param_ignoreRoute === void 0 ? false : _param_ignoreRoute, _param_loginByUser = param.loginByUser, loginByUser = _param_loginByUser === void 0 ? false : _param_loginByUser, _param_liffLogin = param.liffLogin, liffLogin = _param_liffLogin === void 0 ? false : _param_liffLogin, customerRedirectUrl = param.customerRedirectUrl, inviteCode = param.inviteCode, handleLoginError = param.handleLoginError;
458
458
  var _useState = _sliced_to_array(React.useState(null), 2), liffObject = _useState[0], setLiffObject = _useState[1];
459
- var _useState1 = _sliced_to_array(React.useState(false), 2), liffInitialized = _useState1[0], setLiffInitialized = _useState1[1];
460
- var _useState2 = _sliced_to_array(React.useState(""), 2), accessToken = _useState2[0], setAccessToken = _useState2[1];
461
- var _useState3 = _sliced_to_array(React.useState(null), 2), liffError = _useState3[0], setLiffError = _useState3[1];
462
- var _useState4 = _sliced_to_array(React.useState(null), 2), loginData = _useState4[0], setLoginData = _useState4[1];
463
- var _useState5 = _sliced_to_array(React.useState(null), 2), userInfo = _useState5[0], setUserInfo = _useState5[1];
464
- var _useState6 = _sliced_to_array(React.useState(null), 2), liffProfile = _useState6[0], setLiffProfile = _useState6[1];
465
- var _useState7 = _sliced_to_array(React.useState(null), 2), isFriendship = _useState7[0], setFriendship = _useState7[1];
466
- var _useState8 = _sliced_to_array(React.useState(null), 2), loginType = _useState8[0], setLoginType = _useState8[1];
459
+ var _useState1 = _sliced_to_array(React.useState(""), 2), accessToken = _useState1[0], setAccessToken = _useState1[1];
460
+ var _useState2 = _sliced_to_array(React.useState(null), 2), liffError = _useState2[0], setLiffError = _useState2[1];
461
+ var _useState3 = _sliced_to_array(React.useState(null), 2), loginData = _useState3[0], setLoginData = _useState3[1];
462
+ var _useState4 = _sliced_to_array(React.useState(null), 2), userInfo = _useState4[0], setUserInfo = _useState4[1];
463
+ var _useState5 = _sliced_to_array(React.useState(null), 2), liffProfile = _useState5[0], setLiffProfile = _useState5[1];
464
+ var _useState6 = _sliced_to_array(React.useState(null), 2), isFriendship = _useState6[0], setFriendship = _useState6[1];
465
+ var _useState7 = _sliced_to_array(React.useState(null), 2), loginType = _useState7[0], setLoginType = _useState7[1];
467
466
  // userInfo 的 localStorage key
468
467
  var userInfoStorageKey = "".concat(localStorageKey, "-userInfo");
469
468
  // liff profile 的 localStorage key
470
469
  var liffProfileStorageKey = "".concat(localStorageKey, "-liffProfile");
471
- // liff initialized flag 的 localStorage key
472
- var liffInitializedStorageKey = "".concat(localStorageKey, "-liffInitialized");
473
470
  // 從 localStorage 載入 userInfo
474
471
  var loadUserInfoFromStorage = function() {
475
472
  try {
@@ -518,16 +515,6 @@ var LiffProvider = function(param) {
518
515
  }, [
519
516
  liffProfileStorageKey
520
517
  ]);
521
- // 儲存 liffInitialized flag 到 localStorage
522
- var saveLiffInitializedToStorage = React.useCallback(function() {
523
- try {
524
- window.localStorage.setItem(liffInitializedStorageKey, "1");
525
- } catch (err) {
526
- console.error("儲存 liffInitialized 失敗:", err);
527
- }
528
- }, [
529
- liffInitializedStorageKey
530
- ]);
531
518
  var fetchMemberInfo = function() {
532
519
  var _ref = _async_to_generator(function(token) {
533
520
  var response, err;
@@ -636,13 +623,6 @@ var LiffProvider = function(param) {
636
623
  // token 無效時清除 userInfo
637
624
  setUserInfo(null);
638
625
  window.localStorage.removeItem(userInfoStorageKey);
639
- // token 無效也清除 liff 相關快取與已初始化標記
640
- try {
641
- window.localStorage.removeItem(liffProfileStorageKey);
642
- window.localStorage.removeItem(liffInitializedStorageKey);
643
- } catch (e) {
644
- // ignore
645
- }
646
626
  return [
647
627
  3,
648
628
  7
@@ -762,10 +742,9 @@ var LiffProvider = function(param) {
762
742
  ,
763
743
  11
764
744
  ]);
765
- // 確保 LIFF 已初始化(只執行一次)
766
745
  return [
767
746
  4,
768
- ensureLiffInitialized()
747
+ ensureLiffInitialized(isValid)
769
748
  ];
770
749
  case 1:
771
750
  _state.sent();
@@ -777,6 +756,9 @@ var LiffProvider = function(param) {
777
756
  imported = _state.sent();
778
757
  sdk = liffObject || imported.liff;
779
758
  setLiffObject(sdk);
759
+ if (sdk.isLoggedIn() && isValid) return [
760
+ 2
761
+ ];
780
762
  lineToken = sdk === null || sdk === void 0 ? void 0 : (_sdk_getAccessToken = sdk.getAccessToken) === null || _sdk_getAccessToken === void 0 ? void 0 : _sdk_getAccessToken.call(sdk);
781
763
  // 未登入先進行登入(呼叫 login 後立即 return,避免後續執行)
782
764
  if (!(sdk === null || sdk === void 0 ? void 0 : (_sdk_isLoggedIn = sdk.isLoggedIn) === null || _sdk_isLoggedIn === void 0 ? void 0 : _sdk_isLoggedIn.call(sdk))) {
@@ -876,123 +858,92 @@ var LiffProvider = function(param) {
876
858
  };
877
859
  }();
878
860
  // 確保 LIFF init 只執行一次且在需要時才執行
879
- var ensureLiffInitialized = React.useCallback(/*#__PURE__*/ _async_to_generator(function() {
880
- var storedFlag, customFetch, liff, originalFetch, profile, e1;
881
- return _ts_generator(this, function(_state) {
882
- switch(_state.label){
883
- case 0:
884
- console.log("ensureLiffInitialized called", liffInitialized);
885
- // 如果 state 或 localStorage 上已有 initialized 的標記,就視為已初始化
886
- if (liffInitialized) return [
887
- 2
888
- ];
889
- try {
890
- storedFlag = window.localStorage.getItem(liffInitializedStorageKey);
891
- if (storedFlag === "1") {
892
- setLiffInitialized(true);
893
- console.log("liffInitialized loaded from storage");
861
+ var ensureLiffInitialized = React.useCallback(function() {
862
+ var _ref = _async_to_generator(function(isValid) {
863
+ var customFetch, liff, originalFetch, profile, e;
864
+ return _ts_generator(this, function(_state) {
865
+ switch(_state.label){
866
+ case 0:
867
+ if (!liffId) {
868
+ console.warn("liffId 未提供,跳過 liff.init()。");
894
869
  return [
895
870
  2
896
871
  ];
897
872
  }
898
- } catch (e) {
899
- // ignore
900
- }
901
- if (!liffId) {
902
- console.warn("liffId 未提供,跳過 liff.init()。");
873
+ _state.label = 1;
874
+ case 1:
875
+ _state.trys.push([
876
+ 1,
877
+ 5,
878
+ ,
879
+ 6
880
+ ]);
881
+ customFetch = // 自訂 fetch 函數,避免每次請求都改變 URL
882
+ // eslint-disable-next-line no-inner-declarations
883
+ function customFetch(url, options) {
884
+ if (url.toString().startsWith("https://liffsdk.line-scdn.net/xlt/") && url.toString().endsWith(".json")) {
885
+ url = "".concat(url, "?ts=").concat(Math.random());
886
+ }
887
+ return originalFetch(url, options);
888
+ };
903
889
  return [
904
- 2
890
+ 4,
891
+ Promise.resolve().then(function () { return require('./index.cjs3.js'); })
905
892
  ];
906
- }
907
- _state.label = 1;
908
- case 1:
909
- _state.trys.push([
910
- 1,
911
- 8,
912
- ,
913
- 9
914
- ]);
915
- customFetch = // 自訂 fetch 函數,避免每次請求都改變 URL
916
- // eslint-disable-next-line no-inner-declarations
917
- function customFetch(url, options) {
918
- if (url.toString().startsWith("https://liffsdk.line-scdn.net/xlt/") && url.toString().endsWith(".json")) {
919
- url = "".concat(url, "?ts=").concat(Math.random());
893
+ case 2:
894
+ liff = _state.sent().liff;
895
+ originalFetch = window.fetch;
896
+ window.fetch = customFetch;
897
+ 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);
898
+ if (liff.isLoggedIn() && isValid) {
899
+ console.log("LIFF already initialized.");
900
+ return [
901
+ 2
902
+ ];
920
903
  }
921
- return originalFetch(url, options);
922
- };
923
- return [
924
- 4,
925
- Promise.resolve().then(function () { return require('./index.cjs3.js'); })
926
- ];
927
- case 2:
928
- liff = _state.sent().liff;
929
- originalFetch = window.fetch;
930
- window.fetch = customFetch;
931
- 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);
932
- return [
933
- 4,
934
- liff.init({
935
- liffId: liffId,
936
- withLoginOnExternalBrowser: false
937
- })
938
- ];
939
- case 3:
940
- _state.sent();
941
- _state.label = 4;
942
- case 4:
943
- _state.trys.push([
944
- 4,
945
- 6,
946
- ,
947
- 7
948
- ]);
949
- return [
950
- 4,
951
- liff.getProfile()
952
- ];
953
- case 5:
954
- profile = _state.sent();
955
- setLiffProfile(profile);
956
- saveLiffProfileToStorage(profile);
957
- return [
958
- 3,
959
- 7
960
- ];
961
- case 6:
962
- _state.sent();
963
- return [
964
- 3,
965
- 7
966
- ];
967
- case 7:
968
- setLiffObject(liff);
969
- setLiffInitialized(true);
970
- saveLiffInitializedToStorage();
971
- console.log("LIFF initialized.");
972
- return [
973
- 3,
974
- 9
975
- ];
976
- case 8:
977
- e1 = _state.sent();
978
- console.error("ensureLiffInitialized failed:", e1);
979
- return [
980
- 3,
981
- 9
982
- ];
983
- case 9:
984
- return [
985
- 2
986
- ];
987
- }
904
+ return [
905
+ 4,
906
+ liff.init({
907
+ liffId: liffId,
908
+ withLoginOnExternalBrowser: false
909
+ })
910
+ ];
911
+ case 3:
912
+ _state.sent();
913
+ return [
914
+ 4,
915
+ liff.getProfile()
916
+ ];
917
+ case 4:
918
+ profile = _state.sent();
919
+ setLiffProfile(profile);
920
+ saveLiffProfileToStorage(profile);
921
+ setLiffObject(liff);
922
+ console.log("LIFF initialized.");
923
+ return [
924
+ 3,
925
+ 6
926
+ ];
927
+ case 5:
928
+ e = _state.sent();
929
+ console.error("ensureLiffInitialized failed:", e);
930
+ return [
931
+ 3,
932
+ 6
933
+ ];
934
+ case 6:
935
+ return [
936
+ 2
937
+ ];
938
+ }
939
+ });
988
940
  });
989
- }), [
990
- liffInitialized,
941
+ return function(isValid) {
942
+ return _ref.apply(this, arguments);
943
+ };
944
+ }(), [
991
945
  liffId,
992
- openInApp,
993
- saveLiffInitializedToStorage,
994
- saveLiffProfileToStorage,
995
- liffInitializedStorageKey
946
+ openInApp
996
947
  ]);
997
948
  var accountLogin = function() {
998
949
  var _ref = _async_to_generator(function(username, password) {
@@ -452,20 +452,17 @@ var LiffContext = /*#__PURE__*/ createContext(undefined);
452
452
  var LiffProvider = function(param) {
453
453
  var children = param.children, liffId = param.liffId, _param_localStorageKey = param.localStorageKey, localStorageKey = _param_localStorageKey === void 0 ? "one-gobo-global-login" : _param_localStorageKey, checkTokenUrl = param.checkTokenUrl, loginUrl = param.loginUrl, accountLoginUrl = param.accountLoginUrl, memberInfoUrl = param.memberInfoUrl, _param_openInApp = param.openInApp, openInApp = _param_openInApp === void 0 ? false : _param_openInApp, _param_ignoreCheckAddFriend = param.ignoreCheckAddFriend, ignoreCheckAddFriend = _param_ignoreCheckAddFriend === void 0 ? false : _param_ignoreCheckAddFriend, _param_ignoreRoute = param.ignoreRoute, ignoreRoute = _param_ignoreRoute === void 0 ? false : _param_ignoreRoute, _param_loginByUser = param.loginByUser, loginByUser = _param_loginByUser === void 0 ? false : _param_loginByUser, _param_liffLogin = param.liffLogin, liffLogin = _param_liffLogin === void 0 ? false : _param_liffLogin, customerRedirectUrl = param.customerRedirectUrl, inviteCode = param.inviteCode, handleLoginError = param.handleLoginError;
454
454
  var _useState = _sliced_to_array(useState(null), 2), liffObject = _useState[0], setLiffObject = _useState[1];
455
- var _useState1 = _sliced_to_array(useState(false), 2), liffInitialized = _useState1[0], setLiffInitialized = _useState1[1];
456
- var _useState2 = _sliced_to_array(useState(""), 2), accessToken = _useState2[0], setAccessToken = _useState2[1];
457
- var _useState3 = _sliced_to_array(useState(null), 2), liffError = _useState3[0], setLiffError = _useState3[1];
458
- var _useState4 = _sliced_to_array(useState(null), 2), loginData = _useState4[0], setLoginData = _useState4[1];
459
- var _useState5 = _sliced_to_array(useState(null), 2), userInfo = _useState5[0], setUserInfo = _useState5[1];
460
- var _useState6 = _sliced_to_array(useState(null), 2), liffProfile = _useState6[0], setLiffProfile = _useState6[1];
461
- var _useState7 = _sliced_to_array(useState(null), 2), isFriendship = _useState7[0], setFriendship = _useState7[1];
462
- var _useState8 = _sliced_to_array(useState(null), 2), loginType = _useState8[0], setLoginType = _useState8[1];
455
+ var _useState1 = _sliced_to_array(useState(""), 2), accessToken = _useState1[0], setAccessToken = _useState1[1];
456
+ var _useState2 = _sliced_to_array(useState(null), 2), liffError = _useState2[0], setLiffError = _useState2[1];
457
+ var _useState3 = _sliced_to_array(useState(null), 2), loginData = _useState3[0], setLoginData = _useState3[1];
458
+ var _useState4 = _sliced_to_array(useState(null), 2), userInfo = _useState4[0], setUserInfo = _useState4[1];
459
+ var _useState5 = _sliced_to_array(useState(null), 2), liffProfile = _useState5[0], setLiffProfile = _useState5[1];
460
+ var _useState6 = _sliced_to_array(useState(null), 2), isFriendship = _useState6[0], setFriendship = _useState6[1];
461
+ var _useState7 = _sliced_to_array(useState(null), 2), loginType = _useState7[0], setLoginType = _useState7[1];
463
462
  // userInfo 的 localStorage key
464
463
  var userInfoStorageKey = "".concat(localStorageKey, "-userInfo");
465
464
  // liff profile 的 localStorage key
466
465
  var liffProfileStorageKey = "".concat(localStorageKey, "-liffProfile");
467
- // liff initialized flag 的 localStorage key
468
- var liffInitializedStorageKey = "".concat(localStorageKey, "-liffInitialized");
469
466
  // 從 localStorage 載入 userInfo
470
467
  var loadUserInfoFromStorage = function() {
471
468
  try {
@@ -514,16 +511,6 @@ var LiffProvider = function(param) {
514
511
  }, [
515
512
  liffProfileStorageKey
516
513
  ]);
517
- // 儲存 liffInitialized flag 到 localStorage
518
- var saveLiffInitializedToStorage = useCallback(function() {
519
- try {
520
- window.localStorage.setItem(liffInitializedStorageKey, "1");
521
- } catch (err) {
522
- console.error("儲存 liffInitialized 失敗:", err);
523
- }
524
- }, [
525
- liffInitializedStorageKey
526
- ]);
527
514
  var fetchMemberInfo = function() {
528
515
  var _ref = _async_to_generator(function(token) {
529
516
  var response, err;
@@ -632,13 +619,6 @@ var LiffProvider = function(param) {
632
619
  // token 無效時清除 userInfo
633
620
  setUserInfo(null);
634
621
  window.localStorage.removeItem(userInfoStorageKey);
635
- // token 無效也清除 liff 相關快取與已初始化標記
636
- try {
637
- window.localStorage.removeItem(liffProfileStorageKey);
638
- window.localStorage.removeItem(liffInitializedStorageKey);
639
- } catch (e) {
640
- // ignore
641
- }
642
622
  return [
643
623
  3,
644
624
  7
@@ -758,10 +738,9 @@ var LiffProvider = function(param) {
758
738
  ,
759
739
  11
760
740
  ]);
761
- // 確保 LIFF 已初始化(只執行一次)
762
741
  return [
763
742
  4,
764
- ensureLiffInitialized()
743
+ ensureLiffInitialized(isValid)
765
744
  ];
766
745
  case 1:
767
746
  _state.sent();
@@ -773,6 +752,9 @@ var LiffProvider = function(param) {
773
752
  imported = _state.sent();
774
753
  sdk = liffObject || imported.liff;
775
754
  setLiffObject(sdk);
755
+ if (sdk.isLoggedIn() && isValid) return [
756
+ 2
757
+ ];
776
758
  lineToken = sdk === null || sdk === void 0 ? void 0 : (_sdk_getAccessToken = sdk.getAccessToken) === null || _sdk_getAccessToken === void 0 ? void 0 : _sdk_getAccessToken.call(sdk);
777
759
  // 未登入先進行登入(呼叫 login 後立即 return,避免後續執行)
778
760
  if (!(sdk === null || sdk === void 0 ? void 0 : (_sdk_isLoggedIn = sdk.isLoggedIn) === null || _sdk_isLoggedIn === void 0 ? void 0 : _sdk_isLoggedIn.call(sdk))) {
@@ -872,123 +854,92 @@ var LiffProvider = function(param) {
872
854
  };
873
855
  }();
874
856
  // 確保 LIFF init 只執行一次且在需要時才執行
875
- var ensureLiffInitialized = useCallback(/*#__PURE__*/ _async_to_generator(function() {
876
- var storedFlag, customFetch, liff, originalFetch, profile, e1;
877
- return _ts_generator(this, function(_state) {
878
- switch(_state.label){
879
- case 0:
880
- console.log("ensureLiffInitialized called", liffInitialized);
881
- // 如果 state 或 localStorage 上已有 initialized 的標記,就視為已初始化
882
- if (liffInitialized) return [
883
- 2
884
- ];
885
- try {
886
- storedFlag = window.localStorage.getItem(liffInitializedStorageKey);
887
- if (storedFlag === "1") {
888
- setLiffInitialized(true);
889
- console.log("liffInitialized loaded from storage");
857
+ var ensureLiffInitialized = useCallback(function() {
858
+ var _ref = _async_to_generator(function(isValid) {
859
+ var customFetch, liff, originalFetch, profile, e;
860
+ return _ts_generator(this, function(_state) {
861
+ switch(_state.label){
862
+ case 0:
863
+ if (!liffId) {
864
+ console.warn("liffId 未提供,跳過 liff.init()。");
890
865
  return [
891
866
  2
892
867
  ];
893
868
  }
894
- } catch (e) {
895
- // ignore
896
- }
897
- if (!liffId) {
898
- console.warn("liffId 未提供,跳過 liff.init()。");
869
+ _state.label = 1;
870
+ case 1:
871
+ _state.trys.push([
872
+ 1,
873
+ 5,
874
+ ,
875
+ 6
876
+ ]);
877
+ customFetch = // 自訂 fetch 函數,避免每次請求都改變 URL
878
+ // eslint-disable-next-line no-inner-declarations
879
+ function customFetch(url, options) {
880
+ if (url.toString().startsWith("https://liffsdk.line-scdn.net/xlt/") && url.toString().endsWith(".json")) {
881
+ url = "".concat(url, "?ts=").concat(Math.random());
882
+ }
883
+ return originalFetch(url, options);
884
+ };
899
885
  return [
900
- 2
886
+ 4,
887
+ import('./index.esm3.js')
901
888
  ];
902
- }
903
- _state.label = 1;
904
- case 1:
905
- _state.trys.push([
906
- 1,
907
- 8,
908
- ,
909
- 9
910
- ]);
911
- customFetch = // 自訂 fetch 函數,避免每次請求都改變 URL
912
- // eslint-disable-next-line no-inner-declarations
913
- function customFetch(url, options) {
914
- if (url.toString().startsWith("https://liffsdk.line-scdn.net/xlt/") && url.toString().endsWith(".json")) {
915
- url = "".concat(url, "?ts=").concat(Math.random());
889
+ case 2:
890
+ liff = _state.sent().liff;
891
+ originalFetch = window.fetch;
892
+ window.fetch = customFetch;
893
+ 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);
894
+ if (liff.isLoggedIn() && isValid) {
895
+ console.log("LIFF already initialized.");
896
+ return [
897
+ 2
898
+ ];
916
899
  }
917
- return originalFetch(url, options);
918
- };
919
- return [
920
- 4,
921
- import('./index.esm3.js')
922
- ];
923
- case 2:
924
- liff = _state.sent().liff;
925
- originalFetch = window.fetch;
926
- window.fetch = customFetch;
927
- 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);
928
- return [
929
- 4,
930
- liff.init({
931
- liffId: liffId,
932
- withLoginOnExternalBrowser: false
933
- })
934
- ];
935
- case 3:
936
- _state.sent();
937
- _state.label = 4;
938
- case 4:
939
- _state.trys.push([
940
- 4,
941
- 6,
942
- ,
943
- 7
944
- ]);
945
- return [
946
- 4,
947
- liff.getProfile()
948
- ];
949
- case 5:
950
- profile = _state.sent();
951
- setLiffProfile(profile);
952
- saveLiffProfileToStorage(profile);
953
- return [
954
- 3,
955
- 7
956
- ];
957
- case 6:
958
- _state.sent();
959
- return [
960
- 3,
961
- 7
962
- ];
963
- case 7:
964
- setLiffObject(liff);
965
- setLiffInitialized(true);
966
- saveLiffInitializedToStorage();
967
- console.log("LIFF initialized.");
968
- return [
969
- 3,
970
- 9
971
- ];
972
- case 8:
973
- e1 = _state.sent();
974
- console.error("ensureLiffInitialized failed:", e1);
975
- return [
976
- 3,
977
- 9
978
- ];
979
- case 9:
980
- return [
981
- 2
982
- ];
983
- }
900
+ return [
901
+ 4,
902
+ liff.init({
903
+ liffId: liffId,
904
+ withLoginOnExternalBrowser: false
905
+ })
906
+ ];
907
+ case 3:
908
+ _state.sent();
909
+ return [
910
+ 4,
911
+ liff.getProfile()
912
+ ];
913
+ case 4:
914
+ profile = _state.sent();
915
+ setLiffProfile(profile);
916
+ saveLiffProfileToStorage(profile);
917
+ setLiffObject(liff);
918
+ console.log("LIFF initialized.");
919
+ return [
920
+ 3,
921
+ 6
922
+ ];
923
+ case 5:
924
+ e = _state.sent();
925
+ console.error("ensureLiffInitialized failed:", e);
926
+ return [
927
+ 3,
928
+ 6
929
+ ];
930
+ case 6:
931
+ return [
932
+ 2
933
+ ];
934
+ }
935
+ });
984
936
  });
985
- }), [
986
- liffInitialized,
937
+ return function(isValid) {
938
+ return _ref.apply(this, arguments);
939
+ };
940
+ }(), [
987
941
  liffId,
988
- openInApp,
989
- saveLiffInitializedToStorage,
990
- saveLiffProfileToStorage,
991
- liffInitializedStorageKey
942
+ openInApp
992
943
  ]);
993
944
  var accountLogin = function() {
994
945
  var _ref = _async_to_generator(function(username, password) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@sunggang/ui-lib",
3
- "version": "0.4.45",
3
+ "version": "0.4.46",
4
4
  "sideEffects": [
5
5
  "*.css",
6
6
  "./src/style.css",
@@ -7,6 +7,7 @@ type LiffContextType = {
7
7
  accessToken: string;
8
8
  liffError: string | null;
9
9
  initializeLiff: () => Promise<void>;
10
+ getLiffProfile: () => Promise<any | null>;
10
11
  isFriendship: boolean | null;
11
12
  ensureLiffTokenValid: () => Promise<boolean>;
12
13
  loginType: string | null;