@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.
Files changed (147) hide show
  1. package/README.md +17 -17
  2. package/dist/client/climatology.js +1 -1
  3. package/dist/client/history.js +3 -11
  4. package/dist/client/live.d.ts +2 -1
  5. package/dist/client/live.js +7 -4
  6. package/dist/client/stores.js +10 -2
  7. package/dist/climatology.d.ts +1 -1
  8. package/dist/climatology.js +1 -1
  9. package/dist/connectivity.d.ts +2 -2
  10. package/dist/contract.d.ts +98 -98
  11. package/dist/derive.js +9 -8
  12. package/dist/elements/elements/AirExtremesElement.js +5 -18
  13. package/dist/elements/elements/AirMatrixElement.js +6 -31
  14. package/dist/elements/elements/ClimatologyDailyPatternElement.js +17 -12
  15. package/dist/elements/elements/ClimatologyRoseElement.js +5 -15
  16. package/dist/elements/elements/CompassFanElement.js +5 -64
  17. package/dist/elements/elements/CurrentConditionsElement.js +7 -26
  18. package/dist/elements/elements/DailyPatternElement.d.ts +0 -1
  19. package/dist/elements/elements/DailyPatternElement.js +6 -120
  20. package/dist/elements/elements/DialElement.js +3 -95
  21. package/dist/elements/elements/FavorableShareElement.js +6 -21
  22. package/dist/elements/elements/RecentSummariesElement.js +6 -23
  23. package/dist/elements/elements/SparklineElement.d.ts +0 -1
  24. package/dist/elements/elements/SparklineElement.js +4 -39
  25. package/dist/elements/elements/StationCardElement.js +4 -18
  26. package/dist/elements/elements/StationFeedElement.js +4 -2
  27. package/dist/elements/elements/StationStripElement.js +4 -18
  28. package/dist/elements/elements/StationTableElement.js +15 -51
  29. package/dist/elements/elements/TrendChartElement.js +27 -94
  30. package/dist/elements/elements/WindHistoryChartElement.js +29 -189
  31. package/dist/elements/elements/WindRoseElement.d.ts +0 -1
  32. package/dist/elements/elements/WindRoseElement.js +6 -70
  33. package/dist/elements/elements/atoms.js +11 -38
  34. package/dist/elements/index.js +3 -3
  35. package/dist/elements/lib/fragments.js +8 -37
  36. package/dist/elements/lib/h.js +1 -1
  37. package/dist/elements/lib/pinned-cursor.js +48 -0
  38. package/dist/elements/lib/render.js +30 -0
  39. package/dist/fixtures.d.ts +6 -2
  40. package/dist/fixtures.js +30 -2
  41. package/dist/format.js +7 -3
  42. package/dist/geometry.d.ts +1 -1
  43. package/dist/geometry.js +22 -9
  44. package/dist/instruments.js +2 -2
  45. package/dist/react/components/AirExtremes.d.ts +1 -1
  46. package/dist/react/components/AirExtremes.js +5 -22
  47. package/dist/react/components/AirMatrix.js +10 -43
  48. package/dist/react/components/ClimatologyDailyPattern.d.ts +1 -1
  49. package/dist/react/components/ClimatologyDailyPattern.js +19 -13
  50. package/dist/react/components/ClimatologyRose.d.ts +1 -1
  51. package/dist/react/components/ClimatologyRose.js +11 -28
  52. package/dist/react/components/CompassFan.d.ts +1 -1
  53. package/dist/react/components/CompassFan.js +6 -73
  54. package/dist/react/components/CurrentConditions.d.ts +1 -1
  55. package/dist/react/components/CurrentConditions.js +11 -74
  56. package/dist/react/components/DailyPattern.d.ts +1 -3
  57. package/dist/react/components/DailyPattern.js +10 -149
  58. package/dist/react/components/Dial.d.ts +2 -3
  59. package/dist/react/components/Dial.js +5 -118
  60. package/dist/react/components/FavorableShare.d.ts +1 -1
  61. package/dist/react/components/FavorableShare.js +6 -27
  62. package/dist/react/components/FreshnessBadge.d.ts +1 -1
  63. package/dist/react/components/FreshnessBadge.js +5 -12
  64. package/dist/react/components/RecentSummaries.d.ts +1 -1
  65. package/dist/react/components/RecentSummaries.js +6 -44
  66. package/dist/react/components/SceneTree.js +38 -0
  67. package/dist/react/components/Sparkline.d.ts +1 -1
  68. package/dist/react/components/Sparkline.js +3 -39
  69. package/dist/react/components/StationCard.d.ts +2 -2
  70. package/dist/react/components/StationCard.js +5 -45
  71. package/dist/react/components/StationStrip.d.ts +1 -1
  72. package/dist/react/components/StationStrip.js +5 -60
  73. package/dist/react/components/StationTable.js +21 -75
  74. package/dist/react/components/TrendChart.js +13 -86
  75. package/dist/react/components/WindArrow.d.ts +1 -1
  76. package/dist/react/components/WindArrow.js +3 -15
  77. package/dist/react/components/WindHistoryChart.js +12 -205
  78. package/dist/react/components/WindRose.d.ts +1 -3
  79. package/dist/react/components/WindRose.js +6 -89
  80. package/dist/react/components/WindSampleStrip.js +14 -139
  81. package/dist/react/components/atoms.d.ts +5 -5
  82. package/dist/react/components/atoms.js +12 -48
  83. package/dist/react/hooks/useStation.js +28 -50
  84. package/dist/react/hooks/useStationCurrent.js +3 -2
  85. package/dist/react/hooks/useStationFeed.d.ts +0 -1
  86. package/dist/react/hooks/useStationFeed.js +3 -2
  87. package/dist/react/index.d.ts +2 -2
  88. package/dist/react/index.js +7 -7
  89. package/dist/react/lib/cells.js +4 -24
  90. package/dist/react/lib/use-pinned-cursor.js +32 -0
  91. package/dist/samples.js +7 -43
  92. package/dist/scene/air-extremes.js +12 -27
  93. package/dist/scene/air-matrix.js +45 -58
  94. package/dist/scene/card.js +14 -40
  95. package/dist/scene/cells.d.ts +4 -0
  96. package/dist/scene/cells.js +51 -0
  97. package/dist/scene/chart.js +2 -1
  98. package/dist/scene/climatology-pattern.d.ts +1 -2
  99. package/dist/scene/climatology-pattern.js +10 -11
  100. package/dist/scene/climatology-rose.d.ts +1 -2
  101. package/dist/scene/climatology-rose.js +14 -33
  102. package/dist/scene/compass-fan.js +28 -100
  103. package/dist/scene/current.d.ts +2 -1
  104. package/dist/scene/current.js +29 -56
  105. package/dist/scene/daily-pattern.d.ts +1 -3
  106. package/dist/scene/daily-pattern.js +20 -27
  107. package/dist/scene/dial-parts.d.ts +1 -0
  108. package/dist/scene/dial-parts.js +70 -0
  109. package/dist/scene/dial.d.ts +1 -2
  110. package/dist/scene/dial.js +48 -136
  111. package/dist/scene/favorable-share.js +16 -33
  112. package/dist/scene/glyphs.js +20 -16
  113. package/dist/scene/index.d.ts +5 -3
  114. package/dist/scene/node.js +19 -0
  115. package/dist/scene/recent-summaries.js +26 -66
  116. package/dist/scene/rose.js +89 -117
  117. package/dist/scene/sample-strip.d.ts +1 -2
  118. package/dist/scene/sample-strip.js +35 -36
  119. package/dist/scene/sparkline.js +31 -40
  120. package/dist/scene/strip.js +18 -57
  121. package/dist/scene/table.js +47 -69
  122. package/dist/scene/trend.d.ts +1 -2
  123. package/dist/scene/trend.js +29 -55
  124. package/dist/scene/wind-history.d.ts +1 -2
  125. package/dist/scene/wind-history.js +41 -51
  126. package/dist/scene/wind-plot.js +70 -140
  127. package/dist/server/adapters/campbell.d.ts +7 -7
  128. package/dist/server/adapters/campbell.js +1 -1
  129. package/dist/server/adapters/ecowitt.d.ts +8 -8
  130. package/dist/server/adapters/tempest.d.ts +6 -6
  131. package/dist/server/adapters/windnerd-climatology.js +4 -3
  132. package/dist/server/adapters/windnerd-live.js +3 -2
  133. package/dist/server/adapters/windnerd.d.ts +10 -11
  134. package/dist/server/adapters/windnerd.js +3 -13
  135. package/dist/server/config.d.ts +48 -48
  136. package/dist/server/hologram.js +2 -1
  137. package/dist/server/index.d.ts +2 -2
  138. package/dist/server/index.js +2 -2
  139. package/dist/windnerd.d.ts +3 -1
  140. package/dist/windnerd.js +11 -1
  141. package/package.json +7 -12
  142. package/schema/README.md +3 -3
  143. package/schema/stationclimatology.schema.json +64 -61
  144. package/schema/stationcurrent.schema.json +68 -156
  145. package/schema/stationfeed.schema.json +71 -163
  146. package/schema/stationhistory.schema.json +37 -46
  147. package/schema/stationlive.schema.json +221 -306
@@ -1,75 +1,35 @@
1
- import { vectorMeanWind } from "../geometry.js";
2
1
  import { optionalSpeed, roundSpeed } from "../format.js";
2
+ import { el, keyed } from "./node.js";
3
+ import { windArrowNode } from "./glyphs.js";
3
4
  import { inDirectionArcs } from "@azohra/meteo.core";
4
5
  //#region src/scene/recent-summaries.ts
5
6
  const RECENT_SUMMARIES_CLASS = "meteo-recent-summaries";
6
- /** hidden unless the source declares the capability; the no-samples words
7
+ /** Null unless the source declares the capability; the no-samples words
7
8
  * when the declared block is dark. */
8
- function recentSummariesGate(station, summaries, words) {
9
- const source = summaries ?? (station?.status === "ok" ? station.recentSummaries ?? null : null);
10
- if (station != null && station.capabilities.recentSummaries !== true) return { kind: "hidden" };
11
- if (source == null || source.length === 0) return {
12
- kind: "note",
13
- className: `${RECENT_SUMMARIES_CLASS} meteo-recent-summaries-na`,
14
- text: words.noSamples
15
- };
16
- return {
17
- kind: "draw",
18
- summaries: source
19
- };
20
- }
21
9
  function recentSummariesScene(input) {
22
- 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);
23
17
  const arcs = favorableDirections ?? [];
24
- return {
25
- className: RECENT_SUMMARIES_CLASS,
26
- ariaLabel: words.aria.recentSummaries(stationName ?? ""),
27
- panels: summaries.map((block) => {
28
- const points = block.points;
29
- const avgMps = points.length === 0 ? null : points.reduce((sum, point) => sum + point.windAvgMps, 0) / points.length;
30
- const gusts = points.map((point) => point.windGustMps).filter((gust) => gust != null);
31
- const lulls = points.map((point) => point.windLullMps).filter((lull) => lull != null);
32
- const mean = vectorMeanWind(points);
33
- return {
34
- key: block.windowMinutes,
35
- className: "meteo-recent-summary",
36
- label: {
37
- className: "meteo-microlabel",
38
- text: words.recentWindowLabel(block.windowMinutes)
39
- },
40
- stats: [
41
- {
42
- key: "avg",
43
- className: "meteo-recent-summary-stat",
44
- label: words.avgLabel,
45
- value: avgMps == null ? "—" : `${roundSpeed(avgMps, unit)} ${words.speedUnits[unit]}`
46
- },
47
- {
48
- key: "gust",
49
- className: "meteo-recent-summary-stat",
50
- label: words.gustLabel,
51
- value: optionalSpeed(gusts.length === 0 ? null : Math.max(...gusts), unit)
52
- },
53
- {
54
- key: "lull",
55
- className: "meteo-recent-summary-stat",
56
- label: words.lullLabel,
57
- value: optionalSpeed(lulls.length === 0 ? null : Math.min(...lulls), unit)
58
- }
59
- ],
60
- ghosts: points.flatMap((point) => {
61
- if (point.windDirectionDeg == null) return [];
62
- const verdict = arcs.length === 0 ? "" : inDirectionArcs(point.windDirectionDeg, arcs) ? " meteo-direction-favorable" : " meteo-direction-unfavorable";
63
- return [{
64
- key: point.observedAt,
65
- className: `meteo-recent-summary-ghost${verdict}`,
66
- deg: point.windDirectionDeg
67
- }];
68
- }),
69
- meanDirectionDeg: mean.windDirectionDeg
70
- };
71
- })
72
- };
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
+ }));
73
33
  }
74
34
  //#endregion
75
- export { RECENT_SUMMARIES_CLASS, recentSummariesGate, recentSummariesScene };
35
+ export { RECENT_SUMMARIES_CLASS, recentSummariesScene };
@@ -1,135 +1,107 @@
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
+ import { el, keyed } from "./node.js";
4
5
  //#region 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
106
  //#endregion
135
- export { WIND_ROSE_CLASS, windRoseGate, windRoseScene, windRoseSource };
107
+ 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,7 +1,8 @@
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";
4
+ import { el, keyed } from "./node.js";
5
+ import { calmNoteText, plotLine, speedGridLines, stretchedChartFrame, vaneCells, vaneGuideLines, vaneTickTexts, windRowLabels } from "./wind-plot.js";
5
6
  //#region src/scene/sample-strip.ts
6
7
  const SAMPLE_STRIP_CLASS = "meteo-sample-strip";
7
8
  function sampleStripGate(samples, words) {
@@ -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,21 +115,12 @@ 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
  };
@@ -1,6 +1,7 @@
1
1
  import { thresholdsToMps } from "../derive.js";
2
2
  import { speedBand } from "../geometry.js";
3
3
  import { bandStrips, historyRuns, sparklineScale } from "../instruments.js";
4
+ import { el, keyed } from "./node.js";
4
5
  //#region src/scene/sparkline.ts
5
6
  const coordinate = (x, y) => `${x.toFixed(1)},${y.toFixed(1)}`;
6
7
  function sparklineScene(input) {
@@ -8,66 +9,56 @@ function sparklineScene(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
63
  //#endregion
73
64
  export { sparklineScene };
@@ -1,63 +1,24 @@
1
1
  import { optionalSpeed, roundSpeed, temperatureText } from "../format.js";
2
+ import { el } from "./node.js";
3
+ import { freshnessBadgeNode } from "./glyphs.js";
4
+ import { directionCellNodes, stationNameNode } from "./cells.js";
2
5
  //#region 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
23
  //#endregion
63
24
  export { stationStripScene };