@youversion/platform-react-hooks 1.6.2 → 1.8.0
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/.turbo/turbo-build.log +1 -1
- package/CHANGELOG.md +28 -0
- package/dist/context/YouVersionAuthProvider.d.ts.map +1 -1
- package/dist/context/YouVersionAuthProvider.js +1 -0
- package/dist/context/YouVersionAuthProvider.js.map +1 -1
- package/dist/types/auth.d.ts +1 -0
- package/dist/types/auth.d.ts.map +1 -1
- package/dist/useFilteredVersions.d.ts +1 -1
- package/dist/useFilteredVersions.d.ts.map +1 -1
- package/dist/useFilteredVersions.js +7 -2
- package/dist/useFilteredVersions.js.map +1 -1
- package/dist/useYVAuth.d.ts +3 -2
- package/dist/useYVAuth.d.ts.map +1 -1
- package/dist/useYVAuth.js +11 -6
- package/dist/useYVAuth.js.map +1 -1
- package/package.json +2 -2
- package/src/context/YouVersionAuthProvider.tsx +1 -0
- package/src/types/auth.ts +1 -0
- package/src/useFilteredVersions.test.tsx +58 -0
- package/src/useFilteredVersions.ts +8 -1
- package/src/useYVAuth.test.tsx +25 -1
- package/src/useYVAuth.ts +17 -7
package/.turbo/turbo-build.log
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
|
|
2
|
-
> @youversion/platform-react-hooks@1.
|
|
2
|
+
> @youversion/platform-react-hooks@1.8.0 build /home/runner/work/platform-sdk-react/platform-sdk-react/packages/hooks
|
|
3
3
|
> tsc -p tsconfig.build.json
|
|
4
4
|
|
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,33 @@
|
|
|
1
1
|
# @youversion/platform-react-hooks
|
|
2
2
|
|
|
3
|
+
## 1.8.0
|
|
4
|
+
|
|
5
|
+
### Minor Changes
|
|
6
|
+
|
|
7
|
+
- 45516c2: Add recently used versions to the Bible Version Picker
|
|
8
|
+
- Display up to 3 recently selected Bible versions at the top of the picker
|
|
9
|
+
- Persist recent version selections in localStorage
|
|
10
|
+
- Recent versions are searchable and excluded from the main "All Versions" list
|
|
11
|
+
|
|
12
|
+
### Patch Changes
|
|
13
|
+
|
|
14
|
+
- Updated dependencies [45516c2]
|
|
15
|
+
- @youversion/platform-core@1.8.0
|
|
16
|
+
|
|
17
|
+
## 1.7.0
|
|
18
|
+
|
|
19
|
+
### Minor Changes
|
|
20
|
+
|
|
21
|
+
- a3e357e: feat(ui, hook): add sign in/out to bible reader
|
|
22
|
+
- Add sign in/out functionality to the BibleReader component
|
|
23
|
+
- Refactor auth hooks so redirectUri is optional (can be inferred from provider)
|
|
24
|
+
- New icons: gear.tsx and person.tsx for settings/auth UI
|
|
25
|
+
|
|
26
|
+
### Patch Changes
|
|
27
|
+
|
|
28
|
+
- Updated dependencies [a3e357e]
|
|
29
|
+
- @youversion/platform-core@1.7.0
|
|
30
|
+
|
|
3
31
|
## 1.6.2
|
|
4
32
|
|
|
5
33
|
### Patch Changes
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"YouVersionAuthProvider.d.ts","sourceRoot":"","sources":["../../src/context/YouVersionAuthProvider.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,EAAuB,KAAK,SAAS,EAAE,MAAM,OAAO,CAAC;AAOnE,OAAO,KAAK,EAAE,UAAU,EAAoB,MAAM,eAAe,CAAC;AAElE,MAAM,WAAW,2BAA2B;IAC1C,MAAM,EAAE,UAAU,CAAC;IACnB,QAAQ,EAAE,SAAS,CAAC;CACrB;AAED,MAAM,CAAC,OAAO,UAAU,sBAAsB,CAAC,EAC7C,MAAM,EACN,QAAQ,GACT,EAAE,2BAA2B,GAAG,KAAK,CAAC,YAAY,
|
|
1
|
+
{"version":3,"file":"YouVersionAuthProvider.d.ts","sourceRoot":"","sources":["../../src/context/YouVersionAuthProvider.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,EAAuB,KAAK,SAAS,EAAE,MAAM,OAAO,CAAC;AAOnE,OAAO,KAAK,EAAE,UAAU,EAAoB,MAAM,e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AC,CAAC;4BACpB,CAAC;iCAAM,CAAC;gCACN,IAAI,CAAC,OAAO;oCAAE,OAAO;gCACrB,WAAW,CAAC,IAAI,CAAC,CAAC;4BACpB,CAAC;wBACH,CAAC;wBAAC,MAAM,CAAC;4BACP,IAAI,CAAC,OAAO;gCAAE,OAAO;4BACrB,WAAW,CAAC,IAAI,CAAC,CAAC;wBACpB,CAAC;oBACH,CAAC;gBACH,CAAC;YACH,CAAC;YAED,IAAI,CAAC,OAAO;gBAAE,OAAO;YACrB,YAAY,CAAC,KAAK,CAAC,CAAC;QACtB,CAAC,CAAC;QAEF,KAAK,QAAQ,EAAE,CAAC;QAChB,OAAO,GAAG,EAAE;YACV,OAAO,GAAG,KAAK,CAAC;QAClB,CAAC,CAAC;IACJ,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,kDAAkD;IAE1D,MAAM,KAAK,GAAqB;QAC9B,QAAQ;QACR,WAAW;QACX,SAAS;QACT,KAAK;QACL,WAAW,EAAE,MAAM,CAAC,WAAW;KAChC,CAAC;IAEF,OAAO,KAAC,qBAAqB,CAAC,QAAQ,IAAC,KAAK,EAAE,KAAK,YAAG,QAAQ,GAAkC,CAAC;AACnG,CAAC"}
|
package/dist/types/auth.d.ts
CHANGED
package/dist/types/auth.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"auth.d.ts","sourceRoot":"","sources":["../../src/types/auth.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,2BAA2B,CAAC;AACpE,OAAO,KAAK,EAAE,QAAQ,EAAE,cAAc,EAAE,MAAM,OAAO,CAAC;AAEtD,MAAM,WAAW,UAAU;IACzB,MAAM,EAAE,MAAM,CAAC;IACf,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,WAAW,CAAC,EAAE,MAAM,CAAC;CACtB;AAED,MAAM,WAAW,gBAAgB;IAC/B,QAAQ,EAAE,kBAAkB,GAAG,IAAI,CAAC;IACpC,WAAW,EAAE,QAAQ,CAAC,cAAc,CAAC,kBAAkB,GAAG,IAAI,CAAC,CAAC,CAAC;IACjE,SAAS,EAAE,OAAO,CAAC;IACnB,KAAK,EAAE,KAAK,GAAG,IAAI,CAAC;
|
|
1
|
+
{"version":3,"file":"auth.d.ts","sourceRoot":"","sources":["../../src/types/auth.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,2BAA2B,CAAC;AACpE,OAAO,KAAK,EAAE,QAAQ,EAAE,cAAc,EAAE,MAAM,OAAO,CAAC;AAEtD,MAAM,WAAW,UAAU;IACzB,MAAM,EAAE,MAAM,CAAC;IACf,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,WAAW,CAAC,EAAE,MAAM,CAAC;CACtB;AAED,MAAM,WAAW,gBAAgB;IAC/B,QAAQ,EAAE,kBAAkB,GAAG,IAAI,CAAC;IACpC,WAAW,EAAE,QAAQ,CAAC,cAAc,CAAC,kBAAkB,GAAG,IAAI,CAAC,CAAC,CAAC;IACjE,SAAS,EAAE,OAAO,CAAC;IACnB,KAAK,EAAE,KAAK,GAAG,IAAI,CAAC;IACpB,WAAW,CAAC,EAAE,MAAM,CAAC;CACtB;AAED,MAAM,WAAW,iBAAiB;IAChC,MAAM,EAAE,UAAU,CAAC;IACnB,QAAQ,EAAE,KAAK,CAAC,SAAS,CAAC;CAC3B"}
|
|
@@ -2,5 +2,5 @@ import type { BibleVersion } from '@youversion/platform-core';
|
|
|
2
2
|
/**
|
|
3
3
|
* Custom hook to filter versions based on search term
|
|
4
4
|
*/
|
|
5
|
-
export declare function useFilteredVersions(versions: BibleVersion[], searchTerm: string, selectedLanguage: string): BibleVersion[];
|
|
5
|
+
export declare function useFilteredVersions(versions: BibleVersion[], searchTerm: string, selectedLanguage: string, recentVersions?: Pick<BibleVersion, 'id' | 'title' | 'localized_abbreviation'>[]): BibleVersion[];
|
|
6
6
|
//# sourceMappingURL=useFilteredVersions.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useFilteredVersions.d.ts","sourceRoot":"","sources":["../src/useFilteredVersions.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,2BAA2B,CAAC;AAI9D;;GAEG;AACH,wBAAgB,mBAAmB,CACjC,QAAQ,EAAE,YAAY,EAAE,EACxB,UAAU,EAAE,MAAM,EAClB,gBAAgB,EAAE,MAAM,
|
|
1
|
+
{"version":3,"file":"useFilteredVersions.d.ts","sourceRoot":"","sources":["../src/useFilteredVersions.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,2BAA2B,CAAC;AAI9D;;GAEG;AACH,wBAAgB,mBAAmB,CACjC,QAAQ,EAAE,YAAY,EAAE,EACxB,UAAU,EAAE,MAAM,EAClB,gBAAgB,EAAE,MAAM,EACxB,cAAc,CAAC,EAAE,IAAI,CAAC,YAAY,EAAE,IAAI,GAAG,OAAO,GAAG,wBAAwB,CAAC,EAAE,GAC/E,YAAY,EAAE,CA8BhB"}
|
|
@@ -4,7 +4,7 @@ import { getISOFromVersion } from './utility/version';
|
|
|
4
4
|
/**
|
|
5
5
|
* Custom hook to filter versions based on search term
|
|
6
6
|
*/
|
|
7
|
-
export function useFilteredVersions(versions, searchTerm, selectedLanguage) {
|
|
7
|
+
export function useFilteredVersions(versions, searchTerm, selectedLanguage, recentVersions) {
|
|
8
8
|
return useMemo(() => {
|
|
9
9
|
let result = [...versions];
|
|
10
10
|
// Language filter
|
|
@@ -18,7 +18,12 @@ export function useFilteredVersions(versions, searchTerm, selectedLanguage) {
|
|
|
18
18
|
version.abbreviation.toLowerCase().includes(searchLower) ||
|
|
19
19
|
getISOFromVersion(version).toLowerCase().includes(searchLower));
|
|
20
20
|
}
|
|
21
|
+
// Recently Used Filter
|
|
22
|
+
if (recentVersions) {
|
|
23
|
+
const recentVersionIds = recentVersions.map((version) => version.id);
|
|
24
|
+
result = result.filter((version) => !recentVersionIds.includes(version.id));
|
|
25
|
+
}
|
|
21
26
|
return result;
|
|
22
|
-
}, [versions, searchTerm, selectedLanguage]);
|
|
27
|
+
}, [versions, recentVersions, searchTerm, selectedLanguage]);
|
|
23
28
|
}
|
|
24
29
|
//# sourceMappingURL=useFilteredVersions.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useFilteredVersions.js","sourceRoot":"","sources":["../src/useFilteredVersions.ts"],"names":[],"mappings":"AAAA,YAAY,CAAC;AAGb,OAAO,EAAE,OAAO,EAAE,MAAM,OAAO,CAAC;AAChC,OAAO,EAAE,iBAAiB,EAAE,MAAM,mBAAmB,CAAC;AAEtD;;GAEG;AACH,MAAM,UAAU,mBAAmB,CACjC,QAAwB,EACxB,UAAkB,EAClB,gBAAwB;
|
|
1
|
+
{"version":3,"file":"useFilteredVersions.js","sourceRoot":"","sources":["../src/useFilteredVersions.ts"],"names":[],"mappings":"AAAA,YAAY,CAAC;AAGb,OAAO,EAAE,OAAO,EAAE,MAAM,OAAO,CAAC;AAChC,OAAO,EAAE,iBAAiB,EAAE,MAAM,mBAAmB,CAAC;AAEtD;;GAEG;AACH,MAAM,UAAU,mBAAmB,CACjC,QAAwB,EACxB,UAAkB,EAClB,gBAAwB,EACxB,cAAgF;IAEhF,OAAO,OAAO,CAAC,GAAG,EAAE;QAClB,IAAI,MAAM,GAAG,CAAC,GAAG,QAAQ,CAAC,CAAC;QAE3B,kBAAkB;QAClB,IAAI,gBAAgB,IAAI,gBAAgB,KAAK,GAAG,EAAE,CAAC;YACjD,MAAM,GAAG,MAAM,CAAC,MAAM,CACpB,CAAC,OAAO,EAAE,EAAE,CAAC,iBAAiB,CAAC,OAAO,CAAC,CAAC,WAAW,EAAE,KAAK,gBAAgB,CAAC,WAAW,EAAE,CACzF,CAAC;QACJ,CAAC;QAED,gBAAgB;QAChB,IAAI,UAAU,CAAC,IAAI,EAAE,EAAE,CAAC;YACtB,MAAM,WAAW,GAAG,UAAU,CAAC,WAAW,EAAE,CAAC;YAC7C,MAAM,GAAG,MAAM,CAAC,MAAM,CACpB,CAAC,OAAO,EAAE,EAAE,CACV,OAAO,CAAC,KAAK,CAAC,WAAW,EAAE,CAAC,QAAQ,CAAC,WAAW,CAAC;gBACjD,OAAO,CAAC,YAAY,CAAC,WAAW,EAAE,CAAC,QAAQ,CAAC,WAAW,CAAC;gBACxD,iBAAiB,CAAC,OAAO,CAAC,CAAC,WAAW,EAAE,CAAC,QAAQ,CAAC,WAAW,CAAC,CACjE,CAAC;QACJ,CAAC;QAED,uBAAuB;QACvB,IAAI,cAAc,EAAE,CAAC;YACnB,MAAM,gBAAgB,GAAG,cAAc,CAAC,GAAG,CAAC,CAAC,OAAO,EAAE,EAAE,CAAC,OAAO,CAAC,EAAE,CAAC,CAAC;YACrE,MAAM,GAAG,MAAM,CAAC,MAAM,CAAC,CAAC,OAAO,EAAE,EAAE,CAAC,CAAC,gBAAgB,CAAC,QAAQ,CAAC,OAAO,CAAC,EAAE,CAAC,CAAC,CAAC;QAC9E,CAAC;QAED,OAAO,MAAM,CAAC;IAChB,CAAC,EAAE,CAAC,QAAQ,EAAE,cAAc,EAAE,UAAU,EAAE,gBAAgB,CAAC,CAAC,CAAC;AAC/D,CAAC"}
|
package/dist/useYVAuth.d.ts
CHANGED
|
@@ -1,13 +1,14 @@
|
|
|
1
1
|
import { type AuthenticationState, type SignInWithYouVersionResult, type YouVersionUserInfo, type AuthenticationScopes } from '@youversion/platform-core';
|
|
2
2
|
export interface UseYVAuthReturn {
|
|
3
3
|
auth: AuthenticationState;
|
|
4
|
-
signIn: (params
|
|
5
|
-
redirectUrl
|
|
4
|
+
signIn: (params?: {
|
|
5
|
+
redirectUrl?: string;
|
|
6
6
|
scopes?: AuthenticationScopes[];
|
|
7
7
|
}) => Promise<void>;
|
|
8
8
|
signOut: () => void;
|
|
9
9
|
processCallback: () => Promise<SignInWithYouVersionResult | null>;
|
|
10
10
|
userInfo: YouVersionUserInfo | null;
|
|
11
|
+
redirectUri?: string;
|
|
11
12
|
}
|
|
12
13
|
/**
|
|
13
14
|
* Comprehensive YouVersion authentication hook using vanilla React.
|
package/dist/useYVAuth.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useYVAuth.d.ts","sourceRoot":"","sources":["../src/useYVAuth.ts"],"names":[],"mappings":"AACA,OAAO,EAGL,KAAK,mBAAmB,EACxB,KAAK,0BAA0B,EAC/B,KAAK,kBAAkB,EACvB,KAAK,oBAAoB,EAC1B,MAAM,2BAA2B,CAAC;AAGnC,MAAM,WAAW,eAAe;IAE9B,IAAI,EAAE,mBAAmB,CAAC;IAG1B,MAAM,EAAE,CAAC,MAAM,EAAE;QAAE,WAAW,EAAE,MAAM,CAAC;QAAC,MAAM,CAAC,EAAE,oBAAoB,EAAE,CAAA;KAAE,KAAK,OAAO,CAAC,IAAI,CAAC,CAAC;
|
|
1
|
+
{"version":3,"file":"useYVAuth.d.ts","sourceRoot":"","sources":["../src/useYVAuth.ts"],"names":[],"mappings":"AACA,OAAO,EAGL,KAAK,mBAAmB,EACxB,KAAK,0BAA0B,EAC/B,KAAK,kBAAkB,EACvB,KAAK,oBAAoB,EAC1B,MAAM,2BAA2B,CAAC;AAGnC,MAAM,WAAW,eAAe;IAE9B,IAAI,EAAE,mBAAmB,CAAC;IAG1B,MAAM,EAAE,CAAC,MAAM,CAAC,EAAE;QAAE,WAAW,CAAC,EAAE,MAAM,CAAC;QAAC,MAAM,CAAC,EAAE,oBAAoB,EAAE,CAAA;KAAE,KAAK,OAAO,CAAC,IAAI,CAAC,CAAC;IAC9F,OAAO,EAAE,MAAM,IAAI,CAAC;IAGpB,eAAe,EAAE,MAAM,OAAO,CAAC,0BAA0B,GAAG,IAAI,CAAC,CAAC;IAGlE,QAAQ,EAAE,kBAAkB,GAAG,IAAI,CAAC;IAGpC,WAAW,CAAC,EAAE,MAAM,CAAC;CACtB;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAkFG;AACH,wBAAgB,SAAS,IAAI,eAAe,CAsE3C"}
|
package/dist/useYVAuth.js
CHANGED
|
@@ -86,7 +86,7 @@ import { useYouVersionAuthContext } from './context/YouVersionAuthContext';
|
|
|
86
86
|
*/
|
|
87
87
|
export function useYVAuth() {
|
|
88
88
|
// Get auth state from provider context
|
|
89
|
-
const { userInfo, setUserInfo, isLoading, error } = useYouVersionAuthContext();
|
|
89
|
+
const { userInfo, setUserInfo, isLoading, error, redirectUri } = useYouVersionAuthContext();
|
|
90
90
|
// Derive authentication state
|
|
91
91
|
const isAuthenticated = !!userInfo;
|
|
92
92
|
// Get current tokens for actions
|
|
@@ -100,15 +100,19 @@ export function useYVAuth() {
|
|
|
100
100
|
return { accessToken: null, idToken: null };
|
|
101
101
|
}, []);
|
|
102
102
|
// Sign in function
|
|
103
|
-
const signIn = useCallback(async (
|
|
104
|
-
|
|
105
|
-
|
|
103
|
+
const signIn = useCallback(async (params) => {
|
|
104
|
+
const url = params?.redirectUrl ?? redirectUri;
|
|
105
|
+
if (!url) {
|
|
106
|
+
throw new Error('redirectUrl is required. Provide it via signIn params or configure redirectUri in the auth provider.');
|
|
107
|
+
}
|
|
108
|
+
if (params?.scopes) {
|
|
109
|
+
await YouVersionAPIUsers.signIn(url, params.scopes);
|
|
106
110
|
}
|
|
107
111
|
else {
|
|
108
|
-
await YouVersionAPIUsers.signIn(
|
|
112
|
+
await YouVersionAPIUsers.signIn(url);
|
|
109
113
|
}
|
|
110
114
|
// Note: This will redirect, so code after this won't execute
|
|
111
|
-
}, []);
|
|
115
|
+
}, [redirectUri]);
|
|
112
116
|
// Process callback function
|
|
113
117
|
const processCallback = useCallback(async () => {
|
|
114
118
|
const result = await YouVersionAPIUsers.handleAuthCallback();
|
|
@@ -134,6 +138,7 @@ export function useYVAuth() {
|
|
|
134
138
|
signOut,
|
|
135
139
|
processCallback,
|
|
136
140
|
userInfo,
|
|
141
|
+
redirectUri,
|
|
137
142
|
};
|
|
138
143
|
}
|
|
139
144
|
//# sourceMappingURL=useYVAuth.js.map
|
package/dist/useYVAuth.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useYVAuth.js","sourceRoot":"","sources":["../src/useYVAuth.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,WAAW,EAAE,MAAM,OAAO,CAAC;AAC7C,OAAO,EACL,kBAAkB,EAClB,+BAA+B,GAKhC,MAAM,2BAA2B,CAAC;AACnC,OAAO,EAAE,wBAAwB,EAAE,MAAM,iCAAiC,CAAC;
|
|
1
|
+
{"version":3,"file":"useYVAuth.js","sourceRoot":"","sources":["../src/useYVAuth.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,WAAW,EAAE,MAAM,OAAO,CAAC;AAC7C,OAAO,EACL,kBAAkB,EAClB,+BAA+B,GAKhC,MAAM,2BAA2B,CAAC;AACnC,OAAO,EAAE,wBAAwB,EAAE,MAAM,iCAAiC,CAAC;AAoB3E;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAkFG;AACH,MAAM,UAAU,SAAS;IACvB,uCAAuC;IACvC,MAAM,EAAE,QAAQ,EAAE,WAAW,EAAE,SAAS,EAAE,KAAK,EAAE,WAAW,EAAE,GAAG,wBAAwB,EAAE,CAAC;IAE5F,8BAA8B;IAC9B,MAAM,eAAe,GAAG,CAAC,CAAC,QAAQ,CAAC;IAEnC,iCAAiC;IACjC,MAAM,UAAU,GAAG,OAAO,CAAC,GAAG,EAAE;QAC9B,IAAI,OAAO,MAAM,KAAK,WAAW,EAAE,CAAC;YAClC,OAAO;gBACL,WAAW,EAAE,+BAA+B,CAAC,WAAW;gBACxD,OAAO,EAAE,+BAA+B,CAAC,OAAO;aACjD,CAAC;QACJ,CAAC;QACD,OAAO,EAAE,W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,WAAW,CAAC,IAAI,CAAC,CAAC;IACpB,CAAC,EAAE,EAAE,CAAC,CAAC;IAEP,OAAO;QACL,IAAI;QACJ,MAAM;QACN,OAAO;QACP,eAAe;QACf,QAAQ;QACR,WAAW;KACZ,CAAC;AACJ,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@youversion/platform-react-hooks",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.8.0",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"publishConfig": {
|
|
6
6
|
"access": "public",
|
|
@@ -22,7 +22,7 @@
|
|
|
22
22
|
}
|
|
23
23
|
},
|
|
24
24
|
"dependencies": {
|
|
25
|
-
"@youversion/platform-core": "1.
|
|
25
|
+
"@youversion/platform-core": "1.8.0"
|
|
26
26
|
},
|
|
27
27
|
"peerDependencies": {
|
|
28
28
|
"react": ">=19.1.0 <20.0.0"
|
package/src/types/auth.ts
CHANGED
|
@@ -198,6 +198,64 @@ describe('useFilteredVersions', () => {
|
|
|
198
198
|
});
|
|
199
199
|
});
|
|
200
200
|
|
|
201
|
+
describe('recent versions exclusion', () => {
|
|
202
|
+
it('should not exclude any versions when recentVersions is undefined', () => {
|
|
203
|
+
const { result } = renderHook(() => useFilteredVersions(mockVersions, '', '*', undefined));
|
|
204
|
+
|
|
205
|
+
expect(result.current).toEqual(mockVersions);
|
|
206
|
+
expect(result.current).toHaveLength(5);
|
|
207
|
+
});
|
|
208
|
+
|
|
209
|
+
it('should exclude recent versions from the results', () => {
|
|
210
|
+
const recentVersions = [
|
|
211
|
+
{ id: 1, title: 'King James Version', localized_abbreviation: 'KJV' },
|
|
212
|
+
];
|
|
213
|
+
|
|
214
|
+
const { result } = renderHook(() =>
|
|
215
|
+
useFilteredVersions(mockVersions, '', '*', recentVersions),
|
|
216
|
+
);
|
|
217
|
+
|
|
218
|
+
expect(result.current).toHaveLength(4);
|
|
219
|
+
expect(result.current.find((v) => v.id === 1)).toBeUndefined();
|
|
220
|
+
});
|
|
221
|
+
|
|
222
|
+
it('should exclude multiple recent versions from the results', () => {
|
|
223
|
+
const recentVersions = [
|
|
224
|
+
{ id: 1, title: 'King James Version', localized_abbreviation: 'KJV' },
|
|
225
|
+
{ id: 2, title: 'New International Version', localized_abbreviation: 'NIV' },
|
|
226
|
+
];
|
|
227
|
+
|
|
228
|
+
const { result } = renderHook(() =>
|
|
229
|
+
useFilteredVersions(mockVersions, '', '*', recentVersions),
|
|
230
|
+
);
|
|
231
|
+
|
|
232
|
+
expect(result.current).toHaveLength(3);
|
|
233
|
+
expect(result.current.find((v) => v.id === 1)).toBeUndefined();
|
|
234
|
+
expect(result.current.find((v) => v.id === 2)).toBeUndefined();
|
|
235
|
+
});
|
|
236
|
+
|
|
237
|
+
it('should not exclude any versions when recentVersions is empty array', () => {
|
|
238
|
+
const { result } = renderHook(() => useFilteredVersions(mockVersions, '', '*', []));
|
|
239
|
+
|
|
240
|
+
expect(result.current).toEqual(mockVersions);
|
|
241
|
+
expect(result.current).toHaveLength(5);
|
|
242
|
+
});
|
|
243
|
+
|
|
244
|
+
it('should exclude recent versions even when they match search term', () => {
|
|
245
|
+
const recentVersions = [
|
|
246
|
+
{ id: 2, title: 'New International Version', localized_abbreviation: 'NIV' },
|
|
247
|
+
];
|
|
248
|
+
|
|
249
|
+
const { result } = renderHook(() =>
|
|
250
|
+
useFilteredVersions(mockVersions, 'Version', '*', recentVersions),
|
|
251
|
+
);
|
|
252
|
+
|
|
253
|
+
// "Version" matches KJV and NIV, but NIV is excluded as a recent version
|
|
254
|
+
expect(result.current).toHaveLength(1);
|
|
255
|
+
expect(result.current[0]?.title).toBe('King James Version');
|
|
256
|
+
});
|
|
257
|
+
});
|
|
258
|
+
|
|
201
259
|
describe('memoization', () => {
|
|
202
260
|
it('should return the same reference when inputs do not change', () => {
|
|
203
261
|
const { result, rerender } = renderHook(
|
|
@@ -11,6 +11,7 @@ export function useFilteredVersions(
|
|
|
11
11
|
versions: BibleVersion[],
|
|
12
12
|
searchTerm: string,
|
|
13
13
|
selectedLanguage: string,
|
|
14
|
+
recentVersions?: Pick<BibleVersion, 'id' | 'title' | 'localized_abbreviation'>[],
|
|
14
15
|
): BibleVersion[] {
|
|
15
16
|
return useMemo(() => {
|
|
16
17
|
let result = [...versions];
|
|
@@ -33,6 +34,12 @@ export function useFilteredVersions(
|
|
|
33
34
|
);
|
|
34
35
|
}
|
|
35
36
|
|
|
37
|
+
// Recently Used Filter
|
|
38
|
+
if (recentVersions) {
|
|
39
|
+
const recentVersionIds = recentVersions.map((version) => version.id);
|
|
40
|
+
result = result.filter((version) => !recentVersionIds.includes(version.id));
|
|
41
|
+
}
|
|
42
|
+
|
|
36
43
|
return result;
|
|
37
|
-
}, [versions, searchTerm, selectedLanguage]);
|
|
44
|
+
}, [versions, recentVersions, searchTerm, selectedLanguage]);
|
|
38
45
|
}
|
package/src/useYVAuth.test.tsx
CHANGED
|
@@ -150,7 +150,7 @@ const renderAuthHook = async () => {
|
|
|
150
150
|
|
|
151
151
|
describe('useYVAuth', () => {
|
|
152
152
|
beforeEach(() => {
|
|
153
|
-
vi.
|
|
153
|
+
vi.resetAllMocks();
|
|
154
154
|
|
|
155
155
|
// Setup window mock
|
|
156
156
|
vi.stubGlobal('window', mockWindow);
|
|
@@ -248,6 +248,30 @@ describe('useYVAuth', () => {
|
|
|
248
248
|
}),
|
|
249
249
|
).rejects.toThrow('Sign in failed');
|
|
250
250
|
});
|
|
251
|
+
|
|
252
|
+
it('should use redirectUri from provider when redirectUrl is not passed', async () => {
|
|
253
|
+
const { result } = await renderAuthHook();
|
|
254
|
+
|
|
255
|
+
await act(async () => {
|
|
256
|
+
await result.current.signIn();
|
|
257
|
+
});
|
|
258
|
+
|
|
259
|
+
expect(vi.mocked(YouVersionAPIUsers.signIn)).toHaveBeenCalledWith('http://test.example.com');
|
|
260
|
+
});
|
|
261
|
+
|
|
262
|
+
it('should use redirectUri from provider with scopes when redirectUrl is not passed', async () => {
|
|
263
|
+
const { result } = await renderAuthHook();
|
|
264
|
+
const scopes: AuthenticationScopes[] = ['profile', 'email'];
|
|
265
|
+
|
|
266
|
+
await act(async () => {
|
|
267
|
+
await result.current.signIn({ scopes });
|
|
268
|
+
});
|
|
269
|
+
|
|
270
|
+
expect(vi.mocked(YouVersionAPIUsers.signIn)).toHaveBeenCalledWith(
|
|
271
|
+
'http://test.example.com',
|
|
272
|
+
scopes,
|
|
273
|
+
);
|
|
274
|
+
});
|
|
251
275
|
});
|
|
252
276
|
|
|
253
277
|
describe('processCallback', () => {
|
package/src/useYVAuth.ts
CHANGED
|
@@ -14,7 +14,7 @@ export interface UseYVAuthReturn {
|
|
|
14
14
|
auth: AuthenticationState;
|
|
15
15
|
|
|
16
16
|
// Actions
|
|
17
|
-
signIn: (params
|
|
17
|
+
signIn: (params?: { redirectUrl?: string; scopes?: AuthenticationScopes[] }) => Promise<void>;
|
|
18
18
|
signOut: () => void;
|
|
19
19
|
|
|
20
20
|
// Callback processing (for callback page) - caches user info
|
|
@@ -22,6 +22,9 @@ export interface UseYVAuthReturn {
|
|
|
22
22
|
|
|
23
23
|
// Cached user info (populated after successful callback)
|
|
24
24
|
userInfo: YouVersionUserInfo | null;
|
|
25
|
+
|
|
26
|
+
// Redirect URI from provider config
|
|
27
|
+
redirectUri?: string;
|
|
25
28
|
}
|
|
26
29
|
|
|
27
30
|
/**
|
|
@@ -109,7 +112,7 @@ export interface UseYVAuthReturn {
|
|
|
109
112
|
*/
|
|
110
113
|
export function useYVAuth(): UseYVAuthReturn {
|
|
111
114
|
// Get auth state from provider context
|
|
112
|
-
const { userInfo, setUserInfo, isLoading, error } = useYouVersionAuthContext();
|
|
115
|
+
const { userInfo, setUserInfo, isLoading, error, redirectUri } = useYouVersionAuthContext();
|
|
113
116
|
|
|
114
117
|
// Derive authentication state
|
|
115
118
|
const isAuthenticated = !!userInfo;
|
|
@@ -127,15 +130,21 @@ export function useYVAuth(): UseYVAuthReturn {
|
|
|
127
130
|
|
|
128
131
|
// Sign in function
|
|
129
132
|
const signIn = useCallback(
|
|
130
|
-
async (
|
|
131
|
-
|
|
132
|
-
|
|
133
|
+
async (params?: { redirectUrl?: string; scopes?: AuthenticationScopes[] }) => {
|
|
134
|
+
const url = params?.redirectUrl ?? redirectUri;
|
|
135
|
+
if (!url) {
|
|
136
|
+
throw new Error(
|
|
137
|
+
'redirectUrl is required. Provide it via signIn params or configure redirectUri in the auth provider.',
|
|
138
|
+
);
|
|
139
|
+
}
|
|
140
|
+
if (params?.scopes) {
|
|
141
|
+
await YouVersionAPIUsers.signIn(url, params.scopes);
|
|
133
142
|
} else {
|
|
134
|
-
await YouVersionAPIUsers.signIn(
|
|
143
|
+
await YouVersionAPIUsers.signIn(url);
|
|
135
144
|
}
|
|
136
145
|
// Note: This will redirect, so code after this won't execute
|
|
137
146
|
},
|
|
138
|
-
[],
|
|
147
|
+
[redirectUri],
|
|
139
148
|
);
|
|
140
149
|
|
|
141
150
|
// Process callback function
|
|
@@ -169,5 +178,6 @@ export function useYVAuth(): UseYVAuthReturn {
|
|
|
169
178
|
signOut,
|
|
170
179
|
processCallback,
|
|
171
180
|
userInfo,
|
|
181
|
+
redirectUri,
|
|
172
182
|
};
|
|
173
183
|
}
|