@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,150 @@
1
+ "use client";
2
+ import { resolveDisplay } from "../../display.js";
3
+ import { activeChartIndex, chartIndexAtClient, measuredChartWidth, readoutAriaLive, togglePinnedAt } from "../../scene/chart.js";
4
+ import { TREND_CLASS, trendGate, trendScene } from "../../scene/trend.js";
5
+ import { requireResolved, resolveStation, useStationFeedContext } from "./StationFeedProvider.js";
6
+ import { useEffect, useRef, useState } from "react";
7
+ import { Fragment, jsx, jsxs } from "react/jsx-runtime";
8
+ //#region src/react/components/TrendChart.tsx
9
+ function TrendChart({ station: stationProp, stationId, series, strings: stringsProp, formatTime: formatTimeProp }) {
10
+ const context = useStationFeedContext();
11
+ const station = requireResolved("TrendChart", "station", stationProp ?? resolveStation(context, stationId));
12
+ const { formatTime, words } = resolveDisplay(context, {
13
+ formatTime: formatTimeProp,
14
+ strings: stringsProp
15
+ });
16
+ const wrapRef = useRef(null);
17
+ const [width, setWidth] = useState(null);
18
+ const gate = trendGate(station, series, words);
19
+ useEffect(() => {
20
+ const element = wrapRef.current;
21
+ if (!element) return;
22
+ if (typeof ResizeObserver === "undefined") {
23
+ setWidth(360);
24
+ return;
25
+ }
26
+ const observer = new ResizeObserver((entries) => {
27
+ setWidth(measuredChartWidth(entries[0]?.contentRect.width ?? 0));
28
+ });
29
+ observer.observe(element);
30
+ return () => observer.disconnect();
31
+ }, [gate.kind === "draw"]);
32
+ if (gate.kind === "hidden") return null;
33
+ if (gate.kind === "note") return /* @__PURE__ */ jsx("div", {
34
+ className: gate.className,
35
+ role: "note",
36
+ children: gate.text
37
+ });
38
+ return /* @__PURE__ */ jsx("div", {
39
+ className: TREND_CLASS,
40
+ ref: wrapRef,
41
+ children: width != null && /* @__PURE__ */ jsx(MeasuredTrend, {
42
+ formatTime,
43
+ history: gate.history,
44
+ series,
45
+ stationName: station.name,
46
+ width,
47
+ words
48
+ })
49
+ });
50
+ }
51
+ function MeasuredTrend({ formatTime, history, series, stationName, width, words }) {
52
+ const [pinnedAt, setPinnedAt] = useState(null);
53
+ const [previewIndex, setPreviewIndex] = useState(null);
54
+ const scene = trendScene({
55
+ formatTime,
56
+ history,
57
+ series,
58
+ stationName,
59
+ width,
60
+ words
61
+ });
62
+ const { readout, cursor } = scene.inspect(activeChartIndex(scene.points, pinnedAt, previewIndex));
63
+ const indexAtPoint = (clientX, hit) => {
64
+ const svg = hit.ownerSVGElement;
65
+ if (!svg) return null;
66
+ const bounds = svg.getBoundingClientRect();
67
+ return chartIndexAtClient(scene.points, scene.frame, scene.scales, clientX, bounds);
68
+ };
69
+ const handlePointerMove = (event) => {
70
+ if (event.pointerType === "touch") return;
71
+ setPreviewIndex(indexAtPoint(event.clientX, event.currentTarget));
72
+ };
73
+ const handleClick = (event) => {
74
+ const index = indexAtPoint(event.clientX, event.currentTarget);
75
+ if (index == null) return;
76
+ const observedAt = scene.points[index]?.observedAt;
77
+ if (observedAt == null) return;
78
+ setPinnedAt((current) => togglePinnedAt(current, observedAt));
79
+ setPreviewIndex(null);
80
+ };
81
+ return /* @__PURE__ */ jsxs(Fragment, { children: [/* @__PURE__ */ jsxs("output", {
82
+ "aria-label": scene.readout.ariaLabel,
83
+ "aria-live": readoutAriaLive(previewIndex),
84
+ className: scene.readout.className,
85
+ children: [/* @__PURE__ */ jsx("strong", { children: readout.strong }), /* @__PURE__ */ jsx("span", { children: readout.span })]
86
+ }), /* @__PURE__ */ jsxs("svg", {
87
+ "aria-label": scene.svg.ariaLabel,
88
+ className: scene.svg.className,
89
+ height: scene.svg.height,
90
+ role: "img",
91
+ viewBox: scene.svg.viewBox,
92
+ width: scene.svg.width,
93
+ children: [
94
+ scene.grid.map(({ key, line, label }) => /* @__PURE__ */ jsxs("g", { children: [/* @__PURE__ */ jsx("line", {
95
+ className: line.className,
96
+ x1: line.x1,
97
+ x2: line.x2,
98
+ y1: line.y1,
99
+ y2: line.y2
100
+ }), /* @__PURE__ */ jsx("text", {
101
+ className: label.className,
102
+ textAnchor: label.anchor,
103
+ x: label.x,
104
+ y: label.y,
105
+ children: label.text
106
+ })] }, key)),
107
+ scene.segments.map((segment) => segment.kind === "dot" ? /* @__PURE__ */ jsx("circle", {
108
+ className: segment.className,
109
+ cx: segment.cx,
110
+ cy: segment.cy,
111
+ r: segment.r
112
+ }, segment.startedAt) : /* @__PURE__ */ jsx("polyline", {
113
+ className: segment.className,
114
+ points: segment.points
115
+ }, segment.startedAt)),
116
+ scene.ticks.map((tick) => /* @__PURE__ */ jsx("text", {
117
+ className: tick.className,
118
+ textAnchor: tick.anchor,
119
+ x: tick.x,
120
+ y: tick.y,
121
+ children: tick.text
122
+ }, tick.key)),
123
+ cursor && /* @__PURE__ */ jsxs(Fragment, { children: [/* @__PURE__ */ jsx("line", {
124
+ className: cursor.line.className,
125
+ x1: cursor.line.x1,
126
+ x2: cursor.line.x2,
127
+ y1: cursor.line.y1,
128
+ y2: cursor.line.y2
129
+ }), cursor.dot && /* @__PURE__ */ jsx("circle", {
130
+ className: cursor.dot.className,
131
+ cx: cursor.dot.cx,
132
+ cy: cursor.dot.cy,
133
+ r: cursor.dot.r
134
+ })] }),
135
+ /* @__PURE__ */ jsx("rect", {
136
+ className: scene.hit.className,
137
+ fill: scene.hit.fill,
138
+ height: scene.hit.height,
139
+ onClick: handleClick,
140
+ onPointerLeave: () => setPreviewIndex(null),
141
+ onPointerMove: handlePointerMove,
142
+ width: scene.hit.width,
143
+ x: scene.hit.x,
144
+ y: scene.hit.y
145
+ })
146
+ ]
147
+ })] });
148
+ }
149
+ //#endregion
150
+ export { TrendChart };
@@ -0,0 +1,7 @@
1
+ //#region src/react/components/WindArrow.d.ts
2
+ declare function WindArrow({ deg, size }: {
3
+ deg: number;
4
+ size?: number;
5
+ }): import("react").JSX.Element;
6
+ //#endregion
7
+ export { WindArrow };
@@ -0,0 +1,21 @@
1
+ "use client";
2
+ import { windArrowSpec } from "../../scene/glyphs.js";
3
+ import { jsx } from "react/jsx-runtime";
4
+ //#region src/react/components/WindArrow.tsx
5
+ function WindArrow({ deg, size = 12 }) {
6
+ const spec = windArrowSpec(deg, size);
7
+ return /* @__PURE__ */ jsx("svg", {
8
+ "aria-hidden": "true",
9
+ className: spec.className,
10
+ height: spec.height,
11
+ style: { transform: spec.transform },
12
+ viewBox: spec.viewBox,
13
+ width: spec.width,
14
+ children: /* @__PURE__ */ jsx("path", {
15
+ d: spec.path.d,
16
+ fill: spec.path.fill
17
+ })
18
+ });
19
+ }
20
+ //#endregion
21
+ export { WindArrow };
@@ -0,0 +1,18 @@
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
+ //#region src/react/components/WindHistoryChart.d.ts
6
+ declare function WindHistoryChart({ station: stationProp, stationId, thresholds: thresholdsProp, unit: unitProp, plotHeight, windowHours, compareOffsetDays, strings: stringsProp, formatTime: formatTimeProp }: {
7
+ station?: Station;
8
+ stationId?: string;
9
+ thresholds?: SpeedThresholds | null;
10
+ unit?: SpeedUnit;
11
+ plotHeight?: number;
12
+ windowHours?: number;
13
+ compareOffsetDays?: 1 | 2 | 3;
14
+ strings?: StationStringOverrides;
15
+ formatTime?: FormatTime;
16
+ }): import("react").JSX.Element | null;
17
+ //#endregion
18
+ export { WindHistoryChart };
@@ -0,0 +1,278 @@
1
+ "use client";
2
+ import { resolveDisplay } from "../../display.js";
3
+ import { activeChartIndex, chartIndexAtClient, measuredChartWidth, readoutAriaLive, togglePinnedAt } from "../../scene/chart.js";
4
+ import { WIND_CHART_CLASS, windChartGate, windChartScene } from "../../scene/wind-history.js";
5
+ import { requireResolved, resolveStation, useStationFeedContext } from "./StationFeedProvider.js";
6
+ import { WindArrow } from "./WindArrow.js";
7
+ import { useEffect, useId, useRef, useState } from "react";
8
+ import { Fragment, jsx, jsxs } from "react/jsx-runtime";
9
+ //#region src/react/components/WindHistoryChart.tsx
10
+ function WindHistoryChart({ station: stationProp, stationId, thresholds: thresholdsProp, unit: unitProp, plotHeight, windowHours, compareOffsetDays, strings: stringsProp, formatTime: formatTimeProp }) {
11
+ const context = useStationFeedContext();
12
+ const station = requireResolved("WindHistoryChart", "station", stationProp ?? resolveStation(context, stationId));
13
+ const { formatTime, thresholds, unit, words } = resolveDisplay(context, {
14
+ formatTime: formatTimeProp,
15
+ strings: stringsProp,
16
+ thresholds: thresholdsProp,
17
+ unit: unitProp
18
+ });
19
+ const wrapRef = useRef(null);
20
+ const [width, setWidth] = useState(null);
21
+ const gate = windChartGate(station, words);
22
+ useEffect(() => {
23
+ const element = wrapRef.current;
24
+ if (!element) return;
25
+ if (typeof ResizeObserver === "undefined") {
26
+ setWidth(360);
27
+ return;
28
+ }
29
+ const observer = new ResizeObserver((entries) => {
30
+ setWidth(measuredChartWidth(entries[0]?.contentRect.width ?? 0));
31
+ });
32
+ observer.observe(element);
33
+ return () => observer.disconnect();
34
+ }, [gate.kind === "draw"]);
35
+ if (gate.kind === "hidden") return null;
36
+ if (gate.kind === "note") return /* @__PURE__ */ jsx("div", {
37
+ className: gate.className,
38
+ role: "note",
39
+ children: gate.text
40
+ });
41
+ return /* @__PURE__ */ jsx("div", {
42
+ className: WIND_CHART_CLASS,
43
+ ref: wrapRef,
44
+ children: width != null && /* @__PURE__ */ jsx(MeasuredChart, {
45
+ compareOffsetDays,
46
+ formatTime,
47
+ history: gate.history,
48
+ plotHeight,
49
+ stationName: station.name,
50
+ thresholds,
51
+ unit,
52
+ width,
53
+ windowHours,
54
+ words
55
+ })
56
+ });
57
+ }
58
+ function ReadoutSpan({ parts }) {
59
+ return /* @__PURE__ */ jsx("span", { children: parts.map((part, index) => part.kind === "arrow" ? /* @__PURE__ */ jsx(WindArrow, { deg: part.deg }, index) : part.text) });
60
+ }
61
+ function MeasuredChart({ compareOffsetDays, formatTime, history, plotHeight, stationName, thresholds, unit, width, windowHours, words }) {
62
+ const hatchId = `meteo-hatch-${useId().replace(/[^a-zA-Z0-9_-]/g, "")}`;
63
+ const [pinnedAt, setPinnedAt] = useState(null);
64
+ const [previewIndex, setPreviewIndex] = useState(null);
65
+ const scene = windChartScene({
66
+ compareOffsetDays,
67
+ formatTime,
68
+ hatchId,
69
+ history,
70
+ plotHeight,
71
+ stationName,
72
+ thresholds,
73
+ unit,
74
+ width,
75
+ windowHours,
76
+ words
77
+ });
78
+ const { readout, cursor } = scene.inspect(activeChartIndex(scene.points, pinnedAt, previewIndex));
79
+ const indexAtPoint = (clientX, hit) => {
80
+ const svg = hit.ownerSVGElement;
81
+ if (!svg) return null;
82
+ const bounds = svg.getBoundingClientRect();
83
+ return chartIndexAtClient(scene.points, scene.frame, scene.scales, clientX, bounds);
84
+ };
85
+ const handlePointerMove = (event) => {
86
+ if (event.pointerType === "touch") return;
87
+ setPreviewIndex(indexAtPoint(event.clientX, event.currentTarget));
88
+ };
89
+ const handleClick = (event) => {
90
+ const index = indexAtPoint(event.clientX, event.currentTarget);
91
+ if (index == null) return;
92
+ const observedAt = scene.points[index]?.observedAt;
93
+ if (observedAt == null) return;
94
+ setPinnedAt((current) => togglePinnedAt(current, observedAt));
95
+ setPreviewIndex(null);
96
+ };
97
+ return /* @__PURE__ */ jsxs(Fragment, { children: [/* @__PURE__ */ jsxs("output", {
98
+ "aria-label": scene.readout.ariaLabel,
99
+ "aria-live": readoutAriaLive(previewIndex),
100
+ className: scene.readout.className,
101
+ children: [/* @__PURE__ */ jsx("strong", { children: readout.strong }), /* @__PURE__ */ jsx(ReadoutSpan, { parts: readout.span })]
102
+ }), /* @__PURE__ */ jsxs("svg", {
103
+ "aria-label": scene.svg.ariaLabel,
104
+ className: scene.svg.className,
105
+ height: scene.svg.height,
106
+ role: "img",
107
+ viewBox: scene.svg.viewBox,
108
+ width: scene.svg.width,
109
+ children: [
110
+ /* @__PURE__ */ jsxs("defs", { children: [/* @__PURE__ */ jsx("pattern", {
111
+ height: scene.defs.pattern.height,
112
+ id: scene.defs.pattern.id,
113
+ patternTransform: scene.defs.pattern.transform,
114
+ patternUnits: scene.defs.pattern.units,
115
+ width: scene.defs.pattern.width,
116
+ children: /* @__PURE__ */ jsx("line", {
117
+ className: scene.defs.pattern.line.className,
118
+ x1: scene.defs.pattern.line.x1,
119
+ x2: scene.defs.pattern.line.x2,
120
+ y1: scene.defs.pattern.line.y1,
121
+ y2: scene.defs.pattern.line.y2
122
+ })
123
+ }), /* @__PURE__ */ jsx("clipPath", {
124
+ id: scene.defs.clip.id,
125
+ children: /* @__PURE__ */ jsx("rect", {
126
+ height: scene.defs.clip.rect.height,
127
+ width: scene.defs.clip.rect.width,
128
+ x: scene.defs.clip.rect.x,
129
+ y: scene.defs.clip.rect.y
130
+ })
131
+ })] }),
132
+ scene.zones.map((zone) => /* @__PURE__ */ jsx("rect", {
133
+ className: zone.className,
134
+ height: zone.height,
135
+ width: zone.width,
136
+ x: zone.x,
137
+ y: zone.y
138
+ }, zone.key)),
139
+ scene.grid.map(({ key, line, label }) => /* @__PURE__ */ jsxs("g", { children: [/* @__PURE__ */ jsx("line", {
140
+ className: line.className,
141
+ x1: line.x1,
142
+ x2: line.x2,
143
+ y1: line.y1,
144
+ y2: line.y2
145
+ }), /* @__PURE__ */ jsx("text", {
146
+ className: label.className,
147
+ textAnchor: label.anchor,
148
+ x: label.x,
149
+ y: label.y,
150
+ children: label.text
151
+ })] }, key)),
152
+ scene.thresholdGuides.map(({ key, line, label }) => /* @__PURE__ */ jsxs("g", { children: [/* @__PURE__ */ jsx("line", {
153
+ className: line.className,
154
+ x1: line.x1,
155
+ x2: line.x2,
156
+ y1: line.y1,
157
+ y2: line.y2
158
+ }), /* @__PURE__ */ jsx("text", {
159
+ className: label.className,
160
+ textAnchor: label.anchor,
161
+ x: label.x,
162
+ y: label.y,
163
+ children: label.text
164
+ })] }, key)),
165
+ scene.vaneGuides.map((guide) => /* @__PURE__ */ jsx("line", {
166
+ className: guide.className,
167
+ x1: guide.x1,
168
+ x2: guide.x2,
169
+ y1: guide.y1,
170
+ y2: guide.y2
171
+ }, `guide-${guide.key}`)),
172
+ scene.gaps.map((gap) => /* @__PURE__ */ jsx("rect", {
173
+ className: gap.className,
174
+ fill: gap.fill,
175
+ height: gap.height,
176
+ width: gap.width,
177
+ x: gap.x,
178
+ y: gap.y
179
+ }, gap.key)),
180
+ scene.band && /* @__PURE__ */ jsx("polygon", {
181
+ className: scene.band.className,
182
+ points: scene.band.points
183
+ }),
184
+ scene.compare && /* @__PURE__ */ jsx("polyline", {
185
+ className: scene.compare.className,
186
+ clipPath: scene.compare.clipPath,
187
+ points: scene.compare.points
188
+ }),
189
+ scene.mean.kind === "polyline" ? /* @__PURE__ */ jsx("polyline", {
190
+ className: scene.mean.className,
191
+ points: scene.mean.points
192
+ }) : scene.mean.segments.map((segment) => /* @__PURE__ */ jsx("line", {
193
+ className: segment.className,
194
+ x1: segment.x1,
195
+ x2: segment.x2,
196
+ y1: segment.y1,
197
+ y2: segment.y2
198
+ }, segment.key)),
199
+ scene.calmNote && /* @__PURE__ */ jsx("text", {
200
+ className: scene.calmNote.className,
201
+ textAnchor: scene.calmNote.anchor,
202
+ x: scene.calmNote.x,
203
+ y: scene.calmNote.y,
204
+ children: scene.calmNote.text
205
+ }),
206
+ /* @__PURE__ */ jsx("text", {
207
+ className: scene.rowLabels.to.className,
208
+ textAnchor: scene.rowLabels.to.anchor,
209
+ x: scene.rowLabels.to.x,
210
+ y: scene.rowLabels.to.y,
211
+ children: scene.rowLabels.to.text
212
+ }),
213
+ scene.vanes.map((vane) => vane.mark.kind === "calm" ? /* @__PURE__ */ jsx("text", {
214
+ className: vane.mark.text.className,
215
+ textAnchor: vane.mark.text.anchor,
216
+ x: vane.mark.text.x,
217
+ y: vane.mark.text.y,
218
+ children: vane.mark.text.text
219
+ }, vane.key) : /* @__PURE__ */ jsx("path", {
220
+ className: vane.mark.className,
221
+ d: vane.mark.d
222
+ }, vane.key)),
223
+ scene.vanes.map((vane) => /* @__PURE__ */ jsx("text", {
224
+ className: vane.label.className,
225
+ textAnchor: vane.label.anchor,
226
+ x: vane.label.x,
227
+ y: vane.label.y,
228
+ children: vane.label.text
229
+ }, `label-${vane.key}`)),
230
+ /* @__PURE__ */ jsx("text", {
231
+ className: scene.rowLabels.avg.className,
232
+ textAnchor: scene.rowLabels.avg.anchor,
233
+ x: scene.rowLabels.avg.x,
234
+ y: scene.rowLabels.avg.y,
235
+ children: scene.rowLabels.avg.text
236
+ }),
237
+ scene.vanes.map((vane) => /* @__PURE__ */ jsx("text", {
238
+ className: vane.value.className,
239
+ textAnchor: vane.value.anchor,
240
+ x: vane.value.x,
241
+ y: vane.value.y,
242
+ children: vane.value.text
243
+ }, `value-${vane.key}`)),
244
+ scene.ticks.map((tick) => /* @__PURE__ */ jsx("text", {
245
+ className: tick.className,
246
+ textAnchor: tick.anchor,
247
+ x: tick.x,
248
+ y: tick.y,
249
+ children: tick.text
250
+ }, tick.key)),
251
+ cursor && /* @__PURE__ */ jsxs(Fragment, { children: [/* @__PURE__ */ jsx("line", {
252
+ className: cursor.line.className,
253
+ x1: cursor.line.x1,
254
+ x2: cursor.line.x2,
255
+ y1: cursor.line.y1,
256
+ y2: cursor.line.y2
257
+ }), /* @__PURE__ */ jsx("circle", {
258
+ className: cursor.dot.className,
259
+ cx: cursor.dot.cx,
260
+ cy: cursor.dot.cy,
261
+ r: cursor.dot.r
262
+ })] }),
263
+ /* @__PURE__ */ jsx("rect", {
264
+ className: scene.hit.className,
265
+ fill: scene.hit.fill,
266
+ height: scene.hit.height,
267
+ onClick: handleClick,
268
+ onPointerLeave: () => setPreviewIndex(null),
269
+ onPointerMove: handlePointerMove,
270
+ width: scene.hit.width,
271
+ x: scene.hit.x,
272
+ y: scene.hit.y
273
+ })
274
+ ]
275
+ })] });
276
+ }
277
+ //#endregion
278
+ export { WindHistoryChart };
@@ -0,0 +1,17 @@
1
+ import { HistoryPoint, Station } from "../../contract.js";
2
+ import { SpeedThresholds } from "../../derive.js";
3
+ import { StationStringOverrides } from "../../strings.js";
4
+ import { FavorableDirection } from "../../instruments.js";
5
+ import "../../index.js";
6
+ //#region src/react/components/WindRose.d.ts
7
+ declare function WindRose({ station: stationProp, stationId, points, sectorCount, thresholds: thresholdsProp, favorableDirections, strings: stringsProp }: {
8
+ station?: Station;
9
+ stationId?: string;
10
+ points?: HistoryPoint[];
11
+ sectorCount?: number;
12
+ thresholds?: SpeedThresholds | null;
13
+ favorableDirections?: FavorableDirection[];
14
+ strings?: StationStringOverrides;
15
+ }): import("react").JSX.Element;
16
+ //#endregion
17
+ export { WindRose };
@@ -0,0 +1,99 @@
1
+ "use client";
2
+ import { resolveDisplay } from "../../display.js";
3
+ import { windRoseGate, windRoseScene, windRoseSource } from "../../scene/rose.js";
4
+ import { resolveStation, useStationFeedContext } from "./StationFeedProvider.js";
5
+ import { Fragment, jsx, jsxs } from "react/jsx-runtime";
6
+ //#region src/react/components/WindRose.tsx
7
+ function WindRose({ station: stationProp, stationId, points, sectorCount = 16, thresholds: thresholdsProp, favorableDirections, strings: stringsProp }) {
8
+ const context = useStationFeedContext();
9
+ const station = stationProp ?? (points == null ? resolveStation(context, stationId) ?? void 0 : void 0);
10
+ const { thresholds, words } = resolveDisplay(context, {
11
+ strings: stringsProp,
12
+ thresholds: thresholdsProp
13
+ });
14
+ const source = windRoseSource(points, station);
15
+ const gate = windRoseGate(source, words);
16
+ if (gate.kind === "note") return /* @__PURE__ */ jsx("div", {
17
+ className: gate.className,
18
+ role: "note",
19
+ children: gate.text
20
+ });
21
+ const scene = windRoseScene({
22
+ favorableDirections,
23
+ sectorCount,
24
+ source,
25
+ stationName: station?.name,
26
+ thresholds,
27
+ words
28
+ });
29
+ return /* @__PURE__ */ jsxs("div", {
30
+ className: scene.className,
31
+ children: [/* @__PURE__ */ jsxs("svg", {
32
+ "aria-label": scene.svg.ariaLabel,
33
+ className: scene.svg.className,
34
+ height: scene.svg.height,
35
+ role: "img",
36
+ viewBox: scene.svg.viewBox,
37
+ width: scene.svg.width,
38
+ children: [
39
+ scene.gridCircles.map((circle) => /* @__PURE__ */ jsx("circle", {
40
+ className: circle.className,
41
+ cx: circle.cx,
42
+ cy: circle.cy,
43
+ r: circle.r
44
+ }, circle.key)),
45
+ scene.ring && /* @__PURE__ */ jsxs(Fragment, { children: [/* @__PURE__ */ jsx("circle", {
46
+ className: scene.ring.unfavorable.className,
47
+ cx: scene.ring.unfavorable.cx,
48
+ cy: scene.ring.unfavorable.cy,
49
+ r: scene.ring.unfavorable.r
50
+ }), scene.ring.favorable.map((arc) => /* @__PURE__ */ jsx("path", {
51
+ className: arc.className,
52
+ d: arc.d
53
+ }, arc.key))] }),
54
+ scene.ticks.map((tick) => /* @__PURE__ */ jsx("line", {
55
+ className: tick.className,
56
+ x1: tick.x1,
57
+ x2: tick.x2,
58
+ y1: tick.y1,
59
+ y2: tick.y2
60
+ }, tick.key)),
61
+ scene.letters.map((letter) => /* @__PURE__ */ jsx("text", {
62
+ className: letter.className,
63
+ textAnchor: letter.anchor,
64
+ x: letter.x,
65
+ y: letter.y,
66
+ children: letter.text
67
+ }, letter.key)),
68
+ scene.petals.map((petal) => /* @__PURE__ */ jsx("path", {
69
+ className: petal.className,
70
+ d: petal.d
71
+ }, petal.key)),
72
+ scene.ringLabel && /* @__PURE__ */ jsx("text", {
73
+ className: scene.ringLabel.className,
74
+ textAnchor: scene.ringLabel.anchor,
75
+ x: scene.ringLabel.x,
76
+ y: scene.ringLabel.y,
77
+ children: scene.ringLabel.text
78
+ }),
79
+ /* @__PURE__ */ jsx("circle", {
80
+ className: scene.hub.className,
81
+ cx: scene.hub.cx,
82
+ cy: scene.hub.cy,
83
+ r: scene.hub.r
84
+ }),
85
+ /* @__PURE__ */ jsx("circle", {
86
+ className: scene.dot.className,
87
+ cx: scene.dot.cx,
88
+ cy: scene.dot.cy,
89
+ r: scene.dot.r
90
+ })
91
+ ]
92
+ }), scene.calmCaption && /* @__PURE__ */ jsx("p", {
93
+ className: scene.calmCaption.className,
94
+ children: scene.calmCaption.text
95
+ })]
96
+ });
97
+ }
98
+ //#endregion
99
+ export { WindRose };
@@ -0,0 +1,33 @@
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
+ //#region src/react/components/atoms.d.ts
6
+ type AtomProps = {
7
+ station?: Station;
8
+ stationId?: string;
9
+ strings?: StationStringOverrides;
10
+ };
11
+ type SpeedAtomProps = AtomProps & {
12
+ unit?: SpeedUnit;
13
+ };
14
+ declare function Speed(props: SpeedAtomProps): import("react").JSX.Element;
15
+ declare function Gust(props: SpeedAtomProps): import("react").JSX.Element;
16
+ declare function Lull(props: SpeedAtomProps): import("react").JSX.Element;
17
+ declare function Temperature({ station: stationProp, stationId, strings: stringsProp }: AtomProps): import("react").JSX.Element;
18
+ declare function Pressure({ station: stationProp, stationId, strings: stringsProp }: AtomProps): import("react").JSX.Element;
19
+ declare function Direction({ station: stationProp, stationId, strings: stringsProp }: AtomProps): import("react").JSX.Element;
20
+ declare function UpdatedAt({ station: stationProp, stationId, servedAt: servedAtProp, receivedAtMs: receivedAtMsProp, strings: stringsProp, formatTime: formatTimeProp }: {
21
+ station?: Station;
22
+ stationId?: string;
23
+ servedAt?: string | null;
24
+ receivedAtMs?: number | null;
25
+ strings?: StationStringOverrides;
26
+ formatTime?: FormatTime;
27
+ }): import("react").JSX.Element;
28
+ declare function BandChip({ station: stationProp, stationId, thresholds: thresholdsProp, labels, unit: unitProp, strings: stringsProp }: SpeedAtomProps & {
29
+ thresholds?: SpeedThresholds | null;
30
+ labels?: readonly string[];
31
+ }): import("react").JSX.Element;
32
+ //#endregion
33
+ export { BandChip, Direction, Gust, Lull, Pressure, Speed, Temperature, UpdatedAt };