@cos-design/weather-background 3.5.6 → 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/{index.js → core/index.js} +354 -384
- 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/react/index.js +1571 -0
- 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
|
@@ -1,8 +1,6 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
import './index.css';//#region src/components/weatherBackground/day-cycle.ts
|
|
5
|
-
var u = (e) => Math.min(1, Math.max(0, e)), d = (e) => {
|
|
1
|
+
import { applyCanvasHostBox as e, bindPrefersReducedMotion as t, bindVisibilityPause as n, observeElementSize as r, prefersReducedMotion as i, resolveCanvasBoxSize as a } from "@cos-design/shared";
|
|
2
|
+
//#region src/components/weatherBackground/day-cycle.ts
|
|
3
|
+
var o = (e) => Math.min(1, Math.max(0, e)), s = (e) => {
|
|
6
4
|
let t = e.replace("#", "").trim(), n = t.length === 3 ? t.split("").map((e) => e + e).join("") : t;
|
|
7
5
|
if (n.length !== 6) return [
|
|
8
6
|
80,
|
|
@@ -19,17 +17,17 @@ var u = (e) => Math.min(1, Math.max(0, e)), d = (e) => {
|
|
|
19
17
|
r >> 8 & 255,
|
|
20
18
|
r & 255
|
|
21
19
|
];
|
|
22
|
-
},
|
|
20
|
+
}, c = ([e, t, n]) => {
|
|
23
21
|
let r = (e) => Math.min(255, Math.max(0, Math.round(e))).toString(16).padStart(2, "0");
|
|
24
22
|
return `#${r(e)}${r(t)}${r(n)}`;
|
|
25
|
-
},
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
],
|
|
30
|
-
let t =
|
|
23
|
+
}, l = (e, t, n) => e + (t - e) * n, u = (e, t, n) => [
|
|
24
|
+
l(e[0], t[0], n),
|
|
25
|
+
l(e[1], t[1], n),
|
|
26
|
+
l(e[2], t[2], n)
|
|
27
|
+
], d = (e, t, n) => c(u(s(e), s(t), o(n))), f = (e) => {
|
|
28
|
+
let t = o(e);
|
|
31
29
|
return t * t * (3 - 2 * t);
|
|
32
|
-
},
|
|
30
|
+
}, p = (e = Date.now()) => {
|
|
33
31
|
let t = new Date(e), n = new Date(t);
|
|
34
32
|
n.setHours(6, 0, 0, 0);
|
|
35
33
|
let r = new Date(t);
|
|
@@ -37,52 +35,52 @@ var u = (e) => Math.min(1, Math.max(0, e)), d = (e) => {
|
|
|
37
35
|
sunrise: n.getTime(),
|
|
38
36
|
sunset: r.getTime()
|
|
39
37
|
};
|
|
40
|
-
},
|
|
38
|
+
}, m = (e, t = /* @__PURE__ */ new Date()) => {
|
|
41
39
|
let n = e.trim().match(/^(\d{1,2}):(\d{2})$/);
|
|
42
40
|
if (!n) return null;
|
|
43
41
|
let r = Number(n[1]), i = Number(n[2]);
|
|
44
42
|
if (r < 0 || r > 23 || i < 0 || i > 59) return null;
|
|
45
43
|
let a = new Date(t);
|
|
46
44
|
return a.setHours(r, i, 0, 0), a.getTime();
|
|
47
|
-
},
|
|
45
|
+
}, h = (e, t = /* @__PURE__ */ new Date()) => m(e ?? "14:00", t) ?? m("14:00", t), g = (e, t) => {
|
|
48
46
|
let { sunrise: n, sunset: r } = t;
|
|
49
47
|
if (!(r > n)) {
|
|
50
|
-
let t =
|
|
48
|
+
let t = p(e);
|
|
51
49
|
n = t.sunrise, r = t.sunset;
|
|
52
50
|
}
|
|
53
|
-
let i = Math.max(1, r - n), a = n + 1440 * 60 * 1e3,
|
|
54
|
-
if (
|
|
51
|
+
let i = Math.max(1, r - n), a = n + 1440 * 60 * 1e3, s = r - 1440 * 60 * 1e3, c = e >= n && e < r, l;
|
|
52
|
+
if (c) l = o((e - n) / i);
|
|
55
53
|
else if (e >= r) {
|
|
56
54
|
let t = Math.max(1, a - r);
|
|
57
|
-
|
|
55
|
+
l = o((e - r) / t);
|
|
58
56
|
} else {
|
|
59
|
-
let t = Math.max(1, n -
|
|
60
|
-
|
|
57
|
+
let t = Math.max(1, n - s);
|
|
58
|
+
l = o((e - s) / t);
|
|
61
59
|
}
|
|
62
|
-
let
|
|
60
|
+
let u = c ? Math.sin(Math.PI * l) : 0, d = Math.abs(e - n), f = Math.abs(e - r), m = o(1 - Math.min(d, f) / 45e5);
|
|
63
61
|
return {
|
|
64
|
-
isDay:
|
|
65
|
-
arcProgress:
|
|
66
|
-
elevation:
|
|
67
|
-
twilight:
|
|
62
|
+
isDay: c,
|
|
63
|
+
arcProgress: l,
|
|
64
|
+
elevation: u,
|
|
65
|
+
twilight: m
|
|
68
66
|
};
|
|
69
|
-
},
|
|
70
|
-
let r =
|
|
67
|
+
}, _ = (e, t, n) => {
|
|
68
|
+
let r = o(n), i = Math.sin(Math.PI * r);
|
|
71
69
|
return {
|
|
72
70
|
x: e * (.1 + .8 * r),
|
|
73
71
|
y: t * (.58 - .4 * i)
|
|
74
72
|
};
|
|
75
|
-
},
|
|
73
|
+
}, v = "#e8895c", y = "#f3c98a", b = "#2a1f4a", x = "#c4784a", S = (e, t, n) => {
|
|
76
74
|
if (n.isDay) {
|
|
77
|
-
let t =
|
|
78
|
-
return [
|
|
75
|
+
let t = f(n.elevation), r = (1 - t) * .72;
|
|
76
|
+
return [d(d(e[0], v, r), "#1a2438", (1 - t) * .12), d(d(e[1], y, r * .85), "#3a4558", (1 - t) * .08)];
|
|
79
77
|
}
|
|
80
78
|
let r = n.twilight;
|
|
81
|
-
return [
|
|
82
|
-
},
|
|
79
|
+
return [d(t[0], d(b, v, .35), r * .55), d(t[1], d(x, y, .4), r * .7)];
|
|
80
|
+
}, C = (e, t, n) => {
|
|
83
81
|
let r = e.createLinearGradient(0, 0, 0, t);
|
|
84
82
|
return r.addColorStop(0, n[0]), r.addColorStop(1, n[1]), r;
|
|
85
|
-
},
|
|
83
|
+
}, w = (e) => {
|
|
86
84
|
if (!e.isDay) return {
|
|
87
85
|
scale: .92 + e.twilight * .06,
|
|
88
86
|
alpha: .75 + e.twilight * .2
|
|
@@ -92,16 +90,16 @@ var u = (e) => Math.min(1, Math.max(0, e)), d = (e) => {
|
|
|
92
90
|
scale: .82 + t * .22,
|
|
93
91
|
alpha: .65 + t * .35
|
|
94
92
|
};
|
|
95
|
-
},
|
|
93
|
+
}, T = 2, E = [
|
|
96
94
|
"",
|
|
97
95
|
"薄雾",
|
|
98
96
|
"中雾",
|
|
99
97
|
"浓雾"
|
|
100
|
-
],
|
|
101
|
-
let t =
|
|
102
|
-
return `${t} · ${
|
|
103
|
-
},
|
|
104
|
-
let n =
|
|
98
|
+
], D = (e) => Math.min(3, Math.max(1, Math.round(e))), O = (e) => {
|
|
99
|
+
let t = D(e);
|
|
100
|
+
return `${t} · ${E[t]}`;
|
|
101
|
+
}, ee = (e) => e === "fog", te = (e, t) => {
|
|
102
|
+
let n = D(t);
|
|
105
103
|
return n === 1 ? {
|
|
106
104
|
...e,
|
|
107
105
|
fogBanks: 3,
|
|
@@ -121,19 +119,19 @@ var u = (e) => Math.min(1, Math.max(0, e)), d = (e) => {
|
|
|
121
119
|
cloudAlpha: .32,
|
|
122
120
|
sun: "dim"
|
|
123
121
|
};
|
|
124
|
-
},
|
|
125
|
-
let t =
|
|
122
|
+
}, ne = (e) => {
|
|
123
|
+
let t = D(e);
|
|
126
124
|
return t === 1 ? .45 : t === 3 ? .95 : .65;
|
|
127
|
-
},
|
|
125
|
+
}, k = (e) => e === 45 ? 2 : e === 48 ? 3 : null, A = (e) => e == null || !Number.isFinite(e) ? null : e >= 5e3 ? 1 : e >= 1e3 ? 2 : 3, j = 2, M = [
|
|
128
126
|
"",
|
|
129
127
|
"细雹",
|
|
130
128
|
"密雹",
|
|
131
129
|
"巨雹"
|
|
132
|
-
],
|
|
133
|
-
let t =
|
|
134
|
-
return `${t} · ${
|
|
135
|
-
},
|
|
136
|
-
let t =
|
|
130
|
+
], N = (e) => Math.min(3, Math.max(1, Math.round(e))), re = (e) => {
|
|
131
|
+
let t = N(e);
|
|
132
|
+
return `${t} · ${M[t]}`;
|
|
133
|
+
}, ie = (e) => e === "hail", ae = (e) => {
|
|
134
|
+
let t = N(e);
|
|
137
135
|
return t === 1 ? {
|
|
138
136
|
count: 75,
|
|
139
137
|
sizeMin: .85,
|
|
@@ -150,37 +148,37 @@ var u = (e) => Math.min(1, Math.max(0, e)), d = (e) => {
|
|
|
150
148
|
sizeMax: 3.8,
|
|
151
149
|
speedMul: 1
|
|
152
150
|
};
|
|
153
|
-
},
|
|
154
|
-
let t =
|
|
151
|
+
}, P = (e) => e === 96 ? 2 : e === 99 ? 3 : null, oe = 1, se = 10, ce = 5, le = 5, F = (e) => Math.min(10, Math.max(1, Math.round(e))), I = (e, t, n) => e + (t - e) * n, L = (e) => {
|
|
152
|
+
let t = F(e);
|
|
155
153
|
return t <= 2 ? 1 : t <= 4 ? 2 : t <= 6 ? 3 : t <= 8 ? 4 : 5;
|
|
156
|
-
},
|
|
154
|
+
}, R = [
|
|
157
155
|
"毛毛雨",
|
|
158
156
|
"小雨",
|
|
159
157
|
"中雨",
|
|
160
158
|
"暴雨",
|
|
161
159
|
"特大暴雨"
|
|
162
|
-
],
|
|
160
|
+
], z = [
|
|
163
161
|
"毛毛雪",
|
|
164
162
|
"小雪",
|
|
165
163
|
"中雪",
|
|
166
164
|
"暴雪",
|
|
167
165
|
"特大暴雪"
|
|
168
|
-
],
|
|
169
|
-
let n =
|
|
170
|
-
return (t === "rain" ?
|
|
171
|
-
},
|
|
172
|
-
let n = (
|
|
166
|
+
], B = (e, t) => {
|
|
167
|
+
let n = L(e);
|
|
168
|
+
return (t === "rain" ? R : z)[n - 1];
|
|
169
|
+
}, ue = (e, t) => `${F(e)} · ${B(e, t)}`, de = ["", ...R], fe = ["", ...z], V = (e) => e === "lightRain" || e === "moderateRain" || e === "heavyRain" ? "rain" : e === "lightSnow" || e === "moderateSnow" || e === "heavySnow" ? "snow" : e, pe = (e) => e === "rain" || e === "lightRain" || e === "moderateRain" || e === "heavyRain", me = (e) => e === "snow" || e === "lightSnow" || e === "moderateSnow" || e === "heavySnow", he = (e) => pe(e) || e === "thunderstorm" || e === "sleet", ge = (e) => me(e) || e === "sleet", _e = (e, t = 5) => e === "lightRain" ? 3 : e === "moderateRain" ? 5 : e === "heavyRain" ? 8 : F(t), ve = (e, t = 5) => e === "lightSnow" ? 3 : e === "moderateSnow" ? 5 : e === "heavySnow" ? 8 : F(t), H = (e, t) => t === "rain" ? e <= 2 ? "lightRain" : e === 3 ? "moderateRain" : "heavyRain" : e <= 2 ? "lightSnow" : e === 3 ? "moderateSnow" : "heavySnow", ye = (e, t = 5, n = 5) => e === "rain" ? H(L(t), "rain") : e === "lightRain" || e === "moderateRain" || e === "heavyRain" ? H(L(_e(e)), "rain") : e === "snow" ? H(L(n), "snow") : e === "lightSnow" || e === "moderateSnow" || e === "heavySnow" ? H(L(ve(e)), "snow") : e, be = (e, t) => {
|
|
170
|
+
let n = (F(t) - 1) / 9;
|
|
173
171
|
return {
|
|
174
|
-
count: Math.round(
|
|
175
|
-
speed:
|
|
176
|
-
wind:
|
|
177
|
-
alpha:
|
|
178
|
-
splash:
|
|
172
|
+
count: Math.round(I(35, 340, n)),
|
|
173
|
+
speed: I(5.5, 16, n),
|
|
174
|
+
wind: I(-.4, -3.2, n),
|
|
175
|
+
alpha: I(.28, .62, n),
|
|
176
|
+
splash: F(t) >= 5
|
|
179
177
|
};
|
|
180
|
-
},
|
|
181
|
-
let t = (
|
|
182
|
-
return Math.round(
|
|
183
|
-
},
|
|
178
|
+
}, xe = (e) => {
|
|
179
|
+
let t = (F(e) - 1) / 9;
|
|
180
|
+
return Math.round(I(30, 360, t));
|
|
181
|
+
}, Se = (e) => [51, 56].includes(e) ? 2 : [
|
|
184
182
|
61,
|
|
185
183
|
66,
|
|
186
184
|
80
|
|
@@ -190,16 +188,16 @@ var u = (e) => Math.min(1, Math.max(0, e)), d = (e) => {
|
|
|
190
188
|
57,
|
|
191
189
|
63,
|
|
192
190
|
81
|
|
193
|
-
].includes(e) ? 5 : [65, 67].includes(e) ? 8 : [82].includes(e) ? 10 : [95].includes(e) ? 7 : null,
|
|
191
|
+
].includes(e) ? 5 : [65, 67].includes(e) ? 8 : [82].includes(e) ? 10 : [95].includes(e) ? 7 : null, Ce = (e) => [77].includes(e) ? 2 : [71, 85].includes(e) ? 3 : [73].includes(e) ? 5 : [75].includes(e) ? 8 : [86].includes(e) ? 10 : null, we = 2, Te = [
|
|
194
192
|
"",
|
|
195
193
|
"轻霾",
|
|
196
194
|
"中霾",
|
|
197
195
|
"重霾"
|
|
198
|
-
],
|
|
199
|
-
let t =
|
|
200
|
-
return `${t} · ${
|
|
201
|
-
},
|
|
202
|
-
let n =
|
|
196
|
+
], U = (e) => Math.min(3, Math.max(1, Math.round(e))), Ee = (e) => {
|
|
197
|
+
let t = U(e);
|
|
198
|
+
return `${t} · ${Te[t]}`;
|
|
199
|
+
}, W = (e) => e === "smog", De = (e, t) => {
|
|
200
|
+
let n = U(t);
|
|
203
201
|
return n === 1 ? {
|
|
204
202
|
...e,
|
|
205
203
|
fogBanks: 5,
|
|
@@ -219,10 +217,10 @@ var u = (e) => Math.min(1, Math.max(0, e)), d = (e) => {
|
|
|
219
217
|
cloudAlpha: .35,
|
|
220
218
|
sun: "dim"
|
|
221
219
|
};
|
|
222
|
-
},
|
|
223
|
-
let t =
|
|
220
|
+
}, Oe = (e) => {
|
|
221
|
+
let t = U(e);
|
|
224
222
|
return t === 1 ? .55 : t === 3 ? 1.05 : .85;
|
|
225
|
-
},
|
|
223
|
+
}, ke = (e) => e == null || !Number.isFinite(e) ? null : e >= 5e3 ? 1 : e >= 1e3 ? 2 : 3, Ae = {
|
|
226
224
|
0: "sunny",
|
|
227
225
|
1: "sunny",
|
|
228
226
|
2: "partlyCloudy",
|
|
@@ -251,7 +249,7 @@ var u = (e) => Math.min(1, Math.max(0, e)), d = (e) => {
|
|
|
251
249
|
95: "thunderstorm",
|
|
252
250
|
96: "hail",
|
|
253
251
|
99: "hail"
|
|
254
|
-
},
|
|
252
|
+
}, je = (e) => V(Ae[e] ?? "overcast"), G = {
|
|
255
253
|
weather: null,
|
|
256
254
|
rainLevel: null,
|
|
257
255
|
snowLevel: null,
|
|
@@ -261,35 +259,21 @@ var u = (e) => Math.min(1, Math.max(0, e)), d = (e) => {
|
|
|
261
259
|
status: "idle",
|
|
262
260
|
error: null,
|
|
263
261
|
current: null
|
|
264
|
-
},
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
status: "locating",
|
|
272
|
-
error: null,
|
|
273
|
-
current: null
|
|
274
|
-
}, je = {
|
|
275
|
-
weather: null,
|
|
276
|
-
rainLevel: null,
|
|
277
|
-
snowLevel: null,
|
|
278
|
-
fogLevel: null,
|
|
279
|
-
hailLevel: null,
|
|
280
|
-
smogLevel: null,
|
|
281
|
-
status: "fetching",
|
|
282
|
-
error: null,
|
|
283
|
-
current: null
|
|
284
|
-
}, Me = (e) => e != null && Number.isFinite(e.latitude) && Number.isFinite(e.longitude), Q = (e) => {
|
|
262
|
+
}, Me = {
|
|
263
|
+
...G,
|
|
264
|
+
status: "locating"
|
|
265
|
+
}, Ne = {
|
|
266
|
+
...G,
|
|
267
|
+
status: "fetching"
|
|
268
|
+
}, K = (e) => e != null && Number.isFinite(e.latitude) && Number.isFinite(e.longitude), q = (e) => {
|
|
285
269
|
if (typeof e != "string" || !e) return null;
|
|
286
270
|
let t = Date.parse(e);
|
|
287
271
|
return Number.isFinite(t) ? t : null;
|
|
288
|
-
},
|
|
272
|
+
}, Pe = (e) => {
|
|
289
273
|
if (typeof e != "string" || !e) return null;
|
|
290
274
|
let t = e.match(/T(\d{2}):(\d{2})/);
|
|
291
275
|
return t ? `${t[1]}:${t[2]}` : null;
|
|
292
|
-
},
|
|
276
|
+
}, Fe = (e, t) => {
|
|
293
277
|
if (e) try {
|
|
294
278
|
let t = new Intl.DateTimeFormat("en-GB", {
|
|
295
279
|
timeZone: e,
|
|
@@ -300,116 +284,83 @@ var u = (e) => Math.min(1, Math.max(0, e)), d = (e) => {
|
|
|
300
284
|
if (n != null && r != null) return `${n.padStart(2, "0")}:${r.padStart(2, "0")}`;
|
|
301
285
|
} catch {}
|
|
302
286
|
return t ?? null;
|
|
303
|
-
},
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
current: null
|
|
381
|
-
});
|
|
382
|
-
}), () => {
|
|
383
|
-
e = !0;
|
|
384
|
-
}) : (navigator.geolocation.getCurrentPosition(({ coords: t }) => {
|
|
385
|
-
e || (u((e) => ({
|
|
386
|
-
...e,
|
|
387
|
-
status: "fetching"
|
|
388
|
-
})), r(t.latitude, t.longitude));
|
|
389
|
-
}, (t) => {
|
|
390
|
-
e || u({
|
|
391
|
-
weather: null,
|
|
392
|
-
rainLevel: null,
|
|
393
|
-
snowLevel: null,
|
|
394
|
-
fogLevel: null,
|
|
395
|
-
hailLevel: null,
|
|
396
|
-
smogLevel: null,
|
|
397
|
-
status: "error",
|
|
398
|
-
error: t.message || "定位失败",
|
|
399
|
-
current: null
|
|
400
|
-
});
|
|
401
|
-
}, {
|
|
402
|
-
timeout: 1e4,
|
|
403
|
-
maximumAge: 600 * 1e3
|
|
404
|
-
}), () => {
|
|
405
|
-
e = !0, n.abort();
|
|
406
|
-
});
|
|
407
|
-
}, [
|
|
408
|
-
t,
|
|
409
|
-
a,
|
|
410
|
-
o
|
|
411
|
-
]), l;
|
|
412
|
-
}, Ie = async (e, t, n) => {
|
|
287
|
+
}, Ie = (e) => !e?.sunrise || !e?.sunset ? null : {
|
|
288
|
+
sunrise: e.sunrise,
|
|
289
|
+
sunset: e.sunset
|
|
290
|
+
}, J = (e) => ({
|
|
291
|
+
...G,
|
|
292
|
+
status: "error",
|
|
293
|
+
error: e
|
|
294
|
+
}), Le = async (e, t, n) => {
|
|
295
|
+
let r = new URLSearchParams({
|
|
296
|
+
latitude: String(e),
|
|
297
|
+
longitude: String(t),
|
|
298
|
+
current: "weather_code,wind_speed_10m,is_day,visibility",
|
|
299
|
+
daily: "sunrise,sunset",
|
|
300
|
+
timezone: "auto",
|
|
301
|
+
forecast_days: "1"
|
|
302
|
+
}), i = await fetch(`https://api.open-meteo.com/v1/forecast?${r}`, { signal: n });
|
|
303
|
+
if (!i.ok) throw Error(`Open-Meteo 请求失败(HTTP ${i.status})`);
|
|
304
|
+
let a = await i.json(), o = Number(a?.current?.weather_code);
|
|
305
|
+
if (Number.isNaN(o)) throw Error("Open-Meteo 返回数据缺少 weather_code");
|
|
306
|
+
let s = Number(a?.current?.wind_speed_10m ?? 0), c = q(a?.daily?.sunrise?.[0]), l = q(a?.daily?.sunset?.[0]), u = typeof a?.timezone == "string" ? a.timezone : null, d = Pe(a?.current?.time) ?? Fe(u), f = je(o), p = Se(o), m = Ce(o), h = a?.current?.visibility, g = h != null && Number.isFinite(Number(h)) ? Number(h) : null, _ = f === "fog" ? A(g) ?? k(o) ?? 2 : null, v = f === "hail" ? P(o) ?? 2 : null, y = f === "smog" ? ke(g) ?? 2 : null;
|
|
307
|
+
return {
|
|
308
|
+
weather: f,
|
|
309
|
+
rainLevel: p,
|
|
310
|
+
snowLevel: m,
|
|
311
|
+
fogLevel: _,
|
|
312
|
+
hailLevel: v,
|
|
313
|
+
smogLevel: y,
|
|
314
|
+
status: "success",
|
|
315
|
+
error: null,
|
|
316
|
+
current: {
|
|
317
|
+
weatherCode: o,
|
|
318
|
+
windSpeed: s,
|
|
319
|
+
isDay: a?.current?.is_day === 1,
|
|
320
|
+
latitude: e,
|
|
321
|
+
longitude: t,
|
|
322
|
+
timezone: u,
|
|
323
|
+
localTime: d,
|
|
324
|
+
visibility: g,
|
|
325
|
+
rainLevel: p,
|
|
326
|
+
snowLevel: m,
|
|
327
|
+
fogLevel: _,
|
|
328
|
+
hailLevel: v,
|
|
329
|
+
smogLevel: y,
|
|
330
|
+
sunrise: c,
|
|
331
|
+
sunset: l
|
|
332
|
+
}
|
|
333
|
+
};
|
|
334
|
+
}, Re = (e, t, n) => {
|
|
335
|
+
if (!e) return n(G), () => {};
|
|
336
|
+
let r = !1, i = new AbortController(), a = K(t);
|
|
337
|
+
n(a ? Ne : Me);
|
|
338
|
+
let o = async (e, t) => {
|
|
339
|
+
try {
|
|
340
|
+
let a = await Le(e, t, i.signal);
|
|
341
|
+
r || n(a);
|
|
342
|
+
} catch (e) {
|
|
343
|
+
if (r || e instanceof DOMException && e.name === "AbortError") return;
|
|
344
|
+
n(J(e instanceof Error ? e.message : "天气获取失败"));
|
|
345
|
+
}
|
|
346
|
+
};
|
|
347
|
+
return a ? (o(t.latitude, t.longitude), () => {
|
|
348
|
+
r = !0, i.abort();
|
|
349
|
+
}) : typeof navigator > "u" || !navigator.geolocation ? (Promise.resolve().then(() => {
|
|
350
|
+
r || n(J("当前环境不支持定位"));
|
|
351
|
+
}), () => {
|
|
352
|
+
r = !0;
|
|
353
|
+
}) : (navigator.geolocation.getCurrentPosition(({ coords: e }) => {
|
|
354
|
+
r || (n(Ne), o(e.latitude, e.longitude));
|
|
355
|
+
}, (e) => {
|
|
356
|
+
r || n(J(e.message || "定位失败"));
|
|
357
|
+
}, {
|
|
358
|
+
timeout: 1e4,
|
|
359
|
+
maximumAge: 600 * 1e3
|
|
360
|
+
}), () => {
|
|
361
|
+
r = !0, i.abort();
|
|
362
|
+
});
|
|
363
|
+
}, ze = async (e, t, n) => {
|
|
413
364
|
let r = new URLSearchParams({
|
|
414
365
|
latitude: String(e),
|
|
415
366
|
longitude: String(t),
|
|
@@ -418,25 +369,22 @@ var u = (e) => Math.min(1, Math.max(0, e)), d = (e) => {
|
|
|
418
369
|
forecast_days: "1"
|
|
419
370
|
}), i = await fetch(`https://api.open-meteo.com/v1/forecast?${r}`, { signal: n });
|
|
420
371
|
if (!i.ok) return null;
|
|
421
|
-
let a = await i.json(), o =
|
|
372
|
+
let a = await i.json(), o = q(a?.daily?.sunrise?.[0]), s = q(a?.daily?.sunset?.[0]);
|
|
422
373
|
return o == null || s == null ? null : {
|
|
423
374
|
sunrise: o,
|
|
424
375
|
sunset: s
|
|
425
376
|
};
|
|
426
|
-
},
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
};
|
|
438
|
-
}, [i, a]), n ? s : null;
|
|
439
|
-
}, Re = 3, ze = (e) => Math.min(12, Math.max(0, Math.round(e))), Be = (e) => Math.max(0, ze(e) - 2), Ve = .55, He = [
|
|
377
|
+
}, Be = (e, t) => {
|
|
378
|
+
if (!K(e)) return t(null), () => {};
|
|
379
|
+
let n = !1, r = new AbortController();
|
|
380
|
+
return ze(e.latitude, e.longitude, r.signal).then((e) => {
|
|
381
|
+
n || t(e);
|
|
382
|
+
}).catch(() => {
|
|
383
|
+
n || t(null);
|
|
384
|
+
}), () => {
|
|
385
|
+
n = !0, r.abort();
|
|
386
|
+
};
|
|
387
|
+
}, Ve = 3, Y = (e) => Math.min(12, Math.max(0, Math.round(e))), He = (e) => Math.max(0, Y(e) - 2), Ue = .55, We = [
|
|
440
388
|
0,
|
|
441
389
|
3,
|
|
442
390
|
8,
|
|
@@ -450,7 +398,7 @@ var u = (e) => Math.min(1, Math.max(0, e)), d = (e) => {
|
|
|
450
398
|
95,
|
|
451
399
|
110,
|
|
452
400
|
125
|
|
453
|
-
],
|
|
401
|
+
], Ge = [
|
|
454
402
|
1,
|
|
455
403
|
5,
|
|
456
404
|
11,
|
|
@@ -464,8 +412,8 @@ var u = (e) => Math.min(1, Math.max(0, e)), d = (e) => {
|
|
|
464
412
|
102,
|
|
465
413
|
117,
|
|
466
414
|
Infinity
|
|
467
|
-
],
|
|
468
|
-
let i = t.gustiness, a = t.wander, o = n * .0017 + r * .0024, s = e *
|
|
415
|
+
], X = (e, t, n = 0, r = 0) => {
|
|
416
|
+
let i = t.gustiness, a = t.wander, o = n * .0017 + r * .0024, s = e * Ue, c = Math.sin(s * .007 + o), l = Math.sin(s * .021 + 1.37 + o * 1.4), u = Math.sin(s * .055 + 2.8 + o * .6), d = 1 + (.5 * c + .35 * l + .15 * u) * (.25 + i * .75), f = Math.sin(s * .012 + o * .8);
|
|
469
417
|
f > .72 && (d += (f - .72) * (.8 + i * 2.4)), Math.sin(s * .0095 + .6 + o) < -.55 && (d *= .45 + i * .2), d = Math.max(.12, Math.min(2.25, d));
|
|
470
418
|
let p = a * (.55 * Math.sin(s * .0088 + o) + .3 * Math.sin(s * .026 + 1.9 + o * 1.1) + .15 * Math.sin(s * .063 + .4));
|
|
471
419
|
return {
|
|
@@ -474,8 +422,8 @@ var u = (e) => Math.min(1, Math.max(0, e)), d = (e) => {
|
|
|
474
422
|
ux: Math.cos(p),
|
|
475
423
|
uy: Math.sin(p)
|
|
476
424
|
};
|
|
477
|
-
},
|
|
478
|
-
let t =
|
|
425
|
+
}, Z = (e) => {
|
|
426
|
+
let t = Y(e);
|
|
479
427
|
if (t <= 0) return {
|
|
480
428
|
count: 0,
|
|
481
429
|
alphaMul: 0
|
|
@@ -485,12 +433,12 @@ var u = (e) => Math.min(1, Math.max(0, e)), d = (e) => {
|
|
|
485
433
|
count: Math.floor(3 + n * n * 50),
|
|
486
434
|
alphaMul: .1 + n * .9
|
|
487
435
|
};
|
|
488
|
-
},
|
|
436
|
+
}, Q = (e) => We[Y(e)] ?? 16, Ke = (e) => {
|
|
489
437
|
let t = Math.max(0, e);
|
|
490
|
-
for (let e = 0; e <
|
|
438
|
+
for (let e = 0; e < Ge.length; e++) if (t <= Ge[e]) return e;
|
|
491
439
|
return 12;
|
|
492
440
|
}, qe = (e) => {
|
|
493
|
-
let t = Ke(e), n =
|
|
441
|
+
let t = Ke(e), n = He(t), r = Q(n), i = Math.max(.04, Math.min(r / 16, 4.2)), { alphaMul: a } = Z(n), o = i ** .82, s = Math.min(1, (n / 8) ** 1.1), c = (.04 + s * .32) * Math.PI;
|
|
494
442
|
return {
|
|
495
443
|
speedKmh: e,
|
|
496
444
|
level: t,
|
|
@@ -506,7 +454,7 @@ var u = (e) => Math.min(1, Math.max(0, e)), d = (e) => {
|
|
|
506
454
|
gustiness: s,
|
|
507
455
|
wander: c
|
|
508
456
|
};
|
|
509
|
-
}, Je = (e) => e.live && e.liveWindKmh != null && Number.isFinite(e.liveWindKmh) ? Math.max(0, e.liveWindKmh) :
|
|
457
|
+
}, Je = (e) => e.live && e.liveWindKmh != null && Number.isFinite(e.liveWindKmh) ? Math.max(0, e.liveWindKmh) : Q(e.windLevel);
|
|
510
458
|
//#endregion
|
|
511
459
|
//#region src/components/weatherBackground/scene/draw-atmosphere.ts
|
|
512
460
|
function Ye(e) {
|
|
@@ -545,7 +493,7 @@ function $e(e) {
|
|
|
545
493
|
if (n <= .02) return;
|
|
546
494
|
let r = e.state.t;
|
|
547
495
|
for (let i of e.state.windStreaks) {
|
|
548
|
-
let a =
|
|
496
|
+
let a = X(r + i.phase * 18, e.windMotion, i.x, i.y), o = a.intensity * (.55 + .45 * e.windField.intensity), s = a.angle * .65 + e.windField.angle * .35, c = -1 * Math.cos(s), l = Math.sin(s), u = i.speed * t * o;
|
|
549
497
|
i.x += u * c, i.y += u * l * .45, i.wave += .03 + o * .025, (i.x < -i.length - 40 || i.x > e.width + i.length + 40) && (i.x = c < 0 ? e.width + i.length + Math.random() * e.width * .25 : -i.length - Math.random() * e.width * .25, i.y = Math.random() * e.height), i.y < -20 && (i.y = e.height + 10), i.y > e.height + 20 && (i.y = -10);
|
|
550
498
|
let d = 5 + o * 5, f = Math.sin(i.wave) * d, p = i.length * (.85 + o * .2), m = i.x + c * p, h = i.y + l * p * .45, g = i.alpha * n * Math.min(1.35, .55 + o * .55);
|
|
551
499
|
if (e.ctx.beginPath(), e.ctx.moveTo(i.x, i.y), e.ctx.bezierCurveTo(i.x + c * p * .3, i.y + l * p * .3 * .45 + f, i.x + c * p * .7, i.y + l * p * .7 * .45 - f, m, h), e.ctx.strokeStyle = `rgba(235, 244, 250, ${g})`, e.ctx.lineWidth = i.width * (.85 + o * .2), e.ctx.lineCap = "round", e.ctx.stroke(), i.length > 70 && n > .45 && o > .7) {
|
|
@@ -668,7 +616,7 @@ function lt(e) {
|
|
|
668
616
|
--a.delay;
|
|
669
617
|
continue;
|
|
670
618
|
}
|
|
671
|
-
let o =
|
|
619
|
+
let o = X(r + a.phase * 12, e.windMotion, a.x, a.y), s = o.intensity * (.4 + .6 * i.intensity), c = o.angle * .5 + i.angle * .5, l = e.windMotion.snowDrift * .45 * s * Math.cos(c), u = Math.abs(e.windMotion.snowDrift) * s * Math.sin(c) * .2, d = a.x, f = a.y;
|
|
672
620
|
if (a.vy += a.gravity + u * .02, a.vx += a.gust * .004 * n * s + l + (Math.random() - .5) * .08 * n * s, a.x += a.vx + Math.sin(r * .028 + a.phase) * .35, a.y += a.vy, e.ctx.beginPath(), e.ctx.moveTo(d, f), e.ctx.lineTo(a.x, a.y), e.ctx.strokeStyle = `rgba(225, 239, 250, ${a.opacity * .18})`, e.ctx.lineWidth = a.r * .35, e.ctx.stroke(), a.y + a.r >= e.height) if (a.bounces < a.maxBounces) a.y = e.height - a.r, a.vy *= -(.22 + Math.random() * .28), a.vx = a.vx * (.55 + Math.random() * .25) + (Math.random() - .5) * 1.6, a.bounces += 1;
|
|
673
621
|
else {
|
|
674
622
|
at(a, e.width, e.height, t, !0, e.hailSpec ? {
|
|
@@ -701,7 +649,7 @@ function dt(e) {
|
|
|
701
649
|
function ft(e) {
|
|
702
650
|
let t = e.celestial;
|
|
703
651
|
if (!t) return;
|
|
704
|
-
let { ctx: n, sunX: r, sunY: i, state: a } = e, o = 1 + Math.sin(a.t * t.breathSpeed) * t.breathAmp, s = e.dayCycle ?
|
|
652
|
+
let { ctx: n, sunX: r, sunY: i, state: a } = e, o = 1 + Math.sin(a.t * t.breathSpeed) * t.breathAmp, s = e.dayCycle ? w(e.dayCycle) : {
|
|
705
653
|
scale: 1,
|
|
706
654
|
alpha: 1
|
|
707
655
|
}, c = t.half * o * s.scale, l = c * 2;
|
|
@@ -1318,21 +1266,21 @@ var St = (e) => {
|
|
|
1318
1266
|
function Ot(e) {
|
|
1319
1267
|
let { ctx: t, width: n, height: r, activeWeather: i, dayCycleTimes: a = null, sceneTimeMs: o, liveClock: s = !1, windMotion: c, rainLevel: l = 5, snowLevel: u = 5, hailLevel: d = 2, fogLevel: f = 2, smogLevel: p = 2 } = e, m = mt[i], h = (() => {
|
|
1320
1268
|
let e = m;
|
|
1321
|
-
return
|
|
1269
|
+
return he(i) && e.rain && (e = {
|
|
1322
1270
|
...e,
|
|
1323
|
-
rain:
|
|
1324
|
-
}),
|
|
1271
|
+
rain: be(e.rain, l)
|
|
1272
|
+
}), ge(i) && (e = {
|
|
1325
1273
|
...e,
|
|
1326
|
-
snowCount:
|
|
1274
|
+
snowCount: xe(u),
|
|
1327
1275
|
fogBanks: u >= 7 ? Math.max(e.fogBanks, 3) : e.fogBanks,
|
|
1328
1276
|
haze: u >= 7 ? Math.max(e.haze, .12) : e.haze
|
|
1329
|
-
}),
|
|
1330
|
-
})(),
|
|
1331
|
-
if (
|
|
1332
|
-
let e =
|
|
1333
|
-
|
|
1277
|
+
}), ee(i) && (e = te(e, f)), W(i) && (e = De(e, p)), e;
|
|
1278
|
+
})(), v = ht[i], y = a ?? null, b = y ? g(s ? Date.now() : o, y) : null, x = b ? !b.isDay : !1, w = b ? S(h.sky, v.sky, b) : x ? v.sky : h.sky, T = x ? gt(h.cloudColor) : h.cloudColor, E = Math.min(n, r) * .09, D = n * .72, O = r * .26;
|
|
1279
|
+
if (b) {
|
|
1280
|
+
let e = _(n, r, b.arcProgress);
|
|
1281
|
+
D = e.x, O = e.y;
|
|
1334
1282
|
}
|
|
1335
|
-
let
|
|
1283
|
+
let k = C(t, r, w), A = [
|
|
1336
1284
|
{
|
|
1337
1285
|
dx: -.32,
|
|
1338
1286
|
dy: .08,
|
|
@@ -1353,29 +1301,29 @@ function Ot(e) {
|
|
|
1353
1301
|
dy: .24,
|
|
1354
1302
|
r: .07
|
|
1355
1303
|
}
|
|
1356
|
-
],
|
|
1304
|
+
], j = bt(h, E), M = xt(h, E, A), N = x ? M : j, re = x || y != null ? Array.from({ length: v.stars }, () => ({
|
|
1357
1305
|
x: Math.random() * n,
|
|
1358
1306
|
y: Math.random() * r * .72,
|
|
1359
1307
|
r: .4 + Math.random() * 1.1,
|
|
1360
1308
|
phase: Math.random() * Math.PI * 2,
|
|
1361
1309
|
speed: .015 + Math.random() * .035
|
|
1362
|
-
})) : [],
|
|
1310
|
+
})) : [], P = Array.from({ length: h.cloudCount }, () => vt(n, r, h.cloudSpread, T, h.cloudAlpha)), oe = h.rain ? Array.from({ length: h.rain.count }, () => ({
|
|
1363
1311
|
x: Math.random() * (n + 160) - 80,
|
|
1364
1312
|
y: Math.random() * r,
|
|
1365
1313
|
len: 8 + Math.random() * 10,
|
|
1366
1314
|
speed: h.rain.speed * (.75 + Math.random() * .5)
|
|
1367
|
-
})) : [],
|
|
1315
|
+
})) : [], se = [], ce = Array.from({ length: h.fogBanks }, (e, t) => ({
|
|
1368
1316
|
x: Math.random() * n,
|
|
1369
1317
|
y: t / Math.max(h.fogBanks - 1, 1) * r * .9 + r * .05,
|
|
1370
1318
|
rw: n * (.25 + Math.random() * .3),
|
|
1371
1319
|
rh: r * (.08 + Math.random() * .08),
|
|
1372
1320
|
speed: (.1 + Math.random() * .25) * (t % 2 == 0 ? 1 : -1),
|
|
1373
|
-
alpha: (.1 + Math.random() * .1) * (
|
|
1374
|
-
})),
|
|
1375
|
-
min:
|
|
1376
|
-
max:
|
|
1377
|
-
},
|
|
1378
|
-
let { count: e } =
|
|
1321
|
+
alpha: (.1 + Math.random() * .1) * (ee(i) ? ne(f) : W(i) ? Oe(p) : 1)
|
|
1322
|
+
})), le = h.fogBanks > 0 ? yt(Dt(i, x)) : null, F = h.snowCount > 0 ? wt() : null, I = F == null ? [] : Array.from({ length: h.snowCount }, () => Et(n, r, F)), L = ie(i) ? ae(d) : null, R = L == null ? null : rt(), z = R != null && L != null ? Array.from({ length: L.count }, () => ot(n, r, R, {
|
|
1323
|
+
min: L.sizeMin,
|
|
1324
|
+
max: L.sizeMax
|
|
1325
|
+
}, L.speedMul)) : [], B = (() => {
|
|
1326
|
+
let { count: e } = Z(c.visualLevel);
|
|
1379
1327
|
return e <= 0 ? [] : Array.from({ length: e }, () => ({
|
|
1380
1328
|
x: Math.random() * n,
|
|
1381
1329
|
y: Math.random() * r,
|
|
@@ -1386,68 +1334,68 @@ function Ot(e) {
|
|
|
1386
1334
|
width: .5 + Math.random() * 1.1,
|
|
1387
1335
|
phase: Math.random() * Math.PI * 2
|
|
1388
1336
|
}));
|
|
1389
|
-
})(),
|
|
1337
|
+
})(), ue = [], de = 120 + Math.random() * 240;
|
|
1390
1338
|
return {
|
|
1391
|
-
sky:
|
|
1392
|
-
cloudRgb:
|
|
1339
|
+
sky: w,
|
|
1340
|
+
cloudRgb: T,
|
|
1393
1341
|
cfg: h,
|
|
1394
|
-
sunX:
|
|
1395
|
-
sunY:
|
|
1396
|
-
sunR:
|
|
1397
|
-
skyGradient:
|
|
1398
|
-
celestial:
|
|
1399
|
-
sunSprite:
|
|
1400
|
-
moonSprite:
|
|
1401
|
-
fogSprite:
|
|
1402
|
-
dayCycleTimes:
|
|
1403
|
-
dayCycle:
|
|
1342
|
+
sunX: D,
|
|
1343
|
+
sunY: O,
|
|
1344
|
+
sunR: E,
|
|
1345
|
+
skyGradient: k,
|
|
1346
|
+
celestial: N,
|
|
1347
|
+
sunSprite: j,
|
|
1348
|
+
moonSprite: M,
|
|
1349
|
+
fogSprite: le,
|
|
1350
|
+
dayCycleTimes: y,
|
|
1351
|
+
dayCycle: b,
|
|
1404
1352
|
sceneTimeMs: o,
|
|
1405
1353
|
liveClock: s,
|
|
1406
|
-
hailSpec:
|
|
1354
|
+
hailSpec: L,
|
|
1407
1355
|
state: {
|
|
1408
|
-
stars:
|
|
1409
|
-
moonCraters:
|
|
1410
|
-
clouds:
|
|
1411
|
-
drops:
|
|
1412
|
-
splashes:
|
|
1413
|
-
fogBanks:
|
|
1414
|
-
flakes:
|
|
1415
|
-
hailstones:
|
|
1416
|
-
hailPool:
|
|
1417
|
-
windStreaks:
|
|
1356
|
+
stars: re,
|
|
1357
|
+
moonCraters: A,
|
|
1358
|
+
clouds: P,
|
|
1359
|
+
drops: oe,
|
|
1360
|
+
splashes: se,
|
|
1361
|
+
fogBanks: ce,
|
|
1362
|
+
flakes: I,
|
|
1363
|
+
hailstones: z,
|
|
1364
|
+
hailPool: R ?? [],
|
|
1365
|
+
windStreaks: B,
|
|
1418
1366
|
t: 0,
|
|
1419
1367
|
flashAlpha: 0,
|
|
1420
1368
|
boltLife: 0,
|
|
1421
|
-
boltPoints:
|
|
1422
|
-
nextStrike:
|
|
1369
|
+
boltPoints: ue,
|
|
1370
|
+
nextStrike: de
|
|
1423
1371
|
}
|
|
1424
1372
|
};
|
|
1425
1373
|
}
|
|
1426
1374
|
function kt(e, t) {
|
|
1427
1375
|
if (!e.dayCycleTimes) return;
|
|
1428
|
-
let n =
|
|
1429
|
-
e.dayCycle = n, e.activeNight = !n.isDay, e.sky = i, e.skyGradient =
|
|
1376
|
+
let n = g(e.liveClock ? t ?? Date.now() : e.sceneTimeMs, e.dayCycleTimes), r = ht[e.activeWeather], i = S(e.cfg.sky, r.sky, n), a = _(e.width, e.height, n.arcProgress);
|
|
1377
|
+
e.dayCycle = n, e.activeNight = !n.isDay, e.sky = i, e.skyGradient = C(e.ctx, e.height, i), e.sunX = a.x, e.sunY = a.y, e.celestial = n.isDay ? e.sunSprite : e.moonSprite;
|
|
1430
1378
|
}
|
|
1431
1379
|
//#endregion
|
|
1432
1380
|
//#region src/components/weatherBackground/scene/create-weather-scene.ts
|
|
1433
1381
|
function At(e, t) {
|
|
1434
|
-
t && (e.state.t += 1), e.windField =
|
|
1382
|
+
t && (e.state.t += 1), e.windField = X(e.state.t, e.windMotion), e.dayCycleTimes && kt(e, e.liveClock ? Date.now() : e.sceneTimeMs), ut(e), pt(e), Ye(e), Xe(e), Ze(e), st(e), ct(e), lt(e), $e(e), et(e);
|
|
1435
1383
|
}
|
|
1436
1384
|
function jt(e) {
|
|
1437
|
-
let { ctx:
|
|
1438
|
-
ctx:
|
|
1439
|
-
width:
|
|
1440
|
-
height:
|
|
1385
|
+
let { ctx: r, width: a, height: o, activeWeather: s, activeNight: c, windMotion: l } = e, u = Ot(e), d = {
|
|
1386
|
+
ctx: r,
|
|
1387
|
+
width: a,
|
|
1388
|
+
height: o,
|
|
1441
1389
|
activeWeather: s,
|
|
1442
1390
|
activeNight: u.dayCycle ? !u.dayCycle.isDay : c,
|
|
1443
1391
|
windMotion: l,
|
|
1444
|
-
windField:
|
|
1392
|
+
windField: X(0, l),
|
|
1445
1393
|
...u
|
|
1446
1394
|
};
|
|
1447
1395
|
d.dayCycleTimes && kt(d, d.liveClock ? Date.now() : d.sceneTimeMs);
|
|
1448
|
-
let f = document.hidden, p =
|
|
1396
|
+
let f = document.hidden, p = i(), m = n((e) => {
|
|
1449
1397
|
f = e;
|
|
1450
|
-
}), h =
|
|
1398
|
+
}), h = t((e) => {
|
|
1451
1399
|
p = e;
|
|
1452
1400
|
});
|
|
1453
1401
|
if (p) return At(d, !1), () => {
|
|
@@ -1460,98 +1408,120 @@ function jt(e) {
|
|
|
1460
1408
|
cancelAnimationFrame(g), m(), h();
|
|
1461
1409
|
};
|
|
1462
1410
|
}
|
|
1463
|
-
|
|
1464
|
-
|
|
1465
|
-
|
|
1466
|
-
|
|
1467
|
-
|
|
1468
|
-
|
|
1469
|
-
|
|
1470
|
-
|
|
1471
|
-
|
|
1472
|
-
|
|
1473
|
-
|
|
1474
|
-
|
|
1475
|
-
|
|
1476
|
-
|
|
1477
|
-
|
|
1478
|
-
|
|
1479
|
-
|
|
1480
|
-
|
|
1481
|
-
|
|
1482
|
-
|
|
1483
|
-
|
|
1484
|
-
|
|
1485
|
-
|
|
1486
|
-
|
|
1487
|
-
|
|
1488
|
-
|
|
1489
|
-
|
|
1490
|
-
|
|
1491
|
-
|
|
1492
|
-
|
|
1493
|
-
|
|
1494
|
-
|
|
1495
|
-
|
|
1496
|
-
|
|
1497
|
-
|
|
1498
|
-
|
|
1499
|
-
|
|
1500
|
-
|
|
1501
|
-
let
|
|
1502
|
-
|
|
1503
|
-
|
|
1504
|
-
|
|
1505
|
-
|
|
1506
|
-
|
|
1507
|
-
|
|
1508
|
-
|
|
1509
|
-
|
|
1510
|
-
|
|
1511
|
-
|
|
1512
|
-
|
|
1513
|
-
|
|
1514
|
-
|
|
1515
|
-
|
|
1516
|
-
|
|
1411
|
+
//#endregion
|
|
1412
|
+
//#region src/components/weatherBackground/core/engine.ts
|
|
1413
|
+
var $ = "cos-weather-background", Mt = 800, Nt = 450;
|
|
1414
|
+
function Pt(t, n = {}) {
|
|
1415
|
+
let i = {
|
|
1416
|
+
fill: !1,
|
|
1417
|
+
weather: "partlyCloudy",
|
|
1418
|
+
time: "14:00",
|
|
1419
|
+
live: !1,
|
|
1420
|
+
windLevel: 3,
|
|
1421
|
+
rainLevel: 5,
|
|
1422
|
+
snowLevel: 5,
|
|
1423
|
+
hailLevel: 2,
|
|
1424
|
+
fogLevel: 2,
|
|
1425
|
+
smogLevel: 2,
|
|
1426
|
+
loading: !1,
|
|
1427
|
+
loadingText: "天气加载中…",
|
|
1428
|
+
...n
|
|
1429
|
+
}, o = !1, s = i.width ?? Mt, c = i.height ?? Nt, l = null, u = null, d = null, f = G, m = { current: i.onLiveWeather }, _ = document.createElement("div");
|
|
1430
|
+
_.className = $;
|
|
1431
|
+
let v = document.createElement("canvas");
|
|
1432
|
+
v.className = `${$}__canvas`, v.setAttribute("role", "img");
|
|
1433
|
+
let y = document.createElement("div");
|
|
1434
|
+
y.className = `${$}__loading-overlay`, y.setAttribute("role", "status"), y.setAttribute("aria-live", "polite");
|
|
1435
|
+
let b = document.createElement("div");
|
|
1436
|
+
b.className = `${$}__loading-spinner`, b.setAttribute("aria-hidden", "true");
|
|
1437
|
+
let x = document.createElement("span");
|
|
1438
|
+
y.append(b, x), _.append(v, y), t.appendChild(_), y.hidden = !0;
|
|
1439
|
+
let S = () => {
|
|
1440
|
+
e(t, _, {
|
|
1441
|
+
fill: !!i.fill,
|
|
1442
|
+
width: s,
|
|
1443
|
+
height: c
|
|
1444
|
+
}), v.style.width = `${s}px`, v.style.height = `${c}px`;
|
|
1445
|
+
}, C = (e, t, n) => {
|
|
1446
|
+
y.hidden = !(i.loading || i.live && (f.status === "locating" || f.status === "fetching")), x.textContent = i.loadingText ?? "天气加载中…", v.setAttribute("aria-label", i.ariaLabel ?? `天气背景:${e}${t ? "(夜间)" : ""},${n}级风`);
|
|
1447
|
+
}, w = () => {
|
|
1448
|
+
u?.(), u = null;
|
|
1449
|
+
let e = window.devicePixelRatio || 1;
|
|
1450
|
+
v.width = s * e, v.height = c * e;
|
|
1451
|
+
let t = v.getContext("2d");
|
|
1452
|
+
if (!t) return;
|
|
1453
|
+
t.setTransform(e, 0, 0, e, 0, 0);
|
|
1454
|
+
let n = !!i.live, r = V(n && f.weather ? f.weather : i.weather ?? "partlyCloudy"), a = n && f.rainLevel != null ? f.rainLevel : i.rainLevel ?? 5, o = n && f.snowLevel != null ? f.snowLevel : i.snowLevel ?? 5, l = n && f.fogLevel != null ? f.fogLevel : i.fogLevel ?? 2, d = n && f.hailLevel != null ? f.hailLevel : i.hailLevel ?? 2, m = n && f.smogLevel != null ? f.smogLevel : i.smogLevel ?? 2, _ = ye(r, a, o), y = h(i.time), b = f.current?.sunrise ?? null, x = f.current?.sunset ?? null, S = f.current?.windSpeed ?? null, w = n && b != null && x != null ? {
|
|
1455
|
+
sunrise: b,
|
|
1456
|
+
sunset: x
|
|
1457
|
+
} : p(y), T = qe(Je({
|
|
1458
|
+
live: n,
|
|
1459
|
+
windLevel: i.windLevel ?? 3,
|
|
1460
|
+
liveWindKmh: S
|
|
1461
|
+
})), E = n && f.current ? !f.current.isDay : !g(y, w).isDay;
|
|
1462
|
+
C(r, E, T.level), u = jt({
|
|
1463
|
+
ctx: t,
|
|
1464
|
+
width: s,
|
|
1465
|
+
height: c,
|
|
1466
|
+
activeWeather: _,
|
|
1467
|
+
activeNight: E,
|
|
1468
|
+
dayCycleTimes: w,
|
|
1469
|
+
sceneTimeMs: y,
|
|
1470
|
+
liveClock: n,
|
|
1471
|
+
windMotion: T,
|
|
1472
|
+
rainLevel: a,
|
|
1473
|
+
snowLevel: o,
|
|
1474
|
+
fogLevel: l,
|
|
1475
|
+
hailLevel: d,
|
|
1476
|
+
smogLevel: m
|
|
1517
1477
|
});
|
|
1518
|
-
},
|
|
1519
|
-
|
|
1520
|
-
|
|
1521
|
-
|
|
1522
|
-
|
|
1523
|
-
|
|
1524
|
-
|
|
1525
|
-
|
|
1526
|
-
|
|
1527
|
-
|
|
1528
|
-
|
|
1529
|
-
|
|
1530
|
-
|
|
1531
|
-
|
|
1532
|
-
|
|
1533
|
-
|
|
1534
|
-
|
|
1535
|
-
|
|
1536
|
-
|
|
1537
|
-
|
|
1538
|
-
|
|
1539
|
-
|
|
1540
|
-
|
|
1541
|
-
|
|
1542
|
-
}
|
|
1543
|
-
|
|
1544
|
-
|
|
1545
|
-
|
|
1546
|
-
|
|
1547
|
-
|
|
1548
|
-
|
|
1549
|
-
|
|
1550
|
-
|
|
1551
|
-
|
|
1552
|
-
}
|
|
1553
|
-
|
|
1554
|
-
|
|
1555
|
-
|
|
1478
|
+
}, T = () => {
|
|
1479
|
+
if (d?.(), d = null, !i.live) {
|
|
1480
|
+
f = G, w();
|
|
1481
|
+
return;
|
|
1482
|
+
}
|
|
1483
|
+
d = Re(!0, i.latitude != null && i.longitude != null ? {
|
|
1484
|
+
latitude: i.latitude,
|
|
1485
|
+
longitude: i.longitude
|
|
1486
|
+
} : void 0, (e) => {
|
|
1487
|
+
f = e, e.weather && m.current?.(V(e.weather)), w();
|
|
1488
|
+
});
|
|
1489
|
+
}, E = () => {
|
|
1490
|
+
if (l?.(), l = null, !(i.fill ?? !1)) {
|
|
1491
|
+
s = i.width ?? Mt, c = i.height ?? Nt, S(), w();
|
|
1492
|
+
return;
|
|
1493
|
+
}
|
|
1494
|
+
l = r(t, (e) => {
|
|
1495
|
+
let t = a({
|
|
1496
|
+
fill: !0,
|
|
1497
|
+
width: i.width,
|
|
1498
|
+
height: i.height,
|
|
1499
|
+
defaultWidth: Mt,
|
|
1500
|
+
defaultHeight: Nt,
|
|
1501
|
+
measured: e
|
|
1502
|
+
});
|
|
1503
|
+
s = t.width, c = t.height, S(), w();
|
|
1504
|
+
});
|
|
1505
|
+
};
|
|
1506
|
+
return E(), T(), {
|
|
1507
|
+
update(e) {
|
|
1508
|
+
let t = i;
|
|
1509
|
+
i = {
|
|
1510
|
+
...i,
|
|
1511
|
+
...e
|
|
1512
|
+
}, m.current = i.onLiveWeather;
|
|
1513
|
+
let n = t.live !== i.live || t.latitude !== i.latitude || t.longitude !== i.longitude;
|
|
1514
|
+
if (t.fill !== i.fill || t.width !== i.width || t.height !== i.height) E();
|
|
1515
|
+
else if (n) T();
|
|
1516
|
+
else {
|
|
1517
|
+
let e = (e) => JSON.stringify(e, (e, t) => typeof t == "function" ? void 0 : t);
|
|
1518
|
+
e(t) !== e(i) && w();
|
|
1519
|
+
}
|
|
1520
|
+
},
|
|
1521
|
+
destroy() {
|
|
1522
|
+
o || (o = !0, u?.(), d?.(), l?.(), _.remove());
|
|
1523
|
+
}
|
|
1524
|
+
};
|
|
1525
|
+
}
|
|
1556
1526
|
//#endregion
|
|
1557
|
-
export {
|
|
1527
|
+
export { T as DEFAULT_FOG_LEVEL, j as DEFAULT_HAIL_LEVEL, ce as DEFAULT_RAIN_LEVEL, we as DEFAULT_SMOG_LEVEL, le as DEFAULT_SNOW_LEVEL, Ve as DEFAULT_WIND_LEVEL, E as FOG_LEVEL_LABELS, M as HAIL_LEVEL_LABELS, G as IDLE_LIVE_WEATHER, se as MAX_PRECIP_LEVEL, oe as MIN_PRECIP_LEVEL, de as RAIN_LEVEL_LABELS, Te as SMOG_LEVEL_LABELS, fe as SNOW_LEVEL_LABELS, qe as buildWindMotion, D as clampFogLevel, N as clampHailLevel, F as clampPrecipLevel, U as clampSmogLevel, Pt as createWeatherBackground, Le as fetchLiveWeather, ze as fetchSunTimes, ne as fogBankAlphaScale, A as fogLevelFromVisibility, k as fogLevelFromWmo, O as formatFogLevel, re as formatHailLevel, Fe as formatLocalHm, ue as formatPrecipLevel, Ee as formatSmogLevel, Ie as getDayCycleTimesFromLive, P as hailLevelFromWmo, ae as hailSpec, te as intensifyFogConfig, be as intensifyRainConfig, De as intensifySmogConfig, xe as intensifySnowCount, pe as isRainWeather, me as isSnowWeather, K as isValidCoords, Ke as kmhToWindLevel, je as mapWmoCodeToWeatherType, V as normalizeWeatherType, L as precipBand, B as precipLabel, _e as rainLevelFromWeather, Se as rainLevelFromWmo, ye as resolveSceneWeather, X as sampleWindField, Oe as smogBankAlphaScale, ke as smogLevelFromVisibility, ve as snowLevelFromWeather, Ce as snowLevelFromWmo, Re as subscribeLiveWeather, Be as subscribeSunTimes, ee as supportsFogLevel, ie as supportsHailLevel, he as supportsRainLevel, W as supportsSmogLevel, ge as supportsSnowLevel, He as visualWindLevel, Q as windLevelToKmh, Z as windStreakSpec };
|