@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.
Files changed (147) hide show
  1. package/README.md +17 -17
  2. package/dist/client/climatology.js +1 -1
  3. package/dist/client/history.js +3 -11
  4. package/dist/client/live.d.ts +2 -1
  5. package/dist/client/live.js +7 -4
  6. package/dist/client/stores.js +10 -2
  7. package/dist/climatology.d.ts +1 -1
  8. package/dist/climatology.js +1 -1
  9. package/dist/connectivity.d.ts +2 -2
  10. package/dist/contract.d.ts +98 -98
  11. package/dist/derive.js +9 -8
  12. package/dist/elements/elements/AirExtremesElement.js +5 -18
  13. package/dist/elements/elements/AirMatrixElement.js +6 -31
  14. package/dist/elements/elements/ClimatologyDailyPatternElement.js +17 -12
  15. package/dist/elements/elements/ClimatologyRoseElement.js +5 -15
  16. package/dist/elements/elements/CompassFanElement.js +5 -64
  17. package/dist/elements/elements/CurrentConditionsElement.js +7 -26
  18. package/dist/elements/elements/DailyPatternElement.d.ts +0 -1
  19. package/dist/elements/elements/DailyPatternElement.js +6 -120
  20. package/dist/elements/elements/DialElement.js +3 -95
  21. package/dist/elements/elements/FavorableShareElement.js +6 -21
  22. package/dist/elements/elements/RecentSummariesElement.js +6 -23
  23. package/dist/elements/elements/SparklineElement.d.ts +0 -1
  24. package/dist/elements/elements/SparklineElement.js +4 -39
  25. package/dist/elements/elements/StationCardElement.js +4 -18
  26. package/dist/elements/elements/StationFeedElement.js +4 -2
  27. package/dist/elements/elements/StationStripElement.js +4 -18
  28. package/dist/elements/elements/StationTableElement.js +15 -51
  29. package/dist/elements/elements/TrendChartElement.js +27 -94
  30. package/dist/elements/elements/WindHistoryChartElement.js +29 -189
  31. package/dist/elements/elements/WindRoseElement.d.ts +0 -1
  32. package/dist/elements/elements/WindRoseElement.js +6 -70
  33. package/dist/elements/elements/atoms.js +11 -38
  34. package/dist/elements/index.js +3 -3
  35. package/dist/elements/lib/fragments.js +8 -37
  36. package/dist/elements/lib/h.js +1 -1
  37. package/dist/elements/lib/pinned-cursor.js +48 -0
  38. package/dist/elements/lib/render.js +30 -0
  39. package/dist/fixtures.d.ts +6 -2
  40. package/dist/fixtures.js +30 -2
  41. package/dist/format.js +7 -3
  42. package/dist/geometry.d.ts +1 -1
  43. package/dist/geometry.js +22 -9
  44. package/dist/instruments.js +2 -2
  45. package/dist/react/components/AirExtremes.d.ts +1 -1
  46. package/dist/react/components/AirExtremes.js +5 -22
  47. package/dist/react/components/AirMatrix.js +10 -43
  48. package/dist/react/components/ClimatologyDailyPattern.d.ts +1 -1
  49. package/dist/react/components/ClimatologyDailyPattern.js +19 -13
  50. package/dist/react/components/ClimatologyRose.d.ts +1 -1
  51. package/dist/react/components/ClimatologyRose.js +11 -28
  52. package/dist/react/components/CompassFan.d.ts +1 -1
  53. package/dist/react/components/CompassFan.js +6 -73
  54. package/dist/react/components/CurrentConditions.d.ts +1 -1
  55. package/dist/react/components/CurrentConditions.js +11 -74
  56. package/dist/react/components/DailyPattern.d.ts +1 -3
  57. package/dist/react/components/DailyPattern.js +10 -149
  58. package/dist/react/components/Dial.d.ts +2 -3
  59. package/dist/react/components/Dial.js +5 -118
  60. package/dist/react/components/FavorableShare.d.ts +1 -1
  61. package/dist/react/components/FavorableShare.js +6 -27
  62. package/dist/react/components/FreshnessBadge.d.ts +1 -1
  63. package/dist/react/components/FreshnessBadge.js +5 -12
  64. package/dist/react/components/RecentSummaries.d.ts +1 -1
  65. package/dist/react/components/RecentSummaries.js +6 -44
  66. package/dist/react/components/SceneTree.js +38 -0
  67. package/dist/react/components/Sparkline.d.ts +1 -1
  68. package/dist/react/components/Sparkline.js +3 -39
  69. package/dist/react/components/StationCard.d.ts +2 -2
  70. package/dist/react/components/StationCard.js +5 -45
  71. package/dist/react/components/StationStrip.d.ts +1 -1
  72. package/dist/react/components/StationStrip.js +5 -60
  73. package/dist/react/components/StationTable.js +21 -75
  74. package/dist/react/components/TrendChart.js +13 -86
  75. package/dist/react/components/WindArrow.d.ts +1 -1
  76. package/dist/react/components/WindArrow.js +3 -15
  77. package/dist/react/components/WindHistoryChart.js +12 -205
  78. package/dist/react/components/WindRose.d.ts +1 -3
  79. package/dist/react/components/WindRose.js +6 -89
  80. package/dist/react/components/WindSampleStrip.js +14 -139
  81. package/dist/react/components/atoms.d.ts +5 -5
  82. package/dist/react/components/atoms.js +12 -48
  83. package/dist/react/hooks/useStation.js +28 -50
  84. package/dist/react/hooks/useStationCurrent.js +3 -2
  85. package/dist/react/hooks/useStationFeed.d.ts +0 -1
  86. package/dist/react/hooks/useStationFeed.js +3 -2
  87. package/dist/react/index.d.ts +2 -2
  88. package/dist/react/index.js +7 -7
  89. package/dist/react/lib/cells.js +4 -24
  90. package/dist/react/lib/use-pinned-cursor.js +32 -0
  91. package/dist/samples.js +7 -43
  92. package/dist/scene/air-extremes.js +12 -27
  93. package/dist/scene/air-matrix.js +45 -58
  94. package/dist/scene/card.js +14 -40
  95. package/dist/scene/cells.d.ts +4 -0
  96. package/dist/scene/cells.js +51 -0
  97. package/dist/scene/chart.js +2 -1
  98. package/dist/scene/climatology-pattern.d.ts +1 -2
  99. package/dist/scene/climatology-pattern.js +10 -11
  100. package/dist/scene/climatology-rose.d.ts +1 -2
  101. package/dist/scene/climatology-rose.js +14 -33
  102. package/dist/scene/compass-fan.js +28 -100
  103. package/dist/scene/current.d.ts +2 -1
  104. package/dist/scene/current.js +29 -56
  105. package/dist/scene/daily-pattern.d.ts +1 -3
  106. package/dist/scene/daily-pattern.js +20 -27
  107. package/dist/scene/dial-parts.d.ts +1 -0
  108. package/dist/scene/dial-parts.js +70 -0
  109. package/dist/scene/dial.d.ts +1 -2
  110. package/dist/scene/dial.js +48 -136
  111. package/dist/scene/favorable-share.js +16 -33
  112. package/dist/scene/glyphs.js +20 -16
  113. package/dist/scene/index.d.ts +5 -3
  114. package/dist/scene/node.js +19 -0
  115. package/dist/scene/recent-summaries.js +26 -66
  116. package/dist/scene/rose.js +89 -117
  117. package/dist/scene/sample-strip.d.ts +1 -2
  118. package/dist/scene/sample-strip.js +35 -36
  119. package/dist/scene/sparkline.js +31 -40
  120. package/dist/scene/strip.js +18 -57
  121. package/dist/scene/table.js +47 -69
  122. package/dist/scene/trend.d.ts +1 -2
  123. package/dist/scene/trend.js +29 -55
  124. package/dist/scene/wind-history.d.ts +1 -2
  125. package/dist/scene/wind-history.js +41 -51
  126. package/dist/scene/wind-plot.js +70 -140
  127. package/dist/server/adapters/campbell.d.ts +7 -7
  128. package/dist/server/adapters/campbell.js +1 -1
  129. package/dist/server/adapters/ecowitt.d.ts +8 -8
  130. package/dist/server/adapters/tempest.d.ts +6 -6
  131. package/dist/server/adapters/windnerd-climatology.js +4 -3
  132. package/dist/server/adapters/windnerd-live.js +3 -2
  133. package/dist/server/adapters/windnerd.d.ts +10 -11
  134. package/dist/server/adapters/windnerd.js +3 -13
  135. package/dist/server/config.d.ts +48 -48
  136. package/dist/server/hologram.js +2 -1
  137. package/dist/server/index.d.ts +2 -2
  138. package/dist/server/index.js +2 -2
  139. package/dist/windnerd.d.ts +3 -1
  140. package/dist/windnerd.js +11 -1
  141. package/package.json +7 -12
  142. package/schema/README.md +3 -3
  143. package/schema/stationclimatology.schema.json +64 -61
  144. package/schema/stationcurrent.schema.json +68 -156
  145. package/schema/stationfeed.schema.json +71 -163
  146. package/schema/stationhistory.schema.json +37 -46
  147. package/schema/stationlive.schema.json +221 -306
@@ -1,8 +1,8 @@
1
1
  import { resolveStation } from "../../display.js";
2
- import { windRoseGate, windRoseScene, windRoseSource } from "../../scene/rose.js";
2
+ import { windRoseScene, windRoseSource } from "../../scene/rose.js";
3
3
  import { numberAttribute } from "../lib/attributes.js";
4
4
  import { MeteoStationElement } from "../lib/base.js";
5
- import { h, hs } from "../lib/h.js";
5
+ import { renderScene } from "../lib/render.js";
6
6
  //#region src/elements/elements/WindRoseElement.ts
7
7
  var WindRoseElement = class extends MeteoStationElement {
8
8
  static observedAttributes = [
@@ -26,79 +26,15 @@ var WindRoseElement = class extends MeteoStationElement {
26
26
  render() {
27
27
  const station = this.station ?? (this.#points == null ? resolveStation(this.ambient()?.feed ?? null, this.getAttribute("station-id") ?? void 0) ?? void 0 : void 0);
28
28
  const { favorableDirections, thresholds, words } = this.display();
29
- const source = windRoseSource(this.#points, station);
30
- const gate = windRoseGate(source, words);
31
- if (gate.kind === "note") {
32
- this.replaceChildren(h("div", {
33
- class: gate.className,
34
- role: "note"
35
- }, gate.text));
36
- return;
37
- }
38
- const scene = windRoseScene({
29
+ this.replaceChildren(renderScene(windRoseScene({
39
30
  favorableDirections,
40
31
  sectorCount: numberAttribute(this.getAttribute("sector-count")) ?? 16,
41
- source,
32
+ source: windRoseSource(this.#points, station),
42
33
  stationName: station?.name,
43
34
  thresholds,
44
35
  words
45
- });
46
- this.replaceChildren(windRoseSceneDom(scene));
36
+ })));
47
37
  }
48
38
  };
49
- /** One scene, one drawing — shared by the history-fed rose above and the
50
- * climatology-fed twin, which appends its caption row as extra children. */
51
- function windRoseSceneDom(scene, ...extraChildren) {
52
- return h("div", { class: scene.className }, hs("svg", {
53
- "aria-label": scene.svg.ariaLabel,
54
- class: scene.svg.className,
55
- height: scene.svg.height,
56
- role: "img",
57
- viewBox: scene.svg.viewBox,
58
- width: scene.svg.width
59
- }, scene.gridCircles.map((circle) => hs("circle", {
60
- class: circle.className,
61
- cx: circle.cx,
62
- cy: circle.cy,
63
- r: circle.r
64
- })), scene.ring != null ? [hs("circle", {
65
- class: scene.ring.unfavorable.className,
66
- cx: scene.ring.unfavorable.cx,
67
- cy: scene.ring.unfavorable.cy,
68
- r: scene.ring.unfavorable.r
69
- }), scene.ring.favorable.map((arc) => hs("path", {
70
- class: arc.className,
71
- d: arc.d
72
- }))] : null, scene.ticks.map((tick) => hs("line", {
73
- class: tick.className,
74
- x1: tick.x1,
75
- x2: tick.x2,
76
- y1: tick.y1,
77
- y2: tick.y2
78
- })), scene.letters.map((letter) => hs("text", {
79
- class: letter.className,
80
- "text-anchor": letter.anchor,
81
- x: letter.x,
82
- y: letter.y
83
- }, letter.text)), scene.petals.map((petal) => hs("path", {
84
- class: petal.className,
85
- d: petal.d
86
- })), scene.ringLabel != null && hs("text", {
87
- class: scene.ringLabel.className,
88
- "text-anchor": scene.ringLabel.anchor,
89
- x: scene.ringLabel.x,
90
- y: scene.ringLabel.y
91
- }, scene.ringLabel.text), hs("circle", {
92
- class: scene.hub.className,
93
- cx: scene.hub.cx,
94
- cy: scene.hub.cy,
95
- r: scene.hub.r
96
- }), hs("circle", {
97
- class: scene.dot.className,
98
- cx: scene.dot.cx,
99
- cy: scene.dot.cy,
100
- r: scene.dot.r
101
- })), scene.calmCaption != null ? h("p", { class: scene.calmCaption.className }, scene.calmCaption.text) : null, ...extraChildren);
102
- }
103
39
  //#endregion
104
- export { WindRoseElement, windRoseSceneDom };
40
+ export { WindRoseElement };
@@ -1,22 +1,15 @@
1
- import { bandChipScene, directionAtomScene, pressureAtomScene, speedAtomScene, temperatureAtomScene, updatedAtScene } from "../../scene/atoms.js";
1
+ import { pressureAtomScene, speedAtomScene, temperatureAtomScene } from "../../scene/atoms.js";
2
+ import { bandChipNode, directionAtomNode, updatedAtNode, valueAtomNode } from "../../scene/cells.js";
2
3
  import { MeteoStationElement } from "../lib/base.js";
3
- import { h } from "../lib/h.js";
4
- import { directionCellNodes } from "../lib/fragments.js";
4
+ import { renderScene } from "../lib/render.js";
5
5
  //#region src/elements/elements/atoms.ts
6
6
  const STATION_ATTRIBUTES = ["station-id", "unit"];
7
- function valueAtomNode(scene) {
8
- const children = scene.content.kind === "dash" ? [scene.content.text] : [scene.content.text, h("span", { class: scene.content.unit.className }, scene.content.unit.text)];
9
- return h("data", {
10
- class: scene.className,
11
- value: scene.value
12
- }, ...children);
13
- }
14
7
  var SpeedAtomElement = class extends MeteoStationElement {
15
8
  static observedAttributes = [...STATION_ATTRIBUTES];
16
9
  render() {
17
10
  const station = this.requiredStation(this.component);
18
11
  const { unit, words } = this.display();
19
- this.replaceChildren(valueAtomNode(speedAtomScene(station, this.kind, unit, words)));
12
+ this.replaceChildren(renderScene(valueAtomNode(speedAtomScene(station, this.kind, unit, words))));
20
13
  }
21
14
  };
22
15
  var SpeedElement = class extends SpeedAtomElement {
@@ -36,7 +29,7 @@ var TemperatureElement = class extends MeteoStationElement {
36
29
  render() {
37
30
  const station = this.requiredStation("meteo-temperature");
38
31
  const { words } = this.display();
39
- this.replaceChildren(valueAtomNode(temperatureAtomScene(station, words)));
32
+ this.replaceChildren(renderScene(valueAtomNode(temperatureAtomScene(station, words))));
40
33
  }
41
34
  };
42
35
  var PressureElement = class extends MeteoStationElement {
@@ -44,7 +37,7 @@ var PressureElement = class extends MeteoStationElement {
44
37
  render() {
45
38
  const station = this.requiredStation("meteo-pressure");
46
39
  const { words } = this.display();
47
- this.replaceChildren(valueAtomNode(pressureAtomScene(station, words)));
40
+ this.replaceChildren(renderScene(valueAtomNode(pressureAtomScene(station, words))));
48
41
  }
49
42
  };
50
43
  var DirectionElement = class extends MeteoStationElement {
@@ -52,15 +45,7 @@ var DirectionElement = class extends MeteoStationElement {
52
45
  render() {
53
46
  const station = this.requiredStation("meteo-direction");
54
47
  const { favorableDirections, words } = this.display();
55
- const scene = directionAtomScene(station, words, favorableDirections);
56
- if (scene.cell == null) {
57
- this.replaceChildren(h("span", { class: scene.className }, scene.dashText));
58
- return;
59
- }
60
- this.replaceChildren(h("span", {
61
- "aria-label": scene.ariaLabel,
62
- class: scene.className
63
- }, ...directionCellNodes(scene.cell.windAvgMps, scene.cell.windDirectionDeg, words)));
48
+ this.replaceChildren(renderScene(directionAtomNode(station, words, favorableDirections)));
64
49
  }
65
50
  };
66
51
  var UpdatedAtElement = class extends MeteoStationElement {
@@ -75,22 +60,14 @@ var UpdatedAtElement = class extends MeteoStationElement {
75
60
  render() {
76
61
  const station = this.requiredStation("meteo-updated-at");
77
62
  const { formatTime, words } = this.display();
78
- const scene = updatedAtScene({
63
+ this.replaceChildren(renderScene(updatedAtNode({
79
64
  formatTime,
80
65
  nowMs: Date.now(),
81
66
  receivedAtMs: this.receivedAtMsValue(),
82
67
  servedAt: this.servedAtValue(),
83
68
  station,
84
69
  words
85
- });
86
- if (scene.kind === "dash") {
87
- this.replaceChildren(h("span", { class: scene.className }, scene.text));
88
- return;
89
- }
90
- this.replaceChildren(h("time", {
91
- class: scene.className,
92
- datetime: scene.dateTime
93
- }, scene.text));
70
+ })));
94
71
  }
95
72
  };
96
73
  var BandChipElement = class extends MeteoStationElement {
@@ -114,17 +91,13 @@ var BandChipElement = class extends MeteoStationElement {
114
91
  render() {
115
92
  const station = this.requiredStation("meteo-band-chip");
116
93
  const { thresholds, unit, words } = this.display();
117
- const scene = bandChipScene({
94
+ this.replaceChildren(renderScene(bandChipNode({
118
95
  labels: this.#labels,
119
96
  station,
120
97
  thresholds,
121
98
  unit,
122
99
  words
123
- });
124
- this.replaceChildren(h("span", {
125
- class: scene.className,
126
- "data-band": scene.band
127
- }, scene.text));
100
+ })));
128
101
  }
129
102
  };
130
103
  //#endregion
@@ -1,14 +1,13 @@
1
1
  import { BandChipElement, DirectionElement, GustElement, LullElement, PressureElement, SpeedElement, TemperatureElement, UpdatedAtElement } from "./elements/atoms.js";
2
2
  import { AirExtremesElement } from "./elements/AirExtremesElement.js";
3
3
  import { AirMatrixElement } from "./elements/AirMatrixElement.js";
4
- import { DailyPatternElement } from "./elements/DailyPatternElement.js";
5
4
  import { ClimatologyDailyPatternElement } from "./elements/ClimatologyDailyPatternElement.js";
6
5
  import { CompassFanElement } from "./elements/CompassFanElement.js";
7
6
  import { RecentSummariesElement } from "./elements/RecentSummariesElement.js";
8
- import { WindRoseElement } from "./elements/WindRoseElement.js";
9
7
  import { ClimatologyRoseElement } from "./elements/ClimatologyRoseElement.js";
10
- import { DialElement } from "./elements/DialElement.js";
11
8
  import { CurrentConditionsElement } from "./elements/CurrentConditionsElement.js";
9
+ import { DailyPatternElement } from "./elements/DailyPatternElement.js";
10
+ import { DialElement } from "./elements/DialElement.js";
12
11
  import { FavorableShareElement } from "./elements/FavorableShareElement.js";
13
12
  import { FreshnessBadgeElement } from "./elements/FreshnessBadgeElement.js";
14
13
  import { SparklineElement } from "./elements/SparklineElement.js";
@@ -18,6 +17,7 @@ import { StationTableElement } from "./elements/StationTableElement.js";
18
17
  import { TrendChartElement } from "./elements/TrendChartElement.js";
19
18
  import { WindArrowElement } from "./elements/WindArrowElement.js";
20
19
  import { WindHistoryChartElement } from "./elements/WindHistoryChartElement.js";
20
+ import { WindRoseElement } from "./elements/WindRoseElement.js";
21
21
  import { StationCardChartElement, StationCardElement, StationCardHeaderElement, StationCardInstrumentElement, StationCardSummaryElement } from "./elements/StationCardElement.js";
22
22
  //#region src/elements/index.ts
23
23
  const meteoElementTags = {
@@ -1,45 +1,16 @@
1
- import { directionCell } from "../../format.js";
2
- import { freshnessBadgeSpec, windArrowSpec } from "../../scene/glyphs.js";
3
- import { h, hs } from "./h.js";
1
+ import { freshnessBadgeNode, windArrowNode } from "../../scene/glyphs.js";
2
+ import { stationNameNode as stationNameNode$1 } from "../../scene/cells.js";
3
+ import { renderScene } from "./render.js";
4
4
  //#region src/elements/lib/fragments.ts
5
5
  function windArrowSvg(deg, size = 12) {
6
- const spec = windArrowSpec(deg, size);
7
- const svg = hs("svg", {
8
- "aria-hidden": "true",
9
- class: spec.className,
10
- height: spec.height,
11
- viewBox: spec.viewBox,
12
- width: spec.width
13
- }, hs("path", {
14
- d: spec.path.d,
15
- fill: spec.path.fill
16
- }));
17
- svg.style.transform = spec.transform;
18
- return svg;
19
- }
20
- function directionCellNodes(windAvgMps, windDirectionDeg, words) {
21
- const cell = directionCell(windAvgMps, windDirectionDeg);
22
- if (cell.kind === "calm") return [words.calm];
23
- if (cell.kind === "dash") return ["—"];
24
- return [windArrowSvg(cell.deg), ` ${cell.compass} ${cell.rounded}°`];
6
+ return renderScene(windArrowNode(deg, size));
25
7
  }
26
8
  function stationNameNode(station) {
27
- if (station.pageUrl == null) return station.name;
28
- return h("a", {
29
- href: station.pageUrl,
30
- rel: "noreferrer",
31
- target: "_blank"
32
- }, station.name);
9
+ const node = stationNameNode$1(station);
10
+ return typeof node === "object" && node !== null ? renderScene(node) : node;
33
11
  }
34
12
  function freshnessBadgeSpan(status, words) {
35
- const spec = freshnessBadgeSpec(status, words);
36
- return h("span", {
37
- class: spec.className,
38
- "data-freshness": spec.status
39
- }, h("span", {
40
- "aria-hidden": "true",
41
- class: spec.dot.className
42
- }), spec.text);
13
+ return renderScene(freshnessBadgeNode(status, words));
43
14
  }
44
15
  //#endregion
45
- export { directionCellNodes, freshnessBadgeSpan, stationNameNode, windArrowSvg };
16
+ export { freshnessBadgeSpan, stationNameNode, windArrowSvg };
@@ -4,7 +4,7 @@ function apply(element, attrs, children) {
4
4
  if (attrs != null) for (const [name, value] of Object.entries(attrs)) {
5
5
  if (value == null || value === false) continue;
6
6
  if (typeof value === "function") {
7
- element.addEventListener(name.slice(2), value);
7
+ element.addEventListener(name.slice(2).toLowerCase(), value);
8
8
  continue;
9
9
  }
10
10
  element.setAttribute(name, value === true ? "" : String(value));
@@ -0,0 +1,48 @@
1
+ import { activeChartIndex, chartIndexAtClient, togglePinnedAt } from "../../scene/chart.js";
2
+ //#region src/elements/lib/pinned-cursor.ts
3
+ var PinnedCursor = class {
4
+ #pinnedAt = null;
5
+ #previewIndex = null;
6
+ #scene;
7
+ #svg;
8
+ #onChange;
9
+ constructor(host) {
10
+ this.#scene = host.scene;
11
+ this.#svg = host.svg;
12
+ this.#onChange = host.onChange;
13
+ }
14
+ get previewIndex() {
15
+ return this.#previewIndex;
16
+ }
17
+ activeIndex() {
18
+ const scene = this.#scene();
19
+ if (scene == null) return null;
20
+ return activeChartIndex(scene.points, this.#pinnedAt, this.#previewIndex);
21
+ }
22
+ handlePointerMove(event) {
23
+ if (event.pointerType === "touch") return;
24
+ this.#previewIndex = this.#indexAtPoint(event.clientX);
25
+ this.#onChange();
26
+ }
27
+ handlePointerLeave() {
28
+ this.#previewIndex = null;
29
+ this.#onChange();
30
+ }
31
+ handleClick(event) {
32
+ const index = this.#indexAtPoint(event.clientX);
33
+ if (index == null) return;
34
+ const observedAt = this.#scene()?.points[index]?.observedAt;
35
+ if (observedAt == null) return;
36
+ this.#pinnedAt = togglePinnedAt(this.#pinnedAt, observedAt);
37
+ this.#previewIndex = null;
38
+ this.#onChange();
39
+ }
40
+ #indexAtPoint(clientX) {
41
+ const scene = this.#scene();
42
+ const svg = this.#svg();
43
+ if (scene == null || svg == null) return null;
44
+ return chartIndexAtClient(scene.points, scene.frame, scene.scales, clientX, svg.getBoundingClientRect());
45
+ }
46
+ };
47
+ //#endregion
48
+ export { PinnedCursor };
@@ -0,0 +1,30 @@
1
+ import { SVG_ROOT_TAGS } from "../../scene/node.js";
2
+ import { h, hs } from "./h.js";
3
+ //#region src/elements/lib/render.ts
4
+ function renderChild(child, svg = false) {
5
+ if (child == null || child === false) return null;
6
+ if (typeof child === "string") return child;
7
+ if (typeof child === "number") return String(child);
8
+ return renderScene(child, svg);
9
+ }
10
+ function renderScene(node, svg = false) {
11
+ const inSvg = svg || SVG_ROOT_TAGS.has(node.tag);
12
+ const children = (node.children ?? []).map((child) => renderChild(child, inSvg));
13
+ const element = inSvg ? hs(node.tag, node.attrs ?? null, ...children) : h(node.tag, node.attrs ?? null, ...children);
14
+ if (node.style !== void 0) {
15
+ const style = element.style;
16
+ for (const [property, value] of Object.entries(node.style)) if (property.startsWith("--")) element.style.setProperty(property, value);
17
+ else style[property] = value;
18
+ }
19
+ return element;
20
+ }
21
+ /** The scene, or nothing when the widget has no surface to draw. */
22
+ function renderOptional(node) {
23
+ return node === null ? [] : [renderScene(node)];
24
+ }
25
+ /** A run of children with no element of their own to sit in. */
26
+ function renderChildren(children) {
27
+ return children.map((child) => renderChild(child)).filter((node) => node !== null);
28
+ }
29
+ //#endregion
30
+ export { renderChild, renderChildren, renderOptional, renderScene };
@@ -1,5 +1,9 @@
1
- import { HistoryPoint } from "./contract.js";
1
+ import { HistoryPoint, StationMeta } from "./contract.js";
2
+ import { SpeedThresholds } from "./derive.js";
2
3
  //#region src/fixtures.d.ts
4
+ declare const LAUNCH_RIDGE_META: StationMeta;
5
+ /** The wind grading the demo exhibits judge with. */
6
+ declare const EXHIBIT_THRESHOLDS: SpeedThresholds;
3
7
  /** Deterministic PRNG (mulberry32). */
4
8
  declare function mulberry32(seed: number): () => number;
5
9
  /** Smoothstep clamped to [0, 1]. */
@@ -20,4 +24,4 @@ interface LongHistoryOptions {
20
24
  /** A long-range deterministic synthetic history: seasonal, diurnal, with occasional dropouts. */
21
25
  declare function buildLongHistory({ nowMs, days, periodMinutes, seed, withGaps }: LongHistoryOptions): HistoryPoint[];
22
26
  //#endregion
23
- export { LongHistoryOptions, buildLongHistory, mulberry32, smooth, wobble };
27
+ export { EXHIBIT_THRESHOLDS, LAUNCH_RIDGE_META, LongHistoryOptions, buildLongHistory, mulberry32, smooth, wobble };
package/dist/fixtures.js CHANGED
@@ -1,6 +1,34 @@
1
+ import { kmhToMps } from "@azohra/meteo.core";
1
2
  //#region src/fixtures.ts
2
3
  const MINUTE_MS = 6e4;
3
4
  const DAY_MS = 1440 * MINUTE_MS;
5
+ const LAUNCH_RIDGE_META = {
6
+ id: "launch-ridge",
7
+ name: "Launch Ridge",
8
+ sourceLabel: "WindNerd",
9
+ pageUrl: null,
10
+ latitude: 49.078,
11
+ longitude: -117.785,
12
+ timeZone: "America/Vancouver",
13
+ elevationM: 1245,
14
+ capabilities: {
15
+ gustLull: true,
16
+ temperature: true,
17
+ conditions: false,
18
+ history: true
19
+ },
20
+ samplingWindowSeconds: 3,
21
+ recommendedPollSeconds: 5
22
+ };
23
+ /** The wind grading the demo exhibits judge with. */
24
+ const EXHIBIT_THRESHOLDS = {
25
+ unit: "kmh",
26
+ values: [
27
+ 12,
28
+ 20,
29
+ 28
30
+ ]
31
+ };
4
32
  /** Deterministic PRNG (mulberry32). */
5
33
  function mulberry32(seed) {
6
34
  let a = seed >>> 0;
@@ -20,7 +48,7 @@ const smooth = (value) => {
20
48
  const wobble = (seed) => (Math.sin(seed * 12.9898) + Math.sin(seed * 4.1414 + 1.3)) / 2;
21
49
  const round1 = (value) => Math.round(value * 10) / 10;
22
50
  const round2 = (value) => Math.round(value * 100) / 100;
23
- const mps = (kmh) => round2(kmh / 3.6);
51
+ const mps = (kmh) => round2(kmhToMps(kmh));
24
52
  const normalizeDeg = (deg) => (deg % 360 + 360) % 360;
25
53
  function seasonPhase(dateUtc) {
26
54
  const solsticeMs = Date.UTC(dateUtc.getUTCFullYear(), 11, 21);
@@ -64,4 +92,4 @@ function buildLongHistory({ nowMs, days = 420, periodMinutes = 15, seed = 995373
64
92
  return points;
65
93
  }
66
94
  //#endregion
67
- export { buildLongHistory, mulberry32, smooth, wobble };
95
+ export { EXHIBIT_THRESHOLDS, LAUNCH_RIDGE_META, buildLongHistory, mulberry32, smooth, wobble };
package/dist/format.js CHANGED
@@ -1,4 +1,4 @@
1
- import { compassDirection, isCalm, periodSummary, speedFromMps } from "./derive.js";
1
+ import { anchoredAgeMs, compassDirection, isCalm, periodSummary, speedFromMps } from "./derive.js";
2
2
  //#region src/format.ts
3
3
  function roundSpeed(mps, unit) {
4
4
  return Math.round(speedFromMps(mps, unit));
@@ -40,8 +40,12 @@ function relativeWords(ageMs, words) {
40
40
  return words.updated.hoursAgo(Math.floor(ageMs / HOUR_MS));
41
41
  }
42
42
  function readingAgeMs(args) {
43
- const observedMs = Date.parse(args.observedAt);
44
- return args.servedAt != null && args.receivedAtMs != null ? Math.max(0, Date.parse(args.servedAt) - observedMs) + Math.max(0, args.nowMs - args.receivedAtMs) : Math.max(0, args.nowMs - observedMs);
43
+ return args.servedAt != null && args.receivedAtMs != null ? anchoredAgeMs({
44
+ observedAt: args.observedAt,
45
+ servedAt: args.servedAt,
46
+ receivedAtMs: args.receivedAtMs,
47
+ nowMs: args.nowMs
48
+ }) : Math.max(0, args.nowMs - Date.parse(args.observedAt));
45
49
  }
46
50
  function updatedAtText(ageMs, observedAt, words, formatTime) {
47
51
  return ageMs >= 216e5 ? formatTime(new Date(Date.parse(observedAt))) : relativeWords(ageMs, words);
@@ -90,7 +90,7 @@ declare const METEOROLOGICAL_SEASON_MONTHS: Record<"fall" | "spring" | "summer"
90
90
  declare function filterByMonth(points: ReadonlyArray<HistoryPoint>, months: ReadonlyArray<number>, utcOffsetMinutes?: number): HistoryPoint[];
91
91
  declare function filterByTimeOfDay(points: ReadonlyArray<HistoryPoint>, fromMinute: number, toMinute: number, utcOffsetMinutes?: number): HistoryPoint[];
92
92
  /** The share of non-calm history blowing from inside the consumer's arcs;
93
- * null when nothing non-calm was measured — absence over a fabricated zero. */
93
+ * null when nothing non-calm was measured. */
94
94
  declare function favorableShare(points: ReadonlyArray<HistoryPoint>, arcs: ReadonlyArray<DirectionArc>): number | null;
95
95
  type HistoryCoverage = {
96
96
  actualCount: number;
package/dist/geometry.js CHANGED
@@ -28,7 +28,7 @@ function chartFrame(width) {
28
28
  }
29
29
  const DEFAULT_NICE_STEP_MPS = 5 / KMH_PER_MPS;
30
30
  const DEFAULT_FLOOR_MPS = 10 / KMH_PER_MPS;
31
- function chartScales(points, frame, options = {}) {
31
+ function chartScalesOf(points, frame, speedOf, options = {}) {
32
32
  const niceStepMps = options.niceStepMps ?? DEFAULT_NICE_STEP_MPS;
33
33
  const floorMps = options.floorMps ?? DEFAULT_FLOOR_MPS;
34
34
  const first = points[0];
@@ -36,7 +36,7 @@ function chartScales(points, frame, options = {}) {
36
36
  const last = points[points.length - 1];
37
37
  const endMs = last ? Date.parse(last.observedAt) : startMs;
38
38
  const durationMs = Math.max(1, endMs - startMs);
39
- const top = points.reduce((max, point) => Math.max(max, point.windGustMps ?? point.windAvgMps), 0);
39
+ const top = points.reduce((max, point) => Math.max(max, speedOf(point)), 0);
40
40
  const scaleMax = Math.max(floorMps, Math.ceil(top / niceStepMps) * niceStepMps);
41
41
  const xAtMs = (ms) => frame.left + (ms - startMs) / durationMs * (frame.right - frame.left);
42
42
  return {
@@ -49,6 +49,9 @@ function chartScales(points, frame, options = {}) {
49
49
  yAt: (speedMps) => frame.plotBottom - speedMps / scaleMax * (frame.plotBottom - frame.plotTop)
50
50
  };
51
51
  }
52
+ function chartScales(points, frame, options = {}) {
53
+ return chartScalesOf(points, frame, (point) => point.windGustMps ?? point.windAvgMps, options);
54
+ }
52
55
  function valueScale(values, frame, options) {
53
56
  let low = Infinity;
54
57
  let high = -Infinity;
@@ -77,11 +80,18 @@ function bandPoints(points, scales) {
77
80
  const lull = [...points].reverse().map((point) => coordinate(scales.xAt(point.observedAt), scales.yAt(point.windLullMps)));
78
81
  return [...gust, ...lull].join(" ");
79
82
  }
83
+ function tracePointsOf(points, scales, speedOf) {
84
+ return points.map((point) => coordinate(scales.xAt(point.observedAt), scales.yAt(speedOf(point)))).join(" ");
85
+ }
80
86
  function averagePoints(points, scales) {
81
- return points.map((point) => coordinate(scales.xAt(point.observedAt), scales.yAt(point.windAvgMps))).join(" ");
87
+ return tracePointsOf(points, scales, (point) => point.windAvgMps);
88
+ }
89
+ function meanDirectionDegOf(points, speedOf, directionOf) {
90
+ const blowing = points.filter((point) => !isCalm(speedOf(point)) && directionOf(point) != null);
91
+ return meanDirectionDeg(blowing.map((point) => directionOf(point)));
82
92
  }
83
93
  function meanDirectionDeg$1(points) {
84
- return meanDirectionDeg(points.filter((point) => !isCalm(point.windAvgMps) && point.windDirectionDeg != null).map((point) => point.windDirectionDeg));
94
+ return meanDirectionDegOf(points, (point) => point.windAvgMps, (point) => point.windDirectionDeg);
85
95
  }
86
96
  function vectorMeanWind(points) {
87
97
  if (points.length === 0) return {
@@ -102,7 +112,7 @@ function vectorMeanWind(points) {
102
112
  speedMps: mean.speedMps
103
113
  };
104
114
  }
105
- function thinVanes(points, target = 13) {
115
+ function thinVanesOf(points, speedOf, directionOf, target = 13) {
106
116
  if (points.length === 0) return [];
107
117
  const step = Math.max(1, Math.round(points.length / target));
108
118
  return Array.from({ length: Math.ceil(points.length / step) }, (_, index) => {
@@ -112,14 +122,17 @@ function thinVanes(points, target = 13) {
112
122
  const first = Date.parse(window[0].observedAt);
113
123
  const last = Date.parse(window[window.length - 1].observedAt);
114
124
  return {
115
- windAvgMps: window.reduce((sum, point) => sum + point.windAvgMps, 0) / window.length,
116
- windDirectionDeg: meanDirectionDeg$1(window),
125
+ windAvgMps: window.reduce((sum, point) => sum + speedOf(point), 0) / window.length,
126
+ windDirectionDeg: meanDirectionDegOf(window, speedOf, directionOf),
117
127
  endIndex,
118
128
  midMs: first + (last - first) / 2,
119
129
  startIndex
120
130
  };
121
131
  });
122
132
  }
133
+ function thinVanes(points, target = 13) {
134
+ return thinVanesOf(points, (point) => point.windAvgMps, (point) => point.windDirectionDeg, target);
135
+ }
123
136
  function vanePath(cx, cy, fromBearingDeg, { reach = 7, spread = 3.2 } = {}) {
124
137
  const angle = radians(fromBearingDeg + 180);
125
138
  const sin = Math.sin(angle);
@@ -255,7 +268,7 @@ function filterByTimeOfDay(points, fromMinute, toMinute, utcOffsetMinutes = 0) {
255
268
  });
256
269
  }
257
270
  /** The share of non-calm history blowing from inside the consumer's arcs;
258
- * null when nothing non-calm was measured — absence over a fabricated zero. */
271
+ * null when nothing non-calm was measured. */
259
272
  function favorableShare(points, arcs) {
260
273
  let blowing = 0;
261
274
  let favorable = 0;
@@ -368,4 +381,4 @@ function compareTracePoints(comparePoints, scales, offsetDays) {
368
381
  return comparePoints.map((point) => coordinate(scales.xAtMs(Date.parse(point.observedAt) + shiftMs), scales.yAt(point.windAvgMps))).join(" ");
369
382
  }
370
383
  //#endregion
371
- export { CHART_FALLBACK_WIDTH, DAILY_PATTERN_DEFAULT_SLOT_MINUTES, HISTORY_GAP_TOLERANCE_FACTOR, METEOROLOGICAL_SEASON_MONTHS, averagePoints, bandPoints, chartFrame, chartScales, compareTracePoints, compareWindow, dailyPattern, favorableShare, filterByMonth, filterByTimeOfDay, historyCoverage, historyGaps, isCalmHistory, meanDirectionDeg$1 as meanDirectionDeg, measuredChartWidth, nearestIndex, speedBand, stretchFrame, thinVanes, tickAnchor, trendRuns, trendSeriesPad, trendValueOf, valueScale, vanePath, vaneTicks, vectorMeanWind, windRose, windowPoints };
384
+ export { CHART_FALLBACK_WIDTH, DAILY_PATTERN_DEFAULT_SLOT_MINUTES, HISTORY_GAP_TOLERANCE_FACTOR, METEOROLOGICAL_SEASON_MONTHS, averagePoints, bandPoints, chartFrame, chartScales, chartScalesOf, compareTracePoints, compareWindow, dailyPattern, favorableShare, filterByMonth, filterByTimeOfDay, historyCoverage, historyGaps, isCalmHistory, meanDirectionDeg$1 as meanDirectionDeg, meanDirectionDegOf, measuredChartWidth, nearestIndex, speedBand, stretchFrame, thinVanes, thinVanesOf, tickAnchor, tracePointsOf, trendRuns, trendSeriesPad, trendValueOf, valueScale, vanePath, vaneTicks, vectorMeanWind, windRose, windowPoints };
@@ -2,7 +2,7 @@ import { COMPASS_POINTS, KMH_PER_MPS, normalizeDegrees, radians, speedToMps } fr
2
2
  import { HISTORY_GAP_TOLERANCE_FACTOR } from "./geometry.js";
3
3
  //#region src/instruments.ts
4
4
  const DIAL_SIZE = 160;
5
- const DIAL_CENTRE = 160 / 2;
5
+ const DIAL_CENTRE = 80;
6
6
  const DIAL_RING_RADIUS = 70;
7
7
  const DIAL_TICK_INNER = 64;
8
8
  const DIAL_CARDINAL_TICK_INNER = 58;
@@ -62,7 +62,7 @@ const DIAL_CARDINALS = [
62
62
  }
63
63
  ];
64
64
  const ROSE_SIZE = 190;
65
- const ROSE_CENTRE = 190 / 2;
65
+ const ROSE_CENTRE = 95;
66
66
  const ROSE_MAX_RADIUS = 70;
67
67
  const ROSE_FAVORABLE_RING_RADIUS = 75;
68
68
  const ROSE_HUB_RADIUS = 16;
@@ -11,6 +11,6 @@ declare function AirExtremes({ station: stationProp, stationId, nowMs, strings:
11
11
  /** Pinned in tests; defaults to the wall clock. */
12
12
  nowMs?: number;
13
13
  strings?: StationStringOverrides;
14
- }): import("react").JSX.Element | null;
14
+ }): import("react").ReactNode;
15
15
  //#endregion
16
16
  export { AirExtremes };
@@ -1,8 +1,8 @@
1
1
  "use client";
2
2
  import { resolveDisplay } from "../../display.js";
3
- import { airExtremesGate, airExtremesScene } from "../../scene/air-extremes.js";
3
+ import { airExtremesScene } from "../../scene/air-extremes.js";
4
+ import { renderOptional } from "./SceneTree.js";
4
5
  import { resolveStation, useStationFeedContext } from "./StationFeedProvider.js";
5
- import { jsx, jsxs } from "react/jsx-runtime";
6
6
  //#region src/react/components/AirExtremes.tsx
7
7
  /** Derived atmo tiles from served history: the last completed night's low
8
8
  * (real astronomy — no coordinates, no tile) and the trailing pressure
@@ -11,28 +11,11 @@ function AirExtremes({ station: stationProp, stationId, nowMs, strings: stringsP
11
11
  const context = useStationFeedContext();
12
12
  const station = stationProp ?? resolveStation(context, stationId) ?? void 0;
13
13
  const { words } = resolveDisplay(context, { strings: stringsProp });
14
- const gate = airExtremesGate(station);
15
- if (gate.kind === "hidden") return null;
16
- const scene = airExtremesScene({
14
+ return renderOptional(airExtremesScene({
17
15
  nowMs: nowMs ?? Date.now(),
18
- station: gate.station,
16
+ station,
19
17
  words
20
- });
21
- if (scene == null) return null;
22
- return /* @__PURE__ */ jsx("dl", {
23
- "aria-label": scene.ariaLabel,
24
- className: scene.className,
25
- children: scene.tiles.map((tile) => /* @__PURE__ */ jsxs("div", {
26
- className: tile.className,
27
- children: [/* @__PURE__ */ jsx("dt", {
28
- className: "meteo-microlabel",
29
- children: tile.label
30
- }), /* @__PURE__ */ jsx("dd", {
31
- className: "meteo-air-extremes-value",
32
- children: tile.value
33
- })]
34
- }, tile.key))
35
- });
18
+ }));
36
19
  }
37
20
  //#endregion
38
21
  export { AirExtremes };