@azohra/meteo.station 0.6.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.
Files changed (128) hide show
  1. package/README.md +17 -17
  2. package/dist/connectivity.d.ts +2 -2
  3. package/dist/contract.d.ts +105 -105
  4. package/dist/derive.js +4 -4
  5. package/dist/elements/elements/AirExtremesElement.js +5 -18
  6. package/dist/elements/elements/AirMatrixElement.js +6 -31
  7. package/dist/elements/elements/ClimatologyDailyPatternElement.js +17 -12
  8. package/dist/elements/elements/ClimatologyRoseElement.js +5 -15
  9. package/dist/elements/elements/CompassFanElement.js +5 -64
  10. package/dist/elements/elements/CurrentConditionsElement.js +7 -26
  11. package/dist/elements/elements/DailyPatternElement.d.ts +0 -1
  12. package/dist/elements/elements/DailyPatternElement.js +6 -120
  13. package/dist/elements/elements/DialElement.js +3 -95
  14. package/dist/elements/elements/FavorableShareElement.js +6 -21
  15. package/dist/elements/elements/RecentSummariesElement.js +6 -23
  16. package/dist/elements/elements/SparklineElement.d.ts +0 -1
  17. package/dist/elements/elements/SparklineElement.js +4 -39
  18. package/dist/elements/elements/StationCardElement.js +4 -18
  19. package/dist/elements/elements/StationFeedElement.js +4 -2
  20. package/dist/elements/elements/StationStripElement.js +4 -18
  21. package/dist/elements/elements/StationTableElement.js +15 -51
  22. package/dist/elements/elements/TrendChartElement.js +21 -69
  23. package/dist/elements/elements/WindHistoryChartElement.js +23 -164
  24. package/dist/elements/elements/WindRoseElement.d.ts +0 -1
  25. package/dist/elements/elements/WindRoseElement.js +6 -70
  26. package/dist/elements/elements/atoms.d.ts +1 -1
  27. package/dist/elements/elements/atoms.js +11 -38
  28. package/dist/elements/index.js +3 -3
  29. package/dist/elements/lib/fragments.js +8 -37
  30. package/dist/elements/lib/h.js +1 -1
  31. package/dist/elements/lib/render.js +30 -0
  32. package/dist/geometry.js +2 -1
  33. package/dist/instruments.js +2 -2
  34. package/dist/react/components/AirExtremes.d.ts +1 -1
  35. package/dist/react/components/AirExtremes.js +5 -22
  36. package/dist/react/components/AirMatrix.js +10 -43
  37. package/dist/react/components/ClimatologyDailyPattern.d.ts +1 -1
  38. package/dist/react/components/ClimatologyDailyPattern.js +19 -13
  39. package/dist/react/components/ClimatologyRose.d.ts +1 -1
  40. package/dist/react/components/ClimatologyRose.js +11 -28
  41. package/dist/react/components/CompassFan.d.ts +1 -1
  42. package/dist/react/components/CompassFan.js +6 -73
  43. package/dist/react/components/CurrentConditions.d.ts +1 -1
  44. package/dist/react/components/CurrentConditions.js +11 -74
  45. package/dist/react/components/DailyPattern.d.ts +1 -3
  46. package/dist/react/components/DailyPattern.js +10 -149
  47. package/dist/react/components/Dial.d.ts +1 -1
  48. package/dist/react/components/Dial.js +5 -118
  49. package/dist/react/components/FavorableShare.d.ts +1 -1
  50. package/dist/react/components/FavorableShare.js +6 -27
  51. package/dist/react/components/FreshnessBadge.d.ts +1 -1
  52. package/dist/react/components/FreshnessBadge.js +5 -12
  53. package/dist/react/components/RecentSummaries.d.ts +1 -1
  54. package/dist/react/components/RecentSummaries.js +6 -44
  55. package/dist/react/components/SceneTree.js +38 -0
  56. package/dist/react/components/Sparkline.d.ts +1 -1
  57. package/dist/react/components/Sparkline.js +3 -39
  58. package/dist/react/components/StationCard.d.ts +2 -2
  59. package/dist/react/components/StationCard.js +5 -45
  60. package/dist/react/components/StationStrip.d.ts +1 -1
  61. package/dist/react/components/StationStrip.js +5 -60
  62. package/dist/react/components/StationTable.js +21 -75
  63. package/dist/react/components/TrendChart.js +8 -63
  64. package/dist/react/components/WindArrow.d.ts +1 -1
  65. package/dist/react/components/WindArrow.js +3 -15
  66. package/dist/react/components/WindHistoryChart.js +8 -182
  67. package/dist/react/components/WindRose.d.ts +1 -3
  68. package/dist/react/components/WindRose.js +6 -89
  69. package/dist/react/components/WindSampleStrip.js +8 -115
  70. package/dist/react/components/atoms.d.ts +5 -5
  71. package/dist/react/components/atoms.js +12 -48
  72. package/dist/react/hooks/useStationCurrent.js +3 -2
  73. package/dist/react/hooks/useStationFeed.js +3 -2
  74. package/dist/react/index.d.ts +2 -2
  75. package/dist/react/index.js +5 -5
  76. package/dist/react/lib/cells.js +4 -24
  77. package/dist/scene/air-extremes.js +12 -27
  78. package/dist/scene/air-matrix.js +45 -58
  79. package/dist/scene/card.js +14 -40
  80. package/dist/scene/cells.d.ts +4 -0
  81. package/dist/scene/cells.js +51 -0
  82. package/dist/scene/chart.js +2 -1
  83. package/dist/scene/climatology-pattern.d.ts +1 -2
  84. package/dist/scene/climatology-pattern.js +10 -11
  85. package/dist/scene/climatology-rose.d.ts +1 -2
  86. package/dist/scene/climatology-rose.js +14 -33
  87. package/dist/scene/compass-fan.js +28 -100
  88. package/dist/scene/current.d.ts +2 -1
  89. package/dist/scene/current.js +29 -56
  90. package/dist/scene/daily-pattern.d.ts +1 -3
  91. package/dist/scene/daily-pattern.js +20 -27
  92. package/dist/scene/dial-parts.d.ts +1 -0
  93. package/dist/scene/dial-parts.js +70 -0
  94. package/dist/scene/dial.d.ts +1 -2
  95. package/dist/scene/dial.js +48 -136
  96. package/dist/scene/favorable-share.js +16 -33
  97. package/dist/scene/glyphs.js +20 -16
  98. package/dist/scene/index.d.ts +5 -3
  99. package/dist/scene/node.js +19 -0
  100. package/dist/scene/recent-summaries.js +26 -63
  101. package/dist/scene/rose.js +89 -117
  102. package/dist/scene/sample-strip.d.ts +1 -2
  103. package/dist/scene/sample-strip.js +35 -36
  104. package/dist/scene/sparkline.js +31 -40
  105. package/dist/scene/strip.js +18 -57
  106. package/dist/scene/table.js +47 -69
  107. package/dist/scene/trend.d.ts +1 -2
  108. package/dist/scene/trend.js +29 -55
  109. package/dist/scene/wind-history.d.ts +1 -2
  110. package/dist/scene/wind-history.js +41 -51
  111. package/dist/scene/wind-plot.js +70 -140
  112. package/dist/server/adapters/campbell.d.ts +7 -7
  113. package/dist/server/adapters/campbell.js +1 -1
  114. package/dist/server/adapters/ecowitt.d.ts +8 -8
  115. package/dist/server/adapters/tempest.d.ts +6 -6
  116. package/dist/server/adapters/windnerd-climatology.js +4 -3
  117. package/dist/server/adapters/windnerd-live.js +3 -2
  118. package/dist/server/adapters/windnerd.d.ts +8 -8
  119. package/dist/server/adapters/windnerd.js +1 -1
  120. package/dist/server/config.d.ts +48 -48
  121. package/dist/server/hologram.js +2 -1
  122. package/package.json +6 -11
  123. package/schema/README.md +1 -1
  124. package/schema/stationclimatology.schema.json +64 -61
  125. package/schema/stationcurrent.schema.json +68 -156
  126. package/schema/stationfeed.schema.json +71 -163
  127. package/schema/stationhistory.schema.json +37 -46
  128. package/schema/stationlive.schema.json +221 -306
@@ -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";
@@ -1,27 +1,27 @@
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
27
  import { useStation } from "./hooks/useStation.js";
@@ -1,29 +1,9 @@
1
1
  "use client";
2
- import { directionCell } from "../../format.js";
3
- import { WindArrow } from "../components/WindArrow.js";
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
- if (station.pageUrl == null) return /* @__PURE__ */ jsx(Fragment, { children: station.name });
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 { DirectionCell, StationNameLink };
9
+ export { StationNameLink };
@@ -1,42 +1,27 @@
1
1
  import { lastNightLowC, pressureDeltaHpa } from "../derive.js";
2
2
  import { temperatureValue } from "../format.js";
3
+ import { el, keyed } from "./node.js";
3
4
  //#region src/scene/air-extremes.ts
4
5
  const AIR_EXTREMES_CLASS = "meteo-air-extremes";
5
6
  const PRESSURE_DELTA_WINDOW_HOURS = 3;
6
- /** hidden without served history — the tiles are functions of it; each tile
7
+ /** Null without served history — the tiles are functions of it; each tile
7
8
  * additionally stays absent when its own inputs are (no coordinates, no
8
9
  * night; no carried pressure, no delta). */
9
- function airExtremesGate(station) {
10
- if (station == null || station.status !== "ok" || station.history == null) return { kind: "hidden" };
11
- return {
12
- kind: "draw",
13
- station
14
- };
15
- }
16
10
  function airExtremesScene(input) {
17
11
  const { nowMs, station, words } = input;
18
- const points = station.history?.points ?? [];
12
+ if (station == null || station.status !== "ok" || station.history == null) return null;
13
+ const points = station.history.points;
14
+ const tile = (key, label, value) => keyed(key, "div", { class: "meteo-air-extremes-tile" }, el("dt", { class: "meteo-microlabel" }, label), el("dd", { class: "meteo-air-extremes-value" }, value));
19
15
  const tiles = [];
20
16
  const night = lastNightLowC(points, station.latitude, station.longitude, nowMs);
21
- if (night != null) tiles.push({
22
- key: "last-night-low",
23
- className: "meteo-air-extremes-tile",
24
- label: words.lastNightLowLabel,
25
- value: `${temperatureValue(night.lowC)} ${words.degC}`
26
- });
17
+ if (night != null) tiles.push(tile("last-night-low", words.lastNightLowLabel, `${temperatureValue(night.lowC)} ${words.degC}`));
27
18
  const delta = pressureDeltaHpa(points, { windowHours: PRESSURE_DELTA_WINDOW_HOURS });
28
- if (delta != null) tiles.push({
29
- key: "pressure-delta",
30
- className: "meteo-air-extremes-tile",
31
- label: words.pressureDeltaLabel(PRESSURE_DELTA_WINDOW_HOURS),
32
- value: `${delta >= 0 ? "+" : "−"}${Math.abs(delta).toFixed(1)} ${words.air.unitHpa}`
33
- });
19
+ if (delta != null) tiles.push(tile("pressure-delta", words.pressureDeltaLabel(PRESSURE_DELTA_WINDOW_HOURS), `${delta >= 0 ? "+" : "−"}${Math.abs(delta).toFixed(1)} ${words.air.unitHpa}`));
34
20
  if (tiles.length === 0) return null;
35
- return {
36
- className: AIR_EXTREMES_CLASS,
37
- ariaLabel: words.aria.airExtremes(station.name),
38
- tiles
39
- };
21
+ return el("dl", {
22
+ "aria-label": words.aria.airExtremes(station.name),
23
+ class: AIR_EXTREMES_CLASS
24
+ }, tiles);
40
25
  }
41
26
  //#endregion
42
- export { AIR_EXTREMES_CLASS, airExtremesGate, airExtremesScene };
27
+ export { AIR_EXTREMES_CLASS, airExtremesScene };
@@ -1,70 +1,57 @@
1
1
  import { airRows, airSummary, lastStrikeWords } from "../air.js";
2
+ import { el, keyed } from "./node.js";
2
3
  //#region src/scene/air-matrix.ts
4
+ /** The disclosure's own words, plus the panel it opens. The shell stays
5
+ * with each binding: the trigger owns expansion state and its handler. */
3
6
  function airMatrixScene(input) {
4
7
  const { formatTime, stations, words } = input;
5
8
  const capable = stations.filter((station) => station.capabilities.conditions);
6
9
  if (capable.length === 0) return null;
7
10
  const firstConditions = capable.map((station) => station.reading?.conditions ?? null).find((conditions) => conditions != null) ?? null;
8
- const cellsOf = (value) => capable.map((station) => ({
9
- key: station.id,
10
- className: "meteo-air-cell",
11
- text: value(station) ?? "—"
12
- }));
13
- const feelsLikeRows = capable.some((station) => station.reading?.windChillC != null) ? [{
14
- key: words.air.feelsLike,
15
- className: "meteo-air-row",
16
- labelClassName: "meteo-air-label",
17
- label: words.air.feelsLike,
18
- unit: words.degC,
19
- cells: cellsOf((station) => station.reading?.windChillC?.toFixed(1) ?? null)
20
- }] : [];
21
- const conditionRows = airRows(words).filter((row) => capable.some((station) => {
11
+ const rowTemplate = { gridTemplateColumns: `minmax(7.5rem, 1.4fr) repeat(${capable.length}, minmax(4.5rem, 1fr))` };
12
+ const cellsOf = (value) => capable.map((station) => keyed(station.id, "span", {
13
+ class: "meteo-air-cell",
14
+ role: "cell"
15
+ }, value(station) ?? "—"));
16
+ const row = (label, unit, cells) => ({
17
+ ...keyed(label, "div", {
18
+ class: "meteo-air-row",
19
+ role: "row"
20
+ }, el("span", {
21
+ class: "meteo-air-label",
22
+ role: "rowheader"
23
+ }, label, el("small", void 0, unit)), cells),
24
+ style: rowTemplate
25
+ });
26
+ const feelsLikeRows = capable.some((station) => station.reading?.windChillC != null) ? [row(words.air.feelsLike, words.degC, cellsOf((station) => station.reading?.windChillC?.toFixed(1) ?? null))] : [];
27
+ const conditionRows = airRows(words).filter((entry) => capable.some((station) => {
22
28
  const conditions = station.reading?.conditions;
23
- return conditions != null && row.value(conditions) != null;
24
- })).map((row) => ({
25
- key: row.label,
26
- className: "meteo-air-row",
27
- labelClassName: "meteo-air-label",
28
- label: row.label,
29
- unit: row.unit,
30
- cells: cellsOf((station) => {
31
- const conditions = station.reading?.conditions;
32
- return conditions == null ? null : row.value(conditions);
33
- })
34
- }));
29
+ return conditions != null && entry.value(conditions) != null;
30
+ })).map((entry) => row(entry.label, entry.unit, cellsOf((station) => {
31
+ const conditions = station.reading?.conditions;
32
+ return conditions == null ? null : entry.value(conditions);
33
+ })));
34
+ const panel = [el("div", {
35
+ "aria-label": words.aria.air(capable.length),
36
+ class: "meteo-air-matrix",
37
+ role: "table"
38
+ }, {
39
+ ...el("div", {
40
+ class: "meteo-air-row meteo-air-head",
41
+ role: "row"
42
+ }, el("span", {
43
+ class: "meteo-air-corner",
44
+ role: "columnheader"
45
+ }), capable.map((station) => keyed(station.id, "span", {
46
+ class: "meteo-microlabel",
47
+ role: "columnheader"
48
+ }, station.name))),
49
+ style: rowTemplate
50
+ }, [...feelsLikeRows, ...conditionRows]), el("p", { class: "meteo-air-note" }, firstConditions == null ? words.air.noStrike : lastStrikeWords(firstConditions, formatTime, words))];
35
51
  return {
36
- className: "meteo-air",
37
- trigger: {
38
- className: "meteo-air-trigger",
39
- title: {
40
- className: "meteo-air-title",
41
- text: words.air.title
42
- },
43
- summary: {
44
- className: "meteo-air-summary",
45
- text: firstConditions == null ? words.air.summaryFallback : airSummary(firstConditions, words)
46
- }
47
- },
48
- panelClassName: "meteo-air-panel",
49
- matrix: {
50
- ariaLabel: words.aria.air(capable.length),
51
- className: "meteo-air-matrix",
52
- gridTemplateColumns: `minmax(7.5rem, 1.4fr) repeat(${capable.length}, minmax(4.5rem, 1fr))`,
53
- head: {
54
- className: "meteo-air-row meteo-air-head",
55
- corner: { className: "meteo-air-corner" },
56
- columnClassName: "meteo-microlabel",
57
- columns: capable.map((station) => ({
58
- key: station.id,
59
- text: station.name
60
- }))
61
- },
62
- rows: [...feelsLikeRows, ...conditionRows]
63
- },
64
- note: {
65
- className: "meteo-air-note",
66
- text: firstConditions == null ? words.air.noStrike : lastStrikeWords(firstConditions, formatTime, words)
67
- }
52
+ title: words.air.title,
53
+ summary: firstConditions == null ? words.air.summaryFallback : airSummary(firstConditions, words),
54
+ panel
68
55
  };
69
56
  }
70
57
  //#endregion
@@ -1,4 +1,6 @@
1
1
  import { summaryEntries } from "../format.js";
2
+ import { el, keyed } from "./node.js";
3
+ import { freshnessBadgeNode } from "./glyphs.js";
2
4
  //#region src/scene/card.ts
3
5
  const STATION_CARD_CLASS = "meteo-station-card";
4
6
  function cardPartThresholds(own, card) {
@@ -7,48 +9,20 @@ function cardPartThresholds(own, card) {
7
9
  function cardPartWiringError(part, provider) {
8
10
  return `${part} must render inside ${provider} — the provider carries the station, clocks, and display settings.`;
9
11
  }
10
- function cardHeaderScene(station, words) {
11
- return {
12
- className: "meteo-station-card-header",
13
- identity: {
14
- className: "meteo-station-card-identity",
15
- name: {
16
- className: "meteo-station-card-name",
17
- link: station.pageUrl == null ? null : {
18
- href: station.pageUrl,
19
- rel: "noreferrer",
20
- target: "_blank",
21
- text: `${station.name} ↗`
22
- },
23
- text: station.name
24
- },
25
- meta: {
26
- className: "meteo-station-card-meta",
27
- source: {
28
- className: "meteo-station-card-source",
29
- text: station.sourceLabel
30
- },
31
- elevation: station.elevationM == null ? null : {
32
- className: "meteo-station-card-elevation",
33
- text: ` · ${words.elevation(Math.round(station.elevationM))}`
34
- }
35
- }
36
- }
37
- };
12
+ function cardHeaderNode(station, freshness, words) {
13
+ return el("header", { class: "meteo-station-card-header" }, el("div", { class: "meteo-station-card-identity" }, el("h3", { class: "meteo-station-card-name" }, station.pageUrl == null ? station.name : el("a", {
14
+ href: station.pageUrl,
15
+ rel: "noreferrer",
16
+ target: "_blank"
17
+ }, `${station.name} \u2197`)), el("p", { class: "meteo-station-card-meta" }, el("span", { class: "meteo-station-card-source" }, station.sourceLabel), station.elevationM == null ? null : el("span", { class: "meteo-station-card-elevation" }, ` \u00b7 ${words.elevation(Math.round(station.elevationM))}`))), freshness != null ? freshnessBadgeNode(freshness, words) : null);
38
18
  }
39
- function summaryScene(station, unit, words, formatTime) {
19
+ function summaryNode(station, unit, words, formatTime) {
40
20
  const summary = summaryEntries(station, unit, words, formatTime);
41
21
  if (summary == null) return null;
42
- return {
43
- ariaLabel: words.aria.summary(formatTime(new Date(summary.periodEndedAt))),
44
- className: "meteo-summary",
45
- itemClassName: "meteo-summary-item",
46
- labelClassName: "meteo-microlabel",
47
- items: summary.entries.map((entry) => ({
48
- label: entry.label,
49
- value: entry.value
50
- }))
51
- };
22
+ return el("dl", {
23
+ "aria-label": words.aria.summary(formatTime(new Date(summary.periodEndedAt))),
24
+ class: "meteo-summary"
25
+ }, summary.entries.map((entry) => keyed(entry.label, "div", { class: "meteo-summary-item" }, el("dt", { class: "meteo-microlabel" }, entry.label), el("dd", void 0, entry.value))));
52
26
  }
53
27
  //#endregion
54
- export { STATION_CARD_CLASS, cardHeaderScene, cardPartThresholds, cardPartWiringError, summaryScene };
28
+ export { STATION_CARD_CLASS, cardHeaderNode, cardPartThresholds, cardPartWiringError, summaryNode };
@@ -0,0 +1,4 @@
1
+ import "../contract.js";
2
+ import "../strings.js";
3
+ import "../instruments.js";
4
+ import "./atoms.js";
@@ -0,0 +1,51 @@
1
+ import { directionCell } from "../format.js";
2
+ import { el } from "./node.js";
3
+ import { bandChipScene, directionAtomScene, updatedAtScene } from "./atoms.js";
4
+ import { windArrowNode } from "./glyphs.js";
5
+ //#region src/scene/cells.ts
6
+ /** The direction reading: an arrow plus its compass point, or the word for
7
+ * calm, or a dash — one spelling for both display bindings. */
8
+ function directionCellNodes(windAvgMps, windDirectionDeg, words) {
9
+ const cell = directionCell(windAvgMps, windDirectionDeg);
10
+ if (cell.kind === "calm") return [words.calm];
11
+ if (cell.kind === "dash") return ["—"];
12
+ return [windArrowNode(cell.deg), ` ${cell.compass} ${cell.rounded}°`];
13
+ }
14
+ function stationNameNode(station) {
15
+ if (station.pageUrl == null) return station.name;
16
+ return el("a", {
17
+ href: station.pageUrl,
18
+ rel: "noreferrer",
19
+ target: "_blank"
20
+ }, station.name);
21
+ }
22
+ function valueAtomNode(scene) {
23
+ return el("data", {
24
+ class: scene.className,
25
+ value: scene.value
26
+ }, scene.content.kind === "dash" ? scene.content.text : [scene.content.text, el("span", { class: scene.content.unit.className }, scene.content.unit.text)]);
27
+ }
28
+ function directionAtomNode(station, words, favorableDirections) {
29
+ const scene = directionAtomScene(station, words, favorableDirections);
30
+ if (scene.cell == null) return el("span", { class: scene.className }, scene.dashText);
31
+ return el("span", {
32
+ "aria-label": scene.ariaLabel,
33
+ class: scene.className
34
+ }, directionCellNodes(scene.cell.windAvgMps, scene.cell.windDirectionDeg, words));
35
+ }
36
+ function updatedAtNode(input) {
37
+ const scene = updatedAtScene(input);
38
+ return scene.kind === "dash" ? el("span", { class: scene.className }, scene.text) : el("time", {
39
+ class: scene.className,
40
+ datetime: scene.dateTime
41
+ }, scene.text);
42
+ }
43
+ function bandChipNode(input) {
44
+ const scene = bandChipScene(input);
45
+ return el("span", {
46
+ class: scene.className,
47
+ "data-band": scene.band
48
+ }, scene.text);
49
+ }
50
+ //#endregion
51
+ export { bandChipNode, directionAtomNode, directionCellNodes, stationNameNode, updatedAtNode, valueAtomNode };
@@ -10,7 +10,8 @@ function activeChartIndex(points, pinnedAt, previewIndex) {
10
10
  }
11
11
  function chartIndexAtClient(points, frame, scales, clientX, bounds) {
12
12
  if (bounds.width === 0) return null;
13
- return nearestIndex(points, (clientX - bounds.left) / bounds.width * frame.width, frame, scales);
13
+ const chartX = (clientX - bounds.left) / bounds.width * frame.width;
14
+ return nearestIndex(points, chartX, frame, scales);
14
15
  }
15
16
  function togglePinnedAt(current, observedAt) {
16
17
  return current === observedAt ? null : observedAt;
@@ -2,5 +2,4 @@ import "../contract-climatology.js";
2
2
  import "../derive.js";
3
3
  import "../strings.js";
4
4
  import "../instruments.js";
5
- import "../climatology.js";
6
- import "./daily-pattern.js";
5
+ import "../climatology.js";
@@ -1,23 +1,22 @@
1
1
  import { climatologyCoverage, climatologyPattern } from "../climatology.js";
2
+ import { el } from "./node.js";
2
3
  import { dailyPatternSlotsScene } from "./daily-pattern.js";
3
4
  //#region src/scene/climatology-pattern.ts
4
5
  const CLIMATOLOGY_PATTERN_CLASS = "meteo-climatology-daily-pattern";
5
- function climatologyPatternGate(document, words) {
6
- if (document == null || document.cells.length === 0) return {
7
- kind: "note",
8
- className: `${CLIMATOLOGY_PATTERN_CLASS} meteo-climatology-daily-pattern-na`,
9
- text: words.noClimatology
10
- };
11
- return {
12
- kind: "draw",
13
- document
14
- };
6
+ /** Whether the cube has anything to draw — the bindings consult it to
7
+ * decide whether to keep a width observer alive. */
8
+ function hasClimatology(document) {
9
+ return document != null && document.cells.length > 0;
15
10
  }
16
11
  /** The cube's typical day through the daily-pattern drawing. The coverage
17
12
  * percentage rides only the unfiltered view — the ledger cannot vouch for a
18
13
  * filtered slice, which captions a plain sample count instead. */
19
14
  function climatologyPatternScene(input) {
20
15
  const { document, filters, ...rest } = input;
16
+ if (document == null || document.cells.length === 0) return [el("div", {
17
+ class: "meteo-climatology-daily-pattern meteo-climatology-daily-pattern-na",
18
+ role: "note"
19
+ }, rest.words.noClimatology)];
21
20
  const slots = climatologyPattern(document, filters);
22
21
  const totalSamples = slots.reduce((sum, slot) => sum + slot.sampleCount, 0);
23
22
  const coverage = filters?.months == null ? climatologyCoverage(document) : null;
@@ -32,4 +31,4 @@ function climatologyPatternScene(input) {
32
31
  });
33
32
  }
34
33
  //#endregion
35
- export { CLIMATOLOGY_PATTERN_CLASS, climatologyPatternGate, climatologyPatternScene };
34
+ export { CLIMATOLOGY_PATTERN_CLASS, climatologyPatternScene, hasClimatology };
@@ -1,5 +1,4 @@
1
1
  import "../contract-climatology.js";
2
2
  import "../strings.js";
3
3
  import "../instruments.js";
4
- import "../climatology.js";
5
- import "./rose.js";
4
+ import "../climatology.js";
@@ -1,22 +1,22 @@
1
1
  import { climatologyCoverage, climatologyFavorableShare, climatologyRose } from "../climatology.js";
2
+ import { el, keyed } from "./node.js";
2
3
  import { windRoseScene } from "./rose.js";
3
4
  //#region src/scene/climatology-rose.ts
4
5
  const CLIMATOLOGY_ROSE_CLASS = "meteo-climatology-rose";
5
- function climatologyRoseGate(document, words) {
6
- if (document == null || document.cells.length === 0) return {
7
- kind: "note",
8
- className: `${CLIMATOLOGY_ROSE_CLASS} meteo-climatology-rose-na`,
9
- text: words.noClimatology
10
- };
11
- return {
12
- kind: "draw",
13
- document
14
- };
15
- }
16
6
  function climatologyRoseScene(input) {
17
7
  const { document, favorableDirections, filters, stationName, words } = input;
8
+ if (document == null || document.cells.length === 0) return el("div", {
9
+ class: "meteo-climatology-rose meteo-climatology-rose-na",
10
+ role: "note"
11
+ }, words.noClimatology);
18
12
  const summary = climatologyRose(document, filters);
19
- const rose = windRoseScene({
13
+ const captions = [];
14
+ const arcs = favorableDirections ?? [];
15
+ const share = arcs.length === 0 ? null : climatologyFavorableShare(document, arcs, filters);
16
+ if (share != null) captions.push(keyed("favorable", "p", { class: "meteo-climatology-caption meteo-climatology-caption-favorable" }, words.percentFavorable(Math.round(share * 100))));
17
+ const coverage = filters?.months == null && filters?.slots == null ? climatologyCoverage(document) : null;
18
+ captions.push(keyed("samples", "p", { class: "meteo-climatology-caption" }, coverage != null && coverage.ratio != null ? words.dailyPatternCoverage(summary.sampleCount, Math.round(coverage.ratio * 100)) : words.dailyPatternSamples(summary.sampleCount)));
19
+ return el("div", { class: CLIMATOLOGY_ROSE_CLASS }, windRoseScene({
20
20
  favorableDirections,
21
21
  sectorCount: document.sectorCount,
22
22
  source: [],
@@ -24,26 +24,7 @@ function climatologyRoseScene(input) {
24
24
  summary,
25
25
  thresholds: void 0,
26
26
  words
27
- });
28
- const captions = [];
29
- const arcs = favorableDirections ?? [];
30
- const share = arcs.length === 0 ? null : climatologyFavorableShare(document, arcs, filters);
31
- if (share != null) captions.push({
32
- key: "favorable",
33
- className: "meteo-climatology-caption meteo-climatology-caption-favorable",
34
- text: words.percentFavorable(Math.round(share * 100))
35
- });
36
- const coverage = filters?.months == null && filters?.slots == null ? climatologyCoverage(document) : null;
37
- captions.push({
38
- key: "samples",
39
- className: "meteo-climatology-caption",
40
- text: coverage != null && coverage.ratio != null ? words.dailyPatternCoverage(summary.sampleCount, Math.round(coverage.ratio * 100)) : words.dailyPatternSamples(summary.sampleCount)
41
- });
42
- return {
43
- className: CLIMATOLOGY_ROSE_CLASS,
44
- rose,
45
- captions
46
- };
27
+ }, captions));
47
28
  }
48
29
  //#endregion
49
- export { CLIMATOLOGY_ROSE_CLASS, climatologyRoseGate, climatologyRoseScene };
30
+ export { CLIMATOLOGY_ROSE_CLASS, climatologyRoseScene };
@@ -1,115 +1,43 @@
1
1
  import { isCalm } from "../derive.js";
2
2
  import { vanePath } from "../geometry.js";
3
- import { DIAL_CARDINALS, DIAL_COUNTERWEIGHT_RADIUS, dialNeedlePoints, dialPolar, dialRingArcPath } from "../instruments.js";
3
+ import { dialPolar } from "../instruments.js";
4
+ import { el, keyed } from "./node.js";
5
+ import { dialHub, dialLetters, dialNeedle, dialRing, dialTicks, dialVerdictRing } from "./dial-parts.js";
4
6
  //#region src/scene/compass-fan.ts
5
- const COMPASS_FAN_CLASS = "meteo-compass-fan";
6
7
  const FAN_RADIUS = 58;
7
8
  const FAN_GHOST_STEPS = 10;
8
9
  function compassFanSource(samples, station) {
9
10
  return samples ?? (station?.status === "ok" ? station.samples ?? null : null);
10
11
  }
11
- /** hidden without the declared live capability (when judging a station);
12
- * the no-samples words when the ring is empty. */
13
- function compassFanGate(source, station, words) {
14
- if (station != null && station.capabilities.live !== true) return { kind: "hidden" };
15
- if (source == null || source.points.length === 0) return {
16
- kind: "note",
17
- className: `${COMPASS_FAN_CLASS} meteo-compass-fan-na`,
18
- text: words.noSamples
19
- };
20
- return {
21
- kind: "draw",
22
- samples: source
23
- };
24
- }
12
+ /** Null without the declared live capability (when judging a station); the
13
+ * no-samples words when the ring is empty. */
25
14
  function compassFanScene(input) {
26
- const { favorableDirections, samples, stationName, words } = input;
15
+ const { favorableDirections, samples, station, stationName, words } = input;
16
+ if (station != null && station.capabilities.live !== true) return null;
17
+ if (samples == null || samples.points.length === 0) return el("div", {
18
+ class: "meteo-compass-fan meteo-compass-fan-na",
19
+ role: "note"
20
+ }, words.noSamples);
27
21
  const points = samples.points;
28
22
  const count = points.length;
29
23
  const newest = points[count - 1];
30
24
  const newestBlowing = newest != null && !isCalm(newest.windMps) && newest.windDirectionDeg != null;
31
- return {
32
- svg: {
33
- ariaLabel: words.aria.compassFan(stationName ?? ""),
34
- className: "meteo-compass-fan-svg",
35
- height: 160,
36
- viewBox: `0 0 160 160`,
37
- width: 160
38
- },
39
- ring: {
40
- className: "meteo-wind-dial-ring",
41
- cx: 80,
42
- cy: 80,
43
- r: 70
44
- },
45
- verdictRing: favorableDirections != null && favorableDirections.length > 0 ? {
46
- unfavorable: {
47
- className: "meteo-wind-dial-ring-unfavorable",
48
- cx: 80,
49
- cy: 80,
50
- r: 70
51
- },
52
- favorable: favorableDirections.map((sector) => ({
53
- key: `${sector.fromDeg}-${sector.toDeg}`,
54
- className: "meteo-wind-dial-ring-favorable",
55
- d: dialRingArcPath(sector)
56
- }))
57
- } : null,
58
- ticks: Array.from({ length: 16 }, (_, index) => {
59
- const bearing = index * 22.5;
60
- const cardinal = index % 4 === 0;
61
- const [x1, y1] = dialPolar(bearing, 70);
62
- const [x2, y2] = dialPolar(bearing, cardinal ? 58 : 64);
63
- return {
64
- key: bearing,
65
- className: cardinal ? "meteo-wind-dial-tick meteo-wind-dial-tick-cardinal" : "meteo-wind-dial-tick",
66
- x1,
67
- x2,
68
- y1,
69
- y2
70
- };
71
- }),
72
- letters: DIAL_CARDINALS.map(({ bearing, letter }) => {
73
- const [x, y] = dialPolar(bearing, 46);
74
- return {
75
- key: letter,
76
- className: "meteo-wind-dial-letter",
77
- anchor: "middle",
78
- x,
79
- y: y + 3.5,
80
- text: letter
81
- };
82
- }),
83
- ghosts: points.slice(0, -1).flatMap((sample, index) => {
84
- if (isCalm(sample.windMps) || sample.windDirectionDeg == null) return [];
85
- const decile = Math.min(FAN_GHOST_STEPS - 1, Math.floor((count - 1 - index) / count * FAN_GHOST_STEPS));
86
- const [cx, cy] = dialPolar(sample.windDirectionDeg, FAN_RADIUS);
87
- return [{
88
- key: sample.observedAt,
89
- className: `meteo-fan-ghost-${decile}`,
90
- d: vanePath(cx, cy, sample.windDirectionDeg)
91
- }];
92
- }),
93
- needle: newestBlowing && newest.windDirectionDeg != null ? {
94
- className: "meteo-wind-needle",
95
- blade: {
96
- className: "meteo-wind-needle-blade",
97
- points: dialNeedlePoints(newest.windDirectionDeg)
98
- },
99
- counterweight: {
100
- className: "meteo-wind-needle-counterweight",
101
- cx: dialPolar(newest.windDirectionDeg, 46)[0],
102
- cy: dialPolar(newest.windDirectionDeg, 46)[1],
103
- r: DIAL_COUNTERWEIGHT_RADIUS
104
- }
105
- } : null,
106
- hub: {
107
- className: "meteo-wind-dial-hub",
108
- cx: 80,
109
- cy: 80,
110
- r: 36
111
- }
112
- };
25
+ return el("svg", {
26
+ "aria-label": words.aria.compassFan(stationName ?? ""),
27
+ class: "meteo-compass-fan-svg",
28
+ height: 160,
29
+ role: "img",
30
+ viewBox: `0 0 160 160`,
31
+ width: 160
32
+ }, dialRing(), dialVerdictRing(favorableDirections), dialTicks(), dialLetters(), points.slice(0, -1).flatMap((sample, index) => {
33
+ if (isCalm(sample.windMps) || sample.windDirectionDeg == null) return [];
34
+ const decile = Math.min(9, Math.floor((count - 1 - index) / count * FAN_GHOST_STEPS));
35
+ const [cx, cy] = dialPolar(sample.windDirectionDeg, FAN_RADIUS);
36
+ return [keyed(sample.observedAt, "path", {
37
+ class: `meteo-fan-ghost-${decile}`,
38
+ d: vanePath(cx, cy, sample.windDirectionDeg)
39
+ })];
40
+ }), newestBlowing && newest.windDirectionDeg != null ? dialNeedle(newest.windDirectionDeg) : null, dialHub());
113
41
  }
114
42
  //#endregion
115
- export { COMPASS_FAN_CLASS, compassFanGate, compassFanScene, compassFanSource };
43
+ export { compassFanScene, compassFanSource };