@youversion/platform-react-hooks 1.13.0 → 1.14.1
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/AGENTS.md +2 -2
- package/CHANGELOG.md +19 -0
- package/README.md +1 -1
- package/dist/context/YouVersionProvider.d.ts +1 -1
- package/dist/context/YouVersionProvider.d.ts.map +1 -1
- package/dist/context/YouVersionProvider.js +29 -3
- package/dist/context/YouVersionProvider.js.map +1 -1
- package/dist/useInitData.d.ts +2 -2
- package/dist/useInitData.d.ts.map +1 -1
- package/dist/useInitData.js +3 -2
- package/dist/useInitData.js.map +1 -1
- package/package.json +2 -2
- package/src/context/YouVersionProvider.tsx +33 -4
- package/src/useInitData.ts +4 -3
package/.turbo/turbo-build.log
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
|
|
2
|
-
> @youversion/platform-react-hooks@1.
|
|
2
|
+
> @youversion/platform-react-hooks@1.14.1 build /home/runner/work/platform-sdk-react/platform-sdk-react/packages/hooks
|
|
3
3
|
> tsc -p tsconfig.build.json
|
|
4
4
|
|
package/AGENTS.md
CHANGED
|
@@ -102,7 +102,7 @@ import { useChapter, useVersion, useVerseOfTheDay } from '@youversion/platform-r
|
|
|
102
102
|
// Fetch a Bible chapter
|
|
103
103
|
function ChapterView() {
|
|
104
104
|
const { chapter, loading, error } = useChapter(
|
|
105
|
-
|
|
105
|
+
3034, // versionId (e.g., 3034 = Berean Standard Bible)
|
|
106
106
|
'JHN', // book (USFM abbreviation)
|
|
107
107
|
3 // chapter number
|
|
108
108
|
);
|
|
@@ -114,7 +114,7 @@ function ChapterView() {
|
|
|
114
114
|
|
|
115
115
|
// Fetch Bible version metadata
|
|
116
116
|
function VersionInfo() {
|
|
117
|
-
const { version, loading } = useVersion(
|
|
117
|
+
const { version, loading } = useVersion(3034);
|
|
118
118
|
if (loading) return <div>Loading...</div>;
|
|
119
119
|
return <div>{version?.name} ({version?.abbreviation})</div>;
|
|
120
120
|
}
|
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,24 @@
|
|
|
1
1
|
# @youversion/platform-react-hooks
|
|
2
2
|
|
|
3
|
+
## 1.14.1
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- 51d97e5: Standardized our default Bible Version to one that does not require opt-in license to use, so that our components work out of the box by default
|
|
8
|
+
- Updated dependencies [51d97e5]
|
|
9
|
+
- @youversion/platform-core@1.14.1
|
|
10
|
+
|
|
11
|
+
## 1.14.0
|
|
12
|
+
|
|
13
|
+
### Minor Changes
|
|
14
|
+
|
|
15
|
+
- 2d2c597: Added 'system' as an option to YouVersionProvider theme prop that resolves via `prefers-color-scheme` with live OS change listener
|
|
16
|
+
|
|
17
|
+
### Patch Changes
|
|
18
|
+
|
|
19
|
+
- Updated dependencies [2d2c597]
|
|
20
|
+
- @youversion/platform-core@1.14.0
|
|
21
|
+
|
|
3
22
|
## 1.13.0
|
|
4
23
|
|
|
5
24
|
### Minor Changes
|
package/README.md
CHANGED
|
@@ -30,7 +30,7 @@ Get your App Key at [platform.youversion.com](https://platform.youversion.com/)
|
|
|
30
30
|
import { YouVersionProvider, usePassage } from '@youversion/platform-react-hooks';
|
|
31
31
|
|
|
32
32
|
function BibleVerse() {
|
|
33
|
-
const { passage, loading } = usePassage({ versionId:
|
|
33
|
+
const { passage, loading } = usePassage({ versionId: 3034, usfm: 'JHN.3.16' });
|
|
34
34
|
if (loading) return <div>Loading...</div>;
|
|
35
35
|
return <div dangerouslySetInnerHTML={{ __html: passage?.content || '' }} />;
|
|
36
36
|
}
|
|
@@ -3,7 +3,7 @@ interface YouVersionProviderPropsBase {
|
|
|
3
3
|
children: ReactNode;
|
|
4
4
|
appKey: string;
|
|
5
5
|
apiHost?: string;
|
|
6
|
-
theme?: 'light' | 'dark';
|
|
6
|
+
theme?: 'light' | 'dark' | 'system';
|
|
7
7
|
}
|
|
8
8
|
interface YouVersionProviderPropsWithAuth extends YouVersionProviderPropsBase {
|
|
9
9
|
authRedirectUrl: string;
|
|
@@ -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;IACjB,KAAK,CAAC,EAAE,OAAO,GAAG,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,GAAG,QAAQ,CAAC;CACrC;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;AAgCD,wBAAgB,kBAAkB,CAChC,KAAK,EAAE,iBAAiB,CAAC,+BAA+B,GAAG,kCAAkC,CAAC,GAC7F,KAAK,CAAC,YAAY,CAkDpB"}
|
|
@@ -1,11 +1,37 @@
|
|
|
1
1
|
'use client';
|
|
2
2
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
3
|
-
import { lazy, Suspense, useEffect } from 'react';
|
|
3
|
+
import { lazy, Suspense, useEffect, useState } from 'react';
|
|
4
4
|
import { YouVersionContext } from './YouVersionContext';
|
|
5
5
|
import { YouVersionPlatformConfiguration } from '@youversion/platform-core';
|
|
6
6
|
const AuthProvider = lazy(() => import('./YouVersionAuthProvider'));
|
|
7
|
+
function useResolvedTheme(theme) {
|
|
8
|
+
const [resolved, setResolved] = useState(() => {
|
|
9
|
+
if (theme !== 'system')
|
|
10
|
+
return theme;
|
|
11
|
+
if (typeof window === 'undefined')
|
|
12
|
+
return 'light';
|
|
13
|
+
return window.matchMedia('(prefers-color-scheme: dark)').matches ? 'dark' : 'light';
|
|
14
|
+
});
|
|
15
|
+
useEffect(() => {
|
|
16
|
+
if (theme !== 'system') {
|
|
17
|
+
setResolved(theme);
|
|
18
|
+
return;
|
|
19
|
+
}
|
|
20
|
+
if (typeof window === 'undefined')
|
|
21
|
+
return;
|
|
22
|
+
const mediaQueryList = window.matchMedia('(prefers-color-scheme: dark)');
|
|
23
|
+
setResolved(mediaQueryList.matches ? 'dark' : 'light');
|
|
24
|
+
const handler = (e) => {
|
|
25
|
+
setResolved(e.matches ? 'dark' : 'light');
|
|
26
|
+
};
|
|
27
|
+
mediaQueryList.addEventListener('change', handler);
|
|
28
|
+
return () => mediaQueryList.removeEventListener('change', handler);
|
|
29
|
+
}, [theme]);
|
|
30
|
+
return resolved;
|
|
31
|
+
}
|
|
7
32
|
export function YouVersionProvider(props) {
|
|
8
33
|
const { appKey, apiHost = 'api.youversion.com', includeAuth, theme = 'light', children } = props;
|
|
34
|
+
const resolvedTheme = useResolvedTheme(theme);
|
|
9
35
|
// Syncing appKey and apiHost to YouVersionPlatformConfiguration
|
|
10
36
|
// so that this can be in sync with any other code that uses
|
|
11
37
|
// the YouVersionPlatformConfiguration, of which a lot of our
|
|
@@ -21,7 +47,7 @@ export function YouVersionProvider(props) {
|
|
|
21
47
|
appKey,
|
|
22
48
|
apiHost,
|
|
23
49
|
installationId: YouVersionPlatformConfiguration.installationId,
|
|
24
|
-
theme,
|
|
50
|
+
theme: resolvedTheme,
|
|
25
51
|
authEnabled: !!includeAuth,
|
|
26
52
|
}, children: _jsx(Suspense, { children: _jsx(AuthProvider, { config: { appKey, apiHost, redirectUri: authRedirectUrl }, children: children }) }) }));
|
|
27
53
|
}
|
|
@@ -30,7 +56,7 @@ export function YouVersionProvider(props) {
|
|
|
30
56
|
appKey,
|
|
31
57
|
apiHost,
|
|
32
58
|
installationId: YouVersionPlatformConfiguration.installationId,
|
|
33
|
-
theme,
|
|
59
|
+
theme: resolvedTheme,
|
|
34
60
|
authEnabled: !!includeAuth,
|
|
35
61
|
}, children: children }));
|
|
36
62
|
}
|
|
@@ -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;
|
|
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,QAAQ,EAAE,MAAM,OAAO,CAAC;AAC5D,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,SAAS,gBAAgB,CAAC,KAAkC;IAC1D,MAAM,CAAC,QAAQ,EAAE,WAAW,CAAC,GAAG,QAAQ,CAAmB,GAAG,EAAE;QAC9D,IAAI,KAAK,KAAK,QAAQ;YAAE,OAAO,KAAK,CAAC;QACrC,IAAI,OAAO,MAAM,KAAK,WAAW;YAAE,OAAO,OAAO,CAAC;QA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M,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,EAAE,aAAa;gBACpB,WAAW,EAAE,CAAC,CAAC,WAAW;aAC3B,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;YACL,MAAM;YACN,OAAO;YACP,cAAc,EAAE,+BAA+B,CAAC,cAAc;YAC9D,KAAK,EAAE,aAAa;YACpB,WAAW,EAAE,CAAC,CAAC,WAAW;SAC3B,YAEA,QAAQ,GACkB,CAC9B,CAAC;AACJ,CAAC"}
|
package/dist/useInitData.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import type { BibleChapter, BibleVersion
|
|
1
|
+
import type { BibleBook, BibleChapter, BibleVersion } from '@youversion/platform-core';
|
|
2
2
|
export declare const DEFAULT: {
|
|
3
|
-
readonly VERSION:
|
|
3
|
+
readonly VERSION: 3034;
|
|
4
4
|
readonly BOOK: "GEN";
|
|
5
5
|
readonly CHAPTER: 1;
|
|
6
6
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useInitData.d.ts","sourceRoot":"","sources":["../src/useInitData.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"useInitData.d.ts","sourceRoot":"","sources":["../src/useInitData.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,YAAY,EAAE,YAAY,EAAE,MAAM,2BAA2B,CAAC;AAMvF,eAAO,MAAM,OAAO;;;;CAIV,CAAC;AAEX,UAAU,KAAK;IACb,OAAO,EAAE,MAAM,CAAC;IAChB,IAAI,EAAE,MAAM,CAAC;IACb,OAAO,EAAE,MAAM,CAAC;CACjB;AAED,UAAU,QAAQ;IAChB,OAAO,EAAE,YAAY,CAAC;IACtB,IAAI,EAAE,SAAS,CAAC;IAChB,OAAO,EAAE,YAAY,CAAC;CACvB;AAED,wBAAgB,WAAW,CACzB,EAAE,OAAO,EAAE,IAAI,EAAE,OAAO,EAAE,GAAE,KAI3B,GACA;IACD,OAAO,EAAE,OAAO,CAAC;IACjB,KAAK,EAAE,MAAM,GAAG,IAAI,CAAC;IACrB,IAAI,EAAE,QAAQ,GAAG,IAAI,CAAC;CACvB,CAoBA"}
|
package/dist/useInitData.js
CHANGED
|
@@ -1,8 +1,9 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { DEFAULT_LICENSE_FREE_BIBLE_VERSION } from '@youversion/platform-core';
|
|
2
2
|
import { useBook } from './useBook';
|
|
3
3
|
import { useChapter } from './useChapter';
|
|
4
|
+
import { useVersion } from './useVersion';
|
|
4
5
|
export const DEFAULT = {
|
|
5
|
-
VERSION:
|
|
6
|
+
VERSION: DEFAULT_LICENSE_FREE_BIBLE_VERSION,
|
|
6
7
|
BOOK: 'GEN',
|
|
7
8
|
CHAPTER: 1,
|
|
8
9
|
};
|
package/dist/useInitData.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useInitData.js","sourceRoot":"","sources":["../src/useInitData.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"useInitData.js","sourceRoot":"","sources":["../src/useInitData.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,kCAAkC,EAAE,MAA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AE,OAAO,EAAE,WAAW,EAAE,CAAC,CAAC,CAAC,IAAI;KAC/F,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.14.1",
|
|
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.14.1"
|
|
26
26
|
},
|
|
27
27
|
"peerDependencies": {
|
|
28
28
|
"react": ">=19.1.0 <20.0.0"
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
'use client';
|
|
2
2
|
|
|
3
3
|
import type { PropsWithChildren, ReactNode } from 'react';
|
|
4
|
-
import { lazy, Suspense, useEffect } from 'react';
|
|
4
|
+
import { lazy, Suspense, useEffect, useState } from 'react';
|
|
5
5
|
import { YouVersionContext } from './YouVersionContext';
|
|
6
6
|
import { YouVersionPlatformConfiguration } from '@youversion/platform-core';
|
|
7
7
|
|
|
@@ -9,7 +9,7 @@ interface YouVersionProviderPropsBase {
|
|
|
9
9
|
children: ReactNode;
|
|
10
10
|
appKey: string;
|
|
11
11
|
apiHost?: string;
|
|
12
|
-
theme?: 'light' | 'dark';
|
|
12
|
+
theme?: 'light' | 'dark' | 'system';
|
|
13
13
|
}
|
|
14
14
|
|
|
15
15
|
interface YouVersionProviderPropsWithAuth extends YouVersionProviderPropsBase {
|
|
@@ -24,10 +24,39 @@ interface YouVersionProviderPropsWithoutAuth extends YouVersionProviderPropsBase
|
|
|
24
24
|
|
|
25
25
|
const AuthProvider = lazy(() => import('./YouVersionAuthProvider'));
|
|
26
26
|
|
|
27
|
+
function useResolvedTheme(theme: 'light' | 'dark' | 'system'): 'light' | 'dark' {
|
|
28
|
+
const [resolved, setResolved] = useState<'light' | 'dark'>(() => {
|
|
29
|
+
if (theme !== 'system') return theme;
|
|
30
|
+
if (typeof window === 'undefined') return 'light';
|
|
31
|
+
return window.matchMedia('(prefers-color-scheme: dark)').matches ? 'dark' : 'light';
|
|
32
|
+
});
|
|
33
|
+
|
|
34
|
+
useEffect(() => {
|
|
35
|
+
if (theme !== 'system') {
|
|
36
|
+
setResolved(theme);
|
|
37
|
+
return;
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
if (typeof window === 'undefined') return;
|
|
41
|
+
|
|
42
|
+
const mediaQueryList = window.matchMedia('(prefers-color-scheme: dark)');
|
|
43
|
+
setResolved(mediaQueryList.matches ? 'dark' : 'light');
|
|
44
|
+
|
|
45
|
+
const handler = (e: MediaQueryListEvent) => {
|
|
46
|
+
setResolved(e.matches ? 'dark' : 'light');
|
|
47
|
+
};
|
|
48
|
+
mediaQueryList.addEventListener('change', handler);
|
|
49
|
+
return () => mediaQueryList.removeEventListener('change', handler);
|
|
50
|
+
}, [theme]);
|
|
51
|
+
|
|
52
|
+
return resolved;
|
|
53
|
+
}
|
|
54
|
+
|
|
27
55
|
export function YouVersionProvider(
|
|
28
56
|
props: PropsWithChildren<YouVersionProviderPropsWithAuth | YouVersionProviderPropsWithoutAuth>,
|
|
29
57
|
): React.ReactElement {
|
|
30
58
|
const { appKey, apiHost = 'api.youversion.com', includeAuth, theme = 'light', children } = props;
|
|
59
|
+
const resolvedTheme = useResolvedTheme(theme);
|
|
31
60
|
|
|
32
61
|
// Syncing appKey and apiHost to YouVersionPlatformConfiguration
|
|
33
62
|
// so that this can be in sync with any other code that uses
|
|
@@ -48,7 +77,7 @@ export function YouVersionProvider(
|
|
|
48
77
|
appKey,
|
|
49
78
|
apiHost,
|
|
50
79
|
installationId: YouVersionPlatformConfiguration.installationId,
|
|
51
|
-
theme,
|
|
80
|
+
theme: resolvedTheme,
|
|
52
81
|
authEnabled: !!includeAuth,
|
|
53
82
|
}}
|
|
54
83
|
>
|
|
@@ -68,7 +97,7 @@ export function YouVersionProvider(
|
|
|
68
97
|
appKey,
|
|
69
98
|
apiHost,
|
|
70
99
|
installationId: YouVersionPlatformConfiguration.installationId,
|
|
71
|
-
theme,
|
|
100
|
+
theme: resolvedTheme,
|
|
72
101
|
authEnabled: !!includeAuth,
|
|
73
102
|
}}
|
|
74
103
|
>
|
package/src/useInitData.ts
CHANGED
|
@@ -1,10 +1,11 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import type { BibleBook, BibleChapter, BibleVersion } from '@youversion/platform-core';
|
|
2
|
+
import { DEFAULT_LICENSE_FREE_BIBLE_VERSION } from '@youversion/platform-core';
|
|
2
3
|
import { useBook } from './useBook';
|
|
3
4
|
import { useChapter } from './useChapter';
|
|
4
|
-
import
|
|
5
|
+
import { useVersion } from './useVersion';
|
|
5
6
|
|
|
6
7
|
export const DEFAULT = {
|
|
7
|
-
VERSION:
|
|
8
|
+
VERSION: DEFAULT_LICENSE_FREE_BIBLE_VERSION,
|
|
8
9
|
BOOK: 'GEN',
|
|
9
10
|
CHAPTER: 1,
|
|
10
11
|
} as const;
|