@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,72 +1,34 @@
1
1
  import { optionalSpeed, roundSpeed } from "../format.js";
2
+ import { el, keyed } from "./node.js";
3
+ import { windArrowNode } from "./glyphs.js";
2
4
  import { inDirectionArcs } from "@azohra/meteo.core";
3
- //#region src/scene/recent-summaries.ts
5
+ // src/scene/recent-summaries.ts
4
6
  const RECENT_SUMMARIES_CLASS = "meteo-recent-summaries";
5
- /** hidden unless the source declares the capability; the no-samples words
7
+ /** Null unless the source declares the capability; the no-samples words
6
8
  * when the declared block is dark. */
7
- function recentSummariesGate(station, summaries, words) {
8
- const source = summaries ?? (station?.status === "ok" ? station.recentSummaries ?? null : null);
9
- if (station != null && station.capabilities.recentSummaries !== true) return { kind: "hidden" };
10
- if (source == null || source.length === 0) return {
11
- kind: "note",
12
- className: `${RECENT_SUMMARIES_CLASS} meteo-recent-summaries-na`,
13
- text: words.noSamples
14
- };
15
- return {
16
- kind: "draw",
17
- summaries: source
18
- };
19
- }
20
9
  function recentSummariesScene(input) {
21
- const { favorableDirections, stationName, summaries, unit, words } = input;
10
+ const { favorableDirections, station, summaries, unit, words } = input;
11
+ const source = summaries ?? (station?.status === "ok" ? station.recentSummaries ?? null : null);
12
+ if (station != null && station.capabilities.recentSummaries !== true) return null;
13
+ if (source == null || source.length === 0) return el("div", {
14
+ class: "meteo-recent-summaries meteo-recent-summaries-na",
15
+ role: "note"
16
+ }, words.noSamples);
22
17
  const arcs = favorableDirections ?? [];
23
- return {
24
- className: RECENT_SUMMARIES_CLASS,
25
- ariaLabel: words.aria.recentSummaries(stationName ?? ""),
26
- panels: summaries.map((block) => {
27
- const points = block.points;
28
- const avgMps = points.length === 0 ? null : points.reduce((sum, point) => sum + point.windAvgMps, 0) / points.length;
29
- const gusts = points.map((point) => point.windGustMps).filter((gust) => gust != null);
30
- const lulls = points.map((point) => point.windLullMps).filter((lull) => lull != null);
31
- return {
32
- key: block.windowMinutes,
33
- className: "meteo-recent-summary",
34
- label: {
35
- className: "meteo-microlabel",
36
- text: words.recentWindowLabel(block.windowMinutes)
37
- },
38
- stats: [
39
- {
40
- key: "avg",
41
- className: "meteo-recent-summary-stat",
42
- label: words.avgLabel,
43
- value: avgMps == null ? "—" : `${roundSpeed(avgMps, unit)} ${words.speedUnits[unit]}`
44
- },
45
- {
46
- key: "gust",
47
- className: "meteo-recent-summary-stat",
48
- label: words.gustLabel,
49
- value: optionalSpeed(gusts.length === 0 ? null : Math.max(...gusts), unit)
50
- },
51
- {
52
- key: "lull",
53
- className: "meteo-recent-summary-stat",
54
- label: words.lullLabel,
55
- value: optionalSpeed(lulls.length === 0 ? null : Math.min(...lulls), unit)
56
- }
57
- ],
58
- ghosts: points.flatMap((point) => {
59
- if (point.windDirectionDeg == null) return [];
60
- const verdict = arcs.length === 0 ? "" : inDirectionArcs(point.windDirectionDeg, arcs) ? " meteo-direction-favorable" : " meteo-direction-unfavorable";
61
- return [{
62
- key: point.observedAt,
63
- className: `meteo-recent-summary-ghost${verdict}`,
64
- deg: point.windDirectionDeg
65
- }];
66
- })
67
- };
68
- })
69
- };
18
+ const stat = (key, label, value) => keyed(key, "div", { class: "meteo-recent-summary-stat" }, el("dt", { class: "meteo-microlabel" }, label), el("dd", void 0, value));
19
+ return el("div", {
20
+ "aria-label": words.aria.recentSummaries(station?.name ?? ""),
21
+ class: RECENT_SUMMARIES_CLASS
22
+ }, source.map((block) => {
23
+ const points = block.points;
24
+ const avgMps = points.length === 0 ? null : points.reduce((sum, point) => sum + point.windAvgMps, 0) / points.length;
25
+ const gusts = points.map((point) => point.windGustMps).filter((gust) => gust != null);
26
+ const lulls = points.map((point) => point.windLullMps).filter((lull) => lull != null);
27
+ return keyed(String(block.windowMinutes), "section", { class: "meteo-recent-summary" }, el("h4", { class: "meteo-microlabel" }, words.recentWindowLabel(block.windowMinutes)), el("div", { class: "meteo-recent-summary-ghosts" }, points.flatMap((point) => {
28
+ if (point.windDirectionDeg == null) return [];
29
+ const verdict = arcs.length === 0 ? "" : inDirectionArcs(point.windDirectionDeg, arcs) ? " meteo-direction-favorable" : " meteo-direction-unfavorable";
30
+ return [keyed(point.observedAt, "span", { class: `meteo-recent-summary-ghost${verdict}` }, windArrowNode(point.windDirectionDeg, 12))];
31
+ })), el("dl", { class: "meteo-recent-summary-stats" }, stat("avg", words.avgLabel, avgMps == null ? "—" : `${roundSpeed(avgMps, unit)} ${words.speedUnits[unit]}`), stat("gust", words.gustLabel, optionalSpeed(gusts.length === 0 ? null : Math.max(...gusts), unit)), stat("lull", words.lullLabel, optionalSpeed(lulls.length === 0 ? null : Math.min(...lulls), unit))));
32
+ }));
70
33
  }
71
- //#endregion
72
- export { RECENT_SUMMARIES_CLASS, recentSummariesGate, recentSummariesScene };
34
+ export { RECENT_SUMMARIES_CLASS, recentSummariesScene };
@@ -1,135 +1,106 @@
1
1
  import { normalizeDegrees, thresholdsToMps } from "../derive.js";
2
2
  import { speedBand, windRose } from "../geometry.js";
3
3
  import { ROSE_CARDINAL_LETTERS, ROSE_INTERCARDINAL_BEARINGS, ROSE_PETAL_FILL, roseBandPath, rosePetalPath, rosePolar, roseRingArcPath } from "../instruments.js";
4
- //#region src/scene/rose.ts
4
+ import { el, keyed } from "./node.js";
5
+ // src/scene/rose.ts
5
6
  const WIND_ROSE_CLASS = "meteo-wind-rose";
6
7
  function windRoseSource(points, station) {
7
- return points ?? (station?.status === "ok" ? station.history?.points ?? null : null) ?? [];
8
+ return points ?? (station?.status === "ok" ? station.history?.points : null) ?? [];
8
9
  }
9
- function windRoseGate(source, words) {
10
- if (source.length === 0) return {
11
- kind: "note",
12
- className: `${WIND_ROSE_CLASS} meteo-wind-rose-na`,
13
- text: words.noHistory
14
- };
15
- return { kind: "draw" };
16
- }
17
- function windRoseScene(input) {
10
+ function windRoseScene(input, extra = []) {
18
11
  const { favorableDirections, source, stationName, thresholds, words } = input;
12
+ if (input.summary == null && source.length === 0) return el("div", {
13
+ class: "meteo-wind-rose meteo-wind-rose-na",
14
+ role: "note"
15
+ }, words.noHistory);
19
16
  const boundsMps = thresholds == null ? null : thresholdsToMps(thresholds);
20
17
  const rose = input.summary ?? windRose(source, input.sectorCount);
21
18
  const sectorCount = rose.sectors.length;
22
19
  const maxFrequency = Math.max(...rose.sectors.map((sector) => sector.frequency));
23
20
  const halfWidthDeg = 360 / sectorCount / 2 * ROSE_PETAL_FILL;
24
- const calmPercent = Math.round(rose.calmFraction * 100);
25
21
  const [ringLabelX, ringLabelY] = rosePolar(135, 70);
26
22
  const favorable = favorableDirections != null && favorableDirections.length > 0;
27
23
  const baseLabel = stationName != null ? words.aria.rose(stationName) : words.aria.roseGeneric;
28
- const roseLabel = favorable && favorableDirections != null ? `${baseLabel} ${words.aria.roseFavorable(favorableDirections.map((sector) => `${Math.round(normalizeDegrees(sector.fromDeg))}°–${Math.round(normalizeDegrees(sector.toDeg))}°`).join(", "))}` : baseLabel;
29
- return {
30
- className: WIND_ROSE_CLASS,
31
- svg: {
32
- ariaLabel: roseLabel,
33
- className: "meteo-wind-rose-svg",
34
- height: 190,
35
- viewBox: `0 0 190 190`,
36
- width: 190
37
- },
38
- gridCircles: [
39
- 1,
40
- 2 / 3,
41
- 1 / 3
42
- ].map((fraction) => ({
43
- key: fraction,
44
- className: "meteo-wind-rose-grid",
45
- cx: 95,
46
- cy: 95,
47
- r: 70 * fraction
48
- })),
49
- ring: favorable && favorableDirections != null ? {
50
- unfavorable: {
51
- className: "meteo-wind-rose-ring-unfavorable",
52
- cx: 95,
53
- cy: 95,
54
- r: 75
55
- },
56
- favorable: favorableDirections.map((sector) => ({
57
- key: `${sector.fromDeg}-${sector.toDeg}`,
58
- className: "meteo-wind-rose-ring-favorable",
59
- d: roseRingArcPath(sector)
60
- }))
61
- } : null,
62
- ticks: ROSE_INTERCARDINAL_BEARINGS.map((bearing) => {
63
- const [x1, y1] = rosePolar(bearing, 66);
64
- const [x2, y2] = rosePolar(bearing, 74);
65
- return {
66
- key: bearing,
67
- className: "meteo-wind-rose-tick",
68
- x1,
69
- x2,
70
- y1,
71
- y2
72
- };
73
- }),
74
- letters: ROSE_CARDINAL_LETTERS.map(({ bearing, letter }) => {
75
- const [x, y] = rosePolar(bearing, 82);
76
- return {
77
- key: letter,
78
- className: "meteo-wind-rose-letter",
79
- anchor: "middle",
80
- x,
81
- y: y + 4,
82
- text: letter
83
- };
84
- }),
85
- petals: rose.sectors.flatMap((sector) => {
86
- if (sector.count === 0 || maxFrequency === 0) return [];
87
- const radius = 16 + sector.frequency / maxFrequency * 54;
88
- if (sector.bandCounts != null) {
89
- let cumulative = 0;
90
- return sector.bandCounts.flatMap((bandCount, band) => {
91
- if (bandCount === 0) return [];
92
- const innerRadius = 16 + cumulative / sector.count * (radius - 16);
93
- cumulative += bandCount;
94
- const outerRadius = 16 + cumulative / sector.count * (radius - 16);
95
- return [{
96
- key: `${sector.bearingDeg}-${band}`,
97
- className: `meteo-wind-rose-petal meteo-band-${band}`,
98
- d: roseBandPath(sector.bearingDeg, innerRadius, outerRadius, halfWidthDeg)
99
- }];
100
- });
101
- }
102
- const banded = boundsMps != null && sector.meanSpeedMps != null ? ` meteo-band-${speedBand(sector.meanSpeedMps, boundsMps)}` : "";
103
- return [{
104
- key: sector.bearingDeg,
105
- className: `meteo-wind-rose-petal${banded}`,
106
- d: rosePetalPath(sector.bearingDeg, radius, halfWidthDeg)
107
- }];
108
- }),
109
- ringLabel: maxFrequency > 0 ? {
110
- className: "meteo-wind-rose-ring-label",
111
- anchor: "start",
112
- x: ringLabelX + 3,
113
- y: ringLabelY + 9,
114
- text: words.percentShare(Math.round(maxFrequency * 100))
115
- } : null,
116
- hub: {
117
- className: "meteo-wind-rose-hub",
118
- cx: 95,
119
- cy: 95,
120
- r: 16
121
- },
122
- dot: {
123
- className: "meteo-wind-rose-dot",
124
- cx: 95,
125
- cy: 95,
126
- r: 3
127
- },
128
- calmCaption: rose.calmFraction > 0 ? {
129
- className: "meteo-wind-rose-calm",
130
- text: words.percentCalm(calmPercent)
131
- } : null
132
- };
24
+ const roseLabel = favorable && favorableDirections != null ? `${baseLabel} ${words.aria.roseFavorable(favorableDirections.map((sector) => `${Math.round(normalizeDegrees(sector.fromDeg))}\u00b0\u2013${Math.round(normalizeDegrees(sector.toDeg))}\u00b0`).join(", "))}` : baseLabel;
25
+ const petals = rose.sectors.flatMap((sector) => {
26
+ if (sector.count === 0 || maxFrequency === 0) return [];
27
+ const radius = 16 + sector.frequency / maxFrequency * 54;
28
+ if (sector.bandCounts != null) {
29
+ let cumulative = 0;
30
+ return sector.bandCounts.flatMap((bandCount, band) => {
31
+ if (bandCount === 0) return [];
32
+ const innerRadius = 16 + cumulative / sector.count * (radius - 16);
33
+ cumulative += bandCount;
34
+ const outerRadius = 16 + cumulative / sector.count * (radius - 16);
35
+ return [keyed(`${sector.bearingDeg}-${band}`, "path", {
36
+ class: `meteo-wind-rose-petal meteo-band-${band}`,
37
+ d: roseBandPath(sector.bearingDeg, innerRadius, outerRadius, halfWidthDeg)
38
+ })];
39
+ });
40
+ }
41
+ const banded = boundsMps != null && sector.meanSpeedMps != null ? ` meteo-band-${speedBand(sector.meanSpeedMps, boundsMps)}` : "";
42
+ return [keyed(String(sector.bearingDeg), "path", {
43
+ class: `meteo-wind-rose-petal${banded}`,
44
+ d: rosePetalPath(sector.bearingDeg, radius, halfWidthDeg)
45
+ })];
46
+ });
47
+ return el("div", { class: WIND_ROSE_CLASS }, el("svg", {
48
+ "aria-label": roseLabel,
49
+ class: "meteo-wind-rose-svg",
50
+ height: 190,
51
+ role: "img",
52
+ viewBox: `0 0 190 190`,
53
+ width: 190
54
+ }, [
55
+ 1,
56
+ 2 / 3,
57
+ 1 / 3
58
+ ].map((fraction) => keyed(String(fraction), "circle", {
59
+ class: "meteo-wind-rose-grid",
60
+ cx: 95,
61
+ cy: 95,
62
+ r: 70 * fraction
63
+ })), favorable && favorableDirections != null ? [el("circle", {
64
+ class: "meteo-wind-rose-ring-unfavorable",
65
+ cx: 95,
66
+ cy: 95,
67
+ r: 75
68
+ }), ...favorableDirections.map((sector) => keyed(`${sector.fromDeg}-${sector.toDeg}`, "path", {
69
+ class: "meteo-wind-rose-ring-favorable",
70
+ d: roseRingArcPath(sector)
71
+ }))] : [], ROSE_INTERCARDINAL_BEARINGS.map((bearing) => {
72
+ const [x1, y1] = rosePolar(bearing, 66);
73
+ const [x2, y2] = rosePolar(bearing, 74);
74
+ return keyed(String(bearing), "line", {
75
+ class: "meteo-wind-rose-tick",
76
+ x1,
77
+ x2,
78
+ y1,
79
+ y2
80
+ });
81
+ }), ROSE_CARDINAL_LETTERS.map(({ bearing, letter }) => {
82
+ const [x, y] = rosePolar(bearing, 82);
83
+ return keyed(letter, "text", {
84
+ class: "meteo-wind-rose-letter",
85
+ "text-anchor": "middle",
86
+ x,
87
+ y: y + 4
88
+ }, letter);
89
+ }), petals, maxFrequency > 0 ? el("text", {
90
+ class: "meteo-wind-rose-ring-label",
91
+ "text-anchor": "start",
92
+ x: ringLabelX + 3,
93
+ y: ringLabelY + 9
94
+ }, words.percentShare(Math.round(maxFrequency * 100))) : null, el("circle", {
95
+ class: "meteo-wind-rose-hub",
96
+ cx: 95,
97
+ cy: 95,
98
+ r: 16
99
+ }), el("circle", {
100
+ class: "meteo-wind-rose-dot",
101
+ cx: 95,
102
+ cy: 95,
103
+ r: 3
104
+ })), rose.calmFraction > 0 ? el("p", { class: "meteo-wind-rose-calm" }, words.percentCalm(Math.round(rose.calmFraction * 100))) : null, extra);
133
105
  }
134
- //#endregion
135
- export { WIND_ROSE_CLASS, windRoseGate, windRoseScene, windRoseSource };
106
+ export { WIND_ROSE_CLASS, windRoseScene, windRoseSource };
@@ -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, speedToMps } from "../derive.js";
2
2
  import { roundSpeed } from "../format.js";
3
3
  import { samplePoints, sampleRuns, sampleScales, thinSampleVanes } from "../samples.js";
4
- import { calmNoteText, speedGridLines, stretchedChartFrame, vaneCells, vaneGuideLines, vaneTickTexts, windRowLabels } from "./wind-plot.js";
5
- //#region src/scene/sample-strip.ts
4
+ import { el, keyed } from "./node.js";
5
+ import { calmNoteText, plotLine, speedGridLines, stretchedChartFrame, vaneCells, vaneGuideLines, vaneTickTexts, windRowLabels } from "./wind-plot.js";
6
+ // src/scene/sample-strip.ts
6
7
  const SAMPLE_STRIP_CLASS = "meteo-sample-strip";
7
8
  function sampleStripGate(samples, words) {
8
9
  if (samples == null || samples.points.length < 2) return {
@@ -26,6 +27,7 @@ function sampleStripScene(input) {
26
27
  });
27
28
  const runs = sampleRuns(samples);
28
29
  const vanes = thinSampleVanes(points);
30
+ const vaneCellList = vaneCells(vanes, frame, scales, (vane) => String(shown(vane.windAvgMps)), input.favorableDirections);
29
31
  return {
30
32
  frame,
31
33
  scales,
@@ -41,33 +43,39 @@ function sampleStripScene(input) {
41
43
  viewBox: `0 0 ${frame.width} ${frame.height}`,
42
44
  width: frame.width
43
45
  },
44
- grid: speedGridLines(frame, scales, shown),
45
- vaneGuides: vaneGuideLines(vanes, frame, scales),
46
- trace: runs.map((run) => run.length === 1 ? {
47
- kind: "dot",
48
- key: run[0].observedAt,
49
- className: "meteo-sample-dot",
46
+ draw: (cursor, hit) => el("svg", {
47
+ "aria-label": words.aria.sampleStrip(stationName),
48
+ class: "meteo-sample-strip-svg",
49
+ height: frame.height,
50
+ role: "img",
51
+ viewBox: `0 0 ${frame.width} ${frame.height}`,
52
+ width: frame.width
53
+ }, speedGridLines(frame, scales, shown), vaneGuideLines(vanes, frame, scales), runs.map((run) => run.length === 1 ? keyed(run[0].observedAt, "circle", {
54
+ class: "meteo-sample-dot",
50
55
  cx: scales.xAt(run[0].observedAt),
51
56
  cy: scales.yAt(run[0].windMps),
52
57
  r: 2
53
- } : {
54
- kind: "polyline",
55
- key: run[0].observedAt,
56
- className: "meteo-sample-trace",
58
+ }) : keyed(run[0].observedAt, "polyline", {
59
+ class: "meteo-sample-trace",
57
60
  points: samplePoints(run, scales)
58
- }),
59
- calmNote: points.every((sample) => isCalm(sample.windMps)) ? calmNoteText(frame, words) : null,
60
- rowLabels: windRowLabels(frame, words),
61
- vanes: vaneCells(vanes, frame, scales, (vane) => String(shown(vane.windAvgMps)), input.favorableDirections),
62
- ticks: vaneTickTexts(vanes, frame, scales, (timeMs) => formatTime(new Date(timeMs))),
63
- hit: {
64
- className: "meteo-hit",
61
+ })), points.every((sample) => isCalm(sample.windMps)) ? calmNoteText(frame, words) : null, windRowLabels(frame, words)[0], vaneCellList.map((vane) => ({
62
+ ...vane.mark,
63
+ key: String(vane.key)
64
+ })), vaneCellList.flatMap((vane) => vane.label == null ? [] : [{
65
+ ...vane.label,
66
+ key: String(vane.key)
67
+ }]), windRowLabels(frame, words)[1], vaneCellList.flatMap((vane) => vane.value == null ? [] : [{
68
+ ...vane.value,
69
+ key: String(vane.key)
70
+ }]), vaneTickTexts(vanes, frame, scales, (timeMs) => formatTime(new Date(timeMs))), cursor, el("rect", {
71
+ class: "meteo-hit",
65
72
  fill: "transparent",
66
73
  height: frame.height,
67
74
  width: frame.width,
68
75
  x: 0,
69
- y: 0
70
- },
76
+ y: 0,
77
+ ...hit
78
+ })),
71
79
  inspect: (activeIndex) => {
72
80
  const active = activeIndex == null ? void 0 : points[activeIndex];
73
81
  if (active == null) return {
@@ -78,7 +86,7 @@ function sampleStripScene(input) {
78
86
  text: words.inspectHint
79
87
  }]
80
88
  },
81
- cursor: null
89
+ cursor: []
82
90
  };
83
91
  const lead = `${shown(active.windMps)} ${words.speedUnits[unit]} · `;
84
92
  const span = isCalm(active.windMps) ? [{
@@ -107,24 +115,14 @@ function sampleStripScene(input) {
107
115
  strong: formatTime(new Date(active.observedAt)),
108
116
  span
109
117
  },
110
- cursor: {
111
- line: {
112
- className: "meteo-cursor",
113
- x1: x,
114
- x2: x,
115
- y1: frame.plotTop,
116
- y2: frame.vaneRow + 9
117
- },
118
- dot: {
119
- className: "meteo-cursor-dot",
120
- cx: x,
121
- cy: scales.yAt(active.windMps),
122
- r: 3
123
- }
124
- }
118
+ cursor: [plotLine({ class: "meteo-cursor" }, x, x, frame.plotTop, frame.vaneRow + 9), el("circle", {
119
+ class: "meteo-cursor-dot",
120
+ cx: x,
121
+ cy: scales.yAt(active.windMps),
122
+ r: 3
123
+ })]
125
124
  };
126
125
  }
127
126
  };
128
127
  }
129
- //#endregion
130
128
  export { SAMPLE_STRIP_CLASS, sampleStripGate, sampleStripScene };
@@ -1,73 +1,63 @@
1
1
  import { thresholdsToMps } from "../derive.js";
2
2
  import { speedBand } from "../geometry.js";
3
3
  import { bandStrips, historyRuns, sparklineScale } from "../instruments.js";
4
- //#region src/scene/sparkline.ts
4
+ import { el, keyed } from "./node.js";
5
+ // src/scene/sparkline.ts
5
6
  const coordinate = (x, y) => `${x.toFixed(1)},${y.toFixed(1)}`;
6
7
  function sparklineScene(input) {
7
8
  const { height, showBand, station, thresholds, width, words } = input;
8
9
  const label = words.aria.sparkline(station.name);
9
10
  const history = station.status === "ok" ? station.history : null;
10
11
  if (!(station.capabilities.history && history != null && history.points.length >= 2) || history == null) return {
11
- kind: "placeholder",
12
- ariaLabel: label,
13
- className: "meteo-sparkline meteo-sparkline-na",
14
- height,
15
- text: "—",
16
- width
12
+ ...el("span", {
13
+ "aria-label": label,
14
+ class: "meteo-sparkline meteo-sparkline-na",
15
+ role: "img"
16
+ }, "—"),
17
+ style: {
18
+ height: `${height}px`,
19
+ width: `${width}px`
20
+ }
17
21
  };
18
22
  const points = history.points;
19
23
  const { xAt, yAt } = sparklineScale(points, width, height);
20
24
  const runs = historyRuns(points, history.periodMinutes);
21
25
  const strips = showBand ? bandStrips(runs) : [];
22
26
  const boundsMps = thresholds == null ? null : thresholdsToMps(thresholds);
23
- const trace = boundsMps == null ? runs.map((segment) => segment.points.length === 1 ? {
24
- kind: "dot",
25
- key: segment.startedAt,
26
- className: "meteo-sparkline-dot",
27
+ const trace = boundsMps == null ? runs.map((segment) => segment.points.length === 1 ? keyed(segment.startedAt, "circle", {
28
+ class: "meteo-sparkline-dot",
27
29
  cx: xAt(Date.parse(segment.points[0].observedAt)),
28
30
  cy: yAt(segment.points[0].windAvgMps),
29
31
  r: 1.5
30
- } : {
31
- kind: "polyline",
32
- key: segment.startedAt,
33
- className: "meteo-sparkline-line",
32
+ }) : keyed(segment.startedAt, "polyline", {
33
+ class: "meteo-sparkline-line",
34
34
  points: segment.points.map((point) => coordinate(xAt(Date.parse(point.observedAt)), yAt(point.windAvgMps))).join(" ")
35
- }) : runs.flatMap((segment) => segment.points.length === 1 ? [{
36
- kind: "dot",
37
- key: segment.startedAt,
38
- className: `meteo-sparkline-dot meteo-band-${speedBand(segment.points[0].windAvgMps, boundsMps)}`,
35
+ })) : runs.flatMap((segment) => segment.points.length === 1 ? [keyed(segment.startedAt, "circle", {
36
+ class: `meteo-sparkline-dot meteo-band-${speedBand(segment.points[0].windAvgMps, boundsMps)}`,
39
37
  cx: xAt(Date.parse(segment.points[0].observedAt)),
40
38
  cy: yAt(segment.points[0].windAvgMps),
41
39
  r: 1.5
42
- }] : segment.points.slice(1).map((point, index) => {
40
+ })] : segment.points.slice(1).map((point, index) => {
43
41
  const previous = segment.points[index];
44
42
  const band = speedBand((previous.windAvgMps + point.windAvgMps) / 2, boundsMps);
45
- return {
46
- kind: "segment",
47
- key: point.observedAt,
48
- className: `meteo-sparkline-segment meteo-band-${band}`,
43
+ return keyed(point.observedAt, "line", {
44
+ class: `meteo-sparkline-segment meteo-band-${band}`,
49
45
  x1: xAt(Date.parse(previous.observedAt)),
50
46
  x2: xAt(Date.parse(point.observedAt)),
51
47
  y1: yAt(previous.windAvgMps),
52
48
  y2: yAt(point.windAvgMps)
53
- };
49
+ });
54
50
  }));
55
- return {
56
- kind: "draw",
57
- svg: {
58
- ariaLabel: label,
59
- className: "meteo-sparkline",
60
- height,
61
- viewBox: `0 0 ${width} ${height}`,
62
- width
63
- },
64
- bands: strips.filter((strip) => strip.points.length >= 2).map((strip) => ({
65
- key: strip.startedAt,
66
- className: "meteo-sparkline-band",
67
- points: [...strip.points.map((point) => coordinate(xAt(Date.parse(point.observedAt)), yAt(point.windGustMps))), ...[...strip.points].reverse().map((point) => coordinate(xAt(Date.parse(point.observedAt)), yAt(point.windLullMps)))].join(" ")
68
- })),
69
- trace
70
- };
51
+ return el("svg", {
52
+ "aria-label": label,
53
+ class: "meteo-sparkline",
54
+ height,
55
+ role: "img",
56
+ viewBox: `0 0 ${width} ${height}`,
57
+ width
58
+ }, strips.filter((strip) => strip.points.length >= 2).map((strip) => keyed(strip.startedAt, "polygon", {
59
+ class: "meteo-sparkline-band",
60
+ points: [...strip.points.map((point) => coordinate(xAt(Date.parse(point.observedAt)), yAt(point.windGustMps))), ...[...strip.points].reverse().map((point) => coordinate(xAt(Date.parse(point.observedAt)), yAt(point.windLullMps)))].join(" ")
61
+ })), trace);
71
62
  }
72
- //#endregion
73
63
  export { sparklineScene };
@@ -1,63 +1,23 @@
1
1
  import { optionalSpeed, roundSpeed, temperatureText } from "../format.js";
2
- //#region src/scene/strip.ts
2
+ import { el } from "./node.js";
3
+ import { freshnessBadgeNode } from "./glyphs.js";
4
+ import { directionCellNodes, stationNameNode } from "./cells.js";
5
+ // src/scene/strip.ts
3
6
  function stationStripScene(input) {
4
- const { formatTime, station, unit, words } = input;
5
- const root = {
6
- ariaLabel: words.aria.strip(station.name),
7
- className: "meteo-strip",
8
- status: station.status
9
- };
10
- if (station.status !== "ok") return {
11
- root,
12
- stationClassName: "meteo-strip-station",
13
- body: {
14
- kind: "reason",
15
- className: "meteo-strip-reason",
16
- text: words.reasons[station.reason]
17
- }
18
- };
19
- return {
20
- root,
21
- stationClassName: "meteo-strip-station",
22
- body: {
23
- kind: "reading",
24
- wind: {
25
- className: "meteo-strip-wind",
26
- value: String(roundSpeed(station.reading.windAvgMps, unit)),
27
- unitLabel: words.speedUnits[unit]
28
- },
29
- gustLull: station.capabilities.gustLull ? {
30
- lull: {
31
- className: "meteo-strip-lull",
32
- labelClassName: "meteo-microlabel",
33
- label: words.lullLabel,
34
- value: optionalSpeed(station.reading.windLullMps, unit)
35
- },
36
- gust: {
37
- className: "meteo-strip-gust",
38
- labelClassName: "meteo-microlabel",
39
- label: words.gustLabel,
40
- value: optionalSpeed(station.reading.windGustMps, unit)
41
- }
42
- } : null,
43
- from: {
44
- className: "meteo-strip-from",
45
- windAvgMps: station.reading.windAvgMps,
46
- windDirectionDeg: station.reading.windDirectionDeg
47
- },
48
- temperature: station.capabilities.temperature ? {
49
- className: "meteo-strip-temp",
50
- text: temperatureText(station.reading.temperatureC, words)
51
- } : null,
52
- updated: {
53
- className: "meteo-strip-updated",
54
- time: {
55
- className: "meteo-strip-time",
56
- text: formatTime(new Date(station.reading.observedAt))
57
- }
58
- }
59
- }
60
- };
7
+ const { formatTime, freshness, station, unit, words } = input;
8
+ const labelled = (className, label, value) => el("span", { class: className }, el("small", { class: "meteo-microlabel" }, label), value);
9
+ const cells = station.status !== "ok" ? [el("span", { class: "meteo-strip-reason" }, words.reasons[station.reason])] : [
10
+ el("span", { class: "meteo-strip-wind" }, el("strong", void 0, String(roundSpeed(station.reading.windAvgMps, unit))), el("small", void 0, words.speedUnits[unit])),
11
+ ...station.capabilities.gustLull ? [labelled("meteo-strip-lull", words.lullLabel, optionalSpeed(station.reading.windLullMps, unit)), labelled("meteo-strip-gust", words.gustLabel, optionalSpeed(station.reading.windGustMps, unit))] : [],
12
+ el("span", { class: "meteo-strip-from" }, directionCellNodes(station.reading.windAvgMps, station.reading.windDirectionDeg, words)),
13
+ station.capabilities.temperature ? el("span", { class: "meteo-strip-temp" }, temperatureText(station.reading.temperatureC, words)) : null,
14
+ el("span", { class: "meteo-strip-updated" }, el("span", { class: "meteo-strip-time" }, formatTime(new Date(station.reading.observedAt))), freshness != null ? freshnessBadgeNode(freshness, words) : null)
15
+ ];
16
+ return el("div", {
17
+ "aria-label": words.aria.strip(station.name),
18
+ class: "meteo-strip",
19
+ "data-status": station.status,
20
+ role: "group"
21
+ }, el("span", { class: "meteo-strip-station" }, stationNameNode(station)), cells);
61
22
  }
62
- //#endregion
63
23
  export { stationStripScene };