@cos-design/weather-background 3.5.5 → 4.0.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/dist/core/index.d.ts +1 -0
- package/dist/core/index.js +1527 -0
- package/dist/core/packages/shared/src/canvas-box.d.ts +18 -0
- package/dist/core/packages/shared/src/host-layout.d.ts +22 -0
- package/dist/{packages → core/packages}/shared/src/index.d.ts +4 -3
- package/dist/{packages → core/packages}/shared/src/math.d.ts +1 -0
- package/dist/{packages/shared/src/use-element-size.d.ts → core/packages/shared/src/react/index.d.ts} +4 -19
- package/dist/core/packages/weatherBackground/src/core.d.ts +1 -0
- package/dist/core/packages/weatherBackground/src/element.d.ts +1 -0
- package/dist/{packages → core/packages}/weatherBackground/src/index.d.ts +8 -8
- package/dist/core/packages/weatherBackground/src/react.d.ts +15 -0
- package/dist/core/packages/weatherBackground/src/vue.d.ts +2 -0
- package/dist/core/src/components/weatherBackground/core/engine.d.ts +2 -0
- package/dist/core/src/components/weatherBackground/core/index.d.ts +14 -0
- package/dist/core/src/components/weatherBackground/core/types.d.ts +7 -0
- package/dist/core/src/components/weatherBackground/element/index.d.ts +13 -0
- package/dist/core/src/components/weatherBackground/index.d.ts +5 -0
- package/dist/{src/components/weatherBackground/live-weather.d.ts → core/src/components/weatherBackground/live-weather-core.d.ts} +8 -10
- package/dist/core/src/components/weatherBackground/live-weather.d.ts +15 -0
- package/dist/core/src/components/weatherBackground/react/index.d.ts +3 -0
- package/dist/{src → core/src}/vite-env.d.ts +6 -0
- package/dist/element/element.css +1 -0
- package/dist/element/index.d.ts +1 -0
- package/dist/element/index.js +1541 -0
- package/dist/element/packages/shared/src/canvas-box.d.ts +18 -0
- package/dist/element/packages/shared/src/host-layout.d.ts +22 -0
- package/dist/element/packages/shared/src/index.d.ts +11 -0
- package/dist/element/packages/shared/src/math.d.ts +2 -0
- package/dist/element/packages/shared/src/photo.d.ts +15 -0
- package/dist/element/packages/shared/src/pointer.d.ts +14 -0
- package/dist/element/packages/shared/src/react/index.d.ts +30 -0
- package/dist/element/packages/shared/src/reduced-motion.d.ts +4 -0
- package/dist/element/packages/shared/src/size.d.ts +8 -0
- package/dist/element/packages/shared/src/visibility.d.ts +2 -0
- package/dist/element/packages/weatherBackground/src/core.d.ts +1 -0
- package/dist/element/packages/weatherBackground/src/element.d.ts +1 -0
- package/dist/element/packages/weatherBackground/src/index.d.ts +15 -0
- package/dist/element/packages/weatherBackground/src/react.d.ts +15 -0
- package/dist/element/packages/weatherBackground/src/vue.d.ts +2 -0
- package/dist/element/src/components/weatherBackground/configs.d.ts +9 -0
- package/dist/element/src/components/weatherBackground/core/engine.d.ts +2 -0
- package/dist/element/src/components/weatherBackground/core/index.d.ts +14 -0
- package/dist/element/src/components/weatherBackground/core/types.d.ts +7 -0
- package/dist/element/src/components/weatherBackground/day-cycle.d.ts +53 -0
- package/dist/element/src/components/weatherBackground/element/index.d.ts +13 -0
- package/dist/element/src/components/weatherBackground/fog.d.ts +25 -0
- package/dist/element/src/components/weatherBackground/hail-level.d.ts +24 -0
- package/dist/element/src/components/weatherBackground/index.d.ts +5 -0
- package/dist/element/src/components/weatherBackground/lightning.d.ts +1 -0
- package/dist/element/src/components/weatherBackground/live-weather-core.d.ts +79 -0
- package/dist/element/src/components/weatherBackground/live-weather.d.ts +15 -0
- package/dist/element/src/components/weatherBackground/precipitation.d.ts +51 -0
- package/dist/element/src/components/weatherBackground/react/index.d.ts +3 -0
- package/dist/element/src/components/weatherBackground/scene/create-weather-scene.d.ts +2 -0
- package/dist/element/src/components/weatherBackground/scene/draw-atmosphere.d.ts +4 -0
- package/dist/element/src/components/weatherBackground/scene/draw-effects.d.ts +3 -0
- package/dist/element/src/components/weatherBackground/scene/draw-precipitation.d.ts +4 -0
- package/dist/element/src/components/weatherBackground/scene/draw-sky.d.ts +4 -0
- package/dist/element/src/components/weatherBackground/scene/init-state.d.ts +44 -0
- package/dist/element/src/components/weatherBackground/scene/runtime.d.ts +38 -0
- package/dist/element/src/components/weatherBackground/smog.d.ts +17 -0
- package/dist/element/src/components/weatherBackground/sprites/celestial.d.ts +11 -0
- package/dist/element/src/components/weatherBackground/sprites/cloud.d.ts +20 -0
- package/dist/element/src/components/weatherBackground/sprites/hail.d.ts +11 -0
- package/dist/element/src/components/weatherBackground/sprites/snow.d.ts +8 -0
- package/dist/element/src/components/weatherBackground/types.d.ts +230 -0
- package/dist/element/src/components/weatherBackground/wind.d.ts +68 -0
- package/dist/element/src/vite-env.d.ts +45 -0
- package/dist/react/index.cjs +1 -0
- package/dist/react/index.d.ts +89 -0
- package/dist/{index.js → react/index.js} +444 -424
- package/dist/react/packages/shared/src/canvas-box.d.ts +18 -0
- package/dist/react/packages/shared/src/host-layout.d.ts +22 -0
- package/dist/react/packages/shared/src/index.d.ts +11 -0
- package/dist/react/packages/shared/src/math.d.ts +2 -0
- package/dist/react/packages/shared/src/photo.d.ts +15 -0
- package/dist/react/packages/shared/src/pointer.d.ts +14 -0
- package/dist/react/packages/shared/src/react/index.d.ts +30 -0
- package/dist/react/packages/shared/src/reduced-motion.d.ts +4 -0
- package/dist/react/packages/shared/src/size.d.ts +8 -0
- package/dist/react/packages/shared/src/visibility.d.ts +2 -0
- package/dist/react/packages/weatherBackground/src/core.d.ts +1 -0
- package/dist/react/packages/weatherBackground/src/element.d.ts +1 -0
- package/dist/react/packages/weatherBackground/src/index.d.ts +15 -0
- package/dist/react/packages/weatherBackground/src/react.d.ts +15 -0
- package/dist/react/packages/weatherBackground/src/vue.d.ts +2 -0
- package/dist/react/react.css +1 -0
- package/dist/react/src/components/weatherBackground/configs.d.ts +9 -0
- package/dist/react/src/components/weatherBackground/core/engine.d.ts +2 -0
- package/dist/react/src/components/weatherBackground/core/index.d.ts +14 -0
- package/dist/react/src/components/weatherBackground/core/types.d.ts +7 -0
- package/dist/react/src/components/weatherBackground/day-cycle.d.ts +53 -0
- package/dist/react/src/components/weatherBackground/element/index.d.ts +13 -0
- package/dist/react/src/components/weatherBackground/fog.d.ts +25 -0
- package/dist/react/src/components/weatherBackground/hail-level.d.ts +24 -0
- package/dist/react/src/components/weatherBackground/index.d.ts +5 -0
- package/dist/react/src/components/weatherBackground/lightning.d.ts +1 -0
- package/dist/react/src/components/weatherBackground/live-weather-core.d.ts +79 -0
- package/dist/react/src/components/weatherBackground/live-weather.d.ts +15 -0
- package/dist/react/src/components/weatherBackground/precipitation.d.ts +51 -0
- package/dist/react/src/components/weatherBackground/react/index.d.ts +3 -0
- package/dist/react/src/components/weatherBackground/scene/create-weather-scene.d.ts +2 -0
- package/dist/react/src/components/weatherBackground/scene/draw-atmosphere.d.ts +4 -0
- package/dist/react/src/components/weatherBackground/scene/draw-effects.d.ts +3 -0
- package/dist/react/src/components/weatherBackground/scene/draw-precipitation.d.ts +4 -0
- package/dist/react/src/components/weatherBackground/scene/draw-sky.d.ts +4 -0
- package/dist/react/src/components/weatherBackground/scene/init-state.d.ts +44 -0
- package/dist/react/src/components/weatherBackground/scene/runtime.d.ts +38 -0
- package/dist/react/src/components/weatherBackground/smog.d.ts +17 -0
- package/dist/react/src/components/weatherBackground/sprites/celestial.d.ts +11 -0
- package/dist/react/src/components/weatherBackground/sprites/cloud.d.ts +20 -0
- package/dist/react/src/components/weatherBackground/sprites/hail.d.ts +11 -0
- package/dist/react/src/components/weatherBackground/sprites/snow.d.ts +8 -0
- package/dist/react/src/components/weatherBackground/types.d.ts +230 -0
- package/dist/react/src/components/weatherBackground/wind.d.ts +68 -0
- package/dist/react/src/vite-env.d.ts +45 -0
- package/dist/vue/index.d.ts +2 -0
- package/dist/vue/index.js +1517 -0
- package/dist/vue/packages/shared/src/canvas-box.d.ts +18 -0
- package/dist/vue/packages/shared/src/host-layout.d.ts +22 -0
- package/dist/vue/packages/shared/src/index.d.ts +11 -0
- package/dist/vue/packages/shared/src/math.d.ts +2 -0
- package/dist/vue/packages/shared/src/photo.d.ts +15 -0
- package/dist/vue/packages/shared/src/pointer.d.ts +14 -0
- package/dist/vue/packages/shared/src/react/index.d.ts +30 -0
- package/dist/vue/packages/shared/src/reduced-motion.d.ts +4 -0
- package/dist/vue/packages/shared/src/size.d.ts +8 -0
- package/dist/vue/packages/shared/src/visibility.d.ts +2 -0
- package/dist/vue/packages/weatherBackground/src/core.d.ts +1 -0
- package/dist/vue/packages/weatherBackground/src/element.d.ts +1 -0
- package/dist/vue/packages/weatherBackground/src/index.d.ts +15 -0
- package/dist/vue/packages/weatherBackground/src/react.d.ts +15 -0
- package/dist/vue/packages/weatherBackground/src/vue.d.ts +2 -0
- package/dist/vue/src/components/weatherBackground/configs.d.ts +9 -0
- package/dist/vue/src/components/weatherBackground/core/engine.d.ts +2 -0
- package/dist/vue/src/components/weatherBackground/core/index.d.ts +14 -0
- package/dist/vue/src/components/weatherBackground/core/types.d.ts +7 -0
- package/dist/vue/src/components/weatherBackground/day-cycle.d.ts +53 -0
- package/dist/vue/src/components/weatherBackground/element/index.d.ts +13 -0
- package/dist/vue/src/components/weatherBackground/fog.d.ts +25 -0
- package/dist/vue/src/components/weatherBackground/hail-level.d.ts +24 -0
- package/dist/vue/src/components/weatherBackground/index.d.ts +5 -0
- package/dist/vue/src/components/weatherBackground/lightning.d.ts +1 -0
- package/dist/vue/src/components/weatherBackground/live-weather-core.d.ts +79 -0
- package/dist/vue/src/components/weatherBackground/live-weather.d.ts +15 -0
- package/dist/vue/src/components/weatherBackground/precipitation.d.ts +51 -0
- package/dist/vue/src/components/weatherBackground/react/index.d.ts +3 -0
- package/dist/vue/src/components/weatherBackground/scene/create-weather-scene.d.ts +2 -0
- package/dist/vue/src/components/weatherBackground/scene/draw-atmosphere.d.ts +4 -0
- package/dist/vue/src/components/weatherBackground/scene/draw-effects.d.ts +3 -0
- package/dist/vue/src/components/weatherBackground/scene/draw-precipitation.d.ts +4 -0
- package/dist/vue/src/components/weatherBackground/scene/draw-sky.d.ts +4 -0
- package/dist/vue/src/components/weatherBackground/scene/init-state.d.ts +44 -0
- package/dist/vue/src/components/weatherBackground/scene/runtime.d.ts +38 -0
- package/dist/vue/src/components/weatherBackground/smog.d.ts +17 -0
- package/dist/vue/src/components/weatherBackground/sprites/celestial.d.ts +11 -0
- package/dist/vue/src/components/weatherBackground/sprites/cloud.d.ts +20 -0
- package/dist/vue/src/components/weatherBackground/sprites/hail.d.ts +11 -0
- package/dist/vue/src/components/weatherBackground/sprites/snow.d.ts +8 -0
- package/dist/vue/src/components/weatherBackground/types.d.ts +230 -0
- package/dist/vue/src/components/weatherBackground/wind.d.ts +68 -0
- package/dist/vue/src/vite-env.d.ts +45 -0
- package/dist/vue/vue.css +1 -0
- package/package.json +43 -11
- package/dist/index.cjs +0 -1
- package/dist/index.css +0 -1
- package/dist/index.d.ts +0 -5
- package/dist/src/components/weatherBackground/index.d.ts +0 -5
- /package/dist/{packages → core/packages}/shared/src/photo.d.ts +0 -0
- /package/dist/{packages → core/packages}/shared/src/pointer.d.ts +0 -0
- /package/dist/{packages → core/packages}/shared/src/reduced-motion.d.ts +0 -0
- /package/dist/{packages → core/packages}/shared/src/size.d.ts +0 -0
- /package/dist/{packages → core/packages}/shared/src/visibility.d.ts +0 -0
- /package/dist/{src → core/src}/components/weatherBackground/configs.d.ts +0 -0
- /package/dist/{src → core/src}/components/weatherBackground/day-cycle.d.ts +0 -0
- /package/dist/{src → core/src}/components/weatherBackground/fog.d.ts +0 -0
- /package/dist/{src → core/src}/components/weatherBackground/hail-level.d.ts +0 -0
- /package/dist/{src → core/src}/components/weatherBackground/lightning.d.ts +0 -0
- /package/dist/{src → core/src}/components/weatherBackground/precipitation.d.ts +0 -0
- /package/dist/{src → core/src}/components/weatherBackground/scene/create-weather-scene.d.ts +0 -0
- /package/dist/{src → core/src}/components/weatherBackground/scene/draw-atmosphere.d.ts +0 -0
- /package/dist/{src → core/src}/components/weatherBackground/scene/draw-effects.d.ts +0 -0
- /package/dist/{src → core/src}/components/weatherBackground/scene/draw-precipitation.d.ts +0 -0
- /package/dist/{src → core/src}/components/weatherBackground/scene/draw-sky.d.ts +0 -0
- /package/dist/{src → core/src}/components/weatherBackground/scene/init-state.d.ts +0 -0
- /package/dist/{src → core/src}/components/weatherBackground/scene/runtime.d.ts +0 -0
- /package/dist/{src → core/src}/components/weatherBackground/smog.d.ts +0 -0
- /package/dist/{src → core/src}/components/weatherBackground/sprites/celestial.d.ts +0 -0
- /package/dist/{src → core/src}/components/weatherBackground/sprites/cloud.d.ts +0 -0
- /package/dist/{src → core/src}/components/weatherBackground/sprites/hail.d.ts +0 -0
- /package/dist/{src → core/src}/components/weatherBackground/sprites/snow.d.ts +0 -0
- /package/dist/{src → core/src}/components/weatherBackground/types.d.ts +0 -0
- /package/dist/{src → core/src}/components/weatherBackground/wind.d.ts +0 -0
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { ElementSize } from './size';
|
|
2
|
+
export interface CanvasBoxSizeInput {
|
|
3
|
+
/** 为 true 时跟随父容器尺寸(需父级有明确高度) */
|
|
4
|
+
fill?: boolean;
|
|
5
|
+
width?: number;
|
|
6
|
+
height?: number;
|
|
7
|
+
defaultWidth: number;
|
|
8
|
+
defaultHeight: number;
|
|
9
|
+
measured: ElementSize;
|
|
10
|
+
}
|
|
11
|
+
export interface CanvasBoxSize {
|
|
12
|
+
width: number;
|
|
13
|
+
height: number;
|
|
14
|
+
/** 是否处于 fill 模式且尚未量到有效尺寸 */
|
|
15
|
+
pending: boolean;
|
|
16
|
+
}
|
|
17
|
+
/** 根据 fill / 显式宽高 / 测量结果解析画布逻辑尺寸 */
|
|
18
|
+
export declare const resolveCanvasBoxSize: ({ fill, width, height, defaultWidth, defaultHeight, measured, }: CanvasBoxSizeInput) => CanvasBoxSize;
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
/** Apply fill / explicit size to the adapter host and make the engine root fill it. */
|
|
2
|
+
export declare function applyCanvasHostBox(container: HTMLElement, root: HTMLElement, opts: {
|
|
3
|
+
fill: boolean;
|
|
4
|
+
width: number;
|
|
5
|
+
height: number;
|
|
6
|
+
}): void;
|
|
7
|
+
/**
|
|
8
|
+
* Size the adapter host (React/Vue div or custom element) so percentage widths
|
|
9
|
+
* don't collapse when the host is a shrink-wrapped flex child. Root fills the host
|
|
10
|
+
* unless `rootFillsHost` is false (e.g. PhotoAlbum sizes itself via CSS variables).
|
|
11
|
+
*/
|
|
12
|
+
export declare function applyBlockHostBox(container: HTMLElement, root: HTMLElement, size: {
|
|
13
|
+
width?: number | string;
|
|
14
|
+
height?: number | string;
|
|
15
|
+
rootFillsHost?: boolean;
|
|
16
|
+
}): void;
|
|
17
|
+
/** Toggle empty-state nodes; author `display:` rules must not override `[hidden]`. */
|
|
18
|
+
export declare function setHidden(el: HTMLElement, hidden: boolean): void;
|
|
19
|
+
/** Stable JSON key for options, ignoring functions (callbacks). */
|
|
20
|
+
export declare function optionsFingerprint(value: unknown): string;
|
|
21
|
+
/** True when non-function fields differ (shallow). */
|
|
22
|
+
export declare function optionsVisualChanged(prev: Record<string, unknown>, next: Record<string, unknown>): boolean;
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
export { clamp, lerp } from './math';
|
|
2
|
+
export { bindVisibilityPause } from './visibility';
|
|
3
|
+
export { prefersReducedMotion, bindPrefersReducedMotion } from './reduced-motion';
|
|
4
|
+
export { observeElementSize } from './size';
|
|
5
|
+
export type { ElementSize } from './size';
|
|
6
|
+
export { getRelativePointerPosition } from './pointer';
|
|
7
|
+
export type { PointerPosition } from './pointer';
|
|
8
|
+
export type { PhotoItem, PhotoIndexChangeHandler, PhotoFaceChangeHandler } from './photo';
|
|
9
|
+
export { resolveCanvasBoxSize } from './canvas-box';
|
|
10
|
+
export type { CanvasBoxSizeInput, CanvasBoxSize } from './canvas-box';
|
|
11
|
+
export { applyCanvasHostBox, applyBlockHostBox, setHidden, optionsFingerprint, optionsVisualChanged, } from './host-layout';
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
/** 图片预览组件通用照片项 */
|
|
2
|
+
export interface PhotoItem {
|
|
3
|
+
/** 图片地址 */
|
|
4
|
+
src: string;
|
|
5
|
+
/** 图片替代文本 */
|
|
6
|
+
alt?: string;
|
|
7
|
+
/** 照片标题 */
|
|
8
|
+
title?: string;
|
|
9
|
+
/** 照片说明 */
|
|
10
|
+
description?: string;
|
|
11
|
+
}
|
|
12
|
+
/** 线性浏览:当前索引变化(相册 / 胶卷 / 晾绳等) */
|
|
13
|
+
export type PhotoIndexChangeHandler<T = PhotoItem> = (index: number, photo: T) => void;
|
|
14
|
+
/** 环形浏览:正对镜头的面变化(走马灯 / 旋转木马等) */
|
|
15
|
+
export type PhotoFaceChangeHandler<T = PhotoItem> = (index: number, photo?: T) => void;
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
export interface PointerPosition {
|
|
2
|
+
x: number;
|
|
3
|
+
y: number;
|
|
4
|
+
}
|
|
5
|
+
type PointLike = {
|
|
6
|
+
clientX: number;
|
|
7
|
+
clientY: number;
|
|
8
|
+
};
|
|
9
|
+
/** 相对元素左上角的指针坐标(兼容 mouse / touch / pointer) */
|
|
10
|
+
export declare const getRelativePointerPosition: (element: Element, event: PointLike | {
|
|
11
|
+
touches?: ArrayLike<PointLike>;
|
|
12
|
+
changedTouches?: ArrayLike<PointLike>;
|
|
13
|
+
}) => PointerPosition | null;
|
|
14
|
+
export {};
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import { CSSProperties, RefObject } from 'react';
|
|
2
|
+
import { ElementSize } from '../size';
|
|
3
|
+
export type { CanvasBoxSize, CanvasBoxSizeInput } from '../canvas-box';
|
|
4
|
+
export { resolveCanvasBoxSize } from '../canvas-box';
|
|
5
|
+
export interface UseElementSizeOptions {
|
|
6
|
+
/** 为 false 时不观察 */
|
|
7
|
+
enabled?: boolean;
|
|
8
|
+
}
|
|
9
|
+
/** 观察元素尺寸(clientWidth / clientHeight) */
|
|
10
|
+
export declare const useElementSize: <T extends Element>(ref: RefObject<T | null>, options?: UseElementSizeOptions) => ElementSize;
|
|
11
|
+
export interface UseCanvasBoxOptions {
|
|
12
|
+
/** 为 true 时铺满父容器(父级需有明确高度) */
|
|
13
|
+
fill?: boolean;
|
|
14
|
+
width?: number;
|
|
15
|
+
height?: number;
|
|
16
|
+
defaultWidth: number;
|
|
17
|
+
defaultHeight: number;
|
|
18
|
+
}
|
|
19
|
+
export interface UseCanvasBoxResult {
|
|
20
|
+
hostRef: RefObject<HTMLDivElement | null>;
|
|
21
|
+
width: number;
|
|
22
|
+
height: number;
|
|
23
|
+
/** 挂到宿主容器的样式(fill 时为 100%×100%) */
|
|
24
|
+
hostStyle: CSSProperties;
|
|
25
|
+
fill: boolean;
|
|
26
|
+
/** 是否处于 fill 模式且尚未量到有效尺寸 */
|
|
27
|
+
pending: boolean;
|
|
28
|
+
}
|
|
29
|
+
/** 画布/效果宿主尺寸:fill 时跟随父容器,否则用显式宽高或默认值 */
|
|
30
|
+
export declare const useCanvasBox: ({ fill, width: widthProp, height: heightProp, defaultWidth, defaultHeight, }: UseCanvasBoxOptions) => UseCanvasBoxResult;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from '../../../src/components/weatherBackground/core';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from '../../../src/components/weatherBackground/element';
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
export { default } from '../../../src/components/weatherBackground';
|
|
2
|
+
export { default as WeatherBackground } from '../../../src/components/weatherBackground';
|
|
3
|
+
export type * from '../../../src/components/weatherBackground';
|
|
4
|
+
export { formatLocalHm, mapWmoCodeToWeatherType, useLiveWeather, useSunTimes, } from '../../../src/components/weatherBackground/live-weather';
|
|
5
|
+
export type { LiveWeatherCoords, LiveWeatherState, LiveWeatherStatus, OpenMeteoCurrent, } from '../../../src/components/weatherBackground/live-weather';
|
|
6
|
+
export { DEFAULT_FOG_LEVEL, FOG_LEVEL_LABELS, clampFogLevel, fogBankAlphaScale, fogLevelFromVisibility, fogLevelFromWmo, formatFogLevel, intensifyFogConfig, supportsFogLevel, } from '../../../src/components/weatherBackground/fog';
|
|
7
|
+
export type { FogLevel } from '../../../src/components/weatherBackground/fog';
|
|
8
|
+
export { DEFAULT_HAIL_LEVEL, HAIL_LEVEL_LABELS, clampHailLevel, formatHailLevel, hailLevelFromWmo, hailSpec, supportsHailLevel, } from '../../../src/components/weatherBackground/hail-level';
|
|
9
|
+
export type { HailIntensitySpec, HailLevel, } from '../../../src/components/weatherBackground/hail-level';
|
|
10
|
+
export { DEFAULT_SMOG_LEVEL, SMOG_LEVEL_LABELS, clampSmogLevel, formatSmogLevel, intensifySmogConfig, smogBankAlphaScale, smogLevelFromVisibility, supportsSmogLevel, } from '../../../src/components/weatherBackground/smog';
|
|
11
|
+
export type { SmogLevel } from '../../../src/components/weatherBackground/smog';
|
|
12
|
+
export { DEFAULT_RAIN_LEVEL, DEFAULT_SNOW_LEVEL, MAX_PRECIP_LEVEL, MIN_PRECIP_LEVEL, RAIN_LEVEL_LABELS, SNOW_LEVEL_LABELS, clampPrecipLevel, formatPrecipLevel, intensifyRainConfig, intensifySnowCount, isRainWeather, isSnowWeather, normalizeWeatherType, precipBand, precipLabel, rainLevelFromWeather, rainLevelFromWmo, resolveSceneWeather, snowLevelFromWeather, snowLevelFromWmo, supportsRainLevel, supportsSnowLevel, } from '../../../src/components/weatherBackground/precipitation';
|
|
13
|
+
export type { PrecipLevel } from '../../../src/components/weatherBackground/precipitation';
|
|
14
|
+
export { DEFAULT_WIND_LEVEL, buildWindMotion, kmhToWindLevel, sampleWindField, visualWindLevel, windLevelToKmh, windStreakSpec, } from '../../../src/components/weatherBackground/wind';
|
|
15
|
+
export type { WindFieldSample, WindMotion } from '../../../src/components/weatherBackground/wind';
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
export { default } from '../../../src/components/weatherBackground/react';
|
|
2
|
+
export { default as WeatherBackground } from '../../../src/components/weatherBackground/react';
|
|
3
|
+
export type * from '../../../src/components/weatherBackground/core/types';
|
|
4
|
+
export { formatLocalHm, mapWmoCodeToWeatherType, useLiveWeather, useSunTimes, } from '../../../src/components/weatherBackground/live-weather';
|
|
5
|
+
export type { LiveWeatherCoords, LiveWeatherState, LiveWeatherStatus, OpenMeteoCurrent, } from '../../../src/components/weatherBackground/live-weather';
|
|
6
|
+
export { DEFAULT_FOG_LEVEL, FOG_LEVEL_LABELS, clampFogLevel, fogBankAlphaScale, fogLevelFromVisibility, fogLevelFromWmo, formatFogLevel, intensifyFogConfig, supportsFogLevel, } from '../../../src/components/weatherBackground/fog';
|
|
7
|
+
export type { FogLevel } from '../../../src/components/weatherBackground/fog';
|
|
8
|
+
export { DEFAULT_HAIL_LEVEL, HAIL_LEVEL_LABELS, clampHailLevel, formatHailLevel, hailLevelFromWmo, hailSpec, supportsHailLevel, } from '../../../src/components/weatherBackground/hail-level';
|
|
9
|
+
export type { HailIntensitySpec, HailLevel, } from '../../../src/components/weatherBackground/hail-level';
|
|
10
|
+
export { DEFAULT_SMOG_LEVEL, SMOG_LEVEL_LABELS, clampSmogLevel, formatSmogLevel, intensifySmogConfig, smogBankAlphaScale, smogLevelFromVisibility, supportsSmogLevel, } from '../../../src/components/weatherBackground/smog';
|
|
11
|
+
export type { SmogLevel } from '../../../src/components/weatherBackground/smog';
|
|
12
|
+
export { DEFAULT_RAIN_LEVEL, DEFAULT_SNOW_LEVEL, MAX_PRECIP_LEVEL, MIN_PRECIP_LEVEL, RAIN_LEVEL_LABELS, SNOW_LEVEL_LABELS, clampPrecipLevel, formatPrecipLevel, intensifyRainConfig, intensifySnowCount, isRainWeather, isSnowWeather, normalizeWeatherType, precipBand, precipLabel, rainLevelFromWeather, rainLevelFromWmo, resolveSceneWeather, snowLevelFromWeather, snowLevelFromWmo, supportsRainLevel, supportsSnowLevel, } from '../../../src/components/weatherBackground/precipitation';
|
|
13
|
+
export type { PrecipLevel } from '../../../src/components/weatherBackground/precipitation';
|
|
14
|
+
export { DEFAULT_WIND_LEVEL, buildWindMotion, kmhToWindLevel, sampleWindField, visualWindLevel, windLevelToKmh, windStreakSpec, } from '../../../src/components/weatherBackground/wind';
|
|
15
|
+
export type { WindFieldSample, WindMotion } from '../../../src/components/weatherBackground/wind';
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { WeatherConfig, WeatherType } from './types';
|
|
2
|
+
export declare const CONFIGS: Record<WeatherType, WeatherConfig>;
|
|
3
|
+
/** 夜间天空渐变与可见星星数量(云越多星越少) */
|
|
4
|
+
export declare const NIGHT_CONFIGS: Record<WeatherType, {
|
|
5
|
+
sky: [string, string];
|
|
6
|
+
stars: number;
|
|
7
|
+
}>;
|
|
8
|
+
/** 夜间云色:整体压暗并偏冷蓝 */
|
|
9
|
+
export declare const toNightCloudColor: ([r, g, b]: [number, number, number]) => [number, number, number];
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
export { createWeatherBackground } from './engine';
|
|
2
|
+
export type { WeatherBackgroundController, WeatherBackgroundOptions, WeatherBackgroundProps, WeatherType, } from './types';
|
|
3
|
+
export { fetchLiveWeather, fetchSunTimes, formatLocalHm, getDayCycleTimesFromLive, IDLE_LIVE_WEATHER, isValidCoords, mapWmoCodeToWeatherType, subscribeLiveWeather, subscribeSunTimes, } from '../live-weather-core';
|
|
4
|
+
export type { LiveWeatherCoords, LiveWeatherState, LiveWeatherStatus, OpenMeteoCurrent, } from '../live-weather-core';
|
|
5
|
+
export { DEFAULT_FOG_LEVEL, FOG_LEVEL_LABELS, clampFogLevel, fogBankAlphaScale, fogLevelFromVisibility, fogLevelFromWmo, formatFogLevel, intensifyFogConfig, supportsFogLevel, } from '../fog';
|
|
6
|
+
export type { FogLevel } from '../fog';
|
|
7
|
+
export { DEFAULT_HAIL_LEVEL, HAIL_LEVEL_LABELS, clampHailLevel, formatHailLevel, hailLevelFromWmo, hailSpec, supportsHailLevel, } from '../hail-level';
|
|
8
|
+
export type { HailIntensitySpec, HailLevel } from '../hail-level';
|
|
9
|
+
export { DEFAULT_SMOG_LEVEL, SMOG_LEVEL_LABELS, clampSmogLevel, formatSmogLevel, intensifySmogConfig, smogBankAlphaScale, smogLevelFromVisibility, supportsSmogLevel, } from '../smog';
|
|
10
|
+
export type { SmogLevel } from '../smog';
|
|
11
|
+
export { DEFAULT_RAIN_LEVEL, DEFAULT_SNOW_LEVEL, MAX_PRECIP_LEVEL, MIN_PRECIP_LEVEL, RAIN_LEVEL_LABELS, SNOW_LEVEL_LABELS, clampPrecipLevel, formatPrecipLevel, intensifyRainConfig, intensifySnowCount, isRainWeather, isSnowWeather, normalizeWeatherType, precipBand, precipLabel, rainLevelFromWeather, rainLevelFromWmo, resolveSceneWeather, snowLevelFromWeather, snowLevelFromWmo, supportsRainLevel, supportsSnowLevel, } from '../precipitation';
|
|
12
|
+
export type { PrecipLevel } from '../precipitation';
|
|
13
|
+
export { DEFAULT_WIND_LEVEL, buildWindMotion, kmhToWindLevel, sampleWindField, visualWindLevel, windLevelToKmh, windStreakSpec, } from '../wind';
|
|
14
|
+
export type { WindFieldSample, WindMotion } from '../wind';
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { WeatherBackgroundProps, WeatherType } from '../types';
|
|
2
|
+
export type { WeatherBackgroundProps, WeatherType };
|
|
3
|
+
export type WeatherBackgroundOptions = WeatherBackgroundProps;
|
|
4
|
+
export interface WeatherBackgroundController {
|
|
5
|
+
update(options: Partial<WeatherBackgroundOptions>): void;
|
|
6
|
+
destroy(): void;
|
|
7
|
+
}
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
/** 昼夜太阳/月亮位置与天空色温 —— 按真实日出日落推进 */
|
|
2
|
+
export type RGB = [number, number, number];
|
|
3
|
+
export interface DayCycleTimes {
|
|
4
|
+
/** 当日日出(本地时间戳 ms) */
|
|
5
|
+
sunrise: number;
|
|
6
|
+
/** 当日日落(本地时间戳 ms) */
|
|
7
|
+
sunset: number;
|
|
8
|
+
}
|
|
9
|
+
export interface DayCycleState {
|
|
10
|
+
/** 太阳是否在地平线之上 */
|
|
11
|
+
isDay: boolean;
|
|
12
|
+
/**
|
|
13
|
+
* 当前天体沿东→西弧的进度 0~1。
|
|
14
|
+
* 白天:日出→日落;夜晚:日落→次日日出。
|
|
15
|
+
*/
|
|
16
|
+
arcProgress: number;
|
|
17
|
+
/** 高度代理 0~1(地平线→天顶) */
|
|
18
|
+
elevation: number;
|
|
19
|
+
/**
|
|
20
|
+
* 晨昏余晖强度 0~1:靠近日出/日落越高,深夜为 0。
|
|
21
|
+
* 用于天空暖色与星空淡入。
|
|
22
|
+
*/
|
|
23
|
+
twilight: number;
|
|
24
|
+
}
|
|
25
|
+
/** 无日出日落数据时的本地近似(6:00 / 18:00) */
|
|
26
|
+
export declare const approximateDayCycleTimes: (now?: number) => DayCycleTimes;
|
|
27
|
+
/** 默认演示时刻:下午 14:00;夜间示例可用 02:00 */
|
|
28
|
+
export declare const DEFAULT_SCENE_TIME = "14:00";
|
|
29
|
+
/** 将 `HH:mm` 解析为「今天」本地时间戳;非法格式返回 null */
|
|
30
|
+
export declare const parseTimeString: (time: string, base?: Date) => number | null;
|
|
31
|
+
/** 解析时刻,失败时回退默认 14:00 */
|
|
32
|
+
export declare const resolveSceneTimeMs: (time: string | undefined, base?: Date) => number;
|
|
33
|
+
/**
|
|
34
|
+
* 根据当前时刻与日出日落计算日弧进度。
|
|
35
|
+
* 若 now 在日落之后,夜晚弧延伸到「次日日出」= 今日日出 + 24h(近似)。
|
|
36
|
+
*/
|
|
37
|
+
export declare const computeDayCycle: (nowMs: number, times: DayCycleTimes) => DayCycleState;
|
|
38
|
+
/** 东升西落弧:左侧东 → 右侧西,中间最高 */
|
|
39
|
+
export declare const celestialScreenPosition: (width: number, height: number, arcProgress: number) => {
|
|
40
|
+
x: number;
|
|
41
|
+
y: number;
|
|
42
|
+
};
|
|
43
|
+
/**
|
|
44
|
+
* 按日周期混合天气日/夜天空色。
|
|
45
|
+
* daySky / nightSky 来自 CONFIGS / NIGHT_CONFIGS。
|
|
46
|
+
*/
|
|
47
|
+
export declare const resolveSkyByDayCycle: (daySky: [string, string], nightSky: [string, string], cycle: DayCycleState) => [string, string];
|
|
48
|
+
export declare const buildSkyGradient: (ctx: CanvasRenderingContext2D, height: number, sky: [string, string]) => CanvasGradient;
|
|
49
|
+
/** 近地平线时天体略收小、略淡 */
|
|
50
|
+
export declare const celestialDrawScale: (cycle: DayCycleState) => {
|
|
51
|
+
scale: number;
|
|
52
|
+
alpha: number;
|
|
53
|
+
};
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { WeatherBackgroundOptions } from '../core';
|
|
2
|
+
declare const TAG = "cos-weather-background";
|
|
3
|
+
declare class CosWeatherBackgroundElement extends HTMLElement {
|
|
4
|
+
private ctrl;
|
|
5
|
+
_weather?: WeatherBackgroundOptions['weather'];
|
|
6
|
+
get weather(): WeatherBackgroundOptions['weather'] | undefined;
|
|
7
|
+
set weather(value: WeatherBackgroundOptions['weather']);
|
|
8
|
+
static get observedAttributes(): string[];
|
|
9
|
+
connectedCallback(): void;
|
|
10
|
+
disconnectedCallback(): void;
|
|
11
|
+
attributeChangedCallback(): void;
|
|
12
|
+
}
|
|
13
|
+
export { CosWeatherBackgroundElement, TAG };
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { WeatherConfig, WeatherType } from './types';
|
|
2
|
+
/** 雾浓度:1 薄雾 · 2 中雾 · 3 浓雾(整体偏淡,避免铺满白屏) */
|
|
3
|
+
export type FogLevel = 1 | 2 | 3;
|
|
4
|
+
export declare const DEFAULT_FOG_LEVEL: FogLevel;
|
|
5
|
+
export declare const FOG_LEVEL_LABELS: readonly ["", "薄雾", "中雾", "浓雾"];
|
|
6
|
+
export declare const clampFogLevel: (level: number) => FogLevel;
|
|
7
|
+
export declare const formatFogLevel: (level: number) => string;
|
|
8
|
+
export declare const supportsFogLevel: (weather: WeatherType) => weather is "fog";
|
|
9
|
+
/**
|
|
10
|
+
* 按浓度档调节雾团数量与霾层。
|
|
11
|
+
* 相对旧版整体降一档:新浓雾≈旧中雾,新中雾≈旧薄雾,新薄雾再淡一档。
|
|
12
|
+
*/
|
|
13
|
+
export declare const intensifyFogConfig: (cfg: WeatherConfig, level: number) => WeatherConfig;
|
|
14
|
+
/** 雾团单层透明度倍率(与浓度档配套,减轻叠层发白) */
|
|
15
|
+
export declare const fogBankAlphaScale: (level: number) => number;
|
|
16
|
+
/**
|
|
17
|
+
* Open-Meteo WMO → 雾浓度。
|
|
18
|
+
* 45 雾 → 中雾;48 雾凇雾 → 浓雾。
|
|
19
|
+
*/
|
|
20
|
+
export declare const fogLevelFromWmo: (code: number) => FogLevel | null;
|
|
21
|
+
/**
|
|
22
|
+
* 能见度(米)→ 雾浓度。
|
|
23
|
+
* ≥5km 薄雾 · 1~5km 中雾 · <1km 浓雾
|
|
24
|
+
*/
|
|
25
|
+
export declare const fogLevelFromVisibility: (visibilityMeters: number | null | undefined) => FogLevel | null;
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
/** 冰雹强度:1 细雹 · 2 密雹 · 3 巨雹 */
|
|
2
|
+
export type HailLevel = 1 | 2 | 3;
|
|
3
|
+
export declare const DEFAULT_HAIL_LEVEL: HailLevel;
|
|
4
|
+
export declare const HAIL_LEVEL_LABELS: readonly ["", "细雹", "密雹", "巨雹"];
|
|
5
|
+
export declare const clampHailLevel: (level: number) => HailLevel;
|
|
6
|
+
export declare const formatHailLevel: (level: number) => string;
|
|
7
|
+
export declare const supportsHailLevel: (weather: string) => weather is "hail";
|
|
8
|
+
export interface HailIntensitySpec {
|
|
9
|
+
/** 冰雹粒子数量 */
|
|
10
|
+
count: number;
|
|
11
|
+
/** 半径下限 */
|
|
12
|
+
sizeMin: number;
|
|
13
|
+
/** 半径上限 */
|
|
14
|
+
sizeMax: number;
|
|
15
|
+
/** 下落速度倍率 */
|
|
16
|
+
speedMul: number;
|
|
17
|
+
}
|
|
18
|
+
/** 三档冰雹视觉参数 */
|
|
19
|
+
export declare const hailSpec: (level: number) => HailIntensitySpec;
|
|
20
|
+
/**
|
|
21
|
+
* Open-Meteo WMO → 冰雹强度。
|
|
22
|
+
* 96 雷暴伴冰雹 → 密雹;99 强雷暴伴冰雹 → 巨雹。
|
|
23
|
+
*/
|
|
24
|
+
export declare const hailLevelFromWmo: (code: number) => HailLevel | null;
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
export { default } from './react';
|
|
2
|
+
export { default as WeatherBackground } from './react';
|
|
3
|
+
export type * from './core/types';
|
|
4
|
+
export { formatLocalHm, mapWmoCodeToWeatherType, useLiveWeather, useSunTimes, } from './live-weather';
|
|
5
|
+
export type { LiveWeatherCoords, LiveWeatherState, LiveWeatherStatus, OpenMeteoCurrent, } from './live-weather';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function displaceBolt(x1: number, y1: number, x2: number, y2: number, rough: number, depth: number): [number, number][];
|
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
import { DayCycleTimes } from './day-cycle';
|
|
2
|
+
import { WeatherType } from './types';
|
|
3
|
+
import { FogLevel } from './fog';
|
|
4
|
+
import { HailLevel } from './hail-level';
|
|
5
|
+
import { PrecipLevel } from './precipitation';
|
|
6
|
+
import { SmogLevel } from './smog';
|
|
7
|
+
export interface OpenMeteoCurrent {
|
|
8
|
+
/** Open-Meteo 精简天气码(WMO WW 子集,非完整 4677) */
|
|
9
|
+
weatherCode: number;
|
|
10
|
+
/** 10 米风速(km/h) */
|
|
11
|
+
windSpeed: number;
|
|
12
|
+
/** 是否白天 */
|
|
13
|
+
isDay: boolean;
|
|
14
|
+
latitude: number;
|
|
15
|
+
longitude: number;
|
|
16
|
+
/** 当地时区(IANA,如 Asia/Shanghai),来自 Open-Meteo timezone=auto */
|
|
17
|
+
timezone: string | null;
|
|
18
|
+
/** 观测时刻(当地墙钟 HH:mm) */
|
|
19
|
+
localTime: string | null;
|
|
20
|
+
/** 能见度(米);可能缺失 */
|
|
21
|
+
visibility: number | null;
|
|
22
|
+
/** 实况雨量档 1~10;非雨为 null */
|
|
23
|
+
rainLevel: PrecipLevel | null;
|
|
24
|
+
/** 实况雪量档 1~10;非雪为 null */
|
|
25
|
+
snowLevel: PrecipLevel | null;
|
|
26
|
+
/** 实况雾浓度 1~3;非雾为 null */
|
|
27
|
+
fogLevel: FogLevel | null;
|
|
28
|
+
/** 实况冰雹强度 1~3;非冰雹为 null */
|
|
29
|
+
hailLevel: HailLevel | null;
|
|
30
|
+
/** 实况霾强度 1~3;非霾为 null */
|
|
31
|
+
smogLevel: SmogLevel | null;
|
|
32
|
+
/** 当日日出(ms),来自 Open-Meteo daily */
|
|
33
|
+
sunrise: number | null;
|
|
34
|
+
/** 当日日落(ms),来自 Open-Meteo daily */
|
|
35
|
+
sunset: number | null;
|
|
36
|
+
}
|
|
37
|
+
export type LiveWeatherStatus = 'idle' | 'locating' | 'fetching' | 'success' | 'error';
|
|
38
|
+
export interface LiveWeatherState {
|
|
39
|
+
/** 映射后的组件天气类型,成功前为 null */
|
|
40
|
+
weather: WeatherType | null;
|
|
41
|
+
/** 实况雨量档;非雨天为 null */
|
|
42
|
+
rainLevel: PrecipLevel | null;
|
|
43
|
+
/** 实况雪量档;非雪天为 null */
|
|
44
|
+
snowLevel: PrecipLevel | null;
|
|
45
|
+
/** 实况雾浓度;非雾天为 null */
|
|
46
|
+
fogLevel: FogLevel | null;
|
|
47
|
+
/** 实况冰雹强度;非冰雹为 null */
|
|
48
|
+
hailLevel: HailLevel | null;
|
|
49
|
+
/** 实况霾强度;非霾天为 null */
|
|
50
|
+
smogLevel: SmogLevel | null;
|
|
51
|
+
status: LiveWeatherStatus;
|
|
52
|
+
error: string | null;
|
|
53
|
+
/** Open-Meteo 原始实况数据 */
|
|
54
|
+
current: OpenMeteoCurrent | null;
|
|
55
|
+
}
|
|
56
|
+
/** Open-Meteo / WMO 精简天气码 → WeatherType */
|
|
57
|
+
export declare const mapWmoCodeToWeatherType: (code: number) => WeatherType;
|
|
58
|
+
export declare const IDLE_LIVE_WEATHER: LiveWeatherState;
|
|
59
|
+
export interface LiveWeatherCoords {
|
|
60
|
+
latitude: number;
|
|
61
|
+
longitude: number;
|
|
62
|
+
}
|
|
63
|
+
export declare const isValidCoords: (coords?: LiveWeatherCoords) => coords is LiveWeatherCoords;
|
|
64
|
+
/**
|
|
65
|
+
* 按 IANA 时区取当前当地 HH:mm(用于实况滑块随时钟走动)。
|
|
66
|
+
* 时区无效时回退到 observationLocalTime。
|
|
67
|
+
*/
|
|
68
|
+
export declare const formatLocalHm: (timeZone: string | null | undefined, fallbackHm?: string | null) => string | null;
|
|
69
|
+
/** 从实况结果取出日弧用的日出日落;缺省时返回 null */
|
|
70
|
+
export declare const getDayCycleTimesFromLive: (current: OpenMeteoCurrent | null) => DayCycleTimes | null;
|
|
71
|
+
export declare const fetchLiveWeather: (lat: number, lon: number, signal?: AbortSignal) => Promise<LiveWeatherState>;
|
|
72
|
+
/**
|
|
73
|
+
* 非 Hook 实况订阅:定位 + Open-Meteo。
|
|
74
|
+
* 返回取消函数;失败时 status 为 error。
|
|
75
|
+
*/
|
|
76
|
+
export declare const subscribeLiveWeather: (enabled: boolean, coords: LiveWeatherCoords | undefined, onState: (state: LiveWeatherState) => void) => (() => void);
|
|
77
|
+
/** 拉取指定经纬度当日日出日落(Open-Meteo daily) */
|
|
78
|
+
export declare const fetchSunTimes: (lat: number, lon: number, signal?: AbortSignal) => Promise<DayCycleTimes | null>;
|
|
79
|
+
export declare const subscribeSunTimes: (coords: LiveWeatherCoords | undefined, onTimes: (times: DayCycleTimes | null) => void) => (() => void);
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { DayCycleTimes } from './day-cycle';
|
|
2
|
+
import { LiveWeatherCoords, LiveWeatherState } from './live-weather-core';
|
|
3
|
+
export type { LiveWeatherCoords, LiveWeatherState, LiveWeatherStatus, OpenMeteoCurrent, } from './live-weather-core';
|
|
4
|
+
export { fetchLiveWeather, fetchSunTimes, formatLocalHm, getDayCycleTimesFromLive, IDLE_LIVE_WEATHER, isValidCoords, mapWmoCodeToWeatherType, subscribeLiveWeather, subscribeSunTimes, } from './live-weather-core';
|
|
5
|
+
/**
|
|
6
|
+
* Open-Meteo 实况天气。
|
|
7
|
+
* 传入 coords 时直接按该经纬度查询;未传时使用浏览器定位(需 HTTPS 与用户授权)。
|
|
8
|
+
* 失败时 status 为 error,调用方自行回退。
|
|
9
|
+
*/
|
|
10
|
+
export declare const useLiveWeather: (enabled?: boolean, coords?: LiveWeatherCoords) => LiveWeatherState;
|
|
11
|
+
/**
|
|
12
|
+
* 按经纬度获取当地日出日落,用于 `time` 参数判断昼夜。
|
|
13
|
+
* 未传 coords 或请求失败时不更新(调用方回退 approximateDayCycleTimes)。
|
|
14
|
+
*/
|
|
15
|
+
export declare const useSunTimes: (coords?: LiveWeatherCoords) => DayCycleTimes | null;
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
import { WeatherConfig, WeatherType } from './types';
|
|
2
|
+
/** 雨量/雪量档位:1~10,5~6 为中雨/中雪 */
|
|
3
|
+
export type PrecipLevel = number;
|
|
4
|
+
export declare const MIN_PRECIP_LEVEL = 1;
|
|
5
|
+
export declare const MAX_PRECIP_LEVEL = 10;
|
|
6
|
+
export declare const DEFAULT_RAIN_LEVEL = 5;
|
|
7
|
+
export declare const DEFAULT_SNOW_LEVEL = 5;
|
|
8
|
+
export declare const clampPrecipLevel: (level: number) => number;
|
|
9
|
+
/**
|
|
10
|
+
* 五档强度:
|
|
11
|
+
* 1~2 毛毛 · 3~4 小 · 5~6 中 · 7~8 暴 · 9~10 特大暴
|
|
12
|
+
*/
|
|
13
|
+
export declare const precipBand: (level: number) => 1 | 2 | 3 | 4 | 5;
|
|
14
|
+
export declare const precipLabel: (level: number, kind: "rain" | "snow") => string;
|
|
15
|
+
/** 滑块文案,如 `5 · 中雨` */
|
|
16
|
+
export declare const formatPrecipLevel: (level: number, kind: "rain" | "snow") => string;
|
|
17
|
+
/** @deprecated 请用 precipLabel / formatPrecipLevel */
|
|
18
|
+
export declare const RAIN_LEVEL_LABELS: readonly ["", "毛毛雨", "小雨", "中雨", "暴雨", "特大暴雨"];
|
|
19
|
+
/** @deprecated 请用 precipLabel / formatPrecipLevel */
|
|
20
|
+
export declare const SNOW_LEVEL_LABELS: readonly ["", "毛毛雪", "小雪", "中雪", "暴雪", "特大暴雪"];
|
|
21
|
+
/** 对外展示用天气(小/中/大雨雪 → 雨天/雪天) */
|
|
22
|
+
export declare const normalizeWeatherType: (weather: WeatherType) => WeatherType;
|
|
23
|
+
export declare const isRainWeather: (weather: WeatherType) => weather is "rain" | "lightRain" | "moderateRain" | "heavyRain";
|
|
24
|
+
export declare const isSnowWeather: (weather: WeatherType) => weather is "snow" | "lightSnow" | "moderateSnow" | "heavySnow";
|
|
25
|
+
/** 可调节雨量:雨天 + 雷阵雨 + 雨夹雪 */
|
|
26
|
+
export declare const supportsRainLevel: (weather: WeatherType) => weather is "rain" | "lightRain" | "moderateRain" | "heavyRain" | "thunderstorm" | "sleet";
|
|
27
|
+
/** 可调节雪量:雪天 + 雨夹雪 */
|
|
28
|
+
export declare const supportsSnowLevel: (weather: WeatherType) => weather is "snow" | "lightSnow" | "moderateSnow" | "heavySnow" | "sleet";
|
|
29
|
+
/** 从旧版细分天气类型推断雨量档(映射到 1~10) */
|
|
30
|
+
export declare const rainLevelFromWeather: (weather: WeatherType, fallback?: number) => number;
|
|
31
|
+
/** 从旧版细分天气类型推断雪量档(映射到 1~10) */
|
|
32
|
+
export declare const snowLevelFromWeather: (weather: WeatherType, fallback?: number) => number;
|
|
33
|
+
/**
|
|
34
|
+
* 将对外 weather + 雨/雪量解析为内部 CONFIGS 键(天空/云层)。
|
|
35
|
+
* 粒子密度另由 intensifyRainConfig / intensifySnowCount 按 1~10 连续插值。
|
|
36
|
+
*/
|
|
37
|
+
export declare const resolveSceneWeather: (weather: WeatherType, rainLevel?: number, snowLevel?: number) => WeatherType;
|
|
38
|
+
/** 按 1~10 档连续插值雨丝参数(毛毛雨极淡 → 特大暴雨极密) */
|
|
39
|
+
export declare const intensifyRainConfig: (rain: NonNullable<WeatherConfig["rain"]>, level: number) => NonNullable<WeatherConfig["rain"]>;
|
|
40
|
+
/** 按 1~10 档连续插值雪花数量 */
|
|
41
|
+
export declare const intensifySnowCount: (level: number) => number;
|
|
42
|
+
/**
|
|
43
|
+
* Open-Meteo WMO 码 → 雨量档 1~10;非雨返回 null。
|
|
44
|
+
* 毛毛雨→2,小雨→3,中雨→5,暴雨→8,特大→10
|
|
45
|
+
*/
|
|
46
|
+
export declare const rainLevelFromWmo: (code: number) => number | null;
|
|
47
|
+
/**
|
|
48
|
+
* Open-Meteo WMO 码 → 雪量档 1~10;非雪返回 null。
|
|
49
|
+
* 毛毛雪→2,小雪→3,中雪→5,暴雪→8,特大→10
|
|
50
|
+
*/
|
|
51
|
+
export declare const snowLevelFromWmo: (code: number) => number | null;
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
export type { WeatherBackgroundOptions } from '../core/types';
|
|
2
|
+
declare const WeatherBackground: import('react').ForwardRefExoticComponent<import('packages/weatherBackground/src').WeatherBackgroundProps & import('react').RefAttributes<unknown>>;
|
|
3
|
+
export default WeatherBackground;
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
import { DayCycleState, DayCycleTimes } from '../day-cycle';
|
|
2
|
+
import { HailIntensitySpec } from '../hail-level';
|
|
3
|
+
import { CelestialSprite, FogSprite, SceneState, WeatherConfig, WeatherSceneParams } from '../types';
|
|
4
|
+
export interface WeatherSceneLayout {
|
|
5
|
+
sky: [string, string];
|
|
6
|
+
cloudRgb: [number, number, number];
|
|
7
|
+
cfg: WeatherConfig;
|
|
8
|
+
sunX: number;
|
|
9
|
+
sunY: number;
|
|
10
|
+
sunR: number;
|
|
11
|
+
skyGradient: CanvasGradient;
|
|
12
|
+
celestial: CelestialSprite | null;
|
|
13
|
+
sunSprite: CelestialSprite | null;
|
|
14
|
+
moonSprite: CelestialSprite | null;
|
|
15
|
+
fogSprite: FogSprite | null;
|
|
16
|
+
dayCycleTimes: DayCycleTimes | null;
|
|
17
|
+
dayCycle: DayCycleState | null;
|
|
18
|
+
sceneTimeMs: number;
|
|
19
|
+
liveClock: boolean;
|
|
20
|
+
hailSpec: HailIntensitySpec | null;
|
|
21
|
+
}
|
|
22
|
+
export declare function createSceneState(params: WeatherSceneParams): WeatherSceneLayout & {
|
|
23
|
+
state: SceneState;
|
|
24
|
+
};
|
|
25
|
+
/** 按时刻刷新日弧位置、天空与日/月切换 */
|
|
26
|
+
export declare function applyDayCycleToScene(scene: {
|
|
27
|
+
ctx: CanvasRenderingContext2D;
|
|
28
|
+
width: number;
|
|
29
|
+
height: number;
|
|
30
|
+
activeNight: boolean;
|
|
31
|
+
sky: [string, string];
|
|
32
|
+
skyGradient: CanvasGradient;
|
|
33
|
+
sunX: number;
|
|
34
|
+
sunY: number;
|
|
35
|
+
celestial: CelestialSprite | null;
|
|
36
|
+
sunSprite: CelestialSprite | null;
|
|
37
|
+
moonSprite: CelestialSprite | null;
|
|
38
|
+
dayCycleTimes: DayCycleTimes | null;
|
|
39
|
+
dayCycle: DayCycleState | null;
|
|
40
|
+
sceneTimeMs: number;
|
|
41
|
+
liveClock: boolean;
|
|
42
|
+
cfg: WeatherConfig;
|
|
43
|
+
activeWeather: import('../types').WeatherType;
|
|
44
|
+
}, nowMs?: number): void;
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import { CelestialSprite, FogSprite, SceneState, WeatherConfig, WeatherType } from '../types';
|
|
2
|
+
import { DayCycleState, DayCycleTimes } from '../day-cycle';
|
|
3
|
+
import { HailIntensitySpec } from '../hail-level';
|
|
4
|
+
import { WindFieldSample, WindMotion } from '../wind';
|
|
5
|
+
export interface WeatherSceneRuntime {
|
|
6
|
+
ctx: CanvasRenderingContext2D;
|
|
7
|
+
width: number;
|
|
8
|
+
height: number;
|
|
9
|
+
activeWeather: WeatherType;
|
|
10
|
+
activeNight: boolean;
|
|
11
|
+
sky: [string, string];
|
|
12
|
+
cloudRgb: [number, number, number];
|
|
13
|
+
cfg: WeatherConfig;
|
|
14
|
+
sunX: number;
|
|
15
|
+
sunY: number;
|
|
16
|
+
sunR: number;
|
|
17
|
+
/** 缓存的天空线性渐变 */
|
|
18
|
+
skyGradient: CanvasGradient;
|
|
19
|
+
/** 当前绘制的日/月贴图 */
|
|
20
|
+
celestial: CelestialSprite | null;
|
|
21
|
+
/** 预烘焙太阳(日弧模式下与月亮并存) */
|
|
22
|
+
sunSprite: CelestialSprite | null;
|
|
23
|
+
/** 预烘焙月亮 */
|
|
24
|
+
moonSprite: CelestialSprite | null;
|
|
25
|
+
/** 预渲染的雾团贴图,无雾时为 null */
|
|
26
|
+
fogSprite: FogSprite | null;
|
|
27
|
+
/** 当地日出日落 */
|
|
28
|
+
dayCycleTimes: DayCycleTimes | null;
|
|
29
|
+
dayCycle: DayCycleState | null;
|
|
30
|
+
sceneTimeMs: number;
|
|
31
|
+
liveClock: boolean;
|
|
32
|
+
windMotion: WindMotion;
|
|
33
|
+
/** 本帧全局风场(阵风 + 风向),绘制前更新 */
|
|
34
|
+
windField: WindFieldSample;
|
|
35
|
+
/** 冰雹强度规格;非冰雹为 null */
|
|
36
|
+
hailSpec: HailIntensitySpec | null;
|
|
37
|
+
state: SceneState;
|
|
38
|
+
}
|