From 79e65f8994174d15f728156ac5d7406534a6402c Mon Sep 17 00:00:00 2001 From: ayoayco Date: Sat, 17 Aug 2024 10:54:26 +0200 Subject: [PATCH] feat: use new astro-sw support for typescript --- astro.config.mjs | 7 +- package.json | 2 +- pnpm-lock.yaml | 312 +++++++++++++++++++++++++++++++---- src/components/Library.astro | 2 +- src/env.d.ts | 3 +- src/{sw.js => sw.ts} | 17 +- src/utils/logger.mjs | 54 ------ src/utils/logger.ts | 31 ++++ 8 files changed, 322 insertions(+), 106 deletions(-) rename src/{sw.js => sw.ts} (92%) delete mode 100644 src/utils/logger.mjs create mode 100644 src/utils/logger.ts diff --git a/astro.config.mjs b/astro.config.mjs index 29814ce..55ac1e9 100644 --- a/astro.config.mjs +++ b/astro.config.mjs @@ -17,9 +17,12 @@ export default defineConfig({ mdx(), sitemap(), serviceWorker({ - path: "./src/sw.js", + path: "./src/sw.ts", assetCachePrefix: 'cozy-reader', - assetCacheVersionID: VERSION + assetCacheVersionID: VERSION, + esbuild: { + minify: true, + } }) ] }); diff --git a/package.json b/package.json index 63a5e2c..8318a1b 100644 --- a/package.json +++ b/package.json @@ -24,7 +24,7 @@ "@astrojs/rss": "^4.0.7", "@astrojs/sitemap": "^3.1.6", "@ayco/astro-resume": "^0.4.2", - "@ayco/astro-sw": "^0.6.2", + "@ayco/astro-sw": "^0.7.1", "@extractus/article-extractor": "^8.0.10", "@fastify/middie": "^8.3.1", "@fastify/static": "^7.0.4", diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 6680993..a20cd4b 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -13,10 +13,10 @@ importers: version: 0.9.2(typescript@5.5.4) '@astrojs/mdx': specifier: ^3.1.3 - version: 3.1.3(astro@4.14.2(@types/node@22.3.0)(rollup@4.20.0)(sass@1.77.8)(typescript@5.5.4)) + version: 3.1.3(astro@4.14.2(@types/node@22.4.0)(rollup@4.20.0)(sass@1.77.8)(typescript@5.5.4)) '@astrojs/node': specifier: ^8.3.3 - version: 8.3.3(astro@4.14.2(@types/node@22.3.0)(rollup@4.20.0)(sass@1.77.8)(typescript@5.5.4)) + version: 8.3.3(astro@4.14.2(@types/node@22.4.0)(rollup@4.20.0)(sass@1.77.8)(typescript@5.5.4)) '@astrojs/rss': specifier: ^4.0.7 version: 4.0.7 @@ -25,10 +25,10 @@ importers: version: 3.1.6 '@ayco/astro-resume': specifier: ^0.4.2 - version: 0.4.2(astro@4.14.2(@types/node@22.3.0)(rollup@4.20.0)(sass@1.77.8)(typescript@5.5.4)) + version: 0.4.2(astro@4.14.2(@types/node@22.4.0)(rollup@4.20.0)(sass@1.77.8)(typescript@5.5.4)) '@ayco/astro-sw': - specifier: ^0.6.2 - version: 0.6.2 + specifier: ^0.7.1 + version: 0.7.1 '@extractus/article-extractor': specifier: ^8.0.10 version: 8.0.10 @@ -40,7 +40,7 @@ importers: version: 7.0.4 astro: specifier: ^4.14.2 - version: 4.14.2(@types/node@22.3.0)(rollup@4.20.0)(sass@1.77.8)(typescript@5.5.4) + version: 4.14.2(@types/node@22.4.0)(rollup@4.20.0)(sass@1.77.8)(typescript@5.5.4) astro-iconify: specifier: ^1.2.0 version: 1.2.0 @@ -129,8 +129,8 @@ packages: peerDependencies: astro: ^4.12.2 - '@ayco/astro-sw@0.6.2': - resolution: {integrity: sha512-h50aYmnpkbSsWjWvW8gvDPtdBc/TfrPZ2aMEDDvc9Reee7MVc9FawM5q6Nv+l7VMCJgd8CdTwYLTa4KGBOO+fQ==} + '@ayco/astro-sw@0.7.1': + resolution: {integrity: sha512-TSF/oGRBgLWyxOrP0nL7hrqAtJSmgnqLFprlMBko5IrfrOSI64rvhwgfBDhMpQK/dBWauroREdq735jazaqQuQ==} engines: {node: '>=18.0.0'} '@babel/code-frame@7.24.7': @@ -254,138 +254,282 @@ packages: cpu: [ppc64] os: [aix] + '@esbuild/aix-ppc64@0.23.1': + resolution: {integrity: sha512-6VhYk1diRqrhBAqpJEdjASR/+WVRtfjpqKuNw11cLiaWpAT/Uu+nokB+UJnevzy/P9C/ty6AOe0dwueMrGh/iQ==} + engines: {node: '>=18'} + cpu: [ppc64] + os: [aix] + '@esbuild/android-arm64@0.21.5': resolution: {integrity: sha512-c0uX9VAUBQ7dTDCjq+wdyGLowMdtR/GoC2U5IYk/7D1H1JYC0qseD7+11iMP2mRLN9RcCMRcjC4YMclCzGwS/A==} engines: {node: '>=12'} cpu: [arm64] os: [android] + '@esbuild/android-arm64@0.23.1': + resolution: {integrity: sha512-xw50ipykXcLstLeWH7WRdQuysJqejuAGPd30vd1i5zSyKK3WE+ijzHmLKxdiCMtH1pHz78rOg0BKSYOSB/2Khw==} + engines: {node: '>=18'} + cpu: [arm64] + os: [android] + '@esbuild/android-arm@0.21.5': resolution: {integrity: sha512-vCPvzSjpPHEi1siZdlvAlsPxXl7WbOVUBBAowWug4rJHb68Ox8KualB+1ocNvT5fjv6wpkX6o/iEpbDrf68zcg==} engines: {node: '>=12'} cpu: [arm] os: [android] + '@esbuild/android-arm@0.23.1': + resolution: {integrity: sha512-uz6/tEy2IFm9RYOyvKl88zdzZfwEfKZmnX9Cj1BHjeSGNuGLuMD1kR8y5bteYmwqKm1tj8m4cb/aKEorr6fHWQ==} + engines: {node: '>=18'} + cpu: [arm] + os: [android] + '@esbuild/android-x64@0.21.5': resolution: {integrity: sha512-D7aPRUUNHRBwHxzxRvp856rjUHRFW1SdQATKXH2hqA0kAZb1hKmi02OpYRacl0TxIGz/ZmXWlbZgjwWYaCakTA==} engines: {node: '>=12'} cpu: [x64] os: [android] + '@esbuild/android-x64@0.23.1': + resolution: {integrity: sha512-nlN9B69St9BwUoB+jkyU090bru8L0NA3yFvAd7k8dNsVH8bi9a8cUAUSEcEEgTp2z3dbEDGJGfP6VUnkQnlReg==} + engines: {node: '>=18'} + cpu: [x64] + os: [android] + '@esbuild/darwin-arm64@0.21.5': resolution: {integrity: sha512-DwqXqZyuk5AiWWf3UfLiRDJ5EDd49zg6O9wclZ7kUMv2WRFr4HKjXp/5t8JZ11QbQfUS6/cRCKGwYhtNAY88kQ==} engines: {node: '>=12'} cpu: [arm64] os: [darwin] + '@esbuild/darwin-arm64@0.23.1': + resolution: {integrity: sha512-YsS2e3Wtgnw7Wq53XXBLcV6JhRsEq8hkfg91ESVadIrzr9wO6jJDMZnCQbHm1Guc5t/CdDiFSSfWP58FNuvT3Q==} + engines: {node: '>=18'} + cpu: [arm64] + os: [darwin] + '@esbuild/darwin-x64@0.21.5': resolution: {integrity: sha512-se/JjF8NlmKVG4kNIuyWMV/22ZaerB+qaSi5MdrXtd6R08kvs2qCN4C09miupktDitvh8jRFflwGFBQcxZRjbw==} engines: {node: '>=12'} cpu: [x64] os: [darwin] + '@esbuild/darwin-x64@0.23.1': + resolution: {integrity: sha512-aClqdgTDVPSEGgoCS8QDG37Gu8yc9lTHNAQlsztQ6ENetKEO//b8y31MMu2ZaPbn4kVsIABzVLXYLhCGekGDqw==} + engines: {node: '>=18'} + cpu: [x64] + os: [darwin] + '@esbuild/freebsd-arm64@0.21.5': resolution: {integrity: sha512-5JcRxxRDUJLX8JXp/wcBCy3pENnCgBR9bN6JsY4OmhfUtIHe3ZW0mawA7+RDAcMLrMIZaf03NlQiX9DGyB8h4g==} engines: {node: '>=12'} cpu: [arm64] os: [freebsd] + '@esbuild/freebsd-arm64@0.23.1': + resolution: {integrity: sha512-h1k6yS8/pN/NHlMl5+v4XPfikhJulk4G+tKGFIOwURBSFzE8bixw1ebjluLOjfwtLqY0kewfjLSrO6tN2MgIhA==} + engines: {node: '>=18'} + cpu: [arm64] + os: [freebsd] + '@esbuild/freebsd-x64@0.21.5': resolution: {integrity: sha512-J95kNBj1zkbMXtHVH29bBriQygMXqoVQOQYA+ISs0/2l3T9/kj42ow2mpqerRBxDJnmkUDCaQT/dfNXWX/ZZCQ==} engines: {node: '>=12'} cpu: [x64] os: [freebsd] + '@esbuild/freebsd-x64@0.23.1': + resolution: {integrity: sha512-lK1eJeyk1ZX8UklqFd/3A60UuZ/6UVfGT2LuGo3Wp4/z7eRTRYY+0xOu2kpClP+vMTi9wKOfXi2vjUpO1Ro76g==} + engines: {node: '>=18'} + cpu: [x64] + os: [freebsd] + '@esbuild/linux-arm64@0.21.5': resolution: {integrity: sha512-ibKvmyYzKsBeX8d8I7MH/TMfWDXBF3db4qM6sy+7re0YXya+K1cem3on9XgdT2EQGMu4hQyZhan7TeQ8XkGp4Q==} engines: {node: '>=12'} cpu: [arm64] os: [linux] + '@esbuild/linux-arm64@0.23.1': + resolution: {integrity: sha512-/93bf2yxencYDnItMYV/v116zff6UyTjo4EtEQjUBeGiVpMmffDNUyD9UN2zV+V3LRV3/on4xdZ26NKzn6754g==} + engines: {node: '>=18'} + cpu: [arm64] + os: [linux] + '@esbuild/linux-arm@0.21.5': resolution: {integrity: sha512-bPb5AHZtbeNGjCKVZ9UGqGwo8EUu4cLq68E95A53KlxAPRmUyYv2D6F0uUI65XisGOL1hBP5mTronbgo+0bFcA==} engines: {node: '>=12'} cpu: [arm] os: [linux] + '@esbuild/linux-arm@0.23.1': + resolution: {integrity: sha512-CXXkzgn+dXAPs3WBwE+Kvnrf4WECwBdfjfeYHpMeVxWE0EceB6vhWGShs6wi0IYEqMSIzdOF1XjQ/Mkm5d7ZdQ==} + engines: {node: '>=18'} + cpu: [arm] + os: [linux] + '@esbuild/linux-ia32@0.21.5': resolution: {integrity: sha512-YvjXDqLRqPDl2dvRODYmmhz4rPeVKYvppfGYKSNGdyZkA01046pLWyRKKI3ax8fbJoK5QbxblURkwK/MWY18Tg==} engines: {node: '>=12'} cpu: [ia32] os: [linux] + '@esbuild/linux-ia32@0.23.1': + resolution: {integrity: sha512-VTN4EuOHwXEkXzX5nTvVY4s7E/Krz7COC8xkftbbKRYAl96vPiUssGkeMELQMOnLOJ8k3BY1+ZY52tttZnHcXQ==} + engines: {node: '>=18'} + cpu: [ia32] + os: [linux] + '@esbuild/linux-loong64@0.21.5': resolution: {integrity: sha512-uHf1BmMG8qEvzdrzAqg2SIG/02+4/DHB6a9Kbya0XDvwDEKCoC8ZRWI5JJvNdUjtciBGFQ5PuBlpEOXQj+JQSg==} engines: {node: '>=12'} cpu: [loong64] os: [linux] + '@esbuild/linux-loong64@0.23.1': + resolution: {integrity: sha512-Vx09LzEoBa5zDnieH8LSMRToj7ir/Jeq0Gu6qJ/1GcBq9GkfoEAoXvLiW1U9J1qE/Y/Oyaq33w5p2ZWrNNHNEw==} + engines: {node: '>=18'} + cpu: [loong64] + os: [linux] + '@esbuild/linux-mips64el@0.21.5': resolution: {integrity: sha512-IajOmO+KJK23bj52dFSNCMsz1QP1DqM6cwLUv3W1QwyxkyIWecfafnI555fvSGqEKwjMXVLokcV5ygHW5b3Jbg==} engines: {node: '>=12'} cpu: [mips64el] os: [linux] + '@esbuild/linux-mips64el@0.23.1': + resolution: {integrity: sha512-nrFzzMQ7W4WRLNUOU5dlWAqa6yVeI0P78WKGUo7lg2HShq/yx+UYkeNSE0SSfSure0SqgnsxPvmAUu/vu0E+3Q==} + engines: {node: '>=18'} + cpu: [mips64el] + os: [linux] + '@esbuild/linux-ppc64@0.21.5': resolution: {integrity: sha512-1hHV/Z4OEfMwpLO8rp7CvlhBDnjsC3CttJXIhBi+5Aj5r+MBvy4egg7wCbe//hSsT+RvDAG7s81tAvpL2XAE4w==} engines: {node: '>=12'} cpu: [ppc64] os: [linux] + '@esbuild/linux-ppc64@0.23.1': + resolution: {integrity: sha512-dKN8fgVqd0vUIjxuJI6P/9SSSe/mB9rvA98CSH2sJnlZ/OCZWO1DJvxj8jvKTfYUdGfcq2dDxoKaC6bHuTlgcw==} + engines: {node: '>=18'} + cpu: [ppc64] + os: [linux] + '@esbuild/linux-riscv64@0.21.5': resolution: {integrity: sha512-2HdXDMd9GMgTGrPWnJzP2ALSokE/0O5HhTUvWIbD3YdjME8JwvSCnNGBnTThKGEB91OZhzrJ4qIIxk/SBmyDDA==} engines: {node: '>=12'} cpu: [riscv64] os: [linux] + '@esbuild/linux-riscv64@0.23.1': + resolution: {integrity: sha512-5AV4Pzp80fhHL83JM6LoA6pTQVWgB1HovMBsLQ9OZWLDqVY8MVobBXNSmAJi//Csh6tcY7e7Lny2Hg1tElMjIA==} + engines: {node: '>=18'} + cpu: [riscv64] + os: [linux] + '@esbuild/linux-s390x@0.21.5': resolution: {integrity: sha512-zus5sxzqBJD3eXxwvjN1yQkRepANgxE9lgOW2qLnmr8ikMTphkjgXu1HR01K4FJg8h1kEEDAqDcZQtbrRnB41A==} engines: {node: '>=12'} cpu: [s390x] os: [linux] + '@esbuild/linux-s390x@0.23.1': + resolution: {integrity: sha512-9ygs73tuFCe6f6m/Tb+9LtYxWR4c9yg7zjt2cYkjDbDpV/xVn+68cQxMXCjUpYwEkze2RcU/rMnfIXNRFmSoDw==} + engines: {node: '>=18'} + cpu: [s390x] + os: [linux] + '@esbuild/linux-x64@0.21.5': resolution: {integrity: sha512-1rYdTpyv03iycF1+BhzrzQJCdOuAOtaqHTWJZCWvijKD2N5Xu0TtVC8/+1faWqcP9iBCWOmjmhoH94dH82BxPQ==} engines: {node: '>=12'} cpu: [x64] os: [linux] + '@esbuild/linux-x64@0.23.1': + resolution: {integrity: sha512-EV6+ovTsEXCPAp58g2dD68LxoP/wK5pRvgy0J/HxPGB009omFPv3Yet0HiaqvrIrgPTBuC6wCH1LTOY91EO5hQ==} + engines: {node: '>=18'} + cpu: [x64] + os: [linux] + '@esbuild/netbsd-x64@0.21.5': resolution: {integrity: sha512-Woi2MXzXjMULccIwMnLciyZH4nCIMpWQAs049KEeMvOcNADVxo0UBIQPfSmxB3CWKedngg7sWZdLvLczpe0tLg==} engines: {node: '>=12'} cpu: [x64] os: [netbsd] + '@esbuild/netbsd-x64@0.23.1': + resolution: {integrity: sha512-aevEkCNu7KlPRpYLjwmdcuNz6bDFiE7Z8XC4CPqExjTvrHugh28QzUXVOZtiYghciKUacNktqxdpymplil1beA==} + engines: {node: '>=18'} + cpu: [x64] + os: [netbsd] + + '@esbuild/openbsd-arm64@0.23.1': + resolution: {integrity: sha512-3x37szhLexNA4bXhLrCC/LImN/YtWis6WXr1VESlfVtVeoFJBRINPJ3f0a/6LV8zpikqoUg4hyXw0sFBt5Cr+Q==} + engines: {node: '>=18'} + cpu: [arm64] + os: [openbsd] + '@esbuild/openbsd-x64@0.21.5': resolution: {integrity: sha512-HLNNw99xsvx12lFBUwoT8EVCsSvRNDVxNpjZ7bPn947b8gJPzeHWyNVhFsaerc0n3TsbOINvRP2byTZ5LKezow==} engines: {node: '>=12'} cpu: [x64] os: [openbsd] + '@esbuild/openbsd-x64@0.23.1': + resolution: {integrity: sha512-aY2gMmKmPhxfU+0EdnN+XNtGbjfQgwZj43k8G3fyrDM/UdZww6xrWxmDkuz2eCZchqVeABjV5BpildOrUbBTqA==} + engines: {node: '>=18'} + cpu: [x64] + os: [openbsd] + '@esbuild/sunos-x64@0.21.5': resolution: {integrity: sha512-6+gjmFpfy0BHU5Tpptkuh8+uw3mnrvgs+dSPQXQOv3ekbordwnzTVEb4qnIvQcYXq6gzkyTnoZ9dZG+D4garKg==} engines: {node: '>=12'} cpu: [x64] os: [sunos] + '@esbuild/sunos-x64@0.23.1': + resolution: {integrity: sha512-RBRT2gqEl0IKQABT4XTj78tpk9v7ehp+mazn2HbUeZl1YMdaGAQqhapjGTCe7uw7y0frDi4gS0uHzhvpFuI1sA==} + engines: {node: '>=18'} + cpu: [x64] + os: [sunos] + '@esbuild/win32-arm64@0.21.5': resolution: {integrity: sha512-Z0gOTd75VvXqyq7nsl93zwahcTROgqvuAcYDUr+vOv8uHhNSKROyU961kgtCD1e95IqPKSQKH7tBTslnS3tA8A==} engines: {node: '>=12'} cpu: [arm64] os: [win32] + '@esbuild/win32-arm64@0.23.1': + resolution: {integrity: sha512-4O+gPR5rEBe2FpKOVyiJ7wNDPA8nGzDuJ6gN4okSA1gEOYZ67N8JPk58tkWtdtPeLz7lBnY6I5L3jdsr3S+A6A==} + engines: {node: '>=18'} + cpu: [arm64] + os: [win32] + '@esbuild/win32-ia32@0.21.5': resolution: {integrity: sha512-SWXFF1CL2RVNMaVs+BBClwtfZSvDgtL//G/smwAc5oVK/UPu2Gu9tIaRgFmYFFKrmg3SyAjSrElf0TiJ1v8fYA==} engines: {node: '>=12'} cpu: [ia32] os: [win32] + '@esbuild/win32-ia32@0.23.1': + resolution: {integrity: sha512-BcaL0Vn6QwCwre3Y717nVHZbAa4UBEigzFm6VdsVdT/MbZ38xoj1X9HPkZhbmaBGUD1W8vxAfffbDe8bA6AKnQ==} + engines: {node: '>=18'} + cpu: [ia32] + os: [win32] + '@esbuild/win32-x64@0.21.5': resolution: {integrity: sha512-tQd/1efJuzPC6rCFwEvLtci/xNFcTZknmXs98FYDfGE4wP9ClFV98nyKrzJKVPMhdDnjzLhdUyMX4PsQAPjwIw==} engines: {node: '>=12'} cpu: [x64] os: [win32] + '@esbuild/win32-x64@0.23.1': + resolution: {integrity: sha512-BHpFFeslkWrXWyUPnbKm+xYYVYruCinGcftSBaa8zoF9hZO4BcSCFUvHVTtzpIY6YzUnYtuEhZ+C9iEXjxnasg==} + engines: {node: '>=18'} + cpu: [x64] + os: [win32] + '@extractus/article-extractor@8.0.10': resolution: {integrity: sha512-wEUHThxLAss1RqA5dnCB4DiW1rR6yMA5Q7oTrDkbuS7fvyWHtTbDSs8454OANaFp0BBsmjb6KYXz/S8jiHCOTg==} engines: {node: '>= 18'} @@ -730,8 +874,8 @@ packages: '@types/node@17.0.45': resolution: {integrity: sha512-w+tIMs3rq2afQdsPJlODhoUEKzFP1ayaoyl1CcnwtIlsVe7K7bA1NGm4s3PraqTLlXnbIN84zuBlxBWo1u9BLw==} - '@types/node@22.3.0': - resolution: {integrity: sha512-nrWpWVaDZuaVc5X84xJ0vNrLvomM205oQyLsRt7OHNZbSHslcWsvgFR7O7hire2ZonjLrWBbedmotmIlJDVd6g==} + '@types/node@22.4.0': + resolution: {integrity: sha512-49AbMDwYUz7EXxKU/r7mXOsxwFr4BYbvB7tWYxVuLdb2ibd30ijjXINSMAHiEEZk5PCRBmW1gUeisn2VMKt3cQ==} '@types/sax@1.2.7': resolution: {integrity: sha512-rO73L89PJxeYM3s3pPPjiPgVVcymqU490g0YO5n5By0k2Erzj6tay/4lr1CHAAU4JyOWd1rpQ8bCf6cZfHU96A==} @@ -1211,6 +1355,11 @@ packages: engines: {node: '>=12'} hasBin: true + esbuild@0.23.1: + resolution: {integrity: sha512-VVNz/9Sa0bs5SELtn3f7qhJCDPCF5oMEl5cO9/SSinpE9hbPVvxbd572HH5AKiP7WD8INO53GgfDDhRjkylHEg==} + engines: {node: '>=18'} + hasBin: true + escalade@3.1.2: resolution: {integrity: sha512-ErCHMCae19vR8vQGe50xIsVomy19rg6gFu3+r3jkEO46suLMWBksvVyoGgQV+jOfl84ZSOSlmv6Gxa89PmTGmA==} engines: {node: '>=6'} @@ -2560,8 +2709,8 @@ packages: ultrahtml@1.5.3: resolution: {integrity: sha512-GykOvZwgDWZlTQMtp5jrD4BVL+gNn2NVlVafjcFUJ7taY20tqYdwdoWBFy6GBJsNTZe1GkGPkSl5knQAjtgceg==} - undici-types@6.18.2: - resolution: {integrity: sha512-5ruQbENj95yDYJNS3TvcaxPMshV7aizdv/hWYjGIKoANWKjhWNBsr2YEuYZKodQulB1b8l7ILOuDQep3afowQQ==} + undici-types@6.19.6: + resolution: {integrity: sha512-e/vggGopEfTKSvj4ihnOLTsqhrKRN3LeO6qSN/GxohhuRv8qH9bNQ4B8W7e/vFL+0XTnmHPB4/kegunZGA4Org==} undici@6.19.7: resolution: {integrity: sha512-HR3W/bMGPSr90i8AAp2C4DM3wChFdJPLrWYpIS++LxS8K+W535qftjt+4MyjNYHeWabMj1nvtmLIi7l++iq91A==} @@ -2951,12 +3100,12 @@ snapshots: transitivePeerDependencies: - supports-color - '@astrojs/mdx@3.1.3(astro@4.14.2(@types/node@22.3.0)(rollup@4.20.0)(sass@1.77.8)(typescript@5.5.4))': + '@astrojs/mdx@3.1.3(astro@4.14.2(@types/node@22.4.0)(rollup@4.20.0)(sass@1.77.8)(typescript@5.5.4))': dependencies: '@astrojs/markdown-remark': 5.2.0 '@mdx-js/mdx': 3.0.1 acorn: 8.12.1 - astro: 4.14.2(@types/node@22.3.0)(rollup@4.20.0)(sass@1.77.8)(typescript@5.5.4) + astro: 4.14.2(@types/node@22.4.0)(rollup@4.20.0)(sass@1.77.8)(typescript@5.5.4) es-module-lexer: 1.5.4 estree-util-visit: 2.0.0 github-slugger: 2.0.0 @@ -2972,9 +3121,9 @@ snapshots: transitivePeerDependencies: - supports-color - '@astrojs/node@8.3.3(astro@4.14.2(@types/node@22.3.0)(rollup@4.20.0)(sass@1.77.8)(typescript@5.5.4))': + '@astrojs/node@8.3.3(astro@4.14.2(@types/node@22.4.0)(rollup@4.20.0)(sass@1.77.8)(typescript@5.5.4))': dependencies: - astro: 4.14.2(@types/node@22.3.0)(rollup@4.20.0)(sass@1.77.8)(typescript@5.5.4) + astro: 4.14.2(@types/node@22.4.0)(rollup@4.20.0)(sass@1.77.8)(typescript@5.5.4) send: 0.18.0 server-destroy: 1.0.1 transitivePeerDependencies: @@ -3011,11 +3160,13 @@ snapshots: dependencies: yaml: 2.5.0 - '@ayco/astro-resume@0.4.2(astro@4.14.2(@types/node@22.3.0)(rollup@4.20.0)(sass@1.77.8)(typescript@5.5.4))': + '@ayco/astro-resume@0.4.2(astro@4.14.2(@types/node@22.4.0)(rollup@4.20.0)(sass@1.77.8)(typescript@5.5.4))': dependencies: - astro: 4.14.2(@types/node@22.3.0)(rollup@4.20.0)(sass@1.77.8)(typescript@5.5.4) + astro: 4.14.2(@types/node@22.4.0)(rollup@4.20.0)(sass@1.77.8)(typescript@5.5.4) - '@ayco/astro-sw@0.6.2': {} + '@ayco/astro-sw@0.7.1': + dependencies: + esbuild: 0.23.1 '@babel/code-frame@7.24.7': dependencies: @@ -3182,72 +3333,144 @@ snapshots: '@esbuild/aix-ppc64@0.21.5': optional: true + '@esbuild/aix-ppc64@0.23.1': + optional: true + '@esbuild/android-arm64@0.21.5': optional: true + '@esbuild/android-arm64@0.23.1': + optional: true + '@esbuild/android-arm@0.21.5': optional: true + '@esbuild/android-arm@0.23.1': + optional: true + '@esbuild/android-x64@0.21.5': optional: true + '@esbuild/android-x64@0.23.1': + optional: true + '@esbuild/darwin-arm64@0.21.5': optional: true + '@esbuild/darwin-arm64@0.23.1': + optional: true + '@esbuild/darwin-x64@0.21.5': optional: true + '@esbuild/darwin-x64@0.23.1': + optional: true + '@esbuild/freebsd-arm64@0.21.5': optional: true + '@esbuild/freebsd-arm64@0.23.1': + optional: true + '@esbuild/freebsd-x64@0.21.5': optional: true + '@esbuild/freebsd-x64@0.23.1': + optional: true + '@esbuild/linux-arm64@0.21.5': optional: true + '@esbuild/linux-arm64@0.23.1': + optional: true + '@esbuild/linux-arm@0.21.5': optional: true + '@esbuild/linux-arm@0.23.1': + optional: true + '@esbuild/linux-ia32@0.21.5': optional: true + '@esbuild/linux-ia32@0.23.1': + optional: true + '@esbuild/linux-loong64@0.21.5': optional: true + '@esbuild/linux-loong64@0.23.1': + optional: true + '@esbuild/linux-mips64el@0.21.5': optional: true + '@esbuild/linux-mips64el@0.23.1': + optional: true + '@esbuild/linux-ppc64@0.21.5': optional: true + '@esbuild/linux-ppc64@0.23.1': + optional: true + '@esbuild/linux-riscv64@0.21.5': optional: true + '@esbuild/linux-riscv64@0.23.1': + optional: true + '@esbuild/linux-s390x@0.21.5': optional: true + '@esbuild/linux-s390x@0.23.1': + optional: true + '@esbuild/linux-x64@0.21.5': optional: true + '@esbuild/linux-x64@0.23.1': + optional: true + '@esbuild/netbsd-x64@0.21.5': optional: true + '@esbuild/netbsd-x64@0.23.1': + optional: true + + '@esbuild/openbsd-arm64@0.23.1': + optional: true + '@esbuild/openbsd-x64@0.21.5': optional: true + '@esbuild/openbsd-x64@0.23.1': + optional: true + '@esbuild/sunos-x64@0.21.5': optional: true + '@esbuild/sunos-x64@0.23.1': + optional: true + '@esbuild/win32-arm64@0.21.5': optional: true + '@esbuild/win32-arm64@0.23.1': + optional: true + '@esbuild/win32-ia32@0.21.5': optional: true + '@esbuild/win32-ia32@0.23.1': + optional: true + '@esbuild/win32-x64@0.21.5': optional: true + '@esbuild/win32-x64@0.23.1': + optional: true + '@extractus/article-extractor@8.0.10': dependencies: '@mozilla/readability': 0.5.0 @@ -3598,9 +3821,9 @@ snapshots: '@types/node@17.0.45': {} - '@types/node@22.3.0': + '@types/node@22.4.0': dependencies: - undici-types: 6.18.2 + undici-types: 6.19.6 '@types/sax@1.2.7': dependencies: @@ -3608,7 +3831,7 @@ snapshots: '@types/tar@6.1.13': dependencies: - '@types/node': 22.3.0 + '@types/node': 22.4.0 minipass: 4.2.8 '@types/unist@2.0.11': {} @@ -3617,7 +3840,7 @@ snapshots: '@types/yauzl@2.10.3': dependencies: - '@types/node': 22.3.0 + '@types/node': 22.4.0 optional: true '@ungap/structured-clone@1.2.0': {} @@ -3754,7 +3977,7 @@ snapshots: - debug - supports-color - astro@4.14.2(@types/node@22.3.0)(rollup@4.20.0)(sass@1.77.8)(typescript@5.5.4): + astro@4.14.2(@types/node@22.4.0)(rollup@4.20.0)(sass@1.77.8)(typescript@5.5.4): dependencies: '@astrojs/compiler': 2.10.3 '@astrojs/internal-helpers': 0.4.1 @@ -3815,8 +4038,8 @@ snapshots: tsconfck: 3.1.1(typescript@5.5.4) unist-util-visit: 5.0.0 vfile: 6.0.2 - vite: 5.4.1(@types/node@22.3.0)(sass@1.77.8) - vitefu: 0.2.5(vite@5.4.1(@types/node@22.3.0)(sass@1.77.8)) + vite: 5.4.1(@types/node@22.4.0)(sass@1.77.8) + vitefu: 0.2.5(vite@5.4.1(@types/node@22.4.0)(sass@1.77.8)) which-pm: 3.0.0 xxhash-wasm: 1.0.2 yargs-parser: 21.1.1 @@ -4186,6 +4409,33 @@ snapshots: '@esbuild/win32-ia32': 0.21.5 '@esbuild/win32-x64': 0.21.5 + esbuild@0.23.1: + optionalDependencies: + '@esbuild/aix-ppc64': 0.23.1 + '@esbuild/android-arm': 0.23.1 + '@esbuild/android-arm64': 0.23.1 + '@esbuild/android-x64': 0.23.1 + '@esbuild/darwin-arm64': 0.23.1 + '@esbuild/darwin-x64': 0.23.1 + '@esbuild/freebsd-arm64': 0.23.1 + '@esbuild/freebsd-x64': 0.23.1 + '@esbuild/linux-arm': 0.23.1 + '@esbuild/linux-arm64': 0.23.1 + '@esbuild/linux-ia32': 0.23.1 + '@esbuild/linux-loong64': 0.23.1 + '@esbuild/linux-mips64el': 0.23.1 + '@esbuild/linux-ppc64': 0.23.1 + '@esbuild/linux-riscv64': 0.23.1 + '@esbuild/linux-s390x': 0.23.1 + '@esbuild/linux-x64': 0.23.1 + '@esbuild/netbsd-x64': 0.23.1 + '@esbuild/openbsd-arm64': 0.23.1 + '@esbuild/openbsd-x64': 0.23.1 + '@esbuild/sunos-x64': 0.23.1 + '@esbuild/win32-arm64': 0.23.1 + '@esbuild/win32-ia32': 0.23.1 + '@esbuild/win32-x64': 0.23.1 + escalade@3.1.2: {} escape-html@1.0.3: {} @@ -5942,7 +6192,7 @@ snapshots: ultrahtml@1.5.3: {} - undici-types@6.18.2: {} + undici-types@6.19.6: {} undici@6.19.7: {} @@ -6024,19 +6274,19 @@ snapshots: unist-util-stringify-position: 4.0.0 vfile-message: 4.0.2 - vite@5.4.1(@types/node@22.3.0)(sass@1.77.8): + vite@5.4.1(@types/node@22.4.0)(sass@1.77.8): dependencies: esbuild: 0.21.5 postcss: 8.4.41 rollup: 4.20.0 optionalDependencies: - '@types/node': 22.3.0 + '@types/node': 22.4.0 fsevents: 2.3.3 sass: 1.77.8 - vitefu@0.2.5(vite@5.4.1(@types/node@22.3.0)(sass@1.77.8)): + vitefu@0.2.5(vite@5.4.1(@types/node@22.4.0)(sass@1.77.8)): optionalDependencies: - vite: 5.4.1(@types/node@22.3.0)(sass@1.77.8) + vite: 5.4.1(@types/node@22.4.0)(sass@1.77.8) volar-service-css@0.0.59(@volar/language-service@2.4.0-alpha.18): dependencies: diff --git a/src/components/Library.astro b/src/components/Library.astro index a4e303b..6d7681b 100644 --- a/src/components/Library.astro +++ b/src/components/Library.astro @@ -17,7 +17,7 @@ export interface Props { import type { AppConfig } from '../pages/index.astro'; import { getPostCard, renderPost } from '../utils/library' import { cozify } from '../utils/sanitizer'; - import { logError, logInfo } from '../utils/logger.mjs'; + import { logError, logInfo } from '../utils/logger'; const cache = await caches.open('cozy-reader'); const baseUrl = window.location.origin; let url= new URL(window.location.href); diff --git a/src/env.d.ts b/src/env.d.ts index c13bd73..9bc5cb4 100644 --- a/src/env.d.ts +++ b/src/env.d.ts @@ -1,2 +1 @@ -/// -/// \ No newline at end of file +/// \ No newline at end of file diff --git a/src/sw.js b/src/sw.ts similarity index 92% rename from src/sw.js rename to src/sw.ts index edbad03..0346960 100644 --- a/src/sw.js +++ b/src/sw.ts @@ -1,3 +1,4 @@ +import { logInfo } from './utils/logger' /** * Note: @ayco/astro-sw integration injects variables `__prefix`, `__version`, & `__assets` * -- find usage in `astro.config.mjs` integrations @@ -6,23 +7,9 @@ const cacheName = `${__prefix ?? 'app'}-v${__version ?? '000'}` const forceLogging = false; -/** - * TODO: remove this once astro-sw allows importing utils - */ -function logInfo(message, {context, force, data} = {}) { - context = context !== '' - ? `[${context}]: ` - : '' - - if (force) { - console.info(`${context}${message}`, data ?? ''); - } -} - - const addResourcesToCache = async (resources) => { const cache = await caches.open(cacheName); - logInfo('adding resources to cache...', { force: forceLogging, context: 'cozy-sw', data: resources }) + logInfo('adding resources to cache...', { force: !!forceLogging, context: 'cozy-sw', data: resources }) await cache.addAll(resources); }; diff --git a/src/utils/logger.mjs b/src/utils/logger.mjs deleted file mode 100644 index b0704de..0000000 --- a/src/utils/logger.mjs +++ /dev/null @@ -1,54 +0,0 @@ -// @ts-check - -const isDev = import.meta.env.DEV; - -/** - * @typedef {{ - * force?: true - * context?: string, - * data?: any - * }} LogOptions - */ - - -/** - * @param {string} message - * @param {LogOptions} options - */ -export function logMessage(message, {context, force, data} = {}) { - context = context !== '' - ? `[${context}]: ` - : '' - - if (force || isDev) { - console.log(`${context}${message}`, data ?? ''); - } -} - -/** - * @param {string} message - * @param {LogOptions} options - */ -export function logInfo(message, {context, force, data} = {}) { - context = context !== '' - ? `[${context}]: ` - : '' - - if (force || isDev) { - console.info(`${context}${message}`, data ?? ''); - } -} - -/** - * @param {string} message - * @param {LogOptions} options - */ -export function logError(message, {context, force, data} = {}) { - context = context !== '' - ? `[${context}]: ` - : '' - - if (force || isDev) { - console.error(`${context}${message}`, data ?? ''); - } -} \ No newline at end of file diff --git a/src/utils/logger.ts b/src/utils/logger.ts new file mode 100644 index 0000000..ce7dbb9 --- /dev/null +++ b/src/utils/logger.ts @@ -0,0 +1,31 @@ +// @ts-check + +export type LogOptions = { + force?: boolean + context?: string, + data?: any +} + +function log(message, method: 'log' | 'info' | 'error' = 'log', options?: LogOptions) { + let {context, force, data} = options ?? {}; + + context = context && context !== '' + ? `[${context}]: ` + : '' + + if (force) { + console[method](`${context}${message}`, data ?? ''); + } +} + +export function logMessage(message: string, options: LogOptions) { + log(message, 'log', options); +} + +export function logInfo(message: string, options: LogOptions) { + log(message, 'info', options); +} + +export function logError(message: string, options: LogOptions) { + log(message, 'error', options); +} \ No newline at end of file