@azohra/meteo.station 0.5.0 → 0.7.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +17 -17
- package/dist/client/climatology.js +1 -1
- package/dist/client/history.js +3 -11
- package/dist/client/live.d.ts +2 -1
- package/dist/client/live.js +7 -4
- package/dist/client/stores.js +10 -2
- package/dist/climatology.d.ts +1 -1
- package/dist/climatology.js +1 -1
- package/dist/connectivity.d.ts +2 -2
- package/dist/contract.d.ts +98 -98
- package/dist/derive.js +9 -8
- package/dist/elements/elements/AirExtremesElement.js +5 -18
- package/dist/elements/elements/AirMatrixElement.js +6 -31
- package/dist/elements/elements/ClimatologyDailyPatternElement.js +17 -12
- package/dist/elements/elements/ClimatologyRoseElement.js +5 -15
- package/dist/elements/elements/CompassFanElement.js +5 -64
- package/dist/elements/elements/CurrentConditionsElement.js +7 -26
- package/dist/elements/elements/DailyPatternElement.d.ts +0 -1
- package/dist/elements/elements/DailyPatternElement.js +6 -120
- package/dist/elements/elements/DialElement.js +3 -95
- package/dist/elements/elements/FavorableShareElement.js +6 -21
- package/dist/elements/elements/RecentSummariesElement.js +6 -23
- package/dist/elements/elements/SparklineElement.d.ts +0 -1
- package/dist/elements/elements/SparklineElement.js +4 -39
- package/dist/elements/elements/StationCardElement.js +4 -18
- package/dist/elements/elements/StationFeedElement.js +4 -2
- package/dist/elements/elements/StationStripElement.js +4 -18
- package/dist/elements/elements/StationTableElement.js +15 -51
- package/dist/elements/elements/TrendChartElement.js +27 -94
- package/dist/elements/elements/WindHistoryChartElement.js +29 -189
- package/dist/elements/elements/WindRoseElement.d.ts +0 -1
- package/dist/elements/elements/WindRoseElement.js +6 -70
- package/dist/elements/elements/atoms.js +11 -38
- package/dist/elements/index.js +3 -3
- package/dist/elements/lib/fragments.js +8 -37
- package/dist/elements/lib/h.js +1 -1
- package/dist/elements/lib/pinned-cursor.js +48 -0
- package/dist/elements/lib/render.js +30 -0
- package/dist/fixtures.d.ts +6 -2
- package/dist/fixtures.js +30 -2
- package/dist/format.js +7 -3
- package/dist/geometry.d.ts +1 -1
- package/dist/geometry.js +22 -9
- package/dist/instruments.js +2 -2
- package/dist/react/components/AirExtremes.d.ts +1 -1
- package/dist/react/components/AirExtremes.js +5 -22
- package/dist/react/components/AirMatrix.js +10 -43
- package/dist/react/components/ClimatologyDailyPattern.d.ts +1 -1
- package/dist/react/components/ClimatologyDailyPattern.js +19 -13
- package/dist/react/components/ClimatologyRose.d.ts +1 -1
- package/dist/react/components/ClimatologyRose.js +11 -28
- package/dist/react/components/CompassFan.d.ts +1 -1
- package/dist/react/components/CompassFan.js +6 -73
- package/dist/react/components/CurrentConditions.d.ts +1 -1
- package/dist/react/components/CurrentConditions.js +11 -74
- package/dist/react/components/DailyPattern.d.ts +1 -3
- package/dist/react/components/DailyPattern.js +10 -149
- package/dist/react/components/Dial.d.ts +2 -3
- package/dist/react/components/Dial.js +5 -118
- package/dist/react/components/FavorableShare.d.ts +1 -1
- package/dist/react/components/FavorableShare.js +6 -27
- package/dist/react/components/FreshnessBadge.d.ts +1 -1
- package/dist/react/components/FreshnessBadge.js +5 -12
- package/dist/react/components/RecentSummaries.d.ts +1 -1
- package/dist/react/components/RecentSummaries.js +6 -44
- package/dist/react/components/SceneTree.js +38 -0
- package/dist/react/components/Sparkline.d.ts +1 -1
- package/dist/react/components/Sparkline.js +3 -39
- package/dist/react/components/StationCard.d.ts +2 -2
- package/dist/react/components/StationCard.js +5 -45
- package/dist/react/components/StationStrip.d.ts +1 -1
- package/dist/react/components/StationStrip.js +5 -60
- package/dist/react/components/StationTable.js +21 -75
- package/dist/react/components/TrendChart.js +13 -86
- package/dist/react/components/WindArrow.d.ts +1 -1
- package/dist/react/components/WindArrow.js +3 -15
- package/dist/react/components/WindHistoryChart.js +12 -205
- package/dist/react/components/WindRose.d.ts +1 -3
- package/dist/react/components/WindRose.js +6 -89
- package/dist/react/components/WindSampleStrip.js +14 -139
- package/dist/react/components/atoms.d.ts +5 -5
- package/dist/react/components/atoms.js +12 -48
- package/dist/react/hooks/useStation.js +28 -50
- package/dist/react/hooks/useStationCurrent.js +3 -2
- package/dist/react/hooks/useStationFeed.d.ts +0 -1
- package/dist/react/hooks/useStationFeed.js +3 -2
- package/dist/react/index.d.ts +2 -2
- package/dist/react/index.js +7 -7
- package/dist/react/lib/cells.js +4 -24
- package/dist/react/lib/use-pinned-cursor.js +32 -0
- package/dist/samples.js +7 -43
- package/dist/scene/air-extremes.js +12 -27
- package/dist/scene/air-matrix.js +45 -58
- package/dist/scene/card.js +14 -40
- package/dist/scene/cells.d.ts +4 -0
- package/dist/scene/cells.js +51 -0
- package/dist/scene/chart.js +2 -1
- package/dist/scene/climatology-pattern.d.ts +1 -2
- package/dist/scene/climatology-pattern.js +10 -11
- package/dist/scene/climatology-rose.d.ts +1 -2
- package/dist/scene/climatology-rose.js +14 -33
- package/dist/scene/compass-fan.js +28 -100
- package/dist/scene/current.d.ts +2 -1
- package/dist/scene/current.js +29 -56
- package/dist/scene/daily-pattern.d.ts +1 -3
- package/dist/scene/daily-pattern.js +20 -27
- package/dist/scene/dial-parts.d.ts +1 -0
- package/dist/scene/dial-parts.js +70 -0
- package/dist/scene/dial.d.ts +1 -2
- package/dist/scene/dial.js +48 -136
- package/dist/scene/favorable-share.js +16 -33
- package/dist/scene/glyphs.js +20 -16
- package/dist/scene/index.d.ts +5 -3
- package/dist/scene/node.js +19 -0
- package/dist/scene/recent-summaries.js +26 -66
- package/dist/scene/rose.js +89 -117
- package/dist/scene/sample-strip.d.ts +1 -2
- package/dist/scene/sample-strip.js +35 -36
- package/dist/scene/sparkline.js +31 -40
- package/dist/scene/strip.js +18 -57
- package/dist/scene/table.js +47 -69
- package/dist/scene/trend.d.ts +1 -2
- package/dist/scene/trend.js +29 -55
- package/dist/scene/wind-history.d.ts +1 -2
- package/dist/scene/wind-history.js +41 -51
- package/dist/scene/wind-plot.js +70 -140
- package/dist/server/adapters/campbell.d.ts +7 -7
- package/dist/server/adapters/campbell.js +1 -1
- package/dist/server/adapters/ecowitt.d.ts +8 -8
- package/dist/server/adapters/tempest.d.ts +6 -6
- package/dist/server/adapters/windnerd-climatology.js +4 -3
- package/dist/server/adapters/windnerd-live.js +3 -2
- package/dist/server/adapters/windnerd.d.ts +10 -11
- package/dist/server/adapters/windnerd.js +3 -13
- package/dist/server/config.d.ts +48 -48
- package/dist/server/hologram.js +2 -1
- package/dist/server/index.d.ts +2 -2
- package/dist/server/index.js +2 -2
- package/dist/windnerd.d.ts +3 -1
- package/dist/windnerd.js +11 -1
- package/package.json +7 -12
- package/schema/README.md +3 -3
- package/schema/stationclimatology.schema.json +64 -61
- package/schema/stationcurrent.schema.json +68 -156
- package/schema/stationfeed.schema.json +71 -163
- package/schema/stationhistory.schema.json +37 -46
- package/schema/stationlive.schema.json +221 -306
|
@@ -2,9 +2,9 @@
|
|
|
2
2
|
import { resolveDisplay } from "../../display.js";
|
|
3
3
|
import "../../instruments.js";
|
|
4
4
|
import { dialScene } from "../../scene/dial.js";
|
|
5
|
+
import { renderScene } from "./SceneTree.js";
|
|
5
6
|
import { requireResolved, resolveStation, useStationFeedContext } from "./StationFeedProvider.js";
|
|
6
7
|
import { useId } from "react";
|
|
7
|
-
import { Fragment, jsx, jsxs } from "react/jsx-runtime";
|
|
8
8
|
//#region src/react/components/Dial.tsx
|
|
9
9
|
function Dial({ station: stationProp, stationId, thresholds: thresholdsProp, favorableDirections: favorableDirectionsProp, unit: unitProp, size = 160, calmWord = true, strings: stringsProp }) {
|
|
10
10
|
const context = useStationFeedContext();
|
|
@@ -15,8 +15,9 @@ function Dial({ station: stationProp, stationId, thresholds: thresholdsProp, fav
|
|
|
15
15
|
favorableDirections: favorableDirectionsProp,
|
|
16
16
|
unit: unitProp
|
|
17
17
|
});
|
|
18
|
-
const
|
|
19
|
-
|
|
18
|
+
const bezelId = `meteo-bezel-${useId().replace(/[^a-zA-Z0-9_-]/g, "")}`;
|
|
19
|
+
return renderScene(dialScene({
|
|
20
|
+
bezelId,
|
|
20
21
|
calmWord,
|
|
21
22
|
favorableDirections,
|
|
22
23
|
size,
|
|
@@ -24,121 +25,7 @@ function Dial({ station: stationProp, stationId, thresholds: thresholdsProp, fav
|
|
|
24
25
|
thresholds,
|
|
25
26
|
unit,
|
|
26
27
|
words
|
|
27
|
-
});
|
|
28
|
-
const { gradient, centre } = scene;
|
|
29
|
-
return /* @__PURE__ */ jsxs("svg", {
|
|
30
|
-
"aria-label": scene.svg.ariaLabel,
|
|
31
|
-
className: scene.svg.className,
|
|
32
|
-
height: scene.svg.height,
|
|
33
|
-
role: "img",
|
|
34
|
-
viewBox: scene.svg.viewBox,
|
|
35
|
-
width: scene.svg.width,
|
|
36
|
-
children: [
|
|
37
|
-
/* @__PURE__ */ jsx("defs", { children: /* @__PURE__ */ jsx("radialGradient", {
|
|
38
|
-
cx: gradient.cx,
|
|
39
|
-
cy: gradient.cy,
|
|
40
|
-
id: gradient.id,
|
|
41
|
-
r: gradient.r,
|
|
42
|
-
children: gradient.stops.map((stop) => /* @__PURE__ */ jsx("stop", {
|
|
43
|
-
className: stop.className,
|
|
44
|
-
offset: stop.offset
|
|
45
|
-
}, stop.offset))
|
|
46
|
-
}) }),
|
|
47
|
-
/* @__PURE__ */ jsx("circle", {
|
|
48
|
-
className: scene.face.className,
|
|
49
|
-
cx: scene.face.cx,
|
|
50
|
-
cy: scene.face.cy,
|
|
51
|
-
r: scene.face.r
|
|
52
|
-
}),
|
|
53
|
-
/* @__PURE__ */ jsx("circle", {
|
|
54
|
-
className: scene.bezel.className,
|
|
55
|
-
cx: scene.bezel.cx,
|
|
56
|
-
cy: scene.bezel.cy,
|
|
57
|
-
fill: scene.bezel.fill,
|
|
58
|
-
r: scene.bezel.r
|
|
59
|
-
}),
|
|
60
|
-
/* @__PURE__ */ jsx("circle", {
|
|
61
|
-
className: scene.ring.className,
|
|
62
|
-
cx: scene.ring.cx,
|
|
63
|
-
cy: scene.ring.cy,
|
|
64
|
-
r: scene.ring.r
|
|
65
|
-
}),
|
|
66
|
-
scene.verdictRing && /* @__PURE__ */ jsxs(Fragment, { children: [/* @__PURE__ */ jsx("circle", {
|
|
67
|
-
className: scene.verdictRing.unfavorable.className,
|
|
68
|
-
cx: scene.verdictRing.unfavorable.cx,
|
|
69
|
-
cy: scene.verdictRing.unfavorable.cy,
|
|
70
|
-
r: scene.verdictRing.unfavorable.r
|
|
71
|
-
}), scene.verdictRing.favorable.map((arc) => /* @__PURE__ */ jsx("path", {
|
|
72
|
-
className: arc.className,
|
|
73
|
-
d: arc.d
|
|
74
|
-
}, arc.key))] }),
|
|
75
|
-
scene.arc && /* @__PURE__ */ jsx("path", {
|
|
76
|
-
className: scene.arc.className,
|
|
77
|
-
d: scene.arc.d
|
|
78
|
-
}),
|
|
79
|
-
scene.ticks.map((tick) => /* @__PURE__ */ jsx("line", {
|
|
80
|
-
className: tick.className,
|
|
81
|
-
x1: tick.x1,
|
|
82
|
-
x2: tick.x2,
|
|
83
|
-
y1: tick.y1,
|
|
84
|
-
y2: tick.y2
|
|
85
|
-
}, tick.key)),
|
|
86
|
-
scene.letters.map((letter) => /* @__PURE__ */ jsx("text", {
|
|
87
|
-
className: letter.className,
|
|
88
|
-
textAnchor: letter.anchor,
|
|
89
|
-
x: letter.x,
|
|
90
|
-
y: letter.y,
|
|
91
|
-
children: letter.text
|
|
92
|
-
}, letter.key)),
|
|
93
|
-
scene.needle && /* @__PURE__ */ jsxs("g", {
|
|
94
|
-
className: scene.needle.className,
|
|
95
|
-
children: [/* @__PURE__ */ jsx("polygon", {
|
|
96
|
-
className: scene.needle.blade.className,
|
|
97
|
-
points: scene.needle.blade.points
|
|
98
|
-
}), /* @__PURE__ */ jsx("circle", {
|
|
99
|
-
className: scene.needle.counterweight.className,
|
|
100
|
-
cx: scene.needle.counterweight.cx,
|
|
101
|
-
cy: scene.needle.counterweight.cy,
|
|
102
|
-
r: scene.needle.counterweight.r
|
|
103
|
-
})]
|
|
104
|
-
}),
|
|
105
|
-
/* @__PURE__ */ jsx("circle", {
|
|
106
|
-
className: scene.hub.className,
|
|
107
|
-
cx: scene.hub.cx,
|
|
108
|
-
cy: scene.hub.cy,
|
|
109
|
-
r: scene.hub.r
|
|
110
|
-
}),
|
|
111
|
-
centre.kind === "reason" ? /* @__PURE__ */ jsx("text", {
|
|
112
|
-
className: centre.text.className,
|
|
113
|
-
textAnchor: centre.text.anchor,
|
|
114
|
-
x: centre.text.x,
|
|
115
|
-
y: centre.text.y,
|
|
116
|
-
children: centre.text.text
|
|
117
|
-
}) : /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
118
|
-
centre.calmWord && /* @__PURE__ */ jsx("text", {
|
|
119
|
-
className: centre.calmWord.className,
|
|
120
|
-
textAnchor: centre.calmWord.anchor,
|
|
121
|
-
x: centre.calmWord.x,
|
|
122
|
-
y: centre.calmWord.y,
|
|
123
|
-
children: centre.calmWord.text
|
|
124
|
-
}),
|
|
125
|
-
/* @__PURE__ */ jsx("text", {
|
|
126
|
-
className: centre.speed.className,
|
|
127
|
-
textAnchor: centre.speed.anchor,
|
|
128
|
-
x: centre.speed.x,
|
|
129
|
-
y: centre.speed.y,
|
|
130
|
-
children: centre.speed.text
|
|
131
|
-
}),
|
|
132
|
-
/* @__PURE__ */ jsx("text", {
|
|
133
|
-
className: centre.unit.className,
|
|
134
|
-
textAnchor: centre.unit.anchor,
|
|
135
|
-
x: centre.unit.x,
|
|
136
|
-
y: centre.unit.y,
|
|
137
|
-
children: centre.unit.text
|
|
138
|
-
})
|
|
139
|
-
] })
|
|
140
|
-
]
|
|
141
|
-
});
|
|
28
|
+
}));
|
|
142
29
|
}
|
|
143
30
|
//#endregion
|
|
144
31
|
export { Dial };
|
|
@@ -9,6 +9,6 @@ declare function FavorableShare({ station: stationProp, stationId, points, favor
|
|
|
9
9
|
points?: HistoryPoint[];
|
|
10
10
|
favorableDirections?: FavorableDirection[] | null;
|
|
11
11
|
strings?: StationStringOverrides;
|
|
12
|
-
}): import("react").
|
|
12
|
+
}): import("react").ReactNode;
|
|
13
13
|
//#endregion
|
|
14
14
|
export { FavorableShare };
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
import { resolveDisplay } from "../../display.js";
|
|
3
|
-
import {
|
|
3
|
+
import { favorableShareScene, favorableShareSource } from "../../scene/favorable-share.js";
|
|
4
|
+
import { renderOptional } from "./SceneTree.js";
|
|
4
5
|
import { resolveStation, useStationFeedContext } from "./StationFeedProvider.js";
|
|
5
|
-
import { jsx, jsxs } from "react/jsx-runtime";
|
|
6
6
|
//#region src/react/components/FavorableShare.tsx
|
|
7
7
|
function FavorableShare({ station: stationProp, stationId, points, favorableDirections: favorableDirectionsProp, strings: stringsProp }) {
|
|
8
8
|
const context = useStationFeedContext();
|
|
@@ -11,33 +11,12 @@ function FavorableShare({ station: stationProp, stationId, points, favorableDire
|
|
|
11
11
|
strings: stringsProp,
|
|
12
12
|
favorableDirections: favorableDirectionsProp
|
|
13
13
|
});
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
className: gate.className,
|
|
18
|
-
role: "note",
|
|
19
|
-
children: gate.text
|
|
20
|
-
});
|
|
21
|
-
const scene = favorableShareScene({
|
|
22
|
-
share: gate.share,
|
|
14
|
+
return renderOptional(favorableShareScene({
|
|
15
|
+
favorableDirections,
|
|
16
|
+
source: favorableShareSource(points, station),
|
|
23
17
|
stationName: station?.name,
|
|
24
18
|
words
|
|
25
|
-
});
|
|
26
|
-
return /* @__PURE__ */ jsxs("div", {
|
|
27
|
-
"aria-label": scene.ariaLabel,
|
|
28
|
-
className: scene.className,
|
|
29
|
-
children: [
|
|
30
|
-
/* @__PURE__ */ jsx("span", {
|
|
31
|
-
className: scene.label.className,
|
|
32
|
-
children: scene.label.text
|
|
33
|
-
}),
|
|
34
|
-
" ",
|
|
35
|
-
/* @__PURE__ */ jsx("span", {
|
|
36
|
-
className: scene.value.className,
|
|
37
|
-
children: scene.value.text
|
|
38
|
-
})
|
|
39
|
-
]
|
|
40
|
-
});
|
|
19
|
+
}));
|
|
41
20
|
}
|
|
42
21
|
//#endregion
|
|
43
22
|
export { FavorableShare };
|
|
@@ -1,20 +1,13 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
import { resolveDisplay } from "../../display.js";
|
|
3
|
-
import {
|
|
3
|
+
import { freshnessBadgeNode } from "../../scene/glyphs.js";
|
|
4
|
+
import { renderScene } from "./SceneTree.js";
|
|
4
5
|
import { useStationFeedContext } from "./StationFeedProvider.js";
|
|
5
|
-
import { jsx, jsxs } from "react/jsx-runtime";
|
|
6
6
|
//#region src/react/components/FreshnessBadge.tsx
|
|
7
7
|
function FreshnessBadge({ status, strings }) {
|
|
8
|
-
const
|
|
9
|
-
const
|
|
10
|
-
return
|
|
11
|
-
className: spec.className,
|
|
12
|
-
"data-freshness": spec.status,
|
|
13
|
-
children: [/* @__PURE__ */ jsx("span", {
|
|
14
|
-
"aria-hidden": "true",
|
|
15
|
-
className: spec.dot.className
|
|
16
|
-
}), spec.text]
|
|
17
|
-
});
|
|
8
|
+
const context = useStationFeedContext();
|
|
9
|
+
const { words } = resolveDisplay(context, { strings });
|
|
10
|
+
return renderScene(freshnessBadgeNode(status, words));
|
|
18
11
|
}
|
|
19
12
|
//#endregion
|
|
20
13
|
export { FreshnessBadge };
|
|
@@ -13,6 +13,6 @@ declare function RecentSummaries({ summaries, station: stationProp, stationId, f
|
|
|
13
13
|
favorableDirections?: FavorableDirection[] | null;
|
|
14
14
|
unit?: SpeedUnit;
|
|
15
15
|
strings?: StationStringOverrides;
|
|
16
|
-
}): import("react").
|
|
16
|
+
}): import("react").ReactNode;
|
|
17
17
|
//#endregion
|
|
18
18
|
export { RecentSummaries };
|
|
@@ -1,9 +1,8 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
import { resolveDisplay } from "../../display.js";
|
|
3
|
-
import {
|
|
3
|
+
import { recentSummariesScene } from "../../scene/recent-summaries.js";
|
|
4
|
+
import { renderOptional } from "./SceneTree.js";
|
|
4
5
|
import { resolveStation, useStationFeedContext } from "./StationFeedProvider.js";
|
|
5
|
-
import { WindArrow } from "./WindArrow.js";
|
|
6
|
-
import { jsx, jsxs } from "react/jsx-runtime";
|
|
7
6
|
//#region src/react/components/RecentSummaries.tsx
|
|
8
7
|
/** The source's own step digests as summary panels: per window, the
|
|
9
8
|
* average, gust, and lull beside one small arrow per step. */
|
|
@@ -15,50 +14,13 @@ function RecentSummaries({ summaries, station: stationProp, stationId, favorable
|
|
|
15
14
|
favorableDirections: favorableDirectionsProp,
|
|
16
15
|
unit: unitProp
|
|
17
16
|
});
|
|
18
|
-
|
|
19
|
-
if (gate.kind === "hidden") return null;
|
|
20
|
-
if (gate.kind === "note") return /* @__PURE__ */ jsx("div", {
|
|
21
|
-
className: gate.className,
|
|
22
|
-
role: "note",
|
|
23
|
-
children: gate.text
|
|
24
|
-
});
|
|
25
|
-
const scene = recentSummariesScene({
|
|
17
|
+
return renderOptional(recentSummariesScene({
|
|
26
18
|
favorableDirections,
|
|
27
|
-
|
|
28
|
-
summaries
|
|
19
|
+
station,
|
|
20
|
+
summaries,
|
|
29
21
|
unit,
|
|
30
22
|
words
|
|
31
|
-
});
|
|
32
|
-
return /* @__PURE__ */ jsx("div", {
|
|
33
|
-
"aria-label": scene.ariaLabel,
|
|
34
|
-
className: scene.className,
|
|
35
|
-
children: scene.panels.map((panel) => /* @__PURE__ */ jsxs("section", {
|
|
36
|
-
className: panel.className,
|
|
37
|
-
children: [
|
|
38
|
-
/* @__PURE__ */ jsx("h4", {
|
|
39
|
-
className: panel.label.className,
|
|
40
|
-
children: panel.label.text
|
|
41
|
-
}),
|
|
42
|
-
/* @__PURE__ */ jsx("div", {
|
|
43
|
-
className: "meteo-recent-summary-ghosts",
|
|
44
|
-
children: panel.ghosts.map((ghost) => /* @__PURE__ */ jsx("span", {
|
|
45
|
-
className: ghost.className,
|
|
46
|
-
children: /* @__PURE__ */ jsx(WindArrow, { deg: ghost.deg })
|
|
47
|
-
}, ghost.key))
|
|
48
|
-
}),
|
|
49
|
-
/* @__PURE__ */ jsx("dl", {
|
|
50
|
-
className: "meteo-recent-summary-stats",
|
|
51
|
-
children: panel.stats.map((stat) => /* @__PURE__ */ jsxs("div", {
|
|
52
|
-
className: stat.className,
|
|
53
|
-
children: [/* @__PURE__ */ jsx("dt", {
|
|
54
|
-
className: "meteo-microlabel",
|
|
55
|
-
children: stat.label
|
|
56
|
-
}), /* @__PURE__ */ jsx("dd", { children: stat.value })]
|
|
57
|
-
}, stat.key))
|
|
58
|
-
})
|
|
59
|
-
]
|
|
60
|
-
}, panel.key))
|
|
61
|
-
});
|
|
23
|
+
}));
|
|
62
24
|
}
|
|
63
25
|
//#endregion
|
|
64
26
|
export { RecentSummaries };
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import { createElement } from "react";
|
|
2
|
+
//#region src/react/components/SceneTree.tsx
|
|
3
|
+
function reactName(name) {
|
|
4
|
+
if (name === "class") return "className";
|
|
5
|
+
if (name.startsWith("aria-") || name.startsWith("data-") || !name.includes("-")) return name;
|
|
6
|
+
return name.replace(/-([a-z])/g, (_, letter) => letter.toUpperCase());
|
|
7
|
+
}
|
|
8
|
+
function reactProps(node) {
|
|
9
|
+
const props = {};
|
|
10
|
+
for (const [name, value] of Object.entries(node.attrs ?? {})) {
|
|
11
|
+
if (value == null || value === false) continue;
|
|
12
|
+
props[reactName(name)] = value;
|
|
13
|
+
}
|
|
14
|
+
if (node.style !== void 0) props["style"] = node.style;
|
|
15
|
+
if (node.key !== void 0) props["key"] = node.key;
|
|
16
|
+
return props;
|
|
17
|
+
}
|
|
18
|
+
function renderChild(child, index) {
|
|
19
|
+
if (child == null || child === false) return null;
|
|
20
|
+
if (typeof child === "string" || typeof child === "number") return child;
|
|
21
|
+
return renderScene(child, index);
|
|
22
|
+
}
|
|
23
|
+
function renderScene(node, fallbackKey) {
|
|
24
|
+
const props = reactProps(node);
|
|
25
|
+
if (props["key"] === void 0 && fallbackKey !== void 0) props["key"] = fallbackKey;
|
|
26
|
+
const children = node.children ?? [];
|
|
27
|
+
return children.length === 0 ? createElement(node.tag, props) : createElement(node.tag, props, ...children.map(renderChild));
|
|
28
|
+
}
|
|
29
|
+
/** The scene, or nothing when the widget has no surface to draw. */
|
|
30
|
+
function renderOptional(node) {
|
|
31
|
+
return node === null ? null : renderScene(node);
|
|
32
|
+
}
|
|
33
|
+
/** A run of children with no element of their own to sit in. */
|
|
34
|
+
function renderChildren(children) {
|
|
35
|
+
return children.map(renderChild);
|
|
36
|
+
}
|
|
37
|
+
//#endregion
|
|
38
|
+
export { renderChild, renderChildren, renderOptional, renderScene };
|
|
@@ -12,6 +12,6 @@ declare function Sparkline({ station: stationProp, stationId, width, height, sho
|
|
|
12
12
|
thresholds?: SpeedThresholds | null;
|
|
13
13
|
unit?: SpeedUnit;
|
|
14
14
|
strings?: StationStringOverrides;
|
|
15
|
-
}): import("react").
|
|
15
|
+
}): import("react").ReactNode;
|
|
16
16
|
//#endregion
|
|
17
17
|
export { Sparkline };
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
import { resolveDisplay } from "../../display.js";
|
|
3
3
|
import { sparklineScene } from "../../scene/sparkline.js";
|
|
4
|
+
import { renderScene } from "./SceneTree.js";
|
|
4
5
|
import { requireResolved, resolveStation, useStationFeedContext } from "./StationFeedProvider.js";
|
|
5
|
-
import { jsx, jsxs } from "react/jsx-runtime";
|
|
6
6
|
//#region src/react/components/Sparkline.tsx
|
|
7
7
|
function Sparkline({ station: stationProp, stationId, width = 120, height = 32, showBand = true, thresholds: thresholdsProp, strings: stringsProp }) {
|
|
8
8
|
const context = useStationFeedContext();
|
|
@@ -11,50 +11,14 @@ function Sparkline({ station: stationProp, stationId, width = 120, height = 32,
|
|
|
11
11
|
strings: stringsProp,
|
|
12
12
|
thresholds: thresholdsProp
|
|
13
13
|
});
|
|
14
|
-
|
|
14
|
+
return renderScene(sparklineScene({
|
|
15
15
|
height,
|
|
16
16
|
showBand,
|
|
17
17
|
station,
|
|
18
18
|
thresholds,
|
|
19
19
|
width,
|
|
20
20
|
words
|
|
21
|
-
});
|
|
22
|
-
if (scene.kind === "placeholder") return /* @__PURE__ */ jsx("span", {
|
|
23
|
-
"aria-label": scene.ariaLabel,
|
|
24
|
-
className: scene.className,
|
|
25
|
-
role: "img",
|
|
26
|
-
style: {
|
|
27
|
-
height: scene.height,
|
|
28
|
-
width: scene.width
|
|
29
|
-
},
|
|
30
|
-
children: scene.text
|
|
31
|
-
});
|
|
32
|
-
return /* @__PURE__ */ jsxs("svg", {
|
|
33
|
-
"aria-label": scene.svg.ariaLabel,
|
|
34
|
-
className: scene.svg.className,
|
|
35
|
-
height: scene.svg.height,
|
|
36
|
-
role: "img",
|
|
37
|
-
viewBox: scene.svg.viewBox,
|
|
38
|
-
width: scene.svg.width,
|
|
39
|
-
children: [scene.bands.map((band) => /* @__PURE__ */ jsx("polygon", {
|
|
40
|
-
className: band.className,
|
|
41
|
-
points: band.points
|
|
42
|
-
}, band.key)), scene.trace.map((part) => part.kind === "dot" ? /* @__PURE__ */ jsx("circle", {
|
|
43
|
-
className: part.className,
|
|
44
|
-
cx: part.cx,
|
|
45
|
-
cy: part.cy,
|
|
46
|
-
r: part.r
|
|
47
|
-
}, part.key) : part.kind === "polyline" ? /* @__PURE__ */ jsx("polyline", {
|
|
48
|
-
className: part.className,
|
|
49
|
-
points: part.points
|
|
50
|
-
}, part.key) : /* @__PURE__ */ jsx("line", {
|
|
51
|
-
className: part.className,
|
|
52
|
-
x1: part.x1,
|
|
53
|
-
x2: part.x2,
|
|
54
|
-
y1: part.y1,
|
|
55
|
-
y2: part.y2
|
|
56
|
-
}, part.key))]
|
|
57
|
-
});
|
|
21
|
+
}));
|
|
58
22
|
}
|
|
59
23
|
//#endregion
|
|
60
24
|
export { Sparkline };
|
|
@@ -17,7 +17,7 @@ declare function StationCardRoot({ station: stationProp, stationId, servedAt: se
|
|
|
17
17
|
}): import("react").JSX.Element;
|
|
18
18
|
declare function StationCardHeader({ strings }?: {
|
|
19
19
|
strings?: StationStringOverrides;
|
|
20
|
-
}):
|
|
20
|
+
}): ReactNode;
|
|
21
21
|
declare function StationCardInstrument({ thresholds, unit, strings, formatTime }?: {
|
|
22
22
|
thresholds?: SpeedThresholds | null;
|
|
23
23
|
unit?: SpeedUnit;
|
|
@@ -35,7 +35,7 @@ declare function StationCardSummary({ unit, strings, formatTime }?: {
|
|
|
35
35
|
unit?: SpeedUnit;
|
|
36
36
|
strings?: StationStringOverrides;
|
|
37
37
|
formatTime?: FormatTime;
|
|
38
|
-
}):
|
|
38
|
+
}): ReactNode;
|
|
39
39
|
declare const StationCard: typeof StationCardRoot & {
|
|
40
40
|
Header: typeof StationCardHeader;
|
|
41
41
|
Instrument: typeof StationCardInstrument;
|
|
@@ -2,10 +2,10 @@
|
|
|
2
2
|
import { stationFreshnessThresholds } from "../../derive.js";
|
|
3
3
|
import { mergeStringOverrides } from "../../strings.js";
|
|
4
4
|
import { resolveDisplay } from "../../display.js";
|
|
5
|
-
import { STATION_CARD_CLASS,
|
|
5
|
+
import { STATION_CARD_CLASS, cardHeaderNode, cardPartThresholds, cardPartWiringError, summaryNode } from "../../scene/card.js";
|
|
6
|
+
import { renderOptional, renderScene } from "./SceneTree.js";
|
|
6
7
|
import { requireResolved, resolveStation, useStationFeedContext } from "./StationFeedProvider.js";
|
|
7
8
|
import { useFreshness } from "../hooks/useFreshness.js";
|
|
8
|
-
import { FreshnessBadge } from "./FreshnessBadge.js";
|
|
9
9
|
import { CurrentConditions } from "./CurrentConditions.js";
|
|
10
10
|
import { WindHistoryChart } from "./WindHistoryChart.js";
|
|
11
11
|
import { createContext, useContext } from "react";
|
|
@@ -53,37 +53,9 @@ function StationCardRoot({ station: stationProp, stationId, servedAt: servedAtPr
|
|
|
53
53
|
function StationCardHeader({ strings } = {}) {
|
|
54
54
|
const context = useStationCardContext("Header");
|
|
55
55
|
const { station, servedAt, receivedAtMs } = context;
|
|
56
|
-
const {
|
|
56
|
+
const { words } = resolveDisplay(context, { strings });
|
|
57
57
|
const status = useFreshness(station.reading?.observedAt ?? null, servedAt, receivedAtMs, stationFreshnessThresholds(station));
|
|
58
|
-
|
|
59
|
-
const { name, meta } = scene.identity;
|
|
60
|
-
return /* @__PURE__ */ jsxs("header", {
|
|
61
|
-
className: scene.className,
|
|
62
|
-
children: [/* @__PURE__ */ jsxs("div", {
|
|
63
|
-
className: scene.identity.className,
|
|
64
|
-
children: [/* @__PURE__ */ jsx("h3", {
|
|
65
|
-
className: name.className,
|
|
66
|
-
children: name.link ? /* @__PURE__ */ jsx("a", {
|
|
67
|
-
href: name.link.href,
|
|
68
|
-
rel: name.link.rel,
|
|
69
|
-
target: name.link.target,
|
|
70
|
-
children: name.link.text
|
|
71
|
-
}) : name.text
|
|
72
|
-
}), /* @__PURE__ */ jsxs("p", {
|
|
73
|
-
className: meta.className,
|
|
74
|
-
children: [/* @__PURE__ */ jsx("span", {
|
|
75
|
-
className: meta.source.className,
|
|
76
|
-
children: meta.source.text
|
|
77
|
-
}), meta.elevation && /* @__PURE__ */ jsx("span", {
|
|
78
|
-
className: meta.elevation.className,
|
|
79
|
-
children: meta.elevation.text
|
|
80
|
-
})]
|
|
81
|
-
})]
|
|
82
|
-
}), status != null && /* @__PURE__ */ jsx(FreshnessBadge, {
|
|
83
|
-
status,
|
|
84
|
-
strings: resolvedStrings
|
|
85
|
-
})]
|
|
86
|
-
});
|
|
58
|
+
return renderScene(cardHeaderNode(station, status, words));
|
|
87
59
|
}
|
|
88
60
|
function StationCardInstrument({ thresholds, unit, strings, formatTime } = {}) {
|
|
89
61
|
const context = useStationCardContext("Instrument");
|
|
@@ -116,19 +88,7 @@ function StationCardSummary({ unit, strings, formatTime } = {}) {
|
|
|
116
88
|
unit
|
|
117
89
|
});
|
|
118
90
|
const { station } = context;
|
|
119
|
-
|
|
120
|
-
if (summary == null) return null;
|
|
121
|
-
return /* @__PURE__ */ jsx("dl", {
|
|
122
|
-
"aria-label": summary.ariaLabel,
|
|
123
|
-
className: summary.className,
|
|
124
|
-
children: summary.items.map((item) => /* @__PURE__ */ jsxs("div", {
|
|
125
|
-
className: summary.itemClassName,
|
|
126
|
-
children: [/* @__PURE__ */ jsx("dt", {
|
|
127
|
-
className: summary.labelClassName,
|
|
128
|
-
children: item.label
|
|
129
|
-
}), /* @__PURE__ */ jsx("dd", { children: item.value })]
|
|
130
|
-
}, item.label))
|
|
131
|
-
});
|
|
91
|
+
return renderOptional(summaryNode(station, resolvedUnit, words, resolvedFormatTime));
|
|
132
92
|
}
|
|
133
93
|
const StationCard = Object.assign(StationCardRoot, {
|
|
134
94
|
Header: StationCardHeader,
|
|
@@ -11,6 +11,6 @@ declare function StationStrip({ station: stationProp, stationId, servedAt: serve
|
|
|
11
11
|
unit?: SpeedUnit;
|
|
12
12
|
strings?: StationStringOverrides;
|
|
13
13
|
formatTime?: FormatTime;
|
|
14
|
-
}): import("react").
|
|
14
|
+
}): import("react").ReactNode;
|
|
15
15
|
//#endregion
|
|
16
16
|
export { StationStrip };
|
|
@@ -2,83 +2,28 @@
|
|
|
2
2
|
import { stationFreshnessThresholds } from "../../derive.js";
|
|
3
3
|
import { resolveDisplay } from "../../display.js";
|
|
4
4
|
import { stationStripScene } from "../../scene/strip.js";
|
|
5
|
+
import { renderScene } from "./SceneTree.js";
|
|
5
6
|
import { requireResolved, resolveStation, useStationFeedContext } from "./StationFeedProvider.js";
|
|
6
|
-
import { DirectionCell, StationNameLink } from "../lib/cells.js";
|
|
7
7
|
import { useFreshness } from "../hooks/useFreshness.js";
|
|
8
|
-
import { FreshnessBadge } from "./FreshnessBadge.js";
|
|
9
|
-
import { Fragment, jsx, jsxs } from "react/jsx-runtime";
|
|
10
8
|
//#region src/react/components/StationStrip.tsx
|
|
11
9
|
function StationStrip({ station: stationProp, stationId, servedAt: servedAtProp, receivedAtMs: receivedAtMsProp, unit: unitProp, strings: stringsProp, formatTime: formatTimeProp }) {
|
|
12
10
|
const context = useStationFeedContext();
|
|
13
11
|
const station = requireResolved("StationStrip", "station", stationProp ?? resolveStation(context, stationId));
|
|
14
12
|
const servedAt = servedAtProp ?? context?.feed?.servedAt ?? null;
|
|
15
13
|
const receivedAtMs = receivedAtMsProp !== void 0 ? receivedAtMsProp : context?.receivedAtMs ?? null;
|
|
16
|
-
const { formatTime,
|
|
14
|
+
const { formatTime, unit, words } = resolveDisplay(context, {
|
|
17
15
|
formatTime: formatTimeProp,
|
|
18
16
|
strings: stringsProp,
|
|
19
17
|
unit: unitProp
|
|
20
18
|
});
|
|
21
19
|
const status = useFreshness(station.reading?.observedAt ?? null, servedAt, receivedAtMs, stationFreshnessThresholds(station));
|
|
22
|
-
|
|
20
|
+
return renderScene(stationStripScene({
|
|
23
21
|
formatTime,
|
|
22
|
+
freshness: status,
|
|
24
23
|
station,
|
|
25
24
|
unit,
|
|
26
25
|
words
|
|
27
|
-
});
|
|
28
|
-
const { body } = scene;
|
|
29
|
-
return /* @__PURE__ */ jsxs("div", {
|
|
30
|
-
"aria-label": scene.root.ariaLabel,
|
|
31
|
-
className: scene.root.className,
|
|
32
|
-
"data-status": scene.root.status,
|
|
33
|
-
role: "group",
|
|
34
|
-
children: [/* @__PURE__ */ jsx("span", {
|
|
35
|
-
className: scene.stationClassName,
|
|
36
|
-
children: /* @__PURE__ */ jsx(StationNameLink, { station })
|
|
37
|
-
}), body.kind === "reading" ? /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
38
|
-
/* @__PURE__ */ jsxs("span", {
|
|
39
|
-
className: body.wind.className,
|
|
40
|
-
children: [/* @__PURE__ */ jsx("strong", { children: body.wind.value }), /* @__PURE__ */ jsx("small", { children: body.wind.unitLabel })]
|
|
41
|
-
}),
|
|
42
|
-
body.gustLull && /* @__PURE__ */ jsxs(Fragment, { children: [/* @__PURE__ */ jsxs("span", {
|
|
43
|
-
className: body.gustLull.lull.className,
|
|
44
|
-
children: [/* @__PURE__ */ jsx("small", {
|
|
45
|
-
className: body.gustLull.lull.labelClassName,
|
|
46
|
-
children: body.gustLull.lull.label
|
|
47
|
-
}), body.gustLull.lull.value]
|
|
48
|
-
}), /* @__PURE__ */ jsxs("span", {
|
|
49
|
-
className: body.gustLull.gust.className,
|
|
50
|
-
children: [/* @__PURE__ */ jsx("small", {
|
|
51
|
-
className: body.gustLull.gust.labelClassName,
|
|
52
|
-
children: body.gustLull.gust.label
|
|
53
|
-
}), body.gustLull.gust.value]
|
|
54
|
-
})] }),
|
|
55
|
-
/* @__PURE__ */ jsx("span", {
|
|
56
|
-
className: body.from.className,
|
|
57
|
-
children: /* @__PURE__ */ jsx(DirectionCell, {
|
|
58
|
-
windAvgMps: body.from.windAvgMps,
|
|
59
|
-
windDirectionDeg: body.from.windDirectionDeg,
|
|
60
|
-
words
|
|
61
|
-
})
|
|
62
|
-
}),
|
|
63
|
-
body.temperature && /* @__PURE__ */ jsx("span", {
|
|
64
|
-
className: body.temperature.className,
|
|
65
|
-
children: body.temperature.text
|
|
66
|
-
}),
|
|
67
|
-
/* @__PURE__ */ jsxs("span", {
|
|
68
|
-
className: body.updated.className,
|
|
69
|
-
children: [/* @__PURE__ */ jsx("span", {
|
|
70
|
-
className: body.updated.time.className,
|
|
71
|
-
children: body.updated.time.text
|
|
72
|
-
}), status != null && /* @__PURE__ */ jsx(FreshnessBadge, {
|
|
73
|
-
status,
|
|
74
|
-
strings
|
|
75
|
-
})]
|
|
76
|
-
})
|
|
77
|
-
] }) : /* @__PURE__ */ jsx("span", {
|
|
78
|
-
className: body.className,
|
|
79
|
-
children: body.text
|
|
80
|
-
})]
|
|
81
|
-
});
|
|
26
|
+
}));
|
|
82
27
|
}
|
|
83
28
|
//#endregion
|
|
84
29
|
export { StationStrip };
|