2019-02-15 04:39:24 +01:00
|
|
|
// TODO: this is a hacky solution to generating checksums for Sapper's inline scripts.
|
|
|
|
// I determined this by running `sapper export` and then checking all unique inline scripts.
|
|
|
|
// Really, this ought to be built into Sapper somehow.
|
|
|
|
|
|
|
|
import crypto from 'crypto'
|
|
|
|
|
2019-02-15 06:26:41 +01:00
|
|
|
const baseScripts = [
|
2019-08-20 04:08:59 +02:00
|
|
|
'__SAPPER__={baseUrl:"",preloaded:[{},{}]};',
|
|
|
|
'__SAPPER__={baseUrl:"",preloaded:[{}]};',
|
|
|
|
'__SAPPER__={baseUrl:"",preloaded:[{},null,null,{}]};',
|
|
|
|
'__SAPPER__={baseUrl:"",preloaded:[{},null,{}]};'
|
2019-02-15 04:39:24 +01:00
|
|
|
]
|
|
|
|
|
2019-02-15 06:26:41 +01:00
|
|
|
const scriptsWithSW = baseScripts.map(script => (
|
|
|
|
`${script}if('serviceWorker' in navigator)navigator.serviceWorker.register('/service-worker.js');`)
|
|
|
|
)
|
|
|
|
|
|
|
|
// sapper adds service worker usually, but it seems inconsistent in dev mode especially
|
|
|
|
const scripts = [].concat(baseScripts).concat(scriptsWithSW)
|
2019-02-15 04:39:24 +01:00
|
|
|
|
|
|
|
export const sapperInlineScriptChecksums = scripts.map(script => {
|
2021-03-07 17:21:20 +01:00
|
|
|
return crypto.createHash('sha256').update(script, 'utf8').digest('base64')
|
2019-02-15 04:39:24 +01:00
|
|
|
})
|