@youversion/platform-react-native 0.7.2
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/.releaserc.json +104 -0
- package/CHANGELOG.md +29 -0
- package/CONTRIBUTING.md +319 -0
- package/LICENSE +201 -0
- package/README.md +562 -0
- package/RELEASING.md +85 -0
- package/android/build.gradle +43 -0
- package/android/src/main/AndroidManifest.xml +2 -0
- package/assets/github-reactNative-sdk-banner.png +0 -0
- package/build/api/bible.d.ts +26 -0
- package/build/api/bible.d.ts.map +1 -0
- package/build/api/bible.js +32 -0
- package/build/api/bible.js.map +1 -0
- package/build/api/highlights.d.ts +109 -0
- package/build/api/highlights.d.ts.map +1 -0
- package/build/api/highlights.js +49 -0
- package/build/api/highlights.js.map +1 -0
- package/build/api/index.d.ts +27 -0
- package/build/api/index.d.ts.map +1 -0
- package/build/api/index.js +13 -0
- package/build/api/index.js.map +1 -0
- package/build/api/languages.d.ts +11 -0
- package/build/api/languages.d.ts.map +1 -0
- package/build/api/languages.js +13 -0
- package/build/api/languages.js.map +1 -0
- package/build/api/users.d.ts +20 -0
- package/build/api/users.d.ts.map +1 -0
- package/build/api/users.js +26 -0
- package/build/api/users.js.map +1 -0
- package/build/api/votd.d.ts +15 -0
- package/build/api/votd.d.ts.map +1 -0
- package/build/api/votd.js +13 -0
- package/build/api/votd.js.map +1 -0
- package/build/components/BibleReaderView.d.ts +22 -0
- package/build/components/BibleReaderView.d.ts.map +1 -0
- package/build/components/BibleReaderView.js +18 -0
- package/build/components/BibleReaderView.js.map +1 -0
- package/build/components/BibleTextView.d.ts +18 -0
- package/build/components/BibleTextView.d.ts.map +1 -0
- package/build/components/BibleTextView.js +25 -0
- package/build/components/BibleTextView.js.map +1 -0
- package/build/components/BibleWidgetView.d.ts +23 -0
- package/build/components/BibleWidgetView.d.ts.map +1 -0
- package/build/components/BibleWidgetView.js +17 -0
- package/build/components/BibleWidgetView.js.map +1 -0
- package/build/components/SignInWithYouVersionButton.d.ts +37 -0
- package/build/components/SignInWithYouVersionButton.d.ts.map +1 -0
- package/build/components/SignInWithYouVersionButton.js +12 -0
- package/build/components/SignInWithYouVersionButton.js.map +1 -0
- package/build/components/VotdView.d.ts +11 -0
- package/build/components/VotdView.d.ts.map +1 -0
- package/build/components/VotdView.js +12 -0
- package/build/components/VotdView.js.map +1 -0
- package/build/components/index.d.ts +6 -0
- package/build/components/index.d.ts.map +1 -0
- package/build/components/index.js +6 -0
- package/build/components/index.js.map +1 -0
- package/build/index.d.ts +5 -0
- package/build/index.d.ts.map +1 -0
- package/build/index.js +6 -0
- package/build/index.js.map +1 -0
- package/build/native.d.ts +22 -0
- package/build/native.d.ts.map +1 -0
- package/build/native.js +3 -0
- package/build/native.js.map +1 -0
- package/build/platform.d.ts +21 -0
- package/build/platform.d.ts.map +1 -0
- package/build/platform.js +28 -0
- package/build/platform.js.map +1 -0
- package/build/types.d.ts +320 -0
- package/build/types.d.ts.map +1 -0
- package/build/types.js +2 -0
- package/build/types.js.map +1 -0
- package/commitlint.config.js +23 -0
- package/dist/youversion-platform-react-native-0.7.2.tgz +0 -0
- package/eslint.config.js +4 -0
- package/expo-module.config.json +17 -0
- package/ios/APIs/YVPBibleAPI.swift +197 -0
- package/ios/APIs/YVPHighlightsAPI.swift +105 -0
- package/ios/APIs/YVPLanguagesAPI.swift +70 -0
- package/ios/RNBibleReaderViewModule.swift +9 -0
- package/ios/RNBibleTextViewModule.swift +9 -0
- package/ios/RNBibleWidgetViewModule.swift +9 -0
- package/ios/RNSignInWithYouVersionButtonModule.swift +9 -0
- package/ios/RNVotdViewModule.swift +9 -0
- package/ios/RNYouVersionPlatformModule.swift +79 -0
- package/ios/Views/YVPBibleReaderView.swift +57 -0
- package/ios/Views/YVPBibleTextView.swift +114 -0
- package/ios/Views/YVPBibleWidgetView.swift +64 -0
- package/ios/Views/YVPSignInWithYouVersionButton.swift +52 -0
- package/ios/Views/YVPVotdView.swift +35 -0
- package/ios/YVPAuthAPI.swift +77 -0
- package/ios/YVPVotdAPI.swift +20 -0
- package/ios/YVPlatform.swift +17 -0
- package/ios/YouVersionReactNative.podspec +33 -0
- package/mocks/RNYouVersionPlatform.ts +146 -0
- package/package.json +58 -0
- package/scripts/release-local.sh +224 -0
- package/scripts/sync-android-version.js +75 -0
- package/src/api/bible.ts +35 -0
- package/src/api/highlights.ts +145 -0
- package/src/api/index.ts +13 -0
- package/src/api/languages.ts +14 -0
- package/src/api/users.ts +35 -0
- package/src/api/votd.ts +20 -0
- package/src/components/BibleReaderView.tsx +52 -0
- package/src/components/BibleTextView.tsx +63 -0
- package/src/components/BibleWidgetView.tsx +45 -0
- package/src/components/SignInWithYouVersionButton.tsx +70 -0
- package/src/components/VotdView.tsx +36 -0
- package/src/components/index.ts +5 -0
- package/src/index.ts +5 -0
- package/src/native.ts +58 -0
- package/src/platform.ts +30 -0
- package/src/types.ts +382 -0
- package/tsconfig.json +9 -0
|
@@ -0,0 +1,224 @@
|
|
|
1
|
+
#!/bin/bash
|
|
2
|
+
# Local release helper script for branch-protected repositories
|
|
3
|
+
# This script automates the local release workflow while respecting branch protection rules
|
|
4
|
+
|
|
5
|
+
set -e # Exit on error
|
|
6
|
+
|
|
7
|
+
# Colors for output
|
|
8
|
+
RED='\033[0;31m'
|
|
9
|
+
GREEN='\033[0;32m'
|
|
10
|
+
YELLOW='\033[1;33m'
|
|
11
|
+
BLUE='\033[0;34m'
|
|
12
|
+
NC='\033[0m' # No Color
|
|
13
|
+
|
|
14
|
+
# Configuration
|
|
15
|
+
REPO_URL="https://github.com/youversion/platform-sdk-reactnative"
|
|
16
|
+
|
|
17
|
+
# Helper functions
|
|
18
|
+
print_step() {
|
|
19
|
+
echo -e "\n${BLUE}==>${NC} ${GREEN}$1${NC}\n"
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
print_warning() {
|
|
23
|
+
echo -e "${YELLOW}⚠️ $1${NC}"
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
print_error() {
|
|
27
|
+
echo -e "${RED}❌ Error: $1${NC}"
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
print_success() {
|
|
31
|
+
echo -e "${GREEN}✅ $1${NC}"
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
# Check prerequisites
|
|
35
|
+
check_prerequisites() {
|
|
36
|
+
print_step "Checking prerequisites..."
|
|
37
|
+
|
|
38
|
+
# Check if we're in a git repo
|
|
39
|
+
if ! git rev-parse --git-dir > /dev/null 2>&1; then
|
|
40
|
+
print_error "Not in a git repository"
|
|
41
|
+
exit 1
|
|
42
|
+
fi
|
|
43
|
+
|
|
44
|
+
# Check if GITHUB_TOKEN is set
|
|
45
|
+
if [ -z "$GITHUB_TOKEN" ]; then
|
|
46
|
+
print_warning "GITHUB_TOKEN not set"
|
|
47
|
+
echo "Please set GITHUB_TOKEN environment variable:"
|
|
48
|
+
echo " export GITHUB_TOKEN=your_token"
|
|
49
|
+
exit 1
|
|
50
|
+
fi
|
|
51
|
+
|
|
52
|
+
# Check if NPM_TOKEN is set (optional but recommended)
|
|
53
|
+
if [ -z "$NPM_TOKEN" ]; then
|
|
54
|
+
print_warning "NPM_TOKEN not set (you may be prompted for npm login)"
|
|
55
|
+
fi
|
|
56
|
+
|
|
57
|
+
# Check if gh CLI is available
|
|
58
|
+
if ! command -v gh &> /dev/null; then
|
|
59
|
+
print_warning "GitHub CLI (gh) not found - you'll need to create PR manually"
|
|
60
|
+
HAS_GH_CLI=false
|
|
61
|
+
else
|
|
62
|
+
HAS_GH_CLI=true
|
|
63
|
+
fi
|
|
64
|
+
|
|
65
|
+
print_success "Prerequisites checked"
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
# Ensure we're on main and up to date
|
|
69
|
+
ensure_main_updated() {
|
|
70
|
+
print_step "Ensuring main branch is up to date..."
|
|
71
|
+
|
|
72
|
+
git checkout main
|
|
73
|
+
git pull origin main
|
|
74
|
+
|
|
75
|
+
print_success "Main branch updated"
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
# Preview the release
|
|
79
|
+
preview_release() {
|
|
80
|
+
print_step "Previewing release (dry-run)..."
|
|
81
|
+
|
|
82
|
+
npm run release:dry-run
|
|
83
|
+
|
|
84
|
+
echo ""
|
|
85
|
+
read -p "Continue with this release? (y/N): " -n 1 -r
|
|
86
|
+
echo
|
|
87
|
+
if [[ ! $REPLY =~ ^[Yy]$ ]]; then
|
|
88
|
+
print_warning "Release cancelled"
|
|
89
|
+
exit 0
|
|
90
|
+
fi
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
# Create release branch
|
|
94
|
+
create_release_branch() {
|
|
95
|
+
print_step "Creating release branch..."
|
|
96
|
+
|
|
97
|
+
# Get next version from dry-run output
|
|
98
|
+
BRANCH_NAME="release/prepare-$(date +%Y%m%d-%H%M%S)"
|
|
99
|
+
|
|
100
|
+
git checkout -b "$BRANCH_NAME"
|
|
101
|
+
|
|
102
|
+
print_success "Created branch: $BRANCH_NAME"
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
# Create local release config
|
|
106
|
+
create_local_config() {
|
|
107
|
+
print_step "Creating local release configuration..."
|
|
108
|
+
|
|
109
|
+
cat > .releaserc.local.json << 'EOF'
|
|
110
|
+
{
|
|
111
|
+
"extends": "./.releaserc.json",
|
|
112
|
+
"branches": [
|
|
113
|
+
"main",
|
|
114
|
+
{ "name": "release/*", "channel": false }
|
|
115
|
+
]
|
|
116
|
+
}
|
|
117
|
+
EOF
|
|
118
|
+
|
|
119
|
+
print_success "Local configuration created"
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
# Run semantic-release
|
|
123
|
+
run_release() {
|
|
124
|
+
print_step "Running semantic-release..."
|
|
125
|
+
|
|
126
|
+
npx semantic-release --extends ./.releaserc.local.json --no-ci
|
|
127
|
+
|
|
128
|
+
print_success "Release completed - package published to npm!"
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
# Push branch and tags
|
|
132
|
+
push_release() {
|
|
133
|
+
print_step "Pushing release branch and tags..."
|
|
134
|
+
|
|
135
|
+
git push origin "$BRANCH_NAME"
|
|
136
|
+
git push origin --tags
|
|
137
|
+
|
|
138
|
+
print_success "Branch and tags pushed"
|
|
139
|
+
}
|
|
140
|
+
|
|
141
|
+
# Create PR
|
|
142
|
+
create_pr() {
|
|
143
|
+
print_step "Creating pull request..."
|
|
144
|
+
|
|
145
|
+
# Get version from package.json
|
|
146
|
+
VERSION=$(node -p "require('./package.json').version")
|
|
147
|
+
|
|
148
|
+
if [ "$HAS_GH_CLI" = true ]; then
|
|
149
|
+
gh pr create \
|
|
150
|
+
--base main \
|
|
151
|
+
--head "$BRANCH_NAME" \
|
|
152
|
+
--title "chore(release): $VERSION" \
|
|
153
|
+
--body "Release version $VERSION
|
|
154
|
+
|
|
155
|
+
This PR merges the release commit back to main after publishing to npm.
|
|
156
|
+
|
|
157
|
+
- Version: $VERSION
|
|
158
|
+
- Published to npm: ✅
|
|
159
|
+
- GitHub release created: ✅
|
|
160
|
+
|
|
161
|
+
**Merge Instructions:**
|
|
162
|
+
- Use 'Create a merge commit' (preferred) or 'Squash and merge'
|
|
163
|
+
- Do NOT use 'Rebase and merge'
|
|
164
|
+
|
|
165
|
+
---
|
|
166
|
+
|
|
167
|
+
Released via local release workflow (branch protection compliant)"
|
|
168
|
+
|
|
169
|
+
print_success "Pull request created!"
|
|
170
|
+
print_success "View PR: $(gh pr view --web 2>&1 | grep -o 'https://.*')"
|
|
171
|
+
else
|
|
172
|
+
print_warning "GitHub CLI not available"
|
|
173
|
+
echo "Please create PR manually:"
|
|
174
|
+
echo " $REPO_URL/compare/main...$BRANCH_NAME"
|
|
175
|
+
fi
|
|
176
|
+
}
|
|
177
|
+
|
|
178
|
+
# Cleanup
|
|
179
|
+
cleanup() {
|
|
180
|
+
print_step "Cleaning up..."
|
|
181
|
+
|
|
182
|
+
git checkout main
|
|
183
|
+
|
|
184
|
+
if [ -f .releaserc.local.json ]; then
|
|
185
|
+
rm .releaserc.local.json
|
|
186
|
+
print_success "Removed local config"
|
|
187
|
+
fi
|
|
188
|
+
|
|
189
|
+
echo ""
|
|
190
|
+
print_success "Release process complete!"
|
|
191
|
+
echo ""
|
|
192
|
+
echo "Next steps:"
|
|
193
|
+
echo " 1. Wait for PR approvals (1 reviewer + code owner)"
|
|
194
|
+
echo " 2. Resolve any review threads"
|
|
195
|
+
echo " 3. Merge the PR using 'Create a merge commit' or 'Squash and merge'"
|
|
196
|
+
echo " 4. Delete the release branch: git branch -D $BRANCH_NAME"
|
|
197
|
+
echo ""
|
|
198
|
+
echo "Verify the release:"
|
|
199
|
+
echo " npm view @youversion/react-native-sdk"
|
|
200
|
+
echo " $REPO_URL/releases"
|
|
201
|
+
}
|
|
202
|
+
|
|
203
|
+
# Main execution
|
|
204
|
+
main() {
|
|
205
|
+
echo -e "${GREEN}"
|
|
206
|
+
echo "╔════════════════════════════════════════════════════════╗"
|
|
207
|
+
echo "║ YouVersion React Native SDK - Local Release ║"
|
|
208
|
+
echo "║ (Branch Protection Compliant) ║"
|
|
209
|
+
echo "╚════════════════════════════════════════════════════════╝"
|
|
210
|
+
echo -e "${NC}"
|
|
211
|
+
|
|
212
|
+
check_prerequisites
|
|
213
|
+
ensure_main_updated
|
|
214
|
+
preview_release
|
|
215
|
+
create_release_branch
|
|
216
|
+
create_local_config
|
|
217
|
+
run_release
|
|
218
|
+
push_release
|
|
219
|
+
create_pr
|
|
220
|
+
cleanup
|
|
221
|
+
}
|
|
222
|
+
|
|
223
|
+
# Run main function
|
|
224
|
+
main
|
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Sync Android build.gradle version with package.json
|
|
5
|
+
* This script is called by semantic-release during the release process
|
|
6
|
+
*/
|
|
7
|
+
|
|
8
|
+
const fs = require("fs");
|
|
9
|
+
const path = require("path");
|
|
10
|
+
|
|
11
|
+
// Get version from command line argument (passed by semantic-release)
|
|
12
|
+
const newVersion = process.argv[2];
|
|
13
|
+
|
|
14
|
+
if (!newVersion) {
|
|
15
|
+
console.error("❌ Error: Version argument is required");
|
|
16
|
+
console.error("Usage: node sync-android-version.js <version>");
|
|
17
|
+
process.exit(1);
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
// Validate version format (semantic versioning)
|
|
21
|
+
const versionRegex = /^\d+\.\d+\.\d+(-[a-zA-Z0-9.-]+)?$/;
|
|
22
|
+
if (!versionRegex.test(newVersion)) {
|
|
23
|
+
console.error(`❌ Error: Invalid version format: ${newVersion}`);
|
|
24
|
+
console.error("Expected format: X.Y.Z or X.Y.Z-prerelease");
|
|
25
|
+
process.exit(1);
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
// Path to Android build.gradle
|
|
29
|
+
const buildGradlePath = path.join(__dirname, "..", "android", "build.gradle");
|
|
30
|
+
|
|
31
|
+
try {
|
|
32
|
+
// Read the build.gradle file
|
|
33
|
+
let buildGradleContent = fs.readFileSync(buildGradlePath, "utf8");
|
|
34
|
+
|
|
35
|
+
// Find and replace the group-level version line
|
|
36
|
+
// Looking for: version = "X.Y.Z" or version = 'X.Y.Z' at the start of a line
|
|
37
|
+
const versionLineRegex = /^version\s*=\s*["'][\d.]+(-[a-zA-Z0-9.-]+)?["']/m;
|
|
38
|
+
|
|
39
|
+
if (!versionLineRegex.test(buildGradleContent)) {
|
|
40
|
+
console.error(
|
|
41
|
+
"❌ Error: Could not find version line in android/build.gradle",
|
|
42
|
+
);
|
|
43
|
+
console.error('Expected format: version = "X.Y.Z"');
|
|
44
|
+
process.exit(1);
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
// Replace the group-level version
|
|
48
|
+
let updatedContent = buildGradleContent.replace(
|
|
49
|
+
versionLineRegex,
|
|
50
|
+
`version = '${newVersion}'`,
|
|
51
|
+
);
|
|
52
|
+
|
|
53
|
+
// Also update versionName in defaultConfig if it exists
|
|
54
|
+
// Looking for: versionName "X.Y.Z"
|
|
55
|
+
const versionNameRegex = /versionName\s+["'][\d.]+(-[a-zA-Z0-9.-]+)?["']/;
|
|
56
|
+
|
|
57
|
+
if (versionNameRegex.test(updatedContent)) {
|
|
58
|
+
updatedContent = updatedContent.replace(
|
|
59
|
+
versionNameRegex,
|
|
60
|
+
`versionName "${newVersion}"`,
|
|
61
|
+
);
|
|
62
|
+
console.log(`✅ Updated versionName to ${newVersion}`);
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
// Write back to file
|
|
66
|
+
fs.writeFileSync(buildGradlePath, updatedContent, "utf8");
|
|
67
|
+
|
|
68
|
+
console.log(
|
|
69
|
+
`✅ Successfully updated android/build.gradle version to ${newVersion}`,
|
|
70
|
+
);
|
|
71
|
+
process.exit(0);
|
|
72
|
+
} catch (error) {
|
|
73
|
+
console.error(`❌ Error updating android/build.gradle:`, error.message);
|
|
74
|
+
process.exit(1);
|
|
75
|
+
}
|
package/src/api/bible.ts
ADDED
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import { Module } from "../native";
|
|
2
|
+
import { BibleReference, BibleVersion } from "../types";
|
|
3
|
+
|
|
4
|
+
export const BibleAPI = {
|
|
5
|
+
/**
|
|
6
|
+
* Retrieves a list of Bible versions available for a specified language code (like "en").
|
|
7
|
+
*
|
|
8
|
+
* @param languageTag - An optional language code per BCP 47 for filtering available Bible versions. If `nil`
|
|
9
|
+
* the function returns versions for all languages.
|
|
10
|
+
* @returns An array of {@link BibleVersion} objects.
|
|
11
|
+
*/
|
|
12
|
+
getVersions(languageTag?: string): Promise<Omit<BibleVersion, "books">[]> {
|
|
13
|
+
return Module.versions(languageTag);
|
|
14
|
+
},
|
|
15
|
+
|
|
16
|
+
/**
|
|
17
|
+
* Retrieves a single Bible version by its unique identifier.
|
|
18
|
+
*
|
|
19
|
+
* @param versionId - The id of the Bible version
|
|
20
|
+
* @returns A {@link BibleVersion} object
|
|
21
|
+
*/
|
|
22
|
+
getVersion(versionId: number): Promise<BibleVersion> {
|
|
23
|
+
return Module.version(versionId);
|
|
24
|
+
},
|
|
25
|
+
|
|
26
|
+
/**
|
|
27
|
+
* Retrieves the content of a single Bible chapter from the server as an HTML string.
|
|
28
|
+
*
|
|
29
|
+
* @param bibleReference - A {@link BibleReference} object specifying the reference to retrieve.
|
|
30
|
+
* @returns The chapter content as an HTML string.
|
|
31
|
+
*/
|
|
32
|
+
getChapter(bibleReference: BibleReference): Promise<string> {
|
|
33
|
+
return Module.chapter(bibleReference);
|
|
34
|
+
},
|
|
35
|
+
};
|
|
@@ -0,0 +1,145 @@
|
|
|
1
|
+
import { Module } from "../native";
|
|
2
|
+
import { HighlightResponse } from "../types";
|
|
3
|
+
|
|
4
|
+
export const HighlightsAPI = {
|
|
5
|
+
/**
|
|
6
|
+
* Creates a new Bible highlight for the user in YouVersion.
|
|
7
|
+
*
|
|
8
|
+
* @param params - An object ({@link CreateHighlightParams}) containing the parameters for creating the highlight.
|
|
9
|
+
* @param params.bibleId - The Bible version identifier.
|
|
10
|
+
* @param params.passageId - The passage identifier (e.g., "JHN.5.1").
|
|
11
|
+
* @param params.color - The highlight color in hex format (e.g., "#eeeeff").
|
|
12
|
+
* @returns A boolean indicating success or failure.
|
|
13
|
+
*/
|
|
14
|
+
createHighlight({
|
|
15
|
+
bibleId,
|
|
16
|
+
passageId,
|
|
17
|
+
color,
|
|
18
|
+
}: CreateHighlightParams): Promise<boolean> {
|
|
19
|
+
return Module.createHighlight(bibleId, passageId, color);
|
|
20
|
+
},
|
|
21
|
+
|
|
22
|
+
/**
|
|
23
|
+
* Retrieves the user's highlights for a specific Bible chapter from YouVersion.
|
|
24
|
+
* @param params - An object ({@link GetHighlightsParams}) containing the parameters for retrieving highlights.
|
|
25
|
+
* @param params.bibleId - The Bible version identifier.
|
|
26
|
+
* @param params.passageId - The passage identifier (e.g., "JHN.5.1").
|
|
27
|
+
* @returns `HighlightResponse[]` - An array of {@link HighlightResponse} objects
|
|
28
|
+
*/
|
|
29
|
+
getHighlights({
|
|
30
|
+
bibleId,
|
|
31
|
+
passageId,
|
|
32
|
+
}: GetHighlightsParams): Promise<HighlightResponse[]> {
|
|
33
|
+
return Module.getHighlights(bibleId, passageId);
|
|
34
|
+
},
|
|
35
|
+
|
|
36
|
+
/**
|
|
37
|
+
* Updates an existing Bible highlight for the user in YouVersion.
|
|
38
|
+
*
|
|
39
|
+
* @param params - An object ({@link UpdateHighlightParams}) containing the parameters for updating the highlight.
|
|
40
|
+
* @param params.bibleId - The Bible version identifier.
|
|
41
|
+
* @param params.passageId - The passage identifier (e.g., "JHN.5.1").
|
|
42
|
+
* @param params.color - The new highlight color in hex format (e.g., "#eeeeff").
|
|
43
|
+
* @returns A boolean indicating success or failure.
|
|
44
|
+
*/
|
|
45
|
+
updateHighlight({
|
|
46
|
+
bibleId,
|
|
47
|
+
passageId,
|
|
48
|
+
color,
|
|
49
|
+
}: UpdateHighlightParams): Promise<boolean> {
|
|
50
|
+
return Module.updateHighlight(bibleId, passageId, color);
|
|
51
|
+
},
|
|
52
|
+
|
|
53
|
+
/**
|
|
54
|
+
* Deletes a Bible highlight for the user in YouVersion.
|
|
55
|
+
*
|
|
56
|
+
* @param params - An object ({@link DeleteHighlightParams}) containing the parameters for deleting the highlight.
|
|
57
|
+
* @param params.bibleId - The Bible version identifier.
|
|
58
|
+
* @param params.passageId - The passage identifier (e.g., "JHN.5.1").
|
|
59
|
+
* @returns A boolean indicating success or failure.
|
|
60
|
+
*/
|
|
61
|
+
deleteHighlight({
|
|
62
|
+
bibleId,
|
|
63
|
+
passageId,
|
|
64
|
+
}: DeleteHighlightParams): Promise<boolean> {
|
|
65
|
+
return Module.deleteHighlight(bibleId, passageId);
|
|
66
|
+
},
|
|
67
|
+
};
|
|
68
|
+
|
|
69
|
+
export interface CreateHighlightParams {
|
|
70
|
+
/**
|
|
71
|
+
* The Bible version identifier
|
|
72
|
+
*
|
|
73
|
+
* @example 111
|
|
74
|
+
*/
|
|
75
|
+
bibleId: number;
|
|
76
|
+
|
|
77
|
+
/**
|
|
78
|
+
* The passage identifier (verse USFM format)
|
|
79
|
+
*
|
|
80
|
+
* @example "MAT.1.1"
|
|
81
|
+
*/
|
|
82
|
+
passageId: string;
|
|
83
|
+
|
|
84
|
+
/**
|
|
85
|
+
* The highlight color in hex format
|
|
86
|
+
*
|
|
87
|
+
* @example "#44aa44"
|
|
88
|
+
*/
|
|
89
|
+
color: string;
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
export interface GetHighlightsParams {
|
|
93
|
+
/**
|
|
94
|
+
* The Bible version identifier
|
|
95
|
+
*
|
|
96
|
+
* @example 111
|
|
97
|
+
*/
|
|
98
|
+
bibleId: number;
|
|
99
|
+
|
|
100
|
+
/**
|
|
101
|
+
* The passage identifier (e.g., "JHN.5.1")
|
|
102
|
+
*
|
|
103
|
+
* @example "JHN.5.1"
|
|
104
|
+
*/
|
|
105
|
+
passageId: string;
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
export interface UpdateHighlightParams {
|
|
109
|
+
/**
|
|
110
|
+
* The Bible version identifier
|
|
111
|
+
*
|
|
112
|
+
* @example 111
|
|
113
|
+
*/
|
|
114
|
+
bibleId: number;
|
|
115
|
+
|
|
116
|
+
/**
|
|
117
|
+
* The passage identifier (verse USFM format)
|
|
118
|
+
*
|
|
119
|
+
* @example "MAT.1.1"
|
|
120
|
+
*/
|
|
121
|
+
passageId: string;
|
|
122
|
+
|
|
123
|
+
/**
|
|
124
|
+
* The highlight color in hex format
|
|
125
|
+
*
|
|
126
|
+
* @example "#44aa44"
|
|
127
|
+
*/
|
|
128
|
+
color: string;
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
export interface DeleteHighlightParams {
|
|
132
|
+
/**
|
|
133
|
+
* The Bible version identifier
|
|
134
|
+
*
|
|
135
|
+
* @example 111
|
|
136
|
+
*/
|
|
137
|
+
bibleId: number;
|
|
138
|
+
|
|
139
|
+
/**
|
|
140
|
+
* The passage identifier (e.g., "JHN.5.1")
|
|
141
|
+
*
|
|
142
|
+
* @example "JHN.5.1"
|
|
143
|
+
*/
|
|
144
|
+
passageId: string;
|
|
145
|
+
}
|
package/src/api/index.ts
ADDED
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { BibleAPI } from "./bible";
|
|
2
|
+
import { HighlightsAPI } from "./highlights";
|
|
3
|
+
import { LanguagesAPI } from "./languages";
|
|
4
|
+
import { UsersAPI } from "./users";
|
|
5
|
+
import { VotdAPI } from "./votd";
|
|
6
|
+
|
|
7
|
+
export const YouVersionAPI = {
|
|
8
|
+
Users: UsersAPI,
|
|
9
|
+
VOTD: VotdAPI,
|
|
10
|
+
Bible: BibleAPI,
|
|
11
|
+
Languages: LanguagesAPI,
|
|
12
|
+
Highlights: HighlightsAPI,
|
|
13
|
+
};
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { Module } from "../native";
|
|
2
|
+
import { LanguageOverview } from "../types";
|
|
3
|
+
|
|
4
|
+
export const LanguagesAPI = {
|
|
5
|
+
/**
|
|
6
|
+
* Retrieves a list of languages supported in the Platform.
|
|
7
|
+
*
|
|
8
|
+
* @param country - An optional country code for filtering languages. If provided, only languages used in that country will be returned. For example, "US" for the United States.
|
|
9
|
+
* @returns An array of {@link LanguageOverview} objects.
|
|
10
|
+
*/
|
|
11
|
+
getLanguages(country?: string): Promise<LanguageOverview[]> {
|
|
12
|
+
return Module.languages(country);
|
|
13
|
+
},
|
|
14
|
+
};
|
package/src/api/users.ts
ADDED
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import { Module } from "../native";
|
|
2
|
+
import {
|
|
3
|
+
SignInWithYouVersionPermission,
|
|
4
|
+
SignInWithYouVersionResult,
|
|
5
|
+
YouVersionUserInfo,
|
|
6
|
+
} from "../types";
|
|
7
|
+
|
|
8
|
+
export const UsersAPI = {
|
|
9
|
+
/**
|
|
10
|
+
* Presents the YouVersion login flow to the user and returns the login result upon completion.
|
|
11
|
+
*
|
|
12
|
+
* @param permissions - An array of permissions to request during sign-in.
|
|
13
|
+
* @returns A promise that resolves to the login result as a {@link SignInWithYouVersionResult} object.
|
|
14
|
+
*/
|
|
15
|
+
signIn: (
|
|
16
|
+
permissions: SignInWithYouVersionPermission[] = [],
|
|
17
|
+
): Promise<SignInWithYouVersionResult> => {
|
|
18
|
+
return Module.signIn(permissions);
|
|
19
|
+
},
|
|
20
|
+
|
|
21
|
+
/** Signs out the current user by clearing the access token from local storage */
|
|
22
|
+
signOut(): Promise<void> {
|
|
23
|
+
return Module.signOut();
|
|
24
|
+
},
|
|
25
|
+
|
|
26
|
+
/**
|
|
27
|
+
* Retrieves user information for the authenticated user using the provided access token.
|
|
28
|
+
*
|
|
29
|
+
* @param accessToken - Optionally provide an accessToken, or use the one stored in the SDK after the user signs in
|
|
30
|
+
* @returns A promise that resolves to the user information as a {@link YouVersionUserInfo} object.
|
|
31
|
+
*/
|
|
32
|
+
userInfo(accessToken?: string): Promise<YouVersionUserInfo> {
|
|
33
|
+
return Module.userInfo(accessToken);
|
|
34
|
+
},
|
|
35
|
+
};
|
package/src/api/votd.ts
ADDED
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { Module } from "../native";
|
|
2
|
+
import { YouVersionVerseOfTheDay } from "../types";
|
|
3
|
+
|
|
4
|
+
type VerseOfTheDayOptions = {
|
|
5
|
+
dayOfYear: number;
|
|
6
|
+
};
|
|
7
|
+
|
|
8
|
+
export const VotdAPI = {
|
|
9
|
+
/**
|
|
10
|
+
* Retrieves the Verse of the Day from YouVersion for a specified day of the year.
|
|
11
|
+
* A valid `YouVersionPlatformConfiguration.appKey` must be set before calling this function.
|
|
12
|
+
* @param dayOfYear - The day of the year (1-366) to retrieve the verse for
|
|
13
|
+
* @returns A promise that resolves to a {@link YouVersionVerseOfTheDay} object.
|
|
14
|
+
*/
|
|
15
|
+
verseOfTheDay(
|
|
16
|
+
{ dayOfYear = 1 }: VerseOfTheDayOptions = { dayOfYear: 1 },
|
|
17
|
+
): Promise<YouVersionVerseOfTheDay> {
|
|
18
|
+
return Module.verseOfTheDay(dayOfYear);
|
|
19
|
+
},
|
|
20
|
+
};
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
import { requireNativeView } from "expo";
|
|
2
|
+
import { StyleProp, StyleSheet, ViewStyle } from "react-native";
|
|
3
|
+
|
|
4
|
+
import { BibleReference } from "../types";
|
|
5
|
+
|
|
6
|
+
const NativeView: React.ComponentType<NativeProps> =
|
|
7
|
+
requireNativeView("BibleReaderView");
|
|
8
|
+
|
|
9
|
+
/**
|
|
10
|
+
* A full-featured Bible reader component.
|
|
11
|
+
* It allows the user to control font customizations, switch Bible versions and access their verse highlights.
|
|
12
|
+
* It is designed after the YouVersion Bible reader experience found in the YouVersion app.
|
|
13
|
+
* @param props - {@link BibleReaderViewProps}
|
|
14
|
+
*/
|
|
15
|
+
export function BibleReaderView({ reference, ...props }: BibleReaderViewProps) {
|
|
16
|
+
return (
|
|
17
|
+
<NativeView
|
|
18
|
+
style={styles.view}
|
|
19
|
+
hasReference={!!reference}
|
|
20
|
+
{...(reference || {})}
|
|
21
|
+
{...props}
|
|
22
|
+
/>
|
|
23
|
+
);
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
const styles = StyleSheet.create({
|
|
27
|
+
view: {
|
|
28
|
+
flex: 1,
|
|
29
|
+
},
|
|
30
|
+
});
|
|
31
|
+
|
|
32
|
+
export interface BibleReaderViewProps {
|
|
33
|
+
/** A reference to a passage in the Bible the reader should open to. This could be a single verse, a range of verses or the entire chapter */
|
|
34
|
+
reference?: BibleReference | null | undefined;
|
|
35
|
+
|
|
36
|
+
/**
|
|
37
|
+
* Name of your app.
|
|
38
|
+
* The SDK will use this in various places when prompting the user to sign in to their YouVersion account. This will let the user know which app is requesting their information.
|
|
39
|
+
*/
|
|
40
|
+
appName: string;
|
|
41
|
+
|
|
42
|
+
/**
|
|
43
|
+
* A custom message to display to the user from the sign-in sheet, letting them know why they should sign in.
|
|
44
|
+
*/
|
|
45
|
+
signInMessage: string;
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
type NativeProps = Omit<BibleReaderViewProps, "reference"> &
|
|
49
|
+
Partial<BibleReference> & {
|
|
50
|
+
style: StyleProp<ViewStyle>;
|
|
51
|
+
hasReference: boolean;
|
|
52
|
+
};
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
import { requireNativeView } from "expo";
|
|
2
|
+
import { StyleProp, StyleSheet, View, ViewStyle } from "react-native";
|
|
3
|
+
|
|
4
|
+
import {
|
|
5
|
+
BibleReference,
|
|
6
|
+
BibleTextOptions,
|
|
7
|
+
OnBibleTextPressEvent,
|
|
8
|
+
} from "../types";
|
|
9
|
+
|
|
10
|
+
const NativeView: React.ComponentType<NativeProps> =
|
|
11
|
+
requireNativeView("BibleTextView");
|
|
12
|
+
|
|
13
|
+
/**
|
|
14
|
+
* A minimal text view for displaying a Bible passage.
|
|
15
|
+
* The component supports font customizations and accepts an `onPress` handler
|
|
16
|
+
* that provides information about which verse was pressed.
|
|
17
|
+
*
|
|
18
|
+
* @param props - {@link BibleTextViewProps}
|
|
19
|
+
*/
|
|
20
|
+
export function BibleTextView({
|
|
21
|
+
bibleReference,
|
|
22
|
+
style,
|
|
23
|
+
onPress,
|
|
24
|
+
...props
|
|
25
|
+
}: BibleTextViewProps) {
|
|
26
|
+
return (
|
|
27
|
+
<View style={[styles.wrapper, style]}>
|
|
28
|
+
<NativeView
|
|
29
|
+
{...bibleReference}
|
|
30
|
+
{...props}
|
|
31
|
+
onTap={(e: NativeEvent) => onPress?.(e.nativeEvent)}
|
|
32
|
+
style={styles.component}
|
|
33
|
+
/>
|
|
34
|
+
</View>
|
|
35
|
+
);
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
const styles = StyleSheet.create({
|
|
39
|
+
wrapper: {
|
|
40
|
+
flexDirection: "row",
|
|
41
|
+
alignItems: "stretch",
|
|
42
|
+
},
|
|
43
|
+
component: {
|
|
44
|
+
flexGrow: 1,
|
|
45
|
+
},
|
|
46
|
+
});
|
|
47
|
+
|
|
48
|
+
type NativeProps = Omit<BibleTextViewProps, "bibleReference"> &
|
|
49
|
+
BibleReference & {
|
|
50
|
+
onTap?: (e: NativeEvent) => any | null | undefined;
|
|
51
|
+
};
|
|
52
|
+
|
|
53
|
+
type NativeEvent = { nativeEvent: OnBibleTextPressEvent };
|
|
54
|
+
|
|
55
|
+
export interface BibleTextViewProps extends BibleTextOptions {
|
|
56
|
+
/** A reference to a passage in the Bible. This could be a single verse, a range of verses or the entire chapter */
|
|
57
|
+
bibleReference: BibleReference;
|
|
58
|
+
|
|
59
|
+
style?: StyleProp<ViewStyle>;
|
|
60
|
+
|
|
61
|
+
/** Called when the user presses on the Bible text */
|
|
62
|
+
onPress?: (e: OnBibleTextPressEvent) => void | null | undefined;
|
|
63
|
+
}
|