From b0bcc57caa86b83b9122b44de2ffbb0d57f04646 Mon Sep 17 00:00:00 2001 From: ayoayco Date: Thu, 15 Aug 2024 17:35:36 +0200 Subject: [PATCH] perf: improve caching strategy conditions --- package.json | 18 ++- pnpm-lock.yaml | 309 +++++++++++++++++++++++++++++++++++++------------ src/consts.ts | 2 +- src/sw.js | 80 ++++++------- 4 files changed, 287 insertions(+), 122 deletions(-) diff --git a/package.json b/package.json index 5f0aa56..bacdb5e 100644 --- a/package.json +++ b/package.json @@ -18,23 +18,21 @@ "deploy:client": "astro build && scp -r dist/client/ ayo@ayco.io:~/cozy/dist/" }, "devDependencies": { + "@astrojs/check": "^0.9.2", + "@astrojs/mdx": "^3.1.3", "@astrojs/node": "^8.3.3", + "@astrojs/rss": "^4.0.7", + "@astrojs/sitemap": "^3.1.6", "@ayco/astro-resume": "^0.4.2", - "@ayco/astro-sw": "^0.1.1", + "@ayco/astro-sw": "^0.2.2", "@extractus/article-extractor": "^8.0.10", "@fastify/middie": "^8.3.1", "@fastify/static": "^7.0.4", - "astro": "^4.13.4", + "astro": "^4.14.1", "astro-iconify": "^1.2.0", "fastify": "^4.28.1", "sass": "^1.77.8", - "ultrahtml": "^1.5.3", - - "@astrojs/mdx": "^3.1.3", - "@astrojs/rss": "^4.0.7", - "@astrojs/sitemap": "^3.1.6", - "@astrojs/check": "^0.9.2", - "typescript": "^5.5.4" - + "typescript": "^5.5.4", + "ultrahtml": "^1.5.3" } } diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index f68712d..d2b48ec 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.13.4(@types/node@22.3.0)(sass@1.77.8)(typescript@5.5.4)) + version: 3.1.3(astro@4.14.1(@types/node@22.3.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.13.4(@types/node@22.3.0)(sass@1.77.8)(typescript@5.5.4)) + version: 8.3.3(astro@4.14.1(@types/node@22.3.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.13.4(@types/node@22.3.0)(sass@1.77.8)(typescript@5.5.4)) + version: 0.4.2(astro@4.14.1(@types/node@22.3.0)(rollup@4.20.0)(sass@1.77.8)(typescript@5.5.4)) '@ayco/astro-sw': - specifier: ^0.1.1 - version: 0.1.1 + specifier: ^0.2.2 + version: 0.2.2 '@extractus/article-extractor': specifier: ^8.0.10 version: 8.0.10 @@ -39,8 +39,8 @@ importers: specifier: ^7.0.4 version: 7.0.4 astro: - specifier: ^4.13.4 - version: 4.13.4(@types/node@22.3.0)(sass@1.77.8)(typescript@5.5.4) + specifier: ^4.14.1 + version: 4.14.1(@types/node@22.3.0)(rollup@4.20.0)(sass@1.77.8)(typescript@5.5.4) astro-iconify: specifier: ^1.2.0 version: 1.2.0 @@ -81,8 +81,8 @@ packages: '@astrojs/internal-helpers@0.4.1': resolution: {integrity: sha512-bMf9jFihO8YP940uD70SI/RDzIhUHJAolWVcO1v5PUivxGKvfLZTLTVVxEYzGYyPsA3ivdLNqMnL5VgmQySa+g==} - '@astrojs/language-server@2.13.4': - resolution: {integrity: sha512-G57eikA4yGbixbgO7EMlLNH+lsIgjZs2nSuz0dAWL+Ueqz1TX6A0gV1HSIK9PZLFXYmngvWDGn0BLFuVs05QOg==} + '@astrojs/language-server@2.14.0': + resolution: {integrity: sha512-vDufoVpQ7xP98F1FdI9TwccglqsRGGzyQ0D6dQV2W23p/Nif7npWStrv00WeY6YQHBFxsygccOzdvzzITaxViw==} hasBin: true peerDependencies: prettier: ^3.0.0 @@ -121,13 +121,16 @@ packages: resolution: {integrity: sha512-/ca/+D8MIKEC8/A9cSaPUqQNZm+Es/ZinRv0ZAzvu2ios7POQSsVD+VOj7/hypWNsNM3T7RpfgNq7H2TU1KEHA==} engines: {node: ^18.17.1 || ^20.3.0 || >=21.0.0} + '@astrojs/yaml2ts@0.2.0': + resolution: {integrity: sha512-xyJ2JpenXis5V2yk4OExNyHXyRlCKrJcPfNPLK0rqf24grqpRZ4bYD/ztesYicYlaXehH9aUJXG0mVu8P02G9A==} + '@ayco/astro-resume@0.4.2': resolution: {integrity: sha512-blbFmMxkvLqZ0Fw78ySrfeysdhTlaOIsR7V2Fqd1F20Q0B3SCxFomcNvRMw1j45+tBovxeS44XBtEarhBoQXfw==} peerDependencies: astro: ^4.12.2 - '@ayco/astro-sw@0.1.1': - resolution: {integrity: sha512-kwKZTSJWD8W6jVbM12o0FAsXmO9KDOktZ8gqV9DaCsRlkDCRiCdywisORNwnMIXrZVgs6VOkPAZ6qezeudalyA==} + '@ayco/astro-sw@0.2.2': + resolution: {integrity: sha512-G8wv6UChMN7j2BVGfXsytarTnUhLn84IO5xoGxa4nUIFrRS0rUMYb5ovcNJ/THYN4H5bhyp2ymnrPNXO5UqdGw==} engines: {node: '>=18.0.0'} '@babel/code-frame@7.24.7': @@ -586,6 +589,15 @@ packages: resolution: {integrity: sha512-+1VkjdD0QBLPodGrJUeqarH8VAIvQODIbwh9XpP5Syisf7YoQgsJKPNFoqqLQlu+VQ/tVSshMR6loPMn8U+dPg==} engines: {node: '>=14'} + '@rollup/pluginutils@5.1.0': + resolution: {integrity: sha512-XTIWOPPcpvyKI6L1NHo0lFlCyznUEyPmPY1mc3KpPVDYulHSTvyeLNVW00QTLIAFNhR3kYnJTQHeGqU4M3n09g==} + engines: {node: '>=14.0.0'} + peerDependencies: + rollup: ^1.20.0||^2.0.0||^3.0.0||^4.0.0 + peerDependenciesMeta: + rollup: + optional: true + '@rollup/rollup-android-arm-eabi@4.20.0': resolution: {integrity: sha512-TSpWzflCc4VGAUJZlPpgAJE1+V60MePDQnBd7PPkpuEmOy8i87aL6tinFGKBFKuEDikYpig72QzdT3QPYIi+oA==} cpu: [arm] @@ -727,11 +739,11 @@ packages: '@types/tar@6.1.13': resolution: {integrity: sha512-IznnlmU5f4WcGTh2ltRu/Ijpmk8wiWXfF0VA4s+HPjHZgvFggk1YaIkbo5krX/zUCzWF8N/l4+W/LNxnvAJ8nw==} - '@types/unist@2.0.10': - resolution: {integrity: sha512-IfYcSBWE3hLpBg8+X2SEa8LVkJdJEkT2Ese2aaLs3ptGdVtABxndrMaxuFlQ1qdFf9Q5rDvDpxI3WwgvKFAsQA==} + '@types/unist@2.0.11': + resolution: {integrity: sha512-CmBKiL6NNo/OqgmMn95Fk9Whlp2mtvIv+KNpQKN2F4SjvrEesubTRWGYSg+BnWZOnlCaSTU1sMpsBOzgbYhnsA==} - '@types/unist@3.0.2': - resolution: {integrity: sha512-dqId9J8K/vGi5Zr7oo212BGii5m3q5Hxlkwy3WpYuKPklmBEvsbMYYyLxAQpSffdLl/gdW0XUpKWFvYmyoWCoQ==} + '@types/unist@3.0.3': + resolution: {integrity: sha512-ko/gIFJRv177XgZsZcBwnqJN5x/Gien8qNOn0D5bQU/zAzVf9Zt3BlcUiLqhV9y4ARk0GbT3tnUiPNgnTXzc/Q==} '@types/yauzl@2.10.3': resolution: {integrity: sha512-oJoftv0LSuaDZE3Le4DbKX+KS9G36NzOeSap90UIK0yMA/NhKJhqlSGtNDORNRaIbQfzjXDrQa0ytJ6mNRGz/Q==} @@ -853,8 +865,8 @@ packages: astro-iconify@1.2.0: resolution: {integrity: sha512-arLDiSop3DAHHS30raZysspkz5MO9moJJZ4rJk1Ty+4W1jZDa00Jme0LrnRJRDB6BB2EDTxC553fo20yz3MeYw==} - astro@4.13.4: - resolution: {integrity: sha512-uoW961qyU5xxCiUzITVX8wYmdWbSH1zeog9UomoWC5uNpnIbH6WxOPv/qYu2m7W4r2PCxdRqfVXoYjZhFyGfTA==} + astro@4.14.1: + resolution: {integrity: sha512-tLhGE+vHl+n66KgzyV7ek6ro2dqKenHqdxPb/R6x9ci+fKG5lSSOeb/dP/XVhpKUMcuV98IGWTxL5VPzqPFUJQ==} engines: {node: ^18.17.1 || ^20.3.0 || >=21.0.0, npm: '>=9.6.5', pnpm: '>=7.1.0'} hasBin: true @@ -1162,8 +1174,8 @@ packages: ee-first@1.1.1: resolution: {integrity: sha512-WMwm9LhRUo+WUaRN+vRuETqG89IgZphVSNkdFgeb6sS/E4OrDIN7t48CAewSHXc6C8lefD8KKfr5vY61brQlow==} - electron-to-chromium@1.5.7: - resolution: {integrity: sha512-6FTNWIWMxMy/ZY6799nBlPtF1DFDQ6VQJ7yyDP27SJNt5lwtQ5ufqVvHylb3fdQefvRcgA3fKcFMJi9OLwBRNw==} + electron-to-chromium@1.5.8: + resolution: {integrity: sha512-4Nx0gP2tPNBLTrFxBMHpkQbtn2hidPVr/+/FTtcCiBYTucqc70zRyVZiOLj17Ui3wTO7SQ1/N+hkHYzJjBzt6A==} emmet@2.4.7: resolution: {integrity: sha512-O5O5QNqtdlnQM2bmKHtJgyChcrFMgQuulI+WdiOw2NArzprUqqxUW6bgYtKvzKgrsYpuLWalOkdhNP+1jluhCA==} @@ -1238,6 +1250,9 @@ packages: estree-util-visit@2.0.0: resolution: {integrity: sha512-m5KgiH85xAhhW8Wta0vShLcUvOsh3LLPI2YVwcbio1l7E09NTLL1EyMZFM1OyWowoH0skScNbhOPl4kcBgzTww==} + estree-walker@2.0.2: + resolution: {integrity: sha512-Rfkk/Mp/DL7JVje3u18FxFujQlTNR2q6QfMSMB7AvCBx91NGj/ba3kCfza0f6dVDbw7YlRf/nDrn7pQrCCyQ/w==} + estree-walker@3.0.3: resolution: {integrity: sha512-7RUKfXgSMMkzt6ZuXmqapOurLGPPfgj6l9uRZ7lRGolvk0y2yocc35LdcxKC5PQZdn2DMqioAQ2NoWcrTKmm6g==} @@ -1649,6 +1664,9 @@ packages: jsonc-parser@2.3.1: resolution: {integrity: sha512-H8jvkz1O50L3dMZCsLqiuB2tA7muqbSg1AtGEkN0leAqGjsUzDJir3Zwr02BhqdcITPg3ei3mZ+HjMocAknhhg==} + jsonc-parser@3.3.1: + resolution: {integrity: sha512-HUgH65KyejrUFPvHFPbqOY0rsFip3Bo5wb4ngvdi1EpCYWUQDC5V+Y7mZws+DLkr4M//zQJoanu1SP+87Dv1oQ==} + kind-of@6.0.3: resolution: {integrity: sha512-dcS1ul+9tmeD95T+x28/ehLgd9mENa3LsvDTtzm3vyBEO7RPptvAD+t44WVXaUjTBRcrpFeFlC8WCruUR456hw==} engines: {node: '>=0.10.0'} @@ -1686,6 +1704,9 @@ packages: resolution: {integrity: sha512-iPZK6eYjbxRu3uB4/WZ3EsEIMJFMqAoopl3R+zuq0UjcAm/MO6KCweDgPfP3elTztoKP3KtnVHxTn2NHBSDVUw==} engines: {node: '>=10'} + lodash@4.17.21: + resolution: {integrity: sha512-v2kDEe57lecTulaDIuNTPy3Ry4gLGJ6Z1O3vE1krgXZNrsQ+LFTGHVxVjcXPs17LhbZVGedAJv8XZ1tvj5FvSg==} + log-symbols@6.0.0: resolution: {integrity: sha512-i24m8rpwhmPIS4zscNzK6MSEhk0DUWa/8iYQWxhffV8jkI4Phvs3F+quL5xvS0gdQR0FyTCMMH33Y78dDTzzIw==} engines: {node: '>=18'} @@ -1961,6 +1982,10 @@ packages: engines: {node: ^10 || ^12 || ^13.7 || ^14 || >=15.0.1} hasBin: true + neotraverse@0.6.18: + resolution: {integrity: sha512-Z4SmBUweYa09+o6pG+eASabEpP6QkQ70yHj351pQoEXIs8uHbaU2DWVmzBANKgflPa47A50PtB2+NgRpQvr7vA==} + engines: {node: '>= 10'} + nlcst-to-string@4.0.0: resolution: {integrity: sha512-YKLBCcUYKAg0FNlOBT6aI91qFmSiFKiluk655WzPF+DDMA02qIyy8uiRqI8QXtcFpEvll12LpL5MXqEmAZ+dcA==} @@ -2142,6 +2167,11 @@ packages: resolution: {integrity: sha512-gYBeFTZLu055D8Vv3cSPox/0iTPtkzxpLroSYYA7WXgRi31WCJ51Uyl8ZiPeUUjyvs2MBzK+S8v9JVUgHU/Sqw==} engines: {node: '>=18.12'} + prettier@2.8.7: + resolution: {integrity: sha512-yPngTo3aXUUmyuTjeTUT75txrf+aMh9FiD7q9ZE/i6r0bPb22g4FsE6Y338PQX1bmfy08i9QQCB7/rcUAVntfw==} + engines: {node: '>=10.13.0'} + hasBin: true + prismjs@1.29.0: resolution: {integrity: sha512-Kx/1w86q/epKcmte75LNrEoT+lX8pBpavuAbvJWRXar7Hz8jrtF+e3vY751p0R8H9HdArwaCTNDDzHg/ScJK1Q==} engines: {node: '>=6'} @@ -2226,6 +2256,9 @@ packages: remark-stringify@11.0.0: resolution: {integrity: sha512-1OSmLd3awB/t8qdoEOMazZkNsfVTeY4fTsgzcQFdXNq8ToTN4ZGwrMnlda4K6smTFKD+GRV6O48i6Z4iKgPPpw==} + request-light@0.5.8: + resolution: {integrity: sha512-3Zjgh+8b5fhRJBQZoy+zbVKpAQGLyka0MPgW3zruTF4dFFJ8Fqcfu9YsAvi/rvdcaTeWG3MkbZv4WKxAn/84Lg==} + request-light@0.7.0: resolution: {integrity: sha512-lMbBMrDoxgsyO+yB3sDcrDuX85yYt7sS8BfQd11jtbW/z5ZWgLZRcEGLsLoYw7I0WSUGQBs8CC8ScIxkTX1+6Q==} @@ -2582,8 +2615,8 @@ packages: vfile@6.0.2: resolution: {integrity: sha512-zND7NlS8rJYb/sPqkb13ZvbbUoExdbi4w3SfRrMq6R3FvnLQmmfpajJNITuuYm6AZ5uao9vy4BAos3EXBPf2rg==} - vite@5.4.0: - resolution: {integrity: sha512-5xokfMX0PIiwCMCMb9ZJcMyh5wbBun0zUzKib+L65vAZ8GY9ePZMXxFrHbr/Kyll2+LSCY7xtERPpxkBDKngwg==} + vite@5.4.1: + resolution: {integrity: sha512-1oE6yuNXssjrZdblI9AfBbHCC41nnyoVoEZxQnID6yvQZAFBzxxkqoFLtHUMkYunL8hwOLEjgTuxpkRxvba3kA==} engines: {node: ^18.0.0 || >=20.0.0} hasBin: true peerDependencies: @@ -2672,25 +2705,51 @@ packages: '@volar/language-service': optional: true + volar-service-yaml@0.0.59: + resolution: {integrity: sha512-7Pi7XWnmgcWmdW7essscHn2+CcG1BEgnNjEE/31GaycwvLu4rPF+Xztzc0ErZLSFW3F2EBPzaecWfrGL2l4NGQ==} + peerDependencies: + '@volar/language-service': ~2.4.0-alpha.12 + peerDependenciesMeta: + '@volar/language-service': + optional: true + vscode-css-languageservice@6.3.0: resolution: {integrity: sha512-nU92imtkgzpCL0xikrIb8WvedV553F2BENzgz23wFuok/HLN5BeQmroMy26pUwFxV2eV8oNRmYCUv8iO7kSMhw==} vscode-html-languageservice@5.3.0: resolution: {integrity: sha512-C4Z3KsP5Ih+fjHpiBc5jxmvCl+4iEwvXegIrzu2F5pktbWvQaBT3YkVPk8N+QlSSMk8oCG6PKtZ/Sq2YHb5e8g==} + vscode-json-languageservice@4.1.8: + resolution: {integrity: sha512-0vSpg6Xd9hfV+eZAaYN63xVVMOTmJ4GgHxXnkLCh+9RsQBkWKIghzLhW2B9ebfG+LQQg8uLtsQ2aUKjTgE+QOg==} + engines: {npm: '>=7.0.0'} + + vscode-jsonrpc@6.0.0: + resolution: {integrity: sha512-wnJA4BnEjOSyFMvjZdpiOwhSq9uDoK8e/kpRJDTaMYzwlkrhG1fwDIZI94CLsLzlCK5cIbMMtFlJlfR57Lavmg==} + engines: {node: '>=8.0.0 || >=10.0.0'} + vscode-jsonrpc@8.2.0: resolution: {integrity: sha512-C+r0eKJUIfiDIfwJhria30+TYWPtuHJXHtI7J0YlOmKAo7ogxP20T0zxB7HZQIFhIyvoBPwWskjxrvAtfjyZfA==} engines: {node: '>=14.0.0'} + vscode-languageserver-protocol@3.16.0: + resolution: {integrity: sha512-sdeUoAawceQdgIfTI+sdcwkiK2KU+2cbEYA0agzM2uqaUy2UpnnGHtWTHVEtS0ES4zHU0eMFRGN+oQgDxlD66A==} + vscode-languageserver-protocol@3.17.5: resolution: {integrity: sha512-mb1bvRJN8SVznADSGWM9u/b07H7Ecg0I3OgXDuLdn307rl/J3A9YD6/eYOssqhecL27hK1IPZAsaqh00i/Jljg==} vscode-languageserver-textdocument@1.0.12: resolution: {integrity: sha512-cxWNPesCnQCcMPeenjKKsOCKQZ/L6Tv19DTRIGuLWe32lyzWhihGVJ/rcckZXJxfdKCFvRLS3fpBIsV/ZGX4zA==} + vscode-languageserver-types@3.16.0: + resolution: {integrity: sha512-k8luDIWJWyenLc5ToFQQMaSrqCHiLwyKPHKPQZ5zz21vM+vIVUSvsRpcbiECH4WR88K2XZqc4ScRcZ7nk/jbeA==} + vscode-languageserver-types@3.17.5: resolution: {integrity: sha512-Ld1VelNuX9pdF39h2Hgaeb5hEZM2Z3jUrrMgWQAu82jMtZp7p3vJT3BzToKtZI7NgQssZje5o0zryOrhQvzQAg==} + vscode-languageserver@7.0.0: + resolution: {integrity: sha512-60HTx5ID+fLRcgdHfmz0LDZAXYEV68fzwG0JWwEPBode9NuMYTIxuYXPg4ngO8i8+Ou0lM7y6GzaYWbiDL0drw==} + hasBin: true + vscode-languageserver@9.0.1: resolution: {integrity: sha512-woByF3PDpkHFUreUa7Hos7+pUWdeWMXRd26+ZX2A8cFx6v/JPTtd4/uN0/jB6XQHYaOlHbio03NTHCqrgG5n7g==} hasBin: true @@ -2753,6 +2812,9 @@ packages: wrappy@1.0.2: resolution: {integrity: sha512-l4Sp/DRseor9wL6EvV2+TuQn63dMkPjZ/sp9XkghTEbV9KlPS1xUsZ3u7/IQO4wxtcFB4bgpQPRcR3QCvezPcQ==} + xxhash-wasm@1.0.2: + resolution: {integrity: sha512-ibF0Or+FivM9lNrg+HGJfVX8WJqgo+kCLDc4vx6xMeTce7Aj+DLttKbxxRR/gNLSAelRc1omAPlJ77N/Jem07A==} + y18n@5.0.8: resolution: {integrity: sha512-0pfFzegeDWJHJIAmTLRP2DwHjdF5s7jo9tuztdQxAhINCdvS+3nGINqPd00AphqJR/0LhANUS6/+7SCb98YOfA==} engines: {node: '>=10'} @@ -2763,6 +2825,19 @@ packages: yallist@4.0.0: resolution: {integrity: sha512-3wdGidZyq5PB084XLES5TpOSRA3wjXAlIWMhum2kRcv/41Sn2emQ0dycQW4uZXLejwKvg6EsvbdlVL+FYEct7A==} + yaml-language-server@1.15.0: + resolution: {integrity: sha512-N47AqBDCMQmh6mBLmI6oqxryHRzi33aPFPsJhYy3VTUGCdLHYjGh4FZzpUjRlphaADBBkDmnkM/++KNIOHi5Rw==} + hasBin: true + + yaml@2.2.2: + resolution: {integrity: sha512-CBKFWExMn46Foo4cldiChEzn7S7SRV+wqiluAb6xmueD/fGyRHIhX8m14vVGgeFWjN540nKCNVj6P21eQjgTuA==} + engines: {node: '>= 14'} + + yaml@2.5.0: + resolution: {integrity: sha512-2wWLbGbYDiSqqIKoPjar3MPgB94ErzCtrNE1FdqGuaO0pi2JGjmE8aW8TDZwzU7vuxcGRdL/4gPQwQ7hD5AMSw==} + engines: {node: '>= 14'} + hasBin: true + yargs-parser@21.1.1: resolution: {integrity: sha512-tVpsJW7DdjecAiFpbIB1e3qxIQsE6NoPc5/eTdrbbIC4h0LVsWhnoa3g+m2HclBIujHzsxZ4VJVA+GUuc2/LBw==} engines: {node: '>=12'} @@ -2787,6 +2862,12 @@ packages: peerDependencies: zod: ^3.23.3 + zod-to-ts@1.2.0: + resolution: {integrity: sha512-x30XE43V+InwGpvTySRNz9kB7qFU8DlyEy7BsSTCHPH1R0QasMmHWZDCzYm6bVXtj/9NNJAZF3jW8rzFvH5OFA==} + peerDependencies: + typescript: ^4.9.4 || ^5.0.2 + zod: ^3 + zod@3.23.8: resolution: {integrity: sha512-XBx9AXhXktjUqnepgTiE5flcKIYWi/rme0Eaj+5Y0lftuGBq+jyRu/md4WnuxqgP1ubdpNCsYEYPxrzVHD8d6g==} @@ -2809,7 +2890,7 @@ snapshots: '@astrojs/check@0.9.2(typescript@5.5.4)': dependencies: - '@astrojs/language-server': 2.13.4(typescript@5.5.4) + '@astrojs/language-server': 2.14.0(typescript@5.5.4) chokidar: 3.6.0 fast-glob: 3.3.2 kleur: 4.1.5 @@ -2823,9 +2904,10 @@ snapshots: '@astrojs/internal-helpers@0.4.1': {} - '@astrojs/language-server@2.13.4(typescript@5.5.4)': + '@astrojs/language-server@2.14.0(typescript@5.5.4)': dependencies: '@astrojs/compiler': 2.10.3 + '@astrojs/yaml2ts': 0.2.0 '@jridgewell/sourcemap-codec': 1.5.0 '@volar/kit': 2.4.0-alpha.18(typescript@5.5.4) '@volar/language-core': 2.4.0-alpha.18 @@ -2840,6 +2922,7 @@ snapshots: volar-service-prettier: 0.0.59(@volar/language-service@2.4.0-alpha.18) volar-service-typescript: 0.0.59(@volar/language-service@2.4.0-alpha.18) volar-service-typescript-twoslash-queries: 0.0.59(@volar/language-service@2.4.0-alpha.18) + volar-service-yaml: 0.0.59(@volar/language-service@2.4.0-alpha.18) vscode-html-languageservice: 5.3.0 vscode-uri: 3.0.8 transitivePeerDependencies: @@ -2868,12 +2951,12 @@ snapshots: transitivePeerDependencies: - supports-color - '@astrojs/mdx@3.1.3(astro@4.13.4(@types/node@22.3.0)(sass@1.77.8)(typescript@5.5.4))': + '@astrojs/mdx@3.1.3(astro@4.14.1(@types/node@22.3.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.13.4(@types/node@22.3.0)(sass@1.77.8)(typescript@5.5.4) + astro: 4.14.1(@types/node@22.3.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 @@ -2889,9 +2972,9 @@ snapshots: transitivePeerDependencies: - supports-color - '@astrojs/node@8.3.3(astro@4.13.4(@types/node@22.3.0)(sass@1.77.8)(typescript@5.5.4))': + '@astrojs/node@8.3.3(astro@4.14.1(@types/node@22.3.0)(rollup@4.20.0)(sass@1.77.8)(typescript@5.5.4))': dependencies: - astro: 4.13.4(@types/node@22.3.0)(sass@1.77.8)(typescript@5.5.4) + astro: 4.14.1(@types/node@22.3.0)(rollup@4.20.0)(sass@1.77.8)(typescript@5.5.4) send: 0.18.0 server-destroy: 1.0.1 transitivePeerDependencies: @@ -2924,11 +3007,15 @@ snapshots: transitivePeerDependencies: - supports-color - '@ayco/astro-resume@0.4.2(astro@4.13.4(@types/node@22.3.0)(sass@1.77.8)(typescript@5.5.4))': + '@astrojs/yaml2ts@0.2.0': dependencies: - astro: 4.13.4(@types/node@22.3.0)(sass@1.77.8)(typescript@5.5.4) + yaml: 2.5.0 - '@ayco/astro-sw@0.1.1': {} + '@ayco/astro-resume@0.4.2(astro@4.14.1(@types/node@22.3.0)(rollup@4.20.0)(sass@1.77.8)(typescript@5.5.4))': + dependencies: + astro: 4.14.1(@types/node@22.3.0)(rollup@4.20.0)(sass@1.77.8)(typescript@5.5.4) + + '@ayco/astro-sw@0.2.2': {} '@babel/code-frame@7.24.7': dependencies: @@ -3394,6 +3481,14 @@ snapshots: '@pkgjs/parseargs@0.11.0': optional: true + '@rollup/pluginutils@5.1.0(rollup@4.20.0)': + dependencies: + '@types/estree': 1.0.5 + estree-walker: 2.0.2 + picomatch: 2.3.1 + optionalDependencies: + rollup: 4.20.0 + '@rollup/rollup-android-arm-eabi@4.20.0': optional: true @@ -3487,11 +3582,11 @@ snapshots: '@types/hast@3.0.4': dependencies: - '@types/unist': 3.0.2 + '@types/unist': 3.0.3 '@types/mdast@4.0.4': dependencies: - '@types/unist': 3.0.2 + '@types/unist': 3.0.3 '@types/mdx@2.0.13': {} @@ -3499,7 +3594,7 @@ snapshots: '@types/nlcst@2.0.3': dependencies: - '@types/unist': 3.0.2 + '@types/unist': 3.0.3 '@types/node@17.0.45': {} @@ -3516,9 +3611,9 @@ snapshots: '@types/node': 22.3.0 minipass: 4.2.8 - '@types/unist@2.0.10': {} + '@types/unist@2.0.11': {} - '@types/unist@3.0.2': {} + '@types/unist@3.0.3': {} '@types/yauzl@2.10.3': dependencies: @@ -3659,7 +3754,7 @@ snapshots: - debug - supports-color - astro@4.13.4(@types/node@22.3.0)(sass@1.77.8)(typescript@5.5.4): + astro@4.14.1(@types/node@22.3.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 @@ -3672,6 +3767,7 @@ snapshots: '@babel/traverse': 7.25.3 '@babel/types': 7.25.2 '@oslojs/encoding': 0.4.1 + '@rollup/pluginutils': 5.1.0(rollup@4.20.0) '@types/babel__core': 7.20.5 '@types/cookie': 0.6.0 acorn: 8.12.1 @@ -3702,7 +3798,9 @@ snapshots: js-yaml: 4.1.0 kleur: 4.1.5 magic-string: 0.30.11 + micromatch: 4.0.7 mrmime: 2.0.0 + neotraverse: 0.6.18 ora: 8.0.1 p-limit: 6.1.0 p-queue: 8.0.1 @@ -3717,18 +3815,20 @@ snapshots: tsconfck: 3.1.1(typescript@5.5.4) unist-util-visit: 5.0.0 vfile: 6.0.2 - vite: 5.4.0(@types/node@22.3.0)(sass@1.77.8) - vitefu: 0.2.5(vite@5.4.0(@types/node@22.3.0)(sass@1.77.8)) + 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)) which-pm: 3.0.0 - yargs-parser: 21.1.1 + xxhash-wasm: 1.0.2 zod: 3.23.8 zod-to-json-schema: 3.23.2(zod@3.23.8) + zod-to-ts: 1.2.0(typescript@5.5.4)(zod@3.23.8) optionalDependencies: sharp: 0.33.4 transitivePeerDependencies: - '@types/node' - less - lightningcss + - rollup - sass - sass-embedded - stylus @@ -3792,7 +3892,7 @@ snapshots: browserslist@4.23.3: dependencies: caniuse-lite: 1.0.30001651 - electron-to-chromium: 1.5.7 + electron-to-chromium: 1.5.8 node-releases: 2.0.18 update-browserslist-db: 1.1.0(browserslist@4.23.3) @@ -4031,7 +4131,7 @@ snapshots: ee-first@1.1.1: {} - electron-to-chromium@1.5.7: {} + electron-to-chromium@1.5.8: {} emmet@2.4.7: dependencies: @@ -4119,7 +4219,9 @@ snapshots: estree-util-visit@2.0.0: dependencies: '@types/estree-jsx': 1.0.5 - '@types/unist': 3.0.2 + '@types/unist': 3.0.3 + + estree-walker@2.0.2: {} estree-walker@3.0.3: dependencies: @@ -4356,7 +4458,7 @@ snapshots: hast-util-from-parse5@8.0.1: dependencies: '@types/hast': 3.0.4 - '@types/unist': 3.0.2 + '@types/unist': 3.0.3 devlop: 1.1.0 hastscript: 8.0.0 property-information: 6.5.0 @@ -4375,7 +4477,7 @@ snapshots: hast-util-raw@9.0.4: dependencies: '@types/hast': 3.0.4 - '@types/unist': 3.0.2 + '@types/unist': 3.0.3 '@ungap/structured-clone': 1.2.0 hast-util-from-parse5: 8.0.1 hast-util-to-parse5: 8.0.0 @@ -4412,7 +4514,7 @@ snapshots: hast-util-to-html@9.0.1: dependencies: '@types/hast': 3.0.4 - '@types/unist': 3.0.2 + '@types/unist': 3.0.3 ccount: 2.0.1 comma-separated-tokens: 2.0.3 hast-util-raw: 9.0.4 @@ -4428,7 +4530,7 @@ snapshots: dependencies: '@types/estree': 1.0.5 '@types/hast': 3.0.4 - '@types/unist': 3.0.2 + '@types/unist': 3.0.3 comma-separated-tokens: 2.0.3 devlop: 1.1.0 estree-util-is-identifier-name: 3.0.0 @@ -4457,7 +4559,7 @@ snapshots: hast-util-to-text@4.0.2: dependencies: '@types/hast': 3.0.4 - '@types/unist': 3.0.2 + '@types/unist': 3.0.3 hast-util-is-element: 3.0.0 unist-util-find-after: 5.0.0 @@ -4612,6 +4714,8 @@ snapshots: jsonc-parser@2.3.1: {} + jsonc-parser@3.3.1: {} + kind-of@6.0.3: {} kleur@3.0.3: {} @@ -4654,6 +4758,8 @@ snapshots: dependencies: p-locate: 5.0.0 + lodash@4.17.21: {} + log-symbols@6.0.0: dependencies: chalk: 5.3.0 @@ -4678,7 +4784,7 @@ snapshots: mdast-util-definitions@6.0.0: dependencies: '@types/mdast': 4.0.4 - '@types/unist': 3.0.2 + '@types/unist': 3.0.3 unist-util-visit: 5.0.0 mdast-util-find-and-replace@3.0.1: @@ -4691,7 +4797,7 @@ snapshots: mdast-util-from-markdown@2.0.1: dependencies: '@types/mdast': 4.0.4 - '@types/unist': 3.0.2 + '@types/unist': 3.0.3 decode-named-character-reference: 1.0.2 devlop: 1.1.0 mdast-util-to-string: 4.0.0 @@ -4778,7 +4884,7 @@ snapshots: '@types/estree-jsx': 1.0.5 '@types/hast': 3.0.4 '@types/mdast': 4.0.4 - '@types/unist': 3.0.2 + '@types/unist': 3.0.3 ccount: 2.0.1 devlop: 1.1.0 mdast-util-from-markdown: 2.0.1 @@ -4832,7 +4938,7 @@ snapshots: mdast-util-to-markdown@2.1.0: dependencies: '@types/mdast': 4.0.4 - '@types/unist': 3.0.2 + '@types/unist': 3.0.3 longest-streak: 3.1.0 mdast-util-phrasing: 4.1.0 mdast-util-to-string: 4.0.0 @@ -5060,7 +5166,7 @@ snapshots: dependencies: '@types/acorn': 4.0.6 '@types/estree': 1.0.5 - '@types/unist': 3.0.2 + '@types/unist': 3.0.3 devlop: 1.1.0 estree-util-visit: 2.0.0 micromark-util-symbol: 2.0.0 @@ -5175,6 +5281,8 @@ snapshots: nanoid@3.3.7: {} + neotraverse@0.6.18: {} + nlcst-to-string@4.0.0: dependencies: '@types/nlcst': 2.0.3 @@ -5270,7 +5378,7 @@ snapshots: parse-entities@4.0.1: dependencies: - '@types/unist': 2.0.10 + '@types/unist': 2.0.11 character-entities: 2.0.2 character-entities-legacy: 3.0.0 character-reference-invalid: 2.0.1 @@ -5282,7 +5390,7 @@ snapshots: parse-latin@7.0.0: dependencies: '@types/nlcst': 2.0.3 - '@types/unist': 3.0.2 + '@types/unist': 3.0.3 nlcst-to-string: 4.0.0 unist-util-modify-children: 4.0.0 unist-util-visit-children: 3.0.0 @@ -5377,6 +5485,9 @@ snapshots: find-yarn-workspace-root2: 1.2.16 which-pm: 3.0.0 + prettier@2.8.7: + optional: true + prismjs@1.29.0: {} process-warning@3.0.0: {} @@ -5497,6 +5608,8 @@ snapshots: mdast-util-to-markdown: 2.1.0 unified: 11.0.5 + request-light@0.5.8: {} + request-light@0.7.0: {} require-directory@2.1.1: {} @@ -5834,7 +5947,7 @@ snapshots: unified@11.0.5: dependencies: - '@types/unist': 3.0.2 + '@types/unist': 3.0.3 bail: 2.0.2 devlop: 1.1.0 extend: 3.0.2 @@ -5844,47 +5957,47 @@ snapshots: unist-util-find-after@5.0.0: dependencies: - '@types/unist': 3.0.2 + '@types/unist': 3.0.3 unist-util-is: 6.0.0 unist-util-is@6.0.0: dependencies: - '@types/unist': 3.0.2 + '@types/unist': 3.0.3 unist-util-modify-children@4.0.0: dependencies: - '@types/unist': 3.0.2 + '@types/unist': 3.0.3 array-iterate: 2.0.1 unist-util-position-from-estree@2.0.0: dependencies: - '@types/unist': 3.0.2 + '@types/unist': 3.0.3 unist-util-position@5.0.0: dependencies: - '@types/unist': 3.0.2 + '@types/unist': 3.0.3 unist-util-remove-position@5.0.0: dependencies: - '@types/unist': 3.0.2 + '@types/unist': 3.0.3 unist-util-visit: 5.0.0 unist-util-stringify-position@4.0.0: dependencies: - '@types/unist': 3.0.2 + '@types/unist': 3.0.3 unist-util-visit-children@3.0.0: dependencies: - '@types/unist': 3.0.2 + '@types/unist': 3.0.3 unist-util-visit-parents@6.0.1: dependencies: - '@types/unist': 3.0.2 + '@types/unist': 3.0.3 unist-util-is: 6.0.0 unist-util-visit@5.0.0: dependencies: - '@types/unist': 3.0.2 + '@types/unist': 3.0.3 unist-util-is: 6.0.0 unist-util-visit-parents: 6.0.1 @@ -5896,21 +6009,21 @@ snapshots: vfile-location@5.0.3: dependencies: - '@types/unist': 3.0.2 + '@types/unist': 3.0.3 vfile: 6.0.2 vfile-message@4.0.2: dependencies: - '@types/unist': 3.0.2 + '@types/unist': 3.0.3 unist-util-stringify-position: 4.0.0 vfile@6.0.2: dependencies: - '@types/unist': 3.0.2 + '@types/unist': 3.0.3 unist-util-stringify-position: 4.0.0 vfile-message: 4.0.2 - vite@5.4.0(@types/node@22.3.0)(sass@1.77.8): + vite@5.4.1(@types/node@22.3.0)(sass@1.77.8): dependencies: esbuild: 0.21.5 postcss: 8.4.41 @@ -5920,9 +6033,9 @@ snapshots: fsevents: 2.3.3 sass: 1.77.8 - vitefu@0.2.5(vite@5.4.0(@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)): optionalDependencies: - vite: 5.4.0(@types/node@22.3.0)(sass@1.77.8) + vite: 5.4.1(@types/node@22.3.0)(sass@1.77.8) volar-service-css@0.0.59(@volar/language-service@2.4.0-alpha.18): dependencies: @@ -5972,6 +6085,13 @@ snapshots: optionalDependencies: '@volar/language-service': 2.4.0-alpha.18 + volar-service-yaml@0.0.59(@volar/language-service@2.4.0-alpha.18): + dependencies: + vscode-uri: 3.0.8 + yaml-language-server: 1.15.0 + optionalDependencies: + '@volar/language-service': 2.4.0-alpha.18 + vscode-css-languageservice@6.3.0: dependencies: '@vscode/l10n': 0.0.18 @@ -5986,8 +6106,23 @@ snapshots: vscode-languageserver-types: 3.17.5 vscode-uri: 3.0.8 + vscode-json-languageservice@4.1.8: + dependencies: + jsonc-parser: 3.3.1 + vscode-languageserver-textdocument: 1.0.12 + vscode-languageserver-types: 3.17.5 + vscode-nls: 5.2.0 + vscode-uri: 3.0.8 + + vscode-jsonrpc@6.0.0: {} + vscode-jsonrpc@8.2.0: {} + vscode-languageserver-protocol@3.16.0: + dependencies: + vscode-jsonrpc: 6.0.0 + vscode-languageserver-types: 3.16.0 + vscode-languageserver-protocol@3.17.5: dependencies: vscode-jsonrpc: 8.2.0 @@ -5995,8 +6130,14 @@ snapshots: vscode-languageserver-textdocument@1.0.12: {} + vscode-languageserver-types@3.16.0: {} + vscode-languageserver-types@3.17.5: {} + vscode-languageserver@7.0.0: + dependencies: + vscode-languageserver-protocol: 3.16.0 + vscode-languageserver@9.0.1: dependencies: vscode-languageserver-protocol: 3.17.5 @@ -6052,12 +6193,33 @@ snapshots: wrappy@1.0.2: {} + xxhash-wasm@1.0.2: {} + y18n@5.0.8: {} yallist@3.1.1: {} yallist@4.0.0: {} + yaml-language-server@1.15.0: + dependencies: + ajv: 8.17.1 + lodash: 4.17.21 + request-light: 0.5.8 + vscode-json-languageservice: 4.1.8 + vscode-languageserver: 7.0.0 + vscode-languageserver-textdocument: 1.0.12 + vscode-languageserver-types: 3.17.5 + vscode-nls: 5.2.0 + vscode-uri: 3.0.8 + yaml: 2.2.2 + optionalDependencies: + prettier: 2.8.7 + + yaml@2.2.2: {} + + yaml@2.5.0: {} + yargs-parser@21.1.1: {} yargs@17.7.2: @@ -6083,6 +6245,11 @@ snapshots: dependencies: zod: 3.23.8 + zod-to-ts@1.2.0(typescript@5.5.4)(zod@3.23.8): + dependencies: + typescript: 5.5.4 + zod: 3.23.8 + zod@3.23.8: {} zwitch@2.0.4: {} diff --git a/src/consts.ts b/src/consts.ts index b1ea6b2..a49563c 100644 --- a/src/consts.ts +++ b/src/consts.ts @@ -4,4 +4,4 @@ export const SITE_AUTHOR_MASTODON = 'https://social.ayco.io/@ayo'; export const SITE_PROJECT_REPO = 'https://github.com/ayoayco/Cozy'; export const SITE_DESCRIPTION = 'The Web is Yours.'; -export const VERSION = 'Outrageous-Otter'; +export const VERSION = 'Purple-Pizza'; diff --git a/src/sw.js b/src/sw.js index a86d9f7..19a10fe 100644 --- a/src/sw.js +++ b/src/sw.js @@ -24,54 +24,50 @@ const putInCache = async (request, response) => { await cache.put(request, response); }; -const tryCache = async (request, fallbackUrl) => { + +const cacheAndRevalidate = async ({ request, preloadResponsePromise, fallbackUrl }) => { + const cache = await caches.open(cacheName); // Try get the resource from the cache const responseFromCache = await cache.match(request); - if (responseFromCache) { - console.info('[cozy-sw]: using cached response', responseFromCache.url); - - try { - // get network response for revalidation of stale assets - const responseFromNetwork = await fetch(request.clone()); - if (responseFromNetwork) { - console.info('[cozy-sw]: fetched updated assets', responseFromNetwork.url); - putInCache(request, responseFromNetwork.clone()); - } - } catch(error) { - console.info('[cozy-sw]: failed to fetch updated assets', request.url); + try { + // get network response for revalidation of stale assets + const responseFromNetwork = await fetch(request.clone()); + if (responseFromNetwork) { + console.info('[cozy-sw]: fetched updated assets', responseFromNetwork.url); + putInCache(request, responseFromNetwork.clone()); } - return responseFromCache; + if (responseFromCache) { + console.info('[cozy-sw]: using cached response', responseFromCache.url); + return responseFromCache; + } else{ + console.info('[cozy-sw]: using network response', responseFromNetwork.url); + return responseFromNetwork; + } + } catch(error) { + console.info('[cozy-sw]: failed to fetch updated assets', request.url); + if (responseFromCache) { + console.info('[cozy-sw]: using cached response', responseFromCache.url); + return responseFromCache; + } } - // Try the fallback - const fallbackResponse = await cache.match(fallbackUrl); - if (fallbackResponse) { - console.info('[cozy-sw]: using fallback cached response', fallbackResponse.url); - return fallbackResponse; + // Try to use the preloaded response, if it's there + // NOTE: Chrome throws errors regarding preloadResponse, see: + // https://bugs.chromium.org/p/chromium/issues/detail?id=1420515 + // https://github.com/mdn/dom-examples/issues/145 + // To avoid those errors, remove or comment out this block of preloadResponse + // code along with enableNavigationPreload() and the "activate" listener. + const preloadResponse = await preloadResponsePromise; + if (preloadResponse) { + putInCache(request, preloadResponse.clone()); + console.info('[cozy-sw]: using preload response', preloadResponse.url); + return preloadResponse; } -} - -const cacheAndRevalidate = async ({ request, preloadResponsePromise, fallbackUrl }) => { - - return tryCache(request, fallbackUrl); try { - // Try to use the preloaded response, if it's there - // NOTE: Chrome throws errors regarding preloadResponse, see: - // https://bugs.chromium.org/p/chromium/issues/detail?id=1420515 - // https://github.com/mdn/dom-examples/issues/145 - // To avoid those errors, remove or comment out this block of preloadResponse - // code along with enableNavigationPreload() and the "activate" listener. - const preloadResponse = await preloadResponsePromise; - if (preloadResponse) { - console.info('[cozy-sw]: using preload response', preloadResponse.url); - putInCache(request, preloadResponse.clone()); - return preloadResponse; - } - // Try to get the resource from the network for 5 seconds const responseFromNetwork = await fetch(request.clone(), {signal: AbortSignal.timeout(5000)}); // response may be used only once @@ -83,12 +79,17 @@ const cacheAndRevalidate = async ({ request, preloadResponsePromise, fallbackUrl } catch (error) { - return tryCache(request, fallbackUrl) + // Try the fallback + const fallbackResponse = await cache.match(fallbackUrl); + if (fallbackResponse) { + console.info('[cozy-sw]: using fallback cached response', fallbackResponse.url); + return fallbackResponse; + } // when even the fallback response is not available, // there is nothing we can do, but we must always // return a Response object - ?? new Response('Network error happened', { + return new Response('Network error happened', { status: 408, headers: { 'Content-Type': 'text/plain' }, }); @@ -111,7 +112,6 @@ self.addEventListener('install', (event) => { console.log('[cozy-sw]: installing...', event) event.waitUntil( addResourcesToCache([ - './', ...(__assets ?? []) ]) );