From ab3882c2f1465b5b7d5838e6a9a58411c08d8377 Mon Sep 17 00:00:00 2001 From: Zhongwei Li Date: Sun, 30 Nov 2025 08:27:26 +0800 Subject: [PATCH] Initial commit --- .claude-plugin/plugin.json | 12 ++++ README.md | 3 + plugin.lock.json | 45 ++++++++++++++ skills/pwa-service-worker/SKILL.md | 94 ++++++++++++++++++++++++++++++ 4 files changed, 154 insertions(+) create mode 100644 .claude-plugin/plugin.json create mode 100644 README.md create mode 100644 plugin.lock.json create mode 100644 skills/pwa-service-worker/SKILL.md diff --git a/.claude-plugin/plugin.json b/.claude-plugin/plugin.json new file mode 100644 index 0000000..5f3e95e --- /dev/null +++ b/.claude-plugin/plugin.json @@ -0,0 +1,12 @@ +{ + "name": "leapmultix-skill-pwa-service-worker", + "description": "Skill pwa-service-worker from LeapMultix", + "version": "1.0.0", + "author": { + "name": "Julien LE SAUX", + "email": "contact@jls42.org" + }, + "skills": [ + "./skills" + ] +} \ No newline at end of file diff --git a/README.md b/README.md new file mode 100644 index 0000000..b762612 --- /dev/null +++ b/README.md @@ -0,0 +1,3 @@ +# leapmultix-skill-pwa-service-worker + +Skill pwa-service-worker from LeapMultix diff --git a/plugin.lock.json b/plugin.lock.json new file mode 100644 index 0000000..46e906f --- /dev/null +++ b/plugin.lock.json @@ -0,0 +1,45 @@ +{ + "$schema": "internal://schemas/plugin.lock.v1.json", + "pluginId": "gh:jls42/leapmultix:leapmultix-marketplace/skills/pwa-service-worker", + "normalized": { + "repo": null, + "ref": "refs/tags/v20251128.0", + "commit": "01b6b4d42303daa869f4418097eb494157c0a822", + "treeHash": "cc5dfca11a29e793f594f01f60e7420e71aa8dd0764cdee6e7bfbf0ee416d16d", + "generatedAt": "2025-11-28T10:19:14.340018Z", + "toolVersion": "publish_plugins.py@0.2.0" + }, + "origin": { + "remote": "git@github.com:zhongweili/42plugin-data.git", + "branch": "master", + "commit": "aa1497ed0949fd50e99e70d6324a29c5b34f9390", + "repoRoot": "/Users/zhongweili/projects/openmind/42plugin-data" + }, + "manifest": { + "name": "leapmultix-skill-pwa-service-worker", + "description": "Skill pwa-service-worker from LeapMultix", + "version": "1.0.0" + }, + "content": { + "files": [ + { + "path": "README.md", + "sha256": "b339a7191ff5c4e4526d25403ee170ee1bb1c810af9122f4ae94debee9a726fe" + }, + { + "path": ".claude-plugin/plugin.json", + "sha256": "d93b5851b0fae45eda0e45b3ace2bdf3dad33066b32c8f0b39e908754ebfa2be" + }, + { + "path": "skills/pwa-service-worker/SKILL.md", + "sha256": "4756ee8cbe4e310653218976ae893c38ecd2357e335c21c32e2f4d2b21a59a3b" + } + ], + "dirSha256": "cc5dfca11a29e793f594f01f60e7420e71aa8dd0764cdee6e7bfbf0ee416d16d" + }, + "security": { + "scannedAt": null, + "scannerVersion": null, + "flags": [] + } +} \ No newline at end of file diff --git a/skills/pwa-service-worker/SKILL.md b/skills/pwa-service-worker/SKILL.md new file mode 100644 index 0000000..f025855 --- /dev/null +++ b/skills/pwa-service-worker/SKILL.md @@ -0,0 +1,94 @@ +--- +name: managing-pwa-service-worker +description: Manages Service Worker updates securely with cache versioning and offline tests. Use when modifying SW, adding resources, or changing cache strategy +allowed-tools: Read, Write, Grep, Glob, Bash +--- + +# PWA Service Worker Manager + +Gère Service Worker pour offline play et cache versioning sécurisé. + +## Quand utiliser + +- Modification Service Worker +- Ajout ressources à cacher +- Changement stratégie cache +- Tests offline +- Correction bugs SW + +## Scripts essentiels + +```bash +npm run test:pwa-offline # Tester offline (PRINCIPAL) +npm run sw:disable # Désactiver SW +npm run sw:fix # Réparer SW +``` + +## Versioning et workflow + +**SemVer (voir sw.js) :** + +- Major : Changements cassants +- Minor : Ressources ajoutées +- Patch : Corrections + +**Workflow :** + +1. **Modifier :** sw.js (version, ressources, handlers) +2. **Incrémenter :** Version (SemVer) +3. **Tester :** `npm run test:pwa-offline` +4. **Vérifier :** DevTools App tab (Offline mode) +5. **Quality :** format:check, lint, test + +## Stratégies de cache + +- **Cache First :** Assets (HTML, CSS, JS, images) +- **Network First :** APIs (données fraîches) +- **Cache Only :** Assets immuables +- **Network Only :** Analytics, auth + +Trouve stratégie dans sw.js existant. + +## Événements SW clés + +- **Install :** Créer cache, skipWaiting() +- **Activate :** Nettoyer anciens caches, clients.claim() +- **Fetch :** Appliquer stratégie, gérer erreurs + +## Debugging + +**Chrome DevTools (F12) → Application → Service Workers :** + +- Offline mode → Tester navigation +- caches.keys() en console → Vérifier caches + +**Problèmes courants :** + +- SW ne s'update → Incrémenter version, skipWaiting() présent +- Ressources manquantes → Ajouter à liste cache +- Cache volumineux → Cacher uniquement ressources critiques + +## Checklist + +- [ ] Version incrémentée (SemVer) +- [ ] skipWaiting() + clients.claim() présents +- [ ] Nettoyage anciens caches +- [ ] Offline test OK (`npm run test:pwa-offline`) +- [ ] DevTools Offline mode OK +- [ ] format:check, lint, test passent + +## En cas de doute + +**Règles absolues :** + +1. Incrémenter version TOUJOURS +2. Tester offline AVANT commit +3. DevTools Application tab verification +4. `npm run test:pwa-offline` doit passer +5. skipWaiting() + clients.claim() essentiels + +**Références :** + +- `sw.js` - Service Worker principal +- `manifest.json` - PWA manifest +- Chrome DevTools Application tab