@azohra/meteo.station 0.1.1 → 0.1.2
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/dist/client/index.d.ts +2 -1
- package/dist/client/index.js +2 -1
- package/dist/client/live.d.ts +37 -0
- package/dist/client/live.js +241 -0
- package/dist/client/stores.d.ts +1 -0
- package/dist/client/stores.js +41 -6
- package/dist/contract.d.ts +237 -1
- package/dist/contract.js +57 -3
- package/dist/endpoints.d.ts +2 -1
- package/dist/endpoints.js +4 -1
- package/dist/index.d.ts +3 -3
- package/dist/index.js +3 -3
- package/dist/react/hooks/useStation.d.ts +1 -0
- package/dist/react/hooks/useStation.js +25 -5
- package/dist/react/hooks/useStationLive.d.ts +20 -0
- package/dist/react/hooks/useStationLive.js +33 -0
- package/dist/react/index.d.ts +2 -1
- package/dist/react/index.js +2 -1
- package/dist/server/adapter.d.ts +3 -1
- package/dist/server/adapter.js +3 -1
- package/dist/server/adapters/windnerd-live.d.ts +21 -0
- package/dist/server/adapters/windnerd-live.js +179 -0
- package/dist/server/adapters/windnerd.d.ts +36 -5
- package/dist/server/adapters/windnerd.js +177 -15
- package/dist/server/config.d.ts +2 -0
- package/dist/server/config.js +2 -1
- package/dist/server/environment.d.ts +25 -5
- package/dist/server/environment.js +65 -21
- package/dist/server/feed.d.ts +20 -2
- package/dist/server/feed.js +28 -1
- package/dist/server/handler.d.ts +1 -1
- package/dist/server/handler.js +37 -3
- package/dist/server/index.d.ts +6 -4
- package/dist/server/index.js +6 -4
- package/dist/server/live.d.ts +15 -0
- package/dist/server/live.js +19 -0
- package/dist/sse.js +56 -0
- package/package.json +1 -1
- package/schema/README.md +1 -1
- package/schema/example-feed.json +26 -1
- package/schema/example-live.json +74 -0
- package/schema/stationcurrent.schema.json +115 -0
- package/schema/stationfeed.schema.json +115 -0
- package/schema/stationlive.schema.json +868 -0
package/dist/contract.d.ts
CHANGED
|
@@ -23,6 +23,10 @@ declare const airConditionsSchema: z.ZodObject<{
|
|
|
23
23
|
uvIndex: z.ZodNullable<z.ZodNumber>;
|
|
24
24
|
}, z.core.$strip>;
|
|
25
25
|
type AirConditions = z.infer<typeof airConditionsSchema>;
|
|
26
|
+
declare const telemetrySchema: z.ZodObject<{
|
|
27
|
+
batteryVoltage: z.ZodNullable<z.ZodNumber>;
|
|
28
|
+
}, z.core.$strip>;
|
|
29
|
+
type StationTelemetry = z.infer<typeof telemetrySchema>;
|
|
26
30
|
declare const readingSchema: z.ZodObject<{
|
|
27
31
|
observedAt: z.ZodString;
|
|
28
32
|
windAvgMps: z.ZodNumber;
|
|
@@ -75,11 +79,28 @@ declare const historySchema: z.ZodObject<{
|
|
|
75
79
|
}, z.core.$strip>>;
|
|
76
80
|
}, z.core.$strip>;
|
|
77
81
|
type History = z.infer<typeof historySchema>;
|
|
82
|
+
declare const liveSampleSchema: z.ZodObject<{
|
|
83
|
+
observedAt: z.ZodString;
|
|
84
|
+
windMps: z.ZodNumber;
|
|
85
|
+
windDirectionDeg: z.ZodNullable<z.ZodNumber>;
|
|
86
|
+
}, z.core.$strip>;
|
|
87
|
+
type LiveSample = z.infer<typeof liveSampleSchema>;
|
|
88
|
+
declare const liveSamplesSchema: z.ZodObject<{
|
|
89
|
+
intervalSeconds: z.ZodNumber;
|
|
90
|
+
points: z.ZodArray<z.ZodObject<{
|
|
91
|
+
observedAt: z.ZodString;
|
|
92
|
+
windMps: z.ZodNumber;
|
|
93
|
+
windDirectionDeg: z.ZodNullable<z.ZodNumber>;
|
|
94
|
+
}, z.core.$strip>>;
|
|
95
|
+
}, z.core.$strip>;
|
|
96
|
+
type LiveSamples = z.infer<typeof liveSamplesSchema>;
|
|
78
97
|
declare const capabilitiesSchema: z.ZodObject<{
|
|
79
98
|
gustLull: z.ZodBoolean;
|
|
80
99
|
temperature: z.ZodBoolean;
|
|
81
100
|
conditions: z.ZodBoolean;
|
|
82
101
|
history: z.ZodBoolean;
|
|
102
|
+
live: z.ZodOptional<z.ZodNullable<z.ZodBoolean>>;
|
|
103
|
+
battery: z.ZodOptional<z.ZodNullable<z.ZodBoolean>>;
|
|
83
104
|
}, z.core.$strip>;
|
|
84
105
|
type StationCapabilities = z.infer<typeof capabilitiesSchema>;
|
|
85
106
|
declare const stationMetaSchema: z.ZodObject<{
|
|
@@ -96,6 +117,8 @@ declare const stationMetaSchema: z.ZodObject<{
|
|
|
96
117
|
temperature: z.ZodBoolean;
|
|
97
118
|
conditions: z.ZodBoolean;
|
|
98
119
|
history: z.ZodBoolean;
|
|
120
|
+
live: z.ZodOptional<z.ZodNullable<z.ZodBoolean>>;
|
|
121
|
+
battery: z.ZodOptional<z.ZodNullable<z.ZodBoolean>>;
|
|
99
122
|
}, z.core.$strip>;
|
|
100
123
|
samplingWindowSeconds: z.ZodNullable<z.ZodNumber>;
|
|
101
124
|
recommendedPollSeconds: z.ZodNumber;
|
|
@@ -143,6 +166,17 @@ declare const stationSchema: z.ZodDiscriminatedUnion<[z.ZodObject<{
|
|
|
143
166
|
seaLevelPressureHpa: z.ZodOptional<z.ZodNullable<z.ZodNumber>>;
|
|
144
167
|
}, z.core.$strip>>;
|
|
145
168
|
}, z.core.$strip>>;
|
|
169
|
+
telemetry: z.ZodOptional<z.ZodNullable<z.ZodObject<{
|
|
170
|
+
batteryVoltage: z.ZodNullable<z.ZodNumber>;
|
|
171
|
+
}, z.core.$strip>>>;
|
|
172
|
+
samples: z.ZodOptional<z.ZodNullable<z.ZodObject<{
|
|
173
|
+
intervalSeconds: z.ZodNumber;
|
|
174
|
+
points: z.ZodArray<z.ZodObject<{
|
|
175
|
+
observedAt: z.ZodString;
|
|
176
|
+
windMps: z.ZodNumber;
|
|
177
|
+
windDirectionDeg: z.ZodNullable<z.ZodNumber>;
|
|
178
|
+
}, z.core.$strip>>;
|
|
179
|
+
}, z.core.$strip>>>;
|
|
146
180
|
id: z.ZodString;
|
|
147
181
|
name: z.ZodString;
|
|
148
182
|
sourceLabel: z.ZodString;
|
|
@@ -156,6 +190,8 @@ declare const stationSchema: z.ZodDiscriminatedUnion<[z.ZodObject<{
|
|
|
156
190
|
temperature: z.ZodBoolean;
|
|
157
191
|
conditions: z.ZodBoolean;
|
|
158
192
|
history: z.ZodBoolean;
|
|
193
|
+
live: z.ZodOptional<z.ZodNullable<z.ZodBoolean>>;
|
|
194
|
+
battery: z.ZodOptional<z.ZodNullable<z.ZodBoolean>>;
|
|
159
195
|
}, z.core.$strip>;
|
|
160
196
|
samplingWindowSeconds: z.ZodNullable<z.ZodNumber>;
|
|
161
197
|
recommendedPollSeconds: z.ZodNumber;
|
|
@@ -183,6 +219,8 @@ declare const stationSchema: z.ZodDiscriminatedUnion<[z.ZodObject<{
|
|
|
183
219
|
temperature: z.ZodBoolean;
|
|
184
220
|
conditions: z.ZodBoolean;
|
|
185
221
|
history: z.ZodBoolean;
|
|
222
|
+
live: z.ZodOptional<z.ZodNullable<z.ZodBoolean>>;
|
|
223
|
+
battery: z.ZodOptional<z.ZodNullable<z.ZodBoolean>>;
|
|
186
224
|
}, z.core.$strip>;
|
|
187
225
|
samplingWindowSeconds: z.ZodNullable<z.ZodNumber>;
|
|
188
226
|
recommendedPollSeconds: z.ZodNumber;
|
|
@@ -234,6 +272,17 @@ declare const stationFeedSchema: z.ZodObject<{
|
|
|
234
272
|
seaLevelPressureHpa: z.ZodOptional<z.ZodNullable<z.ZodNumber>>;
|
|
235
273
|
}, z.core.$strip>>;
|
|
236
274
|
}, z.core.$strip>>;
|
|
275
|
+
telemetry: z.ZodOptional<z.ZodNullable<z.ZodObject<{
|
|
276
|
+
batteryVoltage: z.ZodNullable<z.ZodNumber>;
|
|
277
|
+
}, z.core.$strip>>>;
|
|
278
|
+
samples: z.ZodOptional<z.ZodNullable<z.ZodObject<{
|
|
279
|
+
intervalSeconds: z.ZodNumber;
|
|
280
|
+
points: z.ZodArray<z.ZodObject<{
|
|
281
|
+
observedAt: z.ZodString;
|
|
282
|
+
windMps: z.ZodNumber;
|
|
283
|
+
windDirectionDeg: z.ZodNullable<z.ZodNumber>;
|
|
284
|
+
}, z.core.$strip>>;
|
|
285
|
+
}, z.core.$strip>>>;
|
|
237
286
|
id: z.ZodString;
|
|
238
287
|
name: z.ZodString;
|
|
239
288
|
sourceLabel: z.ZodString;
|
|
@@ -247,6 +296,8 @@ declare const stationFeedSchema: z.ZodObject<{
|
|
|
247
296
|
temperature: z.ZodBoolean;
|
|
248
297
|
conditions: z.ZodBoolean;
|
|
249
298
|
history: z.ZodBoolean;
|
|
299
|
+
live: z.ZodOptional<z.ZodNullable<z.ZodBoolean>>;
|
|
300
|
+
battery: z.ZodOptional<z.ZodNullable<z.ZodBoolean>>;
|
|
250
301
|
}, z.core.$strip>;
|
|
251
302
|
samplingWindowSeconds: z.ZodNullable<z.ZodNumber>;
|
|
252
303
|
recommendedPollSeconds: z.ZodNumber;
|
|
@@ -274,6 +325,8 @@ declare const stationFeedSchema: z.ZodObject<{
|
|
|
274
325
|
temperature: z.ZodBoolean;
|
|
275
326
|
conditions: z.ZodBoolean;
|
|
276
327
|
history: z.ZodBoolean;
|
|
328
|
+
live: z.ZodOptional<z.ZodNullable<z.ZodBoolean>>;
|
|
329
|
+
battery: z.ZodOptional<z.ZodNullable<z.ZodBoolean>>;
|
|
277
330
|
}, z.core.$strip>;
|
|
278
331
|
samplingWindowSeconds: z.ZodNullable<z.ZodNumber>;
|
|
279
332
|
recommendedPollSeconds: z.ZodNumber;
|
|
@@ -325,6 +378,17 @@ declare const stationCurrentSchema: z.ZodObject<{
|
|
|
325
378
|
seaLevelPressureHpa: z.ZodOptional<z.ZodNullable<z.ZodNumber>>;
|
|
326
379
|
}, z.core.$strip>>;
|
|
327
380
|
}, z.core.$strip>>;
|
|
381
|
+
telemetry: z.ZodOptional<z.ZodNullable<z.ZodObject<{
|
|
382
|
+
batteryVoltage: z.ZodNullable<z.ZodNumber>;
|
|
383
|
+
}, z.core.$strip>>>;
|
|
384
|
+
samples: z.ZodOptional<z.ZodNullable<z.ZodObject<{
|
|
385
|
+
intervalSeconds: z.ZodNumber;
|
|
386
|
+
points: z.ZodArray<z.ZodObject<{
|
|
387
|
+
observedAt: z.ZodString;
|
|
388
|
+
windMps: z.ZodNumber;
|
|
389
|
+
windDirectionDeg: z.ZodNullable<z.ZodNumber>;
|
|
390
|
+
}, z.core.$strip>>;
|
|
391
|
+
}, z.core.$strip>>>;
|
|
328
392
|
id: z.ZodString;
|
|
329
393
|
name: z.ZodString;
|
|
330
394
|
sourceLabel: z.ZodString;
|
|
@@ -338,6 +402,8 @@ declare const stationCurrentSchema: z.ZodObject<{
|
|
|
338
402
|
temperature: z.ZodBoolean;
|
|
339
403
|
conditions: z.ZodBoolean;
|
|
340
404
|
history: z.ZodBoolean;
|
|
405
|
+
live: z.ZodOptional<z.ZodNullable<z.ZodBoolean>>;
|
|
406
|
+
battery: z.ZodOptional<z.ZodNullable<z.ZodBoolean>>;
|
|
341
407
|
}, z.core.$strip>;
|
|
342
408
|
samplingWindowSeconds: z.ZodNullable<z.ZodNumber>;
|
|
343
409
|
recommendedPollSeconds: z.ZodNumber;
|
|
@@ -365,17 +431,187 @@ declare const stationCurrentSchema: z.ZodObject<{
|
|
|
365
431
|
temperature: z.ZodBoolean;
|
|
366
432
|
conditions: z.ZodBoolean;
|
|
367
433
|
history: z.ZodBoolean;
|
|
434
|
+
live: z.ZodOptional<z.ZodNullable<z.ZodBoolean>>;
|
|
435
|
+
battery: z.ZodOptional<z.ZodNullable<z.ZodBoolean>>;
|
|
368
436
|
}, z.core.$strip>;
|
|
369
437
|
samplingWindowSeconds: z.ZodNullable<z.ZodNumber>;
|
|
370
438
|
recommendedPollSeconds: z.ZodNumber;
|
|
371
439
|
}, z.core.$strip>], "status">;
|
|
372
440
|
}, z.core.$strip>;
|
|
373
441
|
type StationCurrent = z.infer<typeof stationCurrentSchema>;
|
|
442
|
+
declare const stationLiveFrameSchema: z.ZodDiscriminatedUnion<[z.ZodObject<{
|
|
443
|
+
type: z.ZodLiteral<"init">;
|
|
444
|
+
schemaVersion: z.ZodLiteral<2>;
|
|
445
|
+
servedAt: z.ZodString;
|
|
446
|
+
station: z.ZodDiscriminatedUnion<[z.ZodObject<{
|
|
447
|
+
status: z.ZodLiteral<"ok">;
|
|
448
|
+
reading: z.ZodObject<{
|
|
449
|
+
observedAt: z.ZodString;
|
|
450
|
+
windAvgMps: z.ZodNumber;
|
|
451
|
+
windDirectionDeg: z.ZodNullable<z.ZodNumber>;
|
|
452
|
+
windGustMps: z.ZodNullable<z.ZodNumber>;
|
|
453
|
+
windLullMps: z.ZodNullable<z.ZodNumber>;
|
|
454
|
+
temperatureC: z.ZodNullable<z.ZodNumber>;
|
|
455
|
+
windChillC: z.ZodNullable<z.ZodNumber>;
|
|
456
|
+
conditions: z.ZodNullable<z.ZodObject<{
|
|
457
|
+
dewPointC: z.ZodNullable<z.ZodNumber>;
|
|
458
|
+
lastLightningStrikeAt: z.ZodNullable<z.ZodString>;
|
|
459
|
+
lastLightningStrikeDistanceKm: z.ZodNullable<z.ZodNumber>;
|
|
460
|
+
lightningStrikeCountLastHour: z.ZodNullable<z.ZodNumber>;
|
|
461
|
+
precipitationMinutesToday: z.ZodNullable<z.ZodNumber>;
|
|
462
|
+
precipitationRateMmPerHour: z.ZodNullable<z.ZodNumber>;
|
|
463
|
+
precipitationTodayMm: z.ZodNullable<z.ZodNumber>;
|
|
464
|
+
pressureTrend: z.ZodNullable<z.ZodEnum<{
|
|
465
|
+
falling: "falling";
|
|
466
|
+
rising: "rising";
|
|
467
|
+
steady: "steady";
|
|
468
|
+
unknown: "unknown";
|
|
469
|
+
}>>;
|
|
470
|
+
relativeHumidityPercent: z.ZodNullable<z.ZodNumber>;
|
|
471
|
+
seaLevelPressureHpa: z.ZodNullable<z.ZodNumber>;
|
|
472
|
+
solarRadiationWm2: z.ZodNullable<z.ZodNumber>;
|
|
473
|
+
uvIndex: z.ZodNullable<z.ZodNumber>;
|
|
474
|
+
}, z.core.$strip>>;
|
|
475
|
+
}, z.core.$strip>;
|
|
476
|
+
history: z.ZodNullable<z.ZodObject<{
|
|
477
|
+
periodMinutes: z.ZodNumber;
|
|
478
|
+
points: z.ZodArray<z.ZodObject<{
|
|
479
|
+
observedAt: z.ZodString;
|
|
480
|
+
windAvgMps: z.ZodNumber;
|
|
481
|
+
windGustMps: z.ZodNullable<z.ZodNumber>;
|
|
482
|
+
windLullMps: z.ZodNullable<z.ZodNumber>;
|
|
483
|
+
windDirectionDeg: z.ZodNullable<z.ZodNumber>;
|
|
484
|
+
temperatureC: z.ZodNullable<z.ZodNumber>;
|
|
485
|
+
seaLevelPressureHpa: z.ZodOptional<z.ZodNullable<z.ZodNumber>>;
|
|
486
|
+
}, z.core.$strip>>;
|
|
487
|
+
}, z.core.$strip>>;
|
|
488
|
+
telemetry: z.ZodOptional<z.ZodNullable<z.ZodObject<{
|
|
489
|
+
batteryVoltage: z.ZodNullable<z.ZodNumber>;
|
|
490
|
+
}, z.core.$strip>>>;
|
|
491
|
+
samples: z.ZodOptional<z.ZodNullable<z.ZodObject<{
|
|
492
|
+
intervalSeconds: z.ZodNumber;
|
|
493
|
+
points: z.ZodArray<z.ZodObject<{
|
|
494
|
+
observedAt: z.ZodString;
|
|
495
|
+
windMps: z.ZodNumber;
|
|
496
|
+
windDirectionDeg: z.ZodNullable<z.ZodNumber>;
|
|
497
|
+
}, z.core.$strip>>;
|
|
498
|
+
}, z.core.$strip>>>;
|
|
499
|
+
id: z.ZodString;
|
|
500
|
+
name: z.ZodString;
|
|
501
|
+
sourceLabel: z.ZodString;
|
|
502
|
+
pageUrl: z.ZodNullable<z.ZodString>;
|
|
503
|
+
latitude: z.ZodNullable<z.ZodNumber>;
|
|
504
|
+
longitude: z.ZodNullable<z.ZodNumber>;
|
|
505
|
+
timeZone: z.ZodNullable<z.ZodString>;
|
|
506
|
+
elevationM: z.ZodNullable<z.ZodNumber>;
|
|
507
|
+
capabilities: z.ZodObject<{
|
|
508
|
+
gustLull: z.ZodBoolean;
|
|
509
|
+
temperature: z.ZodBoolean;
|
|
510
|
+
conditions: z.ZodBoolean;
|
|
511
|
+
history: z.ZodBoolean;
|
|
512
|
+
live: z.ZodOptional<z.ZodNullable<z.ZodBoolean>>;
|
|
513
|
+
battery: z.ZodOptional<z.ZodNullable<z.ZodBoolean>>;
|
|
514
|
+
}, z.core.$strip>;
|
|
515
|
+
samplingWindowSeconds: z.ZodNullable<z.ZodNumber>;
|
|
516
|
+
recommendedPollSeconds: z.ZodNumber;
|
|
517
|
+
}, z.core.$strip>, z.ZodObject<{
|
|
518
|
+
status: z.ZodLiteral<"unavailable">;
|
|
519
|
+
reason: z.ZodEnum<{
|
|
520
|
+
upstream_error: "upstream_error";
|
|
521
|
+
timeout: "timeout";
|
|
522
|
+
rate_limited: "rate_limited";
|
|
523
|
+
contract_break: "contract_break";
|
|
524
|
+
not_configured: "not_configured";
|
|
525
|
+
}>;
|
|
526
|
+
reading: z.ZodNull;
|
|
527
|
+
history: z.ZodNull;
|
|
528
|
+
id: z.ZodString;
|
|
529
|
+
name: z.ZodString;
|
|
530
|
+
sourceLabel: z.ZodString;
|
|
531
|
+
pageUrl: z.ZodNullable<z.ZodString>;
|
|
532
|
+
latitude: z.ZodNullable<z.ZodNumber>;
|
|
533
|
+
longitude: z.ZodNullable<z.ZodNumber>;
|
|
534
|
+
timeZone: z.ZodNullable<z.ZodString>;
|
|
535
|
+
elevationM: z.ZodNullable<z.ZodNumber>;
|
|
536
|
+
capabilities: z.ZodObject<{
|
|
537
|
+
gustLull: z.ZodBoolean;
|
|
538
|
+
temperature: z.ZodBoolean;
|
|
539
|
+
conditions: z.ZodBoolean;
|
|
540
|
+
history: z.ZodBoolean;
|
|
541
|
+
live: z.ZodOptional<z.ZodNullable<z.ZodBoolean>>;
|
|
542
|
+
battery: z.ZodOptional<z.ZodNullable<z.ZodBoolean>>;
|
|
543
|
+
}, z.core.$strip>;
|
|
544
|
+
samplingWindowSeconds: z.ZodNullable<z.ZodNumber>;
|
|
545
|
+
recommendedPollSeconds: z.ZodNumber;
|
|
546
|
+
}, z.core.$strip>], "status">;
|
|
547
|
+
}, z.core.$strip>, z.ZodObject<{
|
|
548
|
+
type: z.ZodLiteral<"samples">;
|
|
549
|
+
stationId: z.ZodString;
|
|
550
|
+
samples: z.ZodObject<{
|
|
551
|
+
intervalSeconds: z.ZodNumber;
|
|
552
|
+
points: z.ZodArray<z.ZodObject<{
|
|
553
|
+
observedAt: z.ZodString;
|
|
554
|
+
windMps: z.ZodNumber;
|
|
555
|
+
windDirectionDeg: z.ZodNullable<z.ZodNumber>;
|
|
556
|
+
}, z.core.$strip>>;
|
|
557
|
+
}, z.core.$strip>;
|
|
558
|
+
}, z.core.$strip>, z.ZodObject<{
|
|
559
|
+
type: z.ZodLiteral<"reading">;
|
|
560
|
+
stationId: z.ZodString;
|
|
561
|
+
servedAt: z.ZodString;
|
|
562
|
+
reading: z.ZodObject<{
|
|
563
|
+
observedAt: z.ZodString;
|
|
564
|
+
windAvgMps: z.ZodNumber;
|
|
565
|
+
windDirectionDeg: z.ZodNullable<z.ZodNumber>;
|
|
566
|
+
windGustMps: z.ZodNullable<z.ZodNumber>;
|
|
567
|
+
windLullMps: z.ZodNullable<z.ZodNumber>;
|
|
568
|
+
temperatureC: z.ZodNullable<z.ZodNumber>;
|
|
569
|
+
windChillC: z.ZodNullable<z.ZodNumber>;
|
|
570
|
+
conditions: z.ZodNullable<z.ZodObject<{
|
|
571
|
+
dewPointC: z.ZodNullable<z.ZodNumber>;
|
|
572
|
+
lastLightningStrikeAt: z.ZodNullable<z.ZodString>;
|
|
573
|
+
lastLightningStrikeDistanceKm: z.ZodNullable<z.ZodNumber>;
|
|
574
|
+
lightningStrikeCountLastHour: z.ZodNullable<z.ZodNumber>;
|
|
575
|
+
precipitationMinutesToday: z.ZodNullable<z.ZodNumber>;
|
|
576
|
+
precipitationRateMmPerHour: z.ZodNullable<z.ZodNumber>;
|
|
577
|
+
precipitationTodayMm: z.ZodNullable<z.ZodNumber>;
|
|
578
|
+
pressureTrend: z.ZodNullable<z.ZodEnum<{
|
|
579
|
+
falling: "falling";
|
|
580
|
+
rising: "rising";
|
|
581
|
+
steady: "steady";
|
|
582
|
+
unknown: "unknown";
|
|
583
|
+
}>>;
|
|
584
|
+
relativeHumidityPercent: z.ZodNullable<z.ZodNumber>;
|
|
585
|
+
seaLevelPressureHpa: z.ZodNullable<z.ZodNumber>;
|
|
586
|
+
solarRadiationWm2: z.ZodNullable<z.ZodNumber>;
|
|
587
|
+
uvIndex: z.ZodNullable<z.ZodNumber>;
|
|
588
|
+
}, z.core.$strip>>;
|
|
589
|
+
}, z.core.$strip>;
|
|
590
|
+
telemetry: z.ZodNullable<z.ZodObject<{
|
|
591
|
+
batteryVoltage: z.ZodNullable<z.ZodNumber>;
|
|
592
|
+
}, z.core.$strip>>;
|
|
593
|
+
}, z.core.$strip>, z.ZodObject<{
|
|
594
|
+
type: z.ZodLiteral<"ping">;
|
|
595
|
+
servedAt: z.ZodString;
|
|
596
|
+
}, z.core.$strip>, z.ZodObject<{
|
|
597
|
+
type: z.ZodLiteral<"unavailable">;
|
|
598
|
+
stationId: z.ZodString;
|
|
599
|
+
reason: z.ZodEnum<{
|
|
600
|
+
upstream_error: "upstream_error";
|
|
601
|
+
timeout: "timeout";
|
|
602
|
+
rate_limited: "rate_limited";
|
|
603
|
+
contract_break: "contract_break";
|
|
604
|
+
not_configured: "not_configured";
|
|
605
|
+
}>;
|
|
606
|
+
}, z.core.$strip>], "type">;
|
|
607
|
+
type StationLiveFrame = z.infer<typeof stationLiveFrameSchema>;
|
|
374
608
|
declare function parseStationFeed(value: unknown): StationFeed | null;
|
|
375
609
|
declare function parseStationFeedJson(text: string): StationFeed | null;
|
|
376
610
|
declare function parseStationCurrent(value: unknown): StationCurrent | null;
|
|
377
611
|
declare function parseStationCurrentJson(text: string): StationCurrent | null;
|
|
612
|
+
declare function parseStationLiveFrame(value: unknown): StationLiveFrame | null;
|
|
613
|
+
declare function parseStationLiveFrameJson(text: string): StationLiveFrame | null;
|
|
378
614
|
declare function emptyConditions(overrides?: Partial<AirConditions>): AirConditions;
|
|
379
615
|
declare function unavailableStation(meta: StationMeta, reason: UnavailableReason): Station;
|
|
380
616
|
//#endregion
|
|
381
|
-
export { AirConditions, History, HistoryPoint, Reading, STATION_SCHEMA_VERSION, Station, StationCapabilities, StationCurrent, StationFeed, StationMeta, UNAVAILABLE_REASONS, UnavailableReason, airConditionsSchema, capabilitiesSchema, emptyConditions, historyPointSchema, historySchema, parseStationCurrent, parseStationCurrentJson, parseStationFeed, parseStationFeedJson, readingSchema, stationCurrentSchema, stationFeedSchema, stationMetaSchema, stationSchema, unavailableStation };
|
|
617
|
+
export { AirConditions, History, HistoryPoint, LiveSample, LiveSamples, Reading, STATION_SCHEMA_VERSION, Station, StationCapabilities, StationCurrent, StationFeed, StationLiveFrame, StationMeta, StationTelemetry, UNAVAILABLE_REASONS, UnavailableReason, airConditionsSchema, capabilitiesSchema, emptyConditions, historyPointSchema, historySchema, liveSampleSchema, liveSamplesSchema, parseStationCurrent, parseStationCurrentJson, parseStationFeed, parseStationFeedJson, parseStationLiveFrame, parseStationLiveFrameJson, readingSchema, stationCurrentSchema, stationFeedSchema, stationLiveFrameSchema, stationMetaSchema, stationSchema, telemetrySchema, unavailableStation };
|
package/dist/contract.js
CHANGED
|
@@ -25,6 +25,7 @@ const airConditionsSchema = z.object({
|
|
|
25
25
|
solarRadiationWm2: z.number().finite().nullable(),
|
|
26
26
|
uvIndex: z.number().finite().min(0).nullable()
|
|
27
27
|
}).describe("Extended air data. null means 'not reported here' — it does not distinguish a missing sensor from a dark one; the station-level conditions capability gates whether a client allocates UI structure.").meta({ id: "AirConditions" });
|
|
28
|
+
const telemetrySchema = z.object({ batteryVoltage: z.number().finite().nullable().describe("Station supply volts. null means 'not reported here', never a dead battery.") }).describe("Device telemetry. The station-level battery capability gates whether a client allocates UI structure; a dark sensor keeps its structure and reports null.").meta({ id: "StationTelemetry" });
|
|
28
29
|
const readingSchema = z.object({
|
|
29
30
|
observedAt: isoTime,
|
|
30
31
|
windAvgMps: speedMps.describe("Wind speed in m/s, averaged over samplingWindowSeconds. Absence is null, never zero."),
|
|
@@ -48,11 +49,22 @@ const historySchema = z.object({
|
|
|
48
49
|
periodMinutes: z.number().finite().positive().describe("Minutes each point covers. Wind run, vane thinning, and dropout detection are functions of it."),
|
|
49
50
|
points: z.array(historyPointSchema).describe("A dropout is an ABSENT record, never a zeroed one — gaps carry no points.")
|
|
50
51
|
}).meta({ id: "History" });
|
|
52
|
+
const liveSampleSchema = z.object({
|
|
53
|
+
observedAt: isoTime,
|
|
54
|
+
windMps: speedMps.describe("Instantaneous m/s — a single anemometer sample, not a period mean."),
|
|
55
|
+
windDirectionDeg: windDirectionDeg.nullable().describe("Degrees FROM; null exactly when calm (below 0.5 m/s).")
|
|
56
|
+
}).meta({ id: "LiveSample" });
|
|
57
|
+
const liveSamplesSchema = z.object({
|
|
58
|
+
intervalSeconds: z.number().finite().positive().describe("Seconds between samples."),
|
|
59
|
+
points: z.array(liveSampleSchema).describe("Oldest first. A dropout is an ABSENT sample, never a zeroed one.")
|
|
60
|
+
}).meta({ id: "LiveSamples" });
|
|
51
61
|
const capabilitiesSchema = z.object({
|
|
52
62
|
gustLull: z.boolean(),
|
|
53
63
|
temperature: z.boolean(),
|
|
54
64
|
conditions: z.boolean(),
|
|
55
|
-
history: z.boolean()
|
|
65
|
+
history: z.boolean(),
|
|
66
|
+
live: z.boolean().nullish().describe("The station has a live sample stream; absent or null reads as false."),
|
|
67
|
+
battery: z.boolean().nullish().describe("The station reports battery telemetry; absent or null reads as false.")
|
|
56
68
|
}).describe("Declared from what the hardware carries, never inferred from data. Capabilities gate client UI structure; a dark sensor keeps its structure and reports null.").meta({ id: "StationCapabilities" });
|
|
57
69
|
const stationMetaShape = {
|
|
58
70
|
id: z.string().min(1),
|
|
@@ -72,7 +84,9 @@ const stationSchema = z.discriminatedUnion("status", [z.object({
|
|
|
72
84
|
...stationMetaShape,
|
|
73
85
|
status: z.literal("ok"),
|
|
74
86
|
reading: readingSchema,
|
|
75
|
-
history: historySchema.nullable()
|
|
87
|
+
history: historySchema.nullable(),
|
|
88
|
+
telemetry: telemetrySchema.nullish(),
|
|
89
|
+
samples: liveSamplesSchema.nullish()
|
|
76
90
|
}), z.object({
|
|
77
91
|
...stationMetaShape,
|
|
78
92
|
status: z.literal("unavailable"),
|
|
@@ -91,6 +105,35 @@ const stationCurrentSchema = z.object({
|
|
|
91
105
|
servedAt: isoTime,
|
|
92
106
|
station: stationSchema
|
|
93
107
|
});
|
|
108
|
+
const stationLiveFrameSchema = z.discriminatedUnion("type", [
|
|
109
|
+
z.object({
|
|
110
|
+
type: z.literal("init"),
|
|
111
|
+
schemaVersion: z.literal(2),
|
|
112
|
+
servedAt: isoTime,
|
|
113
|
+
station: stationSchema
|
|
114
|
+
}),
|
|
115
|
+
z.object({
|
|
116
|
+
type: z.literal("samples"),
|
|
117
|
+
stationId: z.string().min(1),
|
|
118
|
+
samples: liveSamplesSchema
|
|
119
|
+
}),
|
|
120
|
+
z.object({
|
|
121
|
+
type: z.literal("reading"),
|
|
122
|
+
stationId: z.string().min(1),
|
|
123
|
+
servedAt: isoTime,
|
|
124
|
+
reading: readingSchema,
|
|
125
|
+
telemetry: telemetrySchema.nullable()
|
|
126
|
+
}),
|
|
127
|
+
z.object({
|
|
128
|
+
type: z.literal("ping"),
|
|
129
|
+
servedAt: isoTime
|
|
130
|
+
}),
|
|
131
|
+
z.object({
|
|
132
|
+
type: z.literal("unavailable"),
|
|
133
|
+
stationId: z.string().min(1),
|
|
134
|
+
reason: z.enum(UNAVAILABLE_REASONS)
|
|
135
|
+
})
|
|
136
|
+
]).meta({ id: "StationLiveFrame" });
|
|
94
137
|
function parseStationFeed(value) {
|
|
95
138
|
const result = stationFeedSchema.safeParse(value);
|
|
96
139
|
return result.success ? result.data : null;
|
|
@@ -113,6 +156,17 @@ function parseStationCurrentJson(text) {
|
|
|
113
156
|
return null;
|
|
114
157
|
}
|
|
115
158
|
}
|
|
159
|
+
function parseStationLiveFrame(value) {
|
|
160
|
+
const result = stationLiveFrameSchema.safeParse(value);
|
|
161
|
+
return result.success ? result.data : null;
|
|
162
|
+
}
|
|
163
|
+
function parseStationLiveFrameJson(text) {
|
|
164
|
+
try {
|
|
165
|
+
return parseStationLiveFrame(JSON.parse(text));
|
|
166
|
+
} catch {
|
|
167
|
+
return null;
|
|
168
|
+
}
|
|
169
|
+
}
|
|
116
170
|
function emptyConditions(overrides = {}) {
|
|
117
171
|
return {
|
|
118
172
|
dewPointC: null,
|
|
@@ -140,4 +194,4 @@ function unavailableStation(meta, reason) {
|
|
|
140
194
|
};
|
|
141
195
|
}
|
|
142
196
|
//#endregion
|
|
143
|
-
export { STATION_SCHEMA_VERSION, UNAVAILABLE_REASONS, airConditionsSchema, capabilitiesSchema, emptyConditions, historyPointSchema, historySchema, parseStationCurrent, parseStationCurrentJson, parseStationFeed, parseStationFeedJson, readingSchema, stationCurrentSchema, stationFeedSchema, stationMetaSchema, stationSchema, unavailableStation };
|
|
197
|
+
export { STATION_SCHEMA_VERSION, UNAVAILABLE_REASONS, airConditionsSchema, capabilitiesSchema, emptyConditions, historyPointSchema, historySchema, liveSampleSchema, liveSamplesSchema, parseStationCurrent, parseStationCurrentJson, parseStationFeed, parseStationFeedJson, parseStationLiveFrame, parseStationLiveFrameJson, readingSchema, stationCurrentSchema, stationFeedSchema, stationLiveFrameSchema, stationMetaSchema, stationSchema, telemetrySchema, unavailableStation };
|
package/dist/endpoints.d.ts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
//#region src/endpoints.d.ts
|
|
2
2
|
declare function feedEndpoint(base: string): string;
|
|
3
3
|
declare function currentEndpoint(base: string, stationId: string): string;
|
|
4
|
+
declare function liveEndpoint(base: string, stationId: string): string;
|
|
4
5
|
//#endregion
|
|
5
|
-
export { currentEndpoint, feedEndpoint };
|
|
6
|
+
export { currentEndpoint, feedEndpoint, liveEndpoint };
|
package/dist/endpoints.js
CHANGED
|
@@ -6,5 +6,8 @@ function feedEndpoint(base) {
|
|
|
6
6
|
function currentEndpoint(base, stationId) {
|
|
7
7
|
return `${trimBase(base)}/current?station=${encodeURIComponent(stationId)}`;
|
|
8
8
|
}
|
|
9
|
+
function liveEndpoint(base, stationId) {
|
|
10
|
+
return `${trimBase(base)}/live?station=${encodeURIComponent(stationId)}`;
|
|
11
|
+
}
|
|
9
12
|
//#endregion
|
|
10
|
-
export { currentEndpoint, feedEndpoint };
|
|
13
|
+
export { currentEndpoint, feedEndpoint, liveEndpoint };
|
package/dist/index.d.ts
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
|
-
import { AirConditions, History, HistoryPoint, Reading, STATION_SCHEMA_VERSION, Station, StationCapabilities, StationCurrent, StationFeed, StationMeta, UNAVAILABLE_REASONS, UnavailableReason, airConditionsSchema, capabilitiesSchema, emptyConditions, historyPointSchema, historySchema, parseStationCurrent, parseStationCurrentJson, parseStationFeed, parseStationFeedJson, readingSchema, stationCurrentSchema, stationFeedSchema, stationMetaSchema, stationSchema, unavailableStation } from "./contract.js";
|
|
1
|
+
import { AirConditions, History, HistoryPoint, LiveSample, LiveSamples, Reading, STATION_SCHEMA_VERSION, Station, StationCapabilities, StationCurrent, StationFeed, StationLiveFrame, StationMeta, StationTelemetry, UNAVAILABLE_REASONS, UnavailableReason, airConditionsSchema, capabilitiesSchema, emptyConditions, historyPointSchema, historySchema, liveSampleSchema, liveSamplesSchema, parseStationCurrent, parseStationCurrentJson, parseStationFeed, parseStationFeedJson, parseStationLiveFrame, parseStationLiveFrameJson, readingSchema, stationCurrentSchema, stationFeedSchema, stationLiveFrameSchema, stationMetaSchema, stationSchema, telemetrySchema, unavailableStation } from "./contract.js";
|
|
2
2
|
import { CALM_THRESHOLD_MPS, CompassPoint, FreshnessStatus, FreshnessThresholds, PeriodSummary, PressureTendency, SpeedThresholds, SpeedUnit, compassDirection, freshness, isCalm, normalizeDegrees, periodSummary, pressureTendency, seaLevelPressureHpa, speedFromMps, speedToMps, speedUnitLabel, stationFreshnessThresholds, thresholdsToMps } from "./derive.js";
|
|
3
3
|
import { FormatTime, StationStringOverrides, StationStrings, defaultFormatTime, defaultStrings, localeFormatTime, mergeStringOverrides, resolveStrings } from "./strings.js";
|
|
4
4
|
import { DirectionCellData, SummaryEntry, directionCell, optionalSpeed, roundSpeed, summaryEntries, temperatureText, temperatureValue, updatedAtText } from "./format.js";
|
|
5
5
|
import { DisplayDefaults, DisplayProps, ResolvedDisplay, requireResolved, resolveDisplay, resolveStation } from "./display.js";
|
|
6
|
-
import { currentEndpoint, feedEndpoint } from "./endpoints.js";
|
|
6
|
+
import { currentEndpoint, feedEndpoint, liveEndpoint } from "./endpoints.js";
|
|
7
7
|
import { ChartFrame, ChartScaleOptions, ChartScales, ChartTick, DAILY_PATTERN_DEFAULT_SLOT_MINUTES, DailyPatternSlot, METEOROLOGICAL_SEASON_MONTHS, RoseSector, Vane, WindRoseSummary, averagePoints, bandPoints, chartFrame, chartScales, compareTracePoints, compareWindow, dailyPattern, filterByMonth, filterByTimeOfDay, historyGaps, speedBand, thinVanes, vanePath, vaneTicks, windRose, windowPoints } from "./geometry.js";
|
|
8
8
|
import { DIAL_CARDINALS, DIAL_CARDINAL_TICK_INNER, DIAL_CENTRE, DIAL_COUNTERWEIGHT_RADIUS, DIAL_COUNTERWEIGHT_REACH, DIAL_HUB_RADIUS, DIAL_LETTER_RADIUS, DIAL_MIN_MAX_MPS, DIAL_RING_RADIUS, DIAL_SIZE, DIAL_TICK_INNER, FavorableDirection, HistoryRun, ROSE_CARDINAL_LETTERS, ROSE_CENTRE, ROSE_FAVORABLE_RING_RADIUS, ROSE_HUB_DOT_RADIUS, ROSE_HUB_RADIUS, ROSE_INTERCARDINAL_BEARINGS, ROSE_LETTER_RADIUS, ROSE_MAX_RADIUS, ROSE_PETAL_FILL, ROSE_SIZE, ROSE_TICK_REACH, SPARKLINE_EDGE_INSET, SPARKLINE_MAX_PADDING, bandStrips, dialNeedlePoints, dialPolar, dialScaleMaxMps, dialSpeedArcPath, historyRuns, rosePetalPath, rosePolar, roseRingArcPath, sparklineScale } from "./instruments.js";
|
|
9
9
|
import { MergeResult, foldCurrent, mergeCurrent } from "./merge-current.js";
|
|
10
10
|
import { AirRow, airRows, airSummary, lastStrikeWords } from "./air.js";
|
|
11
11
|
import { normalizeWindnerdStationKey, windnerdStationUrl } from "./windnerd.js";
|
|
12
|
-
export { type AirConditions, type AirRow, CALM_THRESHOLD_MPS, type ChartFrame, type ChartScaleOptions, type ChartScales, type ChartTick, type CompassPoint, DAILY_PATTERN_DEFAULT_SLOT_MINUTES, DIAL_CARDINALS, DIAL_CARDINAL_TICK_INNER, DIAL_CENTRE, DIAL_COUNTERWEIGHT_RADIUS, DIAL_COUNTERWEIGHT_REACH, DIAL_HUB_RADIUS, DIAL_LETTER_RADIUS, DIAL_MIN_MAX_MPS, DIAL_RING_RADIUS, DIAL_SIZE, DIAL_TICK_INNER, type DailyPatternSlot, type DirectionCellData, type DisplayDefaults, type DisplayProps, type FavorableDirection, type FormatTime, type FreshnessStatus, type FreshnessThresholds, type History, type HistoryPoint, type HistoryRun, METEOROLOGICAL_SEASON_MONTHS, type MergeResult, type PeriodSummary, type PressureTendency, ROSE_CARDINAL_LETTERS, ROSE_CENTRE, ROSE_FAVORABLE_RING_RADIUS, ROSE_HUB_DOT_RADIUS, ROSE_HUB_RADIUS, ROSE_INTERCARDINAL_BEARINGS, ROSE_LETTER_RADIUS, ROSE_MAX_RADIUS, ROSE_PETAL_FILL, ROSE_SIZE, ROSE_TICK_REACH, type Reading, type ResolvedDisplay, type RoseSector, SPARKLINE_EDGE_INSET, SPARKLINE_MAX_PADDING, STATION_SCHEMA_VERSION, type SpeedThresholds, type SpeedUnit, type Station, type StationCapabilities, type StationCurrent, type StationFeed, type StationMeta, type StationStringOverrides, type StationStrings, type SummaryEntry, UNAVAILABLE_REASONS, type UnavailableReason, type Vane, type WindRoseSummary, airConditionsSchema, airRows, airSummary, averagePoints, bandPoints, bandStrips, capabilitiesSchema, chartFrame, chartScales, compareTracePoints, compareWindow, compassDirection, currentEndpoint, dailyPattern, defaultFormatTime, defaultStrings, dialNeedlePoints, dialPolar, dialScaleMaxMps, dialSpeedArcPath, directionCell, emptyConditions, feedEndpoint, filterByMonth, filterByTimeOfDay, foldCurrent, freshness, historyGaps, historyPointSchema, historyRuns, historySchema, isCalm, lastStrikeWords, localeFormatTime, mergeCurrent, mergeStringOverrides, normalizeDegrees, normalizeWindnerdStationKey, optionalSpeed, parseStationCurrent, parseStationCurrentJson, parseStationFeed, parseStationFeedJson, periodSummary, pressureTendency, readingSchema, requireResolved, resolveDisplay, resolveStation, resolveStrings, rosePetalPath, rosePolar, roseRingArcPath, roundSpeed, seaLevelPressureHpa, sparklineScale, speedBand, speedFromMps, speedToMps, speedUnitLabel, stationCurrentSchema, stationFeedSchema, stationFreshnessThresholds, stationMetaSchema, stationSchema, summaryEntries, temperatureText, temperatureValue, thinVanes, thresholdsToMps, unavailableStation, updatedAtText, vanePath, vaneTicks, windRose, windnerdStationUrl, windowPoints };
|
|
12
|
+
export { type AirConditions, type AirRow, CALM_THRESHOLD_MPS, type ChartFrame, type ChartScaleOptions, type ChartScales, type ChartTick, type CompassPoint, DAILY_PATTERN_DEFAULT_SLOT_MINUTES, DIAL_CARDINALS, DIAL_CARDINAL_TICK_INNER, DIAL_CENTRE, DIAL_COUNTERWEIGHT_RADIUS, DIAL_COUNTERWEIGHT_REACH, DIAL_HUB_RADIUS, DIAL_LETTER_RADIUS, DIAL_MIN_MAX_MPS, DIAL_RING_RADIUS, DIAL_SIZE, DIAL_TICK_INNER, type DailyPatternSlot, type DirectionCellData, type DisplayDefaults, type DisplayProps, type FavorableDirection, type FormatTime, type FreshnessStatus, type FreshnessThresholds, type History, type HistoryPoint, type HistoryRun, type LiveSample, type LiveSamples, METEOROLOGICAL_SEASON_MONTHS, type MergeResult, type PeriodSummary, type PressureTendency, ROSE_CARDINAL_LETTERS, ROSE_CENTRE, ROSE_FAVORABLE_RING_RADIUS, ROSE_HUB_DOT_RADIUS, ROSE_HUB_RADIUS, ROSE_INTERCARDINAL_BEARINGS, ROSE_LETTER_RADIUS, ROSE_MAX_RADIUS, ROSE_PETAL_FILL, ROSE_SIZE, ROSE_TICK_REACH, type Reading, type ResolvedDisplay, type RoseSector, SPARKLINE_EDGE_INSET, SPARKLINE_MAX_PADDING, STATION_SCHEMA_VERSION, type SpeedThresholds, type SpeedUnit, type Station, type StationCapabilities, type StationCurrent, type StationFeed, type StationLiveFrame, type StationMeta, type StationStringOverrides, type StationStrings, type StationTelemetry, type SummaryEntry, UNAVAILABLE_REASONS, type UnavailableReason, type Vane, type WindRoseSummary, airConditionsSchema, airRows, airSummary, averagePoints, bandPoints, bandStrips, capabilitiesSchema, chartFrame, chartScales, compareTracePoints, compareWindow, compassDirection, currentEndpoint, dailyPattern, defaultFormatTime, defaultStrings, dialNeedlePoints, dialPolar, dialScaleMaxMps, dialSpeedArcPath, directionCell, emptyConditions, feedEndpoint, filterByMonth, filterByTimeOfDay, foldCurrent, freshness, historyGaps, historyPointSchema, historyRuns, historySchema, isCalm, lastStrikeWords, liveEndpoint, liveSampleSchema, liveSamplesSchema, localeFormatTime, mergeCurrent, mergeStringOverrides, normalizeDegrees, normalizeWindnerdStationKey, optionalSpeed, parseStationCurrent, parseStationCurrentJson, parseStationFeed, parseStationFeedJson, parseStationLiveFrame, parseStationLiveFrameJson, periodSummary, pressureTendency, readingSchema, requireResolved, resolveDisplay, resolveStation, resolveStrings, rosePetalPath, rosePolar, roseRingArcPath, roundSpeed, seaLevelPressureHpa, sparklineScale, speedBand, speedFromMps, speedToMps, speedUnitLabel, stationCurrentSchema, stationFeedSchema, stationFreshnessThresholds, stationLiveFrameSchema, stationMetaSchema, stationSchema, summaryEntries, telemetrySchema, temperatureText, temperatureValue, thinVanes, thresholdsToMps, unavailableStation, updatedAtText, vanePath, vaneTicks, windRose, windnerdStationUrl, windowPoints };
|
package/dist/index.js
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
|
-
import { STATION_SCHEMA_VERSION, UNAVAILABLE_REASONS, airConditionsSchema, capabilitiesSchema, emptyConditions, historyPointSchema, historySchema, parseStationCurrent, parseStationCurrentJson, parseStationFeed, parseStationFeedJson, readingSchema, stationCurrentSchema, stationFeedSchema, stationMetaSchema, stationSchema, unavailableStation } from "./contract.js";
|
|
1
|
+
import { STATION_SCHEMA_VERSION, UNAVAILABLE_REASONS, airConditionsSchema, capabilitiesSchema, emptyConditions, historyPointSchema, historySchema, liveSampleSchema, liveSamplesSchema, parseStationCurrent, parseStationCurrentJson, parseStationFeed, parseStationFeedJson, parseStationLiveFrame, parseStationLiveFrameJson, readingSchema, stationCurrentSchema, stationFeedSchema, stationLiveFrameSchema, stationMetaSchema, stationSchema, telemetrySchema, unavailableStation } from "./contract.js";
|
|
2
2
|
import { CALM_THRESHOLD_MPS, compassDirection, freshness, isCalm, normalizeDegrees, periodSummary, pressureTendency, seaLevelPressureHpa, speedFromMps, speedToMps, speedUnitLabel, stationFreshnessThresholds, thresholdsToMps } from "./derive.js";
|
|
3
3
|
import { defaultFormatTime, defaultStrings, localeFormatTime, mergeStringOverrides, resolveStrings } from "./strings.js";
|
|
4
4
|
import { requireResolved, resolveDisplay, resolveStation } from "./display.js";
|
|
5
|
-
import { currentEndpoint, feedEndpoint } from "./endpoints.js";
|
|
5
|
+
import { currentEndpoint, feedEndpoint, liveEndpoint } from "./endpoints.js";
|
|
6
6
|
import { directionCell, optionalSpeed, roundSpeed, summaryEntries, temperatureText, temperatureValue, updatedAtText } from "./format.js";
|
|
7
7
|
import { DAILY_PATTERN_DEFAULT_SLOT_MINUTES, METEOROLOGICAL_SEASON_MONTHS, averagePoints, bandPoints, chartFrame, chartScales, compareTracePoints, compareWindow, dailyPattern, filterByMonth, filterByTimeOfDay, historyGaps, speedBand, thinVanes, vanePath, vaneTicks, windRose, windowPoints } from "./geometry.js";
|
|
8
8
|
import { DIAL_CARDINALS, DIAL_CARDINAL_TICK_INNER, DIAL_CENTRE, DIAL_COUNTERWEIGHT_RADIUS, DIAL_COUNTERWEIGHT_REACH, DIAL_HUB_RADIUS, DIAL_LETTER_RADIUS, DIAL_MIN_MAX_MPS, DIAL_RING_RADIUS, DIAL_SIZE, DIAL_TICK_INNER, ROSE_CARDINAL_LETTERS, ROSE_CENTRE, ROSE_FAVORABLE_RING_RADIUS, ROSE_HUB_DOT_RADIUS, ROSE_HUB_RADIUS, ROSE_INTERCARDINAL_BEARINGS, ROSE_LETTER_RADIUS, ROSE_MAX_RADIUS, ROSE_PETAL_FILL, ROSE_SIZE, ROSE_TICK_REACH, SPARKLINE_EDGE_INSET, SPARKLINE_MAX_PADDING, bandStrips, dialNeedlePoints, dialPolar, dialScaleMaxMps, dialSpeedArcPath, historyRuns, rosePetalPath, rosePolar, roseRingArcPath, sparklineScale } from "./instruments.js";
|
|
9
9
|
import { foldCurrent, mergeCurrent } from "./merge-current.js";
|
|
10
10
|
import { airRows, airSummary, lastStrikeWords } from "./air.js";
|
|
11
11
|
import { normalizeWindnerdStationKey, windnerdStationUrl } from "./windnerd.js";
|
|
12
|
-
export { CALM_THRESHOLD_MPS, DAILY_PATTERN_DEFAULT_SLOT_MINUTES, DIAL_CARDINALS, DIAL_CARDINAL_TICK_INNER, DIAL_CENTRE, DIAL_COUNTERWEIGHT_RADIUS, DIAL_COUNTERWEIGHT_REACH, DIAL_HUB_RADIUS, DIAL_LETTER_RADIUS, DIAL_MIN_MAX_MPS, DIAL_RING_RADIUS, DIAL_SIZE, DIAL_TICK_INNER, METEOROLOGICAL_SEASON_MONTHS, ROSE_CARDINAL_LETTERS, ROSE_CENTRE, ROSE_FAVORABLE_RING_RADIUS, ROSE_HUB_DOT_RADIUS, ROSE_HUB_RADIUS, ROSE_INTERCARDINAL_BEARINGS, ROSE_LETTER_RADIUS, ROSE_MAX_RADIUS, ROSE_PETAL_FILL, ROSE_SIZE, ROSE_TICK_REACH, SPARKLINE_EDGE_INSET, SPARKLINE_MAX_PADDING, STATION_SCHEMA_VERSION, UNAVAILABLE_REASONS, airConditionsSchema, airRows, airSummary, averagePoints, bandPoints, bandStrips, capabilitiesSchema, chartFrame, chartScales, compareTracePoints, compareWindow, compassDirection, currentEndpoint, dailyPattern, defaultFormatTime, defaultStrings, dialNeedlePoints, dialPolar, dialScaleMaxMps, dialSpeedArcPath, directionCell, emptyConditions, feedEndpoint, filterByMonth, filterByTimeOfDay, foldCurrent, freshness, historyGaps, historyPointSchema, historyRuns, historySchema, isCalm, lastStrikeWords, localeFormatTime, mergeCurrent, mergeStringOverrides, normalizeDegrees, normalizeWindnerdStationKey, optionalSpeed, parseStationCurrent, parseStationCurrentJson, parseStationFeed, parseStationFeedJson, periodSummary, pressureTendency, readingSchema, requireResolved, resolveDisplay, resolveStation, resolveStrings, rosePetalPath, rosePolar, roseRingArcPath, roundSpeed, seaLevelPressureHpa, sparklineScale, speedBand, speedFromMps, speedToMps, speedUnitLabel, stationCurrentSchema, stationFeedSchema, stationFreshnessThresholds, stationMetaSchema, stationSchema, summaryEntries, temperatureText, temperatureValue, thinVanes, thresholdsToMps, unavailableStation, updatedAtText, vanePath, vaneTicks, windRose, windnerdStationUrl, windowPoints };
|
|
12
|
+
export { CALM_THRESHOLD_MPS, DAILY_PATTERN_DEFAULT_SLOT_MINUTES, DIAL_CARDINALS, DIAL_CARDINAL_TICK_INNER, DIAL_CENTRE, DIAL_COUNTERWEIGHT_RADIUS, DIAL_COUNTERWEIGHT_REACH, DIAL_HUB_RADIUS, DIAL_LETTER_RADIUS, DIAL_MIN_MAX_MPS, DIAL_RING_RADIUS, DIAL_SIZE, DIAL_TICK_INNER, METEOROLOGICAL_SEASON_MONTHS, ROSE_CARDINAL_LETTERS, ROSE_CENTRE, ROSE_FAVORABLE_RING_RADIUS, ROSE_HUB_DOT_RADIUS, ROSE_HUB_RADIUS, ROSE_INTERCARDINAL_BEARINGS, ROSE_LETTER_RADIUS, ROSE_MAX_RADIUS, ROSE_PETAL_FILL, ROSE_SIZE, ROSE_TICK_REACH, SPARKLINE_EDGE_INSET, SPARKLINE_MAX_PADDING, STATION_SCHEMA_VERSION, UNAVAILABLE_REASONS, airConditionsSchema, airRows, airSummary, averagePoints, bandPoints, bandStrips, capabilitiesSchema, chartFrame, chartScales, compareTracePoints, compareWindow, compassDirection, currentEndpoint, dailyPattern, defaultFormatTime, defaultStrings, dialNeedlePoints, dialPolar, dialScaleMaxMps, dialSpeedArcPath, directionCell, emptyConditions, feedEndpoint, filterByMonth, filterByTimeOfDay, foldCurrent, freshness, historyGaps, historyPointSchema, historyRuns, historySchema, isCalm, lastStrikeWords, liveEndpoint, liveSampleSchema, liveSamplesSchema, localeFormatTime, mergeCurrent, mergeStringOverrides, normalizeDegrees, normalizeWindnerdStationKey, optionalSpeed, parseStationCurrent, parseStationCurrentJson, parseStationFeed, parseStationFeedJson, parseStationLiveFrame, parseStationLiveFrameJson, periodSummary, pressureTendency, readingSchema, requireResolved, resolveDisplay, resolveStation, resolveStrings, rosePetalPath, rosePolar, roseRingArcPath, roundSpeed, seaLevelPressureHpa, sparklineScale, speedBand, speedFromMps, speedToMps, speedUnitLabel, stationCurrentSchema, stationFeedSchema, stationFreshnessThresholds, stationLiveFrameSchema, stationMetaSchema, stationSchema, summaryEntries, telemetrySchema, temperatureText, temperatureValue, thinVanes, thresholdsToMps, unavailableStation, updatedAtText, vanePath, vaneTicks, windRose, windnerdStationUrl, windowPoints };
|
|
@@ -1,11 +1,14 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
import { foldCurrent } from "../../merge-current.js";
|
|
3
|
+
import { liveSnapshotToCurrent } from "../../client/live.js";
|
|
3
4
|
import { useStationCurrent } from "./useStationCurrent.js";
|
|
4
5
|
import { useStationFeed } from "./useStationFeed.js";
|
|
6
|
+
import { useStationLive } from "./useStationLive.js";
|
|
5
7
|
import { useCallback, useMemo } from "react";
|
|
6
8
|
//#region src/react/hooks/useStation.ts
|
|
7
9
|
function useStation(url, stationId, options = {}) {
|
|
8
10
|
const { pollSeconds, currentPollSeconds, enabled = true, fetchInit, initialData } = options;
|
|
11
|
+
const live = options.live === true;
|
|
9
12
|
const feedResult = useStationFeed(url, {
|
|
10
13
|
...pollSeconds != null ? { pollSeconds } : {},
|
|
11
14
|
enabled,
|
|
@@ -14,14 +17,31 @@ function useStation(url, stationId, options = {}) {
|
|
|
14
17
|
});
|
|
15
18
|
const currentResult = useStationCurrent(url, stationId, {
|
|
16
19
|
...currentPollSeconds != null ? { pollSeconds: currentPollSeconds } : {},
|
|
17
|
-
enabled,
|
|
20
|
+
enabled: enabled && !live,
|
|
21
|
+
...fetchInit != null ? { fetchInit } : {}
|
|
22
|
+
});
|
|
23
|
+
const liveResult = useStationLive(url, stationId, {
|
|
24
|
+
enabled: enabled && live,
|
|
18
25
|
...fetchInit != null ? { fetchInit } : {}
|
|
19
26
|
});
|
|
20
|
-
const
|
|
27
|
+
const liveCurrent = useMemo(() => live ? liveSnapshotToCurrent({
|
|
28
|
+
station: liveResult.station,
|
|
29
|
+
servedAt: liveResult.servedAt,
|
|
30
|
+
samples: liveResult.samples
|
|
31
|
+
}) : null, [
|
|
32
|
+
live,
|
|
33
|
+
liveResult.station,
|
|
34
|
+
liveResult.servedAt,
|
|
35
|
+
liveResult.samples
|
|
36
|
+
]);
|
|
37
|
+
const current = live ? liveCurrent : currentResult.current;
|
|
38
|
+
const currentReceivedAtMs = live ? liveCurrent == null ? null : liveResult.receivedAtMs : currentResult.receivedAtMs;
|
|
39
|
+
const currentError = live ? liveResult.error : currentResult.error;
|
|
40
|
+
const merged = useMemo(() => foldCurrent(feedResult.feed, feedResult.receivedAtMs, current, currentReceivedAtMs), [
|
|
21
41
|
feedResult.feed,
|
|
22
42
|
feedResult.receivedAtMs,
|
|
23
|
-
|
|
24
|
-
|
|
43
|
+
current,
|
|
44
|
+
currentReceivedAtMs
|
|
25
45
|
]);
|
|
26
46
|
const station = merged.feed?.stations.find((entry) => entry.id === stationId) ?? null;
|
|
27
47
|
const feedRefresh = feedResult.refresh;
|
|
@@ -34,7 +54,7 @@ function useStation(url, stationId, options = {}) {
|
|
|
34
54
|
feed: merged.feed,
|
|
35
55
|
station,
|
|
36
56
|
receivedAtMs: merged.receivedAtMs,
|
|
37
|
-
error: feedResult.error ??
|
|
57
|
+
error: feedResult.error ?? currentError,
|
|
38
58
|
refresh
|
|
39
59
|
};
|
|
40
60
|
}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { PollError } from "../../client/poll.js";
|
|
2
|
+
import { LiveSample, Station } from "../../contract.js";
|
|
3
|
+
import { LiveStatus } from "../../client/live.js";
|
|
4
|
+
import "../../client/index.js";
|
|
5
|
+
import "../../index.js";
|
|
6
|
+
//#region src/react/hooks/useStationLive.d.ts
|
|
7
|
+
declare function useStationLive(url: string, stationId: string, options?: {
|
|
8
|
+
enabled?: boolean;
|
|
9
|
+
fetchInit?: RequestInit;
|
|
10
|
+
windowSeconds?: number;
|
|
11
|
+
}): {
|
|
12
|
+
station: Station | null;
|
|
13
|
+
samples: LiveSample[];
|
|
14
|
+
status: LiveStatus;
|
|
15
|
+
servedAt: string | null;
|
|
16
|
+
receivedAtMs: number | null;
|
|
17
|
+
error: PollError | null;
|
|
18
|
+
};
|
|
19
|
+
//#endregion
|
|
20
|
+
export { useStationLive };
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { createStationLiveStore } from "../../client/live.js";
|
|
3
|
+
import { useEffect, useMemo, useRef, useSyncExternalStore } from "react";
|
|
4
|
+
//#region src/react/hooks/useStationLive.ts
|
|
5
|
+
function useStationLive(url, stationId, options = {}) {
|
|
6
|
+
const { enabled = true, fetchInit, windowSeconds } = options;
|
|
7
|
+
const fetchInitRef = useRef(fetchInit);
|
|
8
|
+
fetchInitRef.current = fetchInit;
|
|
9
|
+
const store = useMemo(() => createStationLiveStore(url, stationId, {
|
|
10
|
+
fetchInit: () => fetchInitRef.current,
|
|
11
|
+
...windowSeconds != null ? { windowSeconds } : {}
|
|
12
|
+
}), [
|
|
13
|
+
url,
|
|
14
|
+
stationId,
|
|
15
|
+
windowSeconds
|
|
16
|
+
]);
|
|
17
|
+
const snapshot = useSyncExternalStore(store.subscribe, store.getSnapshot, store.getSnapshot);
|
|
18
|
+
useEffect(() => {
|
|
19
|
+
if (!enabled) return;
|
|
20
|
+
store.start();
|
|
21
|
+
return () => store.stop();
|
|
22
|
+
}, [store, enabled]);
|
|
23
|
+
return {
|
|
24
|
+
station: snapshot.station,
|
|
25
|
+
samples: snapshot.samples,
|
|
26
|
+
status: snapshot.status,
|
|
27
|
+
servedAt: snapshot.servedAt,
|
|
28
|
+
receivedAtMs: snapshot.receivedAtMs,
|
|
29
|
+
error: snapshot.error
|
|
30
|
+
};
|
|
31
|
+
}
|
|
32
|
+
//#endregion
|
|
33
|
+
export { useStationLive };
|
package/dist/react/index.d.ts
CHANGED
|
@@ -17,4 +17,5 @@ import { useFreshness } from "./hooks/useFreshness.js";
|
|
|
17
17
|
import { useStation } from "./hooks/useStation.js";
|
|
18
18
|
import { useStationCurrent } from "./hooks/useStationCurrent.js";
|
|
19
19
|
import { useStationFeed } from "./hooks/useStationFeed.js";
|
|
20
|
-
|
|
20
|
+
import { useStationLive } from "./hooks/useStationLive.js";
|
|
21
|
+
export { AirMatrix, BandChip, CurrentConditions, DailyPattern, Dial, Direction, FreshnessBadge, Gust, Lull, Pressure, Sparkline, Speed, StationCard, StationCardChart, StationCardHeader, StationCardInstrument, StationCardSummary, type StationFeedContextValue, StationFeedProvider, type StationMetaRenderer, StationStrip, StationTable, Temperature, TrendChart, UpdatedAt, WindArrow, WindHistoryChart, WindRose, useFreshness, useStation, useStationCurrent, useStationFeed, useStationFeedContext, useStationLive };
|
package/dist/react/index.js
CHANGED
|
@@ -17,5 +17,6 @@ import { WindRose } from "./components/WindRose.js";
|
|
|
17
17
|
import { StationCard, StationCardChart, StationCardHeader, StationCardInstrument, StationCardSummary } from "./components/StationCard.js";
|
|
18
18
|
import { useStationCurrent } from "./hooks/useStationCurrent.js";
|
|
19
19
|
import { useStationFeed } from "./hooks/useStationFeed.js";
|
|
20
|
+
import { useStationLive } from "./hooks/useStationLive.js";
|
|
20
21
|
import { useStation } from "./hooks/useStation.js";
|
|
21
|
-
export { AirMatrix, BandChip, CurrentConditions, DailyPattern, Dial, Direction, FreshnessBadge, Gust, Lull, Pressure, Sparkline, Speed, StationCard, StationCardChart, StationCardHeader, StationCardInstrument, StationCardSummary, StationFeedProvider, StationStrip, StationTable, Temperature, TrendChart, UpdatedAt, WindArrow, WindHistoryChart, WindRose, useFreshness, useStation, useStationCurrent, useStationFeed, useStationFeedContext };
|
|
22
|
+
export { AirMatrix, BandChip, CurrentConditions, DailyPattern, Dial, Direction, FreshnessBadge, Gust, Lull, Pressure, Sparkline, Speed, StationCard, StationCardChart, StationCardHeader, StationCardInstrument, StationCardSummary, StationFeedProvider, StationStrip, StationTable, Temperature, TrendChart, UpdatedAt, WindArrow, WindHistoryChart, WindRose, useFreshness, useStation, useStationCurrent, useStationFeed, useStationFeedContext, useStationLive };
|