nuxt-weather-module 1.0.1 → 1.0.4

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 CHANGED
@@ -1,4 +1,4 @@
1
- # Weather Module
1
+ # Nuxt Weather Module
2
2
 
3
3
  [![npm version][npm-version-src]][npm-version-href]
4
4
  [![npm downloads][npm-downloads-src]][npm-downloads-href]
@@ -24,7 +24,7 @@ A Nuxt module for displaying dynamic weather icons from the Open-Meteo API.
24
24
  Install the module to your Nuxt application with one command:
25
25
 
26
26
  ```bash
27
- npx nuxi module add weather-module
27
+ npx nuxi module add nuxt-weather-module
28
28
  ```
29
29
 
30
30
  That's it! You can now use the `DynamicWeather` component in your Nuxt app.
@@ -35,7 +35,7 @@ The module can be configured in your `nuxt.config.ts` file:
35
35
 
36
36
  ```ts
37
37
  export default defineNuxtConfig({
38
- modules: ['weather-module'],
38
+ modules: ['nuxt-weather-module'],
39
39
  weatherModule: {
40
40
  latitude: 55.676098, // Copenhagen
41
41
  longitude: 12.568337, // Copenhagen
@@ -81,10 +81,10 @@ The module exports the following types for use in your application:
81
81
  - `CurrentWeatherDetail`
82
82
  - `CurrentWeatherUnits`
83
83
 
84
- You can import them from `weather-module`:
84
+ You can import them from `nuxt-weather-module`:
85
85
 
86
86
  ```ts
87
- import type { WeatherIcon } from 'weather-module'
87
+ import type { WeatherIcon } from 'nuxt-weather-module'
88
88
  ```
89
89
 
90
90
  ## Notes
@@ -124,14 +124,14 @@ import type { WeatherIcon } from 'weather-module'
124
124
  </details>
125
125
 
126
126
  <!-- Badges -->
127
- [npm-version-src]: https://img.shields.io/npm/v/weather-module/latest.svg?style=flat&colorA=020420&colorB=00DC82
128
- [npm-version-href]: https://npmjs.com/package/weather-module
127
+ [npm-version-src]: https://img.shields.io/npm/v/nuxt-weather-module/latest.svg?style=flat&colorA=020420&colorB=00DC82
128
+ [npm-version-href]: https://npmjs.com/package/nuxt-weather-module
129
129
 
130
- [npm-downloads-src]: https://img.shields.io/npm/dm/weather-module.svg?style=flat&colorA=020420&colorB=00DC82
131
- [npm-downloads-href]: https://npm.chart.dev/weather-module
130
+ [npm-downloads-src]: https://img.shields.io/npm/dm/nuxt-weather-module.svg?style=flat&colorA=020420&colorB=00DC82
131
+ [npm-downloads-href]: https://npm.chart.dev/nuxt-weather-module
132
132
 
133
- [license-src]: https://img.shields.io/npm/l/weather-module.svg?style=flat&colorA=020420&colorB=00DC82
134
- [license-href]: https://npmjs.com/package/weather-module
133
+ [license-src]: https://img.shields.io/npm/l/nuxt-weather-module.svg?style=flat&colorA=020420&colorB=00DC82
134
+ [license-href]: https://npmjs.com/package/nuxt-weather-module
135
135
 
136
136
  [nuxt-src]: https://img.shields.io/badge/Nuxt-020420?logo=nuxt
137
137
  [nuxt-href]: https://nuxt.com
package/dist/module.json CHANGED
@@ -4,7 +4,7 @@
4
4
  "compatibility": {
5
5
  "nuxt": "^4.0.0"
6
6
  },
7
- "version": "1.0.1",
7
+ "version": "1.0.4",
8
8
  "builder": {
9
9
  "@nuxt/module-builder": "1.0.2",
10
10
  "unbuild": "3.6.1"
@@ -1,5 +1,5 @@
1
1
  type __VLS_ModelProps = {
2
- 'status'?: 'idle' | 'pending' | 'success' | 'error';
2
+ "status"?: "idle" | "pending" | "success" | "error";
3
3
  };
4
4
  declare const __VLS_export: import("vue").DefineComponent<__VLS_ModelProps, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {
5
5
  "update:status": (value: "idle" | "pending" | "success" | "error") => any;
@@ -1,6 +1,10 @@
1
1
  <template>
2
2
  <div>
3
- <Icon v-if="status === 'success'" class="dynamic-weather-icon" :name="`weather:${setIcon}`" />
3
+ <Icon
4
+ v-if="status === 'success'"
5
+ class="dynamic-weather-icon"
6
+ :name="`weather:${setIcon}`"
7
+ />
4
8
  </div>
5
9
  </template>
6
10
 
@@ -12,17 +16,34 @@ import { WEATHER_CODE_MAP } from "../utils/constants";
12
16
  const status = defineModel("status", { type: String, ...{
13
17
  default: "pending"
14
18
  } });
19
+ watch(
20
+ status,
21
+ (newStatus) => {
22
+ if (newStatus === void 0) {
23
+ status.value = "pending";
24
+ }
25
+ },
26
+ { immediate: true }
27
+ );
15
28
  const config = useRuntimeConfig();
16
29
  const { latitude, longitude } = config.public.weatherModule;
17
- const { status: asyncStatus, data, error } = await useLazyAsyncData(
30
+ const {
31
+ status: asyncStatus,
32
+ data,
33
+ error
34
+ } = await useLazyAsyncData(
18
35
  "weather-icon",
19
36
  () => $fetch(
20
37
  `https://api.open-meteo.com/v1/forecast?latitude=${latitude}&longitude=${longitude}&current_weather=true`
21
38
  )
22
39
  );
23
- watch(asyncStatus, (newStatus) => {
24
- status.value = newStatus;
25
- }, { immediate: true });
40
+ watch(
41
+ asyncStatus,
42
+ (newStatus) => {
43
+ status.value = newStatus;
44
+ },
45
+ { immediate: true }
46
+ );
26
47
  if (error.value) {
27
48
  console.error("Error fetching weather data:", error.value);
28
49
  }
@@ -1,5 +1,5 @@
1
1
  type __VLS_ModelProps = {
2
- 'status'?: 'idle' | 'pending' | 'success' | 'error';
2
+ "status"?: "idle" | "pending" | "success" | "error";
3
3
  };
4
4
  declare const __VLS_export: import("vue").DefineComponent<__VLS_ModelProps, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {
5
5
  "update:status": (value: "idle" | "pending" | "success" | "error") => any;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "nuxt-weather-module",
3
- "version": "1.0.1",
3
+ "version": "1.0.4",
4
4
  "description": "A Nuxt module for displaying dynamic weather icons from Open-Meteo API with configurable coordinates",
5
5
  "author": "LobergDesign",
6
6
  "homepage": "https://github.com/LobergDesign/weather-module#readme",