@pasquelin/map3d-plugin-windy 0.1.0

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/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Alban Pasquelin
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md ADDED
@@ -0,0 +1,71 @@
1
+ # @pasquelin/map3d-plugin-windy
2
+
3
+ Webcams publiques **réelles** autour de la vue — voie « markers » du contrat plugin
4
+ (`data.fetch`), zéro enrichissement, zéro couche 3D custom. Interroge la
5
+ [Windy Webcams API v3](https://api.windy.com/webcams/api/v3/webcams) (bbox de la vue courante,
6
+ clé API en header `x-windy-api-key`) et pose un marker `webcam` par résultat, avec une vignette
7
+ en avatar, une infobulle (aperçu + localisation) et un menu (ouvrir / copier le lien).
8
+
9
+ ## Usage
10
+
11
+ ```tsx
12
+ import { Map } from '@pasquelin/map3d'
13
+ import { windyWebcams } from '@pasquelin/map3d-plugin-windy'
14
+
15
+ <Map plugins={[windyWebcams({ apiKey: import.meta.env.VITE_WINDY_API_KEY })]} />
16
+ ```
17
+
18
+ Le plugin est **désactivé par défaut** (`enabledByDefault: false`) : l'utilisateur l'active
19
+ depuis le hub des plugins (menu Réglages). `init.apiKey` ne fait que **seeder** le défaut du champ
20
+ `apiKey` — modifiable ensuite depuis le hub (champ `secret`, jamais affiché en clair).
21
+
22
+ ## Clé API — sécurité
23
+
24
+ La clé n'est **jamais** committée. Elle vit uniquement dans `example/.env` (gitignoré) :
25
+
26
+ ```
27
+ VITE_WINDY_API_KEY=...
28
+ ```
29
+
30
+ `example/.env.example` documente la variable sans valeur réelle.
31
+
32
+ ## Configuration
33
+
34
+ | Clé | Type | Défaut | Refetch | Description |
35
+ |---|---|---|---|---|
36
+ | `apiKey` | `string` (secret) | `''` (seedé par `init.apiKey`) | oui | Clé API Windy Webcams (header `x-windy-api-key`). |
37
+ | `category` | `string` | `''` | oui | Filtre `categories` de l'API ; vide ou `'all'` = pas de filtre. |
38
+ | `maxWebcams` | `number` (1–100) | `50` | oui | Nombre max de webcams demandées (`limit`). |
39
+ | `thumbnailSize` | `select` (`thumbnail`/`preview`/`daylight`) | `'preview'` | non | Taille d'image utilisée pour l'avatar et la vignette d'infobulle. |
40
+
41
+ ## Déviation assumée : `refreshMinutes`
42
+
43
+ Le spec métier prévoyait un `refreshMinutes` pour un polling périodique. `data.refresh` est un
44
+ champ **statique** du plugin (évalué une fois, il ne peut pas relire la config au runtime) — il
45
+ ne peut donc pas être piloté par un réglage utilisateur. Dropé en v1 : les webcams se
46
+ rafraîchissent au déplacement de la vue (`refresh: 'viewport'`). Un polling réglable est un
47
+ suivi possible côté map3D (champ `data.refresh` dynamique), pas une limitation de ce plugin.
48
+
49
+ ## Détail technique
50
+
51
+ - `src/config.ts` : `WindyConfig` — écrit à la main (pas dérivé du schéma) car `apiKey` est
52
+ seedé au runtime et `thumbnailSize` doit rester une union littérale.
53
+ - `src/api.ts` : pur, testable, zéro JSX — `buildWebcamsUrl` (bbox `north,east,south,west`,
54
+ `limit`, `include`, `categories` optionnel), `thumbUrl`, `mapWebcams` (élague les webcams sans
55
+ coordonnées numériques).
56
+ - `src/marker.tsx` : `webcamTooltip` (vignette + titre + lieu) et `webcamMenu` (ouvrir / copier
57
+ le lien, inertes sans `detail`).
58
+ - `src/index.ts` : `windyWebcams()` — assemble `meta`, `config`, `data.fetch` (avec
59
+ `x-windy-api-key` en header) et `markerLayer`.
60
+ - `src/fixtures/webcams.json` : capture réelle de 4 webcams parisiennes, utilisée par
61
+ `src/api.test.ts` (aucune clé dedans).
62
+
63
+ ## Exemple
64
+
65
+ ```bash
66
+ pnpm --filter @pasquelin/map3d-plugin-windy-example dev
67
+ ```
68
+
69
+ Nécessite `VITE_WINDY_API_KEY` (fichier `.env` du package `example/`, gitignoré) pour de vraies
70
+ webcams, et `VITE_CESIUM_ION_TOKEN` pour de vrais bâtiments 3D (sinon repli sur le globe
71
+ ellipsoïde). Active le plugin depuis le hub des plugins puis navigue sur la carte.
package/dist/api.d.ts ADDED
@@ -0,0 +1,41 @@
1
+ import { Bounds, MarkerData } from '@pasquelin/map3d';
2
+ import { WindyConfig } from './config';
3
+ import { WindyMarkerData } from './marker';
4
+ export type WindyImage = {
5
+ icon: string;
6
+ thumbnail: string;
7
+ preview: string;
8
+ };
9
+ export type WindyWebcam = {
10
+ webcamId: number;
11
+ title: string;
12
+ status: string;
13
+ images?: {
14
+ current?: WindyImage;
15
+ daylight?: WindyImage;
16
+ };
17
+ location?: {
18
+ latitude: number;
19
+ longitude: number;
20
+ city?: string;
21
+ region?: string;
22
+ country?: string;
23
+ };
24
+ urls?: {
25
+ detail?: string;
26
+ provider?: string;
27
+ };
28
+ };
29
+ export type WindyResponse = {
30
+ total: number;
31
+ webcams: WindyWebcam[];
32
+ };
33
+ /** URL Windy Webcams API v3 : bbox `north,east,south,west` (ordre vérifié), clé en query absente (header). */
34
+ export declare function buildWebcamsUrl(input: {
35
+ bounds: Bounds;
36
+ config: WindyConfig;
37
+ }): string;
38
+ /** Vignette selon la taille choisie ; `daylight` retombe sur `current` si absente (webcam sans variante jour). */
39
+ export declare function thumbUrl(w: WindyWebcam, size: WindyConfig['thumbnailSize']): string | undefined;
40
+ /** Projette la réponse Windy en markers — élague les webcams sans coordonnées exploitables. */
41
+ export declare function mapWebcams(res: WindyResponse, config: WindyConfig): MarkerData<WindyMarkerData>[];
@@ -0,0 +1,6 @@
1
+ export type WindyConfig = {
2
+ apiKey: string;
3
+ category: string;
4
+ maxWebcams: number;
5
+ thumbnailSize: 'thumbnail' | 'preview' | 'daylight';
6
+ };