@azohra/meteo.station 0.6.0 → 0.7.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (237) hide show
  1. package/README.md +17 -17
  2. package/dist/air.d.ts +4 -7
  3. package/dist/air.js +1 -2
  4. package/dist/client/climatology.d.ts +4 -7
  5. package/dist/client/climatology.js +1 -2
  6. package/dist/client/history.d.ts +14 -17
  7. package/dist/client/history.js +1 -2
  8. package/dist/client/live.d.ts +9 -11
  9. package/dist/client/live.js +1 -2
  10. package/dist/client/poll.d.ts +9 -12
  11. package/dist/client/poll.js +1 -2
  12. package/dist/client/stores.d.ts +8 -10
  13. package/dist/client/stores.js +1 -2
  14. package/dist/client/ticker.d.ts +1 -4
  15. package/dist/client/ticker.js +1 -2
  16. package/dist/climatology.d.ts +13 -15
  17. package/dist/climatology.js +1 -2
  18. package/dist/connectivity.d.ts +9 -12
  19. package/dist/connectivity.js +1 -2
  20. package/dist/contract-climatology.d.ts +11 -14
  21. package/dist/contract-climatology.js +1 -2
  22. package/dist/contract.d.ts +148 -151
  23. package/dist/contract.js +1 -2
  24. package/dist/derive.d.ts +24 -26
  25. package/dist/derive.js +5 -6
  26. package/dist/display.d.ts +6 -9
  27. package/dist/display.js +1 -2
  28. package/dist/elements/elements/AirExtremesElement.d.ts +2 -5
  29. package/dist/elements/elements/AirExtremesElement.js +6 -20
  30. package/dist/elements/elements/AirMatrixElement.d.ts +2 -5
  31. package/dist/elements/elements/AirMatrixElement.js +7 -33
  32. package/dist/elements/elements/ClimatologyDailyPatternElement.d.ts +2 -5
  33. package/dist/elements/elements/ClimatologyDailyPatternElement.js +18 -14
  34. package/dist/elements/elements/ClimatologyRoseElement.d.ts +2 -5
  35. package/dist/elements/elements/ClimatologyRoseElement.js +6 -17
  36. package/dist/elements/elements/CompassFanElement.d.ts +2 -5
  37. package/dist/elements/elements/CompassFanElement.js +6 -66
  38. package/dist/elements/elements/CurrentConditionsElement.d.ts +2 -5
  39. package/dist/elements/elements/CurrentConditionsElement.js +8 -28
  40. package/dist/elements/elements/DailyPatternElement.d.ts +2 -6
  41. package/dist/elements/elements/DailyPatternElement.js +7 -122
  42. package/dist/elements/elements/DialElement.d.ts +2 -5
  43. package/dist/elements/elements/DialElement.js +4 -97
  44. package/dist/elements/elements/FavorableShareElement.d.ts +2 -5
  45. package/dist/elements/elements/FavorableShareElement.js +7 -23
  46. package/dist/elements/elements/FreshnessBadgeElement.d.ts +2 -5
  47. package/dist/elements/elements/FreshnessBadgeElement.js +1 -2
  48. package/dist/elements/elements/RecentSummariesElement.d.ts +2 -5
  49. package/dist/elements/elements/RecentSummariesElement.js +7 -25
  50. package/dist/elements/elements/SparklineElement.d.ts +2 -6
  51. package/dist/elements/elements/SparklineElement.js +5 -41
  52. package/dist/elements/elements/StationCardElement.d.ts +6 -8
  53. package/dist/elements/elements/StationCardElement.js +5 -20
  54. package/dist/elements/elements/StationFeedElement.d.ts +2 -5
  55. package/dist/elements/elements/StationFeedElement.js +5 -4
  56. package/dist/elements/elements/StationStripElement.d.ts +2 -5
  57. package/dist/elements/elements/StationStripElement.js +5 -20
  58. package/dist/elements/elements/StationTableElement.d.ts +3 -6
  59. package/dist/elements/elements/StationTableElement.js +16 -53
  60. package/dist/elements/elements/TrendChartElement.d.ts +2 -5
  61. package/dist/elements/elements/TrendChartElement.js +22 -71
  62. package/dist/elements/elements/WindArrowElement.d.ts +2 -5
  63. package/dist/elements/elements/WindArrowElement.js +1 -2
  64. package/dist/elements/elements/WindHistoryChartElement.d.ts +2 -5
  65. package/dist/elements/elements/WindHistoryChartElement.js +24 -166
  66. package/dist/elements/elements/WindRoseElement.d.ts +2 -6
  67. package/dist/elements/elements/WindRoseElement.js +7 -72
  68. package/dist/elements/elements/atoms.d.ts +10 -12
  69. package/dist/elements/elements/atoms.js +12 -40
  70. package/dist/elements/index.d.ts +3 -5
  71. package/dist/elements/index.js +4 -5
  72. package/dist/elements/lib/ambient.d.ts +2 -5
  73. package/dist/elements/lib/ambient.js +1 -2
  74. package/dist/elements/lib/attributes.js +1 -2
  75. package/dist/elements/lib/base.d.ts +3 -6
  76. package/dist/elements/lib/base.js +1 -2
  77. package/dist/elements/lib/context.js +1 -2
  78. package/dist/elements/lib/fragments.js +9 -39
  79. package/dist/elements/lib/h.js +2 -3
  80. package/dist/elements/lib/pinned-cursor.js +1 -2
  81. package/dist/elements/lib/render.js +29 -0
  82. package/dist/elements/register.js +1 -2
  83. package/dist/endpoints.d.ts +6 -9
  84. package/dist/endpoints.js +1 -2
  85. package/dist/fixtures.d.ts +7 -10
  86. package/dist/fixtures.js +1 -2
  87. package/dist/format.d.ts +11 -14
  88. package/dist/format.js +1 -2
  89. package/dist/geometry.d.ts +36 -38
  90. package/dist/geometry.js +3 -3
  91. package/dist/instruments.d.ts +37 -40
  92. package/dist/instruments.js +3 -4
  93. package/dist/merge-current.d.ts +4 -7
  94. package/dist/merge-current.js +1 -2
  95. package/dist/react/components/AirExtremes.d.ts +2 -5
  96. package/dist/react/components/AirExtremes.js +6 -24
  97. package/dist/react/components/AirMatrix.d.ts +2 -5
  98. package/dist/react/components/AirMatrix.js +11 -45
  99. package/dist/react/components/ClimatologyDailyPattern.d.ts +2 -5
  100. package/dist/react/components/ClimatologyDailyPattern.js +20 -15
  101. package/dist/react/components/ClimatologyRose.d.ts +2 -5
  102. package/dist/react/components/ClimatologyRose.js +12 -30
  103. package/dist/react/components/CompassFan.d.ts +2 -5
  104. package/dist/react/components/CompassFan.js +7 -75
  105. package/dist/react/components/CurrentConditions.d.ts +2 -5
  106. package/dist/react/components/CurrentConditions.js +12 -76
  107. package/dist/react/components/DailyPattern.d.ts +3 -8
  108. package/dist/react/components/DailyPattern.js +11 -151
  109. package/dist/react/components/Dial.d.ts +2 -5
  110. package/dist/react/components/Dial.js +6 -120
  111. package/dist/react/components/FavorableShare.d.ts +2 -5
  112. package/dist/react/components/FavorableShare.js +7 -29
  113. package/dist/react/components/FreshnessBadge.d.ts +2 -5
  114. package/dist/react/components/FreshnessBadge.js +6 -14
  115. package/dist/react/components/Readout.d.ts +2 -5
  116. package/dist/react/components/Readout.js +1 -2
  117. package/dist/react/components/RecentSummaries.d.ts +2 -5
  118. package/dist/react/components/RecentSummaries.js +7 -46
  119. package/dist/react/components/SceneTree.js +37 -0
  120. package/dist/react/components/Sparkline.d.ts +2 -5
  121. package/dist/react/components/Sparkline.js +4 -41
  122. package/dist/react/components/StationCard.d.ts +8 -10
  123. package/dist/react/components/StationCard.js +6 -47
  124. package/dist/react/components/StationFeedProvider.d.ts +3 -6
  125. package/dist/react/components/StationFeedProvider.js +1 -2
  126. package/dist/react/components/StationStrip.d.ts +2 -5
  127. package/dist/react/components/StationStrip.js +6 -62
  128. package/dist/react/components/StationTable.d.ts +3 -6
  129. package/dist/react/components/StationTable.js +22 -77
  130. package/dist/react/components/TrendChart.d.ts +2 -5
  131. package/dist/react/components/TrendChart.js +9 -65
  132. package/dist/react/components/WindArrow.d.ts +2 -5
  133. package/dist/react/components/WindArrow.js +4 -17
  134. package/dist/react/components/WindHistoryChart.d.ts +2 -5
  135. package/dist/react/components/WindHistoryChart.js +9 -184
  136. package/dist/react/components/WindRose.d.ts +2 -7
  137. package/dist/react/components/WindRose.js +7 -91
  138. package/dist/react/components/WindSampleStrip.d.ts +2 -5
  139. package/dist/react/components/WindSampleStrip.js +9 -117
  140. package/dist/react/components/atoms.d.ts +12 -14
  141. package/dist/react/components/atoms.js +13 -50
  142. package/dist/react/hooks/useFreshness.d.ts +1 -4
  143. package/dist/react/hooks/useFreshness.js +1 -2
  144. package/dist/react/hooks/useMeasuredChartWidth.d.ts +2 -5
  145. package/dist/react/hooks/useMeasuredChartWidth.js +1 -2
  146. package/dist/react/hooks/usePolledJson.js +1 -2
  147. package/dist/react/hooks/useStation.d.ts +2 -5
  148. package/dist/react/hooks/useStation.js +1 -2
  149. package/dist/react/hooks/useStationClimatology.d.ts +2 -5
  150. package/dist/react/hooks/useStationClimatology.js +1 -2
  151. package/dist/react/hooks/useStationCurrent.d.ts +2 -5
  152. package/dist/react/hooks/useStationCurrent.js +4 -4
  153. package/dist/react/hooks/useStationFeed.d.ts +2 -5
  154. package/dist/react/hooks/useStationFeed.js +4 -4
  155. package/dist/react/hooks/useStationLive.d.ts +2 -5
  156. package/dist/react/hooks/useStationLive.js +1 -2
  157. package/dist/react/index.d.ts +2 -2
  158. package/dist/react/index.js +5 -5
  159. package/dist/react/lib/cells.js +5 -26
  160. package/dist/react/lib/use-pinned-cursor.js +1 -2
  161. package/dist/samples.d.ts +8 -11
  162. package/dist/samples.js +1 -2
  163. package/dist/scene/air-extremes.js +13 -29
  164. package/dist/scene/air-matrix.js +46 -60
  165. package/dist/scene/atoms.js +1 -2
  166. package/dist/scene/card.js +15 -42
  167. package/dist/scene/cells.d.ts +4 -0
  168. package/dist/scene/cells.js +50 -0
  169. package/dist/scene/chart.d.ts +2 -5
  170. package/dist/scene/chart.js +3 -3
  171. package/dist/scene/climatology-pattern.d.ts +1 -2
  172. package/dist/scene/climatology-pattern.js +11 -13
  173. package/dist/scene/climatology-rose.d.ts +1 -2
  174. package/dist/scene/climatology-rose.js +15 -35
  175. package/dist/scene/compass-fan.js +29 -102
  176. package/dist/scene/current.d.ts +2 -1
  177. package/dist/scene/current.js +30 -58
  178. package/dist/scene/daily-pattern.d.ts +1 -3
  179. package/dist/scene/daily-pattern.js +21 -29
  180. package/dist/scene/dial-parts.d.ts +1 -0
  181. package/dist/scene/dial-parts.js +69 -0
  182. package/dist/scene/dial.d.ts +1 -2
  183. package/dist/scene/dial.js +49 -138
  184. package/dist/scene/favorable-share.js +17 -35
  185. package/dist/scene/glyphs.js +21 -18
  186. package/dist/scene/index.d.ts +5 -3
  187. package/dist/scene/node.js +18 -0
  188. package/dist/scene/recent-summaries.js +27 -65
  189. package/dist/scene/rose.js +90 -119
  190. package/dist/scene/sample-strip.d.ts +1 -2
  191. package/dist/scene/sample-strip.js +36 -38
  192. package/dist/scene/sparkline.js +32 -42
  193. package/dist/scene/strip.js +19 -59
  194. package/dist/scene/table.js +48 -71
  195. package/dist/scene/trend.d.ts +1 -2
  196. package/dist/scene/trend.js +30 -57
  197. package/dist/scene/wind-history.d.ts +1 -2
  198. package/dist/scene/wind-history.js +42 -53
  199. package/dist/scene/wind-plot.js +71 -142
  200. package/dist/server/adapter.d.ts +7 -10
  201. package/dist/server/adapter.js +1 -2
  202. package/dist/server/adapters/campbell.d.ts +18 -20
  203. package/dist/server/adapters/campbell.js +2 -3
  204. package/dist/server/adapters/ecowitt.d.ts +12 -15
  205. package/dist/server/adapters/ecowitt.js +1 -2
  206. package/dist/server/adapters/tempest.d.ts +10 -13
  207. package/dist/server/adapters/tempest.js +1 -2
  208. package/dist/server/adapters/windnerd-climatology.d.ts +5 -8
  209. package/dist/server/adapters/windnerd-climatology.js +5 -5
  210. package/dist/server/adapters/windnerd-live.d.ts +2 -5
  211. package/dist/server/adapters/windnerd-live.js +4 -4
  212. package/dist/server/adapters/windnerd.d.ts +30 -33
  213. package/dist/server/adapters/windnerd.js +2 -3
  214. package/dist/server/config.d.ts +61 -63
  215. package/dist/server/config.js +1 -2
  216. package/dist/server/environment.d.ts +20 -22
  217. package/dist/server/environment.js +1 -2
  218. package/dist/server/feed.d.ts +19 -21
  219. package/dist/server/feed.js +1 -2
  220. package/dist/server/handler.d.ts +4 -7
  221. package/dist/server/handler.js +1 -2
  222. package/dist/server/hologram.d.ts +9 -12
  223. package/dist/server/hologram.js +3 -3
  224. package/dist/server/live.d.ts +2 -5
  225. package/dist/server/live.js +1 -2
  226. package/dist/sse.js +1 -2
  227. package/dist/strings.d.ts +8 -11
  228. package/dist/strings.js +1 -2
  229. package/dist/windnerd.d.ts +4 -7
  230. package/dist/windnerd.js +1 -2
  231. package/package.json +12 -17
  232. package/schema/README.md +1 -1
  233. package/schema/stationclimatology.schema.json +64 -61
  234. package/schema/stationcurrent.schema.json +68 -156
  235. package/schema/stationfeed.schema.json +71 -163
  236. package/schema/stationhistory.schema.json +37 -46
  237. package/schema/stationlive.schema.json +221 -306
@@ -2,10 +2,10 @@
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
- //#region src/react/components/Dial.tsx
8
+ // 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();
11
11
  const station = requireResolved("Dial", "station", stationProp ?? resolveStation(context, stationId));
@@ -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,6 @@ 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
- //#endregion
144
30
  export { Dial };
@@ -2,13 +2,10 @@ import { HistoryPoint, Station } from "../../contract.js";
2
2
  import { StationStringOverrides } from "../../strings.js";
3
3
  import { FavorableDirection } from "../../instruments.js";
4
4
  import "../../index.js";
5
- //#region src/react/components/FavorableShare.d.ts
6
- declare function FavorableShare({ station: stationProp, stationId, points, favorableDirections: favorableDirectionsProp, strings: stringsProp }: {
5
+ export declare function FavorableShare({ station: stationProp, stationId, points, favorableDirections: favorableDirectionsProp, strings: stringsProp }: {
7
6
  station?: Station;
8
7
  stationId?: string;
9
8
  points?: HistoryPoint[];
10
9
  favorableDirections?: FavorableDirection[] | null;
11
10
  strings?: StationStringOverrides;
12
- }): import("react").JSX.Element | null;
13
- //#endregion
14
- export { FavorableShare };
11
+ }): import("react").ReactNode;
@@ -1,9 +1,9 @@
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
- //#region src/react/components/FavorableShare.tsx
6
+ // src/react/components/FavorableShare.tsx
7
7
  function FavorableShare({ station: stationProp, stationId, points, favorableDirections: favorableDirectionsProp, strings: stringsProp }) {
8
8
  const context = useStationFeedContext();
9
9
  const station = stationProp ?? (points == null ? resolveStation(context, stationId) ?? void 0 : void 0);
@@ -11,33 +11,11 @@ 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
- //#endregion
43
21
  export { FavorableShare };
@@ -1,10 +1,7 @@
1
1
  import { FreshnessStatus } from "../../derive.js";
2
2
  import { StationStringOverrides } from "../../strings.js";
3
3
  import "../../index.js";
4
- //#region src/react/components/FreshnessBadge.d.ts
5
- declare function FreshnessBadge({ status, strings }: {
4
+ export declare function FreshnessBadge({ status, strings }: {
6
5
  status: FreshnessStatus;
7
6
  strings?: StationStringOverrides;
8
- }): import("react").JSX.Element;
9
- //#endregion
10
- export { FreshnessBadge };
7
+ }): import("react").ReactNode;
@@ -1,20 +1,12 @@
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
- //#region src/react/components/FreshnessBadge.tsx
6
+ // 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
- //#endregion
20
12
  export { FreshnessBadge };
@@ -1,12 +1,9 @@
1
1
  import { ReadoutPart } from "../../scene/chart.js";
2
2
  import "../../scene/index.js";
3
- //#region src/react/components/Readout.d.ts
4
- declare function Readout({ ariaLabel, ariaLive, className, strong, parts }: {
3
+ export declare function Readout({ ariaLabel, ariaLive, className, strong, parts }: {
5
4
  ariaLabel: string;
6
5
  ariaLive: "off" | "polite";
7
6
  className: string;
8
7
  strong: string;
9
8
  parts: ReadoutPart[];
10
- }): import("react").JSX.Element;
11
- //#endregion
12
- export { Readout };
9
+ }): import("react").JSX.Element;
@@ -1,7 +1,7 @@
1
1
  "use client";
2
2
  import { WindArrow } from "./WindArrow.js";
3
3
  import { jsx, jsxs } from "react/jsx-runtime";
4
- //#region src/react/components/Readout.tsx
4
+ // src/react/components/Readout.tsx
5
5
  function Readout({ ariaLabel, ariaLive, className, strong, parts }) {
6
6
  return /* @__PURE__ */ jsxs("output", {
7
7
  "aria-label": ariaLabel,
@@ -10,5 +10,4 @@ function Readout({ ariaLabel, ariaLive, className, strong, parts }) {
10
10
  children: [/* @__PURE__ */ jsx("strong", { children: strong }), /* @__PURE__ */ jsx("span", { children: parts.map((part, index) => part.kind === "arrow" ? /* @__PURE__ */ jsx(WindArrow, { deg: part.deg }, index) : part.text) })]
11
11
  });
12
12
  }
13
- //#endregion
14
13
  export { Readout };
@@ -3,16 +3,13 @@ import { SpeedUnit } from "../../derive.js";
3
3
  import { StationStringOverrides } from "../../strings.js";
4
4
  import { FavorableDirection } from "../../instruments.js";
5
5
  import "../../index.js";
6
- //#region src/react/components/RecentSummaries.d.ts
7
6
  /** The source's own step digests as summary panels: per window, the
8
7
  * average, gust, and lull beside one small arrow per step. */
9
- declare function RecentSummaries({ summaries, station: stationProp, stationId, favorableDirections: favorableDirectionsProp, unit: unitProp, strings: stringsProp }: {
8
+ export declare function RecentSummaries({ summaries, station: stationProp, stationId, favorableDirections: favorableDirectionsProp, unit: unitProp, strings: stringsProp }: {
10
9
  summaries?: RecentSummary[] | null;
11
10
  station?: Station;
12
11
  stationId?: string;
13
12
  favorableDirections?: FavorableDirection[] | null;
14
13
  unit?: SpeedUnit;
15
14
  strings?: StationStringOverrides;
16
- }): import("react").JSX.Element | null;
17
- //#endregion
18
- export { RecentSummaries };
15
+ }): import("react").ReactNode;
@@ -1,10 +1,9 @@
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
- //#region src/react/components/RecentSummaries.tsx
6
+ // 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. */
10
9
  function RecentSummaries({ summaries, station: stationProp, stationId, favorableDirections: favorableDirectionsProp, unit: unitProp, strings: stringsProp }) {
@@ -15,50 +14,12 @@ 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
- //#endregion
64
25
  export { RecentSummaries };
@@ -0,0 +1,37 @@
1
+ import { createElement } from "react";
2
+ // 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
+ export { renderChild, renderChildren, renderOptional, renderScene };
@@ -2,8 +2,7 @@ import { Station } from "../../contract.js";
2
2
  import { SpeedThresholds, SpeedUnit } from "../../derive.js";
3
3
  import { StationStringOverrides } from "../../strings.js";
4
4
  import "../../index.js";
5
- //#region src/react/components/Sparkline.d.ts
6
- declare function Sparkline({ station: stationProp, stationId, width, height, showBand, thresholds: thresholdsProp, strings: stringsProp }: {
5
+ export declare function Sparkline({ station: stationProp, stationId, width, height, showBand, thresholds: thresholdsProp, strings: stringsProp }: {
7
6
  station?: Station;
8
7
  stationId?: string;
9
8
  width?: number;
@@ -12,6 +11,4 @@ declare function Sparkline({ station: stationProp, stationId, width, height, sho
12
11
  thresholds?: SpeedThresholds | null;
13
12
  unit?: SpeedUnit;
14
13
  strings?: StationStringOverrides;
15
- }): import("react").JSX.Element;
16
- //#endregion
17
- export { Sparkline };
14
+ }): import("react").ReactNode;
@@ -1,9 +1,9 @@
1
1
  "use client";
2
2
  import { resolveDisplay } from "../../display.js";
3
3
  import { sparklineScene } from "../../scene/sparkline.js";
4
+ import { renderScene } from "./SceneTree.js";
4
5
  import { requireResolved, resolveStation, useStationFeedContext } from "./StationFeedProvider.js";
5
- import { jsx, jsxs } from "react/jsx-runtime";
6
- //#region src/react/components/Sparkline.tsx
6
+ // src/react/components/Sparkline.tsx
7
7
  function Sparkline({ station: stationProp, stationId, width = 120, height = 32, showBand = true, thresholds: thresholdsProp, strings: stringsProp }) {
8
8
  const context = useStationFeedContext();
9
9
  const station = requireResolved("Sparkline", "station", stationProp ?? resolveStation(context, stationId));
@@ -11,50 +11,13 @@ function Sparkline({ station: stationProp, stationId, width = 120, height = 32,
11
11
  strings: stringsProp,
12
12
  thresholds: thresholdsProp
13
13
  });
14
- const scene = sparklineScene({
14
+ return renderScene(sparklineScene({
15
15
  height,
16
16
  showBand,
17
17
  station,
18
18
  thresholds,
19
19
  width,
20
20
  words
21
- });
22
- if (scene.kind === "placeholder") return /* @__PURE__ */ jsx("span", {
23
- "aria-label": scene.ariaLabel,
24
- className: scene.className,
25
- role: "img",
26
- style: {
27
- height: scene.height,
28
- width: scene.width
29
- },
30
- children: scene.text
31
- });
32
- return /* @__PURE__ */ jsxs("svg", {
33
- "aria-label": scene.svg.ariaLabel,
34
- className: scene.svg.className,
35
- height: scene.svg.height,
36
- role: "img",
37
- viewBox: scene.svg.viewBox,
38
- width: scene.svg.width,
39
- children: [scene.bands.map((band) => /* @__PURE__ */ jsx("polygon", {
40
- className: band.className,
41
- points: band.points
42
- }, band.key)), scene.trace.map((part) => part.kind === "dot" ? /* @__PURE__ */ jsx("circle", {
43
- className: part.className,
44
- cx: part.cx,
45
- cy: part.cy,
46
- r: part.r
47
- }, part.key) : part.kind === "polyline" ? /* @__PURE__ */ jsx("polyline", {
48
- className: part.className,
49
- points: part.points
50
- }, part.key) : /* @__PURE__ */ jsx("line", {
51
- className: part.className,
52
- x1: part.x1,
53
- x2: part.x2,
54
- y1: part.y1,
55
- y2: part.y2
56
- }, part.key))]
57
- });
21
+ }));
58
22
  }
59
- //#endregion
60
23
  export { Sparkline };
@@ -3,7 +3,6 @@ import { SpeedThresholds, SpeedUnit } from "../../derive.js";
3
3
  import { FormatTime, StationStringOverrides } from "../../strings.js";
4
4
  import "../../index.js";
5
5
  import { ReactNode } from "react";
6
- //#region src/react/components/StationCard.d.ts
7
6
  declare function StationCardRoot({ station: stationProp, stationId, servedAt: servedAtProp, receivedAtMs: receivedAtMsProp, thresholds: thresholdsProp, unit: unitProp, strings: stringsProp, formatTime: formatTimeProp, children }: {
8
7
  station?: Station;
9
8
  stationId?: string;
@@ -15,32 +14,31 @@ declare function StationCardRoot({ station: stationProp, stationId, servedAt: se
15
14
  formatTime?: FormatTime;
16
15
  children?: ReactNode;
17
16
  }): import("react").JSX.Element;
18
- declare function StationCardHeader({ strings }?: {
17
+ export declare function StationCardHeader({ strings }?: {
19
18
  strings?: StationStringOverrides;
20
- }): import("react").JSX.Element;
21
- declare function StationCardInstrument({ thresholds, unit, strings, formatTime }?: {
19
+ }): ReactNode;
20
+ export declare function StationCardInstrument({ thresholds, unit, strings, formatTime }?: {
22
21
  thresholds?: SpeedThresholds | null;
23
22
  unit?: SpeedUnit;
24
23
  strings?: StationStringOverrides;
25
24
  formatTime?: FormatTime;
26
25
  }): import("react").JSX.Element;
27
- declare function StationCardChart({ thresholds, unit, plotHeight, strings, formatTime }?: {
26
+ export declare function StationCardChart({ thresholds, unit, plotHeight, strings, formatTime }?: {
28
27
  thresholds?: SpeedThresholds | null;
29
28
  unit?: SpeedUnit;
30
29
  plotHeight?: number;
31
30
  strings?: StationStringOverrides;
32
31
  formatTime?: FormatTime;
33
32
  }): import("react").JSX.Element;
34
- declare function StationCardSummary({ unit, strings, formatTime }?: {
33
+ export declare function StationCardSummary({ unit, strings, formatTime }?: {
35
34
  unit?: SpeedUnit;
36
35
  strings?: StationStringOverrides;
37
36
  formatTime?: FormatTime;
38
- }): import("react").JSX.Element | null;
39
- declare const StationCard: typeof StationCardRoot & {
37
+ }): ReactNode;
38
+ export declare const StationCard: typeof StationCardRoot & {
40
39
  Header: typeof StationCardHeader;
41
40
  Instrument: typeof StationCardInstrument;
42
41
  Chart: typeof StationCardChart;
43
42
  Summary: typeof StationCardSummary;
44
43
  };
45
- //#endregion
46
- export { StationCard, StationCardChart, StationCardHeader, StationCardInstrument, StationCardSummary };
44
+ export {};
@@ -2,15 +2,15 @@
2
2
  import { stationFreshnessThresholds } from "../../derive.js";
3
3
  import { mergeStringOverrides } from "../../strings.js";
4
4
  import { resolveDisplay } from "../../display.js";
5
- import { STATION_CARD_CLASS, cardHeaderScene, cardPartThresholds, cardPartWiringError, summaryScene } from "../../scene/card.js";
5
+ import { STATION_CARD_CLASS, cardHeaderNode, cardPartThresholds, cardPartWiringError, summaryNode } from "../../scene/card.js";
6
+ import { renderOptional, renderScene } from "./SceneTree.js";
6
7
  import { requireResolved, resolveStation, useStationFeedContext } from "./StationFeedProvider.js";
7
8
  import { useFreshness } from "../hooks/useFreshness.js";
8
- import { FreshnessBadge } from "./FreshnessBadge.js";
9
9
  import { CurrentConditions } from "./CurrentConditions.js";
10
10
  import { WindHistoryChart } from "./WindHistoryChart.js";
11
11
  import { createContext, useContext } from "react";
12
12
  import { Fragment, jsx, jsxs } from "react/jsx-runtime";
13
- //#region src/react/components/StationCard.tsx
13
+ // src/react/components/StationCard.tsx
14
14
  const StationCardContext = createContext(null);
15
15
  function useStationCardContext(subcomponent) {
16
16
  const context = useContext(StationCardContext);
@@ -53,37 +53,9 @@ function StationCardRoot({ station: stationProp, stationId, servedAt: servedAtPr
53
53
  function StationCardHeader({ strings } = {}) {
54
54
  const context = useStationCardContext("Header");
55
55
  const { station, servedAt, receivedAtMs } = context;
56
- const { strings: resolvedStrings, words } = resolveDisplay(context, { strings });
56
+ const { words } = resolveDisplay(context, { strings });
57
57
  const status = useFreshness(station.reading?.observedAt ?? null, servedAt, receivedAtMs, stationFreshnessThresholds(station));
58
- const scene = cardHeaderScene(station, words);
59
- const { name, meta } = scene.identity;
60
- return /* @__PURE__ */ jsxs("header", {
61
- className: scene.className,
62
- children: [/* @__PURE__ */ jsxs("div", {
63
- className: scene.identity.className,
64
- children: [/* @__PURE__ */ jsx("h3", {
65
- className: name.className,
66
- children: name.link ? /* @__PURE__ */ jsx("a", {
67
- href: name.link.href,
68
- rel: name.link.rel,
69
- target: name.link.target,
70
- children: name.link.text
71
- }) : name.text
72
- }), /* @__PURE__ */ jsxs("p", {
73
- className: meta.className,
74
- children: [/* @__PURE__ */ jsx("span", {
75
- className: meta.source.className,
76
- children: meta.source.text
77
- }), meta.elevation && /* @__PURE__ */ jsx("span", {
78
- className: meta.elevation.className,
79
- children: meta.elevation.text
80
- })]
81
- })]
82
- }), status != null && /* @__PURE__ */ jsx(FreshnessBadge, {
83
- status,
84
- strings: resolvedStrings
85
- })]
86
- });
58
+ return renderScene(cardHeaderNode(station, status, words));
87
59
  }
88
60
  function StationCardInstrument({ thresholds, unit, strings, formatTime } = {}) {
89
61
  const context = useStationCardContext("Instrument");
@@ -116,19 +88,7 @@ function StationCardSummary({ unit, strings, formatTime } = {}) {
116
88
  unit
117
89
  });
118
90
  const { station } = context;
119
- const summary = summaryScene(station, resolvedUnit, words, resolvedFormatTime);
120
- if (summary == null) return null;
121
- return /* @__PURE__ */ jsx("dl", {
122
- "aria-label": summary.ariaLabel,
123
- className: summary.className,
124
- children: summary.items.map((item) => /* @__PURE__ */ jsxs("div", {
125
- className: summary.itemClassName,
126
- children: [/* @__PURE__ */ jsx("dt", {
127
- className: summary.labelClassName,
128
- children: item.label
129
- }), /* @__PURE__ */ jsx("dd", { children: item.value })]
130
- }, item.label))
131
- });
91
+ return renderOptional(summaryNode(station, resolvedUnit, words, resolvedFormatTime));
132
92
  }
133
93
  const StationCard = Object.assign(StationCardRoot, {
134
94
  Header: StationCardHeader,
@@ -136,5 +96,4 @@ const StationCard = Object.assign(StationCardRoot, {
136
96
  Chart: StationCardChart,
137
97
  Summary: StationCardSummary
138
98
  });
139
- //#endregion
140
99
  export { StationCard, StationCardChart, StationCardHeader, StationCardInstrument, StationCardSummary };
@@ -4,8 +4,7 @@ import { FormatTime, StationStringOverrides } from "../../strings.js";
4
4
  import { FavorableDirection } from "../../instruments.js";
5
5
  import "../../index.js";
6
6
  import { ReactNode } from "react";
7
- //#region src/react/components/StationFeedProvider.d.ts
8
- type StationFeedContextValue = {
7
+ export type StationFeedContextValue = {
9
8
  feed: StationFeed | null;
10
9
  receivedAtMs: number | null;
11
10
  strings: StationStringOverrides | undefined;
@@ -14,7 +13,7 @@ type StationFeedContextValue = {
14
13
  thresholds: SpeedThresholds | undefined;
15
14
  favorableDirections: FavorableDirection[] | undefined;
16
15
  };
17
- declare function StationFeedProvider({ feed, receivedAtMs, strings, unit, formatTime, thresholds, favorableDirections, locale, children }: {
16
+ export declare function StationFeedProvider({ feed, receivedAtMs, strings, unit, formatTime, thresholds, favorableDirections, locale, children }: {
18
17
  feed: StationFeed | null;
19
18
  receivedAtMs: number | null;
20
19
  strings?: StationStringOverrides;
@@ -25,6 +24,4 @@ declare function StationFeedProvider({ feed, receivedAtMs, strings, unit, format
25
24
  locale?: string;
26
25
  children?: ReactNode;
27
26
  }): import("react").JSX.Element;
28
- declare function useStationFeedContext(): StationFeedContextValue | null;
29
- //#endregion
30
- export { StationFeedContextValue, StationFeedProvider, useStationFeedContext };
27
+ export declare function useStationFeedContext(): StationFeedContextValue | null;