mirror of
https://github.com/sonr-io/sonr.git
synced 2026-08-02 17:31:39 +00:00
33 lines
831 B
Templ
33 lines
831 B
Templ
package files
|
|||
|
|
|
||
|
|
templ VaultServiceWorker(path string) {
|
||
|
|
@serviceWorkerJS(path)
|
||
|
|
}
|
||
|
|
|
||
|
|
script serviceWorkerJS(path string) {
|
||
|
|
importScripts('https://cdn.jsdelivr.net/gh/golang/go@go1.18.4/misc/wasm/wasm_exec.js')
|
||
|
|
importScripts('https://cdn.jsdelivr.net/gh/nlepage/go-wasm-http-server@v1.1.0/sw.js')
|
||
|
|
}
|
||
|
|
|
||
|
|
templ IndexHTML() {
|
||
|
|
<html>
|
||
|
|
<head>
|
||
|
|
<title>Sonr ID</title>
|
||
|
|
<script>
|
||
|
|
navigator.serviceWorker.register('sw.js')
|
||
|
|
registerWasmHTTPListener(path)
|
||
|
|
|
||
|
|
// Skip installed stage and jump to activating stage
|
||
|
|
addEventListener('install', (event) => {
|
||
|
|
event.waitUntil(skipWaiting())
|
||
|
|
})
|
||
|
|
|
||
|
|
// Start controlling clients as soon as the SW is activated
|
||
|
|
addEventListener('activate', event => {
|
||
|
|
event.waitUntil(clients.claim())
|
||
|
|
})
|
||
|
|
</script>
|
||
|
|
</head>
|
||
|
|
</html>
|
||
|
|
}
|