@youversion/platform-react-hooks 1.21.0 → 1.22.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.
Files changed (97) hide show
  1. package/.turbo/turbo-build.log +21 -1
  2. package/CHANGELOG.md +21 -0
  3. package/dist/YouVersionAuthProvider-VORD6KDZ.js +80 -0
  4. package/dist/chunk-ITHJF2FD.js +17 -0
  5. package/dist/index.cjs +946 -0
  6. package/dist/index.js +788 -26
  7. package/package.json +11 -6
  8. package/tsconfig.build.json +4 -1
  9. package/dist/__tests__/mocks/auth.js +0 -43
  10. package/dist/__tests__/mocks/auth.js.map +0 -1
  11. package/dist/__tests__/mocks/bibles.js +0 -23
  12. package/dist/__tests__/mocks/bibles.js.map +0 -1
  13. package/dist/__tests__/mocks/core-mock-factory.js +0 -138
  14. package/dist/__tests__/mocks/core-mock-factory.js.map +0 -1
  15. package/dist/__tests__/utils/test-utils.js +0 -11
  16. package/dist/__tests__/utils/test-utils.js.map +0 -1
  17. package/dist/context/ReaderContext.js +0 -17
  18. package/dist/context/ReaderContext.js.map +0 -1
  19. package/dist/context/ReaderProvider.js +0 -24
  20. package/dist/context/ReaderProvider.js.map +0 -1
  21. package/dist/context/VerseSelectionContext.js +0 -6
  22. package/dist/context/VerseSelectionContext.js.map +0 -1
  23. package/dist/context/VerseSelectionProvider.js +0 -36
  24. package/dist/context/VerseSelectionProvider.js.map +0 -1
  25. package/dist/context/YouVersionAuthContext.js +0 -13
  26. package/dist/context/YouVersionAuthContext.js.map +0 -1
  27. package/dist/context/YouVersionAuthProvider.js +0 -81
  28. package/dist/context/YouVersionAuthProvider.js.map +0 -1
  29. package/dist/context/YouVersionContext.js +0 -4
  30. package/dist/context/YouVersionContext.js.map +0 -1
  31. package/dist/context/YouVersionProvider.js +0 -63
  32. package/dist/context/YouVersionProvider.js.map +0 -1
  33. package/dist/context/index.js +0 -7
  34. package/dist/context/index.js.map +0 -1
  35. package/dist/index.js.map +0 -1
  36. package/dist/test/setup.js +0 -9
  37. package/dist/test/setup.js.map +0 -1
  38. package/dist/test/utils.js +0 -7
  39. package/dist/test/utils.js.map +0 -1
  40. package/dist/types/auth.js +0 -2
  41. package/dist/types/auth.js.map +0 -1
  42. package/dist/useApiData.js +0 -46
  43. package/dist/useApiData.js.map +0 -1
  44. package/dist/useBibleClient.js +0 -18
  45. package/dist/useBibleClient.js.map +0 -1
  46. package/dist/useBook.js +0 -11
  47. package/dist/useBook.js.map +0 -1
  48. package/dist/useBooks.js +0 -11
  49. package/dist/useBooks.js.map +0 -1
  50. package/dist/useChapter.js +0 -11
  51. package/dist/useChapter.js.map +0 -1
  52. package/dist/useChapterNavigation.js +0 -57
  53. package/dist/useChapterNavigation.js.map +0 -1
  54. package/dist/useChapters.js +0 -13
  55. package/dist/useChapters.js.map +0 -1
  56. package/dist/useFilteredVersions.js +0 -29
  57. package/dist/useFilteredVersions.js.map +0 -1
  58. package/dist/useHighlights.js +0 -41
  59. package/dist/useHighlights.js.map +0 -1
  60. package/dist/useInitData.js +0 -29
  61. package/dist/useInitData.js.map +0 -1
  62. package/dist/useLanguage.js +0 -17
  63. package/dist/useLanguage.js.map +0 -1
  64. package/dist/useLanguageClient.js +0 -18
  65. package/dist/useLanguageClient.js.map +0 -1
  66. package/dist/useLanguages.js +0 -23
  67. package/dist/useLanguages.js.map +0 -1
  68. package/dist/usePassage.js +0 -11
  69. package/dist/usePassage.js.map +0 -1
  70. package/dist/useTheme.js +0 -21
  71. package/dist/useTheme.js.map +0 -1
  72. package/dist/useVOTD.js +0 -9
  73. package/dist/useVOTD.js.map +0 -1
  74. package/dist/useVerse.js +0 -11
  75. package/dist/useVerse.js.map +0 -1
  76. package/dist/useVerseSelection.js +0 -13
  77. package/dist/useVerseSelection.js.map +0 -1
  78. package/dist/useVerses.js +0 -11
  79. package/dist/useVerses.js.map +0 -1
  80. package/dist/useVersion.js +0 -11
  81. package/dist/useVersion.js.map +0 -1
  82. package/dist/useVersions.js +0 -35
  83. package/dist/useVersions.js.map +0 -1
  84. package/dist/useYVAuth.js +0 -144
  85. package/dist/useYVAuth.js.map +0 -1
  86. package/dist/utility/extractTextFromHTML.js +0 -21
  87. package/dist/utility/extractTextFromHTML.js.map +0 -1
  88. package/dist/utility/extractVersesFromHTML.js +0 -26
  89. package/dist/utility/extractVersesFromHTML.js.map +0 -1
  90. package/dist/utility/getDayOfYear.js +0 -5
  91. package/dist/utility/getDayOfYear.js.map +0 -1
  92. package/dist/utility/index.js +0 -6
  93. package/dist/utility/index.js.map +0 -1
  94. package/dist/utility/useDebounce.js +0 -24
  95. package/dist/utility/useDebounce.js.map +0 -1
  96. package/dist/utility/version.js +0 -4
  97. package/dist/utility/version.js.map +0 -1
@@ -1,4 +1,24 @@
1
1
 
2
- > @youversion/platform-react-hooks@1.21.0 build /home/runner/work/platform-sdk-react/platform-sdk-react/packages/hooks
2
+ > @youversion/platform-react-hooks@1.22.1 build /home/runner/work/platform-sdk-react/platform-sdk-react/packages/hooks
3
+ > pnpm build:js && pnpm build:types
4
+
5
+
6
+ > @youversion/platform-react-hooks@1.22.1 build:js /home/runner/work/platform-sdk-react/platform-sdk-react/packages/hooks
7
+ > tsup src/index.ts --format cjs,esm
8
+
9
+ CLI Building entry: src/index.ts
10
+ CLI Using tsconfig: tsconfig.json
11
+ CLI tsup v8.5.0
12
+ CLI Target: es2022
13
+ CJS Build start
14
+ ESM Build start
15
+ CJS dist/index.cjs 29.77 KB
16
+ CJS ⚡️ Build success in 43ms
17
+ ESM dist/index.js 22.81 KB
18
+ ESM dist/YouVersionAuthProvider-VORD6KDZ.js 2.43 KB
19
+ ESM dist/chunk-ITHJF2FD.js 631.00 B
20
+ ESM ⚡️ Build success in 42ms
21
+
22
+ > @youversion/platform-react-hooks@1.22.1 build:types /home/runner/work/platform-sdk-react/platform-sdk-react/packages/hooks
3
23
  > tsc -p tsconfig.build.json
4
24
 
package/CHANGELOG.md CHANGED
@@ -1,5 +1,26 @@
1
1
  # @youversion/platform-react-hooks
2
2
 
3
+ ## 1.22.1
4
+
5
+ ### Patch Changes
6
+
7
+ - b8b5cf0: Fixed hooks package bundling to produce proper CJS and ESM outputs, resolving import failures in strict ESM runtimes like Deno.
8
+ - 2a64020: Updated the Bible App logo on the BibleCard and VerseOfTheDay React components to the latest designs.
9
+ - Updated dependencies [b8b5cf0]
10
+ - Updated dependencies [2a64020]
11
+ - @youversion/platform-core@1.22.1
12
+
13
+ ## 1.22.0
14
+
15
+ ### Minor Changes
16
+
17
+ - ff14f28: We've moved our theme, fonts, and Bible CSS from the React package into our core JS package to make it more framework agnostic so that consumers using any web framework can include our CSS without the React peer dependency.
18
+
19
+ ### Patch Changes
20
+
21
+ - Updated dependencies [ff14f28]
22
+ - @youversion/platform-core@1.22.0
23
+
3
24
  ## 1.21.0
4
25
 
5
26
  ### Patch Changes
@@ -0,0 +1,80 @@
1
+ "use client";
2
+ import {
3
+ YouVersionAuthContext
4
+ } from "./chunk-ITHJF2FD.js";
5
+
6
+ // src/context/YouVersionAuthProvider.tsx
7
+ import { useEffect, useState } from "react";
8
+ import {
9
+ YouVersionAPIUsers,
10
+ YouVersionPlatformConfiguration
11
+ } from "@youversion/platform-core";
12
+ import { jsx } from "react/jsx-runtime";
13
+ function YouVersionAuthProvider({
14
+ config,
15
+ children
16
+ }) {
17
+ const [userInfo, setUserInfo] = useState(null);
18
+ const [isLoading, setIsLoading] = useState(true);
19
+ const [error, setError] = useState(null);
20
+ useEffect(() => {
21
+ let mounted = true;
22
+ const initAuth = async () => {
23
+ YouVersionPlatformConfiguration.appKey = config.appKey;
24
+ YouVersionPlatformConfiguration.apiHost = config.apiHost ?? "api.youversion.com";
25
+ if (typeof window !== "undefined") {
26
+ const urlParams = new URLSearchParams(window.location.search);
27
+ const isOAuthCallback = urlParams.has("state") || urlParams.has("error");
28
+ if (isOAuthCallback) {
29
+ try {
30
+ const result = await YouVersionAPIUsers.handleAuthCallback();
31
+ if (result && YouVersionPlatformConfiguration.idToken) {
32
+ const info = YouVersionAPIUsers.userInfo(YouVersionPlatformConfiguration.idToken);
33
+ if (!mounted) return;
34
+ setUserInfo(info);
35
+ }
36
+ } catch (err) {
37
+ if (!mounted) return;
38
+ setError(err);
39
+ }
40
+ } else {
41
+ const refreshToken = YouVersionPlatformConfiguration.refreshToken;
42
+ if (refreshToken) {
43
+ try {
44
+ await YouVersionAPIUsers.refreshTokenIfNeeded();
45
+ const idToken = YouVersionPlatformConfiguration.idToken;
46
+ if (idToken) {
47
+ const info = YouVersionAPIUsers.userInfo(idToken);
48
+ if (!mounted) return;
49
+ setUserInfo(info);
50
+ } else {
51
+ if (!mounted) return;
52
+ setUserInfo(null);
53
+ }
54
+ } catch {
55
+ if (!mounted) return;
56
+ setUserInfo(null);
57
+ }
58
+ }
59
+ }
60
+ }
61
+ if (!mounted) return;
62
+ setIsLoading(false);
63
+ };
64
+ void initAuth();
65
+ return () => {
66
+ mounted = false;
67
+ };
68
+ }, []);
69
+ const value = {
70
+ userInfo,
71
+ setUserInfo,
72
+ isLoading,
73
+ error,
74
+ redirectUri: config.redirectUri
75
+ };
76
+ return /* @__PURE__ */ jsx(YouVersionAuthContext.Provider, { value, children });
77
+ }
78
+ export {
79
+ YouVersionAuthProvider as default
80
+ };
@@ -0,0 +1,17 @@
1
+ // src/context/YouVersionAuthContext.tsx
2
+ import { createContext, useContext } from "react";
3
+ var YouVersionAuthContext = createContext(null);
4
+ function useYouVersionAuthContext() {
5
+ const context = useContext(YouVersionAuthContext);
6
+ if (!context) {
7
+ throw new Error(
8
+ "useYouVersionAuthContext must be used within an auth provider. Make sure your app is wrapped with <YouVersionAuthProvider> from @youversion/platform-react-hooks or create your own provider using YouVersionAuthContext from @youversion/platform-react-hooks."
9
+ );
10
+ }
11
+ return context;
12
+ }
13
+
14
+ export {
15
+ YouVersionAuthContext,
16
+ useYouVersionAuthContext
17
+ };