@ramme-io/shared 3.3.1 → 3.5.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/dist/index.cjs +68 -3
- package/dist/index.d.cts +286 -9
- package/dist/index.d.ts +286 -9
- package/dist/index.js +61 -3
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -560,6 +560,7 @@ var AssetHashSchema = z6.string().regex(/^[0-9a-f]{64}$/, "a lowercase hex SHA-2
|
|
|
560
560
|
var IMAGE_MAX_DRAWN = { width: 304, height: 224 };
|
|
561
561
|
var IMAGE_MAX_SCALE = 8;
|
|
562
562
|
var RETRO_RENDITION = { width: 76, height: 56, scale: 4, colors: 16 };
|
|
563
|
+
var FULL_RENDITION = { width: 304, height: 224, quality: 0.82, maxBytes: 48e3 };
|
|
563
564
|
var SPR_FORMAT = {
|
|
564
565
|
/** "RSPR". */
|
|
565
566
|
magic: [82, 83, 80, 82],
|
|
@@ -578,6 +579,12 @@ var AppImageSchema = z6.object({
|
|
|
578
579
|
width: z6.number().int().min(1).max(IMAGE_MAX_DRAWN.width),
|
|
579
580
|
height: z6.number().int().min(1).max(IMAGE_MAX_DRAWN.height),
|
|
580
581
|
scale: z6.number().int().min(1).max(IMAGE_MAX_SCALE).default(1),
|
|
582
|
+
/**
|
|
583
|
+
* What kind of file `asset` names: `spr`, the palette file the retro look
|
|
584
|
+
* uses, or `jpeg`, the full-colour rendition (drawn at scale 1). Absent means
|
|
585
|
+
* `spr`, which is every image block written before full colour existed.
|
|
586
|
+
*/
|
|
587
|
+
format: z6.enum(["spr", "jpeg"]).default("spr"),
|
|
581
588
|
align: AppAlignSchema.default("start"),
|
|
582
589
|
/** Drawn only when this is false, or absent. */
|
|
583
590
|
hideWhen: AppConditionSchema.optional()
|
|
@@ -633,6 +640,14 @@ var AppDocumentSchema = z6.object({
|
|
|
633
640
|
const b = block;
|
|
634
641
|
if (b?.type !== "image" || !b.width || !b.height) return;
|
|
635
642
|
const scale = b.scale ?? 1;
|
|
643
|
+
if (b.format === "jpeg" && scale !== 1) {
|
|
644
|
+
ctx.addIssue({
|
|
645
|
+
code: z6.ZodIssueCode.custom,
|
|
646
|
+
path: [...path, "scale"],
|
|
647
|
+
message: "A jpeg image is drawn at scale 1; make the file the size it should appear."
|
|
648
|
+
});
|
|
649
|
+
return;
|
|
650
|
+
}
|
|
636
651
|
const w = b.width * scale;
|
|
637
652
|
const h = b.height * scale;
|
|
638
653
|
if (w <= IMAGE_MAX_DRAWN.width && h <= IMAGE_MAX_DRAWN.height) return;
|
|
@@ -661,10 +676,22 @@ var ORIGINAL_MAX_SIDE = 3072;
|
|
|
661
676
|
var ORIGINAL_MAX_BYTES = 3e6;
|
|
662
677
|
var PHOTOS_PER_ACCOUNT = 50;
|
|
663
678
|
var PHOTO_UPLOADS_PER_HOUR = 30;
|
|
679
|
+
var PhotoCropSchema = z7.object({
|
|
680
|
+
x: z7.number().min(0).max(1),
|
|
681
|
+
y: z7.number().min(0).max(1),
|
|
682
|
+
w: z7.number().gt(0).max(1),
|
|
683
|
+
h: z7.number().gt(0).max(1),
|
|
684
|
+
mirror: z7.boolean().default(false)
|
|
685
|
+
});
|
|
664
686
|
var PhotoUploadSchema = z7.object({
|
|
665
687
|
rendition: z7.string().min(4),
|
|
666
|
-
original: z7.string().min(4)
|
|
688
|
+
original: z7.string().min(4),
|
|
689
|
+
/** The full-colour rendition (FULL_RENDITION), base64 JPEG. Optional for older clients. */
|
|
690
|
+
full: z7.string().min(4).optional(),
|
|
691
|
+
crop: PhotoCropSchema.optional()
|
|
667
692
|
});
|
|
693
|
+
var PhotoFullSchema = z7.object({ full: z7.string().min(4) });
|
|
694
|
+
var FULL_COLOUR_FRAME_MAX = 4;
|
|
668
695
|
var PhotoSummarySchema = z7.object({
|
|
669
696
|
hash: AssetHashSchema,
|
|
670
697
|
/** The rendition's own pixels. */
|
|
@@ -674,7 +701,10 @@ var PhotoSummarySchema = z7.object({
|
|
|
674
701
|
originalWidth: z7.number().int().positive(),
|
|
675
702
|
originalHeight: z7.number().int().positive(),
|
|
676
703
|
originalBytes: z7.number().int().positive(),
|
|
677
|
-
uploadedAt: z7.number().int()
|
|
704
|
+
uploadedAt: z7.number().int(),
|
|
705
|
+
/** The full-colour rendition, when one has been made. Its own hash names it. */
|
|
706
|
+
full: z7.object({ hash: AssetHashSchema, bytes: z7.number().int().positive() }).optional(),
|
|
707
|
+
crop: PhotoCropSchema.optional()
|
|
678
708
|
});
|
|
679
709
|
|
|
680
710
|
// src/apps/delivery.ts
|
|
@@ -723,6 +753,15 @@ var DeviceRecordSchema = z8.object({
|
|
|
723
753
|
var DEVICE_LABEL_MAX = 48;
|
|
724
754
|
var DEVICE_TTL_SECONDS = 60 * 60 * 24 * 30;
|
|
725
755
|
var CLAIMED_DEVICE_TTL_SECONDS = 60 * 60 * 24 * 400;
|
|
756
|
+
var FirmwareUpdateSchema = z8.object({
|
|
757
|
+
version: z8.string().min(1).max(40),
|
|
758
|
+
url: z8.string().url().max(200),
|
|
759
|
+
sha256: z8.string().regex(/^[0-9a-f]{64}$/),
|
|
760
|
+
bytes: z8.number().int().positive(),
|
|
761
|
+
requestedAt: z8.number().int().nonnegative()
|
|
762
|
+
});
|
|
763
|
+
var FIRMWARE_UPDATE_PREFIX = "https://www.ramme.io/firmware/weather-display/";
|
|
764
|
+
var FIRMWARE_UPDATE_ATTEMPTS = 3;
|
|
726
765
|
|
|
727
766
|
// src/apps/vitals.ts
|
|
728
767
|
import { z as z9 } from "zod";
|
|
@@ -762,7 +801,19 @@ var DeviceSeenSchema = z9.object({
|
|
|
762
801
|
/** When the board last asked for its app. The freshest signal this system has. */
|
|
763
802
|
lastPollAt: z9.number().int().nonnegative(),
|
|
764
803
|
/** The revision it reported drawing at that moment. */
|
|
765
|
-
drewRevision: z9.number().int().nonnegative().optional()
|
|
804
|
+
drewRevision: z9.number().int().nonnegative().optional(),
|
|
805
|
+
/**
|
|
806
|
+
* The firmware it is running, sent on every poll by builds that can update
|
|
807
|
+
* remotely — so its presence is also the answer to "can this board be
|
|
808
|
+
* updated from its page?". Registration reports the version too, but only
|
|
809
|
+
* every six hours; after a remote update this is what shows it took.
|
|
810
|
+
*/
|
|
811
|
+
firmware: z9.string().max(40).optional(),
|
|
812
|
+
/** Photos its app names, and how many of those it holds in flash. */
|
|
813
|
+
photosWanted: z9.number().int().nonnegative().optional(),
|
|
814
|
+
photosHeld: z9.number().int().nonnegative().optional(),
|
|
815
|
+
/** What happened to the last firmware update it tried, in a few words. */
|
|
816
|
+
updateResult: z9.string().max(80).optional()
|
|
766
817
|
});
|
|
767
818
|
var DEVICE_VITALS_FIELDS = [
|
|
768
819
|
{
|
|
@@ -1789,7 +1840,12 @@ export {
|
|
|
1789
1840
|
EntitySchema,
|
|
1790
1841
|
EventBucketSizeSchema,
|
|
1791
1842
|
EventSourceSchema,
|
|
1843
|
+
FIRMWARE_UPDATE_ATTEMPTS,
|
|
1844
|
+
FIRMWARE_UPDATE_PREFIX,
|
|
1845
|
+
FULL_COLOUR_FRAME_MAX,
|
|
1846
|
+
FULL_RENDITION,
|
|
1792
1847
|
FieldSchema,
|
|
1848
|
+
FirmwareUpdateSchema,
|
|
1793
1849
|
FloraTelemetrySchema,
|
|
1794
1850
|
GENESIS_LIBRARY_CONTEXT,
|
|
1795
1851
|
GENESIS_VALID_COMPONENTS,
|
|
@@ -1812,6 +1868,8 @@ export {
|
|
|
1812
1868
|
PageSectionSchema,
|
|
1813
1869
|
PaginatedEntityEventsSchema,
|
|
1814
1870
|
PairCodeSchema,
|
|
1871
|
+
PhotoCropSchema,
|
|
1872
|
+
PhotoFullSchema,
|
|
1815
1873
|
PhotoSummarySchema,
|
|
1816
1874
|
PhotoUploadSchema,
|
|
1817
1875
|
ProvisioningStateSchema,
|