@azohra/meteo.station 0.1.1

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 (160) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +53 -0
  3. package/dist/air.d.ts +13 -0
  4. package/dist/air.js +76 -0
  5. package/dist/client/index.d.ts +4 -0
  6. package/dist/client/index.js +4 -0
  7. package/dist/client/poll.d.ts +42 -0
  8. package/dist/client/poll.js +121 -0
  9. package/dist/client/stores.d.ts +46 -0
  10. package/dist/client/stores.js +128 -0
  11. package/dist/client/ticker.d.ts +4 -0
  12. package/dist/client/ticker.js +19 -0
  13. package/dist/contract.d.ts +381 -0
  14. package/dist/contract.js +143 -0
  15. package/dist/derive.d.ts +54 -0
  16. package/dist/derive.js +134 -0
  17. package/dist/display.d.ts +28 -0
  18. package/dist/display.js +27 -0
  19. package/dist/elements/elements/AirMatrixElement.d.ts +14 -0
  20. package/dist/elements/elements/AirMatrixElement.js +83 -0
  21. package/dist/elements/elements/CurrentConditionsElement.d.ts +9 -0
  22. package/dist/elements/elements/CurrentConditionsElement.js +52 -0
  23. package/dist/elements/elements/DailyPatternElement.d.ts +15 -0
  24. package/dist/elements/elements/DailyPatternElement.js +200 -0
  25. package/dist/elements/elements/DialElement.d.ts +9 -0
  26. package/dist/elements/elements/DialElement.js +128 -0
  27. package/dist/elements/elements/FreshnessBadgeElement.d.ts +8 -0
  28. package/dist/elements/elements/FreshnessBadgeElement.js +22 -0
  29. package/dist/elements/elements/SparklineElement.d.ts +9 -0
  30. package/dist/elements/elements/SparklineElement.js +74 -0
  31. package/dist/elements/elements/StationCardElement.d.ts +53 -0
  32. package/dist/elements/elements/StationCardElement.js +211 -0
  33. package/dist/elements/elements/StationFeedElement.d.ts +32 -0
  34. package/dist/elements/elements/StationFeedElement.js +215 -0
  35. package/dist/elements/elements/StationStripElement.d.ts +9 -0
  36. package/dist/elements/elements/StationStripElement.js +43 -0
  37. package/dist/elements/elements/StationTableElement.d.ts +18 -0
  38. package/dist/elements/elements/StationTableElement.js +102 -0
  39. package/dist/elements/elements/TrendChartElement.d.ts +10 -0
  40. package/dist/elements/elements/TrendChartElement.js +174 -0
  41. package/dist/elements/elements/WindArrowElement.d.ts +8 -0
  42. package/dist/elements/elements/WindArrowElement.js +14 -0
  43. package/dist/elements/elements/WindHistoryChartElement.d.ts +10 -0
  44. package/dist/elements/elements/WindHistoryChartElement.js +277 -0
  45. package/dist/elements/elements/WindRoseElement.d.ts +17 -0
  46. package/dist/elements/elements/WindRoseElement.js +106 -0
  47. package/dist/elements/elements/atoms.d.ts +48 -0
  48. package/dist/elements/elements/atoms.js +131 -0
  49. package/dist/elements/index.d.ts +48 -0
  50. package/dist/elements/index.js +57 -0
  51. package/dist/elements/lib/ambient.d.ts +15 -0
  52. package/dist/elements/lib/ambient.js +5 -0
  53. package/dist/elements/lib/attributes.js +21 -0
  54. package/dist/elements/lib/base.d.ts +45 -0
  55. package/dist/elements/lib/base.js +152 -0
  56. package/dist/elements/lib/context.js +28 -0
  57. package/dist/elements/lib/fragments.js +45 -0
  58. package/dist/elements/lib/h.js +35 -0
  59. package/dist/elements/register.d.ts +1 -0
  60. package/dist/elements/register.js +5 -0
  61. package/dist/endpoints.d.ts +5 -0
  62. package/dist/endpoints.js +10 -0
  63. package/dist/fixtures.d.ts +23 -0
  64. package/dist/fixtures.js +67 -0
  65. package/dist/format.d.ts +31 -0
  66. package/dist/format.js +82 -0
  67. package/dist/geometry.d.ts +84 -0
  68. package/dist/geometry.js +333 -0
  69. package/dist/index.d.ts +12 -0
  70. package/dist/index.js +12 -0
  71. package/dist/instruments.d.ts +75 -0
  72. package/dist/instruments.js +173 -0
  73. package/dist/merge-current.d.ts +13 -0
  74. package/dist/merge-current.js +54 -0
  75. package/dist/react/components/AirMatrix.d.ts +11 -0
  76. package/dist/react/components/AirMatrix.js +82 -0
  77. package/dist/react/components/CurrentConditions.d.ts +17 -0
  78. package/dist/react/components/CurrentConditions.js +98 -0
  79. package/dist/react/components/DailyPattern.d.ts +19 -0
  80. package/dist/react/components/DailyPattern.js +212 -0
  81. package/dist/react/components/Dial.d.ts +17 -0
  82. package/dist/react/components/Dial.js +133 -0
  83. package/dist/react/components/FreshnessBadge.d.ts +10 -0
  84. package/dist/react/components/FreshnessBadge.js +20 -0
  85. package/dist/react/components/Sparkline.d.ts +17 -0
  86. package/dist/react/components/Sparkline.js +60 -0
  87. package/dist/react/components/StationCard.d.ts +46 -0
  88. package/dist/react/components/StationCard.js +140 -0
  89. package/dist/react/components/StationFeedProvider.d.ts +27 -0
  90. package/dist/react/components/StationFeedProvider.js +40 -0
  91. package/dist/react/components/StationStrip.d.ts +16 -0
  92. package/dist/react/components/StationStrip.js +84 -0
  93. package/dist/react/components/StationTable.d.ts +18 -0
  94. package/dist/react/components/StationTable.js +115 -0
  95. package/dist/react/components/TrendChart.d.ts +14 -0
  96. package/dist/react/components/TrendChart.js +150 -0
  97. package/dist/react/components/WindArrow.d.ts +7 -0
  98. package/dist/react/components/WindArrow.js +21 -0
  99. package/dist/react/components/WindHistoryChart.d.ts +18 -0
  100. package/dist/react/components/WindHistoryChart.js +278 -0
  101. package/dist/react/components/WindRose.d.ts +17 -0
  102. package/dist/react/components/WindRose.js +99 -0
  103. package/dist/react/components/atoms.d.ts +33 -0
  104. package/dist/react/components/atoms.js +136 -0
  105. package/dist/react/hooks/useFreshness.d.ts +6 -0
  106. package/dist/react/hooks/useFreshness.js +21 -0
  107. package/dist/react/hooks/usePolledJson.js +17 -0
  108. package/dist/react/hooks/useStation.d.ts +23 -0
  109. package/dist/react/hooks/useStation.js +42 -0
  110. package/dist/react/hooks/useStationCurrent.d.ts +23 -0
  111. package/dist/react/hooks/useStationCurrent.js +32 -0
  112. package/dist/react/hooks/useStationFeed.d.ts +22 -0
  113. package/dist/react/hooks/useStationFeed.js +28 -0
  114. package/dist/react/index.d.ts +20 -0
  115. package/dist/react/index.js +21 -0
  116. package/dist/react/lib/cells.js +29 -0
  117. package/dist/scene/air-matrix.js +71 -0
  118. package/dist/scene/atoms.js +102 -0
  119. package/dist/scene/card.js +54 -0
  120. package/dist/scene/chart.js +28 -0
  121. package/dist/scene/current.js +66 -0
  122. package/dist/scene/daily-pattern.js +81 -0
  123. package/dist/scene/dial.js +141 -0
  124. package/dist/scene/glyphs.js +24 -0
  125. package/dist/scene/rose.js +120 -0
  126. package/dist/scene/sparkline.js +73 -0
  127. package/dist/scene/strip.js +63 -0
  128. package/dist/scene/table.js +76 -0
  129. package/dist/scene/trend.js +160 -0
  130. package/dist/scene/wind-history.js +148 -0
  131. package/dist/scene/wind-plot.js +214 -0
  132. package/dist/server/adapter.d.ts +28 -0
  133. package/dist/server/adapter.js +32 -0
  134. package/dist/server/adapters/campbell.d.ts +112 -0
  135. package/dist/server/adapters/campbell.js +414 -0
  136. package/dist/server/adapters/tempest.d.ts +27 -0
  137. package/dist/server/adapters/tempest.js +137 -0
  138. package/dist/server/adapters/windnerd.d.ts +39 -0
  139. package/dist/server/adapters/windnerd.js +159 -0
  140. package/dist/server/config.d.ts +135 -0
  141. package/dist/server/config.js +57 -0
  142. package/dist/server/environment.d.ts +48 -0
  143. package/dist/server/environment.js +128 -0
  144. package/dist/server/feed.d.ts +31 -0
  145. package/dist/server/feed.js +216 -0
  146. package/dist/server/handler.d.ts +17 -0
  147. package/dist/server/handler.js +133 -0
  148. package/dist/server/index.d.ts +10 -0
  149. package/dist/server/index.js +10 -0
  150. package/dist/strings.d.ts +118 -0
  151. package/dist/strings.js +237 -0
  152. package/dist/windnerd.d.ts +5 -0
  153. package/dist/windnerd.js +25 -0
  154. package/package.json +97 -0
  155. package/schema/README.md +14 -0
  156. package/schema/example-current.json +48 -0
  157. package/schema/example-feed.json +147 -0
  158. package/schema/stationcurrent.schema.json +641 -0
  159. package/schema/stationfeed.schema.json +656 -0
  160. package/styles.css +1141 -0
@@ -0,0 +1,277 @@
1
+ import { activeChartIndex, chartIndexAtClient, measuredChartWidth, readoutAriaLive, togglePinnedAt } from "../../scene/chart.js";
2
+ import { WIND_CHART_CLASS, windChartGate, windChartScene } from "../../scene/wind-history.js";
3
+ import { numberAttribute } from "../lib/attributes.js";
4
+ import { MeteoStationElement } from "../lib/base.js";
5
+ import { h, hs } from "../lib/h.js";
6
+ import { windArrowSvg } from "../lib/fragments.js";
7
+ //#region src/elements/elements/WindHistoryChartElement.ts
8
+ let hatchCounter = 0;
9
+ function readoutSpan(parts) {
10
+ return h("span", null, ...parts.map((part) => part.kind === "arrow" ? windArrowSvg(part.deg) : part.text));
11
+ }
12
+ var WindHistoryChartElement = class extends MeteoStationElement {
13
+ static observedAttributes = [
14
+ "compare-offset-days",
15
+ "plot-height",
16
+ "station-id",
17
+ "thresholds",
18
+ "unit",
19
+ "window-hours"
20
+ ];
21
+ #width = null;
22
+ #observer = null;
23
+ #pinnedAt = null;
24
+ #previewIndex = null;
25
+ #scene = null;
26
+ #readout = null;
27
+ #svg = null;
28
+ #hit = null;
29
+ disconnected() {
30
+ this.#observer?.disconnect();
31
+ this.#observer = null;
32
+ }
33
+ render() {
34
+ const station = this.requiredStation("meteo-wind-history-chart");
35
+ const { formatTime, thresholds, unit, words } = this.display();
36
+ const gate = windChartGate(station, words);
37
+ if (gate.kind !== "draw") {
38
+ this.#observer?.disconnect();
39
+ this.#observer = null;
40
+ if (gate.kind === "hidden") this.replaceChildren();
41
+ else this.replaceChildren(h("div", {
42
+ class: gate.className,
43
+ role: "note"
44
+ }, gate.text));
45
+ return;
46
+ }
47
+ const wrap = h("div", { class: WIND_CHART_CLASS });
48
+ this.replaceChildren(wrap);
49
+ this.#observe(wrap);
50
+ if (this.#width == null) return;
51
+ this.#buildChart(wrap, gate.history, thresholds, unit, words, formatTime, this.#width, station.name);
52
+ }
53
+ #observe(wrap) {
54
+ this.#observer?.disconnect();
55
+ if (typeof ResizeObserver === "undefined") {
56
+ this.#width = 360;
57
+ this.#observer = null;
58
+ return;
59
+ }
60
+ this.#observer = new ResizeObserver((entries) => {
61
+ const width = measuredChartWidth(entries[0]?.contentRect.width ?? 0);
62
+ if (width !== this.#width) {
63
+ this.#width = width;
64
+ this.requestRender();
65
+ }
66
+ });
67
+ this.#observer.observe(wrap);
68
+ }
69
+ #buildChart(wrap, history, thresholds, unit, words, formatTime, width, stationName) {
70
+ const scene = windChartScene({
71
+ compareOffsetDays: numberAttribute(this.getAttribute("compare-offset-days")),
72
+ formatTime,
73
+ hatchId: `meteo-hatch-e${++hatchCounter}`,
74
+ history,
75
+ plotHeight: numberAttribute(this.getAttribute("plot-height")),
76
+ stationName,
77
+ thresholds,
78
+ unit,
79
+ width,
80
+ windowHours: numberAttribute(this.getAttribute("window-hours")),
81
+ words
82
+ });
83
+ this.#scene = scene;
84
+ const readout = h("output", {
85
+ "aria-label": scene.readout.ariaLabel,
86
+ class: scene.readout.className
87
+ });
88
+ this.#readout = readout;
89
+ const hit = hs("rect", {
90
+ class: scene.hit.className,
91
+ fill: scene.hit.fill,
92
+ height: scene.hit.height,
93
+ onclick: (event) => this.#handleClick(event),
94
+ onpointerleave: () => {
95
+ this.#previewIndex = null;
96
+ this.#updateCursor();
97
+ },
98
+ onpointermove: (event) => this.#handlePointerMove(event),
99
+ width: scene.hit.width,
100
+ x: scene.hit.x,
101
+ y: scene.hit.y
102
+ });
103
+ this.#hit = hit;
104
+ const svg = hs("svg", {
105
+ "aria-label": scene.svg.ariaLabel,
106
+ class: scene.svg.className,
107
+ height: scene.svg.height,
108
+ role: "img",
109
+ viewBox: scene.svg.viewBox,
110
+ width: scene.svg.width
111
+ }, hs("defs", null, hs("pattern", {
112
+ height: scene.defs.pattern.height,
113
+ id: scene.defs.pattern.id,
114
+ patternTransform: scene.defs.pattern.transform,
115
+ patternUnits: scene.defs.pattern.units,
116
+ width: scene.defs.pattern.width
117
+ }, hs("line", {
118
+ class: scene.defs.pattern.line.className,
119
+ x1: scene.defs.pattern.line.x1,
120
+ x2: scene.defs.pattern.line.x2,
121
+ y1: scene.defs.pattern.line.y1,
122
+ y2: scene.defs.pattern.line.y2
123
+ })), hs("clipPath", { id: scene.defs.clip.id }, hs("rect", {
124
+ height: scene.defs.clip.rect.height,
125
+ width: scene.defs.clip.rect.width,
126
+ x: scene.defs.clip.rect.x,
127
+ y: scene.defs.clip.rect.y
128
+ }))), scene.zones.map((zone) => hs("rect", {
129
+ class: zone.className,
130
+ height: zone.height,
131
+ width: zone.width,
132
+ x: zone.x,
133
+ y: zone.y
134
+ })), scene.grid.map(({ line, label }) => hs("g", null, hs("line", {
135
+ class: line.className,
136
+ x1: line.x1,
137
+ x2: line.x2,
138
+ y1: line.y1,
139
+ y2: line.y2
140
+ }), hs("text", {
141
+ class: label.className,
142
+ "text-anchor": label.anchor,
143
+ x: label.x,
144
+ y: label.y
145
+ }, label.text))), scene.thresholdGuides.map(({ line, label }) => hs("g", null, hs("line", {
146
+ class: line.className,
147
+ x1: line.x1,
148
+ x2: line.x2,
149
+ y1: line.y1,
150
+ y2: line.y2
151
+ }), hs("text", {
152
+ class: label.className,
153
+ "text-anchor": label.anchor,
154
+ x: label.x,
155
+ y: label.y
156
+ }, label.text))), scene.vaneGuides.map((guide) => hs("line", {
157
+ class: guide.className,
158
+ x1: guide.x1,
159
+ x2: guide.x2,
160
+ y1: guide.y1,
161
+ y2: guide.y2
162
+ })), scene.gaps.map((gap) => hs("rect", {
163
+ class: gap.className,
164
+ fill: gap.fill,
165
+ height: gap.height,
166
+ width: gap.width,
167
+ x: gap.x,
168
+ y: gap.y
169
+ })), scene.band != null && hs("polygon", {
170
+ class: scene.band.className,
171
+ points: scene.band.points
172
+ }), scene.compare != null && hs("polyline", {
173
+ class: scene.compare.className,
174
+ "clip-path": scene.compare.clipPath,
175
+ points: scene.compare.points
176
+ }), scene.mean.kind === "polyline" ? hs("polyline", {
177
+ class: scene.mean.className,
178
+ points: scene.mean.points
179
+ }) : scene.mean.segments.map((segment) => hs("line", {
180
+ class: segment.className,
181
+ x1: segment.x1,
182
+ x2: segment.x2,
183
+ y1: segment.y1,
184
+ y2: segment.y2
185
+ })), scene.calmNote != null && hs("text", {
186
+ class: scene.calmNote.className,
187
+ "text-anchor": scene.calmNote.anchor,
188
+ x: scene.calmNote.x,
189
+ y: scene.calmNote.y
190
+ }, scene.calmNote.text), hs("text", {
191
+ class: scene.rowLabels.to.className,
192
+ "text-anchor": scene.rowLabels.to.anchor,
193
+ x: scene.rowLabels.to.x,
194
+ y: scene.rowLabels.to.y
195
+ }, scene.rowLabels.to.text), scene.vanes.map((vane) => vane.mark.kind === "calm" ? hs("text", {
196
+ class: vane.mark.text.className,
197
+ "text-anchor": vane.mark.text.anchor,
198
+ x: vane.mark.text.x,
199
+ y: vane.mark.text.y
200
+ }, vane.mark.text.text) : hs("path", {
201
+ class: vane.mark.className,
202
+ d: vane.mark.d
203
+ })), scene.vanes.map((vane) => hs("text", {
204
+ class: vane.label.className,
205
+ "text-anchor": vane.label.anchor,
206
+ x: vane.label.x,
207
+ y: vane.label.y
208
+ }, vane.label.text)), hs("text", {
209
+ class: scene.rowLabels.avg.className,
210
+ "text-anchor": scene.rowLabels.avg.anchor,
211
+ x: scene.rowLabels.avg.x,
212
+ y: scene.rowLabels.avg.y
213
+ }, scene.rowLabels.avg.text), scene.vanes.map((vane) => hs("text", {
214
+ class: vane.value.className,
215
+ "text-anchor": vane.value.anchor,
216
+ x: vane.value.x,
217
+ y: vane.value.y
218
+ }, vane.value.text)), scene.ticks.map((tick) => hs("text", {
219
+ class: tick.className,
220
+ "text-anchor": tick.anchor,
221
+ x: tick.x,
222
+ y: tick.y
223
+ }, tick.text)), hit);
224
+ this.#svg = svg;
225
+ wrap.replaceChildren(readout, svg);
226
+ this.#updateCursor();
227
+ }
228
+ #indexAtPoint(clientX) {
229
+ const scene = this.#scene;
230
+ const svg = this.#svg;
231
+ if (scene == null || svg == null) return null;
232
+ return chartIndexAtClient(scene.points, scene.frame, scene.scales, clientX, svg.getBoundingClientRect());
233
+ }
234
+ #handlePointerMove(event) {
235
+ if (event.pointerType === "touch") return;
236
+ this.#previewIndex = this.#indexAtPoint(event.clientX);
237
+ this.#updateCursor();
238
+ }
239
+ #handleClick(event) {
240
+ const index = this.#indexAtPoint(event.clientX);
241
+ if (index == null) return;
242
+ const observedAt = this.#scene?.points[index]?.observedAt;
243
+ if (observedAt == null) return;
244
+ this.#pinnedAt = togglePinnedAt(this.#pinnedAt, observedAt);
245
+ this.#previewIndex = null;
246
+ this.#updateCursor();
247
+ }
248
+ #updateCursor() {
249
+ const scene = this.#scene;
250
+ const readout = this.#readout;
251
+ const svg = this.#svg;
252
+ const hit = this.#hit;
253
+ if (scene == null || readout == null || svg == null || hit == null) return;
254
+ const inspection = scene.inspect(activeChartIndex(scene.points, this.#pinnedAt, this.#previewIndex));
255
+ readout.setAttribute("aria-live", readoutAriaLive(this.#previewIndex));
256
+ readout.replaceChildren(h("strong", null, inspection.readout.strong), readoutSpan(inspection.readout.span));
257
+ for (const mark of [...svg.querySelectorAll(".meteo-cursor, .meteo-cursor-dot")]) mark.remove();
258
+ const cursor = inspection.cursor;
259
+ if (cursor != null) {
260
+ svg.insertBefore(hs("line", {
261
+ class: cursor.line.className,
262
+ x1: cursor.line.x1,
263
+ x2: cursor.line.x2,
264
+ y1: cursor.line.y1,
265
+ y2: cursor.line.y2
266
+ }), hit);
267
+ svg.insertBefore(hs("circle", {
268
+ class: cursor.dot.className,
269
+ cx: cursor.dot.cx,
270
+ cy: cursor.dot.cy,
271
+ r: cursor.dot.r
272
+ }), hit);
273
+ }
274
+ }
275
+ };
276
+ //#endregion
277
+ export { WindHistoryChartElement };
@@ -0,0 +1,17 @@
1
+ import { HistoryPoint } from "../../contract.js";
2
+ import { FavorableDirection } from "../../instruments.js";
3
+ import "../../index.js";
4
+ import { MeteoStationElement } from "../lib/base.js";
5
+ //#region src/elements/elements/WindRoseElement.d.ts
6
+ declare class WindRoseElement extends MeteoStationElement {
7
+ #private;
8
+ static readonly observedAttributes: string[];
9
+ constructor();
10
+ get points(): HistoryPoint[] | undefined;
11
+ set points(value: HistoryPoint[] | undefined);
12
+ get favorableDirections(): FavorableDirection[] | undefined;
13
+ set favorableDirections(value: FavorableDirection[] | undefined);
14
+ protected render(): void;
15
+ }
16
+ //#endregion
17
+ export { WindRoseElement };
@@ -0,0 +1,106 @@
1
+ import { resolveStation } from "../../display.js";
2
+ import { windRoseGate, windRoseScene, windRoseSource } from "../../scene/rose.js";
3
+ import { numberAttribute } from "../lib/attributes.js";
4
+ import { MeteoStationElement } from "../lib/base.js";
5
+ import { h, hs } from "../lib/h.js";
6
+ //#region src/elements/elements/WindRoseElement.ts
7
+ var WindRoseElement = class extends MeteoStationElement {
8
+ static observedAttributes = [
9
+ "sector-count",
10
+ "station-id",
11
+ "thresholds"
12
+ ];
13
+ #points;
14
+ #favorableDirections;
15
+ constructor() {
16
+ super();
17
+ for (const name of ["points", "favorableDirections"]) this.upgradeProperty(name);
18
+ }
19
+ get points() {
20
+ return this.#points;
21
+ }
22
+ set points(value) {
23
+ this.#points = value;
24
+ this.requestRender();
25
+ }
26
+ get favorableDirections() {
27
+ return this.#favorableDirections;
28
+ }
29
+ set favorableDirections(value) {
30
+ this.#favorableDirections = value;
31
+ this.requestRender();
32
+ }
33
+ render() {
34
+ const station = this.station ?? (this.#points == null ? resolveStation(this.ambient()?.feed ?? null, this.getAttribute("station-id") ?? void 0) ?? void 0 : void 0);
35
+ const { thresholds, words } = this.display();
36
+ const source = windRoseSource(this.#points, station);
37
+ const gate = windRoseGate(source, words);
38
+ if (gate.kind === "note") {
39
+ this.replaceChildren(h("div", {
40
+ class: gate.className,
41
+ role: "note"
42
+ }, gate.text));
43
+ return;
44
+ }
45
+ const scene = windRoseScene({
46
+ favorableDirections: this.#favorableDirections,
47
+ sectorCount: numberAttribute(this.getAttribute("sector-count")) ?? 16,
48
+ source,
49
+ stationName: station?.name,
50
+ thresholds,
51
+ words
52
+ });
53
+ this.replaceChildren(h("div", { class: scene.className }, hs("svg", {
54
+ "aria-label": scene.svg.ariaLabel,
55
+ class: scene.svg.className,
56
+ height: scene.svg.height,
57
+ role: "img",
58
+ viewBox: scene.svg.viewBox,
59
+ width: scene.svg.width
60
+ }, scene.gridCircles.map((circle) => hs("circle", {
61
+ class: circle.className,
62
+ cx: circle.cx,
63
+ cy: circle.cy,
64
+ r: circle.r
65
+ })), scene.ring != null ? [hs("circle", {
66
+ class: scene.ring.unfavorable.className,
67
+ cx: scene.ring.unfavorable.cx,
68
+ cy: scene.ring.unfavorable.cy,
69
+ r: scene.ring.unfavorable.r
70
+ }), scene.ring.favorable.map((arc) => hs("path", {
71
+ class: arc.className,
72
+ d: arc.d
73
+ }))] : null, scene.ticks.map((tick) => hs("line", {
74
+ class: tick.className,
75
+ x1: tick.x1,
76
+ x2: tick.x2,
77
+ y1: tick.y1,
78
+ y2: tick.y2
79
+ })), scene.letters.map((letter) => hs("text", {
80
+ class: letter.className,
81
+ "text-anchor": letter.anchor,
82
+ x: letter.x,
83
+ y: letter.y
84
+ }, letter.text)), scene.petals.map((petal) => hs("path", {
85
+ class: petal.className,
86
+ d: petal.d
87
+ })), scene.ringLabel != null && hs("text", {
88
+ class: scene.ringLabel.className,
89
+ "text-anchor": scene.ringLabel.anchor,
90
+ x: scene.ringLabel.x,
91
+ y: scene.ringLabel.y
92
+ }, scene.ringLabel.text), hs("circle", {
93
+ class: scene.hub.className,
94
+ cx: scene.hub.cx,
95
+ cy: scene.hub.cy,
96
+ r: scene.hub.r
97
+ }), hs("circle", {
98
+ class: scene.dot.className,
99
+ cx: scene.dot.cx,
100
+ cy: scene.dot.cy,
101
+ r: scene.dot.r
102
+ })), scene.calmCaption != null ? h("p", { class: scene.calmCaption.className }, scene.calmCaption.text) : null));
103
+ }
104
+ };
105
+ //#endregion
106
+ export { WindRoseElement };
@@ -0,0 +1,48 @@
1
+ import { SpeedKind } from "../../format.js";
2
+ import { MeteoStationElement } from "../lib/base.js";
3
+ //#region src/elements/elements/atoms.d.ts
4
+ declare abstract class SpeedAtomElement extends MeteoStationElement {
5
+ static readonly observedAttributes: ("station-id" | "unit")[];
6
+ protected abstract readonly kind: SpeedKind;
7
+ protected abstract readonly component: string;
8
+ protected render(): void;
9
+ }
10
+ declare class SpeedElement extends SpeedAtomElement {
11
+ protected readonly kind = "average";
12
+ protected readonly component = "meteo-speed";
13
+ }
14
+ declare class GustElement extends SpeedAtomElement {
15
+ protected readonly kind = "gust";
16
+ protected readonly component = "meteo-gust";
17
+ }
18
+ declare class LullElement extends SpeedAtomElement {
19
+ protected readonly kind = "lull";
20
+ protected readonly component = "meteo-lull";
21
+ }
22
+ declare class TemperatureElement extends MeteoStationElement {
23
+ static readonly observedAttributes: string[];
24
+ protected render(): void;
25
+ }
26
+ declare class PressureElement extends MeteoStationElement {
27
+ static readonly observedAttributes: string[];
28
+ protected render(): void;
29
+ }
30
+ declare class DirectionElement extends MeteoStationElement {
31
+ static readonly observedAttributes: string[];
32
+ protected render(): void;
33
+ }
34
+ declare class UpdatedAtElement extends MeteoStationElement {
35
+ static readonly observedAttributes: string[];
36
+ protected connected(): void;
37
+ protected render(): void;
38
+ }
39
+ declare class BandChipElement extends MeteoStationElement {
40
+ #private;
41
+ static readonly observedAttributes: string[];
42
+ constructor();
43
+ get labels(): readonly string[] | undefined;
44
+ set labels(value: readonly string[] | undefined);
45
+ protected render(): void;
46
+ }
47
+ //#endregion
48
+ export { BandChipElement, DirectionElement, GustElement, LullElement, PressureElement, SpeedElement, TemperatureElement, UpdatedAtElement };
@@ -0,0 +1,131 @@
1
+ import { bandChipScene, directionAtomScene, pressureAtomScene, speedAtomScene, temperatureAtomScene, updatedAtScene } from "../../scene/atoms.js";
2
+ import { MeteoStationElement } from "../lib/base.js";
3
+ import { h } from "../lib/h.js";
4
+ import { directionCellNodes } from "../lib/fragments.js";
5
+ //#region src/elements/elements/atoms.ts
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
+ var SpeedAtomElement = class extends MeteoStationElement {
15
+ static observedAttributes = [...STATION_ATTRIBUTES];
16
+ render() {
17
+ const station = this.requiredStation(this.component);
18
+ const { unit, words } = this.display();
19
+ this.replaceChildren(valueAtomNode(speedAtomScene(station, this.kind, unit, words)));
20
+ }
21
+ };
22
+ var SpeedElement = class extends SpeedAtomElement {
23
+ kind = "average";
24
+ component = "meteo-speed";
25
+ };
26
+ var GustElement = class extends SpeedAtomElement {
27
+ kind = "gust";
28
+ component = "meteo-gust";
29
+ };
30
+ var LullElement = class extends SpeedAtomElement {
31
+ kind = "lull";
32
+ component = "meteo-lull";
33
+ };
34
+ var TemperatureElement = class extends MeteoStationElement {
35
+ static observedAttributes = ["station-id"];
36
+ render() {
37
+ const station = this.requiredStation("meteo-temperature");
38
+ const { words } = this.display();
39
+ this.replaceChildren(valueAtomNode(temperatureAtomScene(station, words)));
40
+ }
41
+ };
42
+ var PressureElement = class extends MeteoStationElement {
43
+ static observedAttributes = ["station-id"];
44
+ render() {
45
+ const station = this.requiredStation("meteo-pressure");
46
+ const { words } = this.display();
47
+ this.replaceChildren(valueAtomNode(pressureAtomScene(station, words)));
48
+ }
49
+ };
50
+ var DirectionElement = class extends MeteoStationElement {
51
+ static observedAttributes = ["station-id"];
52
+ render() {
53
+ const station = this.requiredStation("meteo-direction");
54
+ const { words } = this.display();
55
+ const scene = directionAtomScene(station, words);
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)));
64
+ }
65
+ };
66
+ var UpdatedAtElement = class extends MeteoStationElement {
67
+ static observedAttributes = [
68
+ "received-at-ms",
69
+ "served-at",
70
+ "station-id"
71
+ ];
72
+ connected() {
73
+ this.watchFreshness();
74
+ }
75
+ render() {
76
+ const station = this.requiredStation("meteo-updated-at");
77
+ const { formatTime, words } = this.display();
78
+ const scene = updatedAtScene({
79
+ formatTime,
80
+ nowMs: Date.now(),
81
+ receivedAtMs: this.receivedAtMsValue(),
82
+ servedAt: this.servedAtValue(),
83
+ station,
84
+ 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));
94
+ }
95
+ };
96
+ var BandChipElement = class extends MeteoStationElement {
97
+ static observedAttributes = [
98
+ "station-id",
99
+ "thresholds",
100
+ "unit"
101
+ ];
102
+ #labels;
103
+ constructor() {
104
+ super();
105
+ this.upgradeProperty("labels");
106
+ }
107
+ get labels() {
108
+ return this.#labels;
109
+ }
110
+ set labels(value) {
111
+ this.#labels = value;
112
+ this.requestRender();
113
+ }
114
+ render() {
115
+ const station = this.requiredStation("meteo-band-chip");
116
+ const { thresholds, unit, words } = this.display();
117
+ const scene = bandChipScene({
118
+ labels: this.#labels,
119
+ station,
120
+ thresholds,
121
+ unit,
122
+ words
123
+ });
124
+ this.replaceChildren(h("span", {
125
+ class: scene.className,
126
+ "data-band": scene.band
127
+ }, scene.text));
128
+ }
129
+ };
130
+ //#endregion
131
+ export { BandChipElement, DirectionElement, GustElement, LullElement, PressureElement, SpeedElement, TemperatureElement, UpdatedAtElement };
@@ -0,0 +1,48 @@
1
+ import { AmbientStationFeed } from "./lib/ambient.js";
2
+ import { BandChipElement, DirectionElement, GustElement, LullElement, PressureElement, SpeedElement, TemperatureElement, UpdatedAtElement } from "./elements/atoms.js";
3
+ import { AirMatrixElement } from "./elements/AirMatrixElement.js";
4
+ import { CurrentConditionsElement } from "./elements/CurrentConditionsElement.js";
5
+ import { DailyPatternElement } from "./elements/DailyPatternElement.js";
6
+ import { DialElement } from "./elements/DialElement.js";
7
+ import { FreshnessBadgeElement } from "./elements/FreshnessBadgeElement.js";
8
+ import { SparklineElement } from "./elements/SparklineElement.js";
9
+ import { StationFeedElement } from "./elements/StationFeedElement.js";
10
+ import { StationStripElement } from "./elements/StationStripElement.js";
11
+ import { StationMetaRenderer, StationTableElement } from "./elements/StationTableElement.js";
12
+ import { TrendChartElement } from "./elements/TrendChartElement.js";
13
+ import { WindArrowElement } from "./elements/WindArrowElement.js";
14
+ import { WindHistoryChartElement } from "./elements/WindHistoryChartElement.js";
15
+ import { WindRoseElement } from "./elements/WindRoseElement.js";
16
+ import { StationCardChartElement, StationCardElement, StationCardHeaderElement, StationCardInstrumentElement, StationCardSummaryElement } from "./elements/StationCardElement.js";
17
+ //#region src/elements/index.d.ts
18
+ declare const meteoElementTags: {
19
+ readonly "meteo-station-feed": typeof StationFeedElement;
20
+ readonly "meteo-station-card": typeof StationCardElement;
21
+ readonly "meteo-air-matrix": typeof AirMatrixElement;
22
+ readonly "meteo-band-chip": typeof BandChipElement;
23
+ readonly "meteo-current-conditions": typeof CurrentConditionsElement;
24
+ readonly "meteo-daily-pattern": typeof DailyPatternElement;
25
+ readonly "meteo-dial": typeof DialElement;
26
+ readonly "meteo-direction": typeof DirectionElement;
27
+ readonly "meteo-freshness-badge": typeof FreshnessBadgeElement;
28
+ readonly "meteo-gust": typeof GustElement;
29
+ readonly "meteo-lull": typeof LullElement;
30
+ readonly "meteo-pressure": typeof PressureElement;
31
+ readonly "meteo-sparkline": typeof SparklineElement;
32
+ readonly "meteo-speed": typeof SpeedElement;
33
+ readonly "meteo-station-strip": typeof StationStripElement;
34
+ readonly "meteo-station-table": typeof StationTableElement;
35
+ readonly "meteo-temperature": typeof TemperatureElement;
36
+ readonly "meteo-trend-chart": typeof TrendChartElement;
37
+ readonly "meteo-updated-at": typeof UpdatedAtElement;
38
+ readonly "meteo-wind-arrow": typeof WindArrowElement;
39
+ readonly "meteo-wind-history-chart": typeof WindHistoryChartElement;
40
+ readonly "meteo-wind-rose": typeof WindRoseElement;
41
+ readonly "meteo-station-card-chart": typeof StationCardChartElement;
42
+ readonly "meteo-station-card-header": typeof StationCardHeaderElement;
43
+ readonly "meteo-station-card-instrument": typeof StationCardInstrumentElement;
44
+ readonly "meteo-station-card-summary": typeof StationCardSummaryElement;
45
+ };
46
+ declare function defineMeteoElements(registry?: CustomElementRegistry): void;
47
+ //#endregion
48
+ export { AirMatrixElement, type AmbientStationFeed, BandChipElement, CurrentConditionsElement, DailyPatternElement, DialElement, DirectionElement, FreshnessBadgeElement, GustElement, LullElement, PressureElement, SparklineElement, SpeedElement, StationCardChartElement, StationCardElement, StationCardHeaderElement, StationCardInstrumentElement, StationCardSummaryElement, StationFeedElement, type StationMetaRenderer, StationStripElement, StationTableElement, TemperatureElement, TrendChartElement, UpdatedAtElement, WindArrowElement, WindHistoryChartElement, WindRoseElement, defineMeteoElements, meteoElementTags };
@@ -0,0 +1,57 @@
1
+ import { BandChipElement, DirectionElement, GustElement, LullElement, PressureElement, SpeedElement, TemperatureElement, UpdatedAtElement } from "./elements/atoms.js";
2
+ import { AirMatrixElement } from "./elements/AirMatrixElement.js";
3
+ import { DialElement } from "./elements/DialElement.js";
4
+ import { CurrentConditionsElement } from "./elements/CurrentConditionsElement.js";
5
+ import { DailyPatternElement } from "./elements/DailyPatternElement.js";
6
+ import { FreshnessBadgeElement } from "./elements/FreshnessBadgeElement.js";
7
+ import { SparklineElement } from "./elements/SparklineElement.js";
8
+ import { StationFeedElement } from "./elements/StationFeedElement.js";
9
+ import { StationStripElement } from "./elements/StationStripElement.js";
10
+ import { StationTableElement } from "./elements/StationTableElement.js";
11
+ import { TrendChartElement } from "./elements/TrendChartElement.js";
12
+ import { WindArrowElement } from "./elements/WindArrowElement.js";
13
+ import { WindHistoryChartElement } from "./elements/WindHistoryChartElement.js";
14
+ import { WindRoseElement } from "./elements/WindRoseElement.js";
15
+ import { StationCardChartElement, StationCardElement, StationCardHeaderElement, StationCardInstrumentElement, StationCardSummaryElement } from "./elements/StationCardElement.js";
16
+ //#region src/elements/index.ts
17
+ const meteoElementTags = {
18
+ "meteo-station-feed": StationFeedElement,
19
+ "meteo-station-card": StationCardElement,
20
+ "meteo-air-matrix": AirMatrixElement,
21
+ "meteo-band-chip": BandChipElement,
22
+ "meteo-current-conditions": CurrentConditionsElement,
23
+ "meteo-daily-pattern": DailyPatternElement,
24
+ "meteo-dial": DialElement,
25
+ "meteo-direction": DirectionElement,
26
+ "meteo-freshness-badge": FreshnessBadgeElement,
27
+ "meteo-gust": GustElement,
28
+ "meteo-lull": LullElement,
29
+ "meteo-pressure": PressureElement,
30
+ "meteo-sparkline": SparklineElement,
31
+ "meteo-speed": SpeedElement,
32
+ "meteo-station-strip": StationStripElement,
33
+ "meteo-station-table": StationTableElement,
34
+ "meteo-temperature": TemperatureElement,
35
+ "meteo-trend-chart": TrendChartElement,
36
+ "meteo-updated-at": UpdatedAtElement,
37
+ "meteo-wind-arrow": WindArrowElement,
38
+ "meteo-wind-history-chart": WindHistoryChartElement,
39
+ "meteo-wind-rose": WindRoseElement,
40
+ "meteo-station-card-chart": StationCardChartElement,
41
+ "meteo-station-card-header": StationCardHeaderElement,
42
+ "meteo-station-card-instrument": StationCardInstrumentElement,
43
+ "meteo-station-card-summary": StationCardSummaryElement
44
+ };
45
+ function defineMeteoElements(registry = customElements) {
46
+ for (const [tag, constructor] of Object.entries(meteoElementTags)) {
47
+ const existing = registry.get(tag);
48
+ if (existing === constructor) continue;
49
+ if (existing != null) {
50
+ console.warn(`meteo: <${tag}> is already defined by a different constructor; skipping.`);
51
+ continue;
52
+ }
53
+ registry.define(tag, constructor);
54
+ }
55
+ }
56
+ //#endregion
57
+ export { AirMatrixElement, BandChipElement, CurrentConditionsElement, DailyPatternElement, DialElement, DirectionElement, FreshnessBadgeElement, GustElement, LullElement, PressureElement, SparklineElement, SpeedElement, StationCardChartElement, StationCardElement, StationCardHeaderElement, StationCardInstrumentElement, StationCardSummaryElement, StationFeedElement, StationStripElement, StationTableElement, TemperatureElement, TrendChartElement, UpdatedAtElement, WindArrowElement, WindHistoryChartElement, WindRoseElement, defineMeteoElements, meteoElementTags };