@azohra/meteo.station 0.1.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 (160) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +53 -0
  3. package/dist/air.d.ts +13 -0
  4. package/dist/air.js +76 -0
  5. package/dist/client/index.d.ts +4 -0
  6. package/dist/client/index.js +4 -0
  7. package/dist/client/poll.d.ts +42 -0
  8. package/dist/client/poll.js +121 -0
  9. package/dist/client/stores.d.ts +46 -0
  10. package/dist/client/stores.js +128 -0
  11. package/dist/client/ticker.d.ts +4 -0
  12. package/dist/client/ticker.js +19 -0
  13. package/dist/contract.d.ts +381 -0
  14. package/dist/contract.js +143 -0
  15. package/dist/derive.d.ts +54 -0
  16. package/dist/derive.js +134 -0
  17. package/dist/display.d.ts +28 -0
  18. package/dist/display.js +27 -0
  19. package/dist/elements/elements/AirMatrixElement.d.ts +14 -0
  20. package/dist/elements/elements/AirMatrixElement.js +83 -0
  21. package/dist/elements/elements/CurrentConditionsElement.d.ts +9 -0
  22. package/dist/elements/elements/CurrentConditionsElement.js +52 -0
  23. package/dist/elements/elements/DailyPatternElement.d.ts +15 -0
  24. package/dist/elements/elements/DailyPatternElement.js +200 -0
  25. package/dist/elements/elements/DialElement.d.ts +9 -0
  26. package/dist/elements/elements/DialElement.js +128 -0
  27. package/dist/elements/elements/FreshnessBadgeElement.d.ts +8 -0
  28. package/dist/elements/elements/FreshnessBadgeElement.js +22 -0
  29. package/dist/elements/elements/SparklineElement.d.ts +9 -0
  30. package/dist/elements/elements/SparklineElement.js +74 -0
  31. package/dist/elements/elements/StationCardElement.d.ts +53 -0
  32. package/dist/elements/elements/StationCardElement.js +211 -0
  33. package/dist/elements/elements/StationFeedElement.d.ts +32 -0
  34. package/dist/elements/elements/StationFeedElement.js +215 -0
  35. package/dist/elements/elements/StationStripElement.d.ts +9 -0
  36. package/dist/elements/elements/StationStripElement.js +43 -0
  37. package/dist/elements/elements/StationTableElement.d.ts +18 -0
  38. package/dist/elements/elements/StationTableElement.js +102 -0
  39. package/dist/elements/elements/TrendChartElement.d.ts +10 -0
  40. package/dist/elements/elements/TrendChartElement.js +174 -0
  41. package/dist/elements/elements/WindArrowElement.d.ts +8 -0
  42. package/dist/elements/elements/WindArrowElement.js +14 -0
  43. package/dist/elements/elements/WindHistoryChartElement.d.ts +10 -0
  44. package/dist/elements/elements/WindHistoryChartElement.js +277 -0
  45. package/dist/elements/elements/WindRoseElement.d.ts +17 -0
  46. package/dist/elements/elements/WindRoseElement.js +106 -0
  47. package/dist/elements/elements/atoms.d.ts +48 -0
  48. package/dist/elements/elements/atoms.js +131 -0
  49. package/dist/elements/index.d.ts +48 -0
  50. package/dist/elements/index.js +57 -0
  51. package/dist/elements/lib/ambient.d.ts +15 -0
  52. package/dist/elements/lib/ambient.js +5 -0
  53. package/dist/elements/lib/attributes.js +21 -0
  54. package/dist/elements/lib/base.d.ts +45 -0
  55. package/dist/elements/lib/base.js +152 -0
  56. package/dist/elements/lib/context.js +28 -0
  57. package/dist/elements/lib/fragments.js +45 -0
  58. package/dist/elements/lib/h.js +35 -0
  59. package/dist/elements/register.d.ts +1 -0
  60. package/dist/elements/register.js +5 -0
  61. package/dist/endpoints.d.ts +5 -0
  62. package/dist/endpoints.js +10 -0
  63. package/dist/fixtures.d.ts +23 -0
  64. package/dist/fixtures.js +67 -0
  65. package/dist/format.d.ts +31 -0
  66. package/dist/format.js +82 -0
  67. package/dist/geometry.d.ts +84 -0
  68. package/dist/geometry.js +333 -0
  69. package/dist/index.d.ts +12 -0
  70. package/dist/index.js +12 -0
  71. package/dist/instruments.d.ts +75 -0
  72. package/dist/instruments.js +173 -0
  73. package/dist/merge-current.d.ts +13 -0
  74. package/dist/merge-current.js +54 -0
  75. package/dist/react/components/AirMatrix.d.ts +11 -0
  76. package/dist/react/components/AirMatrix.js +82 -0
  77. package/dist/react/components/CurrentConditions.d.ts +17 -0
  78. package/dist/react/components/CurrentConditions.js +98 -0
  79. package/dist/react/components/DailyPattern.d.ts +19 -0
  80. package/dist/react/components/DailyPattern.js +212 -0
  81. package/dist/react/components/Dial.d.ts +17 -0
  82. package/dist/react/components/Dial.js +133 -0
  83. package/dist/react/components/FreshnessBadge.d.ts +10 -0
  84. package/dist/react/components/FreshnessBadge.js +20 -0
  85. package/dist/react/components/Sparkline.d.ts +17 -0
  86. package/dist/react/components/Sparkline.js +60 -0
  87. package/dist/react/components/StationCard.d.ts +46 -0
  88. package/dist/react/components/StationCard.js +140 -0
  89. package/dist/react/components/StationFeedProvider.d.ts +27 -0
  90. package/dist/react/components/StationFeedProvider.js +40 -0
  91. package/dist/react/components/StationStrip.d.ts +16 -0
  92. package/dist/react/components/StationStrip.js +84 -0
  93. package/dist/react/components/StationTable.d.ts +18 -0
  94. package/dist/react/components/StationTable.js +115 -0
  95. package/dist/react/components/TrendChart.d.ts +14 -0
  96. package/dist/react/components/TrendChart.js +150 -0
  97. package/dist/react/components/WindArrow.d.ts +7 -0
  98. package/dist/react/components/WindArrow.js +21 -0
  99. package/dist/react/components/WindHistoryChart.d.ts +18 -0
  100. package/dist/react/components/WindHistoryChart.js +278 -0
  101. package/dist/react/components/WindRose.d.ts +17 -0
  102. package/dist/react/components/WindRose.js +99 -0
  103. package/dist/react/components/atoms.d.ts +33 -0
  104. package/dist/react/components/atoms.js +136 -0
  105. package/dist/react/hooks/useFreshness.d.ts +6 -0
  106. package/dist/react/hooks/useFreshness.js +21 -0
  107. package/dist/react/hooks/usePolledJson.js +17 -0
  108. package/dist/react/hooks/useStation.d.ts +23 -0
  109. package/dist/react/hooks/useStation.js +42 -0
  110. package/dist/react/hooks/useStationCurrent.d.ts +23 -0
  111. package/dist/react/hooks/useStationCurrent.js +32 -0
  112. package/dist/react/hooks/useStationFeed.d.ts +22 -0
  113. package/dist/react/hooks/useStationFeed.js +28 -0
  114. package/dist/react/index.d.ts +20 -0
  115. package/dist/react/index.js +21 -0
  116. package/dist/react/lib/cells.js +29 -0
  117. package/dist/scene/air-matrix.js +71 -0
  118. package/dist/scene/atoms.js +102 -0
  119. package/dist/scene/card.js +54 -0
  120. package/dist/scene/chart.js +28 -0
  121. package/dist/scene/current.js +66 -0
  122. package/dist/scene/daily-pattern.js +81 -0
  123. package/dist/scene/dial.js +141 -0
  124. package/dist/scene/glyphs.js +24 -0
  125. package/dist/scene/rose.js +120 -0
  126. package/dist/scene/sparkline.js +73 -0
  127. package/dist/scene/strip.js +63 -0
  128. package/dist/scene/table.js +76 -0
  129. package/dist/scene/trend.js +160 -0
  130. package/dist/scene/wind-history.js +148 -0
  131. package/dist/scene/wind-plot.js +214 -0
  132. package/dist/server/adapter.d.ts +28 -0
  133. package/dist/server/adapter.js +32 -0
  134. package/dist/server/adapters/campbell.d.ts +112 -0
  135. package/dist/server/adapters/campbell.js +414 -0
  136. package/dist/server/adapters/tempest.d.ts +27 -0
  137. package/dist/server/adapters/tempest.js +137 -0
  138. package/dist/server/adapters/windnerd.d.ts +39 -0
  139. package/dist/server/adapters/windnerd.js +159 -0
  140. package/dist/server/config.d.ts +135 -0
  141. package/dist/server/config.js +57 -0
  142. package/dist/server/environment.d.ts +48 -0
  143. package/dist/server/environment.js +128 -0
  144. package/dist/server/feed.d.ts +31 -0
  145. package/dist/server/feed.js +216 -0
  146. package/dist/server/handler.d.ts +17 -0
  147. package/dist/server/handler.js +133 -0
  148. package/dist/server/index.d.ts +10 -0
  149. package/dist/server/index.js +10 -0
  150. package/dist/strings.d.ts +118 -0
  151. package/dist/strings.js +237 -0
  152. package/dist/windnerd.d.ts +5 -0
  153. package/dist/windnerd.js +25 -0
  154. package/package.json +97 -0
  155. package/schema/README.md +14 -0
  156. package/schema/example-current.json +48 -0
  157. package/schema/example-feed.json +147 -0
  158. package/schema/stationcurrent.schema.json +641 -0
  159. package/schema/stationfeed.schema.json +656 -0
  160. package/styles.css +1141 -0
@@ -0,0 +1,60 @@
1
+ "use client";
2
+ import { resolveDisplay } from "../../display.js";
3
+ import { sparklineScene } from "../../scene/sparkline.js";
4
+ import { requireResolved, resolveStation, useStationFeedContext } from "./StationFeedProvider.js";
5
+ import { jsx, jsxs } from "react/jsx-runtime";
6
+ //#region src/react/components/Sparkline.tsx
7
+ function Sparkline({ station: stationProp, stationId, width = 120, height = 32, showBand = true, thresholds: thresholdsProp, strings: stringsProp }) {
8
+ const context = useStationFeedContext();
9
+ const station = requireResolved("Sparkline", "station", stationProp ?? resolveStation(context, stationId));
10
+ const { thresholds, words } = resolveDisplay(context, {
11
+ strings: stringsProp,
12
+ thresholds: thresholdsProp
13
+ });
14
+ const scene = sparklineScene({
15
+ height,
16
+ showBand,
17
+ station,
18
+ thresholds,
19
+ width,
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
+ });
58
+ }
59
+ //#endregion
60
+ export { Sparkline };
@@ -0,0 +1,46 @@
1
+ import { Station } from "../../contract.js";
2
+ import { SpeedThresholds, SpeedUnit } from "../../derive.js";
3
+ import { FormatTime, StationStringOverrides } from "../../strings.js";
4
+ import "../../index.js";
5
+ import { ReactNode } from "react";
6
+ //#region src/react/components/StationCard.d.ts
7
+ declare function StationCardRoot({ station: stationProp, stationId, servedAt: servedAtProp, receivedAtMs: receivedAtMsProp, thresholds: thresholdsProp, unit: unitProp, strings: stringsProp, formatTime: formatTimeProp, children }: {
8
+ station?: Station;
9
+ stationId?: string;
10
+ servedAt?: string;
11
+ receivedAtMs?: number | null;
12
+ thresholds?: SpeedThresholds | null;
13
+ unit?: SpeedUnit;
14
+ strings?: StationStringOverrides;
15
+ formatTime?: FormatTime;
16
+ children?: ReactNode;
17
+ }): import("react").JSX.Element;
18
+ declare function StationCardHeader({ strings }?: {
19
+ strings?: StationStringOverrides;
20
+ }): import("react").JSX.Element;
21
+ declare function StationCardInstrument({ thresholds, unit, strings, formatTime }?: {
22
+ thresholds?: SpeedThresholds | null;
23
+ unit?: SpeedUnit;
24
+ strings?: StationStringOverrides;
25
+ formatTime?: FormatTime;
26
+ }): import("react").JSX.Element;
27
+ declare function StationCardChart({ thresholds, unit, plotHeight, strings, formatTime }?: {
28
+ thresholds?: SpeedThresholds | null;
29
+ unit?: SpeedUnit;
30
+ plotHeight?: number;
31
+ strings?: StationStringOverrides;
32
+ formatTime?: FormatTime;
33
+ }): import("react").JSX.Element;
34
+ declare function StationCardSummary({ unit, strings, formatTime }?: {
35
+ unit?: SpeedUnit;
36
+ strings?: StationStringOverrides;
37
+ formatTime?: FormatTime;
38
+ }): import("react").JSX.Element | null;
39
+ declare const StationCard: typeof StationCardRoot & {
40
+ Header: typeof StationCardHeader;
41
+ Instrument: typeof StationCardInstrument;
42
+ Chart: typeof StationCardChart;
43
+ Summary: typeof StationCardSummary;
44
+ };
45
+ //#endregion
46
+ export { StationCard, StationCardChart, StationCardHeader, StationCardInstrument, StationCardSummary };
@@ -0,0 +1,140 @@
1
+ "use client";
2
+ import { stationFreshnessThresholds } from "../../derive.js";
3
+ import { mergeStringOverrides } from "../../strings.js";
4
+ import { resolveDisplay } from "../../display.js";
5
+ import { STATION_CARD_CLASS, cardHeaderScene, cardPartThresholds, cardPartWiringError, summaryScene } from "../../scene/card.js";
6
+ import { requireResolved, resolveStation, useStationFeedContext } from "./StationFeedProvider.js";
7
+ import { useFreshness } from "../hooks/useFreshness.js";
8
+ import { FreshnessBadge } from "./FreshnessBadge.js";
9
+ import { CurrentConditions } from "./CurrentConditions.js";
10
+ import { WindHistoryChart } from "./WindHistoryChart.js";
11
+ import { createContext, useContext } from "react";
12
+ import { Fragment, jsx, jsxs } from "react/jsx-runtime";
13
+ //#region src/react/components/StationCard.tsx
14
+ const StationCardContext = createContext(null);
15
+ function useStationCardContext(subcomponent) {
16
+ const context = useContext(StationCardContext);
17
+ if (context == null) throw new Error(cardPartWiringError(`<StationCard.${subcomponent}>`, "<StationCard>"));
18
+ return context;
19
+ }
20
+ function StationCardRoot({ station: stationProp, stationId, servedAt: servedAtProp, receivedAtMs: receivedAtMsProp, thresholds: thresholdsProp, unit: unitProp, strings: stringsProp, formatTime: formatTimeProp, children }) {
21
+ const ambient = useStationFeedContext();
22
+ const station = requireResolved("StationCard", "station", stationProp ?? resolveStation(ambient, stationId));
23
+ const servedAt = servedAtProp ?? ambient?.feed?.servedAt ?? null;
24
+ const receivedAtMs = receivedAtMsProp !== void 0 ? receivedAtMsProp : ambient?.receivedAtMs ?? null;
25
+ const { formatTime, strings, thresholds, unit } = resolveDisplay(ambient, {
26
+ formatTime: formatTimeProp,
27
+ strings: stringsProp,
28
+ thresholds: thresholdsProp,
29
+ unit: unitProp
30
+ });
31
+ return /* @__PURE__ */ jsx(StationCardContext.Provider, {
32
+ value: {
33
+ station,
34
+ servedAt,
35
+ receivedAtMs,
36
+ thresholds,
37
+ unit,
38
+ strings,
39
+ formatTime
40
+ },
41
+ children: /* @__PURE__ */ jsx("article", {
42
+ className: STATION_CARD_CLASS,
43
+ "data-status": station.status,
44
+ children: children === void 0 ? /* @__PURE__ */ jsxs(Fragment, { children: [
45
+ /* @__PURE__ */ jsx(StationCardHeader, {}),
46
+ /* @__PURE__ */ jsx(StationCardInstrument, {}),
47
+ /* @__PURE__ */ jsx(StationCardChart, {}),
48
+ /* @__PURE__ */ jsx(StationCardSummary, {})
49
+ ] }) : children
50
+ })
51
+ });
52
+ }
53
+ function StationCardHeader({ strings } = {}) {
54
+ const context = useStationCardContext("Header");
55
+ const { station, servedAt, receivedAtMs } = context;
56
+ const { strings: resolvedStrings, words } = resolveDisplay(context, { strings });
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
+ });
87
+ }
88
+ function StationCardInstrument({ thresholds, unit, strings, formatTime } = {}) {
89
+ const context = useStationCardContext("Instrument");
90
+ return /* @__PURE__ */ jsx(CurrentConditions, {
91
+ formatTime: formatTime ?? context.formatTime,
92
+ receivedAtMs: context.receivedAtMs,
93
+ servedAt: context.servedAt,
94
+ station: context.station,
95
+ strings: mergeStringOverrides(context.strings, strings),
96
+ thresholds: cardPartThresholds(thresholds, context.thresholds),
97
+ unit: unit ?? context.unit
98
+ });
99
+ }
100
+ function StationCardChart({ thresholds, unit, plotHeight, strings, formatTime } = {}) {
101
+ const context = useStationCardContext("Chart");
102
+ return /* @__PURE__ */ jsx(WindHistoryChart, {
103
+ formatTime: formatTime ?? context.formatTime,
104
+ plotHeight,
105
+ station: context.station,
106
+ strings: mergeStringOverrides(context.strings, strings),
107
+ thresholds: cardPartThresholds(thresholds, context.thresholds),
108
+ unit: unit ?? context.unit
109
+ });
110
+ }
111
+ function StationCardSummary({ unit, strings, formatTime } = {}) {
112
+ const context = useStationCardContext("Summary");
113
+ const { formatTime: resolvedFormatTime, unit: resolvedUnit, words } = resolveDisplay(context, {
114
+ formatTime,
115
+ strings,
116
+ unit
117
+ });
118
+ 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
+ });
132
+ }
133
+ const StationCard = Object.assign(StationCardRoot, {
134
+ Header: StationCardHeader,
135
+ Instrument: StationCardInstrument,
136
+ Chart: StationCardChart,
137
+ Summary: StationCardSummary
138
+ });
139
+ //#endregion
140
+ export { StationCard, StationCardChart, StationCardHeader, StationCardInstrument, StationCardSummary };
@@ -0,0 +1,27 @@
1
+ import { StationFeed } from "../../contract.js";
2
+ import { SpeedThresholds, SpeedUnit } from "../../derive.js";
3
+ import { FormatTime, StationStringOverrides } from "../../strings.js";
4
+ import "../../index.js";
5
+ import { ReactNode } from "react";
6
+ //#region src/react/components/StationFeedProvider.d.ts
7
+ type StationFeedContextValue = {
8
+ feed: StationFeed | null;
9
+ receivedAtMs: number | null;
10
+ strings: StationStringOverrides | undefined;
11
+ unit: SpeedUnit | undefined;
12
+ formatTime: FormatTime | undefined;
13
+ thresholds: SpeedThresholds | undefined;
14
+ };
15
+ declare function StationFeedProvider({ feed, receivedAtMs, strings, unit, formatTime, thresholds, locale, children }: {
16
+ feed: StationFeed | null;
17
+ receivedAtMs: number | null;
18
+ strings?: StationStringOverrides;
19
+ unit?: SpeedUnit;
20
+ formatTime?: FormatTime;
21
+ thresholds?: SpeedThresholds;
22
+ locale?: string;
23
+ children?: ReactNode;
24
+ }): import("react").JSX.Element;
25
+ declare function useStationFeedContext(): StationFeedContextValue | null;
26
+ //#endregion
27
+ export { StationFeedContextValue, StationFeedProvider, useStationFeedContext };
@@ -0,0 +1,40 @@
1
+ "use client";
2
+ import { localeFormatTime } from "../../strings.js";
3
+ import { requireResolved as requireResolved$1, resolveStation as resolveStation$1 } from "../../display.js";
4
+ import { createContext, useContext, useMemo } from "react";
5
+ import { jsx } from "react/jsx-runtime";
6
+ //#region src/react/components/StationFeedProvider.tsx
7
+ const StationFeedContext = createContext(null);
8
+ function StationFeedProvider({ feed, receivedAtMs, strings, unit, formatTime, thresholds, locale, children }) {
9
+ const resolvedFormatTime = formatTime ?? (locale == null ? void 0 : localeFormatTime(locale));
10
+ const value = useMemo(() => ({
11
+ feed,
12
+ receivedAtMs,
13
+ strings,
14
+ unit,
15
+ formatTime: resolvedFormatTime,
16
+ thresholds
17
+ }), [
18
+ feed,
19
+ receivedAtMs,
20
+ strings,
21
+ unit,
22
+ resolvedFormatTime,
23
+ thresholds
24
+ ]);
25
+ return /* @__PURE__ */ jsx(StationFeedContext.Provider, {
26
+ value,
27
+ children
28
+ });
29
+ }
30
+ function useStationFeedContext() {
31
+ return useContext(StationFeedContext);
32
+ }
33
+ function resolveStation(context, stationId) {
34
+ return resolveStation$1(context?.feed ?? null, stationId);
35
+ }
36
+ function requireResolved(component, what, value) {
37
+ return requireResolved$1(component, what, value, "render inside <StationFeedProvider> with a feed");
38
+ }
39
+ //#endregion
40
+ export { StationFeedProvider, requireResolved, resolveStation, useStationFeedContext };
@@ -0,0 +1,16 @@
1
+ import { Station } from "../../contract.js";
2
+ import { SpeedUnit } from "../../derive.js";
3
+ import { FormatTime, StationStringOverrides } from "../../strings.js";
4
+ import "../../index.js";
5
+ //#region src/react/components/StationStrip.d.ts
6
+ declare function StationStrip({ station: stationProp, stationId, servedAt: servedAtProp, receivedAtMs: receivedAtMsProp, unit: unitProp, strings: stringsProp, formatTime: formatTimeProp }: {
7
+ station?: Station;
8
+ stationId?: string;
9
+ servedAt?: string | null;
10
+ receivedAtMs?: number | null;
11
+ unit?: SpeedUnit;
12
+ strings?: StationStringOverrides;
13
+ formatTime?: FormatTime;
14
+ }): import("react").JSX.Element;
15
+ //#endregion
16
+ export { StationStrip };
@@ -0,0 +1,84 @@
1
+ "use client";
2
+ import { stationFreshnessThresholds } from "../../derive.js";
3
+ import { resolveDisplay } from "../../display.js";
4
+ import { stationStripScene } from "../../scene/strip.js";
5
+ import { requireResolved, resolveStation, useStationFeedContext } from "./StationFeedProvider.js";
6
+ import { DirectionCell, StationNameLink } from "../lib/cells.js";
7
+ import { useFreshness } from "../hooks/useFreshness.js";
8
+ import { FreshnessBadge } from "./FreshnessBadge.js";
9
+ import { Fragment, jsx, jsxs } from "react/jsx-runtime";
10
+ //#region src/react/components/StationStrip.tsx
11
+ function StationStrip({ station: stationProp, stationId, servedAt: servedAtProp, receivedAtMs: receivedAtMsProp, unit: unitProp, strings: stringsProp, formatTime: formatTimeProp }) {
12
+ const context = useStationFeedContext();
13
+ const station = requireResolved("StationStrip", "station", stationProp ?? resolveStation(context, stationId));
14
+ const servedAt = servedAtProp ?? context?.feed?.servedAt ?? null;
15
+ const receivedAtMs = receivedAtMsProp !== void 0 ? receivedAtMsProp : context?.receivedAtMs ?? null;
16
+ const { formatTime, strings, unit, words } = resolveDisplay(context, {
17
+ formatTime: formatTimeProp,
18
+ strings: stringsProp,
19
+ unit: unitProp
20
+ });
21
+ const status = useFreshness(station.reading?.observedAt ?? null, servedAt, receivedAtMs, stationFreshnessThresholds(station));
22
+ const scene = stationStripScene({
23
+ formatTime,
24
+ station,
25
+ unit,
26
+ words
27
+ });
28
+ const { body } = scene;
29
+ return /* @__PURE__ */ jsxs("div", {
30
+ "aria-label": scene.root.ariaLabel,
31
+ className: scene.root.className,
32
+ "data-status": scene.root.status,
33
+ role: "group",
34
+ children: [/* @__PURE__ */ jsx("span", {
35
+ className: scene.stationClassName,
36
+ children: /* @__PURE__ */ jsx(StationNameLink, { station })
37
+ }), body.kind === "reading" ? /* @__PURE__ */ jsxs(Fragment, { children: [
38
+ /* @__PURE__ */ jsxs("span", {
39
+ className: body.wind.className,
40
+ children: [/* @__PURE__ */ jsx("strong", { children: body.wind.value }), /* @__PURE__ */ jsx("small", { children: body.wind.unitLabel })]
41
+ }),
42
+ body.gustLull && /* @__PURE__ */ jsxs(Fragment, { children: [/* @__PURE__ */ jsxs("span", {
43
+ className: body.gustLull.lull.className,
44
+ children: [/* @__PURE__ */ jsx("small", {
45
+ className: body.gustLull.lull.labelClassName,
46
+ children: body.gustLull.lull.label
47
+ }), body.gustLull.lull.value]
48
+ }), /* @__PURE__ */ jsxs("span", {
49
+ className: body.gustLull.gust.className,
50
+ children: [/* @__PURE__ */ jsx("small", {
51
+ className: body.gustLull.gust.labelClassName,
52
+ children: body.gustLull.gust.label
53
+ }), body.gustLull.gust.value]
54
+ })] }),
55
+ /* @__PURE__ */ jsx("span", {
56
+ className: body.from.className,
57
+ children: /* @__PURE__ */ jsx(DirectionCell, {
58
+ windAvgMps: body.from.windAvgMps,
59
+ windDirectionDeg: body.from.windDirectionDeg,
60
+ words
61
+ })
62
+ }),
63
+ body.temperature && /* @__PURE__ */ jsx("span", {
64
+ className: body.temperature.className,
65
+ children: body.temperature.text
66
+ }),
67
+ /* @__PURE__ */ jsxs("span", {
68
+ className: body.updated.className,
69
+ children: [/* @__PURE__ */ jsx("span", {
70
+ className: body.updated.time.className,
71
+ children: body.updated.time.text
72
+ }), status != null && /* @__PURE__ */ jsx(FreshnessBadge, {
73
+ status,
74
+ strings
75
+ })]
76
+ })
77
+ ] }) : /* @__PURE__ */ jsx("span", {
78
+ className: body.className,
79
+ children: body.text
80
+ })]
81
+ });
82
+ }
83
+ //#endregion
84
+ export { StationStrip };
@@ -0,0 +1,18 @@
1
+ import { Station } from "../../contract.js";
2
+ import { SpeedUnit } from "../../derive.js";
3
+ import { FormatTime, StationStringOverrides } from "../../strings.js";
4
+ import "../../index.js";
5
+ import { ReactNode } from "react";
6
+ //#region src/react/components/StationTable.d.ts
7
+ type StationMetaRenderer = (station: Station) => ReactNode;
8
+ declare function StationTable({ stations: stationsProp, servedAt: servedAtProp, receivedAtMs: receivedAtMsProp, unit: unitProp, strings: stringsProp, formatTime: formatTimeProp, stationMeta }: {
9
+ stations?: readonly Station[];
10
+ servedAt?: string;
11
+ receivedAtMs?: number | null;
12
+ unit?: SpeedUnit;
13
+ strings?: StationStringOverrides;
14
+ formatTime?: FormatTime;
15
+ stationMeta?: StationMetaRenderer;
16
+ }): import("react").JSX.Element;
17
+ //#endregion
18
+ export { StationMetaRenderer, StationTable };
@@ -0,0 +1,115 @@
1
+ "use client";
2
+ import { stationFreshnessThresholds } from "../../derive.js";
3
+ import { resolveDisplay } from "../../display.js";
4
+ import { stationTableRowScene, stationTableScene } from "../../scene/table.js";
5
+ import { requireResolved, useStationFeedContext } from "./StationFeedProvider.js";
6
+ import { DirectionCell, StationNameLink } from "../lib/cells.js";
7
+ import { useFreshness } from "../hooks/useFreshness.js";
8
+ import { FreshnessBadge } from "./FreshnessBadge.js";
9
+ import { Fragment, jsx, jsxs } from "react/jsx-runtime";
10
+ //#region src/react/components/StationTable.tsx
11
+ function StationTable({ stations: stationsProp, servedAt: servedAtProp, receivedAtMs: receivedAtMsProp, unit: unitProp, strings: stringsProp, formatTime: formatTimeProp, stationMeta }) {
12
+ const context = useStationFeedContext();
13
+ const stations = requireResolved("StationTable", "stations", stationsProp ?? context?.feed?.stations);
14
+ const servedAt = servedAtProp ?? context?.feed?.servedAt ?? null;
15
+ const receivedAtMs = receivedAtMsProp !== void 0 ? receivedAtMsProp : context?.receivedAtMs ?? null;
16
+ const { formatTime, strings, unit, words } = resolveDisplay(context, {
17
+ formatTime: formatTimeProp,
18
+ strings: stringsProp,
19
+ unit: unitProp
20
+ });
21
+ const scene = stationTableScene(stations, words);
22
+ return /* @__PURE__ */ jsxs("div", {
23
+ "aria-label": scene.root.ariaLabel,
24
+ className: scene.root.className,
25
+ role: "table",
26
+ children: [/* @__PURE__ */ jsx("div", {
27
+ className: scene.head.className,
28
+ role: "row",
29
+ children: scene.head.columns.map((column) => /* @__PURE__ */ jsx("span", {
30
+ role: "columnheader",
31
+ children: column
32
+ }, column))
33
+ }), /* @__PURE__ */ jsx("div", {
34
+ className: scene.bodyClassName,
35
+ role: "rowgroup",
36
+ children: stations.map((station) => /* @__PURE__ */ jsx(TableRow, {
37
+ formatTime,
38
+ receivedAtMs,
39
+ servedAt,
40
+ station,
41
+ stationMeta,
42
+ strings,
43
+ unit,
44
+ words
45
+ }, station.id))
46
+ })]
47
+ });
48
+ }
49
+ function TableRow({ formatTime, receivedAtMs, servedAt, station, stationMeta, strings, unit, words }) {
50
+ const status = useFreshness(station.reading?.observedAt ?? null, servedAt, receivedAtMs, stationFreshnessThresholds(station));
51
+ const row = stationTableRowScene({
52
+ formatTime,
53
+ station,
54
+ unit,
55
+ words
56
+ });
57
+ const { cells } = row;
58
+ return /* @__PURE__ */ jsxs("div", {
59
+ className: row.className,
60
+ "data-status": row.status,
61
+ role: "row",
62
+ children: [/* @__PURE__ */ jsxs("span", {
63
+ className: row.stationCellClassName,
64
+ role: "cell",
65
+ children: [/* @__PURE__ */ jsx("strong", { children: /* @__PURE__ */ jsx(StationNameLink, { station }) }), /* @__PURE__ */ jsx("small", { children: stationMeta ? stationMeta(station) : station.sourceLabel })]
66
+ }), cells.kind === "reading" ? /* @__PURE__ */ jsxs(Fragment, { children: [
67
+ /* @__PURE__ */ jsxs("span", {
68
+ className: cells.wind.className,
69
+ role: "cell",
70
+ children: [/* @__PURE__ */ jsx("strong", { children: cells.wind.value }), /* @__PURE__ */ jsx("small", { children: cells.wind.unitLabel })]
71
+ }),
72
+ /* @__PURE__ */ jsx("span", {
73
+ className: cells.lull.className,
74
+ role: "cell",
75
+ children: cells.lull.value
76
+ }),
77
+ /* @__PURE__ */ jsx("span", {
78
+ className: cells.gust.className,
79
+ role: "cell",
80
+ children: cells.gust.value
81
+ }),
82
+ /* @__PURE__ */ jsx("span", {
83
+ className: cells.from.className,
84
+ role: "cell",
85
+ children: /* @__PURE__ */ jsx(DirectionCell, {
86
+ windAvgMps: cells.from.windAvgMps,
87
+ windDirectionDeg: cells.from.windDirectionDeg,
88
+ words
89
+ })
90
+ }),
91
+ /* @__PURE__ */ jsx("span", {
92
+ className: cells.temperature.className,
93
+ role: "cell",
94
+ children: cells.temperature.value
95
+ }),
96
+ /* @__PURE__ */ jsxs("span", {
97
+ className: cells.updated.className,
98
+ role: "cell",
99
+ children: [/* @__PURE__ */ jsx("span", {
100
+ className: cells.updated.time.className,
101
+ children: cells.updated.time.text
102
+ }), status != null && /* @__PURE__ */ jsx(FreshnessBadge, {
103
+ status,
104
+ strings
105
+ })]
106
+ })
107
+ ] }) : /* @__PURE__ */ jsx("span", {
108
+ className: cells.className,
109
+ role: "cell",
110
+ children: cells.text
111
+ })]
112
+ });
113
+ }
114
+ //#endregion
115
+ export { StationTable };
@@ -0,0 +1,14 @@
1
+ import { Station } from "../../contract.js";
2
+ import { FormatTime, StationStringOverrides } from "../../strings.js";
3
+ import { TrendSeries } from "../../geometry.js";
4
+ import "../../index.js";
5
+ //#region src/react/components/TrendChart.d.ts
6
+ declare function TrendChart({ station: stationProp, stationId, series, strings: stringsProp, formatTime: formatTimeProp }: {
7
+ station?: Station;
8
+ stationId?: string;
9
+ series: TrendSeries;
10
+ strings?: StationStringOverrides;
11
+ formatTime?: FormatTime;
12
+ }): import("react").JSX.Element | null;
13
+ //#endregion
14
+ export { TrendChart };