Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
57 commits
Select commit Hold shift + click to select a range
c73934b
chore: sync react localization from platform-localization (#478)
platform-localization-pr-bot[bot] Nov 24, 2026
c913c4e
fix(core): sanitize planted footnote content in Bible HTML (#486)
cameronapak Nov 24, 2026
1326e0a
refactor(ui): organize Bible reader modules (#489)
abharms Nov 24, 2026
ab1a56a
feat(ui): re-export passage and versions hooks (#500)
cameronapak Nov 24, 2026
38b654e
fix(ui): preserve focus at high zoom (#485)
abharms Nov 24, 2026
e709a07
feat(core): add Content Library video APIs (YPE-6573) (#488)
abharms Nov 24, 2026
d582d73
feat(core): add Notes API client (#497)
cameronapak Nov 24, 2026
7ce0341
fix(ui): preserve newer selection after native Share (YPE-6812) (#494)
abharms Nov 24, 2026
f9bd014
fix(ui): label reader sign-in menu trigger (YPE-6810) (#492)
abharms Nov 24, 2026
6994c73
fix(ui): handle reader clipboard failures (#490)
abharms Nov 24, 2026
51024a3
fix(ui): support Bible reader interactions in iframes (YPE-6410) (#491)
abharms Nov 24, 2026
7398f57
fix(ui): handle reader host callback exceptions (YPE-6811) (#493)
abharms Nov 24, 2026
1ddd22d
chore(ui): align declaration build with strict checks (YPE-6464) (#503)
abharms Nov 25, 2026
d5f5279
chore: enable additional TypeScript safety checks (#505)
abharms Nov 25, 2026
594e005
feat(ui): customize verse actions and indicators (#506)
abharms Nov 27, 2026
6c375cb
feat(ui): add Reader note saving
abharms Nov 27, 2026
48fc3ff
fix: recover Reader Notes after interrupted authorization
abharms Nov 27, 2026
2e454f1
fix: preserve Reader Notes through authorization
abharms Nov 27, 2026
24e6dd4
fix: preserve Reader sessions and highlight refresh
abharms Nov 27, 2026
20fe224
fix: preserve Reader draft recovery and auth compatibility
abharms Nov 27, 2026
28e5d2a
fix: preserve Reader auth and passage ownership
abharms Nov 27, 2026
1f0a017
fix: preserve Reader drafts and OAuth attempt ownership
abharms Nov 27, 2026
db5916d
fix: isolate Reader authorization handoffs
abharms Nov 27, 2026
b3d6035
fix: recover Reader note edits after a lost response
abharms Nov 27, 2026
5f51dcb
fix: retry Notes writes after definite rejections
abharms Nov 27, 2026
7d6cfbd
fix: retry corrected Notes payloads after a 413
abharms Nov 27, 2026
bf833d6
fix(ui): preload destination highlights (YPE-6783)
abharms Nov 27, 2026
a4a7063
docs: clarify legacy auth recovery (YPE-6783)
abharms Nov 27, 2026
cc1c061
test(ui): await destination passage before save refresh (YPE-6783)
abharms Nov 27, 2026
3bc1d44
test(ui): await settled highlight colors (YPE-6783)
abharms Nov 27, 2026
0b93362
chore: sync react localization
camrun91 Nov 25, 2026
49bb3d9
fix(ui): announce note highlight color names
abharms Nov 28, 2026
c479eed
fix(ci): verify imported localization provenance
abharms Nov 28, 2026
9ce6165
fix(ui): expose action labels and record Notes QA evidence
abharms Nov 30, 2026
6ae9bff
chore: merge main and retire merged localization import
abharms Nov 30, 2026
928e1eb
chore: remove pilot reports and obsolete localization support
abharms Nov 30, 2026
6625bab
chore: merge latest package release from main
abharms Nov 30, 2026
6c15f86
fix: harden Reader Notes authorization and integration
abharms Nov 30, 2026
f80f2ab
fix: refresh OAuth tree-shaking sentinel
abharms Nov 30, 2026
2963e39
refactor: narrow reader notes auth and test scope
abharms Nov 30, 2026
eb2d942
test: remove redundant notes browser scenarios
abharms Nov 30, 2026
047ece5
refactor: reuse oauth cleanup and reader scope checks
abharms Nov 30, 2026
a96e36b
fix(ui): align notes composer with save design
abharms Dec 1, 2026
998cbdd
test(ui): wait for clipboard retry action visibility
abharms Dec 1, 2026
dc45c06
fix(ui): accept normalized note save responses
abharms Dec 1, 2026
ee14e6b
fix(ui): preserve verse action compatibility for notes
abharms Dec 1, 2026
74e1008
chore: sync main into reader notes branch
abharms Dec 1, 2026
0b6a237
fix(ui): recover note drafts after validation rejections
abharms Dec 1, 2026
4e8f448
chore: sync react localization
abharms Dec 1, 2026
15c50dd
chore: consume notes visibility localization
abharms Dec 1, 2026
ee02523
fix(ui): name the note visibility selector accessibly
abharms Dec 1, 2026
96c9779
chore: sync localization delivery from main
abharms Dec 1, 2026
bd4fe44
chore(demo): remove preloaded verse marker
abharms Dec 1, 2026
f96d8e6
fix(ui): toggle note visibility directly
abharms Dec 1, 2026
785265d
docs(demo): update verse marker smoke instructions
abharms Dec 1, 2026
fe2b3fe
fix(ui): align reader notes actions and authorization
abharms Dec 2, 2026
12992c9
test(ui): wait for custom action popover visibility
abharms Dec 2, 2026
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .changeset/clear-verse-action-labels.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@youversion/platform-react-ui': patch
---

Expose translated verse-action and sign-in confirmation labels as explicit accessible labels.
2 changes: 2 additions & 0 deletions .changeset/major-bikes-care.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
---
---
16 changes: 16 additions & 0 deletions .changeset/reader-auth-review-fixes.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
---
'@youversion/platform-core': minor
'@youversion/platform-react-hooks': patch
'@youversion/platform-react-ui': patch
---

Recover from an expired session left by a still-open older SDK tab by clearing
the stale credentials and allowing a fresh sign-in. Preserve pending sign-in
and staged account changes without carrying old Notes permissions forward.
Sign-out also removes the PKCE verifier and redirect handoff.

Export the OAuth callback errors and shared Notes input schemas. The auth provider
uses typed callback errors and delegates storage-event matching to core. Name the
Notes visibility group and use logical composer sizing. Custom auth contexts that omit ownership retain
host control consistently. The full-app Notes smoke runs from the Vite example
and in CI without requiring Node's experimental TypeScript loader.
2 changes: 2 additions & 0 deletions .changeset/reader-custom-actions-animation.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
---
---
33 changes: 33 additions & 0 deletions .changeset/reader-saves-notes.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
---
'@youversion/platform-core': minor
'@youversion/platform-react-hooks': minor
'@youversion/platform-react-ui': minor
---

Add Save to the Bible Reader's verse actions. The Notes composer keeps the exact
selection, including gaps, and saves a passage with optional text, privacy, and
highlight color. Reader sign-in requests Notes scopes. The reader refreshes
chapter highlights after a successful save.

The Notes composer uses the Save design’s bookmark header, compact privacy
control, and filled note field within the SDK’s standard dialog. Composer swatches
announce localized color names and whether selecting them adds or removes the
highlight color.

Save is included in the default verse actions. Custom `verseActionItems` lists
keep their existing actions and order; opt in with `includeSave` to append Save.
The published action-item types are unchanged. Signed-in readers missing Notes
permission start OAuth directly. Notes titles repeat the full reference for each
selected range, matching Swift and Kotlin.

The client sends empty `content` for passage-only saves. Production currently
rejects this with HTTP 400; passage-only saving remains blocked until the API
fix is deployed and verified. Text-filled notes are supported.

- Hooks exports `useCreateNote` and `useUpdateNote`, which take an explicit access
token for the write. The Reader recovers lost create responses with the same
request ID and reconciles subsequent edits against the recovered note.
- Core records Notes grants against the verified account and credentials.
The Reader resumes only its captured authorization and discards drafts after
sign-out or account replacement. Existing unbound sessions keep ordinary
highlight reads, but require Notes authorization before creating notes.
7 changes: 7 additions & 0 deletions .github/workflows/storybook.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,10 @@ on:
pull_request:
paths:
- 'packages/ui/**'
- 'packages/core/**'
- 'packages/hooks/**'
- 'examples/vite-react/**'
- '.github/workflows/storybook.yml'
- 'pnpm-lock.yaml'

jobs:
Expand Down Expand Up @@ -31,6 +35,9 @@ jobs:
- name: Build packages
run: pnpm build

- name: Run mocked Reader Notes app smoke
run: pnpm --filter vite-react test:notes

- name: Run integration tests
run: cd packages/ui && pnpm run test:integration
env:
Expand Down
4 changes: 2 additions & 2 deletions .size-limit.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,8 @@ export default [
{
name: 'hooks / full barrel',
path: 'packages/hooks/dist/index.js',
// Measured brotlied size 29918 B; set to measured + ~10% per CONTRIBUTING.
limit: '32.9 KB',
// Measured brotlied size 33113 B; set to measured + ~10% per CONTRIBUTING.
limit: '36.5 KB',
ignore: ['react', 'react-dom', '@tanstack/react-query'],
},
{
Expand Down
31 changes: 24 additions & 7 deletions CONTEXT.md
Original file line number Diff line number Diff line change
Expand Up @@ -31,9 +31,10 @@ exactly one **color**.

## Passage

A verse or contiguous verse range in one chapter of one Bible version,
identified by a USFM string (`JHN.3.16`, `JHN.3.16-18`). A chapter USFM
(`JHN.3`) is a passage *scope* used for querying, not a highlightable unit.
A verse or selection of verses in one chapter of one Bible version, identified
by a USFM string (`JHN.3.16`, `JHN.3.16-18`). A Note can attach a nonconsecutive
selection (`JHN.3.16+JHN.3.18`). A chapter USFM
(`JHN.3`) is a passage _scope_ used for querying, not a highlightable unit.

## Passage ID

Expand Down Expand Up @@ -134,7 +135,8 @@ A highlight's fill, a 6-character lowercase hex string without `#`
## Verse selection

The ephemeral set of verses the reader has tapped in `BibleReader`. Drives
the verse action popover. Never persisted; cleared on navigation.
the verse action popover; cleared on navigation. A Note draft captures its own
passage snapshot for authorization and retries.

## Self-contained mode

Expand Down Expand Up @@ -178,9 +180,9 @@ round-trips an updated `highlights` prop.

## Verse action popover

The floating action bar for a verse selection, with highlight colors, copy, and
share as the default actions. The host can reorder or omit these actions and add
its own.
The floating action bar for a verse selection, with highlight colors, Save,
copy, and share as the default actions. The host can reorder or omit these
actions and add its own.

## Highlights permission

Expand Down Expand Up @@ -215,3 +217,18 @@ survives the full-page redirect round-trip and expires (~10 min) so an
abandoned round-trip can never silently apply a highlight during a much later
sign-in. It is intent, not highlight data (highlights stay server-only,
ADR-001); discarded on decline, cancel, failure, or successful apply.

## Note

An account-owned entry with text, Private or Public visibility, and an optional
Bible passage and highlight color. A passage-only note has a passage and no text.

## Note draft

A Reader-owned unsaved note containing the captured passage, text, visibility,
color, and one create identity shared by retries of that note.

## Notes authorization

The account-bound OAuth grant for reading (`read_notes`) or creating and updating
(`write_notes`) notes. It is separate from the Highlights permission.
15 changes: 11 additions & 4 deletions docs/adr/0006-tanstack-query-read-layer.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,16 @@ stale cached entries still revalidate on mount. Keep the `combine` callback stab
so TanStack Query memoizes it and the returned Map stays referentially stable.
No TanStack Query type reaches the public surface.

The cache is memory-only. `refetch` performs exact query invalidation. Writes stay
outside this read layer, owned by the highlights machine, and refresh via
`refetch` after the write.
The cache is memory-only. `refetch` performs exact query invalidation. Highlight
writes stay outside this read layer, owned by the highlights machine, and refresh
via `refetch` after the write. Reader Notes saves also use `refetch` to refresh the
displayed chapter's highlights.

Highlight refetch also restarts an active initial read when it has no cached
result. That read may have started before the write and could return outdated
data; the restart fetches the post-write state. Settled cached data stays visible
during revalidation. Other read hooks retain exact invalidation without this
initial-read restart.

## Why

Expand All @@ -45,4 +52,4 @@ outside this read layer, owned by the highlights machine, and refresh via

## Consequences

Revisits render from cache with background revalidation; disabled queries mask (`data: null`) rather than drop their cache entry. Offline is not a distinct state: a request is always attempted and a failure surfaces through `error` (`networkMode: 'always'`). Across a key change, hooks keep returning the previous key's data with `loading: true` until the new data lands (`placeholderData: keepPreviousData`); the Bible reader's chapter-navigation treatment — current chapter dimmed under a spinner — depends on this. Account-scoped hooks (`useHighlights`) opt out via `keepPreviousData: false`, because their key carries the user scope and held-over data would cross accounts. `loading` covers three windows: the first load of a key (`isPending`), the placeholder window after a key change (`isPlaceholderData && isFetching`), and an errored read's retry while it is in flight (`isError && isFetching` — a reconnect or `refetch` recovery); without the third clause, a recovering hook would report `loading: false` with the stale `error` still set, and consumers would render the error state during the retry. A background revalidation of settled, non-errored data leaves `loading` `false`. Accepted behavioral deltas: (1) `refetch` of settled, non-errored data no longer flips `loading` — data updates in place (an errored read's retry does report `loading: true`, per the third clause); (2) a failed background revalidate surfaces `error` while cached `data` stays non-null; (3) returning to the tab no longer revalidates (`refetchOnWindowFocus: false`), so a change made elsewhere lands on the next mount, key change, or `refetch` instead of on focus; (4) default `gcTime` (5 min) bounds how long "instant revisit" holds. `useQueryKeyBase` derives the `additionalHeaders` key segment itself rather than reading `context.additionalHeadersKey`, which only `YouVersionProvider` computes: `YouVersionContext` is public, and a host that renders it directly sends its own headers on the request, so trusting the precomputed field would collapse two header sets onto one cache entry. An account with no `userId` has no cache key, so `useHighlights` does not fetch for it; the Bible reader's write gate matches that condition, because permitting writes an account can never read back loses them silently. Test seams that render `YouVersionContext.Provider` raw must also mount the package-private query-client context (`TestQueryClientProvider`, published under `@youversion/platform-react-hooks/test-utils`). The referential-stability workaround in `use-bible-reader-highlights.ts` (holding the previous parsed `serverColors` reference across byte-identical refetches) became redundant — structural sharing keeps the `highlights` reference stable — and was removed in the same change.
Revisits render from cache with background revalidation; disabled queries mask (`data: null`) rather than drop their cache entry. Offline is not a distinct state: a request is always attempted and a failure surfaces through `error` (`networkMode: 'always'`). Across a key change, hooks keep returning the previous key's data with `loading: true` until the new data lands (`placeholderData: keepPreviousData`); the Bible reader's chapter-navigation treatment — current chapter dimmed under a spinner — depends on this. Account-scoped hooks (`useHighlights`) opt out via `keepPreviousData: false`, because their key carries the user scope and held-over data would cross accounts. `loading` covers three windows: the first load of a key (`isPending`), the placeholder window after a key change (`isPlaceholderData && isFetching`), and an errored read's retry while it is in flight (`isError && isFetching` — a reconnect or `refetch` recovery); without the third clause, a recovering hook would report `loading: false` with the stale `error` still set, and consumers would render the error state during the retry. A background revalidation of settled, non-errored data leaves `loading` `false`. Accepted behavioral deltas: (1) `refetch` of settled, non-errored data no longer flips `loading` — data updates in place (an errored read's retry does report `loading: true`, per the third clause); (2) a failed background revalidate surfaces `error` while cached `data` stays non-null; (3) returning to the tab no longer revalidates (`refetchOnWindowFocus: false`), so a change made elsewhere lands on the next mount, key change, or `refetch` instead of on focus; (4) default `gcTime` (5 min) bounds how long "instant revisit" holds. `useQueryKeyBase` derives the `additionalHeaders` key segment itself rather than reading `context.additionalHeadersKey`, which only `YouVersionProvider` computes: `YouVersionContext` is public, and a host that renders it directly sends its own headers on the request, so trusting the precomputed field would collapse two header sets onto one cache entry. An account with no `userId` has no cache key, so `useHighlights` does not fetch for it; the Bible reader's write gate matches that condition, because permitting writes an account can never read back loses them silently. Test seams that render `YouVersionContext.Provider` raw must also mount the package-private query-client context (`TestQueryClientProvider`, published under `@youversion/platform-react-hooks/test-utils`). TanStack structural sharing preserves the raw `highlights` reference across identical responses. The Reader also compares the displayed verse colors so metadata-only changes do not restart paint; it retains an equivalent projection in React state.
5 changes: 5 additions & 0 deletions docs/highlight-flow-statechart.md
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,11 @@ resolve to `noop` at the machine boundary (YPE-4494).
Both dialog paths stash a pending highlight (10-min `sessionStorage` TTL) so the
intent survives the full-page redirect and resumes on a granted return.

`DISCARD_AUTHORIZATION` clears the pending Highlight intent when another Reader
action commits its own authorization handoff. In the enabled flow it returns to
`idle`; the global handler also clears the stash when the flow is disabled.
The Notes handoff must be persisted successfully before this event is sent.

The stash is a **list**, not a single slot: a fresh tap replaces it, but a queued
optimistic write that loses permission (401/403) _appends_ its intent with
verse-level last-wins. Two writes queued in different colors can each 401, and
Expand Down
36 changes: 32 additions & 4 deletions examples/vite-react/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,18 +24,46 @@ pnpm dev:web
- **Images** — Smoke page for `ImagesClient` list and detail (metadata only)
- **Sign in with YouVersion Button** - Authentication with YouVersion

## Reader Notes smoke test

Select verses and choose **Save** to open the Notes composer. Sign in from the
Reader when prompted, then save the passage with optional note text, visibility,
and color. Choose **Show custom actions** to access **Mark verses** for local
verse markers; choose **Use default actions** to return to Notes.

Run the repeatable browser smoke with a mocked YouVersion API. The script
checks the Navbar and Reader OAuth scopes, declined authorization, exact
selection resumption, cross-account invalidation, and the Notes create payload.
After installing Playwright Chromium, run `pnpm build` followed by
`pnpm --filter vite-react test:notes` from the repository root. This starts a
dedicated mock-configured Vite server and stops it when the smoke finishes.
The same command runs in CI. It verifies the client flow; mocked empty-content
success does not establish live passage-only API support.

To use an already-running demo instead:

```bash
pnpm build
VITE_YVP_APP_KEY=notes-smoke VITE_YVP_API_HOST=notes-smoke.example.test \
VITE_YVP_AUTH_REDIRECT_URL=http://127.0.0.1:5176/callback/ VITE_YVP_LOCALE=en \
pnpm --filter vite-react dev --port 5176 --strictPort
```

With the server running, execute `node examples/vite-react/scripts/smoke-reader-notes.mjs`.

## Verse marker smoke test

1. Open the browser developer tools' **Network** panel, enable **Preserve log**,
clear the log, and filter for `/notes`.
2. Reload the demo with Network recording enabled and open **Bible Reader** at
John 1. Click the purple marker beside verse 3 and check that the status reads
“Opened marker for JHN.1.3.”
John 1. Check that no markers are preloaded, then choose **Show custom actions**.
3. Tap the text of verses 1 and 4, then choose **Mark verses** in the verse
action popover. Check that the popover closes and markers appear on verses
1 and 4 while verse 2 stays unmarked.
4. Tab to a marker and press Enter. Check that the status shows its passage ID
4. Click the purple marker beside verse 1. Check that the status reads
“Opened marker for JHN.1.1.” and the verse action popover stays closed.
5. Tab to a marker and press Enter. Check that the status shows its passage ID
and the verse action popover stays closed.
5. Verify that the Network panel recorded zero requests to Notes API routes.
6. Verify that the Network panel recorded zero requests to Notes API routes.

The demo keeps markers in memory for the current page session.
3 changes: 2 additions & 1 deletion examples/vite-react/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,8 @@
"scripts": {
"dev": "vite",
"build": "tsc -b && vite build",
"preview": "vite preview"
"preview": "vite preview",
"test:notes": "node scripts/run-reader-notes-smoke.mjs"
},
"dependencies": {
"@youversion/platform-react-ui": "workspace:*",
Expand Down
53 changes: 53 additions & 0 deletions examples/vite-react/scripts/run-reader-notes-smoke.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
import assert from 'node:assert/strict';
import { spawn } from 'node:child_process';
import { createRequire } from 'node:module';
import { dirname, resolve } from 'node:path';
import { fileURLToPath } from 'node:url';
import { setTimeout } from 'node:timers/promises';

const example = fileURLToPath(new URL('../', import.meta.url));
const require = createRequire(new URL('../package.json', import.meta.url));
const vite = resolve(dirname(require.resolve('vite/package.json')), 'bin/vite.js');
const port = process.env.NOTES_SMOKE_PORT ?? '5176';
const app = `http://127.0.0.1:${port}`;
const server = spawn(process.execPath, [vite, '--port', port, '--strictPort'], {
cwd: example,
stdio: 'inherit',
env: {
...process.env,
VITE_YVP_APP_KEY: 'notes-smoke',
VITE_YVP_API_HOST: 'notes-smoke.example.test',
VITE_YVP_AUTH_REDIRECT_URL: `${app}/callback/`,
VITE_YVP_LOCALE: 'en',
},
});

try {
let ready = false;
for (let attempt = 0; attempt < 100; attempt += 1) {
assert.equal(server.exitCode, null, 'Vite exited before the smoke test started');
try {
const response = await fetch(app);
if (response.ok) {
ready = true;
break;
}
} catch {
// Vite has not bound its port yet.
}
await setTimeout(100);
}
assert.ok(ready, 'Vite did not become ready');
const smoke = spawn(
process.execPath,
[fileURLToPath(new URL('./smoke-reader-notes.mjs', import.meta.url)), app],
{ stdio: 'inherit' },
);
const code = await new Promise((resolve, reject) => {
smoke.once('error', reject);
smoke.once('exit', (code) => resolve(code ?? 1));
});
process.exitCode = code;
} finally {
server.kill();
}
Loading
Loading