weather-i18n 1.0.1 → 1.2.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/README.md +13 -9
- package/dist/wmo_4677/data/icons/material-weather-icons.json +114 -0
- package/dist/wmo_4677/data/icons/meteocons.json +114 -0
- package/dist/wmo_4677/data/icons/openmeteo.json +56 -56
- package/dist/wmo_4677/icons/index.d.ts +2 -0
- package/dist/wmo_4677/icons/index.js +2 -0
- package/dist/wmo_4677/icons/material-weather-icons.d.ts +7 -0
- package/dist/wmo_4677/icons/material-weather-icons.js +12 -0
- package/dist/wmo_4677/icons/meteocons.d.ts +11 -0
- package/dist/wmo_4677/icons/meteocons.js +15 -0
- package/dist/wmo_4677/icons/openmeteo.d.ts +6 -1
- package/dist/wmo_4677/icons/openmeteo.js +8 -2
- package/dist/wmo_4677/index.d.ts +1 -0
- package/package.json +15 -5
package/README.md
CHANGED
|
@@ -7,7 +7,7 @@ A lightweight, fully typed TypeScript library for internationalizing, validating
|
|
|
7
7
|
- 🌐 **Internationalization (i18n)**: Translate WMO 4677 weather codes into multiple languages (`en`, `es`) with day/night phase support (`day` / `night`) and fallback language support.
|
|
8
8
|
- 📐 **Complete Specification**: Comprehensive definitions, human-readable keys (`key`), and reverse mappings for WMO 4677 weather codes.
|
|
9
9
|
- 🛡️ **Zod Validation**: Flexible schema to validate and transform numeric inputs (`95`), string values (`"95"`), or human-readable keys (`"thunderstorm_slight_moderate_no_hail"`).
|
|
10
|
-
- 🎨 **Icon Mapping**: Automatically map weather codes to popular icon packs such as
|
|
10
|
+
- 🎨 **Icon Mapping**: Automatically map weather codes to popular icon packs such as Meteocons, Material Weather Icons and Pixelarticons, with both day and night variants.
|
|
11
11
|
- 📦 **Tree-Shaking & Subpath Imports**: Import only what you need or access the raw JSON data directly.
|
|
12
12
|
|
|
13
13
|
## Installation
|
|
@@ -65,14 +65,18 @@ const result = WMO4677Validator.parse("05");
|
|
|
65
65
|
|
|
66
66
|
// Icons (All)
|
|
67
67
|
import WMO4677Icons from "weather-i18n/wmo_4677/icons";
|
|
68
|
-
console.log(WMO4677Icons.
|
|
68
|
+
console.log(WMO4677Icons.meteocons(95, "day"));
|
|
69
69
|
|
|
70
70
|
// Individual icon helpers
|
|
71
|
-
import
|
|
72
|
-
import
|
|
73
|
-
|
|
74
|
-
console.log(
|
|
75
|
-
|
|
71
|
+
import WMO4677Meteocons from "weather-i18n/wmo_4677/icons/meteocons";
|
|
72
|
+
import WMO4677MaterialWeatherIcons from "weather-i18n/wmo_4677/icons/material-weather-icons";
|
|
73
|
+
|
|
74
|
+
console.log(WMO4677Meteocons(95, "night", {
|
|
75
|
+
withUrlTemplate: true,
|
|
76
|
+
variant: "flat",
|
|
77
|
+
format: "svg-static"
|
|
78
|
+
}));
|
|
79
|
+
console.log(WMO4677MaterialWeatherIcons(95, "day"));
|
|
76
80
|
```
|
|
77
81
|
|
|
78
82
|
### 4. Direct JSON Imports
|
|
@@ -82,8 +86,8 @@ You can import the original JSON data files using Import Attributes (or assertio
|
|
|
82
86
|
```ts
|
|
83
87
|
import WMO4677I18nEN from "weather-i18n/wmo_4677/data/i18n/en.json" with { format: "json" };
|
|
84
88
|
import WMO4677I18nES from "weather-i18n/wmo_4677/data/i18n/es.json" with { format: "json" };
|
|
85
|
-
import
|
|
86
|
-
import
|
|
89
|
+
import WMO4677Meteocons from "weather-i18n/wmo_4677/data/icons/meteocons.json" with { format: "json" };
|
|
90
|
+
import WMO4677MaterialWeatherIcons from "weather-i18n/wmo_4677/data/icons/material-weather-icons.json" with { format: "json" };
|
|
87
91
|
```
|
|
88
92
|
|
|
89
93
|
*(Note: In Node.js v20+/v22+ and modern bundlers, `with { type: "json" }` is also supported.)*
|
|
@@ -0,0 +1,114 @@
|
|
|
1
|
+
{
|
|
2
|
+
"0": {
|
|
3
|
+
"day": "clear_day",
|
|
4
|
+
"night": "clear_night"
|
|
5
|
+
},
|
|
6
|
+
"1": {
|
|
7
|
+
"day": "clear_day",
|
|
8
|
+
"night": "clear_night"
|
|
9
|
+
},
|
|
10
|
+
"2": {
|
|
11
|
+
"day": "partly_cloudy_day",
|
|
12
|
+
"night": "partly_cloudy_night"
|
|
13
|
+
},
|
|
14
|
+
"3": {
|
|
15
|
+
"day": "cloudy_day_night",
|
|
16
|
+
"night": "cloudy_day_night"
|
|
17
|
+
},
|
|
18
|
+
"45": {
|
|
19
|
+
"day": "fog_day_night",
|
|
20
|
+
"night": "fog_day_night"
|
|
21
|
+
},
|
|
22
|
+
"48": {
|
|
23
|
+
"day": "fog_day_night",
|
|
24
|
+
"night": "fog_day_night"
|
|
25
|
+
},
|
|
26
|
+
"51": {
|
|
27
|
+
"day": "drizzle_day_night",
|
|
28
|
+
"night": "drizzle_day_night"
|
|
29
|
+
},
|
|
30
|
+
"53": {
|
|
31
|
+
"day": "drizzle_day_night",
|
|
32
|
+
"night": "drizzle_day_night"
|
|
33
|
+
},
|
|
34
|
+
"55": {
|
|
35
|
+
"day": "drizzle_day_night",
|
|
36
|
+
"night": "drizzle_day_night"
|
|
37
|
+
},
|
|
38
|
+
"56": {
|
|
39
|
+
"day": "sleet_day_night",
|
|
40
|
+
"night": "sleet_day_night"
|
|
41
|
+
},
|
|
42
|
+
"57": {
|
|
43
|
+
"day": "sleet_day_night",
|
|
44
|
+
"night": "sleet_day_night"
|
|
45
|
+
},
|
|
46
|
+
"61": {
|
|
47
|
+
"day": "rain_day_night",
|
|
48
|
+
"night": "rain_day_night"
|
|
49
|
+
},
|
|
50
|
+
"63": {
|
|
51
|
+
"day": "rain_day_night",
|
|
52
|
+
"night": "rain_day_night"
|
|
53
|
+
},
|
|
54
|
+
"65": {
|
|
55
|
+
"day": "rain_day_night",
|
|
56
|
+
"night": "rain_day_night"
|
|
57
|
+
},
|
|
58
|
+
"66": {
|
|
59
|
+
"day": "sleet_day_night",
|
|
60
|
+
"night": "sleet_day_night"
|
|
61
|
+
},
|
|
62
|
+
"67": {
|
|
63
|
+
"day": "sleet_day_night",
|
|
64
|
+
"night": "sleet_day_night"
|
|
65
|
+
},
|
|
66
|
+
"71": {
|
|
67
|
+
"day": "snow_day_night",
|
|
68
|
+
"night": "snow_day_night"
|
|
69
|
+
},
|
|
70
|
+
"73": {
|
|
71
|
+
"day": "snow_day_night",
|
|
72
|
+
"night": "snow_day_night"
|
|
73
|
+
},
|
|
74
|
+
"75": {
|
|
75
|
+
"day": "snow_day_night",
|
|
76
|
+
"night": "snow_day_night"
|
|
77
|
+
},
|
|
78
|
+
"77": {
|
|
79
|
+
"day": "sleet_day_night",
|
|
80
|
+
"night": "sleet_day_night"
|
|
81
|
+
},
|
|
82
|
+
"80": {
|
|
83
|
+
"day": "rain_day_night",
|
|
84
|
+
"night": "rain_day_night"
|
|
85
|
+
},
|
|
86
|
+
"81": {
|
|
87
|
+
"day": "rain_day_night",
|
|
88
|
+
"night": "rain_day_night"
|
|
89
|
+
},
|
|
90
|
+
"82": {
|
|
91
|
+
"day": "rain_day_night",
|
|
92
|
+
"night": "rain_day_night"
|
|
93
|
+
},
|
|
94
|
+
"85": {
|
|
95
|
+
"day": "snow_day_night",
|
|
96
|
+
"night": "snow_day_night"
|
|
97
|
+
},
|
|
98
|
+
"86": {
|
|
99
|
+
"day": "snow_day_night",
|
|
100
|
+
"night": "snow_day_night"
|
|
101
|
+
},
|
|
102
|
+
"95": {
|
|
103
|
+
"day": "thunderstorm_day_night",
|
|
104
|
+
"night": "thunderstorm_day_night"
|
|
105
|
+
},
|
|
106
|
+
"96": {
|
|
107
|
+
"day": "hail_day_night",
|
|
108
|
+
"night": "hail_day_night"
|
|
109
|
+
},
|
|
110
|
+
"99": {
|
|
111
|
+
"day": "hail_day_night",
|
|
112
|
+
"night": "hail_day_night"
|
|
113
|
+
}
|
|
114
|
+
}
|
|
@@ -0,0 +1,114 @@
|
|
|
1
|
+
{
|
|
2
|
+
"0": {
|
|
3
|
+
"day": "clear-day",
|
|
4
|
+
"night": "clear-night"
|
|
5
|
+
},
|
|
6
|
+
"1": {
|
|
7
|
+
"day": "clear-day",
|
|
8
|
+
"night": "clear-night"
|
|
9
|
+
},
|
|
10
|
+
"2": {
|
|
11
|
+
"day": "partly-cloudy-day",
|
|
12
|
+
"night": "partly-cloudy-night"
|
|
13
|
+
},
|
|
14
|
+
"3": {
|
|
15
|
+
"day": "cloudy",
|
|
16
|
+
"night": "cloudy"
|
|
17
|
+
},
|
|
18
|
+
"45": {
|
|
19
|
+
"day": "fog-day",
|
|
20
|
+
"night": "fog-night"
|
|
21
|
+
},
|
|
22
|
+
"48": {
|
|
23
|
+
"day": "haze-day",
|
|
24
|
+
"night": "haze-night"
|
|
25
|
+
},
|
|
26
|
+
"51": {
|
|
27
|
+
"day": "partly-cloudy-day-drizzle",
|
|
28
|
+
"night": "partly-cloudy-night-drizzle"
|
|
29
|
+
},
|
|
30
|
+
"53": {
|
|
31
|
+
"day": "drizzle",
|
|
32
|
+
"night": "drizzle"
|
|
33
|
+
},
|
|
34
|
+
"55": {
|
|
35
|
+
"day": "extreme-day-drizzle",
|
|
36
|
+
"night": "extreme-night-drizzle"
|
|
37
|
+
},
|
|
38
|
+
"56": {
|
|
39
|
+
"day": "overcast-drizzle",
|
|
40
|
+
"night": "overcast-drizzle"
|
|
41
|
+
},
|
|
42
|
+
"57": {
|
|
43
|
+
"day": "extreme-drizzle",
|
|
44
|
+
"night": "extreme-drizzle"
|
|
45
|
+
},
|
|
46
|
+
"61": {
|
|
47
|
+
"day": "partly-cloudy-day-rain",
|
|
48
|
+
"night": "partly-cloudy-night-rain"
|
|
49
|
+
},
|
|
50
|
+
"63": {
|
|
51
|
+
"day": "rain",
|
|
52
|
+
"night": "rain"
|
|
53
|
+
},
|
|
54
|
+
"65": {
|
|
55
|
+
"day": "extreme-day-rain",
|
|
56
|
+
"night": "extreme-night-rain"
|
|
57
|
+
},
|
|
58
|
+
"66": {
|
|
59
|
+
"day": "overcast-rain",
|
|
60
|
+
"night": "overcast-rain"
|
|
61
|
+
},
|
|
62
|
+
"67": {
|
|
63
|
+
"day": "extreme-rain",
|
|
64
|
+
"night": "extreme-rain"
|
|
65
|
+
},
|
|
66
|
+
"71": {
|
|
67
|
+
"day": "partly-cloudy-day-snow",
|
|
68
|
+
"night": "partly-cloudy-night-snow"
|
|
69
|
+
},
|
|
70
|
+
"73": {
|
|
71
|
+
"day": "snow",
|
|
72
|
+
"night": "snow"
|
|
73
|
+
},
|
|
74
|
+
"75": {
|
|
75
|
+
"day": "extreme-day-snow",
|
|
76
|
+
"night": "extreme-night-snow"
|
|
77
|
+
},
|
|
78
|
+
"77": {
|
|
79
|
+
"day": "extreme-snow",
|
|
80
|
+
"night": "extreme-snow"
|
|
81
|
+
},
|
|
82
|
+
"80": {
|
|
83
|
+
"day": "mostly-clear-day-rain",
|
|
84
|
+
"night": "mostly-clear-night-rain"
|
|
85
|
+
},
|
|
86
|
+
"81": {
|
|
87
|
+
"day": "mostly-clear-day-rain",
|
|
88
|
+
"night": "mostly-clear-night-rain"
|
|
89
|
+
},
|
|
90
|
+
"82": {
|
|
91
|
+
"day": "extreme-day-rain",
|
|
92
|
+
"night": "extreme-night-rain"
|
|
93
|
+
},
|
|
94
|
+
"85": {
|
|
95
|
+
"day": "mostly-clear-day-snow",
|
|
96
|
+
"night": "mostly-clear-night-snow"
|
|
97
|
+
},
|
|
98
|
+
"86": {
|
|
99
|
+
"day": "mostly-clear-day-snow",
|
|
100
|
+
"night": "mostly-clear-night-snow"
|
|
101
|
+
},
|
|
102
|
+
"95": {
|
|
103
|
+
"day": "thunderstorms-day",
|
|
104
|
+
"night": "thunderstorms-night"
|
|
105
|
+
},
|
|
106
|
+
"96": {
|
|
107
|
+
"day": "thunderstorms-day-hail",
|
|
108
|
+
"night": "thunderstorms-night-hail"
|
|
109
|
+
},
|
|
110
|
+
"99": {
|
|
111
|
+
"day": "thunderstorms-extreme-day-hail",
|
|
112
|
+
"night": "thunderstorms-extreme-night-hail"
|
|
113
|
+
}
|
|
114
|
+
}
|
|
@@ -1,114 +1,114 @@
|
|
|
1
1
|
{
|
|
2
2
|
"0": {
|
|
3
|
-
"day": "
|
|
4
|
-
"night": "
|
|
3
|
+
"day": "01d",
|
|
4
|
+
"night": "01n"
|
|
5
5
|
},
|
|
6
6
|
"1": {
|
|
7
|
-
"day": "
|
|
8
|
-
"night": "
|
|
7
|
+
"day": "01d",
|
|
8
|
+
"night": "01n"
|
|
9
9
|
},
|
|
10
10
|
"2": {
|
|
11
|
-
"day": "
|
|
12
|
-
"night": "
|
|
11
|
+
"day": "02d",
|
|
12
|
+
"night": "02n"
|
|
13
13
|
},
|
|
14
14
|
"3": {
|
|
15
|
-
"day": "
|
|
16
|
-
"night": "
|
|
15
|
+
"day": "03d",
|
|
16
|
+
"night": "03n"
|
|
17
17
|
},
|
|
18
18
|
"45": {
|
|
19
|
-
"day": "
|
|
20
|
-
"night": "
|
|
19
|
+
"day": "50d",
|
|
20
|
+
"night": "50n"
|
|
21
21
|
},
|
|
22
22
|
"48": {
|
|
23
|
-
"day": "
|
|
24
|
-
"night": "
|
|
23
|
+
"day": "50d",
|
|
24
|
+
"night": "50n"
|
|
25
25
|
},
|
|
26
26
|
"51": {
|
|
27
|
-
"day": "
|
|
28
|
-
"night": "
|
|
27
|
+
"day": "09d",
|
|
28
|
+
"night": "09n"
|
|
29
29
|
},
|
|
30
30
|
"53": {
|
|
31
|
-
"day": "
|
|
32
|
-
"night": "
|
|
31
|
+
"day": "09d",
|
|
32
|
+
"night": "09n"
|
|
33
33
|
},
|
|
34
34
|
"55": {
|
|
35
|
-
"day": "
|
|
36
|
-
"night": "
|
|
35
|
+
"day": "09d",
|
|
36
|
+
"night": "09n"
|
|
37
37
|
},
|
|
38
38
|
"56": {
|
|
39
|
-
"day": "
|
|
40
|
-
"night": "
|
|
39
|
+
"day": "09d",
|
|
40
|
+
"night": "09n"
|
|
41
41
|
},
|
|
42
42
|
"57": {
|
|
43
|
-
"day": "
|
|
44
|
-
"night": "
|
|
43
|
+
"day": "09d",
|
|
44
|
+
"night": "09n"
|
|
45
45
|
},
|
|
46
46
|
"61": {
|
|
47
|
-
"day": "
|
|
48
|
-
"night": "
|
|
47
|
+
"day": "10d",
|
|
48
|
+
"night": "10n"
|
|
49
49
|
},
|
|
50
50
|
"63": {
|
|
51
|
-
"day": "
|
|
52
|
-
"night": "
|
|
51
|
+
"day": "10d",
|
|
52
|
+
"night": "10n"
|
|
53
53
|
},
|
|
54
54
|
"65": {
|
|
55
|
-
"day": "
|
|
56
|
-
"night": "
|
|
55
|
+
"day": "10d",
|
|
56
|
+
"night": "10n"
|
|
57
57
|
},
|
|
58
58
|
"66": {
|
|
59
|
-
"day": "
|
|
60
|
-
"night": "
|
|
59
|
+
"day": "10d",
|
|
60
|
+
"night": "10n"
|
|
61
61
|
},
|
|
62
62
|
"67": {
|
|
63
|
-
"day": "
|
|
64
|
-
"night": "
|
|
63
|
+
"day": "10d",
|
|
64
|
+
"night": "10n"
|
|
65
65
|
},
|
|
66
66
|
"71": {
|
|
67
|
-
"day": "
|
|
68
|
-
"night": "
|
|
67
|
+
"day": "13d",
|
|
68
|
+
"night": "13n"
|
|
69
69
|
},
|
|
70
70
|
"73": {
|
|
71
|
-
"day": "
|
|
72
|
-
"night": "
|
|
71
|
+
"day": "13d",
|
|
72
|
+
"night": "13n"
|
|
73
73
|
},
|
|
74
74
|
"75": {
|
|
75
|
-
"day": "
|
|
76
|
-
"night": "
|
|
75
|
+
"day": "13d",
|
|
76
|
+
"night": "13n"
|
|
77
77
|
},
|
|
78
78
|
"77": {
|
|
79
|
-
"day": "
|
|
80
|
-
"night": "
|
|
79
|
+
"day": "13d",
|
|
80
|
+
"night": "13n"
|
|
81
81
|
},
|
|
82
82
|
"80": {
|
|
83
|
-
"day": "
|
|
84
|
-
"night": "
|
|
83
|
+
"day": "09d",
|
|
84
|
+
"night": "09n"
|
|
85
85
|
},
|
|
86
86
|
"81": {
|
|
87
|
-
"day": "
|
|
88
|
-
"night": "
|
|
87
|
+
"day": "09d",
|
|
88
|
+
"night": "09n"
|
|
89
89
|
},
|
|
90
90
|
"82": {
|
|
91
|
-
"day": "
|
|
92
|
-
"night": "
|
|
91
|
+
"day": "09d",
|
|
92
|
+
"night": "09n"
|
|
93
93
|
},
|
|
94
94
|
"85": {
|
|
95
|
-
"day": "
|
|
96
|
-
"night": "
|
|
95
|
+
"day": "13d",
|
|
96
|
+
"night": "13n"
|
|
97
97
|
},
|
|
98
98
|
"86": {
|
|
99
|
-
"day": "
|
|
100
|
-
"night": "
|
|
99
|
+
"day": "13d",
|
|
100
|
+
"night": "13n"
|
|
101
101
|
},
|
|
102
102
|
"95": {
|
|
103
|
-
"day": "
|
|
104
|
-
"night": "
|
|
103
|
+
"day": "11d",
|
|
104
|
+
"night": "11n"
|
|
105
105
|
},
|
|
106
106
|
"96": {
|
|
107
|
-
"day": "
|
|
108
|
-
"night": "
|
|
107
|
+
"day": "11d",
|
|
108
|
+
"night": "11n"
|
|
109
109
|
},
|
|
110
110
|
"99": {
|
|
111
|
-
"day": "
|
|
112
|
-
"night": "
|
|
111
|
+
"day": "11d",
|
|
112
|
+
"night": "11n"
|
|
113
113
|
}
|
|
114
114
|
}
|
|
@@ -1,6 +1,8 @@
|
|
|
1
|
+
import materialweathericons from "./material-weather-icons";
|
|
1
2
|
import openmeteo from "./openmeteo";
|
|
2
3
|
import pixelarticons from "./pixelarticons";
|
|
3
4
|
declare const _default: {
|
|
5
|
+
materialweathericons: typeof materialweathericons;
|
|
4
6
|
openmeteo: typeof openmeteo;
|
|
5
7
|
pixelarticons: typeof pixelarticons;
|
|
6
8
|
};
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import type { DayPhase, WMO4677Code } from "../types";
|
|
2
|
+
export declare const MATERIAL_WEATHER_ICONS_URL_TEMPLATE = "https://github.com/M00NJ/material-weather-icons/blob/main/Icons/{icon}.svg";
|
|
3
|
+
type ProviderOpts = {
|
|
4
|
+
withUrlTemplate?: boolean;
|
|
5
|
+
};
|
|
6
|
+
export default function WMO4677MaterialWeatherIconsIcon(code: WMO4677Code, dayPhase?: DayPhase, { withUrlTemplate, }?: ProviderOpts): string | undefined;
|
|
7
|
+
export {};
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { default as wmoMaterialWeatherIcons } from "../data/icons/material-weather-icons.json" with {
|
|
2
|
+
type: "json"
|
|
3
|
+
};
|
|
4
|
+
export const MATERIAL_WEATHER_ICONS_URL_TEMPLATE = "https://github.com/M00NJ/material-weather-icons/blob/main/Icons/{icon}.svg";
|
|
5
|
+
export default function WMO4677MaterialWeatherIconsIcon(code, dayPhase = "day", { withUrlTemplate = false, } = {}) {
|
|
6
|
+
const icon = wmoMaterialWeatherIcons[code]?.[dayPhase];
|
|
7
|
+
if (!icon)
|
|
8
|
+
return undefined;
|
|
9
|
+
return withUrlTemplate ?
|
|
10
|
+
MATERIAL_WEATHER_ICONS_URL_TEMPLATE.replace("{icon}", icon) :
|
|
11
|
+
icon;
|
|
12
|
+
}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import type { DayPhase, WMO4677Code } from "../types";
|
|
2
|
+
export type MeteoconsFormat = "svg" | "svg-static" | "lottie";
|
|
3
|
+
export type MeteoconsVariant = "fill" | "flat" | "line" | "monochrome";
|
|
4
|
+
export declare const METEOCONS_FILL_URL_TEMPLATE = "https://cdn.meteocons.com/3.0.0-next.10/{format}/{variant}/{icon}.svg";
|
|
5
|
+
type ProviderOpts = {
|
|
6
|
+
format?: MeteoconsFormat;
|
|
7
|
+
variant?: MeteoconsVariant;
|
|
8
|
+
withUrlTemplate?: boolean;
|
|
9
|
+
};
|
|
10
|
+
export default function WMO4677MeteoconsIcon(code: WMO4677Code, dayPhase?: DayPhase, { withUrlTemplate, variant, format, }?: ProviderOpts): string | undefined;
|
|
11
|
+
export {};
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { default as wmoMeteoconsIcons } from "../data/icons/meteocons.json" with {
|
|
2
|
+
type: "json"
|
|
3
|
+
};
|
|
4
|
+
export const METEOCONS_FILL_URL_TEMPLATE = "https://cdn.meteocons.com/3.0.0-next.10/{format}/{variant}/{icon}.svg";
|
|
5
|
+
export default function WMO4677MeteoconsIcon(code, dayPhase = "day", { withUrlTemplate = false, variant = "fill", format = "svg", } = {}) {
|
|
6
|
+
const icon = wmoMeteoconsIcons[code]?.[dayPhase];
|
|
7
|
+
if (!icon)
|
|
8
|
+
return undefined;
|
|
9
|
+
return withUrlTemplate ?
|
|
10
|
+
METEOCONS_FILL_URL_TEMPLATE
|
|
11
|
+
.replace("{format}", format)
|
|
12
|
+
.replace("{variant}", variant)
|
|
13
|
+
.replace("{icon}", icon) :
|
|
14
|
+
icon;
|
|
15
|
+
}
|
|
@@ -1,2 +1,7 @@
|
|
|
1
1
|
import type { DayPhase, WMO4677Code } from "../types";
|
|
2
|
-
export
|
|
2
|
+
export declare const OPENMETEO_URL_TEMPLATE = "http://openweathermap.org/img/wn/{icon}@2x.png";
|
|
3
|
+
type ProviderOpts = {
|
|
4
|
+
withUrlTemplate?: boolean;
|
|
5
|
+
};
|
|
6
|
+
export default function WMO4677OpenMeteoIcon(code: WMO4677Code, dayPhase?: DayPhase, { withUrlTemplate, }?: ProviderOpts): string | undefined;
|
|
7
|
+
export {};
|
|
@@ -1,6 +1,12 @@
|
|
|
1
1
|
import { default as wmoOpenMeteoIcons } from "../data/icons/openmeteo.json" with {
|
|
2
2
|
type: "json"
|
|
3
3
|
};
|
|
4
|
-
export
|
|
5
|
-
|
|
4
|
+
export const OPENMETEO_URL_TEMPLATE = "http://openweathermap.org/img/wn/{icon}@2x.png";
|
|
5
|
+
export default function WMO4677OpenMeteoIcon(code, dayPhase = "day", { withUrlTemplate = false, } = {}) {
|
|
6
|
+
const icon = wmoOpenMeteoIcons[code]?.[dayPhase];
|
|
7
|
+
if (!icon)
|
|
8
|
+
return undefined;
|
|
9
|
+
return withUrlTemplate ?
|
|
10
|
+
OPENMETEO_URL_TEMPLATE.replace("{icon}", icon) :
|
|
11
|
+
icon;
|
|
6
12
|
}
|
package/dist/wmo_4677/index.d.ts
CHANGED
|
@@ -909,6 +909,7 @@ declare const WMO4677: {
|
|
|
909
909
|
code: import("./types").WMO4677Code;
|
|
910
910
|
}, 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | 55 | 56 | 57 | 58 | 59 | 60 | 61 | 62 | 63 | 64 | 65 | 66 | 67 | 68 | 69 | 70 | 71 | 72 | 73 | 74 | 75 | 76 | 77 | 78 | 79 | 80 | 81 | 82 | 83 | 84 | 85 | 86 | 87 | 88 | 89 | 90 | 91 | 92 | 93 | 94 | 95 | 96 | 97 | 98 | 99 | "cloud_not_observed" | "cloud_dissolving" | "sky_unchanged" | "cloud_developing" | "smoke_haze_reduced_visibility" | "haze" | "dust_suspension" | "dust_sand_raised_by_wind" | "dust_sand_whirls" | "duststorm_sandstorm" | "mist" | "fog_patches_shallow" | "fog_shallow_continuous" | "lightning_no_thunder" | "precipitation_not_reaching_ground" | "precipitation_distant" | "precipitation_nearby" | "thunderstorm_no_precipitation" | "squalls" | "funnel_clouds" | "drizzle_or_snow_grains_past_hour" | "rain_past_hour" | "snow_past_hour" | "rain_and_snow_past_hour" | "freezing_drizzle_or_rain_past_hour" | "rain_showers_past_hour" | "snow_showers_past_hour" | "hail_showers_past_hour" | "fog_past_hour" | "thunderstorm_past_hour" | "duststorm_decreasing" | "duststorm_no_change" | "duststorm_increasing" | "severe_duststorm_decreasing" | "severe_duststorm_no_change" | "severe_duststorm_increasing" | "drifting_snow_low_slight" | "drifting_snow_low_heavy" | "blowing_snow_high_slight" | "blowing_snow_high_heavy" | "fog_distant" | "fog_patches" | "fog_thinning_sky_visible" | "fog_thinning_sky_invisible" | "fog_no_change_sky_visible" | "fog_no_change_sky_invisible" | "fog_thickening_sky_visible" | "fog_thickening_sky_invisible" | "fog_rime_sky_visible" | "fog_rime_sky_invisible" | "drizzle_intermittent_slight" | "drizzle_continuous_slight" | "drizzle_intermittent_moderate" | "drizzle_continuous_moderate" | "drizzle_intermittent_heavy" | "drizzle_continuous_heavy" | "freezing_drizzle_slight" | "freezing_drizzle_moderate_heavy" | "rain_drizzle_slight" | "rain_drizzle_moderate_heavy" | "rain_intermittent_slight" | "rain_continuous_slight" | "rain_intermittent_moderate" | "rain_continuous_moderate" | "rain_intermittent_heavy" | "rain_continuous_heavy" | "freezing_rain_slight" | "freezing_rain_moderate_heavy" | "rain_snow_mixed_slight" | "rain_snow_mixed_moderate_heavy" | "snowflakes_intermittent_slight" | "snowflakes_continuous_slight" | "snowflakes_intermittent_moderate" | "snowflakes_continuous_moderate" | "snowflakes_intermittent_heavy" | "snowflakes_continuous_heavy" | "diamond_dust" | "snow_grains" | "snow_crystals" | "ice_pellets" | "rain_showers_slight" | "rain_showers_moderate_heavy" | "rain_showers_violent" | "rain_snow_showers_slight" | "rain_snow_showers_moderate_heavy" | "snow_showers_slight" | "snow_showers_moderate_heavy" | "snow_pellets_hail_showers_slight" | "snow_pellets_hail_showers_moderate_heavy" | "hail_showers_no_thunder_slight" | "hail_showers_no_thunder_moderate_heavy" | "rain_with_recent_thunderstorm_slight" | "rain_with_recent_thunderstorm_moderate_heavy" | "snow_hail_with_recent_thunderstorm_slight" | "snow_hail_with_recent_thunderstorm_moderate_heavy" | "thunderstorm_slight_moderate_no_hail" | "thunderstorm_slight_moderate_with_hail" | "thunderstorm_heavy_no_hail" | "thunderstorm_with_duststorm" | "thunderstorm_heavy_with_hail">>;
|
|
911
911
|
icons: {
|
|
912
|
+
materialweathericons: typeof import("./icons/material-weather-icons").default;
|
|
912
913
|
openmeteo: typeof import("./icons/openmeteo").default;
|
|
913
914
|
pixelarticons: typeof import("./icons/pixelarticons").default;
|
|
914
915
|
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "weather-i18n",
|
|
3
|
-
"version": "1.0
|
|
3
|
+
"version": "1.2.0",
|
|
4
4
|
"description": "I18n utilities and icon mappings for WMO weather codes",
|
|
5
5
|
"homepage": "https://github.com/pxl-ui/weather-i18n#readme",
|
|
6
6
|
"repository": {
|
|
@@ -66,16 +66,26 @@
|
|
|
66
66
|
"import": "./dist/wmo_4677/icons/index.js",
|
|
67
67
|
"default": "./dist/wmo_4677/icons/index.js"
|
|
68
68
|
},
|
|
69
|
-
"./wmo_4677/icons/
|
|
70
|
-
"types": "./dist/wmo_4677/icons/
|
|
71
|
-
"import": "./dist/wmo_4677/icons/
|
|
72
|
-
"default": "./dist/wmo_4677/icons/
|
|
69
|
+
"./wmo_4677/icons/material-weather-icons": {
|
|
70
|
+
"types": "./dist/wmo_4677/icons/material-weather-icons.d.ts",
|
|
71
|
+
"import": "./dist/wmo_4677/icons/material-weather-icons.js",
|
|
72
|
+
"default": "./dist/wmo_4677/icons/material-weather-icons.js"
|
|
73
|
+
},
|
|
74
|
+
"./wmo_4677/icons/meteocons": {
|
|
75
|
+
"types": "./dist/wmo_4677/icons/meteocons.d.ts",
|
|
76
|
+
"import": "./dist/wmo_4677/icons/meteocons.js",
|
|
77
|
+
"default": "./dist/wmo_4677/icons/meteocons.js"
|
|
73
78
|
},
|
|
74
79
|
"./wmo_4677/icons/openmeteo": {
|
|
75
80
|
"types": "./dist/wmo_4677/icons/openmeteo.d.ts",
|
|
76
81
|
"import": "./dist/wmo_4677/icons/openmeteo.js",
|
|
77
82
|
"default": "./dist/wmo_4677/icons/openmeteo.js"
|
|
78
83
|
},
|
|
84
|
+
"./wmo_4677/icons/pixelarticons": {
|
|
85
|
+
"types": "./dist/wmo_4677/icons/pixelarticons.d.ts",
|
|
86
|
+
"import": "./dist/wmo_4677/icons/pixelarticons.js",
|
|
87
|
+
"default": "./dist/wmo_4677/icons/pixelarticons.js"
|
|
88
|
+
},
|
|
79
89
|
"./wmo_4677/data/*": "./dist/wmo_4677/data/*"
|
|
80
90
|
},
|
|
81
91
|
"packageManager": "pnpm@10.33.0",
|