@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,7 +1,6 @@
1
1
  import { stationStripScene } from "../../scene/strip.js";
2
2
  import { MeteoStationElement } from "../lib/base.js";
3
- import { h } from "../lib/h.js";
4
- import { directionCellNodes, freshnessBadgeSpan, stationNameNode } from "../lib/fragments.js";
3
+ import { renderScene } from "../lib/render.js";
5
4
  //#region src/elements/elements/StationStripElement.ts
6
5
  var StationStripElement = class extends MeteoStationElement {
7
6
  static observedAttributes = [
@@ -17,26 +16,13 @@ var StationStripElement = class extends MeteoStationElement {
17
16
  const station = this.requiredStation("meteo-station-strip");
18
17
  const { formatTime, unit, words } = this.display();
19
18
  const status = this.freshnessOf(station);
20
- const scene = stationStripScene({
19
+ this.replaceChildren(renderScene(stationStripScene({
21
20
  formatTime,
21
+ freshness: status,
22
22
  station,
23
23
  unit,
24
24
  words
25
- });
26
- const { body } = scene;
27
- const cells = body.kind === "reading" ? [
28
- h("span", { class: body.wind.className }, h("strong", null, body.wind.value), h("small", null, body.wind.unitLabel)),
29
- body.gustLull != null && [h("span", { class: body.gustLull.lull.className }, h("small", { class: body.gustLull.lull.labelClassName }, body.gustLull.lull.label), body.gustLull.lull.value), h("span", { class: body.gustLull.gust.className }, h("small", { class: body.gustLull.gust.labelClassName }, body.gustLull.gust.label), body.gustLull.gust.value)],
30
- h("span", { class: body.from.className }, ...directionCellNodes(body.from.windAvgMps, body.from.windDirectionDeg, words)),
31
- body.temperature != null && h("span", { class: body.temperature.className }, body.temperature.text),
32
- h("span", { class: body.updated.className }, h("span", { class: body.updated.time.className }, body.updated.time.text), status != null && freshnessBadgeSpan(status, words))
33
- ] : [h("span", { class: body.className }, body.text)];
34
- this.replaceChildren(h("div", {
35
- "aria-label": scene.root.ariaLabel,
36
- class: scene.root.className,
37
- "data-status": scene.root.status,
38
- role: "group"
39
- }, h("span", { class: scene.stationClassName }, stationNameNode(station)), ...cells));
25
+ })));
40
26
  }
41
27
  };
42
28
  //#endregion
@@ -1,9 +1,10 @@
1
1
  import { requireResolved } from "../../display.js";
2
- import { stationTableRowScene, stationTableScene } from "../../scene/table.js";
2
+ import { TABLE_BODY_CLASS, TABLE_ROW_CLASS, TABLE_STATION_CELL_CLASS, stationTableHeadNode, stationTableRootAttrs, stationTableRowCells } from "../../scene/table.js";
3
3
  import { ELEMENTS_AMBIENT_HINT } from "../lib/ambient.js";
4
4
  import { MeteoStationElement } from "../lib/base.js";
5
5
  import { h } from "../lib/h.js";
6
- import { directionCellNodes, freshnessBadgeSpan, stationNameNode } from "../lib/fragments.js";
6
+ import { renderScene } from "../lib/render.js";
7
+ import { stationNameNode } from "../lib/fragments.js";
7
8
  //#region src/elements/elements/StationTableElement.ts
8
9
  var StationTableElement = class extends MeteoStationElement {
9
10
  static observedAttributes = [
@@ -37,65 +38,28 @@ var StationTableElement = class extends MeteoStationElement {
37
38
  render() {
38
39
  const stations = requireResolved("meteo-station-table", "stations", this.#stations ?? this.ambient()?.feed?.stations, ELEMENTS_AMBIENT_HINT);
39
40
  const { formatTime, unit, words } = this.display();
40
- const scene = stationTableScene(stations, words);
41
- this.replaceChildren(h("div", {
42
- "aria-label": scene.root.ariaLabel,
43
- class: scene.root.className,
44
- role: "table"
45
- }, h("div", {
46
- class: scene.head.className,
47
- role: "row"
48
- }, scene.head.columns.map((column) => h("span", { role: "columnheader" }, column))), h("div", {
49
- class: scene.bodyClassName,
41
+ this.replaceChildren(h("div", stationTableRootAttrs(stations, words), renderScene(stationTableHeadNode(words)), h("div", {
42
+ class: TABLE_BODY_CLASS,
50
43
  role: "rowgroup"
51
44
  }, stations.map((station) => this.#row(station, unit, words, formatTime)))));
52
45
  }
53
46
  #row(station, unit, words, formatTime) {
54
47
  const status = this.freshnessOf(station);
55
48
  const meta = this.#stationMeta ? this.#stationMeta(station) : station.sourceLabel;
56
- const row = stationTableRowScene({
57
- formatTime,
58
- station,
59
- unit,
60
- words
61
- });
62
- const { cells } = row;
63
49
  return h("div", {
64
- class: row.className,
65
- "data-status": row.status,
50
+ class: TABLE_ROW_CLASS,
51
+ "data-status": station.status,
66
52
  role: "row"
67
53
  }, h("span", {
68
- class: row.stationCellClassName,
54
+ class: TABLE_STATION_CELL_CLASS,
69
55
  role: "cell"
70
- }, h("strong", null, stationNameNode(station)), h("small", null, meta)), cells.kind === "reading" ? [
71
- h("span", {
72
- class: cells.wind.className,
73
- role: "cell"
74
- }, h("strong", null, cells.wind.value), h("small", null, cells.wind.unitLabel)),
75
- h("span", {
76
- class: cells.lull.className,
77
- role: "cell"
78
- }, cells.lull.value),
79
- h("span", {
80
- class: cells.gust.className,
81
- role: "cell"
82
- }, cells.gust.value),
83
- h("span", {
84
- class: cells.from.className,
85
- role: "cell"
86
- }, ...directionCellNodes(cells.from.windAvgMps, cells.from.windDirectionDeg, words)),
87
- h("span", {
88
- class: cells.temperature.className,
89
- role: "cell"
90
- }, cells.temperature.value),
91
- h("span", {
92
- class: cells.updated.className,
93
- role: "cell"
94
- }, h("span", { class: cells.updated.time.className }, cells.updated.time.text), status != null && freshnessBadgeSpan(status, words))
95
- ] : h("span", {
96
- class: cells.className,
97
- role: "cell"
98
- }, cells.text));
56
+ }, h("strong", null, stationNameNode(station)), h("small", null, meta)), stationTableRowCells({
57
+ formatTime,
58
+ freshness: status,
59
+ station,
60
+ unit,
61
+ words
62
+ }).map((child) => typeof child === "object" && child !== null ? renderScene(child) : child));
99
63
  }
100
64
  };
101
65
  //#endregion
@@ -4,7 +4,8 @@ import { readoutAriaLive } from "../../scene/chart.js";
4
4
  import { TREND_CLASS, trendGate, trendScene } from "../../scene/trend.js";
5
5
  import { ELEMENTS_AMBIENT_HINT } from "../lib/ambient.js";
6
6
  import { MeteoStationElement } from "../lib/base.js";
7
- import { h, hs } from "../lib/h.js";
7
+ import { h } from "../lib/h.js";
8
+ import { renderChildren, renderScene } from "../lib/render.js";
8
9
  import { PinnedCursor } from "../lib/pinned-cursor.js";
9
10
  //#region src/elements/elements/TrendChartElement.ts
10
11
  var TrendChartElement = class extends MeteoStationElement {
@@ -13,11 +14,10 @@ var TrendChartElement = class extends MeteoStationElement {
13
14
  #observer = null;
14
15
  #scene = null;
15
16
  #readout = null;
16
- #svg = null;
17
- #hit = null;
17
+ #wrap = null;
18
18
  #cursor = new PinnedCursor({
19
19
  scene: () => this.#scene,
20
- svg: () => this.#svg,
20
+ svg: () => this.#wrap?.querySelector("svg") ?? null,
21
21
  onChange: () => this.#updateCursor()
22
22
  });
23
23
  disconnected() {
@@ -76,80 +76,32 @@ var TrendChartElement = class extends MeteoStationElement {
76
76
  class: scene.readout.className
77
77
  });
78
78
  this.#readout = readout;
79
- const hit = hs("rect", {
80
- class: scene.hit.className,
81
- fill: scene.hit.fill,
82
- height: scene.hit.height,
83
- onclick: (event) => this.#cursor.handleClick(event),
84
- onpointerleave: () => this.#cursor.handlePointerLeave(),
85
- onpointermove: (event) => this.#cursor.handlePointerMove(event),
86
- width: scene.hit.width,
87
- x: scene.hit.x,
88
- y: scene.hit.y
89
- });
90
- this.#hit = hit;
91
- const svg = hs("svg", {
92
- "aria-label": scene.svg.ariaLabel,
93
- class: scene.svg.className,
94
- height: scene.svg.height,
95
- role: "img",
96
- viewBox: scene.svg.viewBox,
97
- width: scene.svg.width
98
- }, scene.grid.map(({ line, label }) => hs("g", null, hs("line", {
99
- class: line.className,
100
- x1: line.x1,
101
- x2: line.x2,
102
- y1: line.y1,
103
- y2: line.y2
104
- }), hs("text", {
105
- class: label.className,
106
- "text-anchor": label.anchor,
107
- x: label.x,
108
- y: label.y
109
- }, label.text))), scene.segments.map((segment) => segment.kind === "dot" ? hs("circle", {
110
- class: segment.className,
111
- cx: segment.cx,
112
- cy: segment.cy,
113
- r: segment.r
114
- }) : hs("polyline", {
115
- class: segment.className,
116
- points: segment.points
117
- })), scene.ticks.map((tick) => hs("text", {
118
- class: tick.className,
119
- "text-anchor": tick.anchor,
120
- x: tick.x,
121
- y: tick.y
122
- }, tick.text)), hit);
123
- this.#svg = svg;
124
- wrap.replaceChildren(readout, svg);
79
+ this.#wrap = wrap;
80
+ wrap.replaceChildren(readout, this.#drawSvg());
125
81
  this.#updateCursor();
126
82
  }
83
+ #drawSvg() {
84
+ const scene = this.#scene;
85
+ if (scene == null) throw new Error("meteo-trend-chart: no scene to draw");
86
+ return renderScene(scene.draw([], {
87
+ onClick: (event) => this.#cursor.handleClick(event),
88
+ onPointerLeave: () => this.#cursor.handlePointerLeave(),
89
+ onPointerMove: (event) => this.#cursor.handlePointerMove(event)
90
+ }));
91
+ }
127
92
  #updateCursor() {
128
93
  const scene = this.#scene;
129
94
  const readout = this.#readout;
130
- const svg = this.#svg;
131
- const hit = this.#hit;
132
- if (scene == null || readout == null || svg == null || hit == null) return;
95
+ const wrap = this.#wrap;
96
+ if (scene == null || readout == null || wrap == null) return;
133
97
  const inspection = scene.inspect(this.#cursor.activeIndex());
134
98
  readout.setAttribute("aria-live", readoutAriaLive(this.#cursor.previewIndex));
135
99
  readout.replaceChildren(h("strong", null, inspection.readout.strong), h("span", null, inspection.readout.span));
100
+ const svg = wrap.querySelector("svg");
101
+ const hit = svg?.querySelector(".meteo-hit") ?? null;
102
+ if (svg == null) return;
136
103
  for (const mark of [...svg.querySelectorAll(".meteo-cursor, .meteo-cursor-dot")]) mark.remove();
137
- const cursor = inspection.cursor;
138
- if (cursor != null) {
139
- svg.insertBefore(hs("line", {
140
- class: cursor.line.className,
141
- x1: cursor.line.x1,
142
- x2: cursor.line.x2,
143
- y1: cursor.line.y1,
144
- y2: cursor.line.y2
145
- }), hit);
146
- if (cursor.dot != null) svg.insertBefore(hs("circle", {
147
- class: cursor.dot.className,
148
- cx: cursor.dot.cx,
149
- cy: cursor.dot.cy,
150
- r: cursor.dot.r
151
- }), hit);
152
- }
104
+ for (const node of renderChildren(inspection.cursor)) svg.insertBefore(node, hit);
153
105
  }
154
106
  };
155
107
  //#endregion
@@ -3,13 +3,15 @@ import { readoutAriaLive } from "../../scene/chart.js";
3
3
  import { WIND_CHART_CLASS, windChartGate, windChartScene } from "../../scene/wind-history.js";
4
4
  import { numberAttribute } from "../lib/attributes.js";
5
5
  import { MeteoStationElement } from "../lib/base.js";
6
- import { h, hs } from "../lib/h.js";
6
+ import { h } from "../lib/h.js";
7
+ import { renderChildren, renderScene } from "../lib/render.js";
7
8
  import { windArrowSvg } from "../lib/fragments.js";
8
9
  import { PinnedCursor } from "../lib/pinned-cursor.js";
9
10
  //#region src/elements/elements/WindHistoryChartElement.ts
10
11
  let hatchCounter = 0;
11
12
  function readoutSpan(parts) {
12
- return h("span", null, ...parts.map((part) => part.kind === "arrow" ? windArrowSvg(part.deg) : part.text));
13
+ const children = parts.map((part) => part.kind === "arrow" ? windArrowSvg(part.deg) : part.text);
14
+ return h("span", null, ...children);
13
15
  }
14
16
  var WindHistoryChartElement = class extends MeteoStationElement {
15
17
  static observedAttributes = [
@@ -26,11 +28,10 @@ var WindHistoryChartElement = class extends MeteoStationElement {
26
28
  #observer = null;
27
29
  #scene = null;
28
30
  #readout = null;
29
- #svg = null;
30
- #hit = null;
31
+ #wrap = null;
31
32
  #cursor = new PinnedCursor({
32
33
  scene: () => this.#scene,
33
- svg: () => this.#svg,
34
+ svg: () => this.#wrap?.querySelector("svg") ?? null,
34
35
  onChange: () => this.#updateCursor()
35
36
  });
36
37
  disconnected() {
@@ -98,174 +99,32 @@ var WindHistoryChartElement = class extends MeteoStationElement {
98
99
  class: scene.readout.className
99
100
  });
100
101
  this.#readout = readout;
101
- const hit = hs("rect", {
102
- class: scene.hit.className,
103
- fill: scene.hit.fill,
104
- height: scene.hit.height,
105
- onclick: (event) => this.#cursor.handleClick(event),
106
- onpointerleave: () => this.#cursor.handlePointerLeave(),
107
- onpointermove: (event) => this.#cursor.handlePointerMove(event),
108
- width: scene.hit.width,
109
- x: scene.hit.x,
110
- y: scene.hit.y
111
- });
112
- this.#hit = hit;
113
- const svg = hs("svg", {
114
- "aria-label": scene.svg.ariaLabel,
115
- class: scene.svg.className,
116
- height: scene.svg.height,
117
- role: "img",
118
- viewBox: scene.svg.viewBox,
119
- width: scene.svg.width
120
- }, hs("defs", null, hs("pattern", {
121
- height: scene.defs.pattern.height,
122
- id: scene.defs.pattern.id,
123
- patternTransform: scene.defs.pattern.transform,
124
- patternUnits: scene.defs.pattern.units,
125
- width: scene.defs.pattern.width
126
- }, hs("line", {
127
- class: scene.defs.pattern.line.className,
128
- x1: scene.defs.pattern.line.x1,
129
- x2: scene.defs.pattern.line.x2,
130
- y1: scene.defs.pattern.line.y1,
131
- y2: scene.defs.pattern.line.y2
132
- })), hs("clipPath", { id: scene.defs.clip.id }, hs("rect", {
133
- height: scene.defs.clip.rect.height,
134
- width: scene.defs.clip.rect.width,
135
- x: scene.defs.clip.rect.x,
136
- y: scene.defs.clip.rect.y
137
- }))), scene.zones.map((zone) => hs("rect", {
138
- class: zone.className,
139
- height: zone.height,
140
- width: zone.width,
141
- x: zone.x,
142
- y: zone.y
143
- })), scene.nightRects.map((rect) => hs("rect", {
144
- class: rect.className,
145
- height: rect.height,
146
- width: rect.width,
147
- x: rect.x,
148
- y: rect.y
149
- })), scene.grid.map(({ line, label }) => hs("g", null, hs("line", {
150
- class: line.className,
151
- x1: line.x1,
152
- x2: line.x2,
153
- y1: line.y1,
154
- y2: line.y2
155
- }), hs("text", {
156
- class: label.className,
157
- "text-anchor": label.anchor,
158
- x: label.x,
159
- y: label.y
160
- }, label.text))), scene.thresholdGuides.map(({ line, label }) => hs("g", null, hs("line", {
161
- class: line.className,
162
- x1: line.x1,
163
- x2: line.x2,
164
- y1: line.y1,
165
- y2: line.y2
166
- }), hs("text", {
167
- class: label.className,
168
- "text-anchor": label.anchor,
169
- x: label.x,
170
- y: label.y
171
- }, label.text))), scene.vaneGuides.map((guide) => hs("line", {
172
- class: guide.className,
173
- x1: guide.x1,
174
- x2: guide.x2,
175
- y1: guide.y1,
176
- y2: guide.y2
177
- })), scene.gaps.map((gap) => hs("rect", {
178
- class: gap.className,
179
- fill: gap.fill,
180
- height: gap.height,
181
- width: gap.width,
182
- x: gap.x,
183
- y: gap.y
184
- })), scene.band != null && hs("polygon", {
185
- class: scene.band.className,
186
- points: scene.band.points
187
- }), scene.compare != null && hs("polyline", {
188
- class: scene.compare.className,
189
- "clip-path": scene.compare.clipPath,
190
- points: scene.compare.points
191
- }), scene.mean.kind === "polyline" ? hs("polyline", {
192
- class: scene.mean.className,
193
- points: scene.mean.points
194
- }) : scene.mean.segments.map((segment) => hs("line", {
195
- class: segment.className,
196
- x1: segment.x1,
197
- x2: segment.x2,
198
- y1: segment.y1,
199
- y2: segment.y2
200
- })), scene.calmNote != null && hs("text", {
201
- class: scene.calmNote.className,
202
- "text-anchor": scene.calmNote.anchor,
203
- x: scene.calmNote.x,
204
- y: scene.calmNote.y
205
- }, scene.calmNote.text), hs("text", {
206
- class: scene.rowLabels.to.className,
207
- "text-anchor": scene.rowLabels.to.anchor,
208
- x: scene.rowLabels.to.x,
209
- y: scene.rowLabels.to.y
210
- }, scene.rowLabels.to.text), scene.vanes.map((vane) => vane.mark.kind === "calm" ? hs("text", {
211
- class: vane.mark.text.className,
212
- "text-anchor": vane.mark.text.anchor,
213
- x: vane.mark.text.x,
214
- y: vane.mark.text.y
215
- }, vane.mark.text.text) : hs("path", {
216
- class: vane.mark.className,
217
- d: vane.mark.d
218
- })), scene.vanes.flatMap((vane) => vane.label == null ? [] : [hs("text", {
219
- class: vane.label.className,
220
- "text-anchor": vane.label.anchor,
221
- x: vane.label.x,
222
- y: vane.label.y
223
- }, vane.label.text)]), hs("text", {
224
- class: scene.rowLabels.avg.className,
225
- "text-anchor": scene.rowLabels.avg.anchor,
226
- x: scene.rowLabels.avg.x,
227
- y: scene.rowLabels.avg.y
228
- }, scene.rowLabels.avg.text), scene.vanes.flatMap((vane) => vane.value == null ? [] : [hs("text", {
229
- class: vane.value.className,
230
- "text-anchor": vane.value.anchor,
231
- x: vane.value.x,
232
- y: vane.value.y
233
- }, vane.value.text)]), scene.ticks.map((tick) => hs("text", {
234
- class: tick.className,
235
- "text-anchor": tick.anchor,
236
- x: tick.x,
237
- y: tick.y
238
- }, tick.text)), hit);
239
- this.#svg = svg;
240
- wrap.replaceChildren(readout, svg);
102
+ this.#wrap = wrap;
103
+ wrap.replaceChildren(readout, this.#drawSvg());
241
104
  this.#updateCursor();
242
105
  }
106
+ #drawSvg() {
107
+ const scene = this.#scene;
108
+ if (scene == null) throw new Error("meteo-wind-history-chart: no scene to draw");
109
+ return renderScene(scene.draw([], {
110
+ onClick: (event) => this.#cursor.handleClick(event),
111
+ onPointerLeave: () => this.#cursor.handlePointerLeave(),
112
+ onPointerMove: (event) => this.#cursor.handlePointerMove(event)
113
+ }));
114
+ }
243
115
  #updateCursor() {
244
116
  const scene = this.#scene;
245
117
  const readout = this.#readout;
246
- const svg = this.#svg;
247
- const hit = this.#hit;
248
- if (scene == null || readout == null || svg == null || hit == null) return;
118
+ const wrap = this.#wrap;
119
+ if (scene == null || readout == null || wrap == null) return;
249
120
  const inspection = scene.inspect(this.#cursor.activeIndex());
250
121
  readout.setAttribute("aria-live", readoutAriaLive(this.#cursor.previewIndex));
251
122
  readout.replaceChildren(h("strong", null, inspection.readout.strong), readoutSpan(inspection.readout.span));
123
+ const svg = wrap.querySelector("svg");
124
+ const hit = svg?.querySelector(".meteo-hit") ?? null;
125
+ if (svg == null) return;
252
126
  for (const mark of [...svg.querySelectorAll(".meteo-cursor, .meteo-cursor-dot")]) mark.remove();
253
- const cursor = inspection.cursor;
254
- if (cursor != null) {
255
- svg.insertBefore(hs("line", {
256
- class: cursor.line.className,
257
- x1: cursor.line.x1,
258
- x2: cursor.line.x2,
259
- y1: cursor.line.y1,
260
- y2: cursor.line.y2
261
- }), hit);
262
- svg.insertBefore(hs("circle", {
263
- class: cursor.dot.className,
264
- cx: cursor.dot.cx,
265
- cy: cursor.dot.cy,
266
- r: cursor.dot.r
267
- }), hit);
268
- }
127
+ for (const node of renderChildren(inspection.cursor)) svg.insertBefore(node, hit);
269
128
  }
270
129
  };
271
130
  //#endregion
@@ -1,7 +1,6 @@
1
1
  import { HistoryPoint } from "../../contract.js";
2
2
  import "../../index.js";
3
3
  import { MeteoStationElement } from "../lib/base.js";
4
- import "../../scene/index.js";
5
4
  //#region src/elements/elements/WindRoseElement.d.ts
6
5
  declare class WindRoseElement extends MeteoStationElement {
7
6
  #private;
@@ -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 };
@@ -2,7 +2,7 @@ import { SpeedKind } from "../../format.js";
2
2
  import { MeteoStationElement } from "../lib/base.js";
3
3
  //#region src/elements/elements/atoms.d.ts
4
4
  declare abstract class SpeedAtomElement extends MeteoStationElement {
5
- static readonly observedAttributes: ("unit" | "station-id")[];
5
+ static readonly observedAttributes: ("station-id" | "unit")[];
6
6
  protected abstract readonly kind: SpeedKind;
7
7
  protected abstract readonly component: string;
8
8
  protected render(): void;