@cos-design/weather-background 4.0.0 → 4.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.
@@ -0,0 +1,19 @@
1
+ /**
2
+ * Web Component attribute → Core options parsing (v4 Element adapters).
3
+ * Keeps behavior consistent across 91 components.
4
+ */
5
+ export type BooleanAttrMode =
6
+ /** `options.key = el.hasAttribute(attr)` — always written */
7
+ 'presence'
8
+ /** Only when attribute present: `raw !== 'false' && raw !== '0'` (omit when absent) */
9
+ | 'optional-true'
10
+ /** Only when attribute present; when absent leave `undefined` (controlled props like `flipped`) */
11
+ | 'optional-undefined';
12
+ export declare const camelToKebabAttr: (name: string) => string;
13
+ export declare function readStringAttr<T extends object>(options: T, el: HTMLElement, key: keyof T & string, attr?: string): void;
14
+ export declare function readNumberAttr<T extends object>(options: T, el: HTMLElement, key: keyof T & string, attr?: string): void;
15
+ export declare function readBooleanAttr<T extends object>(options: T, el: HTMLElement, key: keyof T & string, attr?: string, mode?: BooleanAttrMode): void;
16
+ export declare function readJsonAttr<T extends object, K extends keyof T & string>(options: T, el: HTMLElement, key: K, attr?: string): void;
17
+ /** Property setters on the custom element class (`_prizes`, `_items`, …) override attributes. */
18
+ export declare function readPropertyOverride<T extends object, K extends keyof T & string>(options: T, el: HTMLElement, key: K, backingKey: string): void;
19
+ export declare function optionCallbackDispatcher(el: HTMLElement, eventName: string): (...args: unknown[]) => void;
@@ -9,3 +9,5 @@ export type { PhotoItem, PhotoIndexChangeHandler, PhotoFaceChangeHandler } from
9
9
  export { resolveCanvasBoxSize } from './canvas-box';
10
10
  export type { CanvasBoxSizeInput, CanvasBoxSize } from './canvas-box';
11
11
  export { applyCanvasHostBox, applyBlockHostBox, setHidden, optionsFingerprint, optionsVisualChanged, } from './host-layout';
12
+ export type { BooleanAttrMode } from './element-options';
13
+ export { camelToKebabAttr, optionCallbackDispatcher, readBooleanAttr, readJsonAttr, readNumberAttr, readPropertyOverride, readStringAttr, } from './element-options';
@@ -1,2 +1,4 @@
1
1
  export { default as WeatherBackground } from '../../../src/components/weatherBackground/vue/WeatherBackground.vue';
2
2
  export type * from '../../../src/components/weatherBackground/core/types';
3
+ export { useLiveWeather, useSunTimes, fetchLiveWeather, fetchSunTimes, formatLocalHm, getDayCycleTimesFromLive, IDLE_LIVE_WEATHER, isValidCoords, mapWmoCodeToWeatherType, subscribeLiveWeather, subscribeSunTimes, } from '../../../src/components/weatherBackground/vue/useLiveWeather';
4
+ export type { LiveWeatherCoords, LiveWeatherState, LiveWeatherStatus, OpenMeteoCurrent, } from '../../../src/components/weatherBackground/vue/useLiveWeather';
@@ -0,0 +1,15 @@
1
+ import { Ref } from 'vue';
2
+ import { DayCycleTimes } from '../day-cycle';
3
+ import { LiveWeatherCoords, LiveWeatherState } from '../live-weather-core';
4
+ export type { LiveWeatherCoords, LiveWeatherState, LiveWeatherStatus, OpenMeteoCurrent, } from '../live-weather-core';
5
+ export { fetchLiveWeather, fetchSunTimes, formatLocalHm, getDayCycleTimesFromLive, IDLE_LIVE_WEATHER, isValidCoords, mapWmoCodeToWeatherType, subscribeLiveWeather, subscribeSunTimes, } from '../live-weather-core';
6
+ /**
7
+ * Open-Meteo 实况天气(Vue composable,语义与 React `useLiveWeather` 对齐)。
8
+ * @param enabled 是否启用实况拉取
9
+ * @param coords 指定经纬度;省略时使用浏览器定位(需 HTTPS 与用户授权)
10
+ */
11
+ export declare function useLiveWeather(enabled?: boolean, coords?: LiveWeatherCoords): Ref<LiveWeatherState>;
12
+ /**
13
+ * 按经纬度获取当地日出日落(用于 `time` / 昼夜判断),与 React `useSunTimes` 对齐。
14
+ */
15
+ export declare function useSunTimes(coords?: LiveWeatherCoords): Ref<DayCycleTimes | null>;
@@ -0,0 +1,19 @@
1
+ /**
2
+ * Web Component attribute → Core options parsing (v4 Element adapters).
3
+ * Keeps behavior consistent across 91 components.
4
+ */
5
+ export type BooleanAttrMode =
6
+ /** `options.key = el.hasAttribute(attr)` — always written */
7
+ 'presence'
8
+ /** Only when attribute present: `raw !== 'false' && raw !== '0'` (omit when absent) */
9
+ | 'optional-true'
10
+ /** Only when attribute present; when absent leave `undefined` (controlled props like `flipped`) */
11
+ | 'optional-undefined';
12
+ export declare const camelToKebabAttr: (name: string) => string;
13
+ export declare function readStringAttr<T extends object>(options: T, el: HTMLElement, key: keyof T & string, attr?: string): void;
14
+ export declare function readNumberAttr<T extends object>(options: T, el: HTMLElement, key: keyof T & string, attr?: string): void;
15
+ export declare function readBooleanAttr<T extends object>(options: T, el: HTMLElement, key: keyof T & string, attr?: string, mode?: BooleanAttrMode): void;
16
+ export declare function readJsonAttr<T extends object, K extends keyof T & string>(options: T, el: HTMLElement, key: K, attr?: string): void;
17
+ /** Property setters on the custom element class (`_prizes`, `_items`, …) override attributes. */
18
+ export declare function readPropertyOverride<T extends object, K extends keyof T & string>(options: T, el: HTMLElement, key: K, backingKey: string): void;
19
+ export declare function optionCallbackDispatcher(el: HTMLElement, eventName: string): (...args: unknown[]) => void;
@@ -9,3 +9,5 @@ export type { PhotoItem, PhotoIndexChangeHandler, PhotoFaceChangeHandler } from
9
9
  export { resolveCanvasBoxSize } from './canvas-box';
10
10
  export type { CanvasBoxSizeInput, CanvasBoxSize } from './canvas-box';
11
11
  export { applyCanvasHostBox, applyBlockHostBox, setHidden, optionsFingerprint, optionsVisualChanged, } from './host-layout';
12
+ export type { BooleanAttrMode } from './element-options';
13
+ export { camelToKebabAttr, optionCallbackDispatcher, readBooleanAttr, readJsonAttr, readNumberAttr, readPropertyOverride, readStringAttr, } from './element-options';
@@ -1,2 +1,4 @@
1
1
  export { default as WeatherBackground } from '../../../src/components/weatherBackground/vue/WeatherBackground.vue';
2
2
  export type * from '../../../src/components/weatherBackground/core/types';
3
+ export { useLiveWeather, useSunTimes, fetchLiveWeather, fetchSunTimes, formatLocalHm, getDayCycleTimesFromLive, IDLE_LIVE_WEATHER, isValidCoords, mapWmoCodeToWeatherType, subscribeLiveWeather, subscribeSunTimes, } from '../../../src/components/weatherBackground/vue/useLiveWeather';
4
+ export type { LiveWeatherCoords, LiveWeatherState, LiveWeatherStatus, OpenMeteoCurrent, } from '../../../src/components/weatherBackground/vue/useLiveWeather';
@@ -1 +1 @@
1
- .cos-weather-background{border-radius:12px;position:relative;overflow:hidden}.cos-weather-background__canvas{display:block}.cos-weather-background__loading-overlay{-webkit-backdrop-filter:blur(2px);backdrop-filter:blur(2px);color:#ffffffe0;pointer-events:none;background:#0c121c52;flex-direction:column;justify-content:center;align-items:center;gap:10px;font-size:13px;display:flex;position:absolute;inset:0}.cos-weather-background__loading-overlay[hidden]{display:none!important}.cos-weather-background__loading-spinner{border:3px solid #ffffff40;border-top-color:#ffffffeb;border-radius:50%;width:28px;height:28px;animation:.8s linear infinite weather-loading-spin}@keyframes weather-loading-spin{to{transform:rotate(360deg)}}
1
+ .cos-weather-background{border-radius:12px;position:relative;overflow:hidden}.cos-weather-background__canvas{display:block}.cos-weather-background__loading-overlay{-webkit-backdrop-filter:blur(2px);backdrop-filter:blur(2px);color:#ffffffe0;pointer-events:none;background:#0c121c52;flex-direction:column;justify-content:center;align-items:center;gap:10px;font-size:13px;display:flex;position:absolute;inset:0}.cos-weather-background__loading-overlay[hidden]{display:none!important}.cos-weather-background__loading-spinner{border:3px solid #ffffff40;border-top-color:#ffffffeb;border-radius:50%;width:28px;height:28px;animation:.8s linear infinite weather-loading-spin}@keyframes weather-loading-spin{to{transform:rotate(360deg)}}@media (prefers-reduced-motion:reduce){.cos-weather-background__loading-spinner{animation:none}}
@@ -0,0 +1,15 @@
1
+ import { Ref } from 'vue';
2
+ import { DayCycleTimes } from '../day-cycle';
3
+ import { LiveWeatherCoords, LiveWeatherState } from '../live-weather-core';
4
+ export type { LiveWeatherCoords, LiveWeatherState, LiveWeatherStatus, OpenMeteoCurrent, } from '../live-weather-core';
5
+ export { fetchLiveWeather, fetchSunTimes, formatLocalHm, getDayCycleTimesFromLive, IDLE_LIVE_WEATHER, isValidCoords, mapWmoCodeToWeatherType, subscribeLiveWeather, subscribeSunTimes, } from '../live-weather-core';
6
+ /**
7
+ * Open-Meteo 实况天气(Vue composable,语义与 React `useLiveWeather` 对齐)。
8
+ * @param enabled 是否启用实况拉取
9
+ * @param coords 指定经纬度;省略时使用浏览器定位(需 HTTPS 与用户授权)
10
+ */
11
+ export declare function useLiveWeather(enabled?: boolean, coords?: LiveWeatherCoords): Ref<LiveWeatherState>;
12
+ /**
13
+ * 按经纬度获取当地日出日落(用于 `time` / 昼夜判断),与 React `useSunTimes` 对齐。
14
+ */
15
+ export declare function useSunTimes(coords?: LiveWeatherCoords): Ref<DayCycleTimes | null>;
@@ -1,2 +1,21 @@
1
1
  export { default as WeatherBackground } from './src/components/weatherBackground/vue/WeatherBackground.vue';
2
2
  export type * from './src/components/weatherBackground/core/types';
3
+ export {
4
+ useLiveWeather,
5
+ useSunTimes,
6
+ fetchLiveWeather,
7
+ fetchSunTimes,
8
+ formatLocalHm,
9
+ getDayCycleTimesFromLive,
10
+ IDLE_LIVE_WEATHER,
11
+ isValidCoords,
12
+ mapWmoCodeToWeatherType,
13
+ subscribeLiveWeather,
14
+ subscribeSunTimes,
15
+ } from './src/components/weatherBackground/vue/useLiveWeather';
16
+ export type {
17
+ LiveWeatherCoords,
18
+ LiveWeatherState,
19
+ LiveWeatherStatus,
20
+ OpenMeteoCurrent,
21
+ } from './src/components/weatherBackground/vue/useLiveWeather';