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