@youversion/platform-react-hooks 0.4.3 → 0.5.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 +19 -0
- package/dist/context/BibleSDKContext.d.ts +2 -0
- package/dist/context/BibleSDKContext.d.ts.map +1 -1
- package/dist/context/BibleSDKContext.js.map +1 -1
- package/dist/context/BibleSDKProvider.d.ts +2 -1
- package/dist/context/BibleSDKProvider.d.ts.map +1 -1
- package/dist/context/BibleSDKProvider.js +13 -2
- package/dist/context/BibleSDKProvider.js.map +1 -1
- package/dist/useBibleClient.d.ts.map +1 -1
- package/dist/useBibleClient.js +4 -3
- package/dist/useBibleClient.js.map +1 -1
- package/dist/useHighlights.d.ts.map +1 -1
- package/dist/useHighlights.js +4 -3
- package/dist/useHighlights.js.map +1 -1
- package/dist/useLanguages.d.ts.map +1 -1
- package/dist/useLanguages.js +4 -3
- package/dist/useLanguages.js.map +1 -1
- package/package.json +4 -4
- package/src/context/BibleSDKContext.tsx +2 -0
- package/src/context/BibleSDKProvider.tsx +20 -1
- package/src/useBibleClient.test.tsx +0 -8
- package/src/useBibleClient.ts +6 -3
- package/src/useHighlights.test.tsx +0 -6
- package/src/useHighlights.ts +4 -7
- package/src/useLanguages.test.tsx +0 -6
- package/src/useLanguages.ts +4 -7
- package/src/useVOTD.test.tsx +0 -8
package/.turbo/turbo-build.log
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
|
|
2
|
-
> @youversion/platform-react-hooks@0.
|
|
2
|
+
> @youversion/platform-react-hooks@0.5.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,24 @@
|
|
|
1
1
|
# @youversion/platform-react-hooks
|
|
2
2
|
|
|
3
|
+
## 0.5.0
|
|
4
|
+
|
|
5
|
+
### Minor Changes
|
|
6
|
+
|
|
7
|
+
- e07208d: feat(ui): add share button to verse of the day component
|
|
8
|
+
|
|
9
|
+
### Patch Changes
|
|
10
|
+
|
|
11
|
+
- Updated dependencies [e07208d]
|
|
12
|
+
- @youversion/platform-core@0.5.0
|
|
13
|
+
|
|
14
|
+
## 0.4.4
|
|
15
|
+
|
|
16
|
+
### Patch Changes
|
|
17
|
+
|
|
18
|
+
- 8dee8f6: chore: allow setting apiHost from React code
|
|
19
|
+
- Updated dependencies [8dee8f6]
|
|
20
|
+
- @youversion/platform-core@0.4.4
|
|
21
|
+
|
|
3
22
|
## 0.4.3
|
|
4
23
|
|
|
5
24
|
### Patch Changes
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"BibleSDKContext.d.ts","sourceRoot":"","sources":["../../src/context/BibleSDKContext.tsx"],"names":[],"mappings":"AAIA,KAAK,mBAAmB,GAAG;IACzB,MAAM,EAAE,MAAM,CAAC;
|
|
1
|
+
{"version":3,"file":"BibleSDKContext.d.ts","sourceRoot":"","sources":["../../src/context/BibleSDKContext.tsx"],"names":[],"mappings":"AAIA,KAAK,mBAAmB,GAAG;IACzB,MAAM,EAAE,MAAM,CAAC;IACf,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,cAAc,CAAC,EAAE,MAAM,CAAC;CACzB,CAAC;AAEF,eAAO,MAAM,eAAe,qDAAkD,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"BibleSDKContext.js","sourceRoot":"","sources":["../../src/context/BibleSDKContext.tsx"],"names":[],"mappings":"AAAA,YAAY,CAAC;AAEb,OAAO,EAAE,aAAa,EAAE,MAAM,OAAO,CAAC;
|
|
1
|
+
{"version":3,"file":"BibleSDKContext.js","sourceRoot":"","sources":["../../src/context/BibleSDKContext.tsx"],"names":[],"mappings":"AAAA,YAAY,CAAC;AAEb,OAAO,EAAE,aAAa,EAAE,MAAM,OAAO,CAAC;AAQtC,MAAM,CAAC,MAAM,eAAe,GAAG,aAAa,CAA6B,IAAI,CAAC,CAAC"}
|
|
@@ -2,7 +2,8 @@ import type { PropsWithChildren, ReactNode } from 'react';
|
|
|
2
2
|
type BibleSDKProviderProps = {
|
|
3
3
|
children: ReactNode;
|
|
4
4
|
appKey: string;
|
|
5
|
+
apiHost?: string;
|
|
5
6
|
};
|
|
6
|
-
export declare function BibleSDKProvider({ appKey, children, }: PropsWithChildren<BibleSDKProviderProps>): React.ReactElement;
|
|
7
|
+
export declare function BibleSDKProvider({ appKey, apiHost, children, }: PropsWithChildren<BibleSDKProviderProps>): React.ReactElement;
|
|
7
8
|
export {};
|
|
8
9
|
//# sourceMappingURL=BibleSDKProvider.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"BibleSDKProvider.d.ts","sourceRoot":"","sources":["../../src/context/BibleSDKProvider.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,iBAAiB,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;
|
|
1
|
+
{"version":3,"file":"BibleSDKProvider.d.ts","sourceRoot":"","sources":["../../src/context/BibleSDKProvider.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,iBAAiB,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;AAK1D,KAAK,qBAAqB,GAAG;IAC3B,QAAQ,EAAE,SAAS,CAAC;IACpB,MAAM,EAAE,MAAM,CAAC;IACf,OAAO,CAAC,EAAE,MAAM,CAAC;CAClB,CAAC;AAEF,wBAAgB,gBAAgB,CAAC,EAC/B,MAAM,EACN,OAA8B,EAC9B,QAAQ,GACT,EAAE,iBAAiB,CAAC,qBAAqB,CAAC,GAAG,KAAK,CAAC,YAAY,CAiB/D"}
|
|
@@ -1,7 +1,18 @@
|
|
|
1
1
|
'use client';
|
|
2
2
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
3
|
+
import { useEffect } from 'react';
|
|
3
4
|
import { BibleSDKContext } from './BibleSDKContext';
|
|
4
|
-
|
|
5
|
-
|
|
5
|
+
import { YouVersionPlatformConfiguration } from '@youversion/platform-core';
|
|
6
|
+
export function BibleSDKProvider({ appKey, apiHost = 'api.youversion.com', children, }) {
|
|
7
|
+
// Syncing appKey and apiHost to YouVersionPlatformConfiguration
|
|
8
|
+
// so that this can be in sync with any other code that uses
|
|
9
|
+
// the YouVersionPlatformConfiguration, of which a lot of our
|
|
10
|
+
// core package uses this configuration.
|
|
11
|
+
useEffect(() => {
|
|
12
|
+
YouVersionPlatformConfiguration.appKey = appKey;
|
|
13
|
+
YouVersionPlatformConfiguration.apiHost = apiHost;
|
|
14
|
+
}, [appKey, apiHost]);
|
|
15
|
+
// Installation ID gets set automatically by YouVersionPlatformConfiguration
|
|
16
|
+
return (_jsx(BibleSDKContext.Provider, { value: { appKey, apiHost, installationId: YouVersionPlatformConfiguration.installationId }, children: children }));
|
|
6
17
|
}
|
|
7
18
|
//# sourceMappingURL=BibleSDKProvider.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"BibleSDKProvider.js","sourceRoot":"","sources":["../../src/context/BibleSDKProvider.tsx"],"names":[],"mappings":"AAAA,YAAY,CAAC;;AAGb,OAAO,EAAE,eAAe,EAAE,MAAM,mBAAmB,CAAC;
|
|
1
|
+
{"version":3,"file":"BibleSDKProvider.js","sourceRoot":"","sources":["../../src/context/BibleSDKProvider.tsx"],"names":[],"mappings":"AAAA,YAAY,CAAC;;AAGb,OAAO,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;AAClC,OAAO,EAAE,eAAe,EAAE,MAAM,mBAAmB,CAAC;AACpD,OAAO,EAAE,+BAA+B,EAAE,MAAM,2BAA2B,CAAC;AAQ5E,MAAM,UAAU,gBAAgB,CAAC,EAC/B,MAAM,EACN,OAAO,GAAG,oBAAoB,EAC9B,QAAQ,GACiC;IACzC,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;IACtB,4EAA4E;IAC5E,OAAO,CACL,KAAC,eAAe,CAAC,QAAQ,IACvB,KAAK,EAAE,EAAE,MAAM,EAAE,OAAO,EAAE,cAAc,EAAE,+BAA+B,CAAC,cAAc,EAAE,YAEzF,QAAQ,GACgB,CAC5B,CAAC;AACJ,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useBibleClient.d.ts","sourceRoot":"","sources":["../src/useBibleClient.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,WAAW,
|
|
1
|
+
{"version":3,"file":"useBibleClient.d.ts","sourceRoot":"","sources":["../src/useBibleClient.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,WAAW,EAAa,MAAM,2BAA2B,CAAC;AAEnE,wBAAgB,cAAc,IAAI,WAAW,CAkB5C"}
|
package/dist/useBibleClient.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
'use client';
|
|
2
2
|
import { useContext, useMemo } from 'react';
|
|
3
3
|
import { BibleSDKContext } from './context';
|
|
4
|
-
import { BibleClient, ApiClient
|
|
4
|
+
import { BibleClient, ApiClient } from '@youversion/platform-core';
|
|
5
5
|
export function useBibleClient() {
|
|
6
6
|
const context = useContext(BibleSDKContext);
|
|
7
7
|
return useMemo(() => {
|
|
@@ -10,8 +10,9 @@ export function useBibleClient() {
|
|
|
10
10
|
}
|
|
11
11
|
return new BibleClient(new ApiClient({
|
|
12
12
|
appKey: context.appKey,
|
|
13
|
-
|
|
13
|
+
apiHost: context.apiHost,
|
|
14
|
+
installationId: context.installationId,
|
|
14
15
|
}));
|
|
15
|
-
}, [context?.appKey]);
|
|
16
|
+
}, [context?.apiHost, context?.appKey, context?.installationId]);
|
|
16
17
|
}
|
|
17
18
|
//# sourceMappingURL=useBibleClient.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useBibleClient.js","sourceRoot":"","sources":["../src/useBibleClient.ts"],"names":[],"mappings":"AAAA,YAAY,CAAC;AAEb,OAAO,EAAE,UAAU,EAAE,OAAO,EAAE,MAAM,OAAO,CAAC;AAC5C,OAAO,EAAE,eAAe,EAAE,MAAM,WAAW,CAAC;AAC5C,OAAO,EAAE,WAAW,EAAE,SAAS,EAAE
|
|
1
|
+
{"version":3,"file":"useBibleClient.js","sourceRoot":"","sources":["../src/useBibleClient.ts"],"names":[],"mappings":"AAAA,YAAY,CAAC;AAEb,OAAO,EAAE,UAAU,EAAE,OAAO,EAAE,MAAM,OAAO,CAAC;AAC5C,OAAO,EAAE,eAAe,EAAE,MAAM,WAAW,CAAC;AAC5C,OAAO,EAAE,WAAW,EAAE,SAAS,EAAE,MAAM,2BAA2B,CAAC;AAEnE,MAAM,UAAU,cAAc;IAC5B,MAAM,OAAO,GAAG,UAAU,CAAC,eAAe,CAAC,CAAC;IAE5C,OAAO,OAAO,CAAC,GAAG,EAAE;QAClB,IAAI,CAAC,OAAO,EAAE,MAAM,EAAE,CAAC;YACrB,MAAM,IAAI,KAAK,CACb,mHAAmH,CACpH,CAAC;QACJ,CAAC;QAED,OAAO,IAAI,WAAW,CACpB,IAAI,SAAS,CAAC;YACZ,MAAM,EAAE,OAAO,CAAC,MAAM;YACtB,OAAO,EAAE,OAAO,CAAC,OAAO;YACxB,cAAc,EAAE,OAAO,CAAC,cAAc;SACvC,CAAC,CACH,CAAC;IACJ,CAAC,EAAE,CAAC,OAAO,EAAE,OAAO,EAAE,OAAO,EAAE,MAAM,EAAE,OAAO,EAAE,cAAc,CAAC,CAAC,CAAC;AACnE,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useHighlights.d.ts","sourceRoot":"","sources":["../src/useHighlights.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"useHighlights.d.ts","sourceRoot":"","sources":["../src/useHighlights.ts"],"names":[],"mappings":"AAMA,OAAO,EAAc,KAAK,iBAAiB,EAAE,MAAM,cAAc,CAAC;AAClE,OAAO,EACL,KAAK,oBAAoB,EACzB,KAAK,sBAAsB,EAC3B,KAAK,eAAe,EACpB,KAAK,UAAU,EACf,KAAK,SAAS,EACf,MAAM,2BAA2B,CAAC;AAEnC,wBAAgB,aAAa,CAC3B,OAAO,CAAC,EAAE,oBAAoB,EAC9B,UAAU,CAAC,EAAE,iBAAiB,GAC7B;IACD,UAAU,EAAE,UAAU,CAAC,SAAS,CAAC,GAAG,IAAI,CAAC;IACzC,OAAO,EAAE,OAAO,CAAC;IACjB,KAAK,EAAE,KAAK,GAAG,IAAI,CAAC;IACpB,OAAO,EAAE,MAAM,IAAI,CAAC;IACpB,eAAe,EAAE,CAAC,IAAI,EAAE,eAAe,KAAK,OAAO,CAAC,SAAS,CAAC,CAAC;IAC/D,eAAe,EAAE,CAAC,SAAS,EAAE,MAAM,EAAE,aAAa,CAAC,EAAE,sBAAsB,KAAK,OAAO,CAAC,IAAI,CAAC,CAAC;CAC/F,CAmDA"}
|
package/dist/useHighlights.js
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
import { useMemo, useCallback } from 'react';
|
|
3
3
|
import { useContext } from 'react';
|
|
4
4
|
import { BibleSDKContext } from './context';
|
|
5
|
-
import { HighlightsClient, ApiClient
|
|
5
|
+
import { HighlightsClient, ApiClient } from '@youversion/platform-core';
|
|
6
6
|
import { useApiData } from './useApiData';
|
|
7
7
|
import {} from '@youversion/platform-core';
|
|
8
8
|
export function useHighlights(options, apiOptions) {
|
|
@@ -13,9 +13,10 @@ export function useHighlights(options, apiOptions) {
|
|
|
13
13
|
}
|
|
14
14
|
return new HighlightsClient(new ApiClient({
|
|
15
15
|
appKey: context.appKey,
|
|
16
|
-
|
|
16
|
+
apiHost: context.apiHost,
|
|
17
|
+
installationId: context.installationId,
|
|
17
18
|
}));
|
|
18
|
-
}, [context?.appKey]);
|
|
19
|
+
}, [context?.apiHost, context?.appKey, context?.installationId]);
|
|
19
20
|
const { data, loading, error, refetch } = useApiData(() => highlightsClient.getHighlights(options), [highlightsClient, options?.version_id, options?.passage_id], {
|
|
20
21
|
enabled: apiOptions?.enabled !== false,
|
|
21
22
|
});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useHighlights.js","sourceRoot":"","sources":["../src/useHighlights.ts"],"names":[],"mappings":"AAAA,YAAY,CAAC;AAEb,OAAO,EAAE,OAAO,EAAE,WAAW,EAAE,MAAM,OAAO,CAAC;AAC7C,OAAO,EAAE,UAAU,EAAE,MAAM,OAAO,CAAC;AACnC,OAAO,EAAE,eAAe,EAAE,MAAM,WAAW,CAAC;AAC5C,OAAO,
|
|
1
|
+
{"version":3,"file":"useHighlights.js","sourceRoot":"","sources":["../src/useHighlights.ts"],"names":[],"mappings":"AAAA,YAAY,CAAC;AAEb,OAAO,EAAE,OAAO,EAAE,WAAW,EAAE,MAAM,OAAO,CAAC;AAC7C,OAAO,EAAE,UAAU,EAAE,MAAM,OAAO,CAAC;AACnC,OAAO,EAAE,eAAe,EAAE,MAAM,WAAW,CAAC;AAC5C,OAAO,EAAE,gBAAgB,EAAE,SAAS,EAAE,MAAM,2BAA2B,CAAC;AACxE,OAAO,EAAE,UAAU,EAA0B,MAAM,cAAc,CAAC;AAClE,OAAO,EAMN,MAAM,2BAA2B,CAAC;AAEnC,MAAM,UAAU,aAAa,CAC3B,OAA8B,EAC9B,UAA8B;IAS9B,MAAM,OAAO,GAAG,UAAU,CAAC,eAAe,CAAC,CAAC;IAE5C,MAAM,gBAAgB,GAAG,OAAO,CAAC,GAAG,EAAE;QACpC,IAAI,CAAC,OAAO,EAAE,MAAM,EAAE,CAAC;YACrB,MAAM,IAAI,KAAK,CACb,mHAAmH,CACpH,CAAC;QACJ,CAAC;QACD,OAAO,IAAI,gBAAgB,CACzB,IAAI,SAAS,CAAC;YACZ,MAAM,EAAE,OAAO,CAAC,MAAM;YACtB,OAAO,EAAE,OAAO,CAAC,OAAO;YACxB,cAAc,EAAE,OAAO,CAAC,cAAc;SACvC,CAAC,CACH,CAAC;IACJ,CAAC,EAAE,CAAC,OAAO,EAAE,OAAO,EAAE,OAAO,EAAE,MAAM,EAAE,OAAO,EAAE,cAAc,CAAC,CAAC,CAAC;IAEjE,MAAM,EAAE,IAAI,EAAE,OAAO,EAAE,KAAK,EAAE,OAAO,EAAE,GAAG,UAAU,CAClD,GAAG,EAAE,CAAC,gBAAgB,CAAC,aAAa,CAAC,OAAO,CAAC,EAC7C,CAAC,gBAAgB,EAAE,OAAO,EAAE,UAAU,EAAE,OAAO,EAAE,UAAU,CAAC,EAC5D;QACE,OAAO,EAAE,UAAU,EAAE,OAAO,KAAK,KAAK;KACvC,CACF,CAAC;IAEF,MAAM,eAAe,GAAG,WAAW,CACjC,KAAK,EAAE,IAAqB,EAAsB,EAAE;QAClD,MAAM,MAAM,GAAG,MAAM,gBAAgB,CAAC,eAAe,CAAC,IAAI,CAAC,CAAC;QAC5D,OAAO,EAAE,CAAC;QACV,OAAO,MAAM,CAAC;IAChB,CAAC,EACD,CAAC,gBAAgB,EAAE,OAAO,CAAC,CAC5B,CAAC;IAEF,MAAM,eAAe,GAAG,WAAW,CACjC,KAAK,EAAE,SAAiB,EAAE,aAAsC,EAAiB,EAAE;QACjF,MAAM,gBAAgB,CAAC,eAAe,CAAC,SAAS,EAAE,aAAa,CAAC,CAAC;QACjE,OAAO,EAAE,CAAC;IACZ,CAAC,EACD,CAAC,gBAAgB,EAAE,OAAO,CAAC,CAC5B,CAAC;IAEF,OAAO;QACL,UAAU,EAAE,IAAI;QAChB,OAAO;QACP,KAAK;QACL,OAAO;QACP,eAAe;QACf,eAAe;KAChB,CAAC;AACJ,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useLanguages.d.ts","sourceRoot":"","sources":["../src/useLanguages.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"useLanguages.d.ts","sourceRoot":"","sources":["../src/useLanguages.ts"],"names":[],"mappings":"AAMA,OAAO,EAAc,KAAK,iBAAiB,EAAE,MAAM,cAAc,CAAC;AAClE,OAAO,EACL,KAAK,mBAAmB,EACxB,KAAK,UAAU,EACf,KAAK,QAAQ,EACd,MAAM,2BAA2B,CAAC;AAEnC,wBAAgB,YAAY,CAC1B,OAAO,EAAE,mBAAmB,EAC5B,UAAU,CAAC,EAAE,iBAAiB,GAC7B;IACD,SAAS,EAAE,UAAU,CAAC,QAAQ,CAAC,GAAG,IAAI,CAAC;IACvC,OAAO,EAAE,OAAO,CAAC;IACjB,KAAK,EAAE,KAAK,GAAG,IAAI,CAAC;IACpB,OAAO,EAAE,MAAM,IAAI,CAAC;CACrB,CAgCA"}
|
package/dist/useLanguages.js
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
import { useMemo } from 'react';
|
|
3
3
|
import { useContext } from 'react';
|
|
4
4
|
import { BibleSDKContext } from './context';
|
|
5
|
-
import { LanguagesClient, ApiClient
|
|
5
|
+
import { LanguagesClient, ApiClient } from '@youversion/platform-core';
|
|
6
6
|
import { useApiData } from './useApiData';
|
|
7
7
|
import {} from '@youversion/platform-core';
|
|
8
8
|
export function useLanguages(options, apiOptions) {
|
|
@@ -13,9 +13,10 @@ export function useLanguages(options, apiOptions) {
|
|
|
13
13
|
}
|
|
14
14
|
return new LanguagesClient(new ApiClient({
|
|
15
15
|
appKey: context.appKey,
|
|
16
|
-
|
|
16
|
+
apiHost: context.apiHost,
|
|
17
|
+
installationId: context.installationId,
|
|
17
18
|
}));
|
|
18
|
-
}, [context?.appKey]);
|
|
19
|
+
}, [context?.apiHost, context?.appKey, context?.installationId]);
|
|
19
20
|
const { data, loading, error, refetch } = useApiData(() => languagesClient.getLanguages(options), [languagesClient, options?.country, options?.page_size, options?.page_token], {
|
|
20
21
|
enabled: apiOptions?.enabled !== false,
|
|
21
22
|
});
|
package/dist/useLanguages.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useLanguages.js","sourceRoot":"","sources":["../src/useLanguages.ts"],"names":[],"mappings":"AAAA,YAAY,CAAC;AAEb,OAAO,EAAE,OAAO,EAAE,MAAM,OAAO,CAAC;AAChC,OAAO,EAAE,UAAU,EAAE,MAAM,OAAO,CAAC;AACnC,OAAO,EAAE,eAAe,EAAE,MAAM,WAAW,CAAC;AAC5C,OAAO,
|
|
1
|
+
{"version":3,"file":"useLanguages.js","sourceRoot":"","sources":["../src/useLanguages.ts"],"names":[],"mappings":"AAAA,YAAY,CAAC;AAEb,OAAO,EAAE,OAAO,EAAE,MAAM,OAAO,CAAC;AAChC,OAAO,EAAE,UAAU,EAAE,MAAM,OAAO,CAAC;AACnC,OAAO,EAAE,eAAe,EAAE,MAAM,WAAW,CAAC;AAC5C,OAAO,EAAE,eAAe,EAAE,SAAS,EAAE,MAAM,2BAA2B,CAAC;AACvE,OAAO,EAAE,UAAU,EAA0B,MAAM,cAAc,CAAC;AAClE,OAAO,EAIN,MAAM,2BAA2B,CAAC;AAEnC,MAAM,UAAU,YAAY,CAC1B,OAA4B,EAC5B,UAA8B;IAO9B,MAAM,OAAO,GAAG,UAAU,CAAC,eAAe,CAAC,CAAC;IAE5C,MAAM,eAAe,GAAG,OAAO,CAAC,GAAG,EAAE;QACnC,IAAI,CAAC,OAAO,EAAE,MAAM,EAAE,CAAC;YACrB,MAAM,IAAI,KAAK,CACb,mHAAmH,CACpH,CAAC;QACJ,CAAC;QACD,OAAO,IAAI,eAAe,CACxB,IAAI,SAAS,CAAC;YACZ,MAAM,EAAE,OAAO,CAAC,MAAM;YACtB,OAAO,EAAE,OAAO,CAAC,OAAO;YACxB,cAAc,EAAE,OAAO,CAAC,cAAc;SACvC,CAAC,CACH,CAAC;IACJ,CAAC,EAAE,CAAC,OAAO,EAAE,OAAO,EAAE,OAAO,EAAE,MAAM,EAAE,OAAO,EAAE,cAAc,CAAC,CAAC,CAAC;IAEjE,MAAM,EAAE,IAAI,EAAE,OAAO,EAAE,KAAK,EAAE,OAAO,EAAE,GAAG,UAAU,CAClD,GAAG,EAAE,CAAC,eAAe,CAAC,YAAY,CAAC,OAAO,CAAC,EAC3C,CAAC,eAAe,EAAE,OAAO,EAAE,OAAO,EAAE,OAAO,EAAE,SAAS,EAAE,OAAO,EAAE,UAAU,CAAC,EAC5E;QACE,OAAO,EAAE,UAAU,EAAE,OAAO,KAAK,KAAK;KACvC,CACF,CAAC;IAEF,OAAO;QACL,SAAS,EAAE,IAAI;QACf,OAAO;QACP,KAAK;QACL,OAAO;KACR,CAAC;AACJ,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@youversion/platform-react-hooks",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.5.0",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"publishConfig": {
|
|
6
6
|
"access": "public"
|
|
@@ -21,7 +21,7 @@
|
|
|
21
21
|
}
|
|
22
22
|
},
|
|
23
23
|
"dependencies": {
|
|
24
|
-
"@youversion/platform-core": "0.
|
|
24
|
+
"@youversion/platform-core": "0.5.0"
|
|
25
25
|
},
|
|
26
26
|
"peerDependencies": {
|
|
27
27
|
"react": ">=19.1.0 <20.0.0"
|
|
@@ -35,8 +35,8 @@
|
|
|
35
35
|
"eslint": "9.38.0",
|
|
36
36
|
"typescript": "5.9.3",
|
|
37
37
|
"vitest": "4.0.4",
|
|
38
|
-
"@internal/
|
|
39
|
-
"@internal/
|
|
38
|
+
"@internal/eslint-config": "0.0.0",
|
|
39
|
+
"@internal/tsconfig": "0.0.0"
|
|
40
40
|
},
|
|
41
41
|
"scripts": {
|
|
42
42
|
"dev": "tsc --watch",
|
|
@@ -1,16 +1,35 @@
|
|
|
1
1
|
'use client';
|
|
2
2
|
|
|
3
3
|
import type { PropsWithChildren, ReactNode } from 'react';
|
|
4
|
+
import { useEffect } from 'react';
|
|
4
5
|
import { BibleSDKContext } from './BibleSDKContext';
|
|
6
|
+
import { YouVersionPlatformConfiguration } from '@youversion/platform-core';
|
|
5
7
|
|
|
6
8
|
type BibleSDKProviderProps = {
|
|
7
9
|
children: ReactNode;
|
|
8
10
|
appKey: string;
|
|
11
|
+
apiHost?: string;
|
|
9
12
|
};
|
|
10
13
|
|
|
11
14
|
export function BibleSDKProvider({
|
|
12
15
|
appKey,
|
|
16
|
+
apiHost = 'api.youversion.com',
|
|
13
17
|
children,
|
|
14
18
|
}: PropsWithChildren<BibleSDKProviderProps>): React.ReactElement {
|
|
15
|
-
|
|
19
|
+
// Syncing appKey and apiHost to YouVersionPlatformConfiguration
|
|
20
|
+
// so that this can be in sync with any other code that uses
|
|
21
|
+
// the YouVersionPlatformConfiguration, of which a lot of our
|
|
22
|
+
// core package uses this configuration.
|
|
23
|
+
useEffect(() => {
|
|
24
|
+
YouVersionPlatformConfiguration.appKey = appKey;
|
|
25
|
+
YouVersionPlatformConfiguration.apiHost = apiHost;
|
|
26
|
+
}, [appKey, apiHost]);
|
|
27
|
+
// Installation ID gets set automatically by YouVersionPlatformConfiguration
|
|
28
|
+
return (
|
|
29
|
+
<BibleSDKContext.Provider
|
|
30
|
+
value={{ appKey, apiHost, installationId: YouVersionPlatformConfiguration.installationId }}
|
|
31
|
+
>
|
|
32
|
+
{children}
|
|
33
|
+
</BibleSDKContext.Provider>
|
|
34
|
+
);
|
|
16
35
|
}
|
|
@@ -19,11 +19,6 @@ vi.mock('@youversion/platform-core', async () => {
|
|
|
19
19
|
isApiClient: true,
|
|
20
20
|
};
|
|
21
21
|
}),
|
|
22
|
-
YouVersionPlatformConfiguration: {
|
|
23
|
-
get installationId() {
|
|
24
|
-
return 'auto-generated-uuid';
|
|
25
|
-
},
|
|
26
|
-
},
|
|
27
22
|
};
|
|
28
23
|
});
|
|
29
24
|
|
|
@@ -49,7 +44,6 @@ describe('useBibleClient', () => {
|
|
|
49
44
|
|
|
50
45
|
expect(ApiClient).toHaveBeenCalledWith({
|
|
51
46
|
appKey: mockAppKey,
|
|
52
|
-
installationId: 'auto-generated-uuid',
|
|
53
47
|
});
|
|
54
48
|
expect(BibleClient).toHaveBeenCalledWith(expect.objectContaining({ isApiClient: true }));
|
|
55
49
|
expect(result.current).toEqual(expect.objectContaining({ isBibleClient: true }));
|
|
@@ -117,7 +111,6 @@ describe('useBibleClient', () => {
|
|
|
117
111
|
expect(BibleClient).toHaveBeenCalledTimes(1);
|
|
118
112
|
expect(ApiClient).toHaveBeenCalledWith({
|
|
119
113
|
appKey: mockAppKey,
|
|
120
|
-
installationId: 'auto-generated-uuid',
|
|
121
114
|
});
|
|
122
115
|
|
|
123
116
|
currentAppKey = 'new-app-key';
|
|
@@ -129,7 +122,6 @@ describe('useBibleClient', () => {
|
|
|
129
122
|
|
|
130
123
|
expect(ApiClient).toHaveBeenLastCalledWith({
|
|
131
124
|
appKey: 'new-app-key',
|
|
132
|
-
installationId: 'auto-generated-uuid',
|
|
133
125
|
});
|
|
134
126
|
});
|
|
135
127
|
|
package/src/useBibleClient.ts
CHANGED
|
@@ -2,21 +2,24 @@
|
|
|
2
2
|
|
|
3
3
|
import { useContext, useMemo } from 'react';
|
|
4
4
|
import { BibleSDKContext } from './context';
|
|
5
|
-
import { BibleClient, ApiClient
|
|
5
|
+
import { BibleClient, ApiClient } from '@youversion/platform-core';
|
|
6
6
|
|
|
7
7
|
export function useBibleClient(): BibleClient {
|
|
8
8
|
const context = useContext(BibleSDKContext);
|
|
9
|
+
|
|
9
10
|
return useMemo(() => {
|
|
10
11
|
if (!context?.appKey) {
|
|
11
12
|
throw new Error(
|
|
12
13
|
'BibleSDK context not found. Make sure your component is wrapped with BibleSDKProvider and an API key is provided.',
|
|
13
14
|
);
|
|
14
15
|
}
|
|
16
|
+
|
|
15
17
|
return new BibleClient(
|
|
16
18
|
new ApiClient({
|
|
17
19
|
appKey: context.appKey,
|
|
18
|
-
|
|
20
|
+
apiHost: context.apiHost,
|
|
21
|
+
installationId: context.installationId,
|
|
19
22
|
}),
|
|
20
23
|
);
|
|
21
|
-
}, [context?.appKey]);
|
|
24
|
+
}, [context?.apiHost, context?.appKey, context?.installationId]);
|
|
22
25
|
}
|
|
@@ -22,11 +22,6 @@ vi.mock('@youversion/platform-core', async () => {
|
|
|
22
22
|
ApiClient: vi.fn(function () {
|
|
23
23
|
return { isApiClient: true };
|
|
24
24
|
}),
|
|
25
|
-
YouVersionPlatformConfiguration: {
|
|
26
|
-
get installationId() {
|
|
27
|
-
return 'auto-generated-uuid';
|
|
28
|
-
},
|
|
29
|
-
},
|
|
30
25
|
};
|
|
31
26
|
});
|
|
32
27
|
|
|
@@ -115,7 +110,6 @@ describe('useHighlights', () => {
|
|
|
115
110
|
|
|
116
111
|
expect(ApiClient).toHaveBeenCalledWith({
|
|
117
112
|
appKey: mockAppKey,
|
|
118
|
-
installationId: 'auto-generated-uuid',
|
|
119
113
|
});
|
|
120
114
|
expect(HighlightsClient).toHaveBeenCalledWith(expect.objectContaining({ isApiClient: true }));
|
|
121
115
|
});
|
package/src/useHighlights.ts
CHANGED
|
@@ -3,11 +3,7 @@
|
|
|
3
3
|
import { useMemo, useCallback } from 'react';
|
|
4
4
|
import { useContext } from 'react';
|
|
5
5
|
import { BibleSDKContext } from './context';
|
|
6
|
-
import {
|
|
7
|
-
HighlightsClient,
|
|
8
|
-
ApiClient,
|
|
9
|
-
YouVersionPlatformConfiguration,
|
|
10
|
-
} from '@youversion/platform-core';
|
|
6
|
+
import { HighlightsClient, ApiClient } from '@youversion/platform-core';
|
|
11
7
|
import { useApiData, type UseApiDataOptions } from './useApiData';
|
|
12
8
|
import {
|
|
13
9
|
type GetHighlightsOptions,
|
|
@@ -39,10 +35,11 @@ export function useHighlights(
|
|
|
39
35
|
return new HighlightsClient(
|
|
40
36
|
new ApiClient({
|
|
41
37
|
appKey: context.appKey,
|
|
42
|
-
|
|
38
|
+
apiHost: context.apiHost,
|
|
39
|
+
installationId: context.installationId,
|
|
43
40
|
}),
|
|
44
41
|
);
|
|
45
|
-
}, [context?.appKey]);
|
|
42
|
+
}, [context?.apiHost, context?.appKey, context?.installationId]);
|
|
46
43
|
|
|
47
44
|
const { data, loading, error, refetch } = useApiData<Collection<Highlight>>(
|
|
48
45
|
() => highlightsClient.getHighlights(options),
|
|
@@ -22,11 +22,6 @@ vi.mock('@youversion/platform-core', async () => {
|
|
|
22
22
|
ApiClient: vi.fn(function () {
|
|
23
23
|
return { isApiClient: true };
|
|
24
24
|
}),
|
|
25
|
-
YouVersionPlatformConfiguration: {
|
|
26
|
-
get installationId() {
|
|
27
|
-
return 'auto-generated-uuid';
|
|
28
|
-
},
|
|
29
|
-
},
|
|
30
25
|
};
|
|
31
26
|
});
|
|
32
27
|
|
|
@@ -129,7 +124,6 @@ describe('useLanguages', () => {
|
|
|
129
124
|
|
|
130
125
|
expect(ApiClient).toHaveBeenCalledWith({
|
|
131
126
|
appKey: mockAppKey,
|
|
132
|
-
installationId: 'auto-generated-uuid',
|
|
133
127
|
});
|
|
134
128
|
expect(LanguagesClient).toHaveBeenCalledWith(expect.objectContaining({ isApiClient: true }));
|
|
135
129
|
});
|
package/src/useLanguages.ts
CHANGED
|
@@ -3,11 +3,7 @@
|
|
|
3
3
|
import { useMemo } from 'react';
|
|
4
4
|
import { useContext } from 'react';
|
|
5
5
|
import { BibleSDKContext } from './context';
|
|
6
|
-
import {
|
|
7
|
-
LanguagesClient,
|
|
8
|
-
ApiClient,
|
|
9
|
-
YouVersionPlatformConfiguration,
|
|
10
|
-
} from '@youversion/platform-core';
|
|
6
|
+
import { LanguagesClient, ApiClient } from '@youversion/platform-core';
|
|
11
7
|
import { useApiData, type UseApiDataOptions } from './useApiData';
|
|
12
8
|
import {
|
|
13
9
|
type GetLanguagesOptions,
|
|
@@ -35,10 +31,11 @@ export function useLanguages(
|
|
|
35
31
|
return new LanguagesClient(
|
|
36
32
|
new ApiClient({
|
|
37
33
|
appKey: context.appKey,
|
|
38
|
-
|
|
34
|
+
apiHost: context.apiHost,
|
|
35
|
+
installationId: context.installationId,
|
|
39
36
|
}),
|
|
40
37
|
);
|
|
41
|
-
}, [context?.appKey]);
|
|
38
|
+
}, [context?.apiHost, context?.appKey, context?.installationId]);
|
|
42
39
|
|
|
43
40
|
const { data, loading, error, refetch } = useApiData<Collection<Language>>(
|
|
44
41
|
() => languagesClient.getLanguages(options),
|
package/src/useVOTD.test.tsx
CHANGED
|
@@ -5,8 +5,6 @@ import { useVerseOfTheDay } from './useVOTD';
|
|
|
5
5
|
import { BibleSDKContext } from './context';
|
|
6
6
|
import { BibleClient, ApiClient, type VOTD } from '@youversion/platform-core';
|
|
7
7
|
|
|
8
|
-
const MOCK_INSTALLATION_ID = 'auto-generated-uuid';
|
|
9
|
-
|
|
10
8
|
// Mock the core package
|
|
11
9
|
vi.mock('@youversion/platform-core', async () => {
|
|
12
10
|
const actual = await vi.importActual('@youversion/platform-core');
|
|
@@ -18,11 +16,6 @@ vi.mock('@youversion/platform-core', async () => {
|
|
|
18
16
|
ApiClient: vi.fn(function () {
|
|
19
17
|
return { isApiClient: true };
|
|
20
18
|
}),
|
|
21
|
-
YouVersionPlatformConfiguration: {
|
|
22
|
-
get installationId() {
|
|
23
|
-
return MOCK_INSTALLATION_ID;
|
|
24
|
-
},
|
|
25
|
-
},
|
|
26
19
|
};
|
|
27
20
|
});
|
|
28
21
|
|
|
@@ -88,7 +81,6 @@ describe('useVerseOfTheDay', () => {
|
|
|
88
81
|
|
|
89
82
|
expect(ApiClient).toHaveBeenCalledWith({
|
|
90
83
|
appKey: mockAppKey,
|
|
91
|
-
installationId: MOCK_INSTALLATION_ID,
|
|
92
84
|
});
|
|
93
85
|
expect(BibleClient).toHaveBeenCalledWith(expect.objectContaining({ isApiClient: true }));
|
|
94
86
|
});
|