@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,66 +1,39 @@
1
1
  import { compassDirection, isCalm } from "../derive.js";
2
2
  import { roundSpeed, temperatureText, temperatureValue } from "../format.js";
3
+ import "../instruments.js";
4
+ import { el } from "./node.js";
5
+ import { freshnessBadgeNode, windArrowNode } from "./glyphs.js";
6
+ import { dialScene } from "./dial.js";
3
7
  //#region src/scene/current.ts
4
8
  function currentConditionsScene(input) {
5
- const { formatTime, station, unit, words } = input;
9
+ const { bezelId, favorableDirections, formatTime, freshness, station, thresholds, unit, words } = input;
6
10
  const reading = station.status === "ok" ? station.reading : null;
7
11
  const calm = reading != null && isCalm(reading.windAvgMps);
8
12
  const blowing = reading != null && !calm && reading.windDirectionDeg != null;
9
- const flankValue = (valueMps) => valueMps == null ? "—" : String(roundSpeed(valueMps, unit));
10
- return {
11
- root: {
12
- ariaLabel: words.aria.current(station.name),
13
- className: "meteo-current",
14
- status: station.status
15
- },
16
- instrumentClassName: "meteo-current-instrument",
17
- flanks: station.capabilities.gustLull ? {
18
- lull: {
19
- className: "meteo-current-flank meteo-current-flank-lull",
20
- labelClassName: "meteo-microlabel",
21
- label: words.lullLabel,
22
- value: flankValue(reading?.windLullMps)
23
- },
24
- gust: {
25
- className: "meteo-current-flank meteo-current-flank-gust",
26
- labelClassName: "meteo-microlabel",
27
- label: words.gustLabel,
28
- value: flankValue(reading?.windGustMps)
29
- }
30
- } : null,
31
- direction: {
32
- className: "meteo-current-direction",
33
- content: station.status === "unavailable" ? {
34
- kind: "text",
35
- text: words.reasons[station.reason]
36
- } : blowing && reading.windDirectionDeg != null ? {
37
- kind: "from",
38
- labelClassName: "meteo-current-from-label",
39
- label: words.fromLabel,
40
- deg: reading.windDirectionDeg,
41
- compass: compassDirection(reading.windDirectionDeg),
42
- tail: ` ${Math.round(reading.windDirectionDeg)}°`
43
- } : {
44
- kind: "text",
45
- text: calm ? words.calm : "—"
46
- }
47
- },
48
- temperature: station.capabilities.temperature ? {
49
- className: "meteo-current-temp",
50
- text: temperatureText(reading?.temperatureC ?? null, words),
51
- chill: reading?.windChillC != null ? {
52
- className: "meteo-current-chill",
53
- text: ` · ${words.feelsLikeLabel} ${temperatureValue(reading.windChillC)} ${words.degC}`
54
- } : null
55
- } : null,
56
- footer: {
57
- className: "meteo-current-footer",
58
- observed: {
59
- className: "meteo-current-observed",
60
- text: reading == null ? "—" : formatTime(new Date(reading.observedAt))
61
- }
62
- }
63
- };
13
+ const flank = (attrs, label, valueMps) => el("div", attrs, el("small", { class: "meteo-microlabel" }, label), el("strong", void 0, valueMps == null ? "—" : String(roundSpeed(valueMps, unit))));
14
+ const directionChildren = station.status === "unavailable" ? [words.reasons[station.reason]] : blowing && reading.windDirectionDeg != null ? [
15
+ el("span", { class: "meteo-current-from-label" }, words.fromLabel),
16
+ " ",
17
+ windArrowNode(reading.windDirectionDeg),
18
+ " ",
19
+ el("strong", void 0, compassDirection(reading.windDirectionDeg)),
20
+ ` ${Math.round(reading.windDirectionDeg)}°`
21
+ ] : [calm ? words.calm : "—"];
22
+ return el("div", {
23
+ "aria-label": words.aria.current(station.name),
24
+ class: "meteo-current",
25
+ "data-status": station.status,
26
+ role: "group"
27
+ }, el("div", { class: "meteo-current-instrument" }, station.capabilities.gustLull ? flank({ class: "meteo-current-flank meteo-current-flank-lull" }, words.lullLabel, reading?.windLullMps) : null, dialScene({
28
+ bezelId,
29
+ calmWord: false,
30
+ favorableDirections,
31
+ size: 160,
32
+ station,
33
+ thresholds,
34
+ unit,
35
+ words
36
+ }), station.capabilities.gustLull ? flank({ class: "meteo-current-flank meteo-current-flank-gust" }, words.gustLabel, reading?.windGustMps) : null), el("p", { class: "meteo-current-direction" }, directionChildren), station.capabilities.temperature ? el("p", { class: "meteo-current-temp" }, temperatureText(reading?.temperatureC ?? null, words), reading?.windChillC != null ? el("span", { class: "meteo-current-chill" }, ` · ${words.feelsLikeLabel} ${temperatureValue(reading.windChillC)} ${words.degC}`) : null) : null, el("p", { class: "meteo-current-footer" }, freshness != null ? freshnessBadgeNode(freshness, words) : null, el("span", { class: "meteo-current-observed" }, reading == null ? "—" : formatTime(new Date(reading.observedAt)))));
64
37
  }
65
38
  //#endregion
66
39
  export { currentConditionsScene };
@@ -2,6 +2,4 @@ import "../contract.js";
2
2
  import "../derive.js";
3
3
  import "../strings.js";
4
4
  import "../instruments.js";
5
- import "../geometry.js";
6
- import "./chart.js";
7
- import "./wind-plot.js";
5
+ import "../geometry.js";
@@ -1,13 +1,14 @@
1
1
  import { isCalm, thresholdsToMps } from "../derive.js";
2
2
  import { dailyPattern, thinVanes } from "../geometry.js";
3
3
  import { roundSpeed } from "../format.js";
4
+ import { el } from "./node.js";
4
5
  import { calmNoteText, displaySpeedScales, gapHatchPattern, gapHatchRect, gradedMeanTrace, speedGridLines, stretchedChartFrame, vaneCells, vaneGuideLines, vaneTickTexts, windRowLabels, windThresholdGuides, windZoneRects } from "./wind-plot.js";
5
6
  //#region src/scene/daily-pattern.ts
6
7
  const DAILY_PATTERN_CLASS = "meteo-daily-pattern";
7
8
  const SYNTHETIC_EPOCH_MS = Date.parse("2000-01-01T00:00:00Z");
8
9
  function dailyPatternSource(points, station) {
9
10
  return {
10
- source: points ?? (station?.status === "ok" ? station.history?.points ?? null : null) ?? [],
11
+ source: points ?? (station?.status === "ok" ? station.history?.points : null) ?? [],
11
12
  periodMinutes: points == null && station?.status === "ok" ? station.history?.periodMinutes ?? null : null
12
13
  };
13
14
  }
@@ -64,32 +65,24 @@ function dailyPatternSlotsScene(input) {
64
65
  const calm = synthetic.every((point) => isCalm(point.windAvgMps));
65
66
  const boundsMps = thresholds == null ? null : thresholdsToMps(thresholds);
66
67
  const voidSpans = slots.filter((slot) => slot.sampleCount === 0).map((slot) => [scales.xAtMs(SYNTHETIC_EPOCH_MS + slot.startMinuteOfDay * 6e4), scales.xAtMs(SYNTHETIC_EPOCH_MS + (slot.startMinuteOfDay + slotMinutes) * 6e4)]);
67
- return {
68
- frame,
69
- scales,
70
- caption: {
71
- className: "meteo-daily-pattern-caption",
72
- text: percent != null ? words.dailyPatternCoverage(totalSamples, percent) : words.dailyPatternSamples(totalSamples)
73
- },
74
- svg: {
75
- ariaLabel: stationName ? words.aria.dailyPattern(stationName) : words.aria.dailyPatternGeneric,
76
- className: "meteo-daily-pattern-svg",
77
- height: frame.height,
78
- viewBox: `0 0 ${frame.width} ${frame.height}`,
79
- width: frame.width
80
- },
81
- defs: { pattern: gapHatchPattern(hatchId) },
82
- zones: windZoneRects(boundsMps, frame, scales),
83
- grid: speedGridLines(frame, scales, shown),
84
- thresholdGuides: windThresholdGuides(thresholds, boundsMps, unit, frame, scales, shown),
85
- vaneGuides: vaneGuideLines(vanes, frame, scales),
86
- gaps: voidSpans.map(([startX, endX]) => gapHatchRect(hatchId, frame, startX, startX, endX - startX)),
87
- mean: gradedMeanTrace(synthetic, scales, boundsMps),
88
- calmNote: calm ? calmNoteText(frame, words) : null,
89
- rowLabels: windRowLabels(frame, words),
90
- vanes: vaneCells(vanes, frame, scales, (vane) => slots.slice(vane.startIndex, vane.endIndex).every((slot) => slot.sampleCount === 0) ? "—" : String(shown(vane.windAvgMps)), input.favorableDirections),
91
- ticks: vaneTickTexts(vanes, frame, scales, (timeMs) => formatMinuteOfDay((timeMs - SYNTHETIC_EPOCH_MS) / 6e4))
92
- };
68
+ const vaneCellList = vaneCells(vanes, frame, scales, (vane) => slots.slice(vane.startIndex, vane.endIndex).every((slot) => slot.sampleCount === 0) ? "—" : String(shown(vane.windAvgMps)), input.favorableDirections);
69
+ return [el("output", { class: "meteo-daily-pattern-caption" }, percent != null ? words.dailyPatternCoverage(totalSamples, percent) : words.dailyPatternSamples(totalSamples)), el("svg", {
70
+ "aria-label": stationName ? words.aria.dailyPattern(stationName) : words.aria.dailyPatternGeneric,
71
+ class: "meteo-daily-pattern-svg",
72
+ height: frame.height,
73
+ role: "img",
74
+ viewBox: `0 0 ${frame.width} ${frame.height}`,
75
+ width: frame.width
76
+ }, el("defs", void 0, gapHatchPattern(hatchId)), windZoneRects(boundsMps, frame, scales), speedGridLines(frame, scales, shown), windThresholdGuides(thresholds, boundsMps, unit, frame, scales, shown), vaneGuideLines(vanes, frame, scales), voidSpans.map(([startX, endX]) => gapHatchRect(hatchId, frame, startX, startX, endX - startX)), gradedMeanTrace(synthetic, scales, boundsMps), calm ? calmNoteText(frame, words) : null, windRowLabels(frame, words)[0], vaneCellList.map((vane) => ({
77
+ ...vane.mark,
78
+ key: String(vane.key)
79
+ })), vaneCellList.flatMap((vane) => vane.label == null ? [] : [{
80
+ ...vane.label,
81
+ key: String(vane.key)
82
+ }]), windRowLabels(frame, words)[1], vaneCellList.flatMap((vane) => vane.value == null ? [] : [{
83
+ ...vane.value,
84
+ key: String(vane.key)
85
+ }]), vaneTickTexts(vanes, frame, scales, (timeMs) => formatMinuteOfDay((timeMs - SYNTHETIC_EPOCH_MS) / 6e4)))];
93
86
  }
94
87
  //#endregion
95
88
  export { DAILY_PATTERN_CLASS, dailyPatternGate, dailyPatternScene, dailyPatternSlotsScene, dailyPatternSource };
@@ -0,0 +1 @@
1
+ import "../instruments.js";
@@ -0,0 +1,70 @@
1
+ import { DIAL_CARDINALS, DIAL_COUNTERWEIGHT_RADIUS, dialNeedlePoints, dialPolar, dialRingArcPath } from "../instruments.js";
2
+ import { el, keyed } from "./node.js";
3
+ //#region src/scene/dial-parts.ts
4
+ function dialRing() {
5
+ return el("circle", {
6
+ class: "meteo-wind-dial-ring",
7
+ cx: 80,
8
+ cy: 80,
9
+ r: 70
10
+ });
11
+ }
12
+ function dialVerdictRing(arcs) {
13
+ if (arcs == null || arcs.length === 0) return [];
14
+ return [el("circle", {
15
+ class: "meteo-wind-dial-ring-unfavorable",
16
+ cx: 80,
17
+ cy: 80,
18
+ r: 70
19
+ }), ...arcs.map((sector) => keyed(`${sector.fromDeg}-${sector.toDeg}`, "path", {
20
+ class: "meteo-wind-dial-ring-favorable",
21
+ d: dialRingArcPath(sector)
22
+ }))];
23
+ }
24
+ function dialTicks() {
25
+ return Array.from({ length: 16 }, (_, index) => {
26
+ const bearing = index * 22.5;
27
+ const cardinal = index % 4 === 0;
28
+ const [x1, y1] = dialPolar(bearing, 70);
29
+ const [x2, y2] = dialPolar(bearing, cardinal ? 58 : 64);
30
+ return keyed(String(bearing), "line", {
31
+ class: cardinal ? "meteo-wind-dial-tick meteo-wind-dial-tick-cardinal" : "meteo-wind-dial-tick",
32
+ x1,
33
+ x2,
34
+ y1,
35
+ y2
36
+ });
37
+ });
38
+ }
39
+ function dialLetters() {
40
+ return DIAL_CARDINALS.map(({ bearing, letter }) => {
41
+ const [x, y] = dialPolar(bearing, 46);
42
+ return keyed(letter, "text", {
43
+ class: "meteo-wind-dial-letter",
44
+ "text-anchor": "middle",
45
+ x,
46
+ y: y + 3.5
47
+ }, letter);
48
+ });
49
+ }
50
+ function dialNeedle(directionDeg) {
51
+ return el("g", { class: "meteo-wind-needle" }, el("polygon", {
52
+ class: "meteo-wind-needle-blade",
53
+ points: dialNeedlePoints(directionDeg)
54
+ }), el("circle", {
55
+ class: "meteo-wind-needle-counterweight",
56
+ cx: dialPolar(directionDeg, 46)[0],
57
+ cy: dialPolar(directionDeg, 46)[1],
58
+ r: DIAL_COUNTERWEIGHT_RADIUS
59
+ }));
60
+ }
61
+ function dialHub() {
62
+ return el("circle", {
63
+ class: "meteo-wind-dial-hub",
64
+ cx: 80,
65
+ cy: 80,
66
+ r: 36
67
+ });
68
+ }
69
+ //#endregion
70
+ export { dialHub, dialLetters, dialNeedle, dialRing, dialTicks, dialVerdictRing };
@@ -1,5 +1,4 @@
1
1
  import "../contract.js";
2
2
  import "../derive.js";
3
3
  import "../strings.js";
4
- import "../instruments.js";
5
- import "./wind-plot.js";
4
+ import "../instruments.js";
@@ -1,7 +1,9 @@
1
1
  import { isCalm, thresholdsToMps } from "../derive.js";
2
2
  import { speedBand } from "../geometry.js";
3
3
  import { roundSpeed } from "../format.js";
4
- import { DIAL_CARDINALS, DIAL_COUNTERWEIGHT_RADIUS, dialNeedlePoints, dialPolar, dialRingArcPath, dialScaleMaxMps, dialSpeedArcPath } from "../instruments.js";
4
+ import { dialScaleMaxMps, dialSpeedArcPath } from "../instruments.js";
5
+ import { el, keyed } from "./node.js";
6
+ import { dialHub, dialLetters, dialNeedle, dialRing, dialTicks, dialVerdictRing } from "./dial-parts.js";
5
7
  //#region src/scene/dial.ts
6
8
  function dialScene(input) {
7
9
  const { bezelId, calmWord, favorableDirections, size, station, thresholds, unit, words } = input;
@@ -14,141 +16,51 @@ function dialScene(input) {
14
16
  const arcFraction = reading == null ? 0 : Math.min(1, Math.max(0, reading.windAvgMps) / dialMax);
15
17
  const boundsMps = thresholds == null ? null : thresholdsToMps(thresholds);
16
18
  const arcBand = reading != null && boundsMps != null ? speedBand(reading.windAvgMps, boundsMps) : null;
17
- return {
18
- svg: {
19
- ariaLabel: station.status === "unavailable" ? `${station.name}: ${words.reasons[station.reason]}` : calm ? `${station.name}: ${words.calm}, ${shown(station.reading.windAvgMps)} ${unitLabel}` : `${station.name}: ${shown(station.reading.windAvgMps)} ${unitLabel}`,
20
- className: station.status === "unavailable" ? "meteo-wind-dial meteo-wind-dial-unavailable" : "meteo-wind-dial",
21
- height: size,
22
- viewBox: `0 0 160 160`,
23
- width: size
24
- },
25
- gradient: {
26
- id: bezelId,
27
- cx: "50%",
28
- cy: "42%",
29
- r: "68%",
30
- stops: [{
31
- className: "meteo-wind-dial-bezel-in",
32
- offset: "55%"
33
- }, {
34
- className: "meteo-wind-dial-bezel-out",
35
- offset: "100%"
36
- }]
37
- },
38
- face: {
39
- className: "meteo-wind-dial-face",
40
- cx: 80,
41
- cy: 80,
42
- r: 70
43
- },
44
- bezel: {
45
- className: "meteo-wind-dial-bezel",
46
- cx: 80,
47
- cy: 80,
48
- fill: `url(#${bezelId})`,
49
- r: 70
50
- },
51
- ring: {
52
- className: "meteo-wind-dial-ring",
53
- cx: 80,
54
- cy: 80,
55
- r: 70
56
- },
57
- verdictRing: favorableDirections != null && favorableDirections.length > 0 ? {
58
- unfavorable: {
59
- className: "meteo-wind-dial-ring-unfavorable",
60
- cx: 80,
61
- cy: 80,
62
- r: 70
63
- },
64
- favorable: favorableDirections.map((sector) => ({
65
- key: `${sector.fromDeg}-${sector.toDeg}`,
66
- className: "meteo-wind-dial-ring-favorable",
67
- d: dialRingArcPath(sector)
68
- }))
69
- } : null,
70
- arc: reading != null && arcFraction > 0 ? {
71
- className: arcBand == null ? "meteo-wind-dial-arc" : `meteo-wind-dial-arc meteo-band-${arcBand}`,
72
- d: dialSpeedArcPath(arcFraction)
73
- } : null,
74
- ticks: Array.from({ length: 16 }, (_, index) => {
75
- const bearing = index * 22.5;
76
- const cardinal = index % 4 === 0;
77
- const [x1, y1] = dialPolar(bearing, 70);
78
- const [x2, y2] = dialPolar(bearing, cardinal ? 58 : 64);
79
- return {
80
- key: bearing,
81
- className: cardinal ? "meteo-wind-dial-tick meteo-wind-dial-tick-cardinal" : "meteo-wind-dial-tick",
82
- x1,
83
- x2,
84
- y1,
85
- y2
86
- };
87
- }),
88
- letters: DIAL_CARDINALS.map(({ bearing, letter }) => {
89
- const [x, y] = dialPolar(bearing, 46);
90
- return {
91
- key: letter,
92
- className: "meteo-wind-dial-letter",
93
- anchor: "middle",
94
- x,
95
- y: y + 3.5,
96
- text: letter
97
- };
98
- }),
99
- needle: blowing && reading.windDirectionDeg != null ? {
100
- className: "meteo-wind-needle",
101
- blade: {
102
- className: "meteo-wind-needle-blade",
103
- points: dialNeedlePoints(reading.windDirectionDeg)
104
- },
105
- counterweight: {
106
- className: "meteo-wind-needle-counterweight",
107
- cx: dialPolar(reading.windDirectionDeg, 46)[0],
108
- cy: dialPolar(reading.windDirectionDeg, 46)[1],
109
- r: DIAL_COUNTERWEIGHT_RADIUS
110
- }
111
- } : null,
112
- hub: {
113
- className: "meteo-wind-dial-hub",
114
- cx: 80,
115
- cy: 80,
116
- r: 36
117
- },
118
- centre: reading == null ? {
119
- kind: "reason",
120
- text: {
121
- className: "meteo-wind-dial-reason",
122
- anchor: "middle",
123
- x: 80,
124
- y: 84,
125
- text: words.notReporting
126
- }
127
- } : {
128
- kind: "reading",
129
- calmWord: calm && calmWord ? {
130
- className: "meteo-wind-dial-reason",
131
- anchor: "middle",
132
- x: 80,
133
- y: 58,
134
- text: words.calm
135
- } : null,
136
- speed: {
137
- className: "meteo-wind-dial-speed",
138
- anchor: "middle",
139
- x: 80,
140
- y: 88,
141
- text: String(shown(reading.windAvgMps))
142
- },
143
- unit: {
144
- className: "meteo-wind-dial-unit",
145
- anchor: "middle",
146
- x: 80,
147
- y: 106,
148
- text: unitLabel
149
- }
150
- }
151
- };
19
+ const dialLabel = station.status === "unavailable" ? `${station.name}: ${words.reasons[station.reason]}` : calm ? `${station.name}: ${words.calm}, ${shown(station.reading.windAvgMps)} ${unitLabel}` : `${station.name}: ${shown(station.reading.windAvgMps)} ${unitLabel}`;
20
+ const centreText = (className, y, text) => el("text", {
21
+ class: className,
22
+ "text-anchor": "middle",
23
+ x: 80,
24
+ y
25
+ }, text);
26
+ const centre = reading == null ? [centreText("meteo-wind-dial-reason", 84, words.notReporting)] : [
27
+ calm && calmWord ? centreText("meteo-wind-dial-reason", 58, words.calm) : null,
28
+ centreText("meteo-wind-dial-speed", 88, String(shown(reading.windAvgMps))),
29
+ centreText("meteo-wind-dial-unit", 106, unitLabel)
30
+ ];
31
+ return el("svg", {
32
+ "aria-label": dialLabel,
33
+ class: station.status === "unavailable" ? "meteo-wind-dial meteo-wind-dial-unavailable" : "meteo-wind-dial",
34
+ height: size,
35
+ role: "img",
36
+ viewBox: `0 0 160 160`,
37
+ width: size
38
+ }, el("defs", void 0, el("radialGradient", {
39
+ cx: "50%",
40
+ cy: "42%",
41
+ id: bezelId,
42
+ r: "68%"
43
+ }, keyed("55%", "stop", {
44
+ class: "meteo-wind-dial-bezel-in",
45
+ offset: "55%"
46
+ }), keyed("100%", "stop", {
47
+ class: "meteo-wind-dial-bezel-out",
48
+ offset: "100%"
49
+ }))), el("circle", {
50
+ class: "meteo-wind-dial-face",
51
+ cx: 80,
52
+ cy: 80,
53
+ r: 70
54
+ }), el("circle", {
55
+ class: "meteo-wind-dial-bezel",
56
+ cx: 80,
57
+ cy: 80,
58
+ fill: `url(#${bezelId})`,
59
+ r: 70
60
+ }), dialRing(), dialVerdictRing(favorableDirections), reading != null && arcFraction > 0 ? el("path", {
61
+ class: arcBand == null ? "meteo-wind-dial-arc" : `meteo-wind-dial-arc meteo-band-${arcBand}`,
62
+ d: dialSpeedArcPath(arcFraction)
63
+ }) : null, dialTicks(), dialLetters(), blowing && reading.windDirectionDeg != null ? dialNeedle(reading.windDirectionDeg) : null, dialHub(), centre);
152
64
  }
153
65
  //#endregion
154
66
  export { dialScene };
@@ -1,41 +1,24 @@
1
1
  import { favorableShare } from "../geometry.js";
2
+ import { el } from "./node.js";
2
3
  //#region src/scene/favorable-share.ts
3
4
  const FAVORABLE_SHARE_CLASS = "meteo-favorable-share";
4
5
  function favorableShareSource(points, station) {
5
- return points ?? (station?.status === "ok" ? station.history?.points ?? null : null) ?? [];
6
- }
7
- function favorableShareGate(source, favorableDirections, words) {
8
- if (favorableDirections == null || favorableDirections.length === 0) return { kind: "hidden" };
9
- if (source.length === 0) return {
10
- kind: "note",
11
- className: `${FAVORABLE_SHARE_CLASS} meteo-favorable-share-na`,
12
- text: words.noHistory
13
- };
14
- const share = favorableShare(source, favorableDirections);
15
- if (share == null) return {
16
- kind: "note",
17
- className: `${FAVORABLE_SHARE_CLASS} meteo-favorable-share-na`,
18
- text: words.calm
19
- };
20
- return {
21
- kind: "draw",
22
- share
23
- };
6
+ return points ?? (station?.status === "ok" ? station.history?.points : null) ?? [];
24
7
  }
25
8
  function favorableShareScene(input) {
26
- const { share, stationName, words } = input;
27
- return {
28
- className: FAVORABLE_SHARE_CLASS,
29
- ariaLabel: stationName == null ? void 0 : words.aria.favorableShare(stationName),
30
- label: {
31
- className: "meteo-favorable-share-label",
32
- text: words.favorableLabel
33
- },
34
- value: {
35
- className: "meteo-favorable-share-value",
36
- text: words.percentShare(Math.round(share * 100))
37
- }
38
- };
9
+ const { favorableDirections, source, stationName, words } = input;
10
+ const note = (text) => el("div", {
11
+ class: `${FAVORABLE_SHARE_CLASS} meteo-favorable-share-na`,
12
+ role: "note"
13
+ }, text);
14
+ if (favorableDirections == null || favorableDirections.length === 0) return null;
15
+ if (source.length === 0) return note(words.noHistory);
16
+ const share = favorableShare(source, favorableDirections);
17
+ if (share == null) return note(words.calm);
18
+ return el("div", {
19
+ "aria-label": stationName == null ? void 0 : words.aria.favorableShare(stationName),
20
+ class: FAVORABLE_SHARE_CLASS
21
+ }, el("span", { class: "meteo-favorable-share-label" }, words.favorableLabel), " ", el("span", { class: "meteo-favorable-share-value" }, words.percentShare(Math.round(share * 100))));
39
22
  }
40
23
  //#endregion
41
- export { FAVORABLE_SHARE_CLASS, favorableShareGate, favorableShareScene, favorableShareSource };
24
+ export { FAVORABLE_SHARE_CLASS, favorableShareScene, favorableShareSource };
@@ -1,24 +1,28 @@
1
+ import { el } from "./node.js";
1
2
  //#region src/scene/glyphs.ts
2
- function windArrowSpec(deg, size = 12) {
3
+ function windArrowNode(deg, size = 12) {
3
4
  return {
4
- className: "meteo-wind-arrow",
5
- height: size,
6
- width: size,
7
- viewBox: "0 0 16 16",
8
- transform: `rotate(${deg + 180}deg)`,
9
- path: {
5
+ ...el("svg", {
6
+ "aria-hidden": "true",
7
+ class: "meteo-wind-arrow",
8
+ height: size,
9
+ viewBox: "0 0 16 16",
10
+ width: size
11
+ }, el("path", {
10
12
  d: "M8 1 L13 14 L8 10.6 L3 14 Z",
11
13
  fill: "currentColor"
12
- }
14
+ })),
15
+ style: { transform: `rotate(${deg + 180}deg)` }
13
16
  };
14
17
  }
15
- function freshnessBadgeSpec(status, words) {
16
- return {
17
- className: "meteo-freshness",
18
- status,
19
- dot: { className: "meteo-freshness-dot" },
20
- text: words.freshness[status]
21
- };
18
+ function freshnessBadgeNode(status, words) {
19
+ return el("span", {
20
+ class: "meteo-freshness",
21
+ "data-freshness": status
22
+ }, el("span", {
23
+ "aria-hidden": "true",
24
+ class: "meteo-freshness-dot"
25
+ }), words.freshness[status]);
22
26
  }
23
27
  //#endregion
24
- export { freshnessBadgeSpec, windArrowSpec };
28
+ export { freshnessBadgeNode, windArrowNode };
@@ -5,20 +5,22 @@ import "./atoms.js";
5
5
  import "./compass-fan.js";
6
6
  import "./card.js";
7
7
  import { ReadoutPart } from "./chart.js";
8
- import "./wind-plot.js";
9
- import "./daily-pattern.js";
10
8
  import "./climatology-pattern.js";
11
- import "./rose.js";
12
9
  import "./climatology-rose.js";
13
10
  import "./current.js";
14
11
  import "./dial.js";
15
12
  import "./favorable-share.js";
13
+ import "./cells.js";
14
+ import "./dial-parts.js";
16
15
  import "./glyphs.js";
16
+ import "./daily-pattern.js";
17
17
  import "./recent-summaries.js";
18
+ import "./rose.js";
18
19
  import "./sample-strip.js";
19
20
  import "./sparkline.js";
20
21
  import "./strip.js";
21
22
  import "./table.js";
22
23
  import "./trend.js";
23
24
  import "./wind-history.js";
25
+ import "./wind-plot.js";
24
26
  export { ReadoutPart };
@@ -0,0 +1,19 @@
1
+ //#region src/scene/node.ts
2
+ /** An element node; children may be nested arrays and are flattened by the walkers. */
3
+ function el(tag, attrs, ...children) {
4
+ const node = { tag };
5
+ if (attrs !== void 0) node.attrs = attrs;
6
+ if (children.length > 0) node.children = children.flat();
7
+ return node;
8
+ }
9
+ /** The same, carrying list identity. */
10
+ function keyed(key, tag, attrs, ...children) {
11
+ return {
12
+ ...el(tag, attrs, ...children),
13
+ key
14
+ };
15
+ }
16
+ /** Tags that open an SVG subtree; everything inside one stays in that namespace. */
17
+ const SVG_ROOT_TAGS = /* @__PURE__ */ new Set(["svg"]);
18
+ //#endregion
19
+ export { SVG_ROOT_TAGS, el, keyed };