@ramme-io/shared 3.4.0 → 3.6.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 +169 -6
- package/dist/index.d.cts +5038 -1951
- package/dist/index.d.ts +5038 -1951
- package/dist/index.js +158 -6
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -503,6 +503,8 @@ var AppTextSchema = z6.object({
|
|
|
503
503
|
size: AppTextSizeSchema.default("base"),
|
|
504
504
|
align: AppAlignSchema.default("start"),
|
|
505
505
|
/** Printed after the value, e.g. a degree symbol. Never itself bound. */
|
|
506
|
+
/** Drawn before the value, as `suffix` is after: "H " for "H 68°". */
|
|
507
|
+
prefix: z6.string().max(8).optional(),
|
|
506
508
|
suffix: z6.string().max(8).optional(),
|
|
507
509
|
...leafBase
|
|
508
510
|
});
|
|
@@ -560,6 +562,7 @@ var AssetHashSchema = z6.string().regex(/^[0-9a-f]{64}$/, "a lowercase hex SHA-2
|
|
|
560
562
|
var IMAGE_MAX_DRAWN = { width: 304, height: 224 };
|
|
561
563
|
var IMAGE_MAX_SCALE = 8;
|
|
562
564
|
var RETRO_RENDITION = { width: 76, height: 56, scale: 4, colors: 16 };
|
|
565
|
+
var FULL_RENDITION = { width: 304, height: 224, quality: 0.82, maxBytes: 48e3 };
|
|
563
566
|
var SPR_FORMAT = {
|
|
564
567
|
/** "RSPR". */
|
|
565
568
|
magic: [82, 83, 80, 82],
|
|
@@ -578,7 +581,24 @@ var AppImageSchema = z6.object({
|
|
|
578
581
|
width: z6.number().int().min(1).max(IMAGE_MAX_DRAWN.width),
|
|
579
582
|
height: z6.number().int().min(1).max(IMAGE_MAX_DRAWN.height),
|
|
580
583
|
scale: z6.number().int().min(1).max(IMAGE_MAX_SCALE).default(1),
|
|
584
|
+
/**
|
|
585
|
+
* What kind of file `asset` names: `spr`, the palette file the retro look
|
|
586
|
+
* uses, or `jpeg`, the full-colour rendition (drawn at scale 1). Absent means
|
|
587
|
+
* `spr`, which is every image block written before full colour existed.
|
|
588
|
+
*/
|
|
589
|
+
format: z6.enum(["spr", "jpeg"]).default("spr"),
|
|
590
|
+
align: AppAlignSchema.default("start"),
|
|
591
|
+
/** Drawn only when this is false, or absent. */
|
|
592
|
+
hideWhen: AppConditionSchema.optional()
|
|
593
|
+
});
|
|
594
|
+
var ICON_SIZE_PX = { sm: 24, md: 48, lg: 72, xl: 96 };
|
|
595
|
+
var AppIconSchema = z6.object({
|
|
596
|
+
type: z6.literal("icon"),
|
|
597
|
+
value: AppBindingSchema,
|
|
598
|
+
size: z6.enum(["sm", "md", "lg", "xl"]).default("md"),
|
|
581
599
|
align: AppAlignSchema.default("start"),
|
|
600
|
+
color: AppColorSchema.default("foreground"),
|
|
601
|
+
rules: z6.array(AppStyleRuleSchema).max(4).optional(),
|
|
582
602
|
/** Drawn only when this is false, or absent. */
|
|
583
603
|
hideWhen: AppConditionSchema.optional()
|
|
584
604
|
});
|
|
@@ -589,13 +609,25 @@ var AppLeafSchema = z6.discriminatedUnion("type", [
|
|
|
589
609
|
AppBarSchema,
|
|
590
610
|
AppStatusSchema,
|
|
591
611
|
AppSpriteSchema,
|
|
592
|
-
AppImageSchema
|
|
612
|
+
AppImageSchema,
|
|
613
|
+
AppIconSchema
|
|
593
614
|
]);
|
|
594
615
|
var AppGroupSchema = z6.object({
|
|
595
616
|
type: z6.literal("group"),
|
|
596
617
|
direction: z6.enum(["row", "stack"]),
|
|
597
618
|
gap: z6.number().int().min(0).max(64).default(4),
|
|
598
619
|
align: AppAlignSchema.default("start"),
|
|
620
|
+
/**
|
|
621
|
+
* A row whose children take their own width, `gap` apart, placed together
|
|
622
|
+
* at the row's `align` — "68°" with its icon right beside it, "H 68° L 56°"
|
|
623
|
+
* as one line. Without it a row splits into equal cells, which put a short
|
|
624
|
+
* temperature and its icon half a screen apart. Text is as wide as the
|
|
625
|
+
* board draws it (six pixels in eight, per character); bars, dials,
|
|
626
|
+
* sparklines and status lights have no width of their own and share what is
|
|
627
|
+
* left. Ignored by a stack, and by firmware older than 2026-10-17, which
|
|
628
|
+
* falls back to equal cells.
|
|
629
|
+
*/
|
|
630
|
+
pack: z6.boolean().optional(),
|
|
599
631
|
children: z6.array(AppLeafSchema).min(1).max(8)
|
|
600
632
|
});
|
|
601
633
|
var AppBlockSchema = z6.union([AppLeafSchema, AppGroupSchema]);
|
|
@@ -612,6 +644,13 @@ var AppDocumentSchema = z6.object({
|
|
|
612
644
|
author: z6.string().max(32).optional(),
|
|
613
645
|
screen: AppScreenSizeSchema.default("320x240"),
|
|
614
646
|
background: AppColorSchema.default("background"),
|
|
647
|
+
/**
|
|
648
|
+
* Where the blocks sit on the screen as a whole: from the top, or in the
|
|
649
|
+
* middle with the space shared above and below. A document taller than the
|
|
650
|
+
* screen starts at the top either way, so centring never pushes the first
|
|
651
|
+
* block off the glass. Older firmware draws from the top.
|
|
652
|
+
*/
|
|
653
|
+
valign: z6.enum(["start", "center"]).optional(),
|
|
615
654
|
/** Named so bindings can refer to them. */
|
|
616
655
|
sources: z6.record(AppSourceSchema).default({}),
|
|
617
656
|
blocks: z6.array(AppBlockSchema).min(1).max(12)
|
|
@@ -633,6 +672,14 @@ var AppDocumentSchema = z6.object({
|
|
|
633
672
|
const b = block;
|
|
634
673
|
if (b?.type !== "image" || !b.width || !b.height) return;
|
|
635
674
|
const scale = b.scale ?? 1;
|
|
675
|
+
if (b.format === "jpeg" && scale !== 1) {
|
|
676
|
+
ctx.addIssue({
|
|
677
|
+
code: z6.ZodIssueCode.custom,
|
|
678
|
+
path: [...path, "scale"],
|
|
679
|
+
message: "A jpeg image is drawn at scale 1; make the file the size it should appear."
|
|
680
|
+
});
|
|
681
|
+
return;
|
|
682
|
+
}
|
|
636
683
|
const w = b.width * scale;
|
|
637
684
|
const h = b.height * scale;
|
|
638
685
|
if (w <= IMAGE_MAX_DRAWN.width && h <= IMAGE_MAX_DRAWN.height) return;
|
|
@@ -661,10 +708,22 @@ var ORIGINAL_MAX_SIDE = 3072;
|
|
|
661
708
|
var ORIGINAL_MAX_BYTES = 3e6;
|
|
662
709
|
var PHOTOS_PER_ACCOUNT = 50;
|
|
663
710
|
var PHOTO_UPLOADS_PER_HOUR = 30;
|
|
711
|
+
var PhotoCropSchema = z7.object({
|
|
712
|
+
x: z7.number().min(0).max(1),
|
|
713
|
+
y: z7.number().min(0).max(1),
|
|
714
|
+
w: z7.number().gt(0).max(1),
|
|
715
|
+
h: z7.number().gt(0).max(1),
|
|
716
|
+
mirror: z7.boolean().default(false)
|
|
717
|
+
});
|
|
664
718
|
var PhotoUploadSchema = z7.object({
|
|
665
719
|
rendition: z7.string().min(4),
|
|
666
|
-
original: z7.string().min(4)
|
|
720
|
+
original: z7.string().min(4),
|
|
721
|
+
/** The full-colour rendition (FULL_RENDITION), base64 JPEG. Optional for older clients. */
|
|
722
|
+
full: z7.string().min(4).optional(),
|
|
723
|
+
crop: PhotoCropSchema.optional()
|
|
667
724
|
});
|
|
725
|
+
var PhotoFullSchema = z7.object({ full: z7.string().min(4) });
|
|
726
|
+
var FULL_COLOUR_FRAME_MAX = 4;
|
|
668
727
|
var PhotoSummarySchema = z7.object({
|
|
669
728
|
hash: AssetHashSchema,
|
|
670
729
|
/** The rendition's own pixels. */
|
|
@@ -674,7 +733,10 @@ var PhotoSummarySchema = z7.object({
|
|
|
674
733
|
originalWidth: z7.number().int().positive(),
|
|
675
734
|
originalHeight: z7.number().int().positive(),
|
|
676
735
|
originalBytes: z7.number().int().positive(),
|
|
677
|
-
uploadedAt: z7.number().int()
|
|
736
|
+
uploadedAt: z7.number().int(),
|
|
737
|
+
/** The full-colour rendition, when one has been made. Its own hash names it. */
|
|
738
|
+
full: z7.object({ hash: AssetHashSchema, bytes: z7.number().int().positive() }).optional(),
|
|
739
|
+
crop: PhotoCropSchema.optional()
|
|
678
740
|
});
|
|
679
741
|
|
|
680
742
|
// src/apps/delivery.ts
|
|
@@ -948,6 +1010,73 @@ var DEVICE_TIMEZONES = [
|
|
|
948
1010
|
];
|
|
949
1011
|
var DEVICE_TIMEZONE_FALLBACK = "UTC0";
|
|
950
1012
|
|
|
1013
|
+
// src/apps/weather.ts
|
|
1014
|
+
var WEATHER_ICON_NAMES = ["sun", "partly", "cloud", "fog", "rain", "snow", "storm"];
|
|
1015
|
+
var WEATHER_CODES = [
|
|
1016
|
+
{ upTo: 0, word: "Clear", icon: "sun" },
|
|
1017
|
+
{ upTo: 1, word: "Mostly clear", icon: "sun" },
|
|
1018
|
+
{ upTo: 2, word: "Partly cloudy", icon: "partly" },
|
|
1019
|
+
{ upTo: 3, word: "Cloudy", icon: "cloud" },
|
|
1020
|
+
{ upTo: 48, word: "Fog", icon: "fog" },
|
|
1021
|
+
{ upTo: 57, word: "Drizzle", icon: "rain" },
|
|
1022
|
+
{ upTo: 67, word: "Rain", icon: "rain" },
|
|
1023
|
+
{ upTo: 77, word: "Snow", icon: "snow" },
|
|
1024
|
+
{ upTo: 82, word: "Showers", icon: "rain" },
|
|
1025
|
+
{ upTo: 86, word: "Snow showers", icon: "snow" },
|
|
1026
|
+
{ upTo: 99, word: "Storm", icon: "storm" }
|
|
1027
|
+
];
|
|
1028
|
+
var ICON_GRID = 48;
|
|
1029
|
+
var ICON_STROKE = 3;
|
|
1030
|
+
var WEATHER_ICONS = {
|
|
1031
|
+
sun: [
|
|
1032
|
+
[32, 24, 32, 26, 30, 29, 29, 30, 26, 32, 22, 32, 19, 30, 18, 29, 16, 26, 16, 22, 18, 19, 19, 18, 22, 16, 26, 16, 29, 18, 30, 19, 32, 22, 32, 24],
|
|
1033
|
+
[37, 24, 43, 24],
|
|
1034
|
+
[33, 33, 37, 37],
|
|
1035
|
+
[24, 37, 24, 43],
|
|
1036
|
+
[15, 33, 11, 37],
|
|
1037
|
+
[11, 24, 5, 24],
|
|
1038
|
+
[15, 15, 11, 11],
|
|
1039
|
+
[24, 11, 24, 5],
|
|
1040
|
+
[33, 15, 37, 11]
|
|
1041
|
+
],
|
|
1042
|
+
partly: [
|
|
1043
|
+
[17, 23, 15, 23, 13, 22, 11, 20, 10, 18, 10, 14, 11, 12, 13, 10, 15, 9, 19, 9, 21, 10, 23, 12, 24, 14, 24, 16],
|
|
1044
|
+
[28, 16, 32, 16],
|
|
1045
|
+
[9, 24, 6, 27],
|
|
1046
|
+
[6, 16, 2, 16],
|
|
1047
|
+
[9, 8, 6, 5],
|
|
1048
|
+
[17, 5, 17, 1],
|
|
1049
|
+
[25, 8, 28, 5],
|
|
1050
|
+
[41, 33, 40, 35, 38, 37, 36, 38, 15, 38, 13, 37, 11, 33, 13, 29, 15, 27, 17, 27, 17, 24, 19, 20, 21, 18, 23, 17, 28, 17, 30, 18, 34, 22, 34, 24, 37, 25, 39, 26, 41, 28, 42, 30, 41, 33]
|
|
1051
|
+
],
|
|
1052
|
+
cloud: [
|
|
1053
|
+
[42, 32, 40, 35, 38, 37, 35, 38, 12, 38, 10, 37, 9, 34, 8, 32, 9, 30, 10, 27, 14, 25, 14, 22, 15, 20, 21, 14, 27, 14, 33, 20, 34, 22, 37, 23, 39, 24, 41, 26, 42, 29, 42, 32]
|
|
1054
|
+
],
|
|
1055
|
+
fog: [
|
|
1056
|
+
[8, 16, 40, 16],
|
|
1057
|
+
[12, 24, 36, 24],
|
|
1058
|
+
[8, 32, 40, 32]
|
|
1059
|
+
],
|
|
1060
|
+
rain: [
|
|
1061
|
+
[41, 25, 37, 29, 35, 30, 13, 30, 10, 29, 9, 27, 9, 22, 10, 20, 14, 18, 15, 15, 15, 13, 19, 9, 21, 8, 26, 8, 29, 9, 31, 11, 33, 15, 36, 16, 38, 17, 40, 19, 41, 22, 41, 24],
|
|
1062
|
+
[15, 36, 12, 43],
|
|
1063
|
+
[24, 36, 21, 43],
|
|
1064
|
+
[33, 36, 30, 43]
|
|
1065
|
+
],
|
|
1066
|
+
snow: [
|
|
1067
|
+
[41, 25, 37, 29, 35, 30, 13, 30, 10, 29, 9, 27, 9, 22, 10, 20, 14, 18, 15, 15, 15, 13, 19, 9, 21, 8, 26, 8, 29, 9, 31, 11, 33, 15, 36, 16, 38, 17, 40, 19, 41, 22, 41, 24],
|
|
1068
|
+
[14, 39, 14, 39],
|
|
1069
|
+
[24, 42, 24, 42],
|
|
1070
|
+
[34, 39, 34, 39],
|
|
1071
|
+
[19, 45, 19, 45],
|
|
1072
|
+
[29, 45, 29, 45]
|
|
1073
|
+
],
|
|
1074
|
+
storm: [
|
|
1075
|
+
[41, 25, 37, 29, 35, 30, 13, 30, 10, 29, 9, 27, 9, 22, 10, 20, 14, 18, 15, 15, 15, 13, 19, 9, 21, 8, 26, 8, 29, 9, 31, 11, 33, 15, 36, 16, 38, 17, 40, 19, 41, 22, 41, 24],
|
|
1076
|
+
[26, 33, 20, 41, 27, 41, 22, 47]
|
|
1077
|
+
]
|
|
1078
|
+
};
|
|
1079
|
+
|
|
951
1080
|
// src/ai/tools.ts
|
|
952
1081
|
import { z as z10 } from "zod";
|
|
953
1082
|
var telemetryGraphParameters = z10.object({
|
|
@@ -1231,7 +1360,8 @@ THE SHAPE
|
|
|
1231
1360
|
|
|
1232
1361
|
BLOCKS \u2014 up to 12, drawn top to bottom. Each is one of:
|
|
1233
1362
|
|
|
1234
|
-
{ "type": "text", "value": V, "size": S, "align": A, "color": C, "suffix": "\xB0" }
|
|
1363
|
+
{ "type": "text", "value": V, "size": S, "align": A, "color": C, "prefix": "H ", "suffix": "\xB0" }
|
|
1364
|
+
{ "type": "icon", "value": V, "size": "sm"|"md"|"lg"|"xl", "align": A, "color": C }
|
|
1235
1365
|
{ "type": "dial", "value": V, "min": 0, "max": 100, "label": "CPU", "color": C }
|
|
1236
1366
|
{ "type": "bar", "value": V, "min": 0, "max": 100, "color": C }
|
|
1237
1367
|
{ "type": "sparkline", "series": V, "color": C }
|
|
@@ -1240,7 +1370,18 @@ BLOCKS \u2014 up to 12, drawn top to bottom. Each is one of:
|
|
|
1240
1370
|
0110
|
|
1241
1371
|
1100
|
|
1242
1372
|
0011", "align": A }
|
|
1243
|
-
{ "type": "group", "direction": "row"|"stack", "gap": 8, "align": A, "children": [ ...leaves... ] }
|
|
1373
|
+
{ "type": "group", "direction": "row"|"stack", "gap": 8, "align": A, "pack": true, "children": [ ...leaves... ] }
|
|
1374
|
+
|
|
1375
|
+
A row splits the width into equal cells. Add "pack": true and each child takes
|
|
1376
|
+
only its own width, "gap" apart \u2014 a number with its icon right beside it, or
|
|
1377
|
+
"H 68\xB0 L 56\xB0" as one line. Put "valign": "center" at the top level of the
|
|
1378
|
+
document to centre the blocks on the screen rather than start at the top.
|
|
1379
|
+
|
|
1380
|
+
AN ICON is the sky drawn in outline: "sun", "partly", "cloud", "fog", "rain",
|
|
1381
|
+
"snow" or "storm". Bind its value to a weather source's "icon" field so it
|
|
1382
|
+
follows the weather \u2014 { "source": "forecast", "field": "icon" } \u2014 or write one
|
|
1383
|
+
of those names as a literal. Sizes are 24, 48, 72 and 96 pixels square. Prefer
|
|
1384
|
+
it to drawing a weather sprite: it costs nothing and the board draws it crisply.
|
|
1244
1385
|
|
|
1245
1386
|
DRAWING A SPRITE \u2014 you may, and here is the only form that works.
|
|
1246
1387
|
|
|
@@ -1322,7 +1463,7 @@ SOURCES \u2014 declare what the app reads, then bind to it by name:
|
|
|
1322
1463
|
|
|
1323
1464
|
"forecast": { "kind": "weather", "latitude": 39.95, "longitude": -75.17,
|
|
1324
1465
|
"units": "imperial", "refreshSeconds": 600 }
|
|
1325
|
-
fields: temperature, condition, high, low
|
|
1466
|
+
fields: temperature, condition, icon, high, low
|
|
1326
1467
|
"now": { "kind": "clock", "timezone": "America/New_York", "twentyFourHour": false }
|
|
1327
1468
|
fields: time, date, weekday, hour (hour is 0-23, for rules about time of day)
|
|
1328
1469
|
"until": { "kind": "countdown", "target": "2026-12-25", "label": "Christmas" }
|
|
@@ -1742,6 +1883,7 @@ export {
|
|
|
1742
1883
|
AppDialSchema,
|
|
1743
1884
|
AppDocumentSchema,
|
|
1744
1885
|
AppGroupSchema,
|
|
1886
|
+
AppIconSchema,
|
|
1745
1887
|
AppImageSchema,
|
|
1746
1888
|
AppLeafSchema,
|
|
1747
1889
|
AppOperandSchema,
|
|
@@ -1812,11 +1954,16 @@ export {
|
|
|
1812
1954
|
EventSourceSchema,
|
|
1813
1955
|
FIRMWARE_UPDATE_ATTEMPTS,
|
|
1814
1956
|
FIRMWARE_UPDATE_PREFIX,
|
|
1957
|
+
FULL_COLOUR_FRAME_MAX,
|
|
1958
|
+
FULL_RENDITION,
|
|
1815
1959
|
FieldSchema,
|
|
1816
1960
|
FirmwareUpdateSchema,
|
|
1817
1961
|
FloraTelemetrySchema,
|
|
1818
1962
|
GENESIS_LIBRARY_CONTEXT,
|
|
1819
1963
|
GENESIS_VALID_COMPONENTS,
|
|
1964
|
+
ICON_GRID,
|
|
1965
|
+
ICON_SIZE_PX,
|
|
1966
|
+
ICON_STROKE,
|
|
1820
1967
|
IMAGE_MAX_DRAWN,
|
|
1821
1968
|
IMAGE_MAX_SCALE,
|
|
1822
1969
|
IMPACT_FLAG_THRESHOLD,
|
|
@@ -1836,6 +1983,8 @@ export {
|
|
|
1836
1983
|
PageSectionSchema,
|
|
1837
1984
|
PaginatedEntityEventsSchema,
|
|
1838
1985
|
PairCodeSchema,
|
|
1986
|
+
PhotoCropSchema,
|
|
1987
|
+
PhotoFullSchema,
|
|
1839
1988
|
PhotoSummarySchema,
|
|
1840
1989
|
PhotoUploadSchema,
|
|
1841
1990
|
ProvisioningStateSchema,
|
|
@@ -1876,6 +2025,9 @@ export {
|
|
|
1876
2025
|
TriggerSchema,
|
|
1877
2026
|
UserSchema,
|
|
1878
2027
|
VitalSourceSchema,
|
|
2028
|
+
WEATHER_CODES,
|
|
2029
|
+
WEATHER_ICONS,
|
|
2030
|
+
WEATHER_ICON_NAMES,
|
|
1879
2031
|
WeatherAppConfigSchema,
|
|
1880
2032
|
WorkflowSchema,
|
|
1881
2033
|
architectureReferenceParameters,
|