mirror of
https://github.com/CharaChorder/DeviceManager.git
synced 2026-01-03 08:32:52 +00:00
17 lines
515 B
TypeScript
17 lines
515 B
TypeScript
import type {RegisterSWOptions} from "vite-plugin-pwa/types"
|
|
|
|
export async function initPwa(): Promise<string> {
|
|
// @ts-expect-error confused TS
|
|
const {pwaInfo} = await import("virtual:pwa-info")
|
|
// @ts-expect-error confused TS
|
|
const {registerSW} = await import("virtual:pwa-register")
|
|
registerSW({
|
|
immediate: true,
|
|
onRegisterError(error) {
|
|
console.log("ServiceWorker Registration Error", error)
|
|
},
|
|
} satisfies RegisterSWOptions)
|
|
|
|
return pwaInfo ? pwaInfo.webManifest.linkTag : ""
|
|
}
|