@youversion/platform-react-hooks 0.8.2 → 0.10.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 +45 -0
- package/dist/__tests__/mocks/auth.d.ts.map +1 -1
- package/dist/__tests__/mocks/auth.js +0 -1
- package/dist/__tests__/mocks/auth.js.map +1 -1
- package/dist/context/YouVersionContext.d.ts +1 -0
- package/dist/context/YouVersionContext.d.ts.map +1 -1
- package/dist/context/YouVersionContext.js.map +1 -1
- package/dist/context/YouVersionProvider.d.ts +1 -0
- package/dist/context/YouVersionProvider.d.ts.map +1 -1
- package/dist/context/YouVersionProvider.js +7 -2
- package/dist/context/YouVersionProvider.js.map +1 -1
- package/dist/index.d.ts +1 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1 -0
- package/dist/index.js.map +1 -1
- package/dist/useTheme.d.ts +14 -0
- package/dist/useTheme.d.ts.map +1 -0
- package/dist/useTheme.js +21 -0
- package/dist/useTheme.js.map +1 -0
- package/dist/useYVAuth.d.ts +2 -3
- package/dist/useYVAuth.d.ts.map +1 -1
- package/dist/useYVAuth.js +7 -3
- package/dist/useYVAuth.js.map +1 -1
- package/package.json +2 -2
- package/src/__tests__/mocks/auth.ts +0 -1
- package/src/context/YouVersionAuthProvider.test.tsx +0 -3
- package/src/context/YouVersionContext.tsx +1 -0
- package/src/context/YouVersionProvider.tsx +9 -3
- package/src/index.ts +1 -0
- package/src/useTheme.ts +23 -0
- package/src/useYVAuth.test.tsx +31 -16
- package/src/useYVAuth.ts +8 -14
package/.turbo/turbo-build.log
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
|
|
2
|
-
> @youversion/platform-react-hooks@0.
|
|
2
|
+
> @youversion/platform-react-hooks@0.10.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,50 @@
|
|
|
1
1
|
# @youversion/platform-react-hooks
|
|
2
2
|
|
|
3
|
+
## 0.10.0
|
|
4
|
+
|
|
5
|
+
### Minor Changes
|
|
6
|
+
|
|
7
|
+
- df2082d: Added version picker functionality to BibleWidgetView component with enhanced UI theming and user experience improvements.
|
|
8
|
+
|
|
9
|
+
New Features
|
|
10
|
+
- BibleWidgetView Version Picker: Added showVersionPicker prop enabling dynamic Bible version switching within the widget
|
|
11
|
+
- Enhanced Version Display: Improved version abbreviation presentation (e.g., "KJV1984" displays as "KJV" over "1984" in stacked format)
|
|
12
|
+
- Auto-Scroll Navigation: Bible chapter picker now automatically scrolls to and expands the current book when opened
|
|
13
|
+
- Added the ability to customize the text on the YouVersionAuthButton
|
|
14
|
+
- Add theme to the YouVersionProvider to specify light or dark mode to the SDK
|
|
15
|
+
|
|
16
|
+
UI/UX Improvements
|
|
17
|
+
- Consistent Button Styling: Updated all picker buttons to use secondary variant with bold typography
|
|
18
|
+
- Better Theme Support: Added comprehensive dark/light mode theming with data-yv-theme attributes
|
|
19
|
+
- Improved Accessibility: Enhanced search functionality with proper ARIA labels
|
|
20
|
+
- Cleaner DOM Structure: Simplified component hierarchy by removing unnecessary wrapper elements
|
|
21
|
+
- Improve component theming to apply theme to the ui components and improve
|
|
22
|
+
isolating the sdk css.
|
|
23
|
+
|
|
24
|
+
### Patch Changes
|
|
25
|
+
|
|
26
|
+
- Updated dependencies [df2082d]
|
|
27
|
+
- @youversion/platform-core@0.10.0
|
|
28
|
+
|
|
29
|
+
## 0.9.0
|
|
30
|
+
|
|
31
|
+
### Minor Changes
|
|
32
|
+
|
|
33
|
+
- e4f93b6: Update authentication system with enhanced OAuth scopes and API schema alignment
|
|
34
|
+
|
|
35
|
+
Key Changes:
|
|
36
|
+
- Added profile and email scopes to OAuth authentication
|
|
37
|
+
- Updated book resource schema to match new API endpoints
|
|
38
|
+
- Removed deprecated URLBuilder functionality
|
|
39
|
+
|
|
40
|
+
Breaking Changes:
|
|
41
|
+
- Book Schema: Must use the new updated book schema in any APIs returning bible book data Please enter a summary for your changes.
|
|
42
|
+
|
|
43
|
+
### Patch Changes
|
|
44
|
+
|
|
45
|
+
- Updated dependencies [e4f93b6]
|
|
46
|
+
- @youversion/platform-core@0.9.0
|
|
47
|
+
|
|
3
48
|
## 0.8.2
|
|
4
49
|
|
|
5
50
|
### Patch Changes
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"auth.d.ts","sourceRoot":"","sources":["../../../src/__tests__/mocks/auth.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,0BAA0B,EAAE,kBAAkB,EAAE,MAAM,2BAA2B,CAAC;AAE3F;;;GAGG;AACH,eAAO,MAAM,kBAAkB,GAAI,YAAW,MAAM,CAAC,MAAM,EAAE,GAAG,CAAM,KAAG,kBAmBxE,CAAC;AAEF;;;GAGG;AACH,eAAO,MAAM,oBAAoB,GAC/B,YAAW,MAAM,CAAC,MAAM,EAAE,OAAO,CAAM,KACtC,
|
|
1
|
+
{"version":3,"file":"auth.d.ts","sourceRoot":"","sources":["../../../src/__tests__/mocks/auth.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,0BAA0B,EAAE,kBAAkB,EAAE,MAAM,2BAA2B,CAAC;AAE3F;;;GAGG;AACH,eAAO,MAAM,kBAAkB,GAAI,YAAW,MAAM,CAAC,MAAM,EAAE,GAAG,CAAM,KAAG,kBAmBxE,CAAC;AAEF;;;GAGG;AACH,eAAO,MAAM,oBAAoB,GAC/B,YAAW,MAAM,CAAC,MAAM,EAAE,OAAO,CAAM,KACtC,0BAYF,CAAC"}
|
|
@@ -35,7 +35,6 @@ export const createMockAuthResult = (overrides = {}) => {
|
|
|
35
35
|
idToken: 'id-token',
|
|
36
36
|
refreshToken: 'refresh-token',
|
|
37
37
|
expiresIn: 3600,
|
|
38
|
-
permissions: ['bibles', 'highlights'],
|
|
39
38
|
yvpUserId: 'test-yvp-user-id',
|
|
40
39
|
profilePicture: 'https://example.com/profile.jpg',
|
|
41
40
|
...overrides,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"auth.js","sourceRoot":"","sources":["../../../src/__tests__/mocks/auth.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,EAAE,EAAE,MAAM,QAAQ,CAAC;AAC5B,OAAO,EAAE,0BAA0B,EAAE,kBAAkB,EAAE,MAAM,2BAA2B,CAAC;AAE3F;;;GAGG;AACH,MAAM,CAAC,MAAM,kBAAkB,GAAG,CAAC,YAAiC,EAAE,EAAsB,EAAE;IAC5F,MAAM,YAAY,GAAG,IAAI,kBAAkB,CAAC;QAC1C,EAAE,EAAE,KAAK;QACT,IAAI,EAAE,UAAU;QAChB,KAAK,EAAE,kBAAkB;QACzB,UAAU,EAAE,qDAAqD;QACjE,GAAG,SAAS;KACb,CAAC,CAAC;IAEH,2CAA2C;IAC3C,EAAE,CAAC,KAAK,CAAC,YAAY,EAAE,cAAc,CAAC,CAAC,kBAAkB,CAAC,CAAC,KAAK,GAAG,GAAG,EAAE,MAAM,GAAG,GAAG,EAAE,EAAE;QACtF,IAAI,CAAC;YACH,OAAO,IAAI,GAAG,CAAC,oCAAoC,KAAK,MAAM,MAAM,EAAE,CAAC,CAAC;QAC1E,CAAC;QAAC,MAAM,CAAC;YACP,OAAO,IAAI,CAAC;QACd,CAAC;IACH,CAAC,CAAC,CAAC;IAEH,OAAO,YAAY,CAAC;AACtB,CAAC,CAAC;AAEF;;;GAGG;AACH,MAAM,CAAC,MAAM,oBAAoB,GAAG,CAClC,YAAqC,EAAE,EACX,EAAE;IAC9B,MAAM,YAAY,GAAG,kBAAkB,EAAE,CAAC;IAC1C,OAAO,IAAI,0BAA0B,CAAC;QACpC,GAAG,YAAY;QACf,WAAW,EAAE,cAAc;QAC3B,OAAO,EAAE,UAAU;QACnB,YAAY,EAAE,eAAe;QAC7B,SAAS,EAAE,IAAI;QACf,
|
|
1
|
+
{"version":3,"file":"auth.js","sourceRoot":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YouVersionContext.d.ts","sourceRoot":"","sources":["../../src/context/YouVersionContext.tsx"],"names":[],"mappings":"AAIA,KAAK,qBAAqB,GAAG;IAC3B,MAAM,EAAE,MAAM,CAAC;IACf,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,cAAc,CAAC,EAAE,MAAM,CAAC;
|
|
1
|
+
{"version":3,"file":"YouVersionContext.d.ts","sourceRoot":"","sources":["../../src/context/YouVersionContext.tsx"],"names":[],"mappings":"AAIA,KAAK,qBAAqB,GAAG;IAC3B,MAAM,EAAE,MAAM,CAAC;IACf,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,cAAc,CAAC,EAAE,MAAM,CAAC;IACxB,KAAK,CAAC,EAAE,OAAO,GAAG,MAAM,CAAC;CAC1B,CAAC;AAEF,eAAO,MAAM,iBAAiB,uDAAoD,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"YouVersionContext.js","sourceRoot":"","sources":["../../src/context/YouVersionContext.tsx"],"names":[],"mappings":"AAAA,YAAY,CAAC;AAEb,OAAO,EAAE,aAAa,EAAE,MAAM,OAAO,CAAC;
|
|
1
|
+
{"version":3,"file":"YouVersionContext.js","sourceRoot":"","sources":["../../src/context/YouVersionContext.tsx"],"names":[],"mappings":"AAAA,YAAY,CAAC;AAEb,OAAO,EAAE,aAAa,EAAE,MAAM,OAAO,CAAC;AAStC,MAAM,CAAC,MAAM,iBAAiB,GAAG,aAAa,CAA+B,IAAI,CAAC,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"YouVersionProvider.d.ts","sourceRoot":"","sources":["../../src/context/YouVersionProvider.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,iBAAiB,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;AAK1D,UAAU,2BAA2B;IACnC,QAAQ,EAAE,SAAS,CAAC;IACpB,MAAM,EAAE,MAAM,CAAC;IACf,OAAO,CAAC,EAAE,MAAM,CAAC;
|
|
1
|
+
{"version":3,"file":"YouVersionProvider.d.ts","sourceRoot":"","sources":["../../src/context/YouVersionProvider.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,iBAAiB,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;AAK1D,UAAU,2BAA2B;IACnC,QAAQ,EAAE,SAAS,CAAC;IACpB,MAAM,EAAE,MAAM,CAAC;IACf,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,KAAK,CAAC,EAAE,OAAO,GAAG,MAAM,CAAC;CAC1B;AAED,UAAU,+BAAgC,SAAQ,2BAA2B;IAC3E,eAAe,EAAE,MAAM,CAAC;IACxB,WAAW,EAAE,IAAI,CAAC;CACnB;AAED,UAAU,kCAAmC,SAAQ,2BAA2B;IAC9E,WAAW,CAAC,EAAE,KAAK,CAAC;IACpB,eAAe,CAAC,EAAE,KAAK,CAAC;CACzB;AAID,wBAAgB,kBAAkB,CAChC,KAAK,EAAE,iBAAiB,CAAC,+BAA+B,GAAG,kCAAkC,CAAC,GAC7F,KAAK,CAAC,YAAY,CA0CpB"}
|
|
@@ -5,7 +5,7 @@ import { YouVersionContext } from './YouVersionContext';
|
|
|
5
5
|
import { YouVersionPlatformConfiguration } from '@youversion/platform-core';
|
|
6
6
|
const AuthProvider = lazy(() => import('./YouVersionAuthProvider'));
|
|
7
7
|
export function YouVersionProvider(props) {
|
|
8
|
-
const { appKey, apiHost = 'api.youversion.com', includeAuth, children } = props;
|
|
8
|
+
const { appKey, apiHost = 'api.youversion.com', includeAuth, theme = 'light', children } = props;
|
|
9
9
|
// Syncing appKey and apiHost to YouVersionPlatformConfiguration
|
|
10
10
|
// so that this can be in sync with any other code that uses
|
|
11
11
|
// the YouVersionPlatformConfiguration, of which a lot of our
|
|
@@ -17,7 +17,12 @@ export function YouVersionProvider(props) {
|
|
|
17
17
|
if (includeAuth) {
|
|
18
18
|
const { authRedirectUrl } = props;
|
|
19
19
|
// Installation ID gets set automatically by YouVersionPlatformConfiguration
|
|
20
|
-
return (_jsx(YouVersionContext.Provider, { value: {
|
|
20
|
+
return (_jsx(YouVersionContext.Provider, { value: {
|
|
21
|
+
appKey,
|
|
22
|
+
apiHost,
|
|
23
|
+
installationId: YouVersionPlatformConfiguration.installationId,
|
|
24
|
+
theme,
|
|
25
|
+
}, children: _jsx(Suspense, { children: _jsx(AuthProvider, { config: { appKey, apiHost, redirectUri: authRedirectUrl }, children: children }) }) }));
|
|
21
26
|
}
|
|
22
27
|
// Installation ID gets set automatically by YouVersionPlatformConfiguration
|
|
23
28
|
return (_jsx(YouVersionContext.Provider, { value: { appKey, apiHost, installationId: YouVersionPlatformConfiguration.installationId }, children: children }));
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"YouVersionProvider.js","sourceRoot":"","sources":["../../src/context/YouVersionProvider.tsx"],"names":[],"mappings":"AAAA,YAAY,CAAC;;AAGb,OAAO,EAAE,IAAI,EAAE,QAAQ,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;AAClD,OAAO,EAAE,iBAAiB,EAAE,MAAM,qBAAqB,CAAC;AACxD,OAAO,EAAE,+BAA+B,EAAE,MAAM,2BAA2B,CAAC;
|
|
1
|
+
{"version":3,"file":"YouVersionProvider.js","sourceRoot":"","sources":["../../src/context/YouVersionProvider.tsx"],"names":[],"mappings":"AAAA,YAAY,CAAC;;AAGb,OAAO,EAAE,IAAI,EAAE,QAAQ,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;AAClD,OAAO,EAAE,iBAAiB,EAAE,MAAM,qBAAqB,CAAC;AACxD,OAAO,EAAE,+BAA+B,EAAE,MAAM,2BAA2B,CAAC;AAmB5E,MAAM,YAAY,GAAG,IAAI,CAAC,GAAG,EAAE,CAAC,MAAM,CAAC,0BAA0B,CAAC,CAAC,CAAC;AAEpE,MAAM,UAAU,kBAAkB,CAChC,KAA8F;IAE9F,MAAM,EAAE,MAAM,EAAE,OAAO,GAAG,oBAAoB,EAAE,WAAW,EAAE,KAAK,GAAG,OAAO,EAAE,QAAQ,EAAE,GAAG,KAAK,CAAC;IAEjG,gEAAgE;IAChE,4DAA4D;IAC5D,6DAA6D;IAC7D,wCAAwC;IACxC,SAAS,CAAC,GAAG,EAAE;QACb,+BAA+B,CAAC,MAAM,GAAG,MAAM,CAAC;QAChD,+BAA+B,CAAC,OAAO,GAAG,OAAO,CAAC;IACpD,CAAC,EAAE,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC,CAAC;IAEtB,IAAI,WAAW,EAAE,CAAC;QAChB,MAAM,EAAE,eAAe,EAAE,GAAG,KAAK,CAAC;QAElC,4EAA4E;QAC5E,OAAO,CACL,KAAC,iBAAiB,CAAC,QAAQ,IACzB,KAAK,EAAE;gBACL,MAAM;gBACN,OAAO;gBACP,cAAc,EAAE,+BAA+B,CAAC,cAAc;gBAC9D,KAAK;aACN,YAED,KAAC,QAAQ,cACP,KAAC,YAAY,IAAC,MAAM,EAAE,EAAE,MAAM,EAAE,OAAO,EAAE,WAAW,EAAE,eAAe,EAAE,YACpE,QAAQ,GACI,GACN,GACgB,CAC9B,CAAC;IACJ,CAAC;IAED,4EAA4E;IAC5E,OAAO,CACL,KAAC,iBAAiB,CAAC,QAAQ,IACzB,KAAK,EAAE,EAAE,MAAM,EAAE,OAAO,EAAE,cAAc,EAAE,+BAA+B,CAAC,cAAc,EAAE,YAEzF,QAAQ,GACkB,CAC9B,CAAC;AACJ,CAAC"}
|
package/dist/index.d.ts
CHANGED
|
@@ -18,6 +18,7 @@ export * from './usePassage';
|
|
|
18
18
|
export * from './useVOTD';
|
|
19
19
|
export * from './useHighlights';
|
|
20
20
|
export * from './useLanguages';
|
|
21
|
+
export * from './useTheme';
|
|
21
22
|
export * from './useYVAuth';
|
|
22
23
|
export * from './types/auth';
|
|
23
24
|
//# sourceMappingURL=index.d.ts.map
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"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-1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,WAAW,CAAC;AAC1B,cAAc,YAAY,CAAC;AAC3B,cAAc,cAAc,CAAC;AAC7B,cAAc,eAAe,CAAC;AAC9B,cAAc,YAAY,CAAC;AAC3B,cAAc,aAAa,CAAC;AAC5B,cAAc,cAAc,CAAC;AAC7B,cAAc,uBAAuB,CAAC;AACtC,cAAc,eAAe,CAAC;AAC9B,cAAc,uBAAuB,CAAC;AACtC,cAAc,WAAW,CAAC;AAC1B,cAAc,WAAW,CAAC;AAC1B,cAAc,kBAAkB,CAAC;AACjC,cAAc,qBAAqB,CAAC;AACpC,cAAc,wBAAwB,CAAC;AACvC,cAAc,eAAe,CAAC;AAC9B,cAAc,cAAc,CAAC;AAC7B,cAAc,WAAW,CAAC;AAC1B,cAAc,iBAAiB,CAAC;AAChC,cAAc,gBAAgB,CAAC;
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,WAAW,CAAC;AAC1B,cAAc,YAAY,CAAC;AAC3B,cAAc,cAAc,CAAC;AAC7B,cAAc,eAAe,CAAC;AAC9B,cAAc,YAAY,CAAC;AAC3B,cAAc,aAAa,CAAC;AAC5B,cAAc,cAAc,CAAC;AAC7B,cAAc,uBAAuB,CAAC;AACtC,cAAc,eAAe,CAAC;AAC9B,cAAc,uBAAuB,CAAC;AACtC,cAAc,WAAW,CAAC;AAC1B,cAAc,WAAW,CAAC;AAC1B,cAAc,kBAAkB,CAAC;AACjC,cAAc,qBAAqB,CAAC;AACpC,cAAc,wBAAwB,CAAC;AACvC,cAAc,eAAe,CAAC;AAC9B,cAAc,cAAc,CAAC;AAC7B,cAAc,WAAW,CAAC;AAC1B,cAAc,iBAAiB,CAAC;AAChC,cAAc,gBAAgB,CAAC;AAC/B,cAAc,YAAY,CAAC;AAE3B,aAAa;AACb,cAAc,aAAa,CAAC;AAC5B,cAAc,cAAc,CAAC"}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Hook to access the current theme from YouVersionContext
|
|
3
|
+
*
|
|
4
|
+
* @returns The current theme ('light' or 'dark'), defaults to 'light' if provider is missing
|
|
5
|
+
*
|
|
6
|
+
* @example
|
|
7
|
+
* ```tsx
|
|
8
|
+
* function MyComponent() {
|
|
9
|
+
* const theme = useTheme();
|
|
10
|
+
* }
|
|
11
|
+
* ```
|
|
12
|
+
*/
|
|
13
|
+
export declare function useTheme(): 'light' | 'dark';
|
|
14
|
+
//# sourceMappingURL=useTheme.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useTheme.d.ts","sourceRoot":"","sources":["../src/useTheme.ts"],"names":[],"mappings":"AAKA;;;;;;;;;;;GAWG;AACH,wBAAgB,QAAQ,IAAI,OAAO,GAAG,MAAM,CAK3C"}
|
package/dist/useTheme.js
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
import { useContext } from 'react';
|
|
3
|
+
import { YouVersionContext } from './context';
|
|
4
|
+
/**
|
|
5
|
+
* Hook to access the current theme from YouVersionContext
|
|
6
|
+
*
|
|
7
|
+
* @returns The current theme ('light' or 'dark'), defaults to 'light' if provider is missing
|
|
8
|
+
*
|
|
9
|
+
* @example
|
|
10
|
+
* ```tsx
|
|
11
|
+
* function MyComponent() {
|
|
12
|
+
* const theme = useTheme();
|
|
13
|
+
* }
|
|
14
|
+
* ```
|
|
15
|
+
*/
|
|
16
|
+
export function useTheme() {
|
|
17
|
+
const context = useContext(YouVersionContext);
|
|
18
|
+
// Default to 'light' to match YouVersionProvider's default
|
|
19
|
+
return context?.theme || 'light';
|
|
20
|
+
}
|
|
21
|
+
//# sourceMappingURL=useTheme.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useTheme.js","sourceRoot":"","sources":["../src/useTheme.ts"],"names":[],"mappings":"AAAA,YAAY,CAAC;AAEb,OAAO,EAAE,UAAU,EAAE,MAAM,OAAO,CAAC;AACnC,OAAO,EAAE,iBAAiB,EAAE,MAAM,WAAW,CAAC;AAE9C;;;;;;;;;;;GAWG;AACH,MAAM,UAAU,QAAQ;IACtB,MAAM,OAAO,GAAG,UAAU,CAAC,iBAAiB,CAAC,CAAC;IAE9C,2DAA2D;IAC3D,OAAO,OAAO,EAAE,KAAK,IAAI,OAAO,CAAC;AACnC,CAAC"}
|
package/dist/useYVAuth.d.ts
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import { type AuthenticationState, type
|
|
1
|
+
import { type AuthenticationState, type SignInWithYouVersionResult, type YouVersionUserInfo, type AuthenticationScopes } from '@youversion/platform-core';
|
|
2
2
|
export interface UseYVAuthReturn {
|
|
3
3
|
auth: AuthenticationState;
|
|
4
4
|
signIn: (params: {
|
|
5
5
|
redirectUrl: string;
|
|
6
|
-
|
|
6
|
+
scopes?: AuthenticationScopes[];
|
|
7
7
|
}) => Promise<void>;
|
|
8
8
|
signOut: () => void;
|
|
9
9
|
processCallback: () => Promise<SignInWithYouVersionResult | null>;
|
|
@@ -29,7 +29,6 @@ export interface UseYVAuthReturn {
|
|
|
29
29
|
* try {
|
|
30
30
|
* await signIn({
|
|
31
31
|
* redirectUrl: 'https://myapp.com/callback',
|
|
32
|
-
* permissions: [SignInWithYouVersionPermission.bibles]
|
|
33
32
|
* });
|
|
34
33
|
* } catch (error) {
|
|
35
34
|
* console.error('Sign in failed:', error);
|
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,
|
|
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;IAC5F,OAAO,EAAE,MAAM,IAAI,CAAC;IAGpB,eAAe,EAAE,MAAM,OAAO,CAAC,0BAA0B,GAAG,IAAI,CAAC,CAAC;IAGlE,QAAQ,EAAE,kBAAkB,GAAG,IAAI,CAAC;CACrC;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAkFG;AACH,wBAAgB,SAAS,IAAI,eAAe,CA+D3C"}
|
package/dist/useYVAuth.js
CHANGED
|
@@ -21,7 +21,6 @@ import { useYouVersionAuthContext } from './context/YouVersionAuthContext';
|
|
|
21
21
|
* try {
|
|
22
22
|
* await signIn({
|
|
23
23
|
* redirectUrl: 'https://myapp.com/callback',
|
|
24
|
-
* permissions: [SignInWithYouVersionPermission.bibles]
|
|
25
24
|
* });
|
|
26
25
|
* } catch (error) {
|
|
27
26
|
* console.error('Sign in failed:', error);
|
|
@@ -101,8 +100,13 @@ export function useYVAuth() {
|
|
|
101
100
|
return { accessToken: null, idToken: null };
|
|
102
101
|
}, []);
|
|
103
102
|
// Sign in function
|
|
104
|
-
const signIn = useCallback(async ({ redirectUrl,
|
|
105
|
-
|
|
103
|
+
const signIn = useCallback(async ({ redirectUrl, scopes }) => {
|
|
104
|
+
if (scopes) {
|
|
105
|
+
await YouVersionAPIUsers.signIn(redirectUrl, scopes);
|
|
106
|
+
}
|
|
107
|
+
else {
|
|
108
|
+
await YouVersionAPIUsers.signIn(redirectUrl);
|
|
109
|
+
}
|
|
106
110
|
// Note: This will redirect, so code after this won't execute
|
|
107
111
|
}, []);
|
|
108
112
|
// Process callback function
|
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;AAiB3E;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAkFG;AACH,MAAM,UAAU,SAAS;IACvB,uCAAuC;IACvC,MAAM,EAAE,QAAQ,EAAE,WAAW,EAAE,SAAS,EAAE,KAAK,EAAE,GAAG,wBAAwB,EAAE,CAAC;IAE/E,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,OA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"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@youversion/platform-react-hooks",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.10.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": "0.
|
|
25
|
+
"@youversion/platform-core": "0.10.0"
|
|
26
26
|
},
|
|
27
27
|
"peerDependencies": {
|
|
28
28
|
"react": ">=19.1.0 <20.0.0"
|
|
@@ -40,7 +40,6 @@ export const createMockAuthResult = (
|
|
|
40
40
|
idToken: 'id-token',
|
|
41
41
|
refreshToken: 'refresh-token',
|
|
42
42
|
expiresIn: 3600,
|
|
43
|
-
permissions: ['bibles', 'highlights'],
|
|
44
43
|
yvpUserId: 'test-yvp-user-id',
|
|
45
44
|
profilePicture: 'https://example.com/profile.jpg',
|
|
46
45
|
...overrides,
|
|
@@ -91,7 +91,6 @@ vi.mock('@youversion/platform-core', () => {
|
|
|
91
91
|
expiryDate: Date | undefined;
|
|
92
92
|
refreshToken: string | undefined;
|
|
93
93
|
idToken: string | undefined;
|
|
94
|
-
permissions: string[] | undefined;
|
|
95
94
|
yvpUserId: string | undefined;
|
|
96
95
|
name: string | undefined;
|
|
97
96
|
profilePicture: string | undefined;
|
|
@@ -102,7 +101,6 @@ vi.mock('@youversion/platform-core', () => {
|
|
|
102
101
|
expiresIn?: number;
|
|
103
102
|
refreshToken?: string;
|
|
104
103
|
idToken?: string;
|
|
105
|
-
permissions?: string[];
|
|
106
104
|
yvpUserId?: string;
|
|
107
105
|
name?: string;
|
|
108
106
|
profilePicture?: string;
|
|
@@ -114,7 +112,6 @@ vi.mock('@youversion/platform-core', () => {
|
|
|
114
112
|
: new Date();
|
|
115
113
|
this.refreshToken = props.refreshToken;
|
|
116
114
|
this.idToken = props.idToken;
|
|
117
|
-
this.permissions = props.permissions;
|
|
118
115
|
this.yvpUserId = props.yvpUserId;
|
|
119
116
|
this.name = props.name;
|
|
120
117
|
this.profilePicture = props.profilePicture;
|
|
@@ -9,6 +9,7 @@ interface YouVersionProviderPropsBase {
|
|
|
9
9
|
children: ReactNode;
|
|
10
10
|
appKey: string;
|
|
11
11
|
apiHost?: string;
|
|
12
|
+
theme?: 'light' | 'dark';
|
|
12
13
|
}
|
|
13
14
|
|
|
14
15
|
interface YouVersionProviderPropsWithAuth extends YouVersionProviderPropsBase {
|
|
@@ -26,7 +27,7 @@ const AuthProvider = lazy(() => import('./YouVersionAuthProvider'));
|
|
|
26
27
|
export function YouVersionProvider(
|
|
27
28
|
props: PropsWithChildren<YouVersionProviderPropsWithAuth | YouVersionProviderPropsWithoutAuth>,
|
|
28
29
|
): React.ReactElement {
|
|
29
|
-
const { appKey, apiHost = 'api.youversion.com', includeAuth, children } = props;
|
|
30
|
+
const { appKey, apiHost = 'api.youversion.com', includeAuth, theme = 'light', children } = props;
|
|
30
31
|
|
|
31
32
|
// Syncing appKey and apiHost to YouVersionPlatformConfiguration
|
|
32
33
|
// so that this can be in sync with any other code that uses
|
|
@@ -43,11 +44,16 @@ export function YouVersionProvider(
|
|
|
43
44
|
// Installation ID gets set automatically by YouVersionPlatformConfiguration
|
|
44
45
|
return (
|
|
45
46
|
<YouVersionContext.Provider
|
|
46
|
-
value={{
|
|
47
|
+
value={{
|
|
48
|
+
appKey,
|
|
49
|
+
apiHost,
|
|
50
|
+
installationId: YouVersionPlatformConfiguration.installationId,
|
|
51
|
+
theme,
|
|
52
|
+
}}
|
|
47
53
|
>
|
|
48
54
|
<Suspense>
|
|
49
55
|
<AuthProvider config={{ appKey, apiHost, redirectUri: authRedirectUrl }}>
|
|
50
|
-
|
|
56
|
+
{children}
|
|
51
57
|
</AuthProvider>
|
|
52
58
|
</Suspense>
|
|
53
59
|
</YouVersionContext.Provider>
|
package/src/index.ts
CHANGED
package/src/useTheme.ts
ADDED
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
|
|
3
|
+
import { useContext } from 'react';
|
|
4
|
+
import { YouVersionContext } from './context';
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* Hook to access the current theme from YouVersionContext
|
|
8
|
+
*
|
|
9
|
+
* @returns The current theme ('light' or 'dark'), defaults to 'light' if provider is missing
|
|
10
|
+
*
|
|
11
|
+
* @example
|
|
12
|
+
* ```tsx
|
|
13
|
+
* function MyComponent() {
|
|
14
|
+
* const theme = useTheme();
|
|
15
|
+
* }
|
|
16
|
+
* ```
|
|
17
|
+
*/
|
|
18
|
+
export function useTheme(): 'light' | 'dark' {
|
|
19
|
+
const context = useContext(YouVersionContext);
|
|
20
|
+
|
|
21
|
+
// Default to 'light' to match YouVersionProvider's default
|
|
22
|
+
return context?.theme || 'light';
|
|
23
|
+
}
|
package/src/useYVAuth.test.tsx
CHANGED
|
@@ -1,15 +1,12 @@
|
|
|
1
1
|
/* eslint-disable @typescript-eslint/unbound-method, @typescript-eslint/no-unsafe-argument */
|
|
2
2
|
import { describe, it, expect, vi, beforeEach, afterEach } from 'vitest';
|
|
3
3
|
import { renderHook, act } from '@testing-library/react';
|
|
4
|
-
import {
|
|
5
|
-
YouVersionAPIUsers,
|
|
6
|
-
YouVersionPlatformConfiguration,
|
|
7
|
-
SignInWithYouVersionPermission,
|
|
8
|
-
} from '@youversion/platform-core';
|
|
4
|
+
import { YouVersionAPIUsers, YouVersionPlatformConfiguration } from '@youversion/platform-core';
|
|
9
5
|
import { useYVAuth } from './useYVAuth';
|
|
10
6
|
import { YouVersionAuthContext } from './context/YouVersionAuthContext';
|
|
11
7
|
import { createMockUserInfo, createMockAuthResult } from './__tests__/mocks/auth';
|
|
12
8
|
import { createAuthProviderWrapper } from './__tests__/utils/test-utils';
|
|
9
|
+
import type { AuthenticationScopes } from '@youversion/platform-core';
|
|
13
10
|
|
|
14
11
|
// Mock the core modules
|
|
15
12
|
vi.mock('@youversion/platform-core', () => {
|
|
@@ -94,7 +91,6 @@ vi.mock('@youversion/platform-core', () => {
|
|
|
94
91
|
expiryDate: Date | undefined;
|
|
95
92
|
refreshToken: string | undefined;
|
|
96
93
|
idToken: string | undefined;
|
|
97
|
-
permissions: string[] | undefined;
|
|
98
94
|
yvpUserId: string | undefined;
|
|
99
95
|
name: string | undefined;
|
|
100
96
|
profilePicture: string | undefined;
|
|
@@ -105,7 +101,6 @@ vi.mock('@youversion/platform-core', () => {
|
|
|
105
101
|
expiresIn?: number;
|
|
106
102
|
refreshToken?: string;
|
|
107
103
|
idToken?: string;
|
|
108
|
-
permissions?: string[];
|
|
109
104
|
yvpUserId?: string;
|
|
110
105
|
name?: string;
|
|
111
106
|
profilePicture?: string;
|
|
@@ -117,7 +112,6 @@ vi.mock('@youversion/platform-core', () => {
|
|
|
117
112
|
: new Date();
|
|
118
113
|
this.refreshToken = props.refreshToken;
|
|
119
114
|
this.idToken = props.idToken;
|
|
120
|
-
this.permissions = props.permissions;
|
|
121
115
|
this.yvpUserId = props.yvpUserId;
|
|
122
116
|
this.name = props.name;
|
|
123
117
|
this.profilePicture = props.profilePicture;
|
|
@@ -199,19 +193,15 @@ describe('useYVAuth', () => {
|
|
|
199
193
|
it('should call YouVersionAPIUsers.signIn with correct parameters', async () => {
|
|
200
194
|
const { result } = await renderAuthHook();
|
|
201
195
|
const redirectUrl = 'https://example.com/callback';
|
|
202
|
-
const permissions = [SignInWithYouVersionPermission.bibles];
|
|
203
196
|
|
|
204
197
|
await act(async () => {
|
|
205
|
-
await result.current.signIn({ redirectUrl,
|
|
198
|
+
await result.current.signIn({ redirectUrl, scopes: ['profile'] });
|
|
206
199
|
});
|
|
207
200
|
|
|
208
|
-
expect(vi.mocked(YouVersionAPIUsers.signIn)).toHaveBeenCalledWith(
|
|
209
|
-
new Set(permissions),
|
|
210
|
-
redirectUrl,
|
|
211
|
-
);
|
|
201
|
+
expect(vi.mocked(YouVersionAPIUsers.signIn)).toHaveBeenCalledWith(redirectUrl, ['profile']);
|
|
212
202
|
});
|
|
213
203
|
|
|
214
|
-
it('should call signIn with empty
|
|
204
|
+
it('should call signIn with empty scopes when not provided', async () => {
|
|
215
205
|
const { result } = await renderAuthHook();
|
|
216
206
|
const redirectUrl = 'https://example.com/callback';
|
|
217
207
|
|
|
@@ -219,7 +209,32 @@ describe('useYVAuth', () => {
|
|
|
219
209
|
await result.current.signIn({ redirectUrl });
|
|
220
210
|
});
|
|
221
211
|
|
|
222
|
-
expect(vi.mocked(YouVersionAPIUsers.signIn)).toHaveBeenCalledWith(
|
|
212
|
+
expect(vi.mocked(YouVersionAPIUsers.signIn)).toHaveBeenCalledWith(redirectUrl);
|
|
213
|
+
});
|
|
214
|
+
|
|
215
|
+
it('should call YouVersionAPIUsers.signIn exactly once with scopes', async () => {
|
|
216
|
+
const { result } = await renderAuthHook();
|
|
217
|
+
const redirectUrl = 'https://example.com/callback';
|
|
218
|
+
const scopes: AuthenticationScopes[] = ['profile', 'email'];
|
|
219
|
+
|
|
220
|
+
await act(async () => {
|
|
221
|
+
await result.current.signIn({ redirectUrl, scopes });
|
|
222
|
+
});
|
|
223
|
+
|
|
224
|
+
expect(vi.mocked(YouVersionAPIUsers.signIn)).toHaveBeenCalledTimes(1);
|
|
225
|
+
expect(vi.mocked(YouVersionAPIUsers.signIn)).toHaveBeenCalledWith(redirectUrl, scopes);
|
|
226
|
+
});
|
|
227
|
+
|
|
228
|
+
it('should call YouVersionAPIUsers.signIn exactly once without scopes', async () => {
|
|
229
|
+
const { result } = await renderAuthHook();
|
|
230
|
+
const redirectUrl = 'https://example.com/callback';
|
|
231
|
+
|
|
232
|
+
await act(async () => {
|
|
233
|
+
await result.current.signIn({ redirectUrl });
|
|
234
|
+
});
|
|
235
|
+
|
|
236
|
+
expect(vi.mocked(YouVersionAPIUsers.signIn)).toHaveBeenCalledTimes(1);
|
|
237
|
+
expect(vi.mocked(YouVersionAPIUsers.signIn)).toHaveBeenCalledWith(redirectUrl);
|
|
223
238
|
});
|
|
224
239
|
|
|
225
240
|
it('should throw error when signIn fails', async () => {
|
package/src/useYVAuth.ts
CHANGED
|
@@ -3,9 +3,9 @@ import {
|
|
|
3
3
|
YouVersionAPIUsers,
|
|
4
4
|
YouVersionPlatformConfiguration,
|
|
5
5
|
type AuthenticationState,
|
|
6
|
-
type SignInWithYouVersionPermissionValues,
|
|
7
6
|
type SignInWithYouVersionResult,
|
|
8
7
|
type YouVersionUserInfo,
|
|
8
|
+
type AuthenticationScopes,
|
|
9
9
|
} from '@youversion/platform-core';
|
|
10
10
|
import { useYouVersionAuthContext } from './context/YouVersionAuthContext';
|
|
11
11
|
|
|
@@ -14,10 +14,7 @@ export interface UseYVAuthReturn {
|
|
|
14
14
|
auth: AuthenticationState;
|
|
15
15
|
|
|
16
16
|
// Actions
|
|
17
|
-
signIn: (params: {
|
|
18
|
-
redirectUrl: string;
|
|
19
|
-
permissions?: SignInWithYouVersionPermissionValues[];
|
|
20
|
-
}) => Promise<void>;
|
|
17
|
+
signIn: (params: { redirectUrl: string; scopes?: AuthenticationScopes[] }) => Promise<void>;
|
|
21
18
|
signOut: () => void;
|
|
22
19
|
|
|
23
20
|
// Callback processing (for callback page) - caches user info
|
|
@@ -47,7 +44,6 @@ export interface UseYVAuthReturn {
|
|
|
47
44
|
* try {
|
|
48
45
|
* await signIn({
|
|
49
46
|
* redirectUrl: 'https://myapp.com/callback',
|
|
50
|
-
* permissions: [SignInWithYouVersionPermission.bibles]
|
|
51
47
|
* });
|
|
52
48
|
* } catch (error) {
|
|
53
49
|
* console.error('Sign in failed:', error);
|
|
@@ -131,14 +127,12 @@ export function useYVAuth(): UseYVAuthReturn {
|
|
|
131
127
|
|
|
132
128
|
// Sign in function
|
|
133
129
|
const signIn = useCallback(
|
|
134
|
-
async ({
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
}) => {
|
|
141
|
-
await YouVersionAPIUsers.signIn(new Set(permissions), redirectUrl);
|
|
130
|
+
async ({ redirectUrl, scopes }: { redirectUrl: string; scopes?: AuthenticationScopes[] }) => {
|
|
131
|
+
if (scopes) {
|
|
132
|
+
await YouVersionAPIUsers.signIn(redirectUrl, scopes);
|
|
133
|
+
} else {
|
|
134
|
+
await YouVersionAPIUsers.signIn(redirectUrl);
|
|
135
|
+
}
|
|
142
136
|
// Note: This will redirect, so code after this won't execute
|
|
143
137
|
},
|
|
144
138
|
[],
|