@azohra/meteo.station 0.6.0 → 0.7.1

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.
Files changed (237) hide show
  1. package/README.md +17 -17
  2. package/dist/air.d.ts +4 -7
  3. package/dist/air.js +1 -2
  4. package/dist/client/climatology.d.ts +4 -7
  5. package/dist/client/climatology.js +1 -2
  6. package/dist/client/history.d.ts +14 -17
  7. package/dist/client/history.js +1 -2
  8. package/dist/client/live.d.ts +9 -11
  9. package/dist/client/live.js +1 -2
  10. package/dist/client/poll.d.ts +9 -12
  11. package/dist/client/poll.js +1 -2
  12. package/dist/client/stores.d.ts +8 -10
  13. package/dist/client/stores.js +1 -2
  14. package/dist/client/ticker.d.ts +1 -4
  15. package/dist/client/ticker.js +1 -2
  16. package/dist/climatology.d.ts +13 -15
  17. package/dist/climatology.js +1 -2
  18. package/dist/connectivity.d.ts +9 -12
  19. package/dist/connectivity.js +1 -2
  20. package/dist/contract-climatology.d.ts +11 -14
  21. package/dist/contract-climatology.js +1 -2
  22. package/dist/contract.d.ts +148 -151
  23. package/dist/contract.js +1 -2
  24. package/dist/derive.d.ts +24 -26
  25. package/dist/derive.js +5 -6
  26. package/dist/display.d.ts +6 -9
  27. package/dist/display.js +1 -2
  28. package/dist/elements/elements/AirExtremesElement.d.ts +2 -5
  29. package/dist/elements/elements/AirExtremesElement.js +6 -20
  30. package/dist/elements/elements/AirMatrixElement.d.ts +2 -5
  31. package/dist/elements/elements/AirMatrixElement.js +7 -33
  32. package/dist/elements/elements/ClimatologyDailyPatternElement.d.ts +2 -5
  33. package/dist/elements/elements/ClimatologyDailyPatternElement.js +18 -14
  34. package/dist/elements/elements/ClimatologyRoseElement.d.ts +2 -5
  35. package/dist/elements/elements/ClimatologyRoseElement.js +6 -17
  36. package/dist/elements/elements/CompassFanElement.d.ts +2 -5
  37. package/dist/elements/elements/CompassFanElement.js +6 -66
  38. package/dist/elements/elements/CurrentConditionsElement.d.ts +2 -5
  39. package/dist/elements/elements/CurrentConditionsElement.js +8 -28
  40. package/dist/elements/elements/DailyPatternElement.d.ts +2 -6
  41. package/dist/elements/elements/DailyPatternElement.js +7 -122
  42. package/dist/elements/elements/DialElement.d.ts +2 -5
  43. package/dist/elements/elements/DialElement.js +4 -97
  44. package/dist/elements/elements/FavorableShareElement.d.ts +2 -5
  45. package/dist/elements/elements/FavorableShareElement.js +7 -23
  46. package/dist/elements/elements/FreshnessBadgeElement.d.ts +2 -5
  47. package/dist/elements/elements/FreshnessBadgeElement.js +1 -2
  48. package/dist/elements/elements/RecentSummariesElement.d.ts +2 -5
  49. package/dist/elements/elements/RecentSummariesElement.js +7 -25
  50. package/dist/elements/elements/SparklineElement.d.ts +2 -6
  51. package/dist/elements/elements/SparklineElement.js +5 -41
  52. package/dist/elements/elements/StationCardElement.d.ts +6 -8
  53. package/dist/elements/elements/StationCardElement.js +5 -20
  54. package/dist/elements/elements/StationFeedElement.d.ts +2 -5
  55. package/dist/elements/elements/StationFeedElement.js +5 -4
  56. package/dist/elements/elements/StationStripElement.d.ts +2 -5
  57. package/dist/elements/elements/StationStripElement.js +5 -20
  58. package/dist/elements/elements/StationTableElement.d.ts +3 -6
  59. package/dist/elements/elements/StationTableElement.js +16 -53
  60. package/dist/elements/elements/TrendChartElement.d.ts +2 -5
  61. package/dist/elements/elements/TrendChartElement.js +22 -71
  62. package/dist/elements/elements/WindArrowElement.d.ts +2 -5
  63. package/dist/elements/elements/WindArrowElement.js +1 -2
  64. package/dist/elements/elements/WindHistoryChartElement.d.ts +2 -5
  65. package/dist/elements/elements/WindHistoryChartElement.js +24 -166
  66. package/dist/elements/elements/WindRoseElement.d.ts +2 -6
  67. package/dist/elements/elements/WindRoseElement.js +7 -72
  68. package/dist/elements/elements/atoms.d.ts +10 -12
  69. package/dist/elements/elements/atoms.js +12 -40
  70. package/dist/elements/index.d.ts +3 -5
  71. package/dist/elements/index.js +4 -5
  72. package/dist/elements/lib/ambient.d.ts +2 -5
  73. package/dist/elements/lib/ambient.js +1 -2
  74. package/dist/elements/lib/attributes.js +1 -2
  75. package/dist/elements/lib/base.d.ts +3 -6
  76. package/dist/elements/lib/base.js +1 -2
  77. package/dist/elements/lib/context.js +1 -2
  78. package/dist/elements/lib/fragments.js +9 -39
  79. package/dist/elements/lib/h.js +2 -3
  80. package/dist/elements/lib/pinned-cursor.js +1 -2
  81. package/dist/elements/lib/render.js +29 -0
  82. package/dist/elements/register.js +1 -2
  83. package/dist/endpoints.d.ts +6 -9
  84. package/dist/endpoints.js +1 -2
  85. package/dist/fixtures.d.ts +7 -10
  86. package/dist/fixtures.js +1 -2
  87. package/dist/format.d.ts +11 -14
  88. package/dist/format.js +1 -2
  89. package/dist/geometry.d.ts +36 -38
  90. package/dist/geometry.js +3 -3
  91. package/dist/instruments.d.ts +37 -40
  92. package/dist/instruments.js +3 -4
  93. package/dist/merge-current.d.ts +4 -7
  94. package/dist/merge-current.js +1 -2
  95. package/dist/react/components/AirExtremes.d.ts +2 -5
  96. package/dist/react/components/AirExtremes.js +6 -24
  97. package/dist/react/components/AirMatrix.d.ts +2 -5
  98. package/dist/react/components/AirMatrix.js +11 -45
  99. package/dist/react/components/ClimatologyDailyPattern.d.ts +2 -5
  100. package/dist/react/components/ClimatologyDailyPattern.js +20 -15
  101. package/dist/react/components/ClimatologyRose.d.ts +2 -5
  102. package/dist/react/components/ClimatologyRose.js +12 -30
  103. package/dist/react/components/CompassFan.d.ts +2 -5
  104. package/dist/react/components/CompassFan.js +7 -75
  105. package/dist/react/components/CurrentConditions.d.ts +2 -5
  106. package/dist/react/components/CurrentConditions.js +12 -76
  107. package/dist/react/components/DailyPattern.d.ts +3 -8
  108. package/dist/react/components/DailyPattern.js +11 -151
  109. package/dist/react/components/Dial.d.ts +2 -5
  110. package/dist/react/components/Dial.js +6 -120
  111. package/dist/react/components/FavorableShare.d.ts +2 -5
  112. package/dist/react/components/FavorableShare.js +7 -29
  113. package/dist/react/components/FreshnessBadge.d.ts +2 -5
  114. package/dist/react/components/FreshnessBadge.js +6 -14
  115. package/dist/react/components/Readout.d.ts +2 -5
  116. package/dist/react/components/Readout.js +1 -2
  117. package/dist/react/components/RecentSummaries.d.ts +2 -5
  118. package/dist/react/components/RecentSummaries.js +7 -46
  119. package/dist/react/components/SceneTree.js +37 -0
  120. package/dist/react/components/Sparkline.d.ts +2 -5
  121. package/dist/react/components/Sparkline.js +4 -41
  122. package/dist/react/components/StationCard.d.ts +8 -10
  123. package/dist/react/components/StationCard.js +6 -47
  124. package/dist/react/components/StationFeedProvider.d.ts +3 -6
  125. package/dist/react/components/StationFeedProvider.js +1 -2
  126. package/dist/react/components/StationStrip.d.ts +2 -5
  127. package/dist/react/components/StationStrip.js +6 -62
  128. package/dist/react/components/StationTable.d.ts +3 -6
  129. package/dist/react/components/StationTable.js +22 -77
  130. package/dist/react/components/TrendChart.d.ts +2 -5
  131. package/dist/react/components/TrendChart.js +9 -65
  132. package/dist/react/components/WindArrow.d.ts +2 -5
  133. package/dist/react/components/WindArrow.js +4 -17
  134. package/dist/react/components/WindHistoryChart.d.ts +2 -5
  135. package/dist/react/components/WindHistoryChart.js +9 -184
  136. package/dist/react/components/WindRose.d.ts +2 -7
  137. package/dist/react/components/WindRose.js +7 -91
  138. package/dist/react/components/WindSampleStrip.d.ts +2 -5
  139. package/dist/react/components/WindSampleStrip.js +9 -117
  140. package/dist/react/components/atoms.d.ts +12 -14
  141. package/dist/react/components/atoms.js +13 -50
  142. package/dist/react/hooks/useFreshness.d.ts +1 -4
  143. package/dist/react/hooks/useFreshness.js +1 -2
  144. package/dist/react/hooks/useMeasuredChartWidth.d.ts +2 -5
  145. package/dist/react/hooks/useMeasuredChartWidth.js +1 -2
  146. package/dist/react/hooks/usePolledJson.js +1 -2
  147. package/dist/react/hooks/useStation.d.ts +2 -5
  148. package/dist/react/hooks/useStation.js +1 -2
  149. package/dist/react/hooks/useStationClimatology.d.ts +2 -5
  150. package/dist/react/hooks/useStationClimatology.js +1 -2
  151. package/dist/react/hooks/useStationCurrent.d.ts +2 -5
  152. package/dist/react/hooks/useStationCurrent.js +4 -4
  153. package/dist/react/hooks/useStationFeed.d.ts +2 -5
  154. package/dist/react/hooks/useStationFeed.js +4 -4
  155. package/dist/react/hooks/useStationLive.d.ts +2 -5
  156. package/dist/react/hooks/useStationLive.js +1 -2
  157. package/dist/react/index.d.ts +2 -2
  158. package/dist/react/index.js +5 -5
  159. package/dist/react/lib/cells.js +5 -26
  160. package/dist/react/lib/use-pinned-cursor.js +1 -2
  161. package/dist/samples.d.ts +8 -11
  162. package/dist/samples.js +1 -2
  163. package/dist/scene/air-extremes.js +13 -29
  164. package/dist/scene/air-matrix.js +46 -60
  165. package/dist/scene/atoms.js +1 -2
  166. package/dist/scene/card.js +15 -42
  167. package/dist/scene/cells.d.ts +4 -0
  168. package/dist/scene/cells.js +50 -0
  169. package/dist/scene/chart.d.ts +2 -5
  170. package/dist/scene/chart.js +3 -3
  171. package/dist/scene/climatology-pattern.d.ts +1 -2
  172. package/dist/scene/climatology-pattern.js +11 -13
  173. package/dist/scene/climatology-rose.d.ts +1 -2
  174. package/dist/scene/climatology-rose.js +15 -35
  175. package/dist/scene/compass-fan.js +29 -102
  176. package/dist/scene/current.d.ts +2 -1
  177. package/dist/scene/current.js +30 -58
  178. package/dist/scene/daily-pattern.d.ts +1 -3
  179. package/dist/scene/daily-pattern.js +21 -29
  180. package/dist/scene/dial-parts.d.ts +1 -0
  181. package/dist/scene/dial-parts.js +69 -0
  182. package/dist/scene/dial.d.ts +1 -2
  183. package/dist/scene/dial.js +49 -138
  184. package/dist/scene/favorable-share.js +17 -35
  185. package/dist/scene/glyphs.js +21 -18
  186. package/dist/scene/index.d.ts +5 -3
  187. package/dist/scene/node.js +18 -0
  188. package/dist/scene/recent-summaries.js +27 -65
  189. package/dist/scene/rose.js +90 -119
  190. package/dist/scene/sample-strip.d.ts +1 -2
  191. package/dist/scene/sample-strip.js +36 -38
  192. package/dist/scene/sparkline.js +32 -42
  193. package/dist/scene/strip.js +19 -59
  194. package/dist/scene/table.js +48 -71
  195. package/dist/scene/trend.d.ts +1 -2
  196. package/dist/scene/trend.js +30 -57
  197. package/dist/scene/wind-history.d.ts +1 -2
  198. package/dist/scene/wind-history.js +42 -53
  199. package/dist/scene/wind-plot.js +71 -142
  200. package/dist/server/adapter.d.ts +7 -10
  201. package/dist/server/adapter.js +1 -2
  202. package/dist/server/adapters/campbell.d.ts +18 -20
  203. package/dist/server/adapters/campbell.js +2 -3
  204. package/dist/server/adapters/ecowitt.d.ts +12 -15
  205. package/dist/server/adapters/ecowitt.js +1 -2
  206. package/dist/server/adapters/tempest.d.ts +10 -13
  207. package/dist/server/adapters/tempest.js +1 -2
  208. package/dist/server/adapters/windnerd-climatology.d.ts +5 -8
  209. package/dist/server/adapters/windnerd-climatology.js +5 -5
  210. package/dist/server/adapters/windnerd-live.d.ts +2 -5
  211. package/dist/server/adapters/windnerd-live.js +4 -4
  212. package/dist/server/adapters/windnerd.d.ts +30 -33
  213. package/dist/server/adapters/windnerd.js +2 -3
  214. package/dist/server/config.d.ts +61 -63
  215. package/dist/server/config.js +1 -2
  216. package/dist/server/environment.d.ts +20 -22
  217. package/dist/server/environment.js +1 -2
  218. package/dist/server/feed.d.ts +19 -21
  219. package/dist/server/feed.js +1 -2
  220. package/dist/server/handler.d.ts +4 -7
  221. package/dist/server/handler.js +1 -2
  222. package/dist/server/hologram.d.ts +9 -12
  223. package/dist/server/hologram.js +3 -3
  224. package/dist/server/live.d.ts +2 -5
  225. package/dist/server/live.js +1 -2
  226. package/dist/sse.js +1 -2
  227. package/dist/strings.d.ts +8 -11
  228. package/dist/strings.js +1 -2
  229. package/dist/windnerd.d.ts +4 -7
  230. package/dist/windnerd.js +1 -2
  231. package/package.json +12 -17
  232. package/schema/README.md +1 -1
  233. package/schema/stationclimatology.schema.json +64 -61
  234. package/schema/stationcurrent.schema.json +68 -156
  235. package/schema/stationfeed.schema.json +71 -163
  236. package/schema/stationhistory.schema.json +37 -46
  237. package/schema/stationlive.schema.json +221 -306
@@ -1,76 +1,53 @@
1
1
  import { optionalSpeed, roundSpeed, temperatureText } from "../format.js";
2
- //#region src/scene/table.ts
3
- function stationTableScene(stations, words) {
4
- return {
5
- root: {
6
- ariaLabel: words.aria.table(stations.length),
7
- className: "meteo-station-table"
8
- },
9
- head: {
10
- className: "meteo-station-table-row meteo-station-table-head meteo-microlabel",
11
- columns: [
12
- words.table.station,
13
- words.table.wind,
14
- words.table.lull,
15
- words.table.gust,
16
- words.table.from,
17
- words.table.temp,
18
- words.table.updated
19
- ]
20
- },
21
- bodyClassName: "meteo-station-table-body"
22
- };
2
+ import { el, keyed } from "./node.js";
3
+ import { freshnessBadgeNode } from "./glyphs.js";
4
+ import { directionCellNodes } from "./cells.js";
5
+ // src/scene/table.ts
6
+ const TABLE_ROW_CLASS = "meteo-station-table-row";
7
+ const TABLE_STATION_CELL_CLASS = "meteo-station-table-station";
8
+ function stationTableHeadNode(words) {
9
+ const columns = [
10
+ words.table.station,
11
+ words.table.wind,
12
+ words.table.lull,
13
+ words.table.gust,
14
+ words.table.from,
15
+ words.table.temp,
16
+ words.table.updated
17
+ ];
18
+ return el("div", {
19
+ class: `${TABLE_ROW_CLASS} meteo-station-table-head meteo-microlabel`,
20
+ role: "row"
21
+ }, columns.map((column) => keyed(column, "span", { role: "columnheader" }, column)));
23
22
  }
24
- function stationTableRowScene(input) {
25
- const { formatTime, station, unit, words } = input;
26
- const base = {
27
- className: "meteo-station-table-row",
28
- status: station.status,
29
- stationCellClassName: "meteo-station-table-station"
30
- };
31
- if (station.status !== "ok") return {
32
- ...base,
33
- cells: {
34
- kind: "reason",
35
- className: "meteo-station-table-reason",
36
- text: words.reasons[station.reason]
37
- }
38
- };
23
+ /** Every cell after the station cell. The station cell stays with each
24
+ * binding: its `stationMeta` slot is a published escape hatch whose type
25
+ * differs by binding (a ReactNode there, a DOM node here). */
26
+ function stationTableRowCells(input) {
27
+ const { formatTime, freshness, station, unit, words } = input;
28
+ if (station.status !== "ok") return [el("span", {
29
+ class: "meteo-station-table-reason",
30
+ role: "cell"
31
+ }, words.reasons[station.reason])];
32
+ const cell = (className, ...children) => el("span", {
33
+ class: className,
34
+ role: "cell"
35
+ }, ...children);
36
+ return [
37
+ cell("meteo-station-table-wind", el("strong", void 0, String(roundSpeed(station.reading.windAvgMps, unit))), el("small", void 0, words.speedUnits[unit])),
38
+ cell("meteo-station-table-lull", optionalSpeed(station.reading.windLullMps, unit)),
39
+ cell("meteo-station-table-gust", optionalSpeed(station.reading.windGustMps, unit)),
40
+ cell("meteo-station-table-from", directionCellNodes(station.reading.windAvgMps, station.reading.windDirectionDeg, words)),
41
+ cell("meteo-station-table-temp", temperatureText(station.reading.temperatureC, words)),
42
+ cell("meteo-station-table-updated", el("span", { class: "meteo-station-table-time" }, formatTime(new Date(station.reading.observedAt))), freshness != null ? freshnessBadgeNode(freshness, words) : null)
43
+ ];
44
+ }
45
+ function stationTableRootAttrs(stations, words) {
39
46
  return {
40
- ...base,
41
- cells: {
42
- kind: "reading",
43
- wind: {
44
- className: "meteo-station-table-wind",
45
- value: String(roundSpeed(station.reading.windAvgMps, unit)),
46
- unitLabel: words.speedUnits[unit]
47
- },
48
- lull: {
49
- className: "meteo-station-table-lull",
50
- value: optionalSpeed(station.reading.windLullMps, unit)
51
- },
52
- gust: {
53
- className: "meteo-station-table-gust",
54
- value: optionalSpeed(station.reading.windGustMps, unit)
55
- },
56
- from: {
57
- className: "meteo-station-table-from",
58
- windAvgMps: station.reading.windAvgMps,
59
- windDirectionDeg: station.reading.windDirectionDeg
60
- },
61
- temperature: {
62
- className: "meteo-station-table-temp",
63
- value: temperatureText(station.reading.temperatureC, words)
64
- },
65
- updated: {
66
- className: "meteo-station-table-updated",
67
- time: {
68
- className: "meteo-station-table-time",
69
- text: formatTime(new Date(station.reading.observedAt))
70
- }
71
- }
72
- }
47
+ "aria-label": words.aria.table(stations.length),
48
+ class: "meteo-station-table",
49
+ role: "table"
73
50
  };
74
51
  }
75
- //#endregion
76
- export { stationTableRowScene, stationTableScene };
52
+ const TABLE_BODY_CLASS = "meteo-station-table-body";
53
+ export { TABLE_BODY_CLASS, TABLE_ROW_CLASS, TABLE_STATION_CELL_CLASS, stationTableHeadNode, stationTableRootAttrs, stationTableRowCells };
@@ -1,4 +1,3 @@
1
1
  import "../contract.js";
2
2
  import "../strings.js";
3
- import "../geometry.js";
4
- import "./chart.js";
3
+ import "../geometry.js";
@@ -1,5 +1,7 @@
1
1
  import { chartFrame, chartScales, tickAnchor, trendRuns, trendSeriesPad, trendValueOf, valueScale } from "../geometry.js";
2
- //#region src/scene/trend.ts
2
+ import { el, keyed } from "./node.js";
3
+ import { plotLine, plotText } from "./wind-plot.js";
4
+ // src/scene/trend.ts
3
5
  const TREND_CLASS = "meteo-trend";
4
6
  function trendGate(station, series, words) {
5
7
  if (!station.capabilities.history) return { kind: "hidden" };
@@ -37,19 +39,15 @@ function trendScene(input) {
37
39
  const segments = trendRuns(points, series, history.periodMinutes).map((run) => {
38
40
  const coords = run.samples.map(([ms, value]) => [scales.xAtMs(ms), scale.yAt(value)]);
39
41
  const only = coords[0];
40
- return coords.length === 1 && only != null ? {
41
- kind: "dot",
42
- className: "meteo-trend-dot",
43
- startedAt: run.startedAt,
42
+ return coords.length === 1 && only != null ? keyed(run.startedAt, "circle", {
43
+ class: "meteo-trend-dot",
44
44
  cx: only[0],
45
45
  cy: only[1],
46
46
  r: 2.5
47
- } : {
48
- kind: "polyline",
49
- className: "meteo-trend-line",
50
- startedAt: run.startedAt,
47
+ }) : keyed(run.startedAt, "polyline", {
48
+ class: "meteo-trend-line",
51
49
  points: coords.map(([x, y]) => `${x.toFixed(1)},${y.toFixed(1)}`).join(" ")
52
- };
50
+ });
53
51
  });
54
52
  const seriesLabel = series === "temperature" ? words.trendTemperature : words.trendPressure;
55
53
  const unitWord = series === "temperature" ? words.degC : words.air.unitHpa;
@@ -59,34 +57,14 @@ function trendScene(input) {
59
57
  1
60
58
  ].map((fraction) => {
61
59
  const gridY = frame.plotBottom - fraction * (frame.plotBottom - frame.plotTop);
62
- return {
63
- key: fraction,
64
- line: {
65
- className: "meteo-grid-line",
66
- x1: frame.left,
67
- x2: frame.right,
68
- y1: gridY,
69
- y2: gridY
70
- },
71
- label: {
72
- className: "meteo-grid-label",
73
- anchor: "end",
74
- x: frame.left - 6,
75
- y: gridY + 5,
76
- text: String(Math.round(scale.min + fraction * (scale.max - scale.min)))
77
- }
78
- };
60
+ return keyed(String(fraction), "g", void 0, plotLine({ class: "meteo-grid-line" }, frame.left, frame.right, gridY, gridY), plotText({ class: "meteo-grid-label" }, "end", frame.left - 6, gridY + 5, String(Math.round(scale.min + fraction * (scale.max - scale.min)))));
79
61
  });
80
62
  const tickCount = Math.max(2, Math.min(5, Math.floor((frame.right - frame.left) / 76)));
81
63
  const ticks = Array.from({ length: tickCount }, (_, at) => at / (tickCount - 1)).map((fraction, index) => {
82
64
  const timeMs = scales.startMs + fraction * scales.durationMs;
83
65
  return {
84
- key: index,
85
- className: "meteo-tick",
86
- anchor: tickAnchor(index, 4),
87
- x: scales.xAtMs(timeMs),
88
- y: frame.labelRow,
89
- text: formatTime(new Date(timeMs))
66
+ ...plotText({ class: "meteo-tick" }, tickAnchor(index, 4), scales.xAtMs(timeMs), frame.labelRow, formatTime(new Date(timeMs))),
67
+ key: String(index)
90
68
  };
91
69
  });
92
70
  return {
@@ -104,17 +82,22 @@ function trendScene(input) {
104
82
  viewBox: `0 0 ${frame.width} ${frame.height}`,
105
83
  width: frame.width
106
84
  },
107
- grid,
108
- segments,
109
- ticks,
110
- hit: {
111
- className: "meteo-hit",
85
+ draw: (cursor, hit) => el("svg", {
86
+ "aria-label": words.aria.trend(stationName, seriesLabel),
87
+ class: "meteo-trend-svg",
88
+ height: frame.height,
89
+ role: "img",
90
+ viewBox: `0 0 ${frame.width} ${frame.height}`,
91
+ width: frame.width
92
+ }, grid, segments, ticks, cursor, el("rect", {
93
+ class: "meteo-hit",
112
94
  fill: "transparent",
113
95
  height: frame.height,
114
96
  width: frame.width,
115
97
  x: 0,
116
- y: 0
117
- },
98
+ y: 0,
99
+ ...hit
100
+ })),
118
101
  inspect: (activeIndex) => {
119
102
  const active = activeIndex == null ? void 0 : points[activeIndex];
120
103
  if (active == null) return {
@@ -122,7 +105,7 @@ function trendScene(input) {
122
105
  strong: `${formatTime(new Date(scales.startMs))}–${formatTime(new Date(scales.endMs))}`,
123
106
  span: words.inspectHint
124
107
  },
125
- cursor: null
108
+ cursor: []
126
109
  };
127
110
  const activeValue = trendValueOf(active, series);
128
111
  const x = scales.xAt(active.observedAt);
@@ -131,24 +114,14 @@ function trendScene(input) {
131
114
  strong: formatTime(new Date(active.observedAt)),
132
115
  span: `${seriesLabel} ${activeValue == null ? "—" : `${activeValue.toFixed(1)} ${unitWord}`}`
133
116
  },
134
- cursor: {
135
- line: {
136
- className: "meteo-cursor",
137
- x1: x,
138
- x2: x,
139
- y1: frame.plotTop,
140
- y2: frame.plotBottom + 4
141
- },
142
- dot: activeValue == null ? null : {
143
- className: "meteo-cursor-dot",
144
- cx: x,
145
- cy: scale.yAt(activeValue),
146
- r: 3
147
- }
148
- }
117
+ cursor: [plotLine({ class: "meteo-cursor" }, x, x, frame.plotTop, frame.plotBottom + 4), activeValue == null ? null : el("circle", {
118
+ class: "meteo-cursor-dot",
119
+ cx: x,
120
+ cy: scale.yAt(activeValue),
121
+ r: 3
122
+ })]
149
123
  };
150
124
  }
151
125
  };
152
126
  }
153
- //#endregion
154
127
  export { TREND_CLASS, trendFrame, trendGate, trendScene };
@@ -3,5 +3,4 @@ import "../derive.js";
3
3
  import "../strings.js";
4
4
  import "../instruments.js";
5
5
  import "../geometry.js";
6
- import "./chart.js";
7
- import "./wind-plot.js";
6
+ import "./chart.js";
@@ -1,8 +1,9 @@
1
1
  import { compassDirection, isCalm, thresholdsToMps } from "../derive.js";
2
2
  import { bandPoints, compareTracePoints, compareWindow, historyGaps, isCalmHistory, thinVanes, windowPoints } from "../geometry.js";
3
3
  import { roundSpeed } from "../format.js";
4
- import { calmNoteText, displaySpeedScales, gapHatchPattern, gapHatchRect, gradedMeanTrace, nightRects, speedGridLines, stretchedChartFrame, vaneCells, vaneGuideLines, vaneTickTexts, windRowLabels, windThresholdGuides, windZoneRects } from "./wind-plot.js";
5
- //#region src/scene/wind-history.ts
4
+ import { el } from "./node.js";
5
+ import { calmNoteText, displaySpeedScales, gapHatchPattern, gapHatchRect, gradedMeanTrace, nightRects, plotLine, speedGridLines, stretchedChartFrame, vaneCells, vaneGuideLines, vaneTickTexts, windRowLabels, windThresholdGuides, windZoneRects } from "./wind-plot.js";
6
+ // src/scene/wind-history.ts
6
7
  const WIND_CHART_CLASS = "meteo-wind-chart";
7
8
  function windChartGate(station, words) {
8
9
  if (!station.capabilities.history) return { kind: "hidden" };
@@ -25,6 +26,7 @@ function windChartScene(input) {
25
26
  const scales = displaySpeedScales(points, frame, unit);
26
27
  const band = bandPoints(points, scales);
27
28
  const vanes = thinVanes(points);
29
+ const vaneCellList = vaneCells(vanes, frame, scales, (vane) => String(shown(vane.windAvgMps)), input.favorableDirections);
28
30
  const gaps = historyGaps({
29
31
  ...history,
30
32
  points
@@ -47,46 +49,43 @@ function windChartScene(input) {
47
49
  viewBox: `0 0 ${frame.width} ${frame.height}`,
48
50
  width: frame.width
49
51
  },
50
- defs: {
51
- pattern: gapHatchPattern(hatchId),
52
- clip: {
53
- id: `${hatchId}-plot`,
54
- rect: {
55
- height: frame.plotBottom - frame.plotTop,
56
- width: frame.right - frame.left,
57
- x: frame.left,
58
- y: frame.plotTop
59
- }
60
- }
61
- },
62
- zones: windZoneRects(boundsMps, frame, scales),
63
- nightRects: nightRects(points, frame, scales, input.night),
64
- grid: speedGridLines(frame, scales, shown),
65
- thresholdGuides: windThresholdGuides(thresholds, boundsMps, unit, frame, scales, shown),
66
- vaneGuides: vaneGuideLines(vanes, frame, scales),
67
- gaps: gaps.map(([startMs, endMs]) => gapHatchRect(hatchId, frame, startMs, scales.xAtMs(startMs), scales.xAtMs(endMs) - scales.xAtMs(startMs))),
68
- band: band == null ? null : {
69
- className: "meteo-wind-band",
52
+ draw: (cursor, hit) => el("svg", {
53
+ "aria-label": words.aria.chart(stationName),
54
+ class: "meteo-wind-chart-svg",
55
+ height: frame.height,
56
+ role: "img",
57
+ viewBox: `0 0 ${frame.width} ${frame.height}`,
58
+ width: frame.width
59
+ }, el("defs", void 0, gapHatchPattern(hatchId), el("clipPath", { id: `${hatchId}-plot` }, el("rect", {
60
+ height: frame.plotBottom - frame.plotTop,
61
+ width: frame.right - frame.left,
62
+ x: frame.left,
63
+ y: frame.plotTop
64
+ }))), windZoneRects(boundsMps, frame, scales), nightRects(points, frame, scales, input.night), speedGridLines(frame, scales, shown), windThresholdGuides(thresholds, boundsMps, unit, frame, scales, shown), vaneGuideLines(vanes, frame, scales), gaps.map(([startMs, endMs]) => gapHatchRect(hatchId, frame, startMs, scales.xAtMs(startMs), scales.xAtMs(endMs) - scales.xAtMs(startMs))), band == null ? null : el("polygon", {
65
+ class: "meteo-wind-band",
70
66
  points: band
71
- },
72
- compare: compareTrace == null ? null : {
73
- className: "meteo-wind-compare",
74
- clipPath: `url(#${hatchId}-plot)`,
67
+ }), compareTrace == null ? null : el("polyline", {
68
+ class: "meteo-wind-compare",
69
+ "clip-path": `url(#${hatchId}-plot)`,
75
70
  points: compareTrace
76
- },
77
- mean: gradedMeanTrace(points, scales, boundsMps),
78
- calmNote: isCalmHistory(points) ? calmNoteText(frame, words) : null,
79
- rowLabels: windRowLabels(frame, words),
80
- vanes: vaneCells(vanes, frame, scales, (vane) => String(shown(vane.windAvgMps)), input.favorableDirections),
81
- ticks: vaneTickTexts(vanes, frame, scales, (timeMs) => formatTime(new Date(timeMs))),
82
- hit: {
83
- className: "meteo-hit",
71
+ }), gradedMeanTrace(points, scales, boundsMps), isCalmHistory(points) ? calmNoteText(frame, words) : null, windRowLabels(frame, words)[0], vaneCellList.map((vane) => ({
72
+ ...vane.mark,
73
+ key: String(vane.key)
74
+ })), vaneCellList.flatMap((vane) => vane.label == null ? [] : [{
75
+ ...vane.label,
76
+ key: String(vane.key)
77
+ }]), windRowLabels(frame, words)[1], vaneCellList.flatMap((vane) => vane.value == null ? [] : [{
78
+ ...vane.value,
79
+ key: String(vane.key)
80
+ }]), vaneTickTexts(vanes, frame, scales, (timeMs) => formatTime(new Date(timeMs))), cursor, el("rect", {
81
+ class: "meteo-hit",
84
82
  fill: "transparent",
85
83
  height: frame.height,
86
84
  width: frame.width,
87
85
  x: 0,
88
- y: 0
89
- },
86
+ y: 0,
87
+ ...hit
88
+ })),
90
89
  inspect: (activeIndex) => {
91
90
  const active = activeIndex == null ? void 0 : points[activeIndex];
92
91
  if (active == null) return {
@@ -97,7 +96,7 @@ function windChartScene(input) {
97
96
  text: words.inspectHint
98
97
  }]
99
98
  },
100
- cursor: null
99
+ cursor: []
101
100
  };
102
101
  const lead = `${words.avgLabel} ${shown(active.windAvgMps)} · ${words.lullLabel} ${active.windLullMps == null ? "—" : shown(active.windLullMps)} · ${words.gustLabel} ${active.windGustMps == null ? "—" : shown(active.windGustMps)} ${words.speedUnits[unit]} · `;
103
102
  const span = isCalm(active.windAvgMps) ? [{
@@ -126,24 +125,14 @@ function windChartScene(input) {
126
125
  strong: formatTime(new Date(active.observedAt)),
127
126
  span
128
127
  },
129
- cursor: {
130
- line: {
131
- className: "meteo-cursor",
132
- x1: x,
133
- x2: x,
134
- y1: frame.plotTop,
135
- y2: frame.vaneRow + 9
136
- },
137
- dot: {
138
- className: "meteo-cursor-dot",
139
- cx: x,
140
- cy: scales.yAt(active.windAvgMps),
141
- r: 3
142
- }
143
- }
128
+ cursor: [plotLine({ class: "meteo-cursor" }, x, x, frame.plotTop, frame.vaneRow + 9), el("circle", {
129
+ class: "meteo-cursor-dot",
130
+ cx: x,
131
+ cy: scales.yAt(active.windAvgMps),
132
+ r: 3
133
+ })]
144
134
  };
145
135
  }
146
136
  };
147
137
  }
148
- //#endregion
149
138
  export { WIND_CHART_CLASS, windChartGate, windChartScene };