-
-
Notifications
You must be signed in to change notification settings - Fork 55
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #410 from evoluhq/changeset-release/main
[ci] release
- Loading branch information
Showing
8 changed files
with
77 additions
and
63 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,12 +1,12 @@ | ||
import { | ||
defineConfig, | ||
minimal2023Preset as preset, | ||
} from '@vite-pwa/assets-generator/config' | ||
defineConfig, | ||
minimal2023Preset as preset, | ||
} from "@vite-pwa/assets-generator/config"; | ||
|
||
export default defineConfig({ | ||
headLinkOptions: { | ||
preset: '2023', | ||
}, | ||
preset, | ||
images: ['public/favicon.svg'], | ||
}) | ||
headLinkOptions: { | ||
preset: "2023", | ||
}, | ||
preset, | ||
images: ["public/favicon.svg"], | ||
}); |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,77 +1,90 @@ | ||
import './PWABadge.css' | ||
import "./PWABadge.css"; | ||
|
||
import { useRegisterSW } from 'virtual:pwa-register/react' | ||
import { useRegisterSW } from "virtual:pwa-register/react"; | ||
|
||
function PWABadge() { | ||
// check for updates every hour | ||
const period = 60 * 60 * 1000 | ||
const period = 60 * 60 * 1000; | ||
|
||
const { | ||
offlineReady: [offlineReady, setOfflineReady], | ||
needRefresh: [needRefresh, setNeedRefresh], | ||
updateServiceWorker, | ||
} = useRegisterSW({ | ||
onRegisteredSW(swUrl, r) { | ||
if (period <= 0) return | ||
if (r?.active?.state === 'activated') { | ||
registerPeriodicSync(period, swUrl, r) | ||
} | ||
else if (r?.installing) { | ||
r.installing.addEventListener('statechange', (e) => { | ||
const sw = e.target as ServiceWorker | ||
if (sw.state === 'activated') | ||
registerPeriodicSync(period, swUrl, r) | ||
}) | ||
if (period <= 0) return; | ||
if (r?.active?.state === "activated") { | ||
registerPeriodicSync(period, swUrl, r); | ||
} else if (r?.installing) { | ||
r.installing.addEventListener("statechange", (e) => { | ||
const sw = e.target as ServiceWorker; | ||
if (sw.state === "activated") registerPeriodicSync(period, swUrl, r); | ||
}); | ||
} | ||
}, | ||
}) | ||
}); | ||
|
||
function close() { | ||
setOfflineReady(false) | ||
setNeedRefresh(false) | ||
setOfflineReady(false); | ||
setNeedRefresh(false); | ||
} | ||
|
||
return ( | ||
<div className="PWABadge" role="alert" aria-labelledby="toast-message"> | ||
{ (offlineReady || needRefresh) | ||
&& ( | ||
{(offlineReady || needRefresh) && ( | ||
<div className="PWABadge-toast"> | ||
<div className="PWABadge-message"> | ||
{ offlineReady | ||
? <span id="toast-message">App ready to work offline</span> | ||
: <span id="toast-message">New content available, click on reload button to update.</span>} | ||
{offlineReady ? ( | ||
<span id="toast-message">App ready to work offline</span> | ||
) : ( | ||
<span id="toast-message"> | ||
New content available, click on reload button to update. | ||
</span> | ||
)} | ||
</div> | ||
<div className="PWABadge-buttons"> | ||
{ needRefresh && <button className="PWABadge-toast-button" onClick={() => updateServiceWorker(true)}>Reload</button> } | ||
<button className="PWABadge-toast-button" onClick={() => close()}>Close</button> | ||
{needRefresh && ( | ||
<button | ||
className="PWABadge-toast-button" | ||
onClick={() => updateServiceWorker(true)} | ||
> | ||
Reload | ||
</button> | ||
)} | ||
<button className="PWABadge-toast-button" onClick={() => close()}> | ||
Close | ||
</button> | ||
</div> | ||
</div> | ||
)} | ||
</div> | ||
) | ||
); | ||
} | ||
|
||
export default PWABadge | ||
export default PWABadge; | ||
|
||
/** | ||
* This function will register a periodic sync check every hour, you can modify the interval as needed. | ||
* This function will register a periodic sync check every hour, you can modify | ||
* the interval as needed. | ||
*/ | ||
function registerPeriodicSync(period: number, swUrl: string, r: ServiceWorkerRegistration) { | ||
if (period <= 0) return | ||
function registerPeriodicSync( | ||
period: number, | ||
swUrl: string, | ||
r: ServiceWorkerRegistration, | ||
) { | ||
if (period <= 0) return; | ||
|
||
setInterval(async () => { | ||
if ('onLine' in navigator && !navigator.onLine) | ||
return | ||
if ("onLine" in navigator && !navigator.onLine) return; | ||
|
||
const resp = await fetch(swUrl, { | ||
cache: 'no-store', | ||
cache: "no-store", | ||
headers: { | ||
'cache': 'no-store', | ||
'cache-control': 'no-cache', | ||
cache: "no-store", | ||
"cache-control": "no-cache", | ||
}, | ||
}) | ||
}); | ||
|
||
if (resp?.status === 200) | ||
await r.update() | ||
}, period) | ||
if (resp?.status === 200) await r.update(); | ||
}, period); | ||
} |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,10 @@ | ||
import React from 'react' | ||
import ReactDOM from 'react-dom/client' | ||
import App from './App.tsx' | ||
import './index.css' | ||
import React from "react"; | ||
import ReactDOM from "react-dom/client"; | ||
import App from "./App.tsx"; | ||
import "./index.css"; | ||
|
||
ReactDOM.createRoot(document.getElementById('root')!).render( | ||
ReactDOM.createRoot(document.getElementById("root")!).render( | ||
<React.StrictMode> | ||
<App /> | ||
</React.StrictMode>, | ||
) | ||
); |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,11 @@ | ||
# @evolu/common-web | ||
|
||
## 8.0.5 | ||
|
||
### Patch Changes | ||
|
||
- 48089be: Update SQLite | ||
|
||
## 8.0.4 | ||
|
||
### Patch Changes | ||
|
This file contains 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
This file contains 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