@azohra/meteo.station 0.5.0 → 0.7.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +17 -17
- package/dist/client/climatology.js +1 -1
- package/dist/client/history.js +3 -11
- package/dist/client/live.d.ts +2 -1
- package/dist/client/live.js +7 -4
- package/dist/client/stores.js +10 -2
- package/dist/climatology.d.ts +1 -1
- package/dist/climatology.js +1 -1
- package/dist/connectivity.d.ts +2 -2
- package/dist/contract.d.ts +98 -98
- package/dist/derive.js +9 -8
- package/dist/elements/elements/AirExtremesElement.js +5 -18
- package/dist/elements/elements/AirMatrixElement.js +6 -31
- package/dist/elements/elements/ClimatologyDailyPatternElement.js +17 -12
- package/dist/elements/elements/ClimatologyRoseElement.js +5 -15
- package/dist/elements/elements/CompassFanElement.js +5 -64
- package/dist/elements/elements/CurrentConditionsElement.js +7 -26
- package/dist/elements/elements/DailyPatternElement.d.ts +0 -1
- package/dist/elements/elements/DailyPatternElement.js +6 -120
- package/dist/elements/elements/DialElement.js +3 -95
- package/dist/elements/elements/FavorableShareElement.js +6 -21
- package/dist/elements/elements/RecentSummariesElement.js +6 -23
- package/dist/elements/elements/SparklineElement.d.ts +0 -1
- package/dist/elements/elements/SparklineElement.js +4 -39
- package/dist/elements/elements/StationCardElement.js +4 -18
- package/dist/elements/elements/StationFeedElement.js +4 -2
- package/dist/elements/elements/StationStripElement.js +4 -18
- package/dist/elements/elements/StationTableElement.js +15 -51
- package/dist/elements/elements/TrendChartElement.js +27 -94
- package/dist/elements/elements/WindHistoryChartElement.js +29 -189
- package/dist/elements/elements/WindRoseElement.d.ts +0 -1
- package/dist/elements/elements/WindRoseElement.js +6 -70
- package/dist/elements/elements/atoms.js +11 -38
- package/dist/elements/index.js +3 -3
- package/dist/elements/lib/fragments.js +8 -37
- package/dist/elements/lib/h.js +1 -1
- package/dist/elements/lib/pinned-cursor.js +48 -0
- package/dist/elements/lib/render.js +30 -0
- package/dist/fixtures.d.ts +6 -2
- package/dist/fixtures.js +30 -2
- package/dist/format.js +7 -3
- package/dist/geometry.d.ts +1 -1
- package/dist/geometry.js +22 -9
- package/dist/instruments.js +2 -2
- package/dist/react/components/AirExtremes.d.ts +1 -1
- package/dist/react/components/AirExtremes.js +5 -22
- package/dist/react/components/AirMatrix.js +10 -43
- package/dist/react/components/ClimatologyDailyPattern.d.ts +1 -1
- package/dist/react/components/ClimatologyDailyPattern.js +19 -13
- package/dist/react/components/ClimatologyRose.d.ts +1 -1
- package/dist/react/components/ClimatologyRose.js +11 -28
- package/dist/react/components/CompassFan.d.ts +1 -1
- package/dist/react/components/CompassFan.js +6 -73
- package/dist/react/components/CurrentConditions.d.ts +1 -1
- package/dist/react/components/CurrentConditions.js +11 -74
- package/dist/react/components/DailyPattern.d.ts +1 -3
- package/dist/react/components/DailyPattern.js +10 -149
- package/dist/react/components/Dial.d.ts +2 -3
- package/dist/react/components/Dial.js +5 -118
- package/dist/react/components/FavorableShare.d.ts +1 -1
- package/dist/react/components/FavorableShare.js +6 -27
- package/dist/react/components/FreshnessBadge.d.ts +1 -1
- package/dist/react/components/FreshnessBadge.js +5 -12
- package/dist/react/components/RecentSummaries.d.ts +1 -1
- package/dist/react/components/RecentSummaries.js +6 -44
- package/dist/react/components/SceneTree.js +38 -0
- package/dist/react/components/Sparkline.d.ts +1 -1
- package/dist/react/components/Sparkline.js +3 -39
- package/dist/react/components/StationCard.d.ts +2 -2
- package/dist/react/components/StationCard.js +5 -45
- package/dist/react/components/StationStrip.d.ts +1 -1
- package/dist/react/components/StationStrip.js +5 -60
- package/dist/react/components/StationTable.js +21 -75
- package/dist/react/components/TrendChart.js +13 -86
- package/dist/react/components/WindArrow.d.ts +1 -1
- package/dist/react/components/WindArrow.js +3 -15
- package/dist/react/components/WindHistoryChart.js +12 -205
- package/dist/react/components/WindRose.d.ts +1 -3
- package/dist/react/components/WindRose.js +6 -89
- package/dist/react/components/WindSampleStrip.js +14 -139
- package/dist/react/components/atoms.d.ts +5 -5
- package/dist/react/components/atoms.js +12 -48
- package/dist/react/hooks/useStation.js +28 -50
- package/dist/react/hooks/useStationCurrent.js +3 -2
- package/dist/react/hooks/useStationFeed.d.ts +0 -1
- package/dist/react/hooks/useStationFeed.js +3 -2
- package/dist/react/index.d.ts +2 -2
- package/dist/react/index.js +7 -7
- package/dist/react/lib/cells.js +4 -24
- package/dist/react/lib/use-pinned-cursor.js +32 -0
- package/dist/samples.js +7 -43
- package/dist/scene/air-extremes.js +12 -27
- package/dist/scene/air-matrix.js +45 -58
- package/dist/scene/card.js +14 -40
- package/dist/scene/cells.d.ts +4 -0
- package/dist/scene/cells.js +51 -0
- package/dist/scene/chart.js +2 -1
- package/dist/scene/climatology-pattern.d.ts +1 -2
- package/dist/scene/climatology-pattern.js +10 -11
- package/dist/scene/climatology-rose.d.ts +1 -2
- package/dist/scene/climatology-rose.js +14 -33
- package/dist/scene/compass-fan.js +28 -100
- package/dist/scene/current.d.ts +2 -1
- package/dist/scene/current.js +29 -56
- package/dist/scene/daily-pattern.d.ts +1 -3
- package/dist/scene/daily-pattern.js +20 -27
- package/dist/scene/dial-parts.d.ts +1 -0
- package/dist/scene/dial-parts.js +70 -0
- package/dist/scene/dial.d.ts +1 -2
- package/dist/scene/dial.js +48 -136
- package/dist/scene/favorable-share.js +16 -33
- package/dist/scene/glyphs.js +20 -16
- package/dist/scene/index.d.ts +5 -3
- package/dist/scene/node.js +19 -0
- package/dist/scene/recent-summaries.js +26 -66
- package/dist/scene/rose.js +89 -117
- package/dist/scene/sample-strip.d.ts +1 -2
- package/dist/scene/sample-strip.js +35 -36
- package/dist/scene/sparkline.js +31 -40
- package/dist/scene/strip.js +18 -57
- package/dist/scene/table.js +47 -69
- package/dist/scene/trend.d.ts +1 -2
- package/dist/scene/trend.js +29 -55
- package/dist/scene/wind-history.d.ts +1 -2
- package/dist/scene/wind-history.js +41 -51
- package/dist/scene/wind-plot.js +70 -140
- package/dist/server/adapters/campbell.d.ts +7 -7
- package/dist/server/adapters/campbell.js +1 -1
- package/dist/server/adapters/ecowitt.d.ts +8 -8
- package/dist/server/adapters/tempest.d.ts +6 -6
- package/dist/server/adapters/windnerd-climatology.js +4 -3
- package/dist/server/adapters/windnerd-live.js +3 -2
- package/dist/server/adapters/windnerd.d.ts +10 -11
- package/dist/server/adapters/windnerd.js +3 -13
- package/dist/server/config.d.ts +48 -48
- package/dist/server/hologram.js +2 -1
- package/dist/server/index.d.ts +2 -2
- package/dist/server/index.js +2 -2
- package/dist/windnerd.d.ts +3 -1
- package/dist/windnerd.js +11 -1
- package/package.json +7 -12
- package/schema/README.md +3 -3
- package/schema/stationclimatology.schema.json +64 -61
- package/schema/stationcurrent.schema.json +68 -156
- package/schema/stationfeed.schema.json +71 -163
- package/schema/stationhistory.schema.json +37 -46
- package/schema/stationlive.schema.json +221 -306
|
@@ -1,15 +1,18 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
import { resolveDisplay } from "../../display.js";
|
|
3
|
-
import {
|
|
3
|
+
import { readoutAriaLive } from "../../scene/chart.js";
|
|
4
4
|
import { SAMPLE_STRIP_CLASS, sampleStripGate, sampleStripScene } from "../../scene/sample-strip.js";
|
|
5
|
+
import { renderScene } from "./SceneTree.js";
|
|
5
6
|
import { useStationFeedContext } from "./StationFeedProvider.js";
|
|
7
|
+
import { usePinnedCursor } from "../lib/use-pinned-cursor.js";
|
|
6
8
|
import { Readout } from "./Readout.js";
|
|
7
9
|
import { useMeasuredChartWidth } from "../hooks/useMeasuredChartWidth.js";
|
|
8
|
-
import { useRef
|
|
10
|
+
import { useRef } from "react";
|
|
9
11
|
import { Fragment, jsx, jsxs } from "react/jsx-runtime";
|
|
10
12
|
//#region src/react/components/WindSampleStrip.tsx
|
|
11
13
|
function WindSampleStrip({ samples, stationName, unit: unitProp, favorableDirections: favorableDirectionsProp, plotHeight, strings: stringsProp, formatTime: formatTimeProp }) {
|
|
12
|
-
const
|
|
14
|
+
const context = useStationFeedContext();
|
|
15
|
+
const { favorableDirections, formatTime, unit, words } = resolveDisplay(context, {
|
|
13
16
|
formatTime: formatTimeProp,
|
|
14
17
|
strings: stringsProp,
|
|
15
18
|
favorableDirections: favorableDirectionsProp,
|
|
@@ -39,8 +42,6 @@ function WindSampleStrip({ samples, stationName, unit: unitProp, favorableDirect
|
|
|
39
42
|
});
|
|
40
43
|
}
|
|
41
44
|
function MeasuredStrip({ favorableDirections, formatTime, plotHeight, samples, stationName, unit, width, words }) {
|
|
42
|
-
const [pinnedAt, setPinnedAt] = useState(null);
|
|
43
|
-
const [previewIndex, setPreviewIndex] = useState(null);
|
|
44
45
|
const scene = sampleStripScene({
|
|
45
46
|
favorableDirections,
|
|
46
47
|
formatTime,
|
|
@@ -51,145 +52,19 @@ function MeasuredStrip({ favorableDirections, formatTime, plotHeight, samples, s
|
|
|
51
52
|
width,
|
|
52
53
|
words
|
|
53
54
|
});
|
|
54
|
-
const
|
|
55
|
-
const
|
|
56
|
-
const svg = hit.ownerSVGElement;
|
|
57
|
-
if (!svg) return null;
|
|
58
|
-
const bounds = svg.getBoundingClientRect();
|
|
59
|
-
return chartIndexAtClient(scene.points, scene.frame, scene.scales, clientX, bounds);
|
|
60
|
-
};
|
|
61
|
-
const handlePointerMove = (event) => {
|
|
62
|
-
if (event.pointerType === "touch") return;
|
|
63
|
-
setPreviewIndex(indexAtPoint(event.clientX, event.currentTarget));
|
|
64
|
-
};
|
|
65
|
-
const handleClick = (event) => {
|
|
66
|
-
const index = indexAtPoint(event.clientX, event.currentTarget);
|
|
67
|
-
if (index == null) return;
|
|
68
|
-
const observedAt = scene.points[index]?.observedAt;
|
|
69
|
-
if (observedAt == null) return;
|
|
70
|
-
setPinnedAt((current) => togglePinnedAt(current, observedAt));
|
|
71
|
-
setPreviewIndex(null);
|
|
72
|
-
};
|
|
55
|
+
const pinned = usePinnedCursor(scene);
|
|
56
|
+
const { readout, cursor } = scene.inspect(pinned.activeIndex);
|
|
73
57
|
return /* @__PURE__ */ jsxs(Fragment, { children: [/* @__PURE__ */ jsx(Readout, {
|
|
74
58
|
ariaLabel: scene.readout.ariaLabel,
|
|
75
|
-
ariaLive: readoutAriaLive(previewIndex),
|
|
59
|
+
ariaLive: readoutAriaLive(pinned.previewIndex),
|
|
76
60
|
className: scene.readout.className,
|
|
77
61
|
parts: readout.span,
|
|
78
62
|
strong: readout.strong
|
|
79
|
-
}),
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
viewBox: scene.svg.viewBox,
|
|
85
|
-
width: scene.svg.width,
|
|
86
|
-
children: [
|
|
87
|
-
scene.grid.map(({ key, line, label }) => /* @__PURE__ */ jsxs("g", { children: [/* @__PURE__ */ jsx("line", {
|
|
88
|
-
className: line.className,
|
|
89
|
-
x1: line.x1,
|
|
90
|
-
x2: line.x2,
|
|
91
|
-
y1: line.y1,
|
|
92
|
-
y2: line.y2
|
|
93
|
-
}), /* @__PURE__ */ jsx("text", {
|
|
94
|
-
className: label.className,
|
|
95
|
-
textAnchor: label.anchor,
|
|
96
|
-
x: label.x,
|
|
97
|
-
y: label.y,
|
|
98
|
-
children: label.text
|
|
99
|
-
})] }, key)),
|
|
100
|
-
scene.vaneGuides.map((guide) => /* @__PURE__ */ jsx("line", {
|
|
101
|
-
className: guide.className,
|
|
102
|
-
x1: guide.x1,
|
|
103
|
-
x2: guide.x2,
|
|
104
|
-
y1: guide.y1,
|
|
105
|
-
y2: guide.y2
|
|
106
|
-
}, `guide-${guide.key}`)),
|
|
107
|
-
scene.trace.map((part) => part.kind === "dot" ? /* @__PURE__ */ jsx("circle", {
|
|
108
|
-
className: part.className,
|
|
109
|
-
cx: part.cx,
|
|
110
|
-
cy: part.cy,
|
|
111
|
-
r: part.r
|
|
112
|
-
}, part.key) : /* @__PURE__ */ jsx("polyline", {
|
|
113
|
-
className: part.className,
|
|
114
|
-
points: part.points
|
|
115
|
-
}, part.key)),
|
|
116
|
-
scene.calmNote && /* @__PURE__ */ jsx("text", {
|
|
117
|
-
className: scene.calmNote.className,
|
|
118
|
-
textAnchor: scene.calmNote.anchor,
|
|
119
|
-
x: scene.calmNote.x,
|
|
120
|
-
y: scene.calmNote.y,
|
|
121
|
-
children: scene.calmNote.text
|
|
122
|
-
}),
|
|
123
|
-
/* @__PURE__ */ jsx("text", {
|
|
124
|
-
className: scene.rowLabels.to.className,
|
|
125
|
-
textAnchor: scene.rowLabels.to.anchor,
|
|
126
|
-
x: scene.rowLabels.to.x,
|
|
127
|
-
y: scene.rowLabels.to.y,
|
|
128
|
-
children: scene.rowLabels.to.text
|
|
129
|
-
}),
|
|
130
|
-
scene.vanes.map((vane) => vane.mark.kind === "calm" ? /* @__PURE__ */ jsx("text", {
|
|
131
|
-
className: vane.mark.text.className,
|
|
132
|
-
textAnchor: vane.mark.text.anchor,
|
|
133
|
-
x: vane.mark.text.x,
|
|
134
|
-
y: vane.mark.text.y,
|
|
135
|
-
children: vane.mark.text.text
|
|
136
|
-
}, vane.key) : /* @__PURE__ */ jsx("path", {
|
|
137
|
-
className: vane.mark.className,
|
|
138
|
-
d: vane.mark.d
|
|
139
|
-
}, vane.key)),
|
|
140
|
-
scene.vanes.map((vane) => vane.label && /* @__PURE__ */ jsx("text", {
|
|
141
|
-
className: vane.label.className,
|
|
142
|
-
textAnchor: vane.label.anchor,
|
|
143
|
-
x: vane.label.x,
|
|
144
|
-
y: vane.label.y,
|
|
145
|
-
children: vane.label.text
|
|
146
|
-
}, `label-${vane.key}`)),
|
|
147
|
-
/* @__PURE__ */ jsx("text", {
|
|
148
|
-
className: scene.rowLabels.avg.className,
|
|
149
|
-
textAnchor: scene.rowLabels.avg.anchor,
|
|
150
|
-
x: scene.rowLabels.avg.x,
|
|
151
|
-
y: scene.rowLabels.avg.y,
|
|
152
|
-
children: scene.rowLabels.avg.text
|
|
153
|
-
}),
|
|
154
|
-
scene.vanes.map((vane) => vane.value && /* @__PURE__ */ jsx("text", {
|
|
155
|
-
className: vane.value.className,
|
|
156
|
-
textAnchor: vane.value.anchor,
|
|
157
|
-
x: vane.value.x,
|
|
158
|
-
y: vane.value.y,
|
|
159
|
-
children: vane.value.text
|
|
160
|
-
}, `value-${vane.key}`)),
|
|
161
|
-
scene.ticks.map((tick) => /* @__PURE__ */ jsx("text", {
|
|
162
|
-
className: tick.className,
|
|
163
|
-
textAnchor: tick.anchor,
|
|
164
|
-
x: tick.x,
|
|
165
|
-
y: tick.y,
|
|
166
|
-
children: tick.text
|
|
167
|
-
}, tick.key)),
|
|
168
|
-
cursor && /* @__PURE__ */ jsxs(Fragment, { children: [/* @__PURE__ */ jsx("line", {
|
|
169
|
-
className: cursor.line.className,
|
|
170
|
-
x1: cursor.line.x1,
|
|
171
|
-
x2: cursor.line.x2,
|
|
172
|
-
y1: cursor.line.y1,
|
|
173
|
-
y2: cursor.line.y2
|
|
174
|
-
}), /* @__PURE__ */ jsx("circle", {
|
|
175
|
-
className: cursor.dot.className,
|
|
176
|
-
cx: cursor.dot.cx,
|
|
177
|
-
cy: cursor.dot.cy,
|
|
178
|
-
r: cursor.dot.r
|
|
179
|
-
})] }),
|
|
180
|
-
/* @__PURE__ */ jsx("rect", {
|
|
181
|
-
className: scene.hit.className,
|
|
182
|
-
fill: scene.hit.fill,
|
|
183
|
-
height: scene.hit.height,
|
|
184
|
-
onClick: handleClick,
|
|
185
|
-
onPointerLeave: () => setPreviewIndex(null),
|
|
186
|
-
onPointerMove: handlePointerMove,
|
|
187
|
-
width: scene.hit.width,
|
|
188
|
-
x: scene.hit.x,
|
|
189
|
-
y: scene.hit.y
|
|
190
|
-
})
|
|
191
|
-
]
|
|
192
|
-
})] });
|
|
63
|
+
}), renderScene(scene.draw(cursor, {
|
|
64
|
+
onClick: pinned.handleClick,
|
|
65
|
+
onPointerLeave: pinned.handlePointerLeave,
|
|
66
|
+
onPointerMove: pinned.handlePointerMove
|
|
67
|
+
}))] });
|
|
193
68
|
}
|
|
194
69
|
//#endregion
|
|
195
70
|
export { WindSampleStrip };
|
|
@@ -15,11 +15,11 @@ type SpeedAtomProps = AtomProps & {
|
|
|
15
15
|
declare function Speed(props: SpeedAtomProps): import("react").JSX.Element;
|
|
16
16
|
declare function Gust(props: SpeedAtomProps): import("react").JSX.Element;
|
|
17
17
|
declare function Lull(props: SpeedAtomProps): import("react").JSX.Element;
|
|
18
|
-
declare function Temperature({ station: stationProp, stationId, strings: stringsProp }: AtomProps): import("react").
|
|
19
|
-
declare function Pressure({ station: stationProp, stationId, strings: stringsProp }: AtomProps): import("react").
|
|
18
|
+
declare function Temperature({ station: stationProp, stationId, strings: stringsProp }: AtomProps): import("react").ReactNode;
|
|
19
|
+
declare function Pressure({ station: stationProp, stationId, strings: stringsProp }: AtomProps): import("react").ReactNode;
|
|
20
20
|
declare function Direction({ station: stationProp, stationId, strings: stringsProp, favorableDirections: favorableDirectionsProp }: AtomProps & {
|
|
21
21
|
favorableDirections?: FavorableDirection[] | null;
|
|
22
|
-
}): import("react").
|
|
22
|
+
}): import("react").ReactNode;
|
|
23
23
|
declare function UpdatedAt({ station: stationProp, stationId, servedAt: servedAtProp, receivedAtMs: receivedAtMsProp, strings: stringsProp, formatTime: formatTimeProp }: {
|
|
24
24
|
station?: Station;
|
|
25
25
|
stationId?: string;
|
|
@@ -27,10 +27,10 @@ declare function UpdatedAt({ station: stationProp, stationId, servedAt: servedAt
|
|
|
27
27
|
receivedAtMs?: number | null;
|
|
28
28
|
strings?: StationStringOverrides;
|
|
29
29
|
formatTime?: FormatTime;
|
|
30
|
-
}): import("react").
|
|
30
|
+
}): import("react").ReactNode;
|
|
31
31
|
declare function BandChip({ station: stationProp, stationId, thresholds: thresholdsProp, labels, unit: unitProp, strings: stringsProp }: SpeedAtomProps & {
|
|
32
32
|
thresholds?: SpeedThresholds | null;
|
|
33
33
|
labels?: readonly string[];
|
|
34
|
-
}): import("react").
|
|
34
|
+
}): import("react").ReactNode;
|
|
35
35
|
//#endregion
|
|
36
36
|
export { BandChip, Direction, Gust, Lull, Pressure, Speed, Temperature, UpdatedAt };
|
|
@@ -1,11 +1,12 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
import { resolveDisplay } from "../../display.js";
|
|
3
3
|
import { subscribeTicker } from "../../client/ticker.js";
|
|
4
|
-
import {
|
|
4
|
+
import { pressureAtomScene, speedAtomScene, temperatureAtomScene } from "../../scene/atoms.js";
|
|
5
|
+
import { bandChipNode, directionAtomNode, updatedAtNode, valueAtomNode } from "../../scene/cells.js";
|
|
6
|
+
import { renderScene } from "./SceneTree.js";
|
|
5
7
|
import { requireResolved, resolveStation, useStationFeedContext } from "./StationFeedProvider.js";
|
|
6
|
-
import { DirectionCell } from "../lib/cells.js";
|
|
7
8
|
import { useEffect, useState } from "react";
|
|
8
|
-
import {
|
|
9
|
+
import { jsx } from "react/jsx-runtime";
|
|
9
10
|
//#region src/react/components/atoms.tsx
|
|
10
11
|
function useResolvedStation(component, stationProp, stationId) {
|
|
11
12
|
const context = useStationFeedContext();
|
|
@@ -14,23 +15,13 @@ function useResolvedStation(component, stationProp, stationId) {
|
|
|
14
15
|
station: requireResolved(component, "station", stationProp ?? resolveStation(context, stationId))
|
|
15
16
|
};
|
|
16
17
|
}
|
|
17
|
-
function ValueAtom({ scene }) {
|
|
18
|
-
return /* @__PURE__ */ jsx("data", {
|
|
19
|
-
className: scene.className,
|
|
20
|
-
value: scene.value,
|
|
21
|
-
children: scene.content.kind === "dash" ? scene.content.text : /* @__PURE__ */ jsxs(Fragment, { children: [scene.content.text, /* @__PURE__ */ jsx("span", {
|
|
22
|
-
className: scene.content.unit.className,
|
|
23
|
-
children: scene.content.unit.text
|
|
24
|
-
})] })
|
|
25
|
-
});
|
|
26
|
-
}
|
|
27
18
|
function SpeedValue({ component, kind, station: stationProp, stationId, unit: unitProp, strings: stringsProp }) {
|
|
28
19
|
const { context, station } = useResolvedStation(component, stationProp, stationId);
|
|
29
20
|
const { unit, words } = resolveDisplay(context, {
|
|
30
21
|
strings: stringsProp,
|
|
31
22
|
unit: unitProp
|
|
32
23
|
});
|
|
33
|
-
return
|
|
24
|
+
return renderScene(valueAtomNode(speedAtomScene(station, kind, unit, words)));
|
|
34
25
|
}
|
|
35
26
|
function Speed(props) {
|
|
36
27
|
return /* @__PURE__ */ jsx(SpeedValue, {
|
|
@@ -56,12 +47,12 @@ function Lull(props) {
|
|
|
56
47
|
function Temperature({ station: stationProp, stationId, strings: stringsProp }) {
|
|
57
48
|
const { context, station } = useResolvedStation("Temperature", stationProp, stationId);
|
|
58
49
|
const { words } = resolveDisplay(context, { strings: stringsProp });
|
|
59
|
-
return
|
|
50
|
+
return renderScene(valueAtomNode(temperatureAtomScene(station, words)));
|
|
60
51
|
}
|
|
61
52
|
function Pressure({ station: stationProp, stationId, strings: stringsProp }) {
|
|
62
53
|
const { context, station } = useResolvedStation("Pressure", stationProp, stationId);
|
|
63
54
|
const { words } = resolveDisplay(context, { strings: stringsProp });
|
|
64
|
-
return
|
|
55
|
+
return renderScene(valueAtomNode(pressureAtomScene(station, words)));
|
|
65
56
|
}
|
|
66
57
|
function Direction({ station: stationProp, stationId, strings: stringsProp, favorableDirections: favorableDirectionsProp }) {
|
|
67
58
|
const { context, station } = useResolvedStation("Direction", stationProp, stationId);
|
|
@@ -69,20 +60,7 @@ function Direction({ station: stationProp, stationId, strings: stringsProp, favo
|
|
|
69
60
|
strings: stringsProp,
|
|
70
61
|
favorableDirections: favorableDirectionsProp
|
|
71
62
|
});
|
|
72
|
-
|
|
73
|
-
if (scene.cell == null) return /* @__PURE__ */ jsx("span", {
|
|
74
|
-
className: scene.className,
|
|
75
|
-
children: scene.dashText
|
|
76
|
-
});
|
|
77
|
-
return /* @__PURE__ */ jsx("span", {
|
|
78
|
-
"aria-label": scene.ariaLabel,
|
|
79
|
-
className: scene.className,
|
|
80
|
-
children: /* @__PURE__ */ jsx(DirectionCell, {
|
|
81
|
-
windAvgMps: scene.cell.windAvgMps,
|
|
82
|
-
windDirectionDeg: scene.cell.windDirectionDeg,
|
|
83
|
-
words
|
|
84
|
-
})
|
|
85
|
-
});
|
|
63
|
+
return renderScene(directionAtomNode(station, words, favorableDirections));
|
|
86
64
|
}
|
|
87
65
|
function UpdatedAt({ station: stationProp, stationId, servedAt: servedAtProp, receivedAtMs: receivedAtMsProp, strings: stringsProp, formatTime: formatTimeProp }) {
|
|
88
66
|
const { context, station } = useResolvedStation("UpdatedAt", stationProp, stationId);
|
|
@@ -97,23 +75,14 @@ function UpdatedAt({ station: stationProp, stationId, servedAt: servedAtProp, re
|
|
|
97
75
|
setNowMs(Date.now());
|
|
98
76
|
return subscribeTicker(() => setNowMs(Date.now()));
|
|
99
77
|
}, []);
|
|
100
|
-
|
|
78
|
+
return renderScene(updatedAtNode({
|
|
101
79
|
formatTime,
|
|
102
80
|
nowMs,
|
|
103
81
|
receivedAtMs,
|
|
104
82
|
servedAt,
|
|
105
83
|
station,
|
|
106
84
|
words
|
|
107
|
-
});
|
|
108
|
-
if (scene.kind === "dash") return /* @__PURE__ */ jsx("span", {
|
|
109
|
-
className: scene.className,
|
|
110
|
-
children: scene.text
|
|
111
|
-
});
|
|
112
|
-
return /* @__PURE__ */ jsx("time", {
|
|
113
|
-
className: scene.className,
|
|
114
|
-
dateTime: scene.dateTime,
|
|
115
|
-
children: scene.text
|
|
116
|
-
});
|
|
85
|
+
}));
|
|
117
86
|
}
|
|
118
87
|
function BandChip({ station: stationProp, stationId, thresholds: thresholdsProp, labels, unit: unitProp, strings: stringsProp }) {
|
|
119
88
|
const { context, station } = useResolvedStation("BandChip", stationProp, stationId);
|
|
@@ -122,18 +91,13 @@ function BandChip({ station: stationProp, stationId, thresholds: thresholdsProp,
|
|
|
122
91
|
thresholds: thresholdsProp,
|
|
123
92
|
unit: unitProp
|
|
124
93
|
});
|
|
125
|
-
|
|
94
|
+
return renderScene(bandChipNode({
|
|
126
95
|
labels,
|
|
127
96
|
station,
|
|
128
97
|
thresholds,
|
|
129
98
|
unit,
|
|
130
99
|
words
|
|
131
|
-
});
|
|
132
|
-
return /* @__PURE__ */ jsx("span", {
|
|
133
|
-
className: scene.className,
|
|
134
|
-
"data-band": scene.band,
|
|
135
|
-
children: scene.text
|
|
136
|
-
});
|
|
100
|
+
}));
|
|
137
101
|
}
|
|
138
102
|
//#endregion
|
|
139
103
|
export { BandChip, Direction, Gust, Lull, Pressure, Speed, Temperature, UpdatedAt };
|
|
@@ -1,61 +1,39 @@
|
|
|
1
1
|
"use client";
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import { useStationCurrent } from "./useStationCurrent.js";
|
|
5
|
-
import { useStationFeed } from "./useStationFeed.js";
|
|
6
|
-
import { useStationLive } from "./useStationLive.js";
|
|
7
|
-
import { useCallback, useMemo } from "react";
|
|
2
|
+
import { createStationStore } from "../../client/stores.js";
|
|
3
|
+
import { useEffect, useMemo, useRef, useSyncExternalStore } from "react";
|
|
8
4
|
//#region src/react/hooks/useStation.ts
|
|
9
5
|
function useStation(url, stationId, options = {}) {
|
|
10
6
|
const { pollSeconds, currentPollSeconds, enabled = true, fetchInit, initialData } = options;
|
|
11
7
|
const live = options.live === true;
|
|
12
|
-
const
|
|
8
|
+
const fetchInitRef = useRef(fetchInit);
|
|
9
|
+
fetchInitRef.current = fetchInit;
|
|
10
|
+
const initialRef = useRef(initialData);
|
|
11
|
+
const mountUrlRef = useRef(url);
|
|
12
|
+
const store = useMemo(() => createStationStore(url, stationId, {
|
|
13
13
|
...pollSeconds != null ? { pollSeconds } : {},
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
...
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
enabled: enabled && live,
|
|
25
|
-
...fetchInit != null ? { fetchInit } : {}
|
|
26
|
-
});
|
|
27
|
-
const liveCurrent = useMemo(() => live ? liveSnapshotToCurrent({
|
|
28
|
-
station: liveResult.station,
|
|
29
|
-
servedAt: liveResult.servedAt,
|
|
30
|
-
samples: liveResult.samples
|
|
31
|
-
}) : null, [
|
|
32
|
-
live,
|
|
33
|
-
liveResult.station,
|
|
34
|
-
liveResult.servedAt,
|
|
35
|
-
liveResult.samples
|
|
14
|
+
...currentPollSeconds != null ? { currentPollSeconds } : {},
|
|
15
|
+
fetchInit: () => fetchInitRef.current,
|
|
16
|
+
...url === mountUrlRef.current && initialRef.current != null ? { initialData: initialRef.current } : {},
|
|
17
|
+
live
|
|
18
|
+
}), [
|
|
19
|
+
url,
|
|
20
|
+
stationId,
|
|
21
|
+
pollSeconds,
|
|
22
|
+
currentPollSeconds,
|
|
23
|
+
live
|
|
36
24
|
]);
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
current,
|
|
44
|
-
currentReceivedAtMs
|
|
45
|
-
]);
|
|
46
|
-
const station = merged.feed?.stations.find((entry) => entry.id === stationId) ?? null;
|
|
47
|
-
const feedRefresh = feedResult.refresh;
|
|
48
|
-
const currentRefresh = currentResult.refresh;
|
|
49
|
-
const refresh = useCallback(() => {
|
|
50
|
-
feedRefresh();
|
|
51
|
-
currentRefresh();
|
|
52
|
-
}, [feedRefresh, currentRefresh]);
|
|
25
|
+
useEffect(() => {
|
|
26
|
+
if (!enabled) return;
|
|
27
|
+
store.start();
|
|
28
|
+
return () => store.stop();
|
|
29
|
+
}, [store, enabled]);
|
|
30
|
+
const snapshot = useSyncExternalStore(store.subscribe, store.getSnapshot, store.getSnapshot);
|
|
53
31
|
return {
|
|
54
|
-
feed:
|
|
55
|
-
station,
|
|
56
|
-
receivedAtMs:
|
|
57
|
-
error:
|
|
58
|
-
refresh
|
|
32
|
+
feed: snapshot.feed,
|
|
33
|
+
station: snapshot.station,
|
|
34
|
+
receivedAtMs: snapshot.receivedAtMs,
|
|
35
|
+
error: snapshot.error,
|
|
36
|
+
refresh: () => store.refresh()
|
|
59
37
|
};
|
|
60
38
|
}
|
|
61
39
|
//#endregion
|
|
@@ -10,7 +10,7 @@ function useStationCurrent(url, stationId, options = {}) {
|
|
|
10
10
|
const initialRef = useRef(initialData);
|
|
11
11
|
const mountUrlRef = useRef(url);
|
|
12
12
|
const mountStationRef = useRef(stationId);
|
|
13
|
-
const
|
|
13
|
+
const store = useMemo(() => createStationCurrentStore(url, stationId, {
|
|
14
14
|
...pollSeconds != null ? { pollSeconds } : {},
|
|
15
15
|
fetchInit: () => fetchInitRef.current,
|
|
16
16
|
...url === mountUrlRef.current && stationId === mountStationRef.current && initialRef.current != null ? { initial: initialRef.current } : {}
|
|
@@ -18,7 +18,8 @@ function useStationCurrent(url, stationId, options = {}) {
|
|
|
18
18
|
url,
|
|
19
19
|
stationId,
|
|
20
20
|
pollSeconds
|
|
21
|
-
])
|
|
21
|
+
]);
|
|
22
|
+
const { snapshot, refresh } = usePoller(store, enabled);
|
|
22
23
|
return {
|
|
23
24
|
current: snapshot.data,
|
|
24
25
|
station: snapshot.data?.station ?? null,
|
|
@@ -9,14 +9,15 @@ function useStationFeed(url, options = {}) {
|
|
|
9
9
|
fetchInitRef.current = fetchInit;
|
|
10
10
|
const initialRef = useRef(initialData);
|
|
11
11
|
const mountUrlRef = useRef(url);
|
|
12
|
-
const
|
|
12
|
+
const store = useMemo(() => createStationFeedStore(url, {
|
|
13
13
|
...pollSeconds != null ? { pollSeconds } : {},
|
|
14
14
|
fetchInit: () => fetchInitRef.current,
|
|
15
15
|
...url === mountUrlRef.current && initialRef.current != null ? { initial: {
|
|
16
16
|
feed: initialRef.current.feed,
|
|
17
17
|
receivedAtMs: initialRef.current.receivedAtMs
|
|
18
18
|
} } : {}
|
|
19
|
-
}), [url, pollSeconds])
|
|
19
|
+
}), [url, pollSeconds]);
|
|
20
|
+
const { snapshot, refresh } = usePoller(store, enabled);
|
|
20
21
|
return {
|
|
21
22
|
feed: snapshot.data,
|
|
22
23
|
error: snapshot.error,
|
package/dist/react/index.d.ts
CHANGED
|
@@ -1,5 +1,3 @@
|
|
|
1
|
-
import { ReadoutPart } from "../scene/chart.js";
|
|
2
|
-
import "../scene/index.js";
|
|
3
1
|
import { AirMatrix } from "./components/AirMatrix.js";
|
|
4
2
|
import { BandChip, Direction, Gust, Lull, Pressure, Speed, Temperature, UpdatedAt } from "./components/atoms.js";
|
|
5
3
|
import { CurrentConditions } from "./components/CurrentConditions.js";
|
|
@@ -18,6 +16,8 @@ import { CompassFan } from "./components/CompassFan.js";
|
|
|
18
16
|
import { RecentSummaries } from "./components/RecentSummaries.js";
|
|
19
17
|
import { ClimatologyRose } from "./components/ClimatologyRose.js";
|
|
20
18
|
import { DailyPattern } from "./components/DailyPattern.js";
|
|
19
|
+
import { ReadoutPart } from "../scene/chart.js";
|
|
20
|
+
import "../scene/index.js";
|
|
21
21
|
import { Readout } from "./components/Readout.js";
|
|
22
22
|
import { WindHistoryChart } from "./components/WindHistoryChart.js";
|
|
23
23
|
import { WindRose } from "./components/WindRose.js";
|
package/dist/react/index.js
CHANGED
|
@@ -1,32 +1,32 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
import { StationFeedProvider, useStationFeedContext } from "./components/StationFeedProvider.js";
|
|
3
3
|
import { AirMatrix } from "./components/AirMatrix.js";
|
|
4
|
-
import { WindArrow } from "./components/WindArrow.js";
|
|
5
4
|
import { BandChip, Direction, Gust, Lull, Pressure, Speed, Temperature, UpdatedAt } from "./components/atoms.js";
|
|
6
5
|
import { useFreshness } from "./hooks/useFreshness.js";
|
|
7
|
-
import { Dial } from "./components/Dial.js";
|
|
8
|
-
import { FreshnessBadge } from "./components/FreshnessBadge.js";
|
|
9
6
|
import { CurrentConditions } from "./components/CurrentConditions.js";
|
|
7
|
+
import { Dial } from "./components/Dial.js";
|
|
10
8
|
import { FavorableShare } from "./components/FavorableShare.js";
|
|
9
|
+
import { FreshnessBadge } from "./components/FreshnessBadge.js";
|
|
11
10
|
import { Sparkline } from "./components/Sparkline.js";
|
|
12
11
|
import { StationTable } from "./components/StationTable.js";
|
|
13
12
|
import { StationStrip } from "./components/StationStrip.js";
|
|
14
13
|
import { TrendChart } from "./components/TrendChart.js";
|
|
14
|
+
import { WindArrow } from "./components/WindArrow.js";
|
|
15
15
|
import { AirExtremes } from "./components/AirExtremes.js";
|
|
16
|
-
import { DailyPattern } from "./components/DailyPattern.js";
|
|
17
16
|
import { ClimatologyDailyPattern } from "./components/ClimatologyDailyPattern.js";
|
|
18
17
|
import { CompassFan } from "./components/CompassFan.js";
|
|
19
18
|
import { RecentSummaries } from "./components/RecentSummaries.js";
|
|
20
|
-
import { WindRose } from "./components/WindRose.js";
|
|
21
19
|
import { ClimatologyRose } from "./components/ClimatologyRose.js";
|
|
20
|
+
import { DailyPattern } from "./components/DailyPattern.js";
|
|
22
21
|
import { Readout } from "./components/Readout.js";
|
|
23
22
|
import { useMeasuredChartWidth } from "./hooks/useMeasuredChartWidth.js";
|
|
24
23
|
import { WindHistoryChart } from "./components/WindHistoryChart.js";
|
|
24
|
+
import { WindRose } from "./components/WindRose.js";
|
|
25
25
|
import { WindSampleStrip } from "./components/WindSampleStrip.js";
|
|
26
26
|
import { StationCard, StationCardChart, StationCardHeader, StationCardInstrument, StationCardSummary } from "./components/StationCard.js";
|
|
27
|
+
import { useStation } from "./hooks/useStation.js";
|
|
28
|
+
import { useStationClimatology } from "./hooks/useStationClimatology.js";
|
|
27
29
|
import { useStationCurrent } from "./hooks/useStationCurrent.js";
|
|
28
30
|
import { useStationFeed } from "./hooks/useStationFeed.js";
|
|
29
31
|
import { useStationLive } from "./hooks/useStationLive.js";
|
|
30
|
-
import { useStation } from "./hooks/useStation.js";
|
|
31
|
-
import { useStationClimatology } from "./hooks/useStationClimatology.js";
|
|
32
32
|
export { AirExtremes, AirMatrix, BandChip, ClimatologyDailyPattern, ClimatologyRose, CompassFan, CurrentConditions, DailyPattern, Dial, Direction, FavorableShare, FreshnessBadge, Gust, Lull, Pressure, Readout, RecentSummaries, Sparkline, Speed, StationCard, StationCardChart, StationCardHeader, StationCardInstrument, StationCardSummary, StationFeedProvider, StationStrip, StationTable, Temperature, TrendChart, UpdatedAt, WindArrow, WindHistoryChart, WindRose, WindSampleStrip, useFreshness, useMeasuredChartWidth, useStation, useStationClimatology, useStationCurrent, useStationFeed, useStationFeedContext, useStationLive };
|
package/dist/react/lib/cells.js
CHANGED
|
@@ -1,29 +1,9 @@
|
|
|
1
1
|
"use client";
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import { Fragment, jsx, jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { stationNameNode } from "../../scene/cells.js";
|
|
3
|
+
import { renderChild } from "../components/SceneTree.js";
|
|
5
4
|
//#region src/react/lib/cells.tsx
|
|
6
|
-
function DirectionCell({ windAvgMps, windDirectionDeg, words }) {
|
|
7
|
-
const cell = directionCell(windAvgMps, windDirectionDeg);
|
|
8
|
-
if (cell.kind === "calm") return /* @__PURE__ */ jsx(Fragment, { children: words.calm });
|
|
9
|
-
if (cell.kind === "dash") return /* @__PURE__ */ jsx(Fragment, { children: "—" });
|
|
10
|
-
return /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
11
|
-
/* @__PURE__ */ jsx(WindArrow, { deg: cell.deg }),
|
|
12
|
-
" ",
|
|
13
|
-
cell.compass,
|
|
14
|
-
" ",
|
|
15
|
-
cell.rounded,
|
|
16
|
-
"°"
|
|
17
|
-
] });
|
|
18
|
-
}
|
|
19
5
|
function StationNameLink({ station }) {
|
|
20
|
-
|
|
21
|
-
return /* @__PURE__ */ jsx("a", {
|
|
22
|
-
href: station.pageUrl,
|
|
23
|
-
rel: "noreferrer",
|
|
24
|
-
target: "_blank",
|
|
25
|
-
children: station.name
|
|
26
|
-
});
|
|
6
|
+
return renderChild(stationNameNode(station), 0);
|
|
27
7
|
}
|
|
28
8
|
//#endregion
|
|
29
|
-
export {
|
|
9
|
+
export { StationNameLink };
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { activeChartIndex, chartIndexAtClient, togglePinnedAt } from "../../scene/chart.js";
|
|
3
|
+
import { useState } from "react";
|
|
4
|
+
//#region src/react/lib/use-pinned-cursor.ts
|
|
5
|
+
function usePinnedCursor(scene) {
|
|
6
|
+
const [pinnedAt, setPinnedAt] = useState(null);
|
|
7
|
+
const [previewIndex, setPreviewIndex] = useState(null);
|
|
8
|
+
const indexAtPoint = (clientX, hit) => {
|
|
9
|
+
const svg = hit.ownerSVGElement;
|
|
10
|
+
if (!svg) return null;
|
|
11
|
+
return chartIndexAtClient(scene.points, scene.frame, scene.scales, clientX, svg.getBoundingClientRect());
|
|
12
|
+
};
|
|
13
|
+
return {
|
|
14
|
+
activeIndex: activeChartIndex(scene.points, pinnedAt, previewIndex),
|
|
15
|
+
previewIndex,
|
|
16
|
+
handleClick: (event) => {
|
|
17
|
+
const index = indexAtPoint(event.clientX, event.currentTarget);
|
|
18
|
+
if (index == null) return;
|
|
19
|
+
const observedAt = scene.points[index]?.observedAt;
|
|
20
|
+
if (observedAt == null) return;
|
|
21
|
+
setPinnedAt((current) => togglePinnedAt(current, observedAt));
|
|
22
|
+
setPreviewIndex(null);
|
|
23
|
+
},
|
|
24
|
+
handlePointerLeave: () => setPreviewIndex(null),
|
|
25
|
+
handlePointerMove: (event) => {
|
|
26
|
+
if (event.pointerType === "touch") return;
|
|
27
|
+
setPreviewIndex(indexAtPoint(event.clientX, event.currentTarget));
|
|
28
|
+
}
|
|
29
|
+
};
|
|
30
|
+
}
|
|
31
|
+
//#endregion
|
|
32
|
+
export { usePinnedCursor };
|