@azohra/meteo.station 0.6.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 (128) hide show
  1. package/README.md +17 -17
  2. package/dist/connectivity.d.ts +2 -2
  3. package/dist/contract.d.ts +105 -105
  4. package/dist/derive.js +4 -4
  5. package/dist/elements/elements/AirExtremesElement.js +5 -18
  6. package/dist/elements/elements/AirMatrixElement.js +6 -31
  7. package/dist/elements/elements/ClimatologyDailyPatternElement.js +17 -12
  8. package/dist/elements/elements/ClimatologyRoseElement.js +5 -15
  9. package/dist/elements/elements/CompassFanElement.js +5 -64
  10. package/dist/elements/elements/CurrentConditionsElement.js +7 -26
  11. package/dist/elements/elements/DailyPatternElement.d.ts +0 -1
  12. package/dist/elements/elements/DailyPatternElement.js +6 -120
  13. package/dist/elements/elements/DialElement.js +3 -95
  14. package/dist/elements/elements/FavorableShareElement.js +6 -21
  15. package/dist/elements/elements/RecentSummariesElement.js +6 -23
  16. package/dist/elements/elements/SparklineElement.d.ts +0 -1
  17. package/dist/elements/elements/SparklineElement.js +4 -39
  18. package/dist/elements/elements/StationCardElement.js +4 -18
  19. package/dist/elements/elements/StationFeedElement.js +4 -2
  20. package/dist/elements/elements/StationStripElement.js +4 -18
  21. package/dist/elements/elements/StationTableElement.js +15 -51
  22. package/dist/elements/elements/TrendChartElement.js +21 -69
  23. package/dist/elements/elements/WindHistoryChartElement.js +23 -164
  24. package/dist/elements/elements/WindRoseElement.d.ts +0 -1
  25. package/dist/elements/elements/WindRoseElement.js +6 -70
  26. package/dist/elements/elements/atoms.d.ts +1 -1
  27. package/dist/elements/elements/atoms.js +11 -38
  28. package/dist/elements/index.js +3 -3
  29. package/dist/elements/lib/fragments.js +8 -37
  30. package/dist/elements/lib/h.js +1 -1
  31. package/dist/elements/lib/render.js +30 -0
  32. package/dist/geometry.js +2 -1
  33. package/dist/instruments.js +2 -2
  34. package/dist/react/components/AirExtremes.d.ts +1 -1
  35. package/dist/react/components/AirExtremes.js +5 -22
  36. package/dist/react/components/AirMatrix.js +10 -43
  37. package/dist/react/components/ClimatologyDailyPattern.d.ts +1 -1
  38. package/dist/react/components/ClimatologyDailyPattern.js +19 -13
  39. package/dist/react/components/ClimatologyRose.d.ts +1 -1
  40. package/dist/react/components/ClimatologyRose.js +11 -28
  41. package/dist/react/components/CompassFan.d.ts +1 -1
  42. package/dist/react/components/CompassFan.js +6 -73
  43. package/dist/react/components/CurrentConditions.d.ts +1 -1
  44. package/dist/react/components/CurrentConditions.js +11 -74
  45. package/dist/react/components/DailyPattern.d.ts +1 -3
  46. package/dist/react/components/DailyPattern.js +10 -149
  47. package/dist/react/components/Dial.d.ts +1 -1
  48. package/dist/react/components/Dial.js +5 -118
  49. package/dist/react/components/FavorableShare.d.ts +1 -1
  50. package/dist/react/components/FavorableShare.js +6 -27
  51. package/dist/react/components/FreshnessBadge.d.ts +1 -1
  52. package/dist/react/components/FreshnessBadge.js +5 -12
  53. package/dist/react/components/RecentSummaries.d.ts +1 -1
  54. package/dist/react/components/RecentSummaries.js +6 -44
  55. package/dist/react/components/SceneTree.js +38 -0
  56. package/dist/react/components/Sparkline.d.ts +1 -1
  57. package/dist/react/components/Sparkline.js +3 -39
  58. package/dist/react/components/StationCard.d.ts +2 -2
  59. package/dist/react/components/StationCard.js +5 -45
  60. package/dist/react/components/StationStrip.d.ts +1 -1
  61. package/dist/react/components/StationStrip.js +5 -60
  62. package/dist/react/components/StationTable.js +21 -75
  63. package/dist/react/components/TrendChart.js +8 -63
  64. package/dist/react/components/WindArrow.d.ts +1 -1
  65. package/dist/react/components/WindArrow.js +3 -15
  66. package/dist/react/components/WindHistoryChart.js +8 -182
  67. package/dist/react/components/WindRose.d.ts +1 -3
  68. package/dist/react/components/WindRose.js +6 -89
  69. package/dist/react/components/WindSampleStrip.js +8 -115
  70. package/dist/react/components/atoms.d.ts +5 -5
  71. package/dist/react/components/atoms.js +12 -48
  72. package/dist/react/hooks/useStationCurrent.js +3 -2
  73. package/dist/react/hooks/useStationFeed.js +3 -2
  74. package/dist/react/index.d.ts +2 -2
  75. package/dist/react/index.js +5 -5
  76. package/dist/react/lib/cells.js +4 -24
  77. package/dist/scene/air-extremes.js +12 -27
  78. package/dist/scene/air-matrix.js +45 -58
  79. package/dist/scene/card.js +14 -40
  80. package/dist/scene/cells.d.ts +4 -0
  81. package/dist/scene/cells.js +51 -0
  82. package/dist/scene/chart.js +2 -1
  83. package/dist/scene/climatology-pattern.d.ts +1 -2
  84. package/dist/scene/climatology-pattern.js +10 -11
  85. package/dist/scene/climatology-rose.d.ts +1 -2
  86. package/dist/scene/climatology-rose.js +14 -33
  87. package/dist/scene/compass-fan.js +28 -100
  88. package/dist/scene/current.d.ts +2 -1
  89. package/dist/scene/current.js +29 -56
  90. package/dist/scene/daily-pattern.d.ts +1 -3
  91. package/dist/scene/daily-pattern.js +20 -27
  92. package/dist/scene/dial-parts.d.ts +1 -0
  93. package/dist/scene/dial-parts.js +70 -0
  94. package/dist/scene/dial.d.ts +1 -2
  95. package/dist/scene/dial.js +48 -136
  96. package/dist/scene/favorable-share.js +16 -33
  97. package/dist/scene/glyphs.js +20 -16
  98. package/dist/scene/index.d.ts +5 -3
  99. package/dist/scene/node.js +19 -0
  100. package/dist/scene/recent-summaries.js +26 -63
  101. package/dist/scene/rose.js +89 -117
  102. package/dist/scene/sample-strip.d.ts +1 -2
  103. package/dist/scene/sample-strip.js +35 -36
  104. package/dist/scene/sparkline.js +31 -40
  105. package/dist/scene/strip.js +18 -57
  106. package/dist/scene/table.js +47 -69
  107. package/dist/scene/trend.d.ts +1 -2
  108. package/dist/scene/trend.js +29 -55
  109. package/dist/scene/wind-history.d.ts +1 -2
  110. package/dist/scene/wind-history.js +41 -51
  111. package/dist/scene/wind-plot.js +70 -140
  112. package/dist/server/adapters/campbell.d.ts +7 -7
  113. package/dist/server/adapters/campbell.js +1 -1
  114. package/dist/server/adapters/ecowitt.d.ts +8 -8
  115. package/dist/server/adapters/tempest.d.ts +6 -6
  116. package/dist/server/adapters/windnerd-climatology.js +4 -3
  117. package/dist/server/adapters/windnerd-live.js +3 -2
  118. package/dist/server/adapters/windnerd.d.ts +8 -8
  119. package/dist/server/adapters/windnerd.js +1 -1
  120. package/dist/server/config.d.ts +48 -48
  121. package/dist/server/hologram.js +2 -1
  122. package/package.json +6 -11
  123. package/schema/README.md +1 -1
  124. package/schema/stationclimatology.schema.json +64 -61
  125. package/schema/stationcurrent.schema.json +68 -156
  126. package/schema/stationfeed.schema.json +71 -163
  127. package/schema/stationhistory.schema.json +37 -46
  128. package/schema/stationlive.schema.json +221 -306
@@ -2,97 +2,34 @@
2
2
  import { stationFreshnessThresholds } from "../../derive.js";
3
3
  import { resolveDisplay } from "../../display.js";
4
4
  import { currentConditionsScene } from "../../scene/current.js";
5
+ import { renderScene } from "./SceneTree.js";
5
6
  import { requireResolved, resolveStation, useStationFeedContext } from "./StationFeedProvider.js";
6
- import { WindArrow } from "./WindArrow.js";
7
7
  import { useFreshness } from "../hooks/useFreshness.js";
8
- import { Dial } from "./Dial.js";
9
- import { FreshnessBadge } from "./FreshnessBadge.js";
10
- import { Fragment, jsx, jsxs } from "react/jsx-runtime";
8
+ import { useId } from "react";
11
9
  //#region src/react/components/CurrentConditions.tsx
12
10
  function CurrentConditions({ station: stationProp, stationId, servedAt: servedAtProp, receivedAtMs: receivedAtMsProp, thresholds: thresholdsProp, unit: unitProp, strings: stringsProp, formatTime: formatTimeProp }) {
13
11
  const context = useStationFeedContext();
12
+ const bezelId = useId();
14
13
  const station = requireResolved("CurrentConditions", "station", stationProp ?? resolveStation(context, stationId));
15
14
  const servedAt = servedAtProp ?? context?.feed?.servedAt ?? null;
16
15
  const receivedAtMs = receivedAtMsProp !== void 0 ? receivedAtMsProp : context?.receivedAtMs ?? null;
17
- const { formatTime, strings, thresholds, unit, words } = resolveDisplay(context, {
16
+ const { formatTime, thresholds, unit, words } = resolveDisplay(context, {
18
17
  formatTime: formatTimeProp,
19
18
  strings: stringsProp,
20
19
  thresholds: thresholdsProp,
21
20
  unit: unitProp
22
21
  });
23
- const status = useFreshness((station.status === "ok" ? station.reading : null)?.observedAt ?? null, servedAt, receivedAtMs, stationFreshnessThresholds(station));
24
- const scene = currentConditionsScene({
22
+ const reading = station.status === "ok" ? station.reading : null;
23
+ const status = useFreshness(reading?.observedAt ?? null, servedAt, receivedAtMs, stationFreshnessThresholds(station));
24
+ return renderScene(currentConditionsScene({
25
+ bezelId: `meteo-bezel-${bezelId.replace(/[^a-zA-Z0-9_-]/g, "")}`,
25
26
  formatTime,
27
+ freshness: status,
26
28
  station,
29
+ thresholds,
27
30
  unit,
28
31
  words
29
- });
30
- const { direction, temperature, footer } = scene;
31
- return /* @__PURE__ */ jsxs("div", {
32
- "aria-label": scene.root.ariaLabel,
33
- className: scene.root.className,
34
- "data-status": scene.root.status,
35
- role: "group",
36
- children: [
37
- /* @__PURE__ */ jsxs("div", {
38
- className: scene.instrumentClassName,
39
- children: [
40
- scene.flanks && /* @__PURE__ */ jsxs("div", {
41
- className: scene.flanks.lull.className,
42
- children: [/* @__PURE__ */ jsx("small", {
43
- className: scene.flanks.lull.labelClassName,
44
- children: scene.flanks.lull.label
45
- }), /* @__PURE__ */ jsx("strong", { children: scene.flanks.lull.value })]
46
- }),
47
- /* @__PURE__ */ jsx(Dial, {
48
- calmWord: false,
49
- station,
50
- strings,
51
- thresholds: thresholds ?? null,
52
- unit
53
- }),
54
- scene.flanks && /* @__PURE__ */ jsxs("div", {
55
- className: scene.flanks.gust.className,
56
- children: [/* @__PURE__ */ jsx("small", {
57
- className: scene.flanks.gust.labelClassName,
58
- children: scene.flanks.gust.label
59
- }), /* @__PURE__ */ jsx("strong", { children: scene.flanks.gust.value })]
60
- })
61
- ]
62
- }),
63
- /* @__PURE__ */ jsx("p", {
64
- className: direction.className,
65
- children: direction.content.kind === "text" ? direction.content.text : /* @__PURE__ */ jsxs(Fragment, { children: [
66
- /* @__PURE__ */ jsx("span", {
67
- className: direction.content.labelClassName,
68
- children: direction.content.label
69
- }),
70
- " ",
71
- /* @__PURE__ */ jsx(WindArrow, { deg: direction.content.deg }),
72
- " ",
73
- /* @__PURE__ */ jsx("strong", { children: direction.content.compass }),
74
- direction.content.tail
75
- ] })
76
- }),
77
- temperature && /* @__PURE__ */ jsxs("p", {
78
- className: temperature.className,
79
- children: [temperature.text, temperature.chill && /* @__PURE__ */ jsx("span", {
80
- className: temperature.chill.className,
81
- children: temperature.chill.text
82
- })]
83
- }),
84
- /* @__PURE__ */ jsxs("p", {
85
- className: footer.className,
86
- children: [status != null && /* @__PURE__ */ jsx(FreshnessBadge, {
87
- status,
88
- strings
89
- }), /* @__PURE__ */ jsx("span", {
90
- className: footer.observed.className,
91
- children: footer.observed.text
92
- })]
93
- })
94
- ]
95
- });
32
+ }));
96
33
  }
97
34
  //#endregion
98
35
  export { CurrentConditions };
@@ -1,10 +1,8 @@
1
1
  import { HistoryPoint, Station } from "../../contract.js";
2
- import { SpeedThresholds, SpeedUnit, compassDirection } from "../../derive.js";
2
+ import { SpeedThresholds, SpeedUnit } from "../../derive.js";
3
3
  import { StationStringOverrides } from "../../strings.js";
4
4
  import { FavorableDirection } from "../../instruments.js";
5
5
  import "../../index.js";
6
- import "../../scene/index.js";
7
- import { WindArrow } from "./WindArrow.js";
8
6
  //#region src/react/components/DailyPattern.d.ts
9
7
  declare function DailyPattern({ station: stationProp, stationId, points, slotMinutes, utcOffsetMinutes, thresholds: thresholdsProp, favorableDirections: favorableDirectionsProp, unit: unitProp, plotHeight, strings: stringsProp }: {
10
8
  station?: Station;
@@ -1,12 +1,11 @@
1
1
  "use client";
2
- import "../../derive.js";
3
2
  import { resolveDisplay } from "../../display.js";
4
3
  import { measuredChartWidth } from "../../geometry.js";
5
4
  import { DAILY_PATTERN_CLASS, dailyPatternGate, dailyPatternScene, dailyPatternSource } from "../../scene/daily-pattern.js";
5
+ import { renderChildren } from "./SceneTree.js";
6
6
  import { resolveStation, useStationFeedContext } from "./StationFeedProvider.js";
7
- import "./WindArrow.js";
8
7
  import { useEffect, useId, useRef, useState } from "react";
9
- import { Fragment, jsx, jsxs } from "react/jsx-runtime";
8
+ import { jsx } from "react/jsx-runtime";
10
9
  //#region src/react/components/DailyPattern.tsx
11
10
  function DailyPattern({ station: stationProp, stationId, points, slotMinutes = 180, utcOffsetMinutes = 0, thresholds: thresholdsProp, favorableDirections: favorableDirectionsProp, unit: unitProp, plotHeight, strings: stringsProp }) {
12
11
  const context = useStationFeedContext();
@@ -21,6 +20,7 @@ function DailyPattern({ station: stationProp, stationId, points, slotMinutes = 1
21
20
  const [width, setWidth] = useState(null);
22
21
  const { source, periodMinutes } = dailyPatternSource(points, station);
23
22
  const gate = dailyPatternGate(source, words);
23
+ const drawable = gate.kind === "draw";
24
24
  useEffect(() => {
25
25
  const element = wrapRef.current;
26
26
  if (!element) return;
@@ -33,7 +33,7 @@ function DailyPattern({ station: stationProp, stationId, points, slotMinutes = 1
33
33
  });
34
34
  observer.observe(element);
35
35
  return () => observer.disconnect();
36
- }, [gate.kind === "draw"]);
36
+ }, [drawable]);
37
37
  if (gate.kind === "note") return /* @__PURE__ */ jsx("div", {
38
38
  className: gate.className,
39
39
  role: "note",
@@ -58,9 +58,10 @@ function DailyPattern({ station: stationProp, stationId, points, slotMinutes = 1
58
58
  });
59
59
  }
60
60
  function MeasuredDailyPattern({ favorableDirections, periodMinutes, plotHeight, points, slotMinutes, stationName, thresholds, unit, utcOffsetMinutes, width, words }) {
61
- return /* @__PURE__ */ jsx(DailyPatternSceneView, { scene: dailyPatternScene({
61
+ const hatchId = `meteo-daily-pattern-hatch-${useId().replace(/[^a-zA-Z0-9_-]/g, "")}`;
62
+ const scene = dailyPatternScene({
62
63
  favorableDirections,
63
- hatchId: `meteo-daily-pattern-hatch-${useId().replace(/[^a-zA-Z0-9_-]/g, "")}`,
64
+ hatchId,
64
65
  periodMinutes,
65
66
  plotHeight,
66
67
  points,
@@ -71,148 +72,8 @@ function MeasuredDailyPattern({ favorableDirections, periodMinutes, plotHeight,
71
72
  utcOffsetMinutes,
72
73
  width,
73
74
  words
74
- }) });
75
- }
76
- /** One scene, one drawing — shared by the history-fed pattern above and the
77
- * climatology-fed twin. */
78
- function DailyPatternSceneView({ scene }) {
79
- return /* @__PURE__ */ jsxs(Fragment, { children: [/* @__PURE__ */ jsx("output", {
80
- className: scene.caption.className,
81
- children: scene.caption.text
82
- }), /* @__PURE__ */ jsxs("svg", {
83
- "aria-label": scene.svg.ariaLabel,
84
- className: scene.svg.className,
85
- height: scene.svg.height,
86
- role: "img",
87
- viewBox: scene.svg.viewBox,
88
- width: scene.svg.width,
89
- children: [
90
- /* @__PURE__ */ jsx("defs", { children: /* @__PURE__ */ jsx("pattern", {
91
- height: scene.defs.pattern.height,
92
- id: scene.defs.pattern.id,
93
- patternTransform: scene.defs.pattern.transform,
94
- patternUnits: scene.defs.pattern.units,
95
- width: scene.defs.pattern.width,
96
- children: /* @__PURE__ */ jsx("line", {
97
- className: scene.defs.pattern.line.className,
98
- x1: scene.defs.pattern.line.x1,
99
- x2: scene.defs.pattern.line.x2,
100
- y1: scene.defs.pattern.line.y1,
101
- y2: scene.defs.pattern.line.y2
102
- })
103
- }) }),
104
- scene.zones.map((zone) => /* @__PURE__ */ jsx("rect", {
105
- className: zone.className,
106
- height: zone.height,
107
- width: zone.width,
108
- x: zone.x,
109
- y: zone.y
110
- }, zone.key)),
111
- scene.grid.map(({ key, line, label }) => /* @__PURE__ */ jsxs("g", { children: [/* @__PURE__ */ jsx("line", {
112
- className: line.className,
113
- x1: line.x1,
114
- x2: line.x2,
115
- y1: line.y1,
116
- y2: line.y2
117
- }), /* @__PURE__ */ jsx("text", {
118
- className: label.className,
119
- textAnchor: label.anchor,
120
- x: label.x,
121
- y: label.y,
122
- children: label.text
123
- })] }, key)),
124
- scene.thresholdGuides.map(({ key, line, label }) => /* @__PURE__ */ jsxs("g", { children: [/* @__PURE__ */ jsx("line", {
125
- className: line.className,
126
- x1: line.x1,
127
- x2: line.x2,
128
- y1: line.y1,
129
- y2: line.y2
130
- }), /* @__PURE__ */ jsx("text", {
131
- className: label.className,
132
- textAnchor: label.anchor,
133
- x: label.x,
134
- y: label.y,
135
- children: label.text
136
- })] }, key)),
137
- scene.vaneGuides.map((guide) => /* @__PURE__ */ jsx("line", {
138
- className: guide.className,
139
- x1: guide.x1,
140
- x2: guide.x2,
141
- y1: guide.y1,
142
- y2: guide.y2
143
- }, `guide-${guide.key}`)),
144
- scene.gaps.map((gap) => /* @__PURE__ */ jsx("rect", {
145
- className: gap.className,
146
- fill: gap.fill,
147
- height: gap.height,
148
- width: gap.width,
149
- x: gap.x,
150
- y: gap.y
151
- }, gap.key)),
152
- scene.mean.kind === "polyline" ? /* @__PURE__ */ jsx("polyline", {
153
- className: scene.mean.className,
154
- points: scene.mean.points
155
- }) : scene.mean.segments.map((segment) => /* @__PURE__ */ jsx("line", {
156
- className: segment.className,
157
- x1: segment.x1,
158
- x2: segment.x2,
159
- y1: segment.y1,
160
- y2: segment.y2
161
- }, segment.key)),
162
- scene.calmNote && /* @__PURE__ */ jsx("text", {
163
- className: scene.calmNote.className,
164
- textAnchor: scene.calmNote.anchor,
165
- x: scene.calmNote.x,
166
- y: scene.calmNote.y,
167
- children: scene.calmNote.text
168
- }),
169
- /* @__PURE__ */ jsx("text", {
170
- className: scene.rowLabels.to.className,
171
- textAnchor: scene.rowLabels.to.anchor,
172
- x: scene.rowLabels.to.x,
173
- y: scene.rowLabels.to.y,
174
- children: scene.rowLabels.to.text
175
- }),
176
- scene.vanes.map((vane) => vane.mark.kind === "calm" ? /* @__PURE__ */ jsx("text", {
177
- className: vane.mark.text.className,
178
- textAnchor: vane.mark.text.anchor,
179
- x: vane.mark.text.x,
180
- y: vane.mark.text.y,
181
- children: vane.mark.text.text
182
- }, vane.key) : /* @__PURE__ */ jsx("path", {
183
- className: vane.mark.className,
184
- d: vane.mark.d
185
- }, vane.key)),
186
- scene.vanes.map((vane) => vane.label && /* @__PURE__ */ jsx("text", {
187
- className: vane.label.className,
188
- textAnchor: vane.label.anchor,
189
- x: vane.label.x,
190
- y: vane.label.y,
191
- children: vane.label.text
192
- }, `label-${vane.key}`)),
193
- /* @__PURE__ */ jsx("text", {
194
- className: scene.rowLabels.avg.className,
195
- textAnchor: scene.rowLabels.avg.anchor,
196
- x: scene.rowLabels.avg.x,
197
- y: scene.rowLabels.avg.y,
198
- children: scene.rowLabels.avg.text
199
- }),
200
- scene.vanes.map((vane) => vane.value && /* @__PURE__ */ jsx("text", {
201
- className: vane.value.className,
202
- textAnchor: vane.value.anchor,
203
- x: vane.value.x,
204
- y: vane.value.y,
205
- children: vane.value.text
206
- }, `value-${vane.key}`)),
207
- scene.ticks.map((tick) => /* @__PURE__ */ jsx("text", {
208
- className: tick.className,
209
- textAnchor: tick.anchor,
210
- x: tick.x,
211
- y: tick.y,
212
- children: tick.text
213
- }, tick.key))
214
- ]
215
- })] });
75
+ });
76
+ return renderChildren(scene);
216
77
  }
217
78
  //#endregion
218
- export { DailyPattern, DailyPatternSceneView };
79
+ export { DailyPattern };
@@ -13,6 +13,6 @@ declare function Dial({ station: stationProp, stationId, thresholds: thresholdsP
13
13
  size?: number;
14
14
  calmWord?: boolean;
15
15
  strings?: StationStringOverrides;
16
- }): import("react").JSX.Element;
16
+ }): import("react").ReactNode;
17
17
  //#endregion
18
18
  export { Dial };
@@ -2,9 +2,9 @@
2
2
  import { resolveDisplay } from "../../display.js";
3
3
  import "../../instruments.js";
4
4
  import { dialScene } from "../../scene/dial.js";
5
+ import { renderScene } from "./SceneTree.js";
5
6
  import { requireResolved, resolveStation, useStationFeedContext } from "./StationFeedProvider.js";
6
7
  import { useId } from "react";
7
- import { Fragment, jsx, jsxs } from "react/jsx-runtime";
8
8
  //#region src/react/components/Dial.tsx
9
9
  function Dial({ station: stationProp, stationId, thresholds: thresholdsProp, favorableDirections: favorableDirectionsProp, unit: unitProp, size = 160, calmWord = true, strings: stringsProp }) {
10
10
  const context = useStationFeedContext();
@@ -15,8 +15,9 @@ function Dial({ station: stationProp, stationId, thresholds: thresholdsProp, fav
15
15
  favorableDirections: favorableDirectionsProp,
16
16
  unit: unitProp
17
17
  });
18
- const scene = dialScene({
19
- bezelId: `meteo-bezel-${useId().replace(/[^a-zA-Z0-9_-]/g, "")}`,
18
+ const bezelId = `meteo-bezel-${useId().replace(/[^a-zA-Z0-9_-]/g, "")}`;
19
+ return renderScene(dialScene({
20
+ bezelId,
20
21
  calmWord,
21
22
  favorableDirections,
22
23
  size,
@@ -24,121 +25,7 @@ function Dial({ station: stationProp, stationId, thresholds: thresholdsProp, fav
24
25
  thresholds,
25
26
  unit,
26
27
  words
27
- });
28
- const { gradient, centre } = scene;
29
- return /* @__PURE__ */ jsxs("svg", {
30
- "aria-label": scene.svg.ariaLabel,
31
- className: scene.svg.className,
32
- height: scene.svg.height,
33
- role: "img",
34
- viewBox: scene.svg.viewBox,
35
- width: scene.svg.width,
36
- children: [
37
- /* @__PURE__ */ jsx("defs", { children: /* @__PURE__ */ jsx("radialGradient", {
38
- cx: gradient.cx,
39
- cy: gradient.cy,
40
- id: gradient.id,
41
- r: gradient.r,
42
- children: gradient.stops.map((stop) => /* @__PURE__ */ jsx("stop", {
43
- className: stop.className,
44
- offset: stop.offset
45
- }, stop.offset))
46
- }) }),
47
- /* @__PURE__ */ jsx("circle", {
48
- className: scene.face.className,
49
- cx: scene.face.cx,
50
- cy: scene.face.cy,
51
- r: scene.face.r
52
- }),
53
- /* @__PURE__ */ jsx("circle", {
54
- className: scene.bezel.className,
55
- cx: scene.bezel.cx,
56
- cy: scene.bezel.cy,
57
- fill: scene.bezel.fill,
58
- r: scene.bezel.r
59
- }),
60
- /* @__PURE__ */ jsx("circle", {
61
- className: scene.ring.className,
62
- cx: scene.ring.cx,
63
- cy: scene.ring.cy,
64
- r: scene.ring.r
65
- }),
66
- scene.verdictRing && /* @__PURE__ */ jsxs(Fragment, { children: [/* @__PURE__ */ jsx("circle", {
67
- className: scene.verdictRing.unfavorable.className,
68
- cx: scene.verdictRing.unfavorable.cx,
69
- cy: scene.verdictRing.unfavorable.cy,
70
- r: scene.verdictRing.unfavorable.r
71
- }), scene.verdictRing.favorable.map((arc) => /* @__PURE__ */ jsx("path", {
72
- className: arc.className,
73
- d: arc.d
74
- }, arc.key))] }),
75
- scene.arc && /* @__PURE__ */ jsx("path", {
76
- className: scene.arc.className,
77
- d: scene.arc.d
78
- }),
79
- scene.ticks.map((tick) => /* @__PURE__ */ jsx("line", {
80
- className: tick.className,
81
- x1: tick.x1,
82
- x2: tick.x2,
83
- y1: tick.y1,
84
- y2: tick.y2
85
- }, tick.key)),
86
- scene.letters.map((letter) => /* @__PURE__ */ jsx("text", {
87
- className: letter.className,
88
- textAnchor: letter.anchor,
89
- x: letter.x,
90
- y: letter.y,
91
- children: letter.text
92
- }, letter.key)),
93
- scene.needle && /* @__PURE__ */ jsxs("g", {
94
- className: scene.needle.className,
95
- children: [/* @__PURE__ */ jsx("polygon", {
96
- className: scene.needle.blade.className,
97
- points: scene.needle.blade.points
98
- }), /* @__PURE__ */ jsx("circle", {
99
- className: scene.needle.counterweight.className,
100
- cx: scene.needle.counterweight.cx,
101
- cy: scene.needle.counterweight.cy,
102
- r: scene.needle.counterweight.r
103
- })]
104
- }),
105
- /* @__PURE__ */ jsx("circle", {
106
- className: scene.hub.className,
107
- cx: scene.hub.cx,
108
- cy: scene.hub.cy,
109
- r: scene.hub.r
110
- }),
111
- centre.kind === "reason" ? /* @__PURE__ */ jsx("text", {
112
- className: centre.text.className,
113
- textAnchor: centre.text.anchor,
114
- x: centre.text.x,
115
- y: centre.text.y,
116
- children: centre.text.text
117
- }) : /* @__PURE__ */ jsxs(Fragment, { children: [
118
- centre.calmWord && /* @__PURE__ */ jsx("text", {
119
- className: centre.calmWord.className,
120
- textAnchor: centre.calmWord.anchor,
121
- x: centre.calmWord.x,
122
- y: centre.calmWord.y,
123
- children: centre.calmWord.text
124
- }),
125
- /* @__PURE__ */ jsx("text", {
126
- className: centre.speed.className,
127
- textAnchor: centre.speed.anchor,
128
- x: centre.speed.x,
129
- y: centre.speed.y,
130
- children: centre.speed.text
131
- }),
132
- /* @__PURE__ */ jsx("text", {
133
- className: centre.unit.className,
134
- textAnchor: centre.unit.anchor,
135
- x: centre.unit.x,
136
- y: centre.unit.y,
137
- children: centre.unit.text
138
- })
139
- ] })
140
- ]
141
- });
28
+ }));
142
29
  }
143
30
  //#endregion
144
31
  export { Dial };
@@ -9,6 +9,6 @@ declare function FavorableShare({ station: stationProp, stationId, points, favor
9
9
  points?: HistoryPoint[];
10
10
  favorableDirections?: FavorableDirection[] | null;
11
11
  strings?: StationStringOverrides;
12
- }): import("react").JSX.Element | null;
12
+ }): import("react").ReactNode;
13
13
  //#endregion
14
14
  export { FavorableShare };
@@ -1,8 +1,8 @@
1
1
  "use client";
2
2
  import { resolveDisplay } from "../../display.js";
3
- import { favorableShareGate, favorableShareScene, favorableShareSource } from "../../scene/favorable-share.js";
3
+ import { favorableShareScene, favorableShareSource } from "../../scene/favorable-share.js";
4
+ import { renderOptional } from "./SceneTree.js";
4
5
  import { resolveStation, useStationFeedContext } from "./StationFeedProvider.js";
5
- import { jsx, jsxs } from "react/jsx-runtime";
6
6
  //#region src/react/components/FavorableShare.tsx
7
7
  function FavorableShare({ station: stationProp, stationId, points, favorableDirections: favorableDirectionsProp, strings: stringsProp }) {
8
8
  const context = useStationFeedContext();
@@ -11,33 +11,12 @@ function FavorableShare({ station: stationProp, stationId, points, favorableDire
11
11
  strings: stringsProp,
12
12
  favorableDirections: favorableDirectionsProp
13
13
  });
14
- const gate = favorableShareGate(favorableShareSource(points, station), favorableDirections, words);
15
- if (gate.kind === "hidden") return null;
16
- if (gate.kind === "note") return /* @__PURE__ */ jsx("div", {
17
- className: gate.className,
18
- role: "note",
19
- children: gate.text
20
- });
21
- const scene = favorableShareScene({
22
- share: gate.share,
14
+ return renderOptional(favorableShareScene({
15
+ favorableDirections,
16
+ source: favorableShareSource(points, station),
23
17
  stationName: station?.name,
24
18
  words
25
- });
26
- return /* @__PURE__ */ jsxs("div", {
27
- "aria-label": scene.ariaLabel,
28
- className: scene.className,
29
- children: [
30
- /* @__PURE__ */ jsx("span", {
31
- className: scene.label.className,
32
- children: scene.label.text
33
- }),
34
- " ",
35
- /* @__PURE__ */ jsx("span", {
36
- className: scene.value.className,
37
- children: scene.value.text
38
- })
39
- ]
40
- });
19
+ }));
41
20
  }
42
21
  //#endregion
43
22
  export { FavorableShare };
@@ -5,6 +5,6 @@ import "../../index.js";
5
5
  declare function FreshnessBadge({ status, strings }: {
6
6
  status: FreshnessStatus;
7
7
  strings?: StationStringOverrides;
8
- }): import("react").JSX.Element;
8
+ }): import("react").ReactNode;
9
9
  //#endregion
10
10
  export { FreshnessBadge };
@@ -1,20 +1,13 @@
1
1
  "use client";
2
2
  import { resolveDisplay } from "../../display.js";
3
- import { freshnessBadgeSpec } from "../../scene/glyphs.js";
3
+ import { freshnessBadgeNode } from "../../scene/glyphs.js";
4
+ import { renderScene } from "./SceneTree.js";
4
5
  import { useStationFeedContext } from "./StationFeedProvider.js";
5
- import { jsx, jsxs } from "react/jsx-runtime";
6
6
  //#region src/react/components/FreshnessBadge.tsx
7
7
  function FreshnessBadge({ status, strings }) {
8
- const { words } = resolveDisplay(useStationFeedContext(), { strings });
9
- const spec = freshnessBadgeSpec(status, words);
10
- return /* @__PURE__ */ jsxs("span", {
11
- className: spec.className,
12
- "data-freshness": spec.status,
13
- children: [/* @__PURE__ */ jsx("span", {
14
- "aria-hidden": "true",
15
- className: spec.dot.className
16
- }), spec.text]
17
- });
8
+ const context = useStationFeedContext();
9
+ const { words } = resolveDisplay(context, { strings });
10
+ return renderScene(freshnessBadgeNode(status, words));
18
11
  }
19
12
  //#endregion
20
13
  export { FreshnessBadge };
@@ -13,6 +13,6 @@ declare function RecentSummaries({ summaries, station: stationProp, stationId, f
13
13
  favorableDirections?: FavorableDirection[] | null;
14
14
  unit?: SpeedUnit;
15
15
  strings?: StationStringOverrides;
16
- }): import("react").JSX.Element | null;
16
+ }): import("react").ReactNode;
17
17
  //#endregion
18
18
  export { RecentSummaries };
@@ -1,9 +1,8 @@
1
1
  "use client";
2
2
  import { resolveDisplay } from "../../display.js";
3
- import { recentSummariesGate, recentSummariesScene } from "../../scene/recent-summaries.js";
3
+ import { recentSummariesScene } from "../../scene/recent-summaries.js";
4
+ import { renderOptional } from "./SceneTree.js";
4
5
  import { resolveStation, useStationFeedContext } from "./StationFeedProvider.js";
5
- import { WindArrow } from "./WindArrow.js";
6
- import { jsx, jsxs } from "react/jsx-runtime";
7
6
  //#region src/react/components/RecentSummaries.tsx
8
7
  /** The source's own step digests as summary panels: per window, the
9
8
  * average, gust, and lull beside one small arrow per step. */
@@ -15,50 +14,13 @@ function RecentSummaries({ summaries, station: stationProp, stationId, favorable
15
14
  favorableDirections: favorableDirectionsProp,
16
15
  unit: unitProp
17
16
  });
18
- const gate = recentSummariesGate(station, summaries, words);
19
- if (gate.kind === "hidden") return null;
20
- if (gate.kind === "note") return /* @__PURE__ */ jsx("div", {
21
- className: gate.className,
22
- role: "note",
23
- children: gate.text
24
- });
25
- const scene = recentSummariesScene({
17
+ return renderOptional(recentSummariesScene({
26
18
  favorableDirections,
27
- stationName: station?.name,
28
- summaries: gate.summaries,
19
+ station,
20
+ summaries,
29
21
  unit,
30
22
  words
31
- });
32
- return /* @__PURE__ */ jsx("div", {
33
- "aria-label": scene.ariaLabel,
34
- className: scene.className,
35
- children: scene.panels.map((panel) => /* @__PURE__ */ jsxs("section", {
36
- className: panel.className,
37
- children: [
38
- /* @__PURE__ */ jsx("h4", {
39
- className: panel.label.className,
40
- children: panel.label.text
41
- }),
42
- /* @__PURE__ */ jsx("div", {
43
- className: "meteo-recent-summary-ghosts",
44
- children: panel.ghosts.map((ghost) => /* @__PURE__ */ jsx("span", {
45
- className: ghost.className,
46
- children: /* @__PURE__ */ jsx(WindArrow, { deg: ghost.deg })
47
- }, ghost.key))
48
- }),
49
- /* @__PURE__ */ jsx("dl", {
50
- className: "meteo-recent-summary-stats",
51
- children: panel.stats.map((stat) => /* @__PURE__ */ jsxs("div", {
52
- className: stat.className,
53
- children: [/* @__PURE__ */ jsx("dt", {
54
- className: "meteo-microlabel",
55
- children: stat.label
56
- }), /* @__PURE__ */ jsx("dd", { children: stat.value })]
57
- }, stat.key))
58
- })
59
- ]
60
- }, panel.key))
61
- });
23
+ }));
62
24
  }
63
25
  //#endregion
64
26
  export { RecentSummaries };
@@ -0,0 +1,38 @@
1
+ import { createElement } from "react";
2
+ //#region src/react/components/SceneTree.tsx
3
+ function reactName(name) {
4
+ if (name === "class") return "className";
5
+ if (name.startsWith("aria-") || name.startsWith("data-") || !name.includes("-")) return name;
6
+ return name.replace(/-([a-z])/g, (_, letter) => letter.toUpperCase());
7
+ }
8
+ function reactProps(node) {
9
+ const props = {};
10
+ for (const [name, value] of Object.entries(node.attrs ?? {})) {
11
+ if (value == null || value === false) continue;
12
+ props[reactName(name)] = value;
13
+ }
14
+ if (node.style !== void 0) props["style"] = node.style;
15
+ if (node.key !== void 0) props["key"] = node.key;
16
+ return props;
17
+ }
18
+ function renderChild(child, index) {
19
+ if (child == null || child === false) return null;
20
+ if (typeof child === "string" || typeof child === "number") return child;
21
+ return renderScene(child, index);
22
+ }
23
+ function renderScene(node, fallbackKey) {
24
+ const props = reactProps(node);
25
+ if (props["key"] === void 0 && fallbackKey !== void 0) props["key"] = fallbackKey;
26
+ const children = node.children ?? [];
27
+ return children.length === 0 ? createElement(node.tag, props) : createElement(node.tag, props, ...children.map(renderChild));
28
+ }
29
+ /** The scene, or nothing when the widget has no surface to draw. */
30
+ function renderOptional(node) {
31
+ return node === null ? null : renderScene(node);
32
+ }
33
+ /** A run of children with no element of their own to sit in. */
34
+ function renderChildren(children) {
35
+ return children.map(renderChild);
36
+ }
37
+ //#endregion
38
+ export { renderChild, renderChildren, renderOptional, renderScene };