@dcl/blog-site 0.1.1 → 0.1.2-22200898455.commit-be7c830
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/assets/{add-DYcLyZdp.js → add-CONdz2L0.js} +1 -1
- package/assets/{all-wallets-C4nGr_7R.js → all-wallets-BqzhB1kH.js} +1 -1
- package/assets/{app-store-B02jYfm-.js → app-store-CG7fZeTB.js} +1 -1
- package/assets/{apple-BCK3uZMt.js → apple-qYUKb-fL.js} +1 -1
- package/assets/{arrow-bottom-DwWnRfSO.js → arrow-bottom-SgoHwiLt.js} +1 -1
- package/assets/{arrow-bottom-circle-BgTVETh1.js → arrow-bottom-circle-wze6Ib1X.js} +1 -1
- package/assets/{arrow-left-DxYUtVyd.js → arrow-left-Bc9t_8h8.js} +1 -1
- package/assets/{arrow-right-DB83ZDpc.js → arrow-right-DQoklnFO.js} +1 -1
- package/assets/{arrow-top-CYdw0BAl.js → arrow-top-CtzlGQJY.js} +1 -1
- package/assets/{bank-BTjGfrQA.js → bank-DNHWU_Jg.js} +1 -1
- package/assets/{basic-C2iOXh6r.js → basic-PxGakulR.js} +1 -1
- package/assets/{browser-C9IPAxxe.js → browser-BNy_mm43.js} +1 -1
- package/assets/{card-BNclZK-a.js → card-g11mKc-V.js} +1 -1
- package/assets/{ccip-Du_VdnfX.js → ccip-CdVPatLX.js} +1 -1
- package/assets/{checkmark-j41jEiwQ.js → checkmark-DhBzwQ6t.js} +1 -1
- package/assets/{checkmark-bold-Cj60b_5b.js → checkmark-bold-svBeKBAh.js} +1 -1
- package/assets/{chevron-bottom-Dei2oM15.js → chevron-bottom-DAKGIwRE.js} +1 -1
- package/assets/{chevron-left-BWzz4H7Q.js → chevron-left-pJoxer2X.js} +1 -1
- package/assets/{chevron-right-DwZ2pATp.js → chevron-right-BZQxa3gA.js} +1 -1
- package/assets/{chevron-top-C4UJBo_X.js → chevron-top-B1p3XmfH.js} +1 -1
- package/assets/{chrome-store-DIu9WL4T.js → chrome-store-eRhpzwit.js} +1 -1
- package/assets/{clock-AppXwo_i.js → clock-BAS4ouqS.js} +1 -1
- package/assets/{close-D8Ywl7Rz.js → close-BAQozjiM.js} +1 -1
- package/assets/{coinPlaceholder-BgOimd3h.js → coinPlaceholder-BXdMDAlW.js} +1 -1
- package/assets/{compass-CXRsrCbw.js → compass-DEaXwX19.js} +1 -1
- package/assets/{copy-B6WsKwA3.js → copy-D5b4R0M8.js} +1 -1
- package/assets/{core-siKY_geQ.js → core-Chr5umbM.js} +4 -4
- package/assets/{cursor-BvI5I206.js → cursor-CToeUN6u.js} +1 -1
- package/assets/{cursor-transparent-l_cbF0Co.js → cursor-transparent-akq7d1Vw.js} +1 -1
- package/assets/{desktop-Mrb9U6QE.js → desktop-DGBZdcEp.js} +1 -1
- package/assets/{disconnect-Tmj3-vY3.js → disconnect-CmKUkObt.js} +1 -1
- package/assets/{discord-mptZVr9G.js → discord-AGPJXkYv.js} +1 -1
- package/assets/{etherscan-2qp_M4dB.js → etherscan-BCzO-bJK.js} +1 -1
- package/assets/{exclamation-triangle-Cx1iR17b.js → exclamation-triangle-Dsv91uqg.js} +1 -1
- package/assets/{extension-CaD-ZP0s.js → extension-DptuMijD.js} +1 -1
- package/assets/{external-link-COz7EdOk.js → external-link-BtrWPfav.js} +1 -1
- package/assets/{facebook-BlPYE0Xr.js → facebook-BM1mR9Hc.js} +1 -1
- package/assets/{farcaster-DJrrnPYp.js → farcaster-BnAwNR4c.js} +1 -1
- package/assets/{filters-CsCtrOAi.js → filters-DnAaDMtu.js} +1 -1
- package/assets/{github--OhF6tqC.js → github-BiifJsd8.js} +1 -1
- package/assets/{google-CPdxmTY-.js → google-CsZwT3WU.js} +1 -1
- package/assets/{help-circle-nIVpORqN.js → help-circle-B8Z8NC0j.js} +1 -1
- package/assets/{id-CfMBMhPT.js → id-DBfaQRNy.js} +1 -1
- package/assets/{image-BcxiQ60W.js → image-BaZrELj9.js} +1 -1
- package/assets/{index-Crz70bkQ.js → index-3zjttLF9.js} +3 -3
- package/assets/{index-DMiQOFb1.js → index-ch5fmFOv.js} +6 -6
- package/assets/{index-BEBfKzhd.js → index-fyJdZPtk.js} +1 -1
- package/assets/{index-TcuOsQmb.js → index-nDqVr4pH.js} +1 -1
- package/assets/{index.es-CfqPJCyU.js → index.es-Cl1t_1D0.js} +4 -4
- package/assets/{info-D20mpohc.js → info-Bbb90kQC.js} +1 -1
- package/assets/{info-circle-BlRPiI_4.js → info-circle-DC62YK7p.js} +1 -1
- package/assets/{lightbulb-Myza8jmt.js → lightbulb-D3KvOoms.js} +1 -1
- package/assets/{localBatchGatewayRequest-CbRQZVuo.js → localBatchGatewayRequest-o8j0FHDn.js} +1 -1
- package/assets/{mail-mb3yq_T-.js → mail-CgVPzJWi.js} +1 -1
- package/assets/{mobile-DyGpDovz.js → mobile-DkODDOLr.js} +1 -1
- package/assets/{more-B7UGlWT0.js → more-Vzh2YixA.js} +1 -1
- package/assets/{network-placeholder-dwQgsyug.js → network-placeholder-CxREg9uT.js} +1 -1
- package/assets/{nftPlaceholder-1gU6FSHu.js → nftPlaceholder-D6oHDmUM.js} +1 -1
- package/assets/{off-CEqFRddB.js → off-D7hAfKPw.js} +1 -1
- package/assets/{play-store-Czqtk8aU.js → play-store-ymeOX5eL.js} +1 -1
- package/assets/{plus-CSuWvMKy.js → plus-BSW9Aosf.js} +1 -1
- package/assets/{qr-code-CIr7qW3r.js → qr-code-Cl8NBuwd.js} +1 -1
- package/assets/{recycle-horizontal-BE9YYNtP.js → recycle-horizontal-DCp7d4ol.js} +1 -1
- package/assets/{refresh-ADIGdSrD.js → refresh-CgZM0T20.js} +1 -1
- package/assets/{reown-logo-Bkc9MyKz.js → reown-logo-C4l2_-Rn.js} +1 -1
- package/assets/{search-DgFM9Hk6.js → search-BFwbgBO3.js} +1 -1
- package/assets/{secp256k1-DdBtVzw3.js → secp256k1-DoSvwiWn.js} +1 -1
- package/assets/{secp256k1-DHM1u1qf.js → secp256k1-ceIhvGka.js} +1 -1
- package/assets/{send-uSCkVXmR.js → send-Bw5bc-ux.js} +1 -1
- package/assets/{swapHorizontal-gESeR7NQ.js → swapHorizontal-DjoIz7Pz.js} +1 -1
- package/assets/{swapHorizontalBold-DKRdD33q.js → swapHorizontalBold-7d-pvfYM.js} +1 -1
- package/assets/{swapHorizontalMedium-DPDDYu6p.js → swapHorizontalMedium-BS3q74Ag.js} +1 -1
- package/assets/{swapHorizontalRoundedBold-Bqm4qWjY.js → swapHorizontalRoundedBold-7x4y8KAj.js} +1 -1
- package/assets/{swapVertical-Cg3Sr5lf.js → swapVertical-C-I-lOO2.js} +1 -1
- package/assets/{telegram-DGKGSsOA.js → telegram-NT_2PwmR.js} +1 -1
- package/assets/{three-dots-DR-sb_-K.js → three-dots-B9XoXaah.js} +1 -1
- package/assets/{twitch-YprgNN7Q.js → twitch-DwklO_-v.js} +1 -1
- package/assets/{twitterIcon-by1ke3d9.js → twitterIcon-D01VF8Iy.js} +1 -1
- package/assets/{verify-DxMVhgIW.js → verify-D15WpctO.js} +1 -1
- package/assets/{verify-filled-CjvpL63x.js → verify-filled-BxWo9YFB.js} +1 -1
- package/assets/{w3m-modal-Cll9lfHE.js → w3m-modal-CGtztDSc.js} +1 -1
- package/assets/{wallet-BUxVBVWc.js → wallet-JyXNRnFs.js} +1 -1
- package/assets/{wallet-placeholder-Ch_S8ctd.js → wallet-placeholder-CSmHe_ZB.js} +1 -1
- package/assets/{walletconnect-CREMUYHB.js → walletconnect-B5GjgoQW.js} +1 -1
- package/assets/{warning-circle-mVdWVzRf.js → warning-circle-BmgJOTmJ.js} +1 -1
- package/assets/{x-mKL2PDEC.js → x-D1Sk_2KN.js} +1 -1
- package/index.html +3 -3
- package/package.json +3 -3
- package/service-worker.js +0 -166
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{p as ve,q as fe,s as ge,t as be,R as l,M as g,u as se,i as v,r as P,a as f,b as a,v as K,e as ce,o as le,j as m,f as Y,k as ye,x as S,E as ie,O as E,C as q,y as oe,l as T,A as H,T as xe,z as Ce,c as ke,h as Se}from"./core-
|
|
1
|
+
import{p as ve,q as fe,s as ge,t as be,R as l,M as g,u as se,i as v,r as P,a as f,b as a,v as K,e as ce,o as le,j as m,f as Y,k as ye,x as S,E as ie,O as E,C as q,y as oe,l as T,A as H,T as xe,z as Ce,c as ke,h as Se}from"./core-Chr5umbM.js";import{c as u,n as w,r as d,o as F,U as We}from"./index-3zjttLF9.js";import"./index-ch5fmFOv.js";import"./index.es-Cl1t_1D0.js";import"./index-nibyPLVP.js";const p=ve({message:"",open:!1,triggerRect:{width:0,height:0,top:0,left:0},variant:"shade"}),Re={state:p,subscribe(r){return ge(p,()=>r(p))},subscribeKey(r,e){return be(p,r,e)},showTooltip({message:r,triggerRect:e,variant:t}){p.open=!0,p.message=r,p.triggerRect=e,p.variant=t},hide(){p.open=!1,p.message="",p.triggerRect={width:0,height:0,top:0,left:0}}},O=fe(Re),de={isUnsupportedChainView(){return l.state.view==="UnsupportedChain"||l.state.view==="SwitchNetwork"&&l.state.history.includes("UnsupportedChain")},async safeClose(){if(this.isUnsupportedChainView()){g.shake();return}if(await se.isSIWXCloseDisabled()){g.shake();return}g.close()}},$e=v`
|
|
2
2
|
:host {
|
|
3
3
|
display: block;
|
|
4
4
|
border-radius: clamp(0px, var(--wui-border-radius-l), 44px);
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{w as o}from"./core-
|
|
1
|
+
import{w as o}from"./core-Chr5umbM.js";import"./index-ch5fmFOv.js";import"./index.es-Cl1t_1D0.js";import"./index-nibyPLVP.js";const r=o`<svg fill="none" viewBox="0 0 20 20">
|
|
2
2
|
<path
|
|
3
3
|
fill="currentColor"
|
|
4
4
|
fill-rule="evenodd"
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{w as a}from"./core-
|
|
1
|
+
import{w as a}from"./core-Chr5umbM.js";import"./index-ch5fmFOv.js";import"./index.es-Cl1t_1D0.js";import"./index-nibyPLVP.js";const r=a`
|
|
2
2
|
<svg fill="none" viewBox="0 0 48 44">
|
|
3
3
|
<path
|
|
4
4
|
style="fill: var(--wui-color-bg-300);"
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{w as l}from"./core-
|
|
1
|
+
import{w as l}from"./core-Chr5umbM.js";import"./index-ch5fmFOv.js";import"./index.es-Cl1t_1D0.js";import"./index-nibyPLVP.js";const i=l`<svg fill="none" viewBox="0 0 96 67">
|
|
2
2
|
<path
|
|
3
3
|
fill="currentColor"
|
|
4
4
|
d="M25.32 18.8a32.56 32.56 0 0 1 45.36 0l1.5 1.47c.63.62.63 1.61 0 2.22l-5.15 5.05c-.31.3-.82.3-1.14 0l-2.07-2.03a22.71 22.71 0 0 0-31.64 0l-2.22 2.18c-.31.3-.82.3-1.14 0l-5.15-5.05a1.55 1.55 0 0 1 0-2.22l1.65-1.62Zm56.02 10.44 4.59 4.5c.63.6.63 1.6 0 2.21l-20.7 20.26c-.62.61-1.63.61-2.26 0L48.28 41.83a.4.4 0 0 0-.56 0L33.03 56.21c-.63.61-1.64.61-2.27 0L10.07 35.95a1.55 1.55 0 0 1 0-2.22l4.59-4.5a1.63 1.63 0 0 1 2.27 0L31.6 43.63a.4.4 0 0 0 .57 0l14.69-14.38a1.63 1.63 0 0 1 2.26 0l14.69 14.38a.4.4 0 0 0 .57 0l14.68-14.38a1.63 1.63 0 0 1 2.27 0Z"
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{w as r}from"./core-
|
|
1
|
+
import{w as r}from"./core-Chr5umbM.js";import"./index-ch5fmFOv.js";import"./index.es-Cl1t_1D0.js";import"./index-nibyPLVP.js";const t=r`<svg fill="none" viewBox="0 0 20 20">
|
|
2
2
|
<path
|
|
3
3
|
fill="currentColor"
|
|
4
4
|
d="M11 6.67a1 1 0 1 0-2 0v2.66a1 1 0 0 0 2 0V6.67ZM10 14.5a1.25 1.25 0 1 0 0-2.5 1.25 1.25 0 0 0 0 2.5Z"
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{w as l}from"./core-
|
|
1
|
+
import{w as l}from"./core-Chr5umbM.js";import"./index-ch5fmFOv.js";import"./index.es-Cl1t_1D0.js";import"./index-nibyPLVP.js";const t=l`<svg fill="none" viewBox="0 0 41 40">
|
|
2
2
|
<g clip-path="url(#a)">
|
|
3
3
|
<path fill="#000" d="M.8 0h40v40H.8z" />
|
|
4
4
|
<path
|
package/index.html
CHANGED
|
@@ -3,11 +3,11 @@
|
|
|
3
3
|
|
|
4
4
|
<head>
|
|
5
5
|
<meta charset="UTF-8" />
|
|
6
|
-
<link rel="icon" type="image/x-icon" href="https://cdn.decentraland.org/@dcl/blog-site/0.1.
|
|
6
|
+
<link rel="icon" type="image/x-icon" href="https://cdn.decentraland.org/@dcl/blog-site/0.1.2-22200898455.commit-be7c830/favicon.ico" />
|
|
7
7
|
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
|
8
8
|
<link href="https://fonts.googleapis.com/css?family=Inconsolata&display=swap" rel="stylesheet" />
|
|
9
9
|
<link rel="sitemap" type="application/xml" title="Sitemap" href="/sitemap.xml" />
|
|
10
|
-
<link rel="manifest" href="https://cdn.decentraland.org/@dcl/blog-site/0.1.
|
|
10
|
+
<link rel="manifest" href="https://cdn.decentraland.org/@dcl/blog-site/0.1.2-22200898455.commit-be7c830/manifest.json" />
|
|
11
11
|
<meta name="theme-color" content="#000000" />
|
|
12
12
|
|
|
13
13
|
<!-- Default SEO tags - will be overridden by react-helmet -->
|
|
@@ -28,7 +28,7 @@
|
|
|
28
28
|
<meta name="twitter:title" content="Decentraland Blog" />
|
|
29
29
|
<meta name="twitter:description" content="Stay up to date with Decentraland announcements, updates, community highlights, and more." />
|
|
30
30
|
<meta name="twitter:image" content="https://cms-images.decentraland.org/ea2ybdmmn1kv/7tYISdowuJYIbSIDqij87H/f3524d454d8e29702792a6b674f5550d/GI_Landscape.Small.png" />
|
|
31
|
-
<script type="module" crossorigin src="https://cdn.decentraland.org/@dcl/blog-site/0.1.
|
|
31
|
+
<script type="module" crossorigin src="https://cdn.decentraland.org/@dcl/blog-site/0.1.2-22200898455.commit-be7c830/assets/index-ch5fmFOv.js"></script>
|
|
32
32
|
</head>
|
|
33
33
|
|
|
34
34
|
<body>
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@dcl/blog-site",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.2-22200898455.commit-be7c830",
|
|
4
4
|
"description": "",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"scripts": {
|
|
@@ -16,6 +16,6 @@
|
|
|
16
16
|
],
|
|
17
17
|
"author": "Decentraland",
|
|
18
18
|
"license": "Apache-2.0",
|
|
19
|
-
"homepage": "https://cdn.decentraland.org/@dcl/blog-site/0.1.
|
|
20
|
-
"commit": "
|
|
19
|
+
"homepage": "https://cdn.decentraland.org/@dcl/blog-site/0.1.2-22200898455.commit-be7c830",
|
|
20
|
+
"commit": "be7c830eeb508b38c67614de95a1885ad1497aa4"
|
|
21
21
|
}
|
package/service-worker.js
DELETED
|
@@ -1,166 +0,0 @@
|
|
|
1
|
-
/* eslint-env serviceworker */
|
|
2
|
-
// Decentraland Blog - Service Worker for API Caching
|
|
3
|
-
// Cache version - increment to invalidate all caches
|
|
4
|
-
const CACHE_VERSION = 'dcl-blog-v1'
|
|
5
|
-
const API_CACHE = `${CACHE_VERSION}-api`
|
|
6
|
-
const ASSET_CACHE = `${CACHE_VERSION}-assets`
|
|
7
|
-
|
|
8
|
-
// Cache duration in milliseconds
|
|
9
|
-
const API_CACHE_DURATION = 5 * 60 * 1000 // 5 minutes
|
|
10
|
-
const ASSET_CACHE_DURATION = 24 * 60 * 60 * 1000 // 24 hours
|
|
11
|
-
|
|
12
|
-
// Patterns to match for caching
|
|
13
|
-
const API_PATTERNS = [/\/api\/cms\//, /cms\.decentraland\.org/, /contentful/]
|
|
14
|
-
|
|
15
|
-
const ASSET_PATTERNS = [/\.(?:png|jpg|jpeg|svg|gif|webp|avif)$/, /\/assets\//, /images\.ctfassets\.net/]
|
|
16
|
-
|
|
17
|
-
// Install event - cleanup old caches
|
|
18
|
-
self.addEventListener('install', () => {
|
|
19
|
-
console.log('[SW] Installing service worker...')
|
|
20
|
-
self.skipWaiting()
|
|
21
|
-
})
|
|
22
|
-
|
|
23
|
-
// Activate event - cleanup old caches
|
|
24
|
-
self.addEventListener('activate', (event) => {
|
|
25
|
-
console.log('[SW] Activating service worker...')
|
|
26
|
-
event.waitUntil(
|
|
27
|
-
caches.keys().then((cacheNames) => {
|
|
28
|
-
return Promise.all(
|
|
29
|
-
cacheNames
|
|
30
|
-
.filter((cacheName) => {
|
|
31
|
-
// Delete old cache versions
|
|
32
|
-
return cacheName.startsWith('dcl-blog-') && !cacheName.startsWith(CACHE_VERSION)
|
|
33
|
-
})
|
|
34
|
-
.map((cacheName) => {
|
|
35
|
-
console.log('[SW] Deleting old cache:', cacheName)
|
|
36
|
-
return caches.delete(cacheName)
|
|
37
|
-
})
|
|
38
|
-
)
|
|
39
|
-
})
|
|
40
|
-
)
|
|
41
|
-
return self.clients.claim()
|
|
42
|
-
})
|
|
43
|
-
|
|
44
|
-
// Helper: Check if URL matches any pattern
|
|
45
|
-
function matchesPattern(url, patterns) {
|
|
46
|
-
return patterns.some((pattern) => pattern.test(url))
|
|
47
|
-
}
|
|
48
|
-
|
|
49
|
-
// Helper: Check if cached response is still fresh
|
|
50
|
-
function isFresh(response, maxAge) {
|
|
51
|
-
if (!response) return false
|
|
52
|
-
|
|
53
|
-
const cachedTime = response.headers.get('sw-cache-time')
|
|
54
|
-
if (!cachedTime) return false
|
|
55
|
-
|
|
56
|
-
const age = Date.now() - parseInt(cachedTime, 10)
|
|
57
|
-
return age < maxAge
|
|
58
|
-
}
|
|
59
|
-
|
|
60
|
-
// Helper: Add timestamp to response headers
|
|
61
|
-
async function addCacheTimestamp(response) {
|
|
62
|
-
const headers = new Headers(response.headers)
|
|
63
|
-
headers.set('sw-cache-time', Date.now().toString())
|
|
64
|
-
|
|
65
|
-
return new Response(response.body, {
|
|
66
|
-
status: response.status,
|
|
67
|
-
statusText: response.statusText,
|
|
68
|
-
headers
|
|
69
|
-
})
|
|
70
|
-
}
|
|
71
|
-
|
|
72
|
-
// Strategy: Stale-While-Revalidate for API calls
|
|
73
|
-
async function staleWhileRevalidate(request, cacheName, maxAge) {
|
|
74
|
-
const cache = await caches.open(cacheName)
|
|
75
|
-
const cachedResponse = await cache.match(request)
|
|
76
|
-
|
|
77
|
-
// Fetch from network
|
|
78
|
-
const fetchPromise = fetch(request)
|
|
79
|
-
.then(async (response) => {
|
|
80
|
-
// Only cache successful responses
|
|
81
|
-
if (response && response.status === 200) {
|
|
82
|
-
const responseToCache = await addCacheTimestamp(response.clone())
|
|
83
|
-
cache.put(request, responseToCache)
|
|
84
|
-
}
|
|
85
|
-
return response
|
|
86
|
-
})
|
|
87
|
-
.catch((error) => {
|
|
88
|
-
console.error('[SW] Fetch failed:', error)
|
|
89
|
-
// Return cached response even if stale on network error
|
|
90
|
-
return cachedResponse
|
|
91
|
-
})
|
|
92
|
-
|
|
93
|
-
// Return cached response if available and fresh, otherwise wait for network
|
|
94
|
-
if (cachedResponse && isFresh(cachedResponse, maxAge)) {
|
|
95
|
-
// Return cache immediately, update in background
|
|
96
|
-
fetchPromise.catch(() => {}) // Prevent unhandled rejection
|
|
97
|
-
return cachedResponse
|
|
98
|
-
}
|
|
99
|
-
|
|
100
|
-
// Wait for network response
|
|
101
|
-
return fetchPromise
|
|
102
|
-
}
|
|
103
|
-
|
|
104
|
-
// Strategy: Cache First for assets
|
|
105
|
-
async function cacheFirst(request, cacheName, maxAge) {
|
|
106
|
-
const cache = await caches.open(cacheName)
|
|
107
|
-
const cachedResponse = await cache.match(request)
|
|
108
|
-
|
|
109
|
-
// Return cached if fresh
|
|
110
|
-
if (cachedResponse && isFresh(cachedResponse, maxAge)) {
|
|
111
|
-
return cachedResponse
|
|
112
|
-
}
|
|
113
|
-
|
|
114
|
-
// Fetch from network and cache
|
|
115
|
-
try {
|
|
116
|
-
const response = await fetch(request)
|
|
117
|
-
if (response && response.status === 200) {
|
|
118
|
-
const responseToCache = await addCacheTimestamp(response.clone())
|
|
119
|
-
cache.put(request, responseToCache)
|
|
120
|
-
}
|
|
121
|
-
return response
|
|
122
|
-
} catch (error) {
|
|
123
|
-
console.error('[SW] Asset fetch failed:', error)
|
|
124
|
-
// Return stale cache if available
|
|
125
|
-
return cachedResponse || new Response('Network error', { status: 503 })
|
|
126
|
-
}
|
|
127
|
-
}
|
|
128
|
-
|
|
129
|
-
// Fetch event - intercept and cache
|
|
130
|
-
self.addEventListener('fetch', (event) => {
|
|
131
|
-
const { request } = event
|
|
132
|
-
const url = request.url
|
|
133
|
-
|
|
134
|
-
// Only handle GET requests
|
|
135
|
-
if (request.method !== 'GET') return
|
|
136
|
-
|
|
137
|
-
// Handle API requests with stale-while-revalidate
|
|
138
|
-
if (matchesPattern(url, API_PATTERNS)) {
|
|
139
|
-
event.respondWith(staleWhileRevalidate(request, API_CACHE, API_CACHE_DURATION))
|
|
140
|
-
return
|
|
141
|
-
}
|
|
142
|
-
|
|
143
|
-
// Handle assets with cache-first
|
|
144
|
-
if (matchesPattern(url, ASSET_PATTERNS)) {
|
|
145
|
-
event.respondWith(cacheFirst(request, ASSET_CACHE, ASSET_CACHE_DURATION))
|
|
146
|
-
return
|
|
147
|
-
}
|
|
148
|
-
|
|
149
|
-
// For everything else, just fetch from network
|
|
150
|
-
})
|
|
151
|
-
|
|
152
|
-
// Message event - allow cache control from app
|
|
153
|
-
self.addEventListener('message', (event) => {
|
|
154
|
-
if (event.data && event.data.type === 'CLEAR_CACHE') {
|
|
155
|
-
event.waitUntil(
|
|
156
|
-
caches.keys().then((cacheNames) => {
|
|
157
|
-
return Promise.all(
|
|
158
|
-
cacheNames.map((cacheName) => {
|
|
159
|
-
console.log('[SW] Clearing cache:', cacheName)
|
|
160
|
-
return caches.delete(cacheName)
|
|
161
|
-
})
|
|
162
|
-
)
|
|
163
|
-
})
|
|
164
|
-
)
|
|
165
|
-
}
|
|
166
|
-
})
|