The complete migration from `minecraft-assets` to [`mc-assets`](https://npmjs.com/mc-assets). Now all block states & block models are processed dynamically! So it is now easily possible to implement custom models - no post-install work anymore: the building is now 3x faster and 4x faster in docker - drop 10x total deploy size - display world ~1.5x faster - fix snow & repeater state parser (they didn't render correctly) rsbuild pipeline! - the initial app load is faster ~1.2 - much fewer requests are made & cached - dev reloads are fast now Resource pack changes: - now textures are reloaded much more quickly on the fly - add hotkey to quickly reload textures (for debugging) assigned to F3+T (open dev widget is now assigned to F3+Y) - add a way to disable resource pack instead of uninstalling it - items render from resource pack are now support - resource pack widgets & icons are now supported
27 lines
977 B
TypeScript
27 lines
977 B
TypeScript
import { isCypress } from './standaloneUtils'
|
|
|
|
// might not resolve at all
|
|
export const registerServiceWorker = async () => {
|
|
if (!('serviceWorker' in navigator)) return
|
|
if (!isCypress() && process.env.NODE_ENV !== 'development') {
|
|
return new Promise<void>(resolve => {
|
|
window.addEventListener('load', async () => {
|
|
await navigator.serviceWorker.register('./service-worker.js').then(registration => {
|
|
console.log('SW registered:', registration)
|
|
resolve()
|
|
}).catch(registrationError => {
|
|
console.log('SW registration failed:', registrationError)
|
|
})
|
|
})
|
|
})
|
|
} else {
|
|
// force unregister service worker in development mode
|
|
const registrations = await navigator.serviceWorker.getRegistrations()
|
|
for (const registration of registrations) {
|
|
await registration.unregister() // eslint-disable-line no-await-in-loop
|
|
}
|
|
if (registrations.length) {
|
|
location.reload()
|
|
}
|
|
}
|
|
}
|