@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.
- package/LICENSE +21 -0
- package/README.md +53 -0
- package/dist/air.d.ts +13 -0
- package/dist/air.js +76 -0
- package/dist/client/index.d.ts +4 -0
- package/dist/client/index.js +4 -0
- package/dist/client/poll.d.ts +42 -0
- package/dist/client/poll.js +121 -0
- package/dist/client/stores.d.ts +46 -0
- package/dist/client/stores.js +128 -0
- package/dist/client/ticker.d.ts +4 -0
- package/dist/client/ticker.js +19 -0
- package/dist/contract.d.ts +381 -0
- package/dist/contract.js +143 -0
- package/dist/derive.d.ts +54 -0
- package/dist/derive.js +134 -0
- package/dist/display.d.ts +28 -0
- package/dist/display.js +27 -0
- package/dist/elements/elements/AirMatrixElement.d.ts +14 -0
- package/dist/elements/elements/AirMatrixElement.js +83 -0
- package/dist/elements/elements/CurrentConditionsElement.d.ts +9 -0
- package/dist/elements/elements/CurrentConditionsElement.js +52 -0
- package/dist/elements/elements/DailyPatternElement.d.ts +15 -0
- package/dist/elements/elements/DailyPatternElement.js +200 -0
- package/dist/elements/elements/DialElement.d.ts +9 -0
- package/dist/elements/elements/DialElement.js +128 -0
- package/dist/elements/elements/FreshnessBadgeElement.d.ts +8 -0
- package/dist/elements/elements/FreshnessBadgeElement.js +22 -0
- package/dist/elements/elements/SparklineElement.d.ts +9 -0
- package/dist/elements/elements/SparklineElement.js +74 -0
- package/dist/elements/elements/StationCardElement.d.ts +53 -0
- package/dist/elements/elements/StationCardElement.js +211 -0
- package/dist/elements/elements/StationFeedElement.d.ts +32 -0
- package/dist/elements/elements/StationFeedElement.js +215 -0
- package/dist/elements/elements/StationStripElement.d.ts +9 -0
- package/dist/elements/elements/StationStripElement.js +43 -0
- package/dist/elements/elements/StationTableElement.d.ts +18 -0
- package/dist/elements/elements/StationTableElement.js +102 -0
- package/dist/elements/elements/TrendChartElement.d.ts +10 -0
- package/dist/elements/elements/TrendChartElement.js +174 -0
- package/dist/elements/elements/WindArrowElement.d.ts +8 -0
- package/dist/elements/elements/WindArrowElement.js +14 -0
- package/dist/elements/elements/WindHistoryChartElement.d.ts +10 -0
- package/dist/elements/elements/WindHistoryChartElement.js +277 -0
- package/dist/elements/elements/WindRoseElement.d.ts +17 -0
- package/dist/elements/elements/WindRoseElement.js +106 -0
- package/dist/elements/elements/atoms.d.ts +48 -0
- package/dist/elements/elements/atoms.js +131 -0
- package/dist/elements/index.d.ts +48 -0
- package/dist/elements/index.js +57 -0
- package/dist/elements/lib/ambient.d.ts +15 -0
- package/dist/elements/lib/ambient.js +5 -0
- package/dist/elements/lib/attributes.js +21 -0
- package/dist/elements/lib/base.d.ts +45 -0
- package/dist/elements/lib/base.js +152 -0
- package/dist/elements/lib/context.js +28 -0
- package/dist/elements/lib/fragments.js +45 -0
- package/dist/elements/lib/h.js +35 -0
- package/dist/elements/register.d.ts +1 -0
- package/dist/elements/register.js +5 -0
- package/dist/endpoints.d.ts +5 -0
- package/dist/endpoints.js +10 -0
- package/dist/fixtures.d.ts +23 -0
- package/dist/fixtures.js +67 -0
- package/dist/format.d.ts +31 -0
- package/dist/format.js +82 -0
- package/dist/geometry.d.ts +84 -0
- package/dist/geometry.js +333 -0
- package/dist/index.d.ts +12 -0
- package/dist/index.js +12 -0
- package/dist/instruments.d.ts +75 -0
- package/dist/instruments.js +173 -0
- package/dist/merge-current.d.ts +13 -0
- package/dist/merge-current.js +54 -0
- package/dist/react/components/AirMatrix.d.ts +11 -0
- package/dist/react/components/AirMatrix.js +82 -0
- package/dist/react/components/CurrentConditions.d.ts +17 -0
- package/dist/react/components/CurrentConditions.js +98 -0
- package/dist/react/components/DailyPattern.d.ts +19 -0
- package/dist/react/components/DailyPattern.js +212 -0
- package/dist/react/components/Dial.d.ts +17 -0
- package/dist/react/components/Dial.js +133 -0
- package/dist/react/components/FreshnessBadge.d.ts +10 -0
- package/dist/react/components/FreshnessBadge.js +20 -0
- package/dist/react/components/Sparkline.d.ts +17 -0
- package/dist/react/components/Sparkline.js +60 -0
- package/dist/react/components/StationCard.d.ts +46 -0
- package/dist/react/components/StationCard.js +140 -0
- package/dist/react/components/StationFeedProvider.d.ts +27 -0
- package/dist/react/components/StationFeedProvider.js +40 -0
- package/dist/react/components/StationStrip.d.ts +16 -0
- package/dist/react/components/StationStrip.js +84 -0
- package/dist/react/components/StationTable.d.ts +18 -0
- package/dist/react/components/StationTable.js +115 -0
- package/dist/react/components/TrendChart.d.ts +14 -0
- package/dist/react/components/TrendChart.js +150 -0
- package/dist/react/components/WindArrow.d.ts +7 -0
- package/dist/react/components/WindArrow.js +21 -0
- package/dist/react/components/WindHistoryChart.d.ts +18 -0
- package/dist/react/components/WindHistoryChart.js +278 -0
- package/dist/react/components/WindRose.d.ts +17 -0
- package/dist/react/components/WindRose.js +99 -0
- package/dist/react/components/atoms.d.ts +33 -0
- package/dist/react/components/atoms.js +136 -0
- package/dist/react/hooks/useFreshness.d.ts +6 -0
- package/dist/react/hooks/useFreshness.js +21 -0
- package/dist/react/hooks/usePolledJson.js +17 -0
- package/dist/react/hooks/useStation.d.ts +23 -0
- package/dist/react/hooks/useStation.js +42 -0
- package/dist/react/hooks/useStationCurrent.d.ts +23 -0
- package/dist/react/hooks/useStationCurrent.js +32 -0
- package/dist/react/hooks/useStationFeed.d.ts +22 -0
- package/dist/react/hooks/useStationFeed.js +28 -0
- package/dist/react/index.d.ts +20 -0
- package/dist/react/index.js +21 -0
- package/dist/react/lib/cells.js +29 -0
- package/dist/scene/air-matrix.js +71 -0
- package/dist/scene/atoms.js +102 -0
- package/dist/scene/card.js +54 -0
- package/dist/scene/chart.js +28 -0
- package/dist/scene/current.js +66 -0
- package/dist/scene/daily-pattern.js +81 -0
- package/dist/scene/dial.js +141 -0
- package/dist/scene/glyphs.js +24 -0
- package/dist/scene/rose.js +120 -0
- package/dist/scene/sparkline.js +73 -0
- package/dist/scene/strip.js +63 -0
- package/dist/scene/table.js +76 -0
- package/dist/scene/trend.js +160 -0
- package/dist/scene/wind-history.js +148 -0
- package/dist/scene/wind-plot.js +214 -0
- package/dist/server/adapter.d.ts +28 -0
- package/dist/server/adapter.js +32 -0
- package/dist/server/adapters/campbell.d.ts +112 -0
- package/dist/server/adapters/campbell.js +414 -0
- package/dist/server/adapters/tempest.d.ts +27 -0
- package/dist/server/adapters/tempest.js +137 -0
- package/dist/server/adapters/windnerd.d.ts +39 -0
- package/dist/server/adapters/windnerd.js +159 -0
- package/dist/server/config.d.ts +135 -0
- package/dist/server/config.js +57 -0
- package/dist/server/environment.d.ts +48 -0
- package/dist/server/environment.js +128 -0
- package/dist/server/feed.d.ts +31 -0
- package/dist/server/feed.js +216 -0
- package/dist/server/handler.d.ts +17 -0
- package/dist/server/handler.js +133 -0
- package/dist/server/index.d.ts +10 -0
- package/dist/server/index.js +10 -0
- package/dist/strings.d.ts +118 -0
- package/dist/strings.js +237 -0
- package/dist/windnerd.d.ts +5 -0
- package/dist/windnerd.js +25 -0
- package/package.json +97 -0
- package/schema/README.md +14 -0
- package/schema/example-current.json +48 -0
- package/schema/example-feed.json +147 -0
- package/schema/stationcurrent.schema.json +641 -0
- package/schema/stationfeed.schema.json +656 -0
- package/styles.css +1141 -0
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { Station } from "../../contract.js";
|
|
2
|
+
import { FormatTime, StationStringOverrides } from "../../strings.js";
|
|
3
|
+
import "../../index.js";
|
|
4
|
+
//#region src/react/components/AirMatrix.d.ts
|
|
5
|
+
declare function AirMatrix({ stations: stationsProp, strings: stringsProp, formatTime: formatTimeProp }: {
|
|
6
|
+
stations?: readonly Station[];
|
|
7
|
+
strings?: StationStringOverrides;
|
|
8
|
+
formatTime?: FormatTime;
|
|
9
|
+
}): import("react").JSX.Element | null;
|
|
10
|
+
//#endregion
|
|
11
|
+
export { AirMatrix };
|
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { resolveDisplay } from "../../display.js";
|
|
3
|
+
import { airMatrixScene } from "../../scene/air-matrix.js";
|
|
4
|
+
import { requireResolved, useStationFeedContext } from "./StationFeedProvider.js";
|
|
5
|
+
import { useId, useState } from "react";
|
|
6
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
7
|
+
//#region src/react/components/AirMatrix.tsx
|
|
8
|
+
function AirMatrix({ stations: stationsProp, strings: stringsProp, formatTime: formatTimeProp }) {
|
|
9
|
+
const context = useStationFeedContext();
|
|
10
|
+
const stations = requireResolved("AirMatrix", "stations", stationsProp ?? context?.feed?.stations);
|
|
11
|
+
const { formatTime, words } = resolveDisplay(context, {
|
|
12
|
+
formatTime: formatTimeProp,
|
|
13
|
+
strings: stringsProp
|
|
14
|
+
});
|
|
15
|
+
const panelId = useId();
|
|
16
|
+
const [expanded, setExpanded] = useState(false);
|
|
17
|
+
const scene = airMatrixScene({
|
|
18
|
+
formatTime,
|
|
19
|
+
stations,
|
|
20
|
+
words
|
|
21
|
+
});
|
|
22
|
+
if (scene == null) return null;
|
|
23
|
+
const rowTemplate = { gridTemplateColumns: scene.matrix.gridTemplateColumns };
|
|
24
|
+
return /* @__PURE__ */ jsxs("section", {
|
|
25
|
+
className: scene.className,
|
|
26
|
+
"data-expanded": expanded,
|
|
27
|
+
children: [/* @__PURE__ */ jsxs("button", {
|
|
28
|
+
"aria-controls": panelId,
|
|
29
|
+
"aria-expanded": expanded,
|
|
30
|
+
className: scene.trigger.className,
|
|
31
|
+
onClick: () => setExpanded((current) => !current),
|
|
32
|
+
type: "button",
|
|
33
|
+
children: [/* @__PURE__ */ jsx("strong", {
|
|
34
|
+
className: scene.trigger.title.className,
|
|
35
|
+
children: scene.trigger.title.text
|
|
36
|
+
}), /* @__PURE__ */ jsx("span", {
|
|
37
|
+
className: scene.trigger.summary.className,
|
|
38
|
+
children: scene.trigger.summary.text
|
|
39
|
+
})]
|
|
40
|
+
}), /* @__PURE__ */ jsxs("div", {
|
|
41
|
+
className: scene.panelClassName,
|
|
42
|
+
hidden: !expanded,
|
|
43
|
+
id: panelId,
|
|
44
|
+
children: [/* @__PURE__ */ jsxs("div", {
|
|
45
|
+
"aria-label": scene.matrix.ariaLabel,
|
|
46
|
+
className: scene.matrix.className,
|
|
47
|
+
role: "table",
|
|
48
|
+
children: [/* @__PURE__ */ jsxs("div", {
|
|
49
|
+
className: scene.matrix.head.className,
|
|
50
|
+
role: "row",
|
|
51
|
+
style: rowTemplate,
|
|
52
|
+
children: [/* @__PURE__ */ jsx("span", {
|
|
53
|
+
className: scene.matrix.head.corner.className,
|
|
54
|
+
role: "columnheader"
|
|
55
|
+
}), scene.matrix.head.columns.map((column) => /* @__PURE__ */ jsx("span", {
|
|
56
|
+
className: scene.matrix.head.columnClassName,
|
|
57
|
+
role: "columnheader",
|
|
58
|
+
children: column.text
|
|
59
|
+
}, column.key))]
|
|
60
|
+
}), scene.matrix.rows.map((row) => /* @__PURE__ */ jsxs("div", {
|
|
61
|
+
className: row.className,
|
|
62
|
+
role: "row",
|
|
63
|
+
style: rowTemplate,
|
|
64
|
+
children: [/* @__PURE__ */ jsxs("span", {
|
|
65
|
+
className: row.labelClassName,
|
|
66
|
+
role: "rowheader",
|
|
67
|
+
children: [row.label, /* @__PURE__ */ jsx("small", { children: row.unit })]
|
|
68
|
+
}), row.cells.map((cell) => /* @__PURE__ */ jsx("span", {
|
|
69
|
+
className: cell.className,
|
|
70
|
+
role: "cell",
|
|
71
|
+
children: cell.text
|
|
72
|
+
}, cell.key))]
|
|
73
|
+
}, row.key))]
|
|
74
|
+
}), /* @__PURE__ */ jsx("p", {
|
|
75
|
+
className: scene.note.className,
|
|
76
|
+
children: scene.note.text
|
|
77
|
+
})]
|
|
78
|
+
})]
|
|
79
|
+
});
|
|
80
|
+
}
|
|
81
|
+
//#endregion
|
|
82
|
+
export { AirMatrix };
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { Station } from "../../contract.js";
|
|
2
|
+
import { SpeedThresholds, SpeedUnit } from "../../derive.js";
|
|
3
|
+
import { FormatTime, StationStringOverrides } from "../../strings.js";
|
|
4
|
+
import "../../index.js";
|
|
5
|
+
//#region src/react/components/CurrentConditions.d.ts
|
|
6
|
+
declare function CurrentConditions({ station: stationProp, stationId, servedAt: servedAtProp, receivedAtMs: receivedAtMsProp, thresholds: thresholdsProp, unit: unitProp, strings: stringsProp, formatTime: formatTimeProp }: {
|
|
7
|
+
station?: Station;
|
|
8
|
+
stationId?: string;
|
|
9
|
+
servedAt?: string | null;
|
|
10
|
+
receivedAtMs?: number | null;
|
|
11
|
+
thresholds?: SpeedThresholds | null;
|
|
12
|
+
unit?: SpeedUnit;
|
|
13
|
+
strings?: StationStringOverrides;
|
|
14
|
+
formatTime?: FormatTime;
|
|
15
|
+
}): import("react").JSX.Element;
|
|
16
|
+
//#endregion
|
|
17
|
+
export { CurrentConditions };
|
|
@@ -0,0 +1,98 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { stationFreshnessThresholds } from "../../derive.js";
|
|
3
|
+
import { resolveDisplay } from "../../display.js";
|
|
4
|
+
import { currentConditionsScene } from "../../scene/current.js";
|
|
5
|
+
import { requireResolved, resolveStation, useStationFeedContext } from "./StationFeedProvider.js";
|
|
6
|
+
import { WindArrow } from "./WindArrow.js";
|
|
7
|
+
import { useFreshness } from "../hooks/useFreshness.js";
|
|
8
|
+
import { Dial } from "./Dial.js";
|
|
9
|
+
import { FreshnessBadge } from "./FreshnessBadge.js";
|
|
10
|
+
import { Fragment, jsx, jsxs } from "react/jsx-runtime";
|
|
11
|
+
//#region src/react/components/CurrentConditions.tsx
|
|
12
|
+
function CurrentConditions({ station: stationProp, stationId, servedAt: servedAtProp, receivedAtMs: receivedAtMsProp, thresholds: thresholdsProp, unit: unitProp, strings: stringsProp, formatTime: formatTimeProp }) {
|
|
13
|
+
const context = useStationFeedContext();
|
|
14
|
+
const station = requireResolved("CurrentConditions", "station", stationProp ?? resolveStation(context, stationId));
|
|
15
|
+
const servedAt = servedAtProp ?? context?.feed?.servedAt ?? null;
|
|
16
|
+
const receivedAtMs = receivedAtMsProp !== void 0 ? receivedAtMsProp : context?.receivedAtMs ?? null;
|
|
17
|
+
const { formatTime, strings, thresholds, unit, words } = resolveDisplay(context, {
|
|
18
|
+
formatTime: formatTimeProp,
|
|
19
|
+
strings: stringsProp,
|
|
20
|
+
thresholds: thresholdsProp,
|
|
21
|
+
unit: unitProp
|
|
22
|
+
});
|
|
23
|
+
const status = useFreshness((station.status === "ok" ? station.reading : null)?.observedAt ?? null, servedAt, receivedAtMs, stationFreshnessThresholds(station));
|
|
24
|
+
const scene = currentConditionsScene({
|
|
25
|
+
formatTime,
|
|
26
|
+
station,
|
|
27
|
+
unit,
|
|
28
|
+
words
|
|
29
|
+
});
|
|
30
|
+
const { direction, temperature, footer } = scene;
|
|
31
|
+
return /* @__PURE__ */ jsxs("div", {
|
|
32
|
+
"aria-label": scene.root.ariaLabel,
|
|
33
|
+
className: scene.root.className,
|
|
34
|
+
"data-status": scene.root.status,
|
|
35
|
+
role: "group",
|
|
36
|
+
children: [
|
|
37
|
+
/* @__PURE__ */ jsxs("div", {
|
|
38
|
+
className: scene.instrumentClassName,
|
|
39
|
+
children: [
|
|
40
|
+
scene.flanks && /* @__PURE__ */ jsxs("div", {
|
|
41
|
+
className: scene.flanks.lull.className,
|
|
42
|
+
children: [/* @__PURE__ */ jsx("small", {
|
|
43
|
+
className: scene.flanks.lull.labelClassName,
|
|
44
|
+
children: scene.flanks.lull.label
|
|
45
|
+
}), /* @__PURE__ */ jsx("strong", { children: scene.flanks.lull.value })]
|
|
46
|
+
}),
|
|
47
|
+
/* @__PURE__ */ jsx(Dial, {
|
|
48
|
+
calmWord: false,
|
|
49
|
+
station,
|
|
50
|
+
strings,
|
|
51
|
+
thresholds: thresholds ?? null,
|
|
52
|
+
unit
|
|
53
|
+
}),
|
|
54
|
+
scene.flanks && /* @__PURE__ */ jsxs("div", {
|
|
55
|
+
className: scene.flanks.gust.className,
|
|
56
|
+
children: [/* @__PURE__ */ jsx("small", {
|
|
57
|
+
className: scene.flanks.gust.labelClassName,
|
|
58
|
+
children: scene.flanks.gust.label
|
|
59
|
+
}), /* @__PURE__ */ jsx("strong", { children: scene.flanks.gust.value })]
|
|
60
|
+
})
|
|
61
|
+
]
|
|
62
|
+
}),
|
|
63
|
+
/* @__PURE__ */ jsx("p", {
|
|
64
|
+
className: direction.className,
|
|
65
|
+
children: direction.content.kind === "text" ? direction.content.text : /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
66
|
+
/* @__PURE__ */ jsx("span", {
|
|
67
|
+
className: direction.content.labelClassName,
|
|
68
|
+
children: direction.content.label
|
|
69
|
+
}),
|
|
70
|
+
" ",
|
|
71
|
+
/* @__PURE__ */ jsx(WindArrow, { deg: direction.content.deg }),
|
|
72
|
+
" ",
|
|
73
|
+
/* @__PURE__ */ jsx("strong", { children: direction.content.compass }),
|
|
74
|
+
direction.content.tail
|
|
75
|
+
] })
|
|
76
|
+
}),
|
|
77
|
+
temperature && /* @__PURE__ */ jsxs("p", {
|
|
78
|
+
className: temperature.className,
|
|
79
|
+
children: [temperature.text, temperature.chill && /* @__PURE__ */ jsx("span", {
|
|
80
|
+
className: temperature.chill.className,
|
|
81
|
+
children: temperature.chill.text
|
|
82
|
+
})]
|
|
83
|
+
}),
|
|
84
|
+
/* @__PURE__ */ jsxs("p", {
|
|
85
|
+
className: footer.className,
|
|
86
|
+
children: [status != null && /* @__PURE__ */ jsx(FreshnessBadge, {
|
|
87
|
+
status,
|
|
88
|
+
strings
|
|
89
|
+
}), /* @__PURE__ */ jsx("span", {
|
|
90
|
+
className: footer.observed.className,
|
|
91
|
+
children: footer.observed.text
|
|
92
|
+
})]
|
|
93
|
+
})
|
|
94
|
+
]
|
|
95
|
+
});
|
|
96
|
+
}
|
|
97
|
+
//#endregion
|
|
98
|
+
export { CurrentConditions };
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { HistoryPoint, Station } from "../../contract.js";
|
|
2
|
+
import { SpeedThresholds, SpeedUnit, compassDirection } from "../../derive.js";
|
|
3
|
+
import { StationStringOverrides } from "../../strings.js";
|
|
4
|
+
import "../../index.js";
|
|
5
|
+
import { WindArrow } from "./WindArrow.js";
|
|
6
|
+
//#region src/react/components/DailyPattern.d.ts
|
|
7
|
+
declare function DailyPattern({ station: stationProp, stationId, points, slotMinutes, utcOffsetMinutes, thresholds: thresholdsProp, unit: unitProp, plotHeight, strings: stringsProp }: {
|
|
8
|
+
station?: Station;
|
|
9
|
+
stationId?: string;
|
|
10
|
+
points?: HistoryPoint[];
|
|
11
|
+
slotMinutes?: number;
|
|
12
|
+
utcOffsetMinutes?: number;
|
|
13
|
+
thresholds?: SpeedThresholds | null;
|
|
14
|
+
unit?: SpeedUnit;
|
|
15
|
+
plotHeight?: number;
|
|
16
|
+
strings?: StationStringOverrides;
|
|
17
|
+
}): import("react").JSX.Element;
|
|
18
|
+
//#endregion
|
|
19
|
+
export { DailyPattern };
|
|
@@ -0,0 +1,212 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import "../../derive.js";
|
|
3
|
+
import { resolveDisplay } from "../../display.js";
|
|
4
|
+
import "../../geometry.js";
|
|
5
|
+
import { measuredChartWidth } from "../../scene/chart.js";
|
|
6
|
+
import { DAILY_PATTERN_CLASS, dailyPatternGate, dailyPatternScene, dailyPatternSource } from "../../scene/daily-pattern.js";
|
|
7
|
+
import { resolveStation, useStationFeedContext } from "./StationFeedProvider.js";
|
|
8
|
+
import "./WindArrow.js";
|
|
9
|
+
import { useEffect, useId, useRef, useState } from "react";
|
|
10
|
+
import { Fragment, jsx, jsxs } from "react/jsx-runtime";
|
|
11
|
+
//#region src/react/components/DailyPattern.tsx
|
|
12
|
+
function DailyPattern({ station: stationProp, stationId, points, slotMinutes = 180, utcOffsetMinutes = 0, thresholds: thresholdsProp, unit: unitProp, plotHeight, strings: stringsProp }) {
|
|
13
|
+
const context = useStationFeedContext();
|
|
14
|
+
const station = stationProp ?? (points == null ? resolveStation(context, stationId) ?? void 0 : void 0);
|
|
15
|
+
const { thresholds, unit, words } = resolveDisplay(context, {
|
|
16
|
+
strings: stringsProp,
|
|
17
|
+
thresholds: thresholdsProp,
|
|
18
|
+
unit: unitProp
|
|
19
|
+
});
|
|
20
|
+
const wrapRef = useRef(null);
|
|
21
|
+
const [width, setWidth] = useState(null);
|
|
22
|
+
const { source, periodMinutes } = dailyPatternSource(points, station);
|
|
23
|
+
const gate = dailyPatternGate(source, words);
|
|
24
|
+
useEffect(() => {
|
|
25
|
+
const element = wrapRef.current;
|
|
26
|
+
if (!element) return;
|
|
27
|
+
if (typeof ResizeObserver === "undefined") {
|
|
28
|
+
setWidth(360);
|
|
29
|
+
return;
|
|
30
|
+
}
|
|
31
|
+
const observer = new ResizeObserver((entries) => {
|
|
32
|
+
setWidth(measuredChartWidth(entries[0]?.contentRect.width ?? 0));
|
|
33
|
+
});
|
|
34
|
+
observer.observe(element);
|
|
35
|
+
return () => observer.disconnect();
|
|
36
|
+
}, [gate.kind === "draw"]);
|
|
37
|
+
if (gate.kind === "note") return /* @__PURE__ */ jsx("div", {
|
|
38
|
+
className: gate.className,
|
|
39
|
+
role: "note",
|
|
40
|
+
children: gate.text
|
|
41
|
+
});
|
|
42
|
+
return /* @__PURE__ */ jsx("div", {
|
|
43
|
+
className: DAILY_PATTERN_CLASS,
|
|
44
|
+
ref: wrapRef,
|
|
45
|
+
children: width != null && /* @__PURE__ */ jsx(MeasuredDailyPattern, {
|
|
46
|
+
periodMinutes,
|
|
47
|
+
plotHeight,
|
|
48
|
+
points: source,
|
|
49
|
+
slotMinutes,
|
|
50
|
+
stationName: station?.name,
|
|
51
|
+
thresholds,
|
|
52
|
+
unit,
|
|
53
|
+
utcOffsetMinutes,
|
|
54
|
+
width,
|
|
55
|
+
words
|
|
56
|
+
})
|
|
57
|
+
});
|
|
58
|
+
}
|
|
59
|
+
function MeasuredDailyPattern({ periodMinutes, plotHeight, points, slotMinutes, stationName, thresholds, unit, utcOffsetMinutes, width, words }) {
|
|
60
|
+
const scene = dailyPatternScene({
|
|
61
|
+
hatchId: `meteo-daily-pattern-hatch-${useId().replace(/[^a-zA-Z0-9_-]/g, "")}`,
|
|
62
|
+
periodMinutes,
|
|
63
|
+
plotHeight,
|
|
64
|
+
points,
|
|
65
|
+
slotMinutes,
|
|
66
|
+
stationName,
|
|
67
|
+
thresholds,
|
|
68
|
+
unit,
|
|
69
|
+
utcOffsetMinutes,
|
|
70
|
+
width,
|
|
71
|
+
words
|
|
72
|
+
});
|
|
73
|
+
return /* @__PURE__ */ jsxs(Fragment, { children: [/* @__PURE__ */ jsx("output", {
|
|
74
|
+
className: scene.caption.className,
|
|
75
|
+
children: scene.caption.text
|
|
76
|
+
}), /* @__PURE__ */ jsxs("svg", {
|
|
77
|
+
"aria-label": scene.svg.ariaLabel,
|
|
78
|
+
className: scene.svg.className,
|
|
79
|
+
height: scene.svg.height,
|
|
80
|
+
role: "img",
|
|
81
|
+
viewBox: scene.svg.viewBox,
|
|
82
|
+
width: scene.svg.width,
|
|
83
|
+
children: [
|
|
84
|
+
/* @__PURE__ */ jsx("defs", { children: /* @__PURE__ */ jsx("pattern", {
|
|
85
|
+
height: scene.defs.pattern.height,
|
|
86
|
+
id: scene.defs.pattern.id,
|
|
87
|
+
patternTransform: scene.defs.pattern.transform,
|
|
88
|
+
patternUnits: scene.defs.pattern.units,
|
|
89
|
+
width: scene.defs.pattern.width,
|
|
90
|
+
children: /* @__PURE__ */ jsx("line", {
|
|
91
|
+
className: scene.defs.pattern.line.className,
|
|
92
|
+
x1: scene.defs.pattern.line.x1,
|
|
93
|
+
x2: scene.defs.pattern.line.x2,
|
|
94
|
+
y1: scene.defs.pattern.line.y1,
|
|
95
|
+
y2: scene.defs.pattern.line.y2
|
|
96
|
+
})
|
|
97
|
+
}) }),
|
|
98
|
+
scene.zones.map((zone) => /* @__PURE__ */ jsx("rect", {
|
|
99
|
+
className: zone.className,
|
|
100
|
+
height: zone.height,
|
|
101
|
+
width: zone.width,
|
|
102
|
+
x: zone.x,
|
|
103
|
+
y: zone.y
|
|
104
|
+
}, zone.key)),
|
|
105
|
+
scene.grid.map(({ key, line, label }) => /* @__PURE__ */ jsxs("g", { children: [/* @__PURE__ */ jsx("line", {
|
|
106
|
+
className: line.className,
|
|
107
|
+
x1: line.x1,
|
|
108
|
+
x2: line.x2,
|
|
109
|
+
y1: line.y1,
|
|
110
|
+
y2: line.y2
|
|
111
|
+
}), /* @__PURE__ */ jsx("text", {
|
|
112
|
+
className: label.className,
|
|
113
|
+
textAnchor: label.anchor,
|
|
114
|
+
x: label.x,
|
|
115
|
+
y: label.y,
|
|
116
|
+
children: label.text
|
|
117
|
+
})] }, key)),
|
|
118
|
+
scene.thresholdGuides.map(({ key, line, label }) => /* @__PURE__ */ jsxs("g", { children: [/* @__PURE__ */ jsx("line", {
|
|
119
|
+
className: line.className,
|
|
120
|
+
x1: line.x1,
|
|
121
|
+
x2: line.x2,
|
|
122
|
+
y1: line.y1,
|
|
123
|
+
y2: line.y2
|
|
124
|
+
}), /* @__PURE__ */ jsx("text", {
|
|
125
|
+
className: label.className,
|
|
126
|
+
textAnchor: label.anchor,
|
|
127
|
+
x: label.x,
|
|
128
|
+
y: label.y,
|
|
129
|
+
children: label.text
|
|
130
|
+
})] }, key)),
|
|
131
|
+
scene.vaneGuides.map((guide) => /* @__PURE__ */ jsx("line", {
|
|
132
|
+
className: guide.className,
|
|
133
|
+
x1: guide.x1,
|
|
134
|
+
x2: guide.x2,
|
|
135
|
+
y1: guide.y1,
|
|
136
|
+
y2: guide.y2
|
|
137
|
+
}, `guide-${guide.key}`)),
|
|
138
|
+
scene.gaps.map((gap) => /* @__PURE__ */ jsx("rect", {
|
|
139
|
+
className: gap.className,
|
|
140
|
+
fill: gap.fill,
|
|
141
|
+
height: gap.height,
|
|
142
|
+
width: gap.width,
|
|
143
|
+
x: gap.x,
|
|
144
|
+
y: gap.y
|
|
145
|
+
}, gap.key)),
|
|
146
|
+
scene.mean.kind === "polyline" ? /* @__PURE__ */ jsx("polyline", {
|
|
147
|
+
className: scene.mean.className,
|
|
148
|
+
points: scene.mean.points
|
|
149
|
+
}) : scene.mean.segments.map((segment) => /* @__PURE__ */ jsx("line", {
|
|
150
|
+
className: segment.className,
|
|
151
|
+
x1: segment.x1,
|
|
152
|
+
x2: segment.x2,
|
|
153
|
+
y1: segment.y1,
|
|
154
|
+
y2: segment.y2
|
|
155
|
+
}, segment.key)),
|
|
156
|
+
scene.calmNote && /* @__PURE__ */ jsx("text", {
|
|
157
|
+
className: scene.calmNote.className,
|
|
158
|
+
textAnchor: scene.calmNote.anchor,
|
|
159
|
+
x: scene.calmNote.x,
|
|
160
|
+
y: scene.calmNote.y,
|
|
161
|
+
children: scene.calmNote.text
|
|
162
|
+
}),
|
|
163
|
+
/* @__PURE__ */ jsx("text", {
|
|
164
|
+
className: scene.rowLabels.to.className,
|
|
165
|
+
textAnchor: scene.rowLabels.to.anchor,
|
|
166
|
+
x: scene.rowLabels.to.x,
|
|
167
|
+
y: scene.rowLabels.to.y,
|
|
168
|
+
children: scene.rowLabels.to.text
|
|
169
|
+
}),
|
|
170
|
+
scene.vanes.map((vane) => vane.mark.kind === "calm" ? /* @__PURE__ */ jsx("text", {
|
|
171
|
+
className: vane.mark.text.className,
|
|
172
|
+
textAnchor: vane.mark.text.anchor,
|
|
173
|
+
x: vane.mark.text.x,
|
|
174
|
+
y: vane.mark.text.y,
|
|
175
|
+
children: vane.mark.text.text
|
|
176
|
+
}, vane.key) : /* @__PURE__ */ jsx("path", {
|
|
177
|
+
className: vane.mark.className,
|
|
178
|
+
d: vane.mark.d
|
|
179
|
+
}, vane.key)),
|
|
180
|
+
scene.vanes.map((vane) => /* @__PURE__ */ jsx("text", {
|
|
181
|
+
className: vane.label.className,
|
|
182
|
+
textAnchor: vane.label.anchor,
|
|
183
|
+
x: vane.label.x,
|
|
184
|
+
y: vane.label.y,
|
|
185
|
+
children: vane.label.text
|
|
186
|
+
}, `label-${vane.key}`)),
|
|
187
|
+
/* @__PURE__ */ jsx("text", {
|
|
188
|
+
className: scene.rowLabels.avg.className,
|
|
189
|
+
textAnchor: scene.rowLabels.avg.anchor,
|
|
190
|
+
x: scene.rowLabels.avg.x,
|
|
191
|
+
y: scene.rowLabels.avg.y,
|
|
192
|
+
children: scene.rowLabels.avg.text
|
|
193
|
+
}),
|
|
194
|
+
scene.vanes.map((vane) => /* @__PURE__ */ jsx("text", {
|
|
195
|
+
className: vane.value.className,
|
|
196
|
+
textAnchor: vane.value.anchor,
|
|
197
|
+
x: vane.value.x,
|
|
198
|
+
y: vane.value.y,
|
|
199
|
+
children: vane.value.text
|
|
200
|
+
}, `value-${vane.key}`)),
|
|
201
|
+
scene.ticks.map((tick) => /* @__PURE__ */ jsx("text", {
|
|
202
|
+
className: tick.className,
|
|
203
|
+
textAnchor: tick.anchor,
|
|
204
|
+
x: tick.x,
|
|
205
|
+
y: tick.y,
|
|
206
|
+
children: tick.text
|
|
207
|
+
}, tick.key))
|
|
208
|
+
]
|
|
209
|
+
})] });
|
|
210
|
+
}
|
|
211
|
+
//#endregion
|
|
212
|
+
export { DailyPattern };
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { Station } from "../../contract.js";
|
|
2
|
+
import { SpeedThresholds, SpeedUnit } from "../../derive.js";
|
|
3
|
+
import { FormatTime, StationStringOverrides } from "../../strings.js";
|
|
4
|
+
import "../../index.js";
|
|
5
|
+
//#region src/react/components/Dial.d.ts
|
|
6
|
+
declare function Dial({ station: stationProp, stationId, thresholds: thresholdsProp, unit: unitProp, size, calmWord, strings: stringsProp }: {
|
|
7
|
+
station?: Station;
|
|
8
|
+
stationId?: string;
|
|
9
|
+
thresholds?: SpeedThresholds | null;
|
|
10
|
+
unit?: SpeedUnit;
|
|
11
|
+
size?: number;
|
|
12
|
+
calmWord?: boolean;
|
|
13
|
+
strings?: StationStringOverrides;
|
|
14
|
+
formatTime?: FormatTime;
|
|
15
|
+
}): import("react").JSX.Element;
|
|
16
|
+
//#endregion
|
|
17
|
+
export { Dial };
|
|
@@ -0,0 +1,133 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { resolveDisplay } from "../../display.js";
|
|
3
|
+
import "../../instruments.js";
|
|
4
|
+
import { dialScene } from "../../scene/dial.js";
|
|
5
|
+
import { requireResolved, resolveStation, useStationFeedContext } from "./StationFeedProvider.js";
|
|
6
|
+
import { useId } from "react";
|
|
7
|
+
import { Fragment, jsx, jsxs } from "react/jsx-runtime";
|
|
8
|
+
//#region src/react/components/Dial.tsx
|
|
9
|
+
function Dial({ station: stationProp, stationId, thresholds: thresholdsProp, unit: unitProp, size = 160, calmWord = true, strings: stringsProp }) {
|
|
10
|
+
const context = useStationFeedContext();
|
|
11
|
+
const station = requireResolved("Dial", "station", stationProp ?? resolveStation(context, stationId));
|
|
12
|
+
const { thresholds, unit, words } = resolveDisplay(context, {
|
|
13
|
+
strings: stringsProp,
|
|
14
|
+
thresholds: thresholdsProp,
|
|
15
|
+
unit: unitProp
|
|
16
|
+
});
|
|
17
|
+
const scene = dialScene({
|
|
18
|
+
bezelId: `meteo-bezel-${useId().replace(/[^a-zA-Z0-9_-]/g, "")}`,
|
|
19
|
+
calmWord,
|
|
20
|
+
size,
|
|
21
|
+
station,
|
|
22
|
+
thresholds,
|
|
23
|
+
unit,
|
|
24
|
+
words
|
|
25
|
+
});
|
|
26
|
+
const { gradient, centre } = scene;
|
|
27
|
+
return /* @__PURE__ */ jsxs("svg", {
|
|
28
|
+
"aria-label": scene.svg.ariaLabel,
|
|
29
|
+
className: scene.svg.className,
|
|
30
|
+
height: scene.svg.height,
|
|
31
|
+
role: "img",
|
|
32
|
+
viewBox: scene.svg.viewBox,
|
|
33
|
+
width: scene.svg.width,
|
|
34
|
+
children: [
|
|
35
|
+
/* @__PURE__ */ jsx("defs", { children: /* @__PURE__ */ jsx("radialGradient", {
|
|
36
|
+
cx: gradient.cx,
|
|
37
|
+
cy: gradient.cy,
|
|
38
|
+
id: gradient.id,
|
|
39
|
+
r: gradient.r,
|
|
40
|
+
children: gradient.stops.map((stop) => /* @__PURE__ */ jsx("stop", {
|
|
41
|
+
className: stop.className,
|
|
42
|
+
offset: stop.offset
|
|
43
|
+
}, stop.offset))
|
|
44
|
+
}) }),
|
|
45
|
+
/* @__PURE__ */ jsx("circle", {
|
|
46
|
+
className: scene.face.className,
|
|
47
|
+
cx: scene.face.cx,
|
|
48
|
+
cy: scene.face.cy,
|
|
49
|
+
r: scene.face.r
|
|
50
|
+
}),
|
|
51
|
+
/* @__PURE__ */ jsx("circle", {
|
|
52
|
+
className: scene.bezel.className,
|
|
53
|
+
cx: scene.bezel.cx,
|
|
54
|
+
cy: scene.bezel.cy,
|
|
55
|
+
fill: scene.bezel.fill,
|
|
56
|
+
r: scene.bezel.r
|
|
57
|
+
}),
|
|
58
|
+
/* @__PURE__ */ jsx("circle", {
|
|
59
|
+
className: scene.ring.className,
|
|
60
|
+
cx: scene.ring.cx,
|
|
61
|
+
cy: scene.ring.cy,
|
|
62
|
+
r: scene.ring.r
|
|
63
|
+
}),
|
|
64
|
+
scene.arc && /* @__PURE__ */ jsx("path", {
|
|
65
|
+
className: scene.arc.className,
|
|
66
|
+
d: scene.arc.d
|
|
67
|
+
}),
|
|
68
|
+
scene.ticks.map((tick) => /* @__PURE__ */ jsx("line", {
|
|
69
|
+
className: tick.className,
|
|
70
|
+
x1: tick.x1,
|
|
71
|
+
x2: tick.x2,
|
|
72
|
+
y1: tick.y1,
|
|
73
|
+
y2: tick.y2
|
|
74
|
+
}, tick.key)),
|
|
75
|
+
scene.letters.map((letter) => /* @__PURE__ */ jsx("text", {
|
|
76
|
+
className: letter.className,
|
|
77
|
+
textAnchor: letter.anchor,
|
|
78
|
+
x: letter.x,
|
|
79
|
+
y: letter.y,
|
|
80
|
+
children: letter.text
|
|
81
|
+
}, letter.key)),
|
|
82
|
+
scene.needle && /* @__PURE__ */ jsxs("g", {
|
|
83
|
+
className: scene.needle.className,
|
|
84
|
+
children: [/* @__PURE__ */ jsx("polygon", {
|
|
85
|
+
className: scene.needle.blade.className,
|
|
86
|
+
points: scene.needle.blade.points
|
|
87
|
+
}), /* @__PURE__ */ jsx("circle", {
|
|
88
|
+
className: scene.needle.counterweight.className,
|
|
89
|
+
cx: scene.needle.counterweight.cx,
|
|
90
|
+
cy: scene.needle.counterweight.cy,
|
|
91
|
+
r: scene.needle.counterweight.r
|
|
92
|
+
})]
|
|
93
|
+
}),
|
|
94
|
+
/* @__PURE__ */ jsx("circle", {
|
|
95
|
+
className: scene.hub.className,
|
|
96
|
+
cx: scene.hub.cx,
|
|
97
|
+
cy: scene.hub.cy,
|
|
98
|
+
r: scene.hub.r
|
|
99
|
+
}),
|
|
100
|
+
centre.kind === "reason" ? /* @__PURE__ */ jsx("text", {
|
|
101
|
+
className: centre.text.className,
|
|
102
|
+
textAnchor: centre.text.anchor,
|
|
103
|
+
x: centre.text.x,
|
|
104
|
+
y: centre.text.y,
|
|
105
|
+
children: centre.text.text
|
|
106
|
+
}) : /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
107
|
+
centre.calmWord && /* @__PURE__ */ jsx("text", {
|
|
108
|
+
className: centre.calmWord.className,
|
|
109
|
+
textAnchor: centre.calmWord.anchor,
|
|
110
|
+
x: centre.calmWord.x,
|
|
111
|
+
y: centre.calmWord.y,
|
|
112
|
+
children: centre.calmWord.text
|
|
113
|
+
}),
|
|
114
|
+
/* @__PURE__ */ jsx("text", {
|
|
115
|
+
className: centre.speed.className,
|
|
116
|
+
textAnchor: centre.speed.anchor,
|
|
117
|
+
x: centre.speed.x,
|
|
118
|
+
y: centre.speed.y,
|
|
119
|
+
children: centre.speed.text
|
|
120
|
+
}),
|
|
121
|
+
/* @__PURE__ */ jsx("text", {
|
|
122
|
+
className: centre.unit.className,
|
|
123
|
+
textAnchor: centre.unit.anchor,
|
|
124
|
+
x: centre.unit.x,
|
|
125
|
+
y: centre.unit.y,
|
|
126
|
+
children: centre.unit.text
|
|
127
|
+
})
|
|
128
|
+
] })
|
|
129
|
+
]
|
|
130
|
+
});
|
|
131
|
+
}
|
|
132
|
+
//#endregion
|
|
133
|
+
export { Dial };
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { FreshnessStatus } from "../../derive.js";
|
|
2
|
+
import { StationStringOverrides } from "../../strings.js";
|
|
3
|
+
import "../../index.js";
|
|
4
|
+
//#region src/react/components/FreshnessBadge.d.ts
|
|
5
|
+
declare function FreshnessBadge({ status, strings }: {
|
|
6
|
+
status: FreshnessStatus;
|
|
7
|
+
strings?: StationStringOverrides;
|
|
8
|
+
}): import("react").JSX.Element;
|
|
9
|
+
//#endregion
|
|
10
|
+
export { FreshnessBadge };
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { resolveDisplay } from "../../display.js";
|
|
3
|
+
import { freshnessBadgeSpec } from "../../scene/glyphs.js";
|
|
4
|
+
import { useStationFeedContext } from "./StationFeedProvider.js";
|
|
5
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
6
|
+
//#region src/react/components/FreshnessBadge.tsx
|
|
7
|
+
function FreshnessBadge({ status, strings }) {
|
|
8
|
+
const { words } = resolveDisplay(useStationFeedContext(), { strings });
|
|
9
|
+
const spec = freshnessBadgeSpec(status, words);
|
|
10
|
+
return /* @__PURE__ */ jsxs("span", {
|
|
11
|
+
className: spec.className,
|
|
12
|
+
"data-freshness": spec.status,
|
|
13
|
+
children: [/* @__PURE__ */ jsx("span", {
|
|
14
|
+
"aria-hidden": "true",
|
|
15
|
+
className: spec.dot.className
|
|
16
|
+
}), spec.text]
|
|
17
|
+
});
|
|
18
|
+
}
|
|
19
|
+
//#endregion
|
|
20
|
+
export { FreshnessBadge };
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { Station } from "../../contract.js";
|
|
2
|
+
import { SpeedThresholds, SpeedUnit } from "../../derive.js";
|
|
3
|
+
import { StationStringOverrides } from "../../strings.js";
|
|
4
|
+
import "../../index.js";
|
|
5
|
+
//#region src/react/components/Sparkline.d.ts
|
|
6
|
+
declare function Sparkline({ station: stationProp, stationId, width, height, showBand, thresholds: thresholdsProp, strings: stringsProp }: {
|
|
7
|
+
station?: Station;
|
|
8
|
+
stationId?: string;
|
|
9
|
+
width?: number;
|
|
10
|
+
height?: number;
|
|
11
|
+
showBand?: boolean;
|
|
12
|
+
thresholds?: SpeedThresholds | null;
|
|
13
|
+
unit?: SpeedUnit;
|
|
14
|
+
strings?: StationStringOverrides;
|
|
15
|
+
}): import("react").JSX.Element;
|
|
16
|
+
//#endregion
|
|
17
|
+
export { Sparkline };
|