@azohra/meteo.station 0.1.3 → 0.3.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (53) hide show
  1. package/README.md +4 -4
  2. package/dist/elements/elements/DailyPatternElement.js +1 -2
  3. package/dist/elements/elements/TrendChartElement.js +2 -1
  4. package/dist/elements/elements/WindHistoryChartElement.js +2 -1
  5. package/dist/geometry.d.ts +6 -1
  6. package/dist/geometry.js +8 -1
  7. package/dist/index.d.ts +3 -3
  8. package/dist/index.js +3 -3
  9. package/dist/react/components/DailyPattern.js +1 -2
  10. package/dist/react/components/Readout.d.ts +12 -0
  11. package/dist/react/components/Readout.js +14 -0
  12. package/dist/react/components/TrendChart.js +2 -1
  13. package/dist/react/components/WindHistoryChart.js +10 -24
  14. package/dist/react/components/WindSampleStrip.d.ts +15 -0
  15. package/dist/react/components/WindSampleStrip.js +192 -0
  16. package/dist/react/hooks/useMeasuredChartWidth.d.ts +8 -0
  17. package/dist/react/hooks/useMeasuredChartWidth.js +26 -0
  18. package/dist/react/index.d.ts +6 -1
  19. package/dist/react/index.js +4 -1
  20. package/dist/scene/air-matrix.d.ts +2 -0
  21. package/dist/scene/atoms.d.ts +4 -0
  22. package/dist/scene/card.d.ts +3 -0
  23. package/dist/scene/chart.d.ts +11 -0
  24. package/dist/scene/chart.js +1 -7
  25. package/dist/scene/current.d.ts +3 -0
  26. package/dist/scene/daily-pattern.d.ts +6 -0
  27. package/dist/scene/dial.d.ts +4 -0
  28. package/dist/scene/glyphs.d.ts +2 -0
  29. package/dist/scene/index.d.ts +18 -0
  30. package/dist/scene/rose.d.ts +4 -0
  31. package/dist/scene/sample-strip.d.ts +6 -0
  32. package/dist/scene/sample-strip.js +130 -0
  33. package/dist/scene/sparkline.d.ts +3 -0
  34. package/dist/scene/strip.d.ts +3 -0
  35. package/dist/scene/table.d.ts +3 -0
  36. package/dist/scene/trend.d.ts +4 -0
  37. package/dist/scene/trend.js +1 -2
  38. package/dist/scene/wind-history.d.ts +6 -0
  39. package/dist/scene/wind-plot.d.ts +5 -0
  40. package/dist/scene/wind-plot.js +1 -2
  41. package/dist/server/adapters/ecowitt.d.ts +28 -0
  42. package/dist/server/adapters/ecowitt.js +150 -0
  43. package/dist/server/config.d.ts +29 -1
  44. package/dist/server/config.js +14 -1
  45. package/dist/server/environment.d.ts +8 -1
  46. package/dist/server/environment.js +23 -1
  47. package/dist/server/feed.js +6 -0
  48. package/dist/server/index.d.ts +4 -3
  49. package/dist/server/index.js +4 -3
  50. package/dist/strings.d.ts +2 -0
  51. package/dist/strings.js +2 -0
  52. package/package.json +1 -1
  53. package/styles.css +24 -0
package/README.md CHANGED
@@ -2,9 +2,9 @@
2
2
 
3
3
  The **station** capability of meteo by Azohra: one wire contract, vendor
4
4
  adapters that normalize into it (WindNerd, WeatherFlow Tempest, Campbell
5
- Scientific loggers, or your own), a mountable `Request → Response` handler
5
+ Scientific loggers, Ecowitt, or your own), a mountable `Request → Response` handler
6
6
  that serves the whole inventory as a single feed, and hooks and components
7
- that render it — natively, in your design system, with no vendor iframe.
7
+ that render it natively, in your design system, with no vendor iframe.
8
8
 
9
9
  ## Surface
10
10
 
@@ -13,8 +13,8 @@ that render it — natively, in your design system, with no vendor iframe.
13
13
  | `@azohra/meteo.station` | The isomorphic root: the wire contract (zod), pure derivations (period stats, compass, freshness, unit and threshold conversion), framework-free chart and instrument geometry, and the shared display rules (strings, formatting, air sentences, display resolution, merge policy) every binding renders from. |
14
14
  | `@azohra/meteo.station/client` | The framework-free client data layer: `createJsonPoller` and the station stores (`createStationFeedStore`, `createStationCurrentStore`, `createStationStore`) every binding subscribes to. Client-only at runtime, import-safe anywhere. |
15
15
  | `@azohra/meteo.station/server` | Vendor adapters plus the custom-adapter interface and `defineStationAdapter`, data-level `loadStationFeed()` / `loadStationCurrent()`, and the mountable feed handler. Server-only, so it can never leak into a client bundle. |
16
- | `@azohra/meteo.station/react` | `StationFeedProvider`, polling hooks (`useStation`, `useStationFeed`, `useStationCurrent`), the component set — `StationCard`, `CurrentConditions`, `WindHistoryChart`, `TrendChart`, `WindRose`, `DailyPattern`, `StationTable`, `StationStrip`, `AirMatrix`, `FreshnessBadge` — and an atoms layer of inline primitives (`Speed`, `Gust`, `Lull`, `Temperature`, `Pressure`, `Direction`, `UpdatedAt`, `BandChip`, `Dial`, `Sparkline`) for composing your own layouts. |
17
- | `@azohra/meteo.station/elements` | The same surface as light-DOM custom elements (`<meteo-station-feed>`, `<meteo-station-card>`, `<meteo-station-table>`, the charts, the atoms…) — a full peer of the react binding, framework-free, held byte-identical by a parity suite. `/register` is the auto-defining one-liner. |
16
+ | `@azohra/meteo.station/react` | `StationFeedProvider`, polling hooks (`useStation`, `useStationFeed`, `useStationCurrent`), the component set (`StationCard`, `CurrentConditions`, `WindHistoryChart`, `WindSampleStrip`, `TrendChart`, `WindRose`, `DailyPattern`, `StationTable`, `StationStrip`, `AirMatrix`, `FreshnessBadge`), and an atoms layer of inline primitives (`Speed`, `Gust`, `Lull`, `Temperature`, `Pressure`, `Direction`, `UpdatedAt`, `BandChip`, `Dial`, `Sparkline`, `Readout`) for composing your own layouts. |
17
+ | `@azohra/meteo.station/elements` | The same surface as light-DOM custom elements (`<meteo-station-feed>`, `<meteo-station-card>`, `<meteo-station-table>`, the charts, the atoms…), a full peer of the react binding, framework-free, held byte-identical by a parity suite. `/register` is the auto-defining one-liner. |
18
18
  | `@azohra/meteo.station/styles.css` | The default skin (an intentional side effect), shared by both bindings. |
19
19
 
20
20
  ## Taste
@@ -1,6 +1,5 @@
1
1
  import { resolveStation } from "../../display.js";
2
- import "../../geometry.js";
3
- import { measuredChartWidth } from "../../scene/chart.js";
2
+ import { measuredChartWidth } from "../../geometry.js";
4
3
  import { DAILY_PATTERN_CLASS, dailyPatternGate, dailyPatternScene, dailyPatternSource } from "../../scene/daily-pattern.js";
5
4
  import { numberAttribute } from "../lib/attributes.js";
6
5
  import { MeteoStationElement } from "../lib/base.js";
@@ -1,5 +1,6 @@
1
1
  import { requireResolved } from "../../display.js";
2
- import { activeChartIndex, chartIndexAtClient, measuredChartWidth, readoutAriaLive, togglePinnedAt } from "../../scene/chart.js";
2
+ import { measuredChartWidth } from "../../geometry.js";
3
+ import { activeChartIndex, chartIndexAtClient, readoutAriaLive, togglePinnedAt } from "../../scene/chart.js";
3
4
  import { TREND_CLASS, trendGate, trendScene } from "../../scene/trend.js";
4
5
  import { ELEMENTS_AMBIENT_HINT } from "../lib/ambient.js";
5
6
  import { MeteoStationElement } from "../lib/base.js";
@@ -1,4 +1,5 @@
1
- import { activeChartIndex, chartIndexAtClient, measuredChartWidth, readoutAriaLive, togglePinnedAt } from "../../scene/chart.js";
1
+ import { measuredChartWidth } from "../../geometry.js";
2
+ import { activeChartIndex, chartIndexAtClient, readoutAriaLive, togglePinnedAt } from "../../scene/chart.js";
2
3
  import { WIND_CHART_CLASS, windChartGate, windChartScene } from "../../scene/wind-history.js";
3
4
  import { numberAttribute } from "../lib/attributes.js";
4
5
  import { MeteoStationElement } from "../lib/base.js";
@@ -12,6 +12,10 @@ type ChartFrame = {
12
12
  valueRow: number;
13
13
  width: number;
14
14
  };
15
+ declare const CHART_FALLBACK_WIDTH = 360;
16
+ declare function measuredChartWidth(measured: number): number;
17
+ type TickAnchor = "end" | "middle" | "start";
18
+ declare function tickAnchor(index: number, lastIndex: number): TickAnchor;
15
19
  declare function chartFrame(width: number): ChartFrame;
16
20
  type ChartScales = {
17
21
  startMs: number;
@@ -29,6 +33,7 @@ type ChartScaleOptions = {
29
33
  declare function chartScales(points: ReadonlyArray<HistoryPoint>, frame: ChartFrame, options?: ChartScaleOptions): ChartScales;
30
34
  declare function bandPoints(points: ReadonlyArray<HistoryPoint>, scales: ChartScales): string | null;
31
35
  declare function averagePoints(points: ReadonlyArray<HistoryPoint>, scales: ChartScales): string;
36
+ declare function meanDirectionDeg(points: ReadonlyArray<HistoryPoint>): number | null;
32
37
  type Vane = {
33
38
  windAvgMps: number;
34
39
  windDirectionDeg: number | null;
@@ -84,4 +89,4 @@ declare function windowPoints(points: ReadonlyArray<HistoryPoint>, hours?: numbe
84
89
  declare function compareWindow(points: ReadonlyArray<HistoryPoint>, offsetDays: number, windowHours?: number): HistoryPoint[] | null;
85
90
  declare function compareTracePoints(comparePoints: ReadonlyArray<HistoryPoint>, scales: ChartScales, offsetDays: number): string;
86
91
  //#endregion
87
- export { ChartFrame, ChartScaleOptions, ChartScales, ChartTick, DAILY_PATTERN_DEFAULT_SLOT_MINUTES, DailyPatternSlot, METEOROLOGICAL_SEASON_MONTHS, RoseSector, TrendSeries, Vane, WindRoseSummary, averagePoints, bandPoints, chartFrame, chartScales, compareTracePoints, compareWindow, dailyPattern, filterByMonth, filterByTimeOfDay, historyGaps, nearestIndex, speedBand, thinVanes, vanePath, vaneTicks, windRose, windowPoints };
92
+ export { CHART_FALLBACK_WIDTH, ChartFrame, ChartScaleOptions, ChartScales, ChartTick, DAILY_PATTERN_DEFAULT_SLOT_MINUTES, DailyPatternSlot, METEOROLOGICAL_SEASON_MONTHS, RoseSector, TickAnchor, TrendSeries, Vane, WindRoseSummary, averagePoints, bandPoints, chartFrame, chartScales, compareTracePoints, compareWindow, dailyPattern, filterByMonth, filterByTimeOfDay, historyGaps, meanDirectionDeg, measuredChartWidth, nearestIndex, speedBand, thinVanes, tickAnchor, vanePath, vaneTicks, windRose, windowPoints };
package/dist/geometry.js CHANGED
@@ -1,7 +1,14 @@
1
1
  import { KMH_PER_MPS, isCalm, normalizeDegrees, radians } from "./derive.js";
2
2
  import { componentsToWind, meanDirectionDeg, windToComponents } from "@azohra/meteo.core";
3
3
  //#region src/geometry.ts
4
+ const CHART_FALLBACK_WIDTH = 360;
4
5
  const CHART_AXIS_GUTTER = 46;
6
+ function measuredChartWidth(measured) {
7
+ return measured > 0 ? Math.round(measured) : 360;
8
+ }
9
+ function tickAnchor(index, lastIndex) {
10
+ return index === 0 ? "start" : index === lastIndex ? "end" : "middle";
11
+ }
5
12
  function chartFrame(width) {
6
13
  const plotHeight = width < 520 ? 76 : 116;
7
14
  const plotTop = 10;
@@ -330,4 +337,4 @@ function compareTracePoints(comparePoints, scales, offsetDays) {
330
337
  return comparePoints.map((point) => coordinate(scales.xAtMs(Date.parse(point.observedAt) + shiftMs), scales.yAt(point.windAvgMps))).join(" ");
331
338
  }
332
339
  //#endregion
333
- export { DAILY_PATTERN_DEFAULT_SLOT_MINUTES, HISTORY_GAP_TOLERANCE_FACTOR, METEOROLOGICAL_SEASON_MONTHS, averagePoints, bandPoints, chartFrame, chartScales, compareTracePoints, compareWindow, dailyPattern, filterByMonth, filterByTimeOfDay, historyGaps, isCalmHistory, meanDirectionDeg$1 as meanDirectionDeg, nearestIndex, speedBand, stretchFrame, thinVanes, trendRuns, trendSeriesPad, trendValueOf, valueScale, vanePath, vaneTicks, vectorMeanWind, windRose, windowPoints };
340
+ export { CHART_FALLBACK_WIDTH, DAILY_PATTERN_DEFAULT_SLOT_MINUTES, HISTORY_GAP_TOLERANCE_FACTOR, METEOROLOGICAL_SEASON_MONTHS, averagePoints, bandPoints, chartFrame, chartScales, compareTracePoints, compareWindow, dailyPattern, filterByMonth, filterByTimeOfDay, historyGaps, isCalmHistory, meanDirectionDeg$1 as meanDirectionDeg, measuredChartWidth, nearestIndex, speedBand, stretchFrame, thinVanes, tickAnchor, trendRuns, trendSeriesPad, trendValueOf, valueScale, vanePath, vaneTicks, vectorMeanWind, windRose, windowPoints };
package/dist/index.d.ts CHANGED
@@ -1,13 +1,13 @@
1
1
  import { AirConditions, History, HistoryPoint, LiveSample, LiveSamples, Reading, STATION_SCHEMA_VERSION, Station, StationCapabilities, StationCurrent, StationFeed, StationLiveFrame, StationMeta, StationTelemetry, UNAVAILABLE_REASONS, UnavailableReason, airConditionsSchema, capabilitiesSchema, emptyConditions, historyPointSchema, historySchema, liveSampleSchema, liveSamplesSchema, parseStationCurrent, parseStationCurrentJson, parseStationFeed, parseStationFeedJson, parseStationLiveFrame, parseStationLiveFrameJson, readingSchema, stationCurrentSchema, stationFeedSchema, stationLiveFrameSchema, stationMetaSchema, stationSchema, telemetrySchema, unavailableStation } from "./contract.js";
2
- import { CALM_THRESHOLD_MPS, CompassPoint, FreshnessStatus, FreshnessThresholds, PeriodSummary, PressureTendency, SpeedThresholds, SpeedUnit, compassDirection, freshness, isCalm, normalizeDegrees, periodSummary, pressureTendency, seaLevelPressureHpa, speedFromMps, speedToMps, speedUnitLabel, stationFreshnessThresholds, thresholdsToMps } from "./derive.js";
2
+ import { CALM_THRESHOLD_MPS, COMPASS_POINTS, CompassPoint, FreshnessStatus, FreshnessThresholds, PeriodSummary, PressureTendency, SpeedThresholds, SpeedUnit, compassDirection, freshness, isCalm, normalizeDegrees, periodSummary, pressureTendency, seaLevelPressureHpa, speedFromMps, speedToMps, speedUnitLabel, stationFreshnessThresholds, thresholdsToMps } from "./derive.js";
3
3
  import { FormatTime, StationStringOverrides, StationStrings, defaultFormatTime, defaultStrings, localeFormatTime, mergeStringOverrides, resolveStrings } from "./strings.js";
4
4
  import { DirectionCellData, SummaryEntry, directionCell, optionalSpeed, roundSpeed, summaryEntries, temperatureText, temperatureValue, updatedAtText } from "./format.js";
5
5
  import { DisplayDefaults, DisplayProps, ResolvedDisplay, requireResolved, resolveDisplay, resolveStation } from "./display.js";
6
6
  import { currentEndpoint, feedEndpoint, liveEndpoint } from "./endpoints.js";
7
- import { ChartFrame, ChartScaleOptions, ChartScales, ChartTick, DAILY_PATTERN_DEFAULT_SLOT_MINUTES, DailyPatternSlot, METEOROLOGICAL_SEASON_MONTHS, RoseSector, Vane, WindRoseSummary, averagePoints, bandPoints, chartFrame, chartScales, compareTracePoints, compareWindow, dailyPattern, filterByMonth, filterByTimeOfDay, historyGaps, nearestIndex, speedBand, thinVanes, vanePath, vaneTicks, windRose, windowPoints } from "./geometry.js";
7
+ import { CHART_FALLBACK_WIDTH, ChartFrame, ChartScaleOptions, ChartScales, ChartTick, DAILY_PATTERN_DEFAULT_SLOT_MINUTES, DailyPatternSlot, METEOROLOGICAL_SEASON_MONTHS, RoseSector, TickAnchor, Vane, WindRoseSummary, averagePoints, bandPoints, chartFrame, chartScales, compareTracePoints, compareWindow, dailyPattern, filterByMonth, filterByTimeOfDay, historyGaps, meanDirectionDeg, measuredChartWidth, nearestIndex, speedBand, thinVanes, tickAnchor, vanePath, vaneTicks, windRose, windowPoints } from "./geometry.js";
8
8
  import { DIAL_CARDINALS, DIAL_CARDINAL_TICK_INNER, DIAL_CENTRE, DIAL_COUNTERWEIGHT_RADIUS, DIAL_COUNTERWEIGHT_REACH, DIAL_HUB_RADIUS, DIAL_LETTER_RADIUS, DIAL_MIN_MAX_MPS, DIAL_RING_RADIUS, DIAL_SIZE, DIAL_TICK_INNER, FavorableDirection, HistoryRun, ROSE_CARDINAL_LETTERS, ROSE_CENTRE, ROSE_FAVORABLE_RING_RADIUS, ROSE_HUB_DOT_RADIUS, ROSE_HUB_RADIUS, ROSE_INTERCARDINAL_BEARINGS, ROSE_LETTER_RADIUS, ROSE_MAX_RADIUS, ROSE_PETAL_FILL, ROSE_SIZE, ROSE_TICK_REACH, SPARKLINE_EDGE_INSET, SPARKLINE_MAX_PADDING, bandStrips, dialNeedlePoints, dialPolar, dialScaleMaxMps, dialSpeedArcPath, historyRuns, rosePetalPath, rosePolar, roseRingArcPath, sparklineScale } from "./instruments.js";
9
9
  import { MergeResult, foldCurrent, mergeCurrent } from "./merge-current.js";
10
10
  import { SAMPLE_GAP_TOLERANCE_FACTOR, SamplesSummary, sampleMeanDirectionDeg, samplePoints, sampleRuns, sampleScales, samplesSummary, thinSampleVanes } from "./samples.js";
11
11
  import { AirRow, airRows, airSummary, lastStrikeWords } from "./air.js";
12
12
  import { normalizeWindnerdStationKey, windnerdStationUrl } from "./windnerd.js";
13
- export { type AirConditions, type AirRow, CALM_THRESHOLD_MPS, type ChartFrame, type ChartScaleOptions, type ChartScales, type ChartTick, type CompassPoint, DAILY_PATTERN_DEFAULT_SLOT_MINUTES, DIAL_CARDINALS, DIAL_CARDINAL_TICK_INNER, DIAL_CENTRE, DIAL_COUNTERWEIGHT_RADIUS, DIAL_COUNTERWEIGHT_REACH, DIAL_HUB_RADIUS, DIAL_LETTER_RADIUS, DIAL_MIN_MAX_MPS, DIAL_RING_RADIUS, DIAL_SIZE, DIAL_TICK_INNER, type DailyPatternSlot, type DirectionCellData, type DisplayDefaults, type DisplayProps, type FavorableDirection, type FormatTime, type FreshnessStatus, type FreshnessThresholds, type History, type HistoryPoint, type HistoryRun, type LiveSample, type LiveSamples, METEOROLOGICAL_SEASON_MONTHS, type MergeResult, type PeriodSummary, type PressureTendency, ROSE_CARDINAL_LETTERS, ROSE_CENTRE, ROSE_FAVORABLE_RING_RADIUS, ROSE_HUB_DOT_RADIUS, ROSE_HUB_RADIUS, ROSE_INTERCARDINAL_BEARINGS, ROSE_LETTER_RADIUS, ROSE_MAX_RADIUS, ROSE_PETAL_FILL, ROSE_SIZE, ROSE_TICK_REACH, type Reading, type ResolvedDisplay, type RoseSector, SAMPLE_GAP_TOLERANCE_FACTOR, SPARKLINE_EDGE_INSET, SPARKLINE_MAX_PADDING, STATION_SCHEMA_VERSION, type SamplesSummary, type SpeedThresholds, type SpeedUnit, type Station, type StationCapabilities, type StationCurrent, type StationFeed, type StationLiveFrame, type StationMeta, type StationStringOverrides, type StationStrings, type StationTelemetry, type SummaryEntry, UNAVAILABLE_REASONS, type UnavailableReason, type Vane, type WindRoseSummary, airConditionsSchema, airRows, airSummary, averagePoints, bandPoints, bandStrips, capabilitiesSchema, chartFrame, chartScales, compareTracePoints, compareWindow, compassDirection, currentEndpoint, dailyPattern, defaultFormatTime, defaultStrings, dialNeedlePoints, dialPolar, dialScaleMaxMps, dialSpeedArcPath, directionCell, emptyConditions, feedEndpoint, filterByMonth, filterByTimeOfDay, foldCurrent, freshness, historyGaps, historyPointSchema, historyRuns, historySchema, isCalm, lastStrikeWords, liveEndpoint, liveSampleSchema, liveSamplesSchema, localeFormatTime, mergeCurrent, mergeStringOverrides, nearestIndex, normalizeDegrees, normalizeWindnerdStationKey, optionalSpeed, parseStationCurrent, parseStationCurrentJson, parseStationFeed, parseStationFeedJson, parseStationLiveFrame, parseStationLiveFrameJson, periodSummary, pressureTendency, readingSchema, requireResolved, resolveDisplay, resolveStation, resolveStrings, rosePetalPath, rosePolar, roseRingArcPath, roundSpeed, sampleMeanDirectionDeg, samplePoints, sampleRuns, sampleScales, samplesSummary, seaLevelPressureHpa, sparklineScale, speedBand, speedFromMps, speedToMps, speedUnitLabel, stationCurrentSchema, stationFeedSchema, stationFreshnessThresholds, stationLiveFrameSchema, stationMetaSchema, stationSchema, summaryEntries, telemetrySchema, temperatureText, temperatureValue, thinSampleVanes, thinVanes, thresholdsToMps, unavailableStation, updatedAtText, vanePath, vaneTicks, windRose, windnerdStationUrl, windowPoints };
13
+ export { type AirConditions, type AirRow, CALM_THRESHOLD_MPS, CHART_FALLBACK_WIDTH, COMPASS_POINTS, type ChartFrame, type ChartScaleOptions, type ChartScales, type ChartTick, type CompassPoint, DAILY_PATTERN_DEFAULT_SLOT_MINUTES, DIAL_CARDINALS, DIAL_CARDINAL_TICK_INNER, DIAL_CENTRE, DIAL_COUNTERWEIGHT_RADIUS, DIAL_COUNTERWEIGHT_REACH, DIAL_HUB_RADIUS, DIAL_LETTER_RADIUS, DIAL_MIN_MAX_MPS, DIAL_RING_RADIUS, DIAL_SIZE, DIAL_TICK_INNER, type DailyPatternSlot, type DirectionCellData, type DisplayDefaults, type DisplayProps, type FavorableDirection, type FormatTime, type FreshnessStatus, type FreshnessThresholds, type History, type HistoryPoint, type HistoryRun, type LiveSample, type LiveSamples, METEOROLOGICAL_SEASON_MONTHS, type MergeResult, type PeriodSummary, type PressureTendency, ROSE_CARDINAL_LETTERS, ROSE_CENTRE, ROSE_FAVORABLE_RING_RADIUS, ROSE_HUB_DOT_RADIUS, ROSE_HUB_RADIUS, ROSE_INTERCARDINAL_BEARINGS, ROSE_LETTER_RADIUS, ROSE_MAX_RADIUS, ROSE_PETAL_FILL, ROSE_SIZE, ROSE_TICK_REACH, type Reading, type ResolvedDisplay, type RoseSector, SAMPLE_GAP_TOLERANCE_FACTOR, SPARKLINE_EDGE_INSET, SPARKLINE_MAX_PADDING, STATION_SCHEMA_VERSION, type SamplesSummary, type SpeedThresholds, type SpeedUnit, type Station, type StationCapabilities, type StationCurrent, type StationFeed, type StationLiveFrame, type StationMeta, type StationStringOverrides, type StationStrings, type StationTelemetry, type SummaryEntry, type TickAnchor, UNAVAILABLE_REASONS, type UnavailableReason, type Vane, type WindRoseSummary, airConditionsSchema, airRows, airSummary, averagePoints, bandPoints, bandStrips, capabilitiesSchema, chartFrame, chartScales, compareTracePoints, compareWindow, compassDirection, currentEndpoint, dailyPattern, defaultFormatTime, defaultStrings, dialNeedlePoints, dialPolar, dialScaleMaxMps, dialSpeedArcPath, directionCell, emptyConditions, feedEndpoint, filterByMonth, filterByTimeOfDay, foldCurrent, freshness, historyGaps, meanDirectionDeg as historyMeanDirectionDeg, historyPointSchema, historyRuns, historySchema, isCalm, lastStrikeWords, liveEndpoint, liveSampleSchema, liveSamplesSchema, localeFormatTime, measuredChartWidth, mergeCurrent, mergeStringOverrides, nearestIndex, normalizeDegrees, normalizeWindnerdStationKey, optionalSpeed, parseStationCurrent, parseStationCurrentJson, parseStationFeed, parseStationFeedJson, parseStationLiveFrame, parseStationLiveFrameJson, periodSummary, pressureTendency, readingSchema, requireResolved, resolveDisplay, resolveStation, resolveStrings, rosePetalPath, rosePolar, roseRingArcPath, roundSpeed, sampleMeanDirectionDeg, samplePoints, sampleRuns, sampleScales, samplesSummary, seaLevelPressureHpa, sparklineScale, speedBand, speedFromMps, speedToMps, speedUnitLabel, stationCurrentSchema, stationFeedSchema, stationFreshnessThresholds, stationLiveFrameSchema, stationMetaSchema, stationSchema, summaryEntries, telemetrySchema, temperatureText, temperatureValue, thinSampleVanes, thinVanes, thresholdsToMps, tickAnchor, unavailableStation, updatedAtText, vanePath, vaneTicks, windRose, windnerdStationUrl, windowPoints };
package/dist/index.js CHANGED
@@ -1,13 +1,13 @@
1
1
  import { STATION_SCHEMA_VERSION, UNAVAILABLE_REASONS, airConditionsSchema, capabilitiesSchema, emptyConditions, historyPointSchema, historySchema, liveSampleSchema, liveSamplesSchema, parseStationCurrent, parseStationCurrentJson, parseStationFeed, parseStationFeedJson, parseStationLiveFrame, parseStationLiveFrameJson, readingSchema, stationCurrentSchema, stationFeedSchema, stationLiveFrameSchema, stationMetaSchema, stationSchema, telemetrySchema, unavailableStation } from "./contract.js";
2
- import { CALM_THRESHOLD_MPS, compassDirection, freshness, isCalm, normalizeDegrees, periodSummary, pressureTendency, seaLevelPressureHpa, speedFromMps, speedToMps, speedUnitLabel, stationFreshnessThresholds, thresholdsToMps } from "./derive.js";
2
+ import { CALM_THRESHOLD_MPS, COMPASS_POINTS, compassDirection, freshness, isCalm, normalizeDegrees, periodSummary, pressureTendency, seaLevelPressureHpa, speedFromMps, speedToMps, speedUnitLabel, stationFreshnessThresholds, thresholdsToMps } from "./derive.js";
3
3
  import { defaultFormatTime, defaultStrings, localeFormatTime, mergeStringOverrides, resolveStrings } from "./strings.js";
4
4
  import { requireResolved, resolveDisplay, resolveStation } from "./display.js";
5
5
  import { currentEndpoint, feedEndpoint, liveEndpoint } from "./endpoints.js";
6
6
  import { directionCell, optionalSpeed, roundSpeed, summaryEntries, temperatureText, temperatureValue, updatedAtText } from "./format.js";
7
- import { DAILY_PATTERN_DEFAULT_SLOT_MINUTES, METEOROLOGICAL_SEASON_MONTHS, averagePoints, bandPoints, chartFrame, chartScales, compareTracePoints, compareWindow, dailyPattern, filterByMonth, filterByTimeOfDay, historyGaps, nearestIndex, speedBand, thinVanes, vanePath, vaneTicks, windRose, windowPoints } from "./geometry.js";
7
+ import { CHART_FALLBACK_WIDTH, DAILY_PATTERN_DEFAULT_SLOT_MINUTES, METEOROLOGICAL_SEASON_MONTHS, averagePoints, bandPoints, chartFrame, chartScales, compareTracePoints, compareWindow, dailyPattern, filterByMonth, filterByTimeOfDay, historyGaps, meanDirectionDeg, measuredChartWidth, nearestIndex, speedBand, thinVanes, tickAnchor, vanePath, vaneTicks, windRose, windowPoints } from "./geometry.js";
8
8
  import { DIAL_CARDINALS, DIAL_CARDINAL_TICK_INNER, DIAL_CENTRE, DIAL_COUNTERWEIGHT_RADIUS, DIAL_COUNTERWEIGHT_REACH, DIAL_HUB_RADIUS, DIAL_LETTER_RADIUS, DIAL_MIN_MAX_MPS, DIAL_RING_RADIUS, DIAL_SIZE, DIAL_TICK_INNER, ROSE_CARDINAL_LETTERS, ROSE_CENTRE, ROSE_FAVORABLE_RING_RADIUS, ROSE_HUB_DOT_RADIUS, ROSE_HUB_RADIUS, ROSE_INTERCARDINAL_BEARINGS, ROSE_LETTER_RADIUS, ROSE_MAX_RADIUS, ROSE_PETAL_FILL, ROSE_SIZE, ROSE_TICK_REACH, SPARKLINE_EDGE_INSET, SPARKLINE_MAX_PADDING, bandStrips, dialNeedlePoints, dialPolar, dialScaleMaxMps, dialSpeedArcPath, historyRuns, rosePetalPath, rosePolar, roseRingArcPath, sparklineScale } from "./instruments.js";
9
9
  import { foldCurrent, mergeCurrent } from "./merge-current.js";
10
10
  import { SAMPLE_GAP_TOLERANCE_FACTOR, sampleMeanDirectionDeg, samplePoints, sampleRuns, sampleScales, samplesSummary, thinSampleVanes } from "./samples.js";
11
11
  import { airRows, airSummary, lastStrikeWords } from "./air.js";
12
12
  import { normalizeWindnerdStationKey, windnerdStationUrl } from "./windnerd.js";
13
- export { CALM_THRESHOLD_MPS, DAILY_PATTERN_DEFAULT_SLOT_MINUTES, DIAL_CARDINALS, DIAL_CARDINAL_TICK_INNER, DIAL_CENTRE, DIAL_COUNTERWEIGHT_RADIUS, DIAL_COUNTERWEIGHT_REACH, DIAL_HUB_RADIUS, DIAL_LETTER_RADIUS, DIAL_MIN_MAX_MPS, DIAL_RING_RADIUS, DIAL_SIZE, DIAL_TICK_INNER, METEOROLOGICAL_SEASON_MONTHS, ROSE_CARDINAL_LETTERS, ROSE_CENTRE, ROSE_FAVORABLE_RING_RADIUS, ROSE_HUB_DOT_RADIUS, ROSE_HUB_RADIUS, ROSE_INTERCARDINAL_BEARINGS, ROSE_LETTER_RADIUS, ROSE_MAX_RADIUS, ROSE_PETAL_FILL, ROSE_SIZE, ROSE_TICK_REACH, SAMPLE_GAP_TOLERANCE_FACTOR, SPARKLINE_EDGE_INSET, SPARKLINE_MAX_PADDING, STATION_SCHEMA_VERSION, UNAVAILABLE_REASONS, airConditionsSchema, airRows, airSummary, averagePoints, bandPoints, bandStrips, capabilitiesSchema, chartFrame, chartScales, compareTracePoints, compareWindow, compassDirection, currentEndpoint, dailyPattern, defaultFormatTime, defaultStrings, dialNeedlePoints, dialPolar, dialScaleMaxMps, dialSpeedArcPath, directionCell, emptyConditions, feedEndpoint, filterByMonth, filterByTimeOfDay, foldCurrent, freshness, historyGaps, historyPointSchema, historyRuns, historySchema, isCalm, lastStrikeWords, liveEndpoint, liveSampleSchema, liveSamplesSchema, localeFormatTime, mergeCurrent, mergeStringOverrides, nearestIndex, normalizeDegrees, normalizeWindnerdStationKey, optionalSpeed, parseStationCurrent, parseStationCurrentJson, parseStationFeed, parseStationFeedJson, parseStationLiveFrame, parseStationLiveFrameJson, periodSummary, pressureTendency, readingSchema, requireResolved, resolveDisplay, resolveStation, resolveStrings, rosePetalPath, rosePolar, roseRingArcPath, roundSpeed, sampleMeanDirectionDeg, samplePoints, sampleRuns, sampleScales, samplesSummary, seaLevelPressureHpa, sparklineScale, speedBand, speedFromMps, speedToMps, speedUnitLabel, stationCurrentSchema, stationFeedSchema, stationFreshnessThresholds, stationLiveFrameSchema, stationMetaSchema, stationSchema, summaryEntries, telemetrySchema, temperatureText, temperatureValue, thinSampleVanes, thinVanes, thresholdsToMps, unavailableStation, updatedAtText, vanePath, vaneTicks, windRose, windnerdStationUrl, windowPoints };
13
+ export { CALM_THRESHOLD_MPS, CHART_FALLBACK_WIDTH, COMPASS_POINTS, DAILY_PATTERN_DEFAULT_SLOT_MINUTES, DIAL_CARDINALS, DIAL_CARDINAL_TICK_INNER, DIAL_CENTRE, DIAL_COUNTERWEIGHT_RADIUS, DIAL_COUNTERWEIGHT_REACH, DIAL_HUB_RADIUS, DIAL_LETTER_RADIUS, DIAL_MIN_MAX_MPS, DIAL_RING_RADIUS, DIAL_SIZE, DIAL_TICK_INNER, METEOROLOGICAL_SEASON_MONTHS, ROSE_CARDINAL_LETTERS, ROSE_CENTRE, ROSE_FAVORABLE_RING_RADIUS, ROSE_HUB_DOT_RADIUS, ROSE_HUB_RADIUS, ROSE_INTERCARDINAL_BEARINGS, ROSE_LETTER_RADIUS, ROSE_MAX_RADIUS, ROSE_PETAL_FILL, ROSE_SIZE, ROSE_TICK_REACH, SAMPLE_GAP_TOLERANCE_FACTOR, SPARKLINE_EDGE_INSET, SPARKLINE_MAX_PADDING, STATION_SCHEMA_VERSION, UNAVAILABLE_REASONS, airConditionsSchema, airRows, airSummary, averagePoints, bandPoints, bandStrips, capabilitiesSchema, chartFrame, chartScales, compareTracePoints, compareWindow, compassDirection, currentEndpoint, dailyPattern, defaultFormatTime, defaultStrings, dialNeedlePoints, dialPolar, dialScaleMaxMps, dialSpeedArcPath, directionCell, emptyConditions, feedEndpoint, filterByMonth, filterByTimeOfDay, foldCurrent, freshness, historyGaps, meanDirectionDeg as historyMeanDirectionDeg, historyPointSchema, historyRuns, historySchema, isCalm, lastStrikeWords, liveEndpoint, liveSampleSchema, liveSamplesSchema, localeFormatTime, measuredChartWidth, mergeCurrent, mergeStringOverrides, nearestIndex, normalizeDegrees, normalizeWindnerdStationKey, optionalSpeed, parseStationCurrent, parseStationCurrentJson, parseStationFeed, parseStationFeedJson, parseStationLiveFrame, parseStationLiveFrameJson, periodSummary, pressureTendency, readingSchema, requireResolved, resolveDisplay, resolveStation, resolveStrings, rosePetalPath, rosePolar, roseRingArcPath, roundSpeed, sampleMeanDirectionDeg, samplePoints, sampleRuns, sampleScales, samplesSummary, seaLevelPressureHpa, sparklineScale, speedBand, speedFromMps, speedToMps, speedUnitLabel, stationCurrentSchema, stationFeedSchema, stationFreshnessThresholds, stationLiveFrameSchema, stationMetaSchema, stationSchema, summaryEntries, telemetrySchema, temperatureText, temperatureValue, thinSampleVanes, thinVanes, thresholdsToMps, tickAnchor, unavailableStation, updatedAtText, vanePath, vaneTicks, windRose, windnerdStationUrl, windowPoints };
@@ -1,8 +1,7 @@
1
1
  "use client";
2
2
  import "../../derive.js";
3
3
  import { resolveDisplay } from "../../display.js";
4
- import "../../geometry.js";
5
- import { measuredChartWidth } from "../../scene/chart.js";
4
+ import { measuredChartWidth } from "../../geometry.js";
6
5
  import { DAILY_PATTERN_CLASS, dailyPatternGate, dailyPatternScene, dailyPatternSource } from "../../scene/daily-pattern.js";
7
6
  import { resolveStation, useStationFeedContext } from "./StationFeedProvider.js";
8
7
  import "./WindArrow.js";
@@ -0,0 +1,12 @@
1
+ import { ReadoutPart } from "../../scene/chart.js";
2
+ import "../../scene/index.js";
3
+ //#region src/react/components/Readout.d.ts
4
+ declare function Readout({ ariaLabel, ariaLive, className, strong, parts }: {
5
+ ariaLabel: string;
6
+ ariaLive: "off" | "polite";
7
+ className: string;
8
+ strong: string;
9
+ parts: ReadoutPart[];
10
+ }): import("react").JSX.Element;
11
+ //#endregion
12
+ export { Readout };
@@ -0,0 +1,14 @@
1
+ "use client";
2
+ import { WindArrow } from "./WindArrow.js";
3
+ import { jsx, jsxs } from "react/jsx-runtime";
4
+ //#region src/react/components/Readout.tsx
5
+ function Readout({ ariaLabel, ariaLive, className, strong, parts }) {
6
+ return /* @__PURE__ */ jsxs("output", {
7
+ "aria-label": ariaLabel,
8
+ "aria-live": ariaLive,
9
+ className,
10
+ children: [/* @__PURE__ */ jsx("strong", { children: strong }), /* @__PURE__ */ jsx("span", { children: parts.map((part, index) => part.kind === "arrow" ? /* @__PURE__ */ jsx(WindArrow, { deg: part.deg }, index) : part.text) })]
11
+ });
12
+ }
13
+ //#endregion
14
+ export { Readout };
@@ -1,6 +1,7 @@
1
1
  "use client";
2
2
  import { resolveDisplay } from "../../display.js";
3
- import { activeChartIndex, chartIndexAtClient, measuredChartWidth, readoutAriaLive, togglePinnedAt } from "../../scene/chart.js";
3
+ import { measuredChartWidth } from "../../geometry.js";
4
+ import { activeChartIndex, chartIndexAtClient, readoutAriaLive, togglePinnedAt } from "../../scene/chart.js";
4
5
  import { TREND_CLASS, trendGate, trendScene } from "../../scene/trend.js";
5
6
  import { requireResolved, resolveStation, useStationFeedContext } from "./StationFeedProvider.js";
6
7
  import { useEffect, useRef, useState } from "react";
@@ -1,10 +1,11 @@
1
1
  "use client";
2
2
  import { resolveDisplay } from "../../display.js";
3
- import { activeChartIndex, chartIndexAtClient, measuredChartWidth, readoutAriaLive, togglePinnedAt } from "../../scene/chart.js";
3
+ import { activeChartIndex, chartIndexAtClient, readoutAriaLive, togglePinnedAt } from "../../scene/chart.js";
4
4
  import { WIND_CHART_CLASS, windChartGate, windChartScene } from "../../scene/wind-history.js";
5
5
  import { requireResolved, resolveStation, useStationFeedContext } from "./StationFeedProvider.js";
6
- import { WindArrow } from "./WindArrow.js";
7
- import { useEffect, useId, useRef, useState } from "react";
6
+ import { Readout } from "./Readout.js";
7
+ import { useMeasuredChartWidth } from "../hooks/useMeasuredChartWidth.js";
8
+ import { useId, useRef, useState } from "react";
8
9
  import { Fragment, jsx, jsxs } from "react/jsx-runtime";
9
10
  //#region src/react/components/WindHistoryChart.tsx
10
11
  function WindHistoryChart({ station: stationProp, stationId, thresholds: thresholdsProp, unit: unitProp, plotHeight, windowHours, compareOffsetDays, strings: stringsProp, formatTime: formatTimeProp }) {
@@ -17,21 +18,8 @@ function WindHistoryChart({ station: stationProp, stationId, thresholds: thresho
17
18
  unit: unitProp
18
19
  });
19
20
  const wrapRef = useRef(null);
20
- const [width, setWidth] = useState(null);
21
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"]);
22
+ const width = useMeasuredChartWidth(wrapRef, { enabled: gate.kind === "draw" });
35
23
  if (gate.kind === "hidden") return null;
36
24
  if (gate.kind === "note") return /* @__PURE__ */ jsx("div", {
37
25
  className: gate.className,
@@ -55,9 +43,6 @@ function WindHistoryChart({ station: stationProp, stationId, thresholds: thresho
55
43
  })
56
44
  });
57
45
  }
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
46
  function MeasuredChart({ compareOffsetDays, formatTime, history, plotHeight, stationName, thresholds, unit, width, windowHours, words }) {
62
47
  const hatchId = `meteo-hatch-${useId().replace(/[^a-zA-Z0-9_-]/g, "")}`;
63
48
  const [pinnedAt, setPinnedAt] = useState(null);
@@ -94,11 +79,12 @@ function MeasuredChart({ compareOffsetDays, formatTime, history, plotHeight, sta
94
79
  setPinnedAt((current) => togglePinnedAt(current, observedAt));
95
80
  setPreviewIndex(null);
96
81
  };
97
- return /* @__PURE__ */ jsxs(Fragment, { children: [/* @__PURE__ */ jsxs("output", {
98
- "aria-label": scene.readout.ariaLabel,
99
- "aria-live": readoutAriaLive(previewIndex),
82
+ return /* @__PURE__ */ jsxs(Fragment, { children: [/* @__PURE__ */ jsx(Readout, {
83
+ ariaLabel: scene.readout.ariaLabel,
84
+ ariaLive: readoutAriaLive(previewIndex),
100
85
  className: scene.readout.className,
101
- children: [/* @__PURE__ */ jsx("strong", { children: readout.strong }), /* @__PURE__ */ jsx(ReadoutSpan, { parts: readout.span })]
86
+ parts: readout.span,
87
+ strong: readout.strong
102
88
  }), /* @__PURE__ */ jsxs("svg", {
103
89
  "aria-label": scene.svg.ariaLabel,
104
90
  className: scene.svg.className,
@@ -0,0 +1,15 @@
1
+ import { LiveSamples } 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/WindSampleStrip.d.ts
6
+ declare function WindSampleStrip({ samples, stationName, unit: unitProp, plotHeight, strings: stringsProp, formatTime: formatTimeProp }: {
7
+ samples: LiveSamples | null | undefined;
8
+ stationName: string;
9
+ unit?: SpeedUnit;
10
+ plotHeight?: number;
11
+ strings?: StationStringOverrides;
12
+ formatTime?: FormatTime;
13
+ }): import("react").JSX.Element;
14
+ //#endregion
15
+ export { WindSampleStrip };
@@ -0,0 +1,192 @@
1
+ "use client";
2
+ import { resolveDisplay } from "../../display.js";
3
+ import { activeChartIndex, chartIndexAtClient, readoutAriaLive, togglePinnedAt } from "../../scene/chart.js";
4
+ import { SAMPLE_STRIP_CLASS, sampleStripGate, sampleStripScene } from "../../scene/sample-strip.js";
5
+ import { useStationFeedContext } from "./StationFeedProvider.js";
6
+ import { Readout } from "./Readout.js";
7
+ import { useMeasuredChartWidth } from "../hooks/useMeasuredChartWidth.js";
8
+ import { useRef, useState } from "react";
9
+ import { Fragment, jsx, jsxs } from "react/jsx-runtime";
10
+ //#region src/react/components/WindSampleStrip.tsx
11
+ function WindSampleStrip({ samples, stationName, unit: unitProp, plotHeight, strings: stringsProp, formatTime: formatTimeProp }) {
12
+ const { formatTime, unit, words } = resolveDisplay(useStationFeedContext(), {
13
+ formatTime: formatTimeProp,
14
+ strings: stringsProp,
15
+ unit: unitProp
16
+ });
17
+ const wrapRef = useRef(null);
18
+ const gate = sampleStripGate(samples, words);
19
+ const width = useMeasuredChartWidth(wrapRef, { enabled: gate.kind === "draw" });
20
+ if (gate.kind === "note") return /* @__PURE__ */ jsx("div", {
21
+ className: gate.className,
22
+ role: "note",
23
+ children: gate.text
24
+ });
25
+ return /* @__PURE__ */ jsx("div", {
26
+ className: SAMPLE_STRIP_CLASS,
27
+ ref: wrapRef,
28
+ children: width != null && /* @__PURE__ */ jsx(MeasuredStrip, {
29
+ formatTime,
30
+ plotHeight,
31
+ samples: gate.samples,
32
+ stationName,
33
+ unit,
34
+ width,
35
+ words
36
+ })
37
+ });
38
+ }
39
+ function MeasuredStrip({ formatTime, plotHeight, samples, stationName, unit, width, words }) {
40
+ const [pinnedAt, setPinnedAt] = useState(null);
41
+ const [previewIndex, setPreviewIndex] = useState(null);
42
+ const scene = sampleStripScene({
43
+ formatTime,
44
+ plotHeight,
45
+ samples,
46
+ stationName,
47
+ unit,
48
+ width,
49
+ words
50
+ });
51
+ const { readout, cursor } = scene.inspect(activeChartIndex(scene.points, pinnedAt, previewIndex));
52
+ const indexAtPoint = (clientX, hit) => {
53
+ const svg = hit.ownerSVGElement;
54
+ if (!svg) return null;
55
+ const bounds = svg.getBoundingClientRect();
56
+ return chartIndexAtClient(scene.points, scene.frame, scene.scales, clientX, bounds);
57
+ };
58
+ const handlePointerMove = (event) => {
59
+ if (event.pointerType === "touch") return;
60
+ setPreviewIndex(indexAtPoint(event.clientX, event.currentTarget));
61
+ };
62
+ const handleClick = (event) => {
63
+ const index = indexAtPoint(event.clientX, event.currentTarget);
64
+ if (index == null) return;
65
+ const observedAt = scene.points[index]?.observedAt;
66
+ if (observedAt == null) return;
67
+ setPinnedAt((current) => togglePinnedAt(current, observedAt));
68
+ setPreviewIndex(null);
69
+ };
70
+ return /* @__PURE__ */ jsxs(Fragment, { children: [/* @__PURE__ */ jsx(Readout, {
71
+ ariaLabel: scene.readout.ariaLabel,
72
+ ariaLive: readoutAriaLive(previewIndex),
73
+ className: scene.readout.className,
74
+ parts: readout.span,
75
+ strong: readout.strong
76
+ }), /* @__PURE__ */ jsxs("svg", {
77
+ "aria-label": scene.svg.ariaLabel,
78
+ className: scene.svg.className,
79
+ height: scene.svg.height,
80
+ role: "img",
81
+ viewBox: scene.svg.viewBox,
82
+ width: scene.svg.width,
83
+ children: [
84
+ scene.grid.map(({ key, line, label }) => /* @__PURE__ */ jsxs("g", { children: [/* @__PURE__ */ jsx("line", {
85
+ className: line.className,
86
+ x1: line.x1,
87
+ x2: line.x2,
88
+ y1: line.y1,
89
+ y2: line.y2
90
+ }), /* @__PURE__ */ jsx("text", {
91
+ className: label.className,
92
+ textAnchor: label.anchor,
93
+ x: label.x,
94
+ y: label.y,
95
+ children: label.text
96
+ })] }, key)),
97
+ scene.vaneGuides.map((guide) => /* @__PURE__ */ jsx("line", {
98
+ className: guide.className,
99
+ x1: guide.x1,
100
+ x2: guide.x2,
101
+ y1: guide.y1,
102
+ y2: guide.y2
103
+ }, `guide-${guide.key}`)),
104
+ scene.trace.map((part) => part.kind === "dot" ? /* @__PURE__ */ jsx("circle", {
105
+ className: part.className,
106
+ cx: part.cx,
107
+ cy: part.cy,
108
+ r: part.r
109
+ }, part.key) : /* @__PURE__ */ jsx("polyline", {
110
+ className: part.className,
111
+ points: part.points
112
+ }, part.key)),
113
+ scene.calmNote && /* @__PURE__ */ jsx("text", {
114
+ className: scene.calmNote.className,
115
+ textAnchor: scene.calmNote.anchor,
116
+ x: scene.calmNote.x,
117
+ y: scene.calmNote.y,
118
+ children: scene.calmNote.text
119
+ }),
120
+ /* @__PURE__ */ jsx("text", {
121
+ className: scene.rowLabels.to.className,
122
+ textAnchor: scene.rowLabels.to.anchor,
123
+ x: scene.rowLabels.to.x,
124
+ y: scene.rowLabels.to.y,
125
+ children: scene.rowLabels.to.text
126
+ }),
127
+ scene.vanes.map((vane) => vane.mark.kind === "calm" ? /* @__PURE__ */ jsx("text", {
128
+ className: vane.mark.text.className,
129
+ textAnchor: vane.mark.text.anchor,
130
+ x: vane.mark.text.x,
131
+ y: vane.mark.text.y,
132
+ children: vane.mark.text.text
133
+ }, vane.key) : /* @__PURE__ */ jsx("path", {
134
+ className: vane.mark.className,
135
+ d: vane.mark.d
136
+ }, vane.key)),
137
+ scene.vanes.map((vane) => /* @__PURE__ */ jsx("text", {
138
+ className: vane.label.className,
139
+ textAnchor: vane.label.anchor,
140
+ x: vane.label.x,
141
+ y: vane.label.y,
142
+ children: vane.label.text
143
+ }, `label-${vane.key}`)),
144
+ /* @__PURE__ */ jsx("text", {
145
+ className: scene.rowLabels.avg.className,
146
+ textAnchor: scene.rowLabels.avg.anchor,
147
+ x: scene.rowLabels.avg.x,
148
+ y: scene.rowLabels.avg.y,
149
+ children: scene.rowLabels.avg.text
150
+ }),
151
+ scene.vanes.map((vane) => /* @__PURE__ */ jsx("text", {
152
+ className: vane.value.className,
153
+ textAnchor: vane.value.anchor,
154
+ x: vane.value.x,
155
+ y: vane.value.y,
156
+ children: vane.value.text
157
+ }, `value-${vane.key}`)),
158
+ scene.ticks.map((tick) => /* @__PURE__ */ jsx("text", {
159
+ className: tick.className,
160
+ textAnchor: tick.anchor,
161
+ x: tick.x,
162
+ y: tick.y,
163
+ children: tick.text
164
+ }, tick.key)),
165
+ cursor && /* @__PURE__ */ jsxs(Fragment, { children: [/* @__PURE__ */ jsx("line", {
166
+ className: cursor.line.className,
167
+ x1: cursor.line.x1,
168
+ x2: cursor.line.x2,
169
+ y1: cursor.line.y1,
170
+ y2: cursor.line.y2
171
+ }), /* @__PURE__ */ jsx("circle", {
172
+ className: cursor.dot.className,
173
+ cx: cursor.dot.cx,
174
+ cy: cursor.dot.cy,
175
+ r: cursor.dot.r
176
+ })] }),
177
+ /* @__PURE__ */ jsx("rect", {
178
+ className: scene.hit.className,
179
+ fill: scene.hit.fill,
180
+ height: scene.hit.height,
181
+ onClick: handleClick,
182
+ onPointerLeave: () => setPreviewIndex(null),
183
+ onPointerMove: handlePointerMove,
184
+ width: scene.hit.width,
185
+ x: scene.hit.x,
186
+ y: scene.hit.y
187
+ })
188
+ ]
189
+ })] });
190
+ }
191
+ //#endregion
192
+ export { WindSampleStrip };
@@ -0,0 +1,8 @@
1
+ //#region src/react/hooks/useMeasuredChartWidth.d.ts
2
+ declare function useMeasuredChartWidth(ref: {
3
+ readonly current: Element | null;
4
+ }, { enabled }?: {
5
+ enabled?: boolean;
6
+ }): number | null;
7
+ //#endregion
8
+ export { useMeasuredChartWidth };
@@ -0,0 +1,26 @@
1
+ "use client";
2
+ import { measuredChartWidth } from "../../geometry.js";
3
+ import { useEffect, useLayoutEffect, useState } from "react";
4
+ //#region src/react/hooks/useMeasuredChartWidth.ts
5
+ const useMeasureEffect = typeof window === "undefined" ? useEffect : useLayoutEffect;
6
+ function useMeasuredChartWidth(ref, { enabled = true } = {}) {
7
+ const [width, setWidth] = useState(null);
8
+ useMeasureEffect(() => {
9
+ const element = ref.current;
10
+ if (!enabled || element == null) return;
11
+ if (typeof ResizeObserver === "undefined") {
12
+ setWidth(360);
13
+ return;
14
+ }
15
+ if (element.clientWidth > 0) setWidth(measuredChartWidth(element.clientWidth));
16
+ const observer = new ResizeObserver((entries) => {
17
+ const measured = entries[0]?.contentRect.width ?? 0;
18
+ if (measured > 0) setWidth(measuredChartWidth(measured));
19
+ });
20
+ observer.observe(element);
21
+ return () => observer.disconnect();
22
+ }, [ref, enabled]);
23
+ return width;
24
+ }
25
+ //#endregion
26
+ export { useMeasuredChartWidth };
@@ -10,12 +10,17 @@ import { StationStrip } from "./components/StationStrip.js";
10
10
  import { TrendChart } from "./components/TrendChart.js";
11
11
  import { WindArrow } from "./components/WindArrow.js";
12
12
  import { DailyPattern } from "./components/DailyPattern.js";
13
+ import { ReadoutPart } from "../scene/chart.js";
14
+ import "../scene/index.js";
15
+ import { Readout } from "./components/Readout.js";
13
16
  import { WindHistoryChart } from "./components/WindHistoryChart.js";
14
17
  import { WindRose } from "./components/WindRose.js";
18
+ import { WindSampleStrip } from "./components/WindSampleStrip.js";
15
19
  import { StationCard, StationCardChart, StationCardHeader, StationCardInstrument, StationCardSummary } from "./components/StationCard.js";
16
20
  import { useFreshness } from "./hooks/useFreshness.js";
21
+ import { useMeasuredChartWidth } from "./hooks/useMeasuredChartWidth.js";
17
22
  import { useStation } from "./hooks/useStation.js";
18
23
  import { useStationCurrent } from "./hooks/useStationCurrent.js";
19
24
  import { useStationFeed } from "./hooks/useStationFeed.js";
20
25
  import { useStationLive } from "./hooks/useStationLive.js";
21
- export { AirMatrix, BandChip, CurrentConditions, DailyPattern, Dial, Direction, FreshnessBadge, Gust, Lull, Pressure, Sparkline, Speed, StationCard, StationCardChart, StationCardHeader, StationCardInstrument, StationCardSummary, type StationFeedContextValue, StationFeedProvider, type StationMetaRenderer, StationStrip, StationTable, Temperature, TrendChart, UpdatedAt, WindArrow, WindHistoryChart, WindRose, useFreshness, useStation, useStationCurrent, useStationFeed, useStationFeedContext, useStationLive };
26
+ export { AirMatrix, BandChip, CurrentConditions, DailyPattern, Dial, Direction, FreshnessBadge, Gust, Lull, Pressure, Readout, type ReadoutPart, Sparkline, Speed, StationCard, StationCardChart, StationCardHeader, StationCardInstrument, StationCardSummary, type StationFeedContextValue, StationFeedProvider, type StationMetaRenderer, StationStrip, StationTable, Temperature, TrendChart, UpdatedAt, WindArrow, WindHistoryChart, WindRose, WindSampleStrip, useFreshness, useMeasuredChartWidth, useStation, useStationCurrent, useStationFeed, useStationFeedContext, useStationLive };
@@ -12,11 +12,14 @@ import { StationTable } from "./components/StationTable.js";
12
12
  import { StationStrip } from "./components/StationStrip.js";
13
13
  import { TrendChart } from "./components/TrendChart.js";
14
14
  import { DailyPattern } from "./components/DailyPattern.js";
15
+ import { Readout } from "./components/Readout.js";
16
+ import { useMeasuredChartWidth } from "./hooks/useMeasuredChartWidth.js";
15
17
  import { WindHistoryChart } from "./components/WindHistoryChart.js";
16
18
  import { WindRose } from "./components/WindRose.js";
19
+ import { WindSampleStrip } from "./components/WindSampleStrip.js";
17
20
  import { StationCard, StationCardChart, StationCardHeader, StationCardInstrument, StationCardSummary } from "./components/StationCard.js";
18
21
  import { useStationCurrent } from "./hooks/useStationCurrent.js";
19
22
  import { useStationFeed } from "./hooks/useStationFeed.js";
20
23
  import { useStationLive } from "./hooks/useStationLive.js";
21
24
  import { useStation } from "./hooks/useStation.js";
22
- export { AirMatrix, BandChip, CurrentConditions, DailyPattern, Dial, Direction, FreshnessBadge, Gust, Lull, Pressure, Sparkline, Speed, StationCard, StationCardChart, StationCardHeader, StationCardInstrument, StationCardSummary, StationFeedProvider, StationStrip, StationTable, Temperature, TrendChart, UpdatedAt, WindArrow, WindHistoryChart, WindRose, useFreshness, useStation, useStationCurrent, useStationFeed, useStationFeedContext, useStationLive };
25
+ export { AirMatrix, BandChip, CurrentConditions, DailyPattern, Dial, Direction, FreshnessBadge, Gust, Lull, Pressure, Readout, Sparkline, Speed, StationCard, StationCardChart, StationCardHeader, StationCardInstrument, StationCardSummary, StationFeedProvider, StationStrip, StationTable, Temperature, TrendChart, UpdatedAt, WindArrow, WindHistoryChart, WindRose, WindSampleStrip, useFreshness, useMeasuredChartWidth, useStation, useStationCurrent, useStationFeed, useStationFeedContext, useStationLive };
@@ -0,0 +1,2 @@
1
+ import "../contract.js";
2
+ import "../strings.js";
@@ -0,0 +1,4 @@
1
+ import "../contract.js";
2
+ import "../derive.js";
3
+ import "../strings.js";
4
+ import "../format.js";
@@ -0,0 +1,3 @@
1
+ import "../contract.js";
2
+ import "../derive.js";
3
+ import "../strings.js";
@@ -0,0 +1,11 @@
1
+ import { TickAnchor, measuredChartWidth, tickAnchor } from "../geometry.js";
2
+ //#region src/scene/chart.d.ts
3
+ type ReadoutPart = {
4
+ kind: "text";
5
+ text: string;
6
+ } | {
7
+ kind: "arrow";
8
+ deg: number;
9
+ };
10
+ //#endregion
11
+ export { ReadoutPart };
@@ -1,11 +1,5 @@
1
- import { nearestIndex } from "../geometry.js";
1
+ import { measuredChartWidth, nearestIndex, tickAnchor } from "../geometry.js";
2
2
  //#region src/scene/chart.ts
3
- function tickAnchor(index, lastIndex) {
4
- return index === 0 ? "start" : index === lastIndex ? "end" : "middle";
5
- }
6
- function measuredChartWidth(measured) {
7
- return measured > 0 ? Math.round(measured) : 360;
8
- }
9
3
  function pinnedIndexOf(points, pinnedAt) {
10
4
  if (pinnedAt == null) return null;
11
5
  const found = points.findIndex((point) => point.observedAt === pinnedAt);
@@ -0,0 +1,3 @@
1
+ import "../contract.js";
2
+ import "../derive.js";
3
+ import "../strings.js";
@@ -0,0 +1,6 @@
1
+ import "../contract.js";
2
+ import "../derive.js";
3
+ import "../strings.js";
4
+ import "../geometry.js";
5
+ import "./chart.js";
6
+ import "./wind-plot.js";
@@ -0,0 +1,4 @@
1
+ import "../contract.js";
2
+ import "../derive.js";
3
+ import "../strings.js";
4
+ import "./wind-plot.js";