@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
|
@@ -1,37 +1,30 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
import { stationFreshnessThresholds } from "../../derive.js";
|
|
3
3
|
import { resolveDisplay } from "../../display.js";
|
|
4
|
-
import {
|
|
4
|
+
import { TABLE_BODY_CLASS, TABLE_ROW_CLASS, TABLE_STATION_CELL_CLASS, stationTableHeadNode, stationTableRootAttrs, stationTableRowCells } from "../../scene/table.js";
|
|
5
|
+
import { renderChildren, renderScene } from "./SceneTree.js";
|
|
5
6
|
import { requireResolved, useStationFeedContext } from "./StationFeedProvider.js";
|
|
6
|
-
import { DirectionCell, StationNameLink } from "../lib/cells.js";
|
|
7
7
|
import { useFreshness } from "../hooks/useFreshness.js";
|
|
8
|
-
import {
|
|
9
|
-
import {
|
|
8
|
+
import { StationNameLink } from "../lib/cells.js";
|
|
9
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
10
10
|
//#region src/react/components/StationTable.tsx
|
|
11
11
|
function StationTable({ stations: stationsProp, servedAt: servedAtProp, receivedAtMs: receivedAtMsProp, unit: unitProp, strings: stringsProp, formatTime: formatTimeProp, stationMeta }) {
|
|
12
12
|
const context = useStationFeedContext();
|
|
13
13
|
const stations = requireResolved("StationTable", "stations", stationsProp ?? context?.feed?.stations);
|
|
14
14
|
const servedAt = servedAtProp ?? context?.feed?.servedAt ?? null;
|
|
15
15
|
const receivedAtMs = receivedAtMsProp !== void 0 ? receivedAtMsProp : context?.receivedAtMs ?? null;
|
|
16
|
-
const { formatTime,
|
|
16
|
+
const { formatTime, unit, words } = resolveDisplay(context, {
|
|
17
17
|
formatTime: formatTimeProp,
|
|
18
18
|
strings: stringsProp,
|
|
19
19
|
unit: unitProp
|
|
20
20
|
});
|
|
21
|
-
const
|
|
21
|
+
const root = stationTableRootAttrs(stations, words);
|
|
22
22
|
return /* @__PURE__ */ jsxs("div", {
|
|
23
|
-
"aria-label":
|
|
24
|
-
className:
|
|
23
|
+
"aria-label": root["aria-label"],
|
|
24
|
+
className: root["class"],
|
|
25
25
|
role: "table",
|
|
26
|
-
children: [/* @__PURE__ */ jsx("div", {
|
|
27
|
-
className:
|
|
28
|
-
role: "row",
|
|
29
|
-
children: scene.head.columns.map((column) => /* @__PURE__ */ jsx("span", {
|
|
30
|
-
role: "columnheader",
|
|
31
|
-
children: column
|
|
32
|
-
}, column))
|
|
33
|
-
}), /* @__PURE__ */ jsx("div", {
|
|
34
|
-
className: scene.bodyClassName,
|
|
26
|
+
children: [renderScene(stationTableHeadNode(words)), /* @__PURE__ */ jsx("div", {
|
|
27
|
+
className: TABLE_BODY_CLASS,
|
|
35
28
|
role: "rowgroup",
|
|
36
29
|
children: stations.map((station) => /* @__PURE__ */ jsx(TableRow, {
|
|
37
30
|
formatTime,
|
|
@@ -39,76 +32,29 @@ function StationTable({ stations: stationsProp, servedAt: servedAtProp, received
|
|
|
39
32
|
servedAt,
|
|
40
33
|
station,
|
|
41
34
|
stationMeta,
|
|
42
|
-
strings,
|
|
43
35
|
unit,
|
|
44
36
|
words
|
|
45
37
|
}, station.id))
|
|
46
38
|
})]
|
|
47
39
|
});
|
|
48
40
|
}
|
|
49
|
-
function TableRow({ formatTime, receivedAtMs, servedAt, station, stationMeta,
|
|
41
|
+
function TableRow({ formatTime, receivedAtMs, servedAt, station, stationMeta, unit, words }) {
|
|
50
42
|
const status = useFreshness(station.reading?.observedAt ?? null, servedAt, receivedAtMs, stationFreshnessThresholds(station));
|
|
51
|
-
const row = stationTableRowScene({
|
|
52
|
-
formatTime,
|
|
53
|
-
station,
|
|
54
|
-
unit,
|
|
55
|
-
words
|
|
56
|
-
});
|
|
57
|
-
const { cells } = row;
|
|
58
43
|
return /* @__PURE__ */ jsxs("div", {
|
|
59
|
-
className:
|
|
60
|
-
"data-status":
|
|
44
|
+
className: TABLE_ROW_CLASS,
|
|
45
|
+
"data-status": station.status,
|
|
61
46
|
role: "row",
|
|
62
47
|
children: [/* @__PURE__ */ jsxs("span", {
|
|
63
|
-
className:
|
|
48
|
+
className: TABLE_STATION_CELL_CLASS,
|
|
64
49
|
role: "cell",
|
|
65
50
|
children: [/* @__PURE__ */ jsx("strong", { children: /* @__PURE__ */ jsx(StationNameLink, { station }) }), /* @__PURE__ */ jsx("small", { children: stationMeta ? stationMeta(station) : station.sourceLabel })]
|
|
66
|
-
}),
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
className: cells.lull.className,
|
|
74
|
-
role: "cell",
|
|
75
|
-
children: cells.lull.value
|
|
76
|
-
}),
|
|
77
|
-
/* @__PURE__ */ jsx("span", {
|
|
78
|
-
className: cells.gust.className,
|
|
79
|
-
role: "cell",
|
|
80
|
-
children: cells.gust.value
|
|
81
|
-
}),
|
|
82
|
-
/* @__PURE__ */ jsx("span", {
|
|
83
|
-
className: cells.from.className,
|
|
84
|
-
role: "cell",
|
|
85
|
-
children: /* @__PURE__ */ jsx(DirectionCell, {
|
|
86
|
-
windAvgMps: cells.from.windAvgMps,
|
|
87
|
-
windDirectionDeg: cells.from.windDirectionDeg,
|
|
88
|
-
words
|
|
89
|
-
})
|
|
90
|
-
}),
|
|
91
|
-
/* @__PURE__ */ jsx("span", {
|
|
92
|
-
className: cells.temperature.className,
|
|
93
|
-
role: "cell",
|
|
94
|
-
children: cells.temperature.value
|
|
95
|
-
}),
|
|
96
|
-
/* @__PURE__ */ jsxs("span", {
|
|
97
|
-
className: cells.updated.className,
|
|
98
|
-
role: "cell",
|
|
99
|
-
children: [/* @__PURE__ */ jsx("span", {
|
|
100
|
-
className: cells.updated.time.className,
|
|
101
|
-
children: cells.updated.time.text
|
|
102
|
-
}), status != null && /* @__PURE__ */ jsx(FreshnessBadge, {
|
|
103
|
-
status,
|
|
104
|
-
strings
|
|
105
|
-
})]
|
|
106
|
-
})
|
|
107
|
-
] }) : /* @__PURE__ */ jsx("span", {
|
|
108
|
-
className: cells.className,
|
|
109
|
-
role: "cell",
|
|
110
|
-
children: cells.text
|
|
111
|
-
})]
|
|
51
|
+
}), renderChildren(stationTableRowCells({
|
|
52
|
+
formatTime,
|
|
53
|
+
freshness: status,
|
|
54
|
+
station,
|
|
55
|
+
unit,
|
|
56
|
+
words
|
|
57
|
+
}))]
|
|
112
58
|
});
|
|
113
59
|
}
|
|
114
60
|
//#endregion
|
|
@@ -1,9 +1,11 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
import { resolveDisplay } from "../../display.js";
|
|
3
3
|
import { measuredChartWidth } from "../../geometry.js";
|
|
4
|
-
import {
|
|
4
|
+
import { readoutAriaLive } from "../../scene/chart.js";
|
|
5
5
|
import { TREND_CLASS, trendGate, trendScene } from "../../scene/trend.js";
|
|
6
|
+
import { renderScene } from "./SceneTree.js";
|
|
6
7
|
import { requireResolved, resolveStation, useStationFeedContext } from "./StationFeedProvider.js";
|
|
8
|
+
import { usePinnedCursor } from "../lib/use-pinned-cursor.js";
|
|
7
9
|
import { useEffect, useRef, useState } from "react";
|
|
8
10
|
import { Fragment, jsx, jsxs } from "react/jsx-runtime";
|
|
9
11
|
//#region src/react/components/TrendChart.tsx
|
|
@@ -17,6 +19,7 @@ function TrendChart({ station: stationProp, stationId, series, strings: stringsP
|
|
|
17
19
|
const wrapRef = useRef(null);
|
|
18
20
|
const [width, setWidth] = useState(null);
|
|
19
21
|
const gate = trendGate(station, series, words);
|
|
22
|
+
const drawable = gate.kind === "draw";
|
|
20
23
|
useEffect(() => {
|
|
21
24
|
const element = wrapRef.current;
|
|
22
25
|
if (!element) return;
|
|
@@ -29,7 +32,7 @@ function TrendChart({ station: stationProp, stationId, series, strings: stringsP
|
|
|
29
32
|
});
|
|
30
33
|
observer.observe(element);
|
|
31
34
|
return () => observer.disconnect();
|
|
32
|
-
}, [
|
|
35
|
+
}, [drawable]);
|
|
33
36
|
if (gate.kind === "hidden") return null;
|
|
34
37
|
if (gate.kind === "note") return /* @__PURE__ */ jsx("div", {
|
|
35
38
|
className: gate.className,
|
|
@@ -50,8 +53,6 @@ function TrendChart({ station: stationProp, stationId, series, strings: stringsP
|
|
|
50
53
|
});
|
|
51
54
|
}
|
|
52
55
|
function MeasuredTrend({ formatTime, history, series, stationName, width, words }) {
|
|
53
|
-
const [pinnedAt, setPinnedAt] = useState(null);
|
|
54
|
-
const [previewIndex, setPreviewIndex] = useState(null);
|
|
55
56
|
const scene = trendScene({
|
|
56
57
|
formatTime,
|
|
57
58
|
history,
|
|
@@ -60,92 +61,18 @@ function MeasuredTrend({ formatTime, history, series, stationName, width, words
|
|
|
60
61
|
width,
|
|
61
62
|
words
|
|
62
63
|
});
|
|
63
|
-
const
|
|
64
|
-
const
|
|
65
|
-
const svg = hit.ownerSVGElement;
|
|
66
|
-
if (!svg) return null;
|
|
67
|
-
const bounds = svg.getBoundingClientRect();
|
|
68
|
-
return chartIndexAtClient(scene.points, scene.frame, scene.scales, clientX, bounds);
|
|
69
|
-
};
|
|
70
|
-
const handlePointerMove = (event) => {
|
|
71
|
-
if (event.pointerType === "touch") return;
|
|
72
|
-
setPreviewIndex(indexAtPoint(event.clientX, event.currentTarget));
|
|
73
|
-
};
|
|
74
|
-
const handleClick = (event) => {
|
|
75
|
-
const index = indexAtPoint(event.clientX, event.currentTarget);
|
|
76
|
-
if (index == null) return;
|
|
77
|
-
const observedAt = scene.points[index]?.observedAt;
|
|
78
|
-
if (observedAt == null) return;
|
|
79
|
-
setPinnedAt((current) => togglePinnedAt(current, observedAt));
|
|
80
|
-
setPreviewIndex(null);
|
|
81
|
-
};
|
|
64
|
+
const pinned = usePinnedCursor(scene);
|
|
65
|
+
const { readout, cursor } = scene.inspect(pinned.activeIndex);
|
|
82
66
|
return /* @__PURE__ */ jsxs(Fragment, { children: [/* @__PURE__ */ jsxs("output", {
|
|
83
67
|
"aria-label": scene.readout.ariaLabel,
|
|
84
|
-
"aria-live": readoutAriaLive(previewIndex),
|
|
68
|
+
"aria-live": readoutAriaLive(pinned.previewIndex),
|
|
85
69
|
className: scene.readout.className,
|
|
86
70
|
children: [/* @__PURE__ */ jsx("strong", { children: readout.strong }), /* @__PURE__ */ jsx("span", { children: readout.span })]
|
|
87
|
-
}),
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
viewBox: scene.svg.viewBox,
|
|
93
|
-
width: scene.svg.width,
|
|
94
|
-
children: [
|
|
95
|
-
scene.grid.map(({ key, line, label }) => /* @__PURE__ */ jsxs("g", { children: [/* @__PURE__ */ jsx("line", {
|
|
96
|
-
className: line.className,
|
|
97
|
-
x1: line.x1,
|
|
98
|
-
x2: line.x2,
|
|
99
|
-
y1: line.y1,
|
|
100
|
-
y2: line.y2
|
|
101
|
-
}), /* @__PURE__ */ jsx("text", {
|
|
102
|
-
className: label.className,
|
|
103
|
-
textAnchor: label.anchor,
|
|
104
|
-
x: label.x,
|
|
105
|
-
y: label.y,
|
|
106
|
-
children: label.text
|
|
107
|
-
})] }, key)),
|
|
108
|
-
scene.segments.map((segment) => segment.kind === "dot" ? /* @__PURE__ */ jsx("circle", {
|
|
109
|
-
className: segment.className,
|
|
110
|
-
cx: segment.cx,
|
|
111
|
-
cy: segment.cy,
|
|
112
|
-
r: segment.r
|
|
113
|
-
}, segment.startedAt) : /* @__PURE__ */ jsx("polyline", {
|
|
114
|
-
className: segment.className,
|
|
115
|
-
points: segment.points
|
|
116
|
-
}, segment.startedAt)),
|
|
117
|
-
scene.ticks.map((tick) => /* @__PURE__ */ jsx("text", {
|
|
118
|
-
className: tick.className,
|
|
119
|
-
textAnchor: tick.anchor,
|
|
120
|
-
x: tick.x,
|
|
121
|
-
y: tick.y,
|
|
122
|
-
children: tick.text
|
|
123
|
-
}, tick.key)),
|
|
124
|
-
cursor && /* @__PURE__ */ jsxs(Fragment, { children: [/* @__PURE__ */ jsx("line", {
|
|
125
|
-
className: cursor.line.className,
|
|
126
|
-
x1: cursor.line.x1,
|
|
127
|
-
x2: cursor.line.x2,
|
|
128
|
-
y1: cursor.line.y1,
|
|
129
|
-
y2: cursor.line.y2
|
|
130
|
-
}), cursor.dot && /* @__PURE__ */ jsx("circle", {
|
|
131
|
-
className: cursor.dot.className,
|
|
132
|
-
cx: cursor.dot.cx,
|
|
133
|
-
cy: cursor.dot.cy,
|
|
134
|
-
r: cursor.dot.r
|
|
135
|
-
})] }),
|
|
136
|
-
/* @__PURE__ */ jsx("rect", {
|
|
137
|
-
className: scene.hit.className,
|
|
138
|
-
fill: scene.hit.fill,
|
|
139
|
-
height: scene.hit.height,
|
|
140
|
-
onClick: handleClick,
|
|
141
|
-
onPointerLeave: () => setPreviewIndex(null),
|
|
142
|
-
onPointerMove: handlePointerMove,
|
|
143
|
-
width: scene.hit.width,
|
|
144
|
-
x: scene.hit.x,
|
|
145
|
-
y: scene.hit.y
|
|
146
|
-
})
|
|
147
|
-
]
|
|
148
|
-
})] });
|
|
71
|
+
}), renderScene(scene.draw(cursor, {
|
|
72
|
+
onClick: pinned.handleClick,
|
|
73
|
+
onPointerLeave: pinned.handlePointerLeave,
|
|
74
|
+
onPointerMove: pinned.handlePointerMove
|
|
75
|
+
}))] });
|
|
149
76
|
}
|
|
150
77
|
//#endregion
|
|
151
78
|
export { TrendChart };
|
|
@@ -1,21 +1,9 @@
|
|
|
1
1
|
"use client";
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
2
|
+
import { windArrowNode } from "../../scene/glyphs.js";
|
|
3
|
+
import { renderScene } from "./SceneTree.js";
|
|
4
4
|
//#region src/react/components/WindArrow.tsx
|
|
5
5
|
function WindArrow({ deg, size = 12 }) {
|
|
6
|
-
|
|
7
|
-
return /* @__PURE__ */ jsx("svg", {
|
|
8
|
-
"aria-hidden": "true",
|
|
9
|
-
className: spec.className,
|
|
10
|
-
height: spec.height,
|
|
11
|
-
style: { transform: spec.transform },
|
|
12
|
-
viewBox: spec.viewBox,
|
|
13
|
-
width: spec.width,
|
|
14
|
-
children: /* @__PURE__ */ jsx("path", {
|
|
15
|
-
d: spec.path.d,
|
|
16
|
-
fill: spec.path.fill
|
|
17
|
-
})
|
|
18
|
-
});
|
|
6
|
+
return renderScene(windArrowNode(deg, size));
|
|
19
7
|
}
|
|
20
8
|
//#endregion
|
|
21
9
|
export { WindArrow };
|
|
@@ -1,11 +1,13 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
import { resolveDisplay } from "../../display.js";
|
|
3
|
-
import {
|
|
3
|
+
import { readoutAriaLive } from "../../scene/chart.js";
|
|
4
4
|
import { WIND_CHART_CLASS, windChartGate, windChartScene } from "../../scene/wind-history.js";
|
|
5
|
+
import { renderScene } from "./SceneTree.js";
|
|
5
6
|
import { requireResolved, resolveStation, useStationFeedContext } from "./StationFeedProvider.js";
|
|
7
|
+
import { usePinnedCursor } from "../lib/use-pinned-cursor.js";
|
|
6
8
|
import { Readout } from "./Readout.js";
|
|
7
9
|
import { useMeasuredChartWidth } from "../hooks/useMeasuredChartWidth.js";
|
|
8
|
-
import { useId, useRef
|
|
10
|
+
import { useId, useRef } from "react";
|
|
9
11
|
import { Fragment, jsx, jsxs } from "react/jsx-runtime";
|
|
10
12
|
//#region src/react/components/WindHistoryChart.tsx
|
|
11
13
|
function WindHistoryChart({ station: stationProp, stationId, thresholds: thresholdsProp, favorableDirections: favorableDirectionsProp, unit: unitProp, plotHeight, windowHours, compareOffsetDays, nightShading = false, strings: stringsProp, formatTime: formatTimeProp }) {
|
|
@@ -51,8 +53,6 @@ function WindHistoryChart({ station: stationProp, stationId, thresholds: thresho
|
|
|
51
53
|
}
|
|
52
54
|
function MeasuredChart({ compareOffsetDays, favorableDirections, formatTime, history, night, plotHeight, stationName, thresholds, unit, width, windowHours, words }) {
|
|
53
55
|
const hatchId = `meteo-hatch-${useId().replace(/[^a-zA-Z0-9_-]/g, "")}`;
|
|
54
|
-
const [pinnedAt, setPinnedAt] = useState(null);
|
|
55
|
-
const [previewIndex, setPreviewIndex] = useState(null);
|
|
56
56
|
const scene = windChartScene({
|
|
57
57
|
compareOffsetDays,
|
|
58
58
|
favorableDirections,
|
|
@@ -68,212 +68,19 @@ function MeasuredChart({ compareOffsetDays, favorableDirections, formatTime, his
|
|
|
68
68
|
windowHours,
|
|
69
69
|
words
|
|
70
70
|
});
|
|
71
|
-
const
|
|
72
|
-
const
|
|
73
|
-
const svg = hit.ownerSVGElement;
|
|
74
|
-
if (!svg) return null;
|
|
75
|
-
const bounds = svg.getBoundingClientRect();
|
|
76
|
-
return chartIndexAtClient(scene.points, scene.frame, scene.scales, clientX, bounds);
|
|
77
|
-
};
|
|
78
|
-
const handlePointerMove = (event) => {
|
|
79
|
-
if (event.pointerType === "touch") return;
|
|
80
|
-
setPreviewIndex(indexAtPoint(event.clientX, event.currentTarget));
|
|
81
|
-
};
|
|
82
|
-
const handleClick = (event) => {
|
|
83
|
-
const index = indexAtPoint(event.clientX, event.currentTarget);
|
|
84
|
-
if (index == null) return;
|
|
85
|
-
const observedAt = scene.points[index]?.observedAt;
|
|
86
|
-
if (observedAt == null) return;
|
|
87
|
-
setPinnedAt((current) => togglePinnedAt(current, observedAt));
|
|
88
|
-
setPreviewIndex(null);
|
|
89
|
-
};
|
|
71
|
+
const pinned = usePinnedCursor(scene);
|
|
72
|
+
const { readout, cursor } = scene.inspect(pinned.activeIndex);
|
|
90
73
|
return /* @__PURE__ */ jsxs(Fragment, { children: [/* @__PURE__ */ jsx(Readout, {
|
|
91
74
|
ariaLabel: scene.readout.ariaLabel,
|
|
92
|
-
ariaLive: readoutAriaLive(previewIndex),
|
|
75
|
+
ariaLive: readoutAriaLive(pinned.previewIndex),
|
|
93
76
|
className: scene.readout.className,
|
|
94
77
|
parts: readout.span,
|
|
95
78
|
strong: readout.strong
|
|
96
|
-
}),
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
viewBox: scene.svg.viewBox,
|
|
102
|
-
width: scene.svg.width,
|
|
103
|
-
children: [
|
|
104
|
-
/* @__PURE__ */ jsxs("defs", { children: [/* @__PURE__ */ jsx("pattern", {
|
|
105
|
-
height: scene.defs.pattern.height,
|
|
106
|
-
id: scene.defs.pattern.id,
|
|
107
|
-
patternTransform: scene.defs.pattern.transform,
|
|
108
|
-
patternUnits: scene.defs.pattern.units,
|
|
109
|
-
width: scene.defs.pattern.width,
|
|
110
|
-
children: /* @__PURE__ */ jsx("line", {
|
|
111
|
-
className: scene.defs.pattern.line.className,
|
|
112
|
-
x1: scene.defs.pattern.line.x1,
|
|
113
|
-
x2: scene.defs.pattern.line.x2,
|
|
114
|
-
y1: scene.defs.pattern.line.y1,
|
|
115
|
-
y2: scene.defs.pattern.line.y2
|
|
116
|
-
})
|
|
117
|
-
}), /* @__PURE__ */ jsx("clipPath", {
|
|
118
|
-
id: scene.defs.clip.id,
|
|
119
|
-
children: /* @__PURE__ */ jsx("rect", {
|
|
120
|
-
height: scene.defs.clip.rect.height,
|
|
121
|
-
width: scene.defs.clip.rect.width,
|
|
122
|
-
x: scene.defs.clip.rect.x,
|
|
123
|
-
y: scene.defs.clip.rect.y
|
|
124
|
-
})
|
|
125
|
-
})] }),
|
|
126
|
-
scene.zones.map((zone) => /* @__PURE__ */ jsx("rect", {
|
|
127
|
-
className: zone.className,
|
|
128
|
-
height: zone.height,
|
|
129
|
-
width: zone.width,
|
|
130
|
-
x: zone.x,
|
|
131
|
-
y: zone.y
|
|
132
|
-
}, zone.key)),
|
|
133
|
-
scene.nightRects.map((rect) => /* @__PURE__ */ jsx("rect", {
|
|
134
|
-
className: rect.className,
|
|
135
|
-
height: rect.height,
|
|
136
|
-
width: rect.width,
|
|
137
|
-
x: rect.x,
|
|
138
|
-
y: rect.y
|
|
139
|
-
}, rect.key)),
|
|
140
|
-
scene.grid.map(({ key, line, label }) => /* @__PURE__ */ jsxs("g", { children: [/* @__PURE__ */ jsx("line", {
|
|
141
|
-
className: line.className,
|
|
142
|
-
x1: line.x1,
|
|
143
|
-
x2: line.x2,
|
|
144
|
-
y1: line.y1,
|
|
145
|
-
y2: line.y2
|
|
146
|
-
}), /* @__PURE__ */ jsx("text", {
|
|
147
|
-
className: label.className,
|
|
148
|
-
textAnchor: label.anchor,
|
|
149
|
-
x: label.x,
|
|
150
|
-
y: label.y,
|
|
151
|
-
children: label.text
|
|
152
|
-
})] }, key)),
|
|
153
|
-
scene.thresholdGuides.map(({ key, line, label }) => /* @__PURE__ */ jsxs("g", { children: [/* @__PURE__ */ jsx("line", {
|
|
154
|
-
className: line.className,
|
|
155
|
-
x1: line.x1,
|
|
156
|
-
x2: line.x2,
|
|
157
|
-
y1: line.y1,
|
|
158
|
-
y2: line.y2
|
|
159
|
-
}), /* @__PURE__ */ jsx("text", {
|
|
160
|
-
className: label.className,
|
|
161
|
-
textAnchor: label.anchor,
|
|
162
|
-
x: label.x,
|
|
163
|
-
y: label.y,
|
|
164
|
-
children: label.text
|
|
165
|
-
})] }, key)),
|
|
166
|
-
scene.vaneGuides.map((guide) => /* @__PURE__ */ jsx("line", {
|
|
167
|
-
className: guide.className,
|
|
168
|
-
x1: guide.x1,
|
|
169
|
-
x2: guide.x2,
|
|
170
|
-
y1: guide.y1,
|
|
171
|
-
y2: guide.y2
|
|
172
|
-
}, `guide-${guide.key}`)),
|
|
173
|
-
scene.gaps.map((gap) => /* @__PURE__ */ jsx("rect", {
|
|
174
|
-
className: gap.className,
|
|
175
|
-
fill: gap.fill,
|
|
176
|
-
height: gap.height,
|
|
177
|
-
width: gap.width,
|
|
178
|
-
x: gap.x,
|
|
179
|
-
y: gap.y
|
|
180
|
-
}, gap.key)),
|
|
181
|
-
scene.band && /* @__PURE__ */ jsx("polygon", {
|
|
182
|
-
className: scene.band.className,
|
|
183
|
-
points: scene.band.points
|
|
184
|
-
}),
|
|
185
|
-
scene.compare && /* @__PURE__ */ jsx("polyline", {
|
|
186
|
-
className: scene.compare.className,
|
|
187
|
-
clipPath: scene.compare.clipPath,
|
|
188
|
-
points: scene.compare.points
|
|
189
|
-
}),
|
|
190
|
-
scene.mean.kind === "polyline" ? /* @__PURE__ */ jsx("polyline", {
|
|
191
|
-
className: scene.mean.className,
|
|
192
|
-
points: scene.mean.points
|
|
193
|
-
}) : scene.mean.segments.map((segment) => /* @__PURE__ */ jsx("line", {
|
|
194
|
-
className: segment.className,
|
|
195
|
-
x1: segment.x1,
|
|
196
|
-
x2: segment.x2,
|
|
197
|
-
y1: segment.y1,
|
|
198
|
-
y2: segment.y2
|
|
199
|
-
}, segment.key)),
|
|
200
|
-
scene.calmNote && /* @__PURE__ */ jsx("text", {
|
|
201
|
-
className: scene.calmNote.className,
|
|
202
|
-
textAnchor: scene.calmNote.anchor,
|
|
203
|
-
x: scene.calmNote.x,
|
|
204
|
-
y: scene.calmNote.y,
|
|
205
|
-
children: scene.calmNote.text
|
|
206
|
-
}),
|
|
207
|
-
/* @__PURE__ */ jsx("text", {
|
|
208
|
-
className: scene.rowLabels.to.className,
|
|
209
|
-
textAnchor: scene.rowLabels.to.anchor,
|
|
210
|
-
x: scene.rowLabels.to.x,
|
|
211
|
-
y: scene.rowLabels.to.y,
|
|
212
|
-
children: scene.rowLabels.to.text
|
|
213
|
-
}),
|
|
214
|
-
scene.vanes.map((vane) => vane.mark.kind === "calm" ? /* @__PURE__ */ jsx("text", {
|
|
215
|
-
className: vane.mark.text.className,
|
|
216
|
-
textAnchor: vane.mark.text.anchor,
|
|
217
|
-
x: vane.mark.text.x,
|
|
218
|
-
y: vane.mark.text.y,
|
|
219
|
-
children: vane.mark.text.text
|
|
220
|
-
}, vane.key) : /* @__PURE__ */ jsx("path", {
|
|
221
|
-
className: vane.mark.className,
|
|
222
|
-
d: vane.mark.d
|
|
223
|
-
}, vane.key)),
|
|
224
|
-
scene.vanes.map((vane) => vane.label && /* @__PURE__ */ jsx("text", {
|
|
225
|
-
className: vane.label.className,
|
|
226
|
-
textAnchor: vane.label.anchor,
|
|
227
|
-
x: vane.label.x,
|
|
228
|
-
y: vane.label.y,
|
|
229
|
-
children: vane.label.text
|
|
230
|
-
}, `label-${vane.key}`)),
|
|
231
|
-
/* @__PURE__ */ jsx("text", {
|
|
232
|
-
className: scene.rowLabels.avg.className,
|
|
233
|
-
textAnchor: scene.rowLabels.avg.anchor,
|
|
234
|
-
x: scene.rowLabels.avg.x,
|
|
235
|
-
y: scene.rowLabels.avg.y,
|
|
236
|
-
children: scene.rowLabels.avg.text
|
|
237
|
-
}),
|
|
238
|
-
scene.vanes.map((vane) => vane.value && /* @__PURE__ */ jsx("text", {
|
|
239
|
-
className: vane.value.className,
|
|
240
|
-
textAnchor: vane.value.anchor,
|
|
241
|
-
x: vane.value.x,
|
|
242
|
-
y: vane.value.y,
|
|
243
|
-
children: vane.value.text
|
|
244
|
-
}, `value-${vane.key}`)),
|
|
245
|
-
scene.ticks.map((tick) => /* @__PURE__ */ jsx("text", {
|
|
246
|
-
className: tick.className,
|
|
247
|
-
textAnchor: tick.anchor,
|
|
248
|
-
x: tick.x,
|
|
249
|
-
y: tick.y,
|
|
250
|
-
children: tick.text
|
|
251
|
-
}, tick.key)),
|
|
252
|
-
cursor && /* @__PURE__ */ jsxs(Fragment, { children: [/* @__PURE__ */ jsx("line", {
|
|
253
|
-
className: cursor.line.className,
|
|
254
|
-
x1: cursor.line.x1,
|
|
255
|
-
x2: cursor.line.x2,
|
|
256
|
-
y1: cursor.line.y1,
|
|
257
|
-
y2: cursor.line.y2
|
|
258
|
-
}), /* @__PURE__ */ jsx("circle", {
|
|
259
|
-
className: cursor.dot.className,
|
|
260
|
-
cx: cursor.dot.cx,
|
|
261
|
-
cy: cursor.dot.cy,
|
|
262
|
-
r: cursor.dot.r
|
|
263
|
-
})] }),
|
|
264
|
-
/* @__PURE__ */ jsx("rect", {
|
|
265
|
-
className: scene.hit.className,
|
|
266
|
-
fill: scene.hit.fill,
|
|
267
|
-
height: scene.hit.height,
|
|
268
|
-
onClick: handleClick,
|
|
269
|
-
onPointerLeave: () => setPreviewIndex(null),
|
|
270
|
-
onPointerMove: handlePointerMove,
|
|
271
|
-
width: scene.hit.width,
|
|
272
|
-
x: scene.hit.x,
|
|
273
|
-
y: scene.hit.y
|
|
274
|
-
})
|
|
275
|
-
]
|
|
276
|
-
})] });
|
|
79
|
+
}), renderScene(scene.draw(cursor, {
|
|
80
|
+
onClick: pinned.handleClick,
|
|
81
|
+
onPointerLeave: pinned.handlePointerLeave,
|
|
82
|
+
onPointerMove: pinned.handlePointerMove
|
|
83
|
+
}))] });
|
|
277
84
|
}
|
|
278
85
|
//#endregion
|
|
279
86
|
export { WindHistoryChart };
|
|
@@ -3,8 +3,6 @@ import { SpeedThresholds } from "../../derive.js";
|
|
|
3
3
|
import { StationStringOverrides } from "../../strings.js";
|
|
4
4
|
import { FavorableDirection } from "../../instruments.js";
|
|
5
5
|
import "../../index.js";
|
|
6
|
-
import "../../scene/index.js";
|
|
7
|
-
import { ReactNode } from "react";
|
|
8
6
|
//#region src/react/components/WindRose.d.ts
|
|
9
7
|
declare function WindRose({ station: stationProp, stationId, points, sectorCount, thresholds: thresholdsProp, favorableDirections: favorableDirectionsProp, strings: stringsProp }: {
|
|
10
8
|
station?: Station;
|
|
@@ -14,6 +12,6 @@ declare function WindRose({ station: stationProp, stationId, points, sectorCount
|
|
|
14
12
|
thresholds?: SpeedThresholds | null;
|
|
15
13
|
favorableDirections?: FavorableDirection[] | null;
|
|
16
14
|
strings?: StationStringOverrides;
|
|
17
|
-
}): import("react").
|
|
15
|
+
}): import("react").ReactNode;
|
|
18
16
|
//#endregion
|
|
19
17
|
export { WindRose };
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
import { resolveDisplay } from "../../display.js";
|
|
3
|
-
import {
|
|
3
|
+
import { windRoseScene, windRoseSource } from "../../scene/rose.js";
|
|
4
|
+
import { renderScene } from "./SceneTree.js";
|
|
4
5
|
import { resolveStation, useStationFeedContext } from "./StationFeedProvider.js";
|
|
5
|
-
import { Fragment, jsx, jsxs } from "react/jsx-runtime";
|
|
6
6
|
//#region src/react/components/WindRose.tsx
|
|
7
7
|
function WindRose({ station: stationProp, stationId, points, sectorCount = 16, thresholds: thresholdsProp, favorableDirections: favorableDirectionsProp, strings: stringsProp }) {
|
|
8
8
|
const context = useStationFeedContext();
|
|
@@ -12,97 +12,14 @@ function WindRose({ station: stationProp, stationId, points, sectorCount = 16, t
|
|
|
12
12
|
thresholds: thresholdsProp,
|
|
13
13
|
favorableDirections: favorableDirectionsProp
|
|
14
14
|
});
|
|
15
|
-
|
|
16
|
-
const gate = windRoseGate(source, words);
|
|
17
|
-
if (gate.kind === "note") return /* @__PURE__ */ jsx("div", {
|
|
18
|
-
className: gate.className,
|
|
19
|
-
role: "note",
|
|
20
|
-
children: gate.text
|
|
21
|
-
});
|
|
22
|
-
return /* @__PURE__ */ jsx(WindRoseSceneView, { scene: windRoseScene({
|
|
15
|
+
return renderScene(windRoseScene({
|
|
23
16
|
favorableDirections,
|
|
24
17
|
sectorCount,
|
|
25
|
-
source,
|
|
18
|
+
source: windRoseSource(points, station),
|
|
26
19
|
stationName: station?.name,
|
|
27
20
|
thresholds,
|
|
28
21
|
words
|
|
29
|
-
})
|
|
30
|
-
}
|
|
31
|
-
/** One scene, one drawing — shared by the history-fed rose above and the
|
|
32
|
-
* climatology-fed twin, which appends its caption row as children. */
|
|
33
|
-
function WindRoseSceneView({ scene, children }) {
|
|
34
|
-
return /* @__PURE__ */ jsxs("div", {
|
|
35
|
-
className: scene.className,
|
|
36
|
-
children: [
|
|
37
|
-
/* @__PURE__ */ jsxs("svg", {
|
|
38
|
-
"aria-label": scene.svg.ariaLabel,
|
|
39
|
-
className: scene.svg.className,
|
|
40
|
-
height: scene.svg.height,
|
|
41
|
-
role: "img",
|
|
42
|
-
viewBox: scene.svg.viewBox,
|
|
43
|
-
width: scene.svg.width,
|
|
44
|
-
children: [
|
|
45
|
-
scene.gridCircles.map((circle) => /* @__PURE__ */ jsx("circle", {
|
|
46
|
-
className: circle.className,
|
|
47
|
-
cx: circle.cx,
|
|
48
|
-
cy: circle.cy,
|
|
49
|
-
r: circle.r
|
|
50
|
-
}, circle.key)),
|
|
51
|
-
scene.ring && /* @__PURE__ */ jsxs(Fragment, { children: [/* @__PURE__ */ jsx("circle", {
|
|
52
|
-
className: scene.ring.unfavorable.className,
|
|
53
|
-
cx: scene.ring.unfavorable.cx,
|
|
54
|
-
cy: scene.ring.unfavorable.cy,
|
|
55
|
-
r: scene.ring.unfavorable.r
|
|
56
|
-
}), scene.ring.favorable.map((arc) => /* @__PURE__ */ jsx("path", {
|
|
57
|
-
className: arc.className,
|
|
58
|
-
d: arc.d
|
|
59
|
-
}, arc.key))] }),
|
|
60
|
-
scene.ticks.map((tick) => /* @__PURE__ */ jsx("line", {
|
|
61
|
-
className: tick.className,
|
|
62
|
-
x1: tick.x1,
|
|
63
|
-
x2: tick.x2,
|
|
64
|
-
y1: tick.y1,
|
|
65
|
-
y2: tick.y2
|
|
66
|
-
}, tick.key)),
|
|
67
|
-
scene.letters.map((letter) => /* @__PURE__ */ jsx("text", {
|
|
68
|
-
className: letter.className,
|
|
69
|
-
textAnchor: letter.anchor,
|
|
70
|
-
x: letter.x,
|
|
71
|
-
y: letter.y,
|
|
72
|
-
children: letter.text
|
|
73
|
-
}, letter.key)),
|
|
74
|
-
scene.petals.map((petal) => /* @__PURE__ */ jsx("path", {
|
|
75
|
-
className: petal.className,
|
|
76
|
-
d: petal.d
|
|
77
|
-
}, petal.key)),
|
|
78
|
-
scene.ringLabel && /* @__PURE__ */ jsx("text", {
|
|
79
|
-
className: scene.ringLabel.className,
|
|
80
|
-
textAnchor: scene.ringLabel.anchor,
|
|
81
|
-
x: scene.ringLabel.x,
|
|
82
|
-
y: scene.ringLabel.y,
|
|
83
|
-
children: scene.ringLabel.text
|
|
84
|
-
}),
|
|
85
|
-
/* @__PURE__ */ jsx("circle", {
|
|
86
|
-
className: scene.hub.className,
|
|
87
|
-
cx: scene.hub.cx,
|
|
88
|
-
cy: scene.hub.cy,
|
|
89
|
-
r: scene.hub.r
|
|
90
|
-
}),
|
|
91
|
-
/* @__PURE__ */ jsx("circle", {
|
|
92
|
-
className: scene.dot.className,
|
|
93
|
-
cx: scene.dot.cx,
|
|
94
|
-
cy: scene.dot.cy,
|
|
95
|
-
r: scene.dot.r
|
|
96
|
-
})
|
|
97
|
-
]
|
|
98
|
-
}),
|
|
99
|
-
scene.calmCaption && /* @__PURE__ */ jsx("p", {
|
|
100
|
-
className: scene.calmCaption.className,
|
|
101
|
-
children: scene.calmCaption.text
|
|
102
|
-
}),
|
|
103
|
-
children
|
|
104
|
-
]
|
|
105
|
-
});
|
|
22
|
+
}));
|
|
106
23
|
}
|
|
107
24
|
//#endregion
|
|
108
|
-
export { WindRose
|
|
25
|
+
export { WindRose };
|