import {clientsClaim} from 'workbox-core'
import {precacheAndRoute} from 'workbox-precaching/precacheAndRoute'
import {cleanupOutdatedCaches} from 'workbox-precaching/cleanupOutdatedCaches'

const sha256 = (message) => {
  // encode as UTF-8
  const msgBuffer = new TextEncoder().encode(message)

  // hash the message
  return crypto.subtle.digest('SHA-256', msgBuffer).then((hashBuffer) => {
    // convert ArrayBuffer to Array
    const hashArray = Array.from(new Uint8Array(hashBuffer))
    // convert bytes to hex string
    const hashHex = hashArray.map(b => ('00' + b.toString(16)).slice(-2)).join('')
    return hashHex
  })
}

const cachedAssets = self.__WB_MANIFEST

self.addEventListener('message', event => {
  if (event.data && event.data.type === 'SKIP_WAITING') {
    self.skipWaiting()
  }
})

clientsClaim()
cleanupOutdatedCaches()

sha256(JSON.stringify(cachedAssets)).then((rev) => {
  precacheAndRoute([
    {url: '/index.html', revision: `${rev}-v1`},
    {url: '/manifest.json', revision: `${rev}-v1`}
  ])
})

precacheAndRoute(cachedAssets)

@@ -629,16 +629,288 @@
   %7D)%0A%7D%0A%0A
+const JSONstringifyOrder = (obj) =%3E %7B%0A  let allKeys = %5B%5D%0A  let seen = %7B%7D%0A  JSON.stringify(obj, (key, value) =%3E %7B%0A    if (!(key in seen)) %7B%0A      allKeys.push(key)%0A      seen%5Bkey%5D = null%0A    %7D%0A    return value%0A  %7D)%0A  allKeys.sort()%0A  return JSON.stringify(obj, allKeys)%0A%7D%0A%0A
 const ca
@@ -941,16 +941,16 @@
 ANIFEST%0A
-
 %0Aself.ad
@@ -1122,25 +1122,24 @@
 %0Asha256(JSON
-.
 stringify(ca
@@ -1135,16 +1135,21 @@
 tringify
+Order
 (cachedA

fix stringify stability for hashing