Repository navigation
Release 1.0.0: update prompt, Next.js support and a live demo - #7
Merged
Merged
Conversation
ClearBrowserCacheBoundary takes an `updatePrompt` element or component and shows it when polling finds a newer build and `auto` is off, so the app can ask before reloading instead of only flipping `isLatestVersion`. With `promptOnError`, a stale-chunk error shows the prompt over `fallback` rather than reloading at once; dismissing it hands the error to the parent boundary. The context gains `dismissUpdate`, which hides the prompt until a newer build. The package also exports `UpdatePrompt`, an unstyled native <dialog> that focuses Reload, dismisses on Escape or Later, locks while reloading and restores focus when it goes away.
The example app built with VITE_DEMO=1 becomes an interactive playground: a "Deploy new version" button, live boundary props, the tab's version and Cache Storage state, and an event log that survives reloads. GitHub Pages serves static files only, so a fetch shim answers meta.json with a version kept in localStorage; the version check, cache clearing and reload run through the library unchanged. A Pages workflow publishes it from master, replacing the gh-pages script. Playwright serves the demo under the same sub-path as Pages and covers the dialog, the stale-chunk path and a custom banner prompt. The library is built once before Playwright starts, since two webServer builds racing on dist would be flaky.
…hooting Lead with the problem and a demo screenshot, list features, and add a table of contents, a three-step quick start, a flow diagram, a full API section, recipes and collapsible troubleshooting. Replace the inaccurate standard-style badge with CI, downloads, bundle size, types and license badges.
…ing mount
- Check at once when a tab gets focus back after a whole `duration`,
instead of waiting another interval on a stale build.
- `reloadWhenHidden` reloads into a newer build as soon as the tab goes to
the background, so users never see the switch.
- `canReload` is asked before every reload the user did not start (`auto`,
`reloadWhenHidden`); a throwing guard counts as a no.
- `blocking={false}` renders the app at once and checks in the background.
The demo gains controls for the new options, and the README documents them
with a reload-on-navigation recipe.
… while hidden The guard ran in checkVersion's default parameter, before the fetch and on every poll, so its answer could be stale by the time a reload happened. A check that resolved after the tab went to the background never reloaded, because visibilitychange had already fired. Polling restarts only when `duration` changes, since `auto` is read at check time.
… demo
Rename the update API to one strategy prop: onUpdate ('prompt' | 'reload' |
'flag') with prompt and promptOnChunkError; auto stays as a deprecated alias.
The library no longer ships a dialog component: prompt takes the app's own
component, and the demo's UpdateDialog is an example to copy.
Read the stored version after mount so the boundary renders on the server and
hydrates without a mismatch, mark the bundle 'use client', and recognise
Turbopack chunk errors. With reloadWhenHidden and duration, going to the
background checks once, so a deploy since the last poll is reloaded into.
lazyRetry keeps its 0.x meaning: the second argument counts attempts in all,
two by default, and 0 makes one attempt instead of retrying forever. The 0.x
ClearBrowserCacheAppVersionStorage type is exported again as deprecated.
The demo uses radio groups for duration, onUpdate and the prompt, a compact
layout, and a redesigned dialog.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Prepares 1.0.0. See CHANGELOG.md for the full list and README "Upgrading from 0.x" for the breaking changes.
onUpdate('prompt' | 'reload' | 'flag') decides what a check that finds a newer build does;autostays as a deprecated alias.prompttakes the app's own component (UpdatePromptProps); the library ships no dialog, the demo has one to copy.promptOnChunkErrorasks before reloading for chunk errors.reloadWhenHidden,canReload,blocking={false}, and an immediate check when focus returns after a wholeduration.'use client'bundle, storage read after mount (server render and hydration without mismatch), Turbopack chunk errors recognised. Verified in a Next 15.5 + Turbopack app.lazyRetrykeeps its 0.x attempt count.Breaking: React 18+, entry points through
exports, stored version saved only on reload,lazyRetry(fn, 0)makes one attempt,debugreceiveserror: unknown.Tests: 70 unit, 33 e2e (Chromium, Firefox, WebKit, demo).