@ramme-io/shared 3.5.0 → 3.7.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.cjs CHANGED
@@ -50,6 +50,7 @@ __export(index_exports, {
50
50
  AppDialSchema: () => AppDialSchema,
51
51
  AppDocumentSchema: () => AppDocumentSchema,
52
52
  AppGroupSchema: () => AppGroupSchema,
53
+ AppIconSchema: () => AppIconSchema,
53
54
  AppImageSchema: () => AppImageSchema,
54
55
  AppLeafSchema: () => AppLeafSchema,
55
56
  AppOperandSchema: () => AppOperandSchema,
@@ -127,6 +128,9 @@ __export(index_exports, {
127
128
  FloraTelemetrySchema: () => FloraTelemetrySchema,
128
129
  GENESIS_LIBRARY_CONTEXT: () => GENESIS_LIBRARY_CONTEXT,
129
130
  GENESIS_VALID_COMPONENTS: () => GENESIS_VALID_COMPONENTS,
131
+ ICON_GRID: () => ICON_GRID,
132
+ ICON_SIZE_PX: () => ICON_SIZE_PX,
133
+ ICON_STROKE: () => ICON_STROKE,
130
134
  IMAGE_MAX_DRAWN: () => IMAGE_MAX_DRAWN,
131
135
  IMAGE_MAX_SCALE: () => IMAGE_MAX_SCALE,
132
136
  IMPACT_FLAG_THRESHOLD: () => IMPACT_FLAG_THRESHOLD,
@@ -188,6 +192,9 @@ __export(index_exports, {
188
192
  TriggerSchema: () => TriggerSchema,
189
193
  UserSchema: () => UserSchema,
190
194
  VitalSourceSchema: () => VitalSourceSchema,
195
+ WEATHER_CODES: () => WEATHER_CODES,
196
+ WEATHER_ICONS: () => WEATHER_ICONS,
197
+ WEATHER_ICON_NAMES: () => WEATHER_ICON_NAMES,
191
198
  WeatherAppConfigSchema: () => WeatherAppConfigSchema,
192
199
  WorkflowSchema: () => WorkflowSchema,
193
200
  architectureReferenceParameters: () => architectureReferenceParameters,
@@ -700,6 +707,8 @@ var AppTextSchema = import_zod6.z.object({
700
707
  size: AppTextSizeSchema.default("base"),
701
708
  align: AppAlignSchema.default("start"),
702
709
  /** Printed after the value, e.g. a degree symbol. Never itself bound. */
710
+ /** Drawn before the value, as `suffix` is after: "H " for "H 68°". */
711
+ prefix: import_zod6.z.string().max(8).optional(),
703
712
  suffix: import_zod6.z.string().max(8).optional(),
704
713
  ...leafBase
705
714
  });
@@ -786,6 +795,17 @@ var AppImageSchema = import_zod6.z.object({
786
795
  /** Drawn only when this is false, or absent. */
787
796
  hideWhen: AppConditionSchema.optional()
788
797
  });
798
+ var ICON_SIZE_PX = { sm: 24, md: 48, lg: 72, xl: 96 };
799
+ var AppIconSchema = import_zod6.z.object({
800
+ type: import_zod6.z.literal("icon"),
801
+ value: AppBindingSchema,
802
+ size: import_zod6.z.enum(["sm", "md", "lg", "xl"]).default("md"),
803
+ align: AppAlignSchema.default("start"),
804
+ color: AppColorSchema.default("foreground"),
805
+ rules: import_zod6.z.array(AppStyleRuleSchema).max(4).optional(),
806
+ /** Drawn only when this is false, or absent. */
807
+ hideWhen: AppConditionSchema.optional()
808
+ });
789
809
  var AppLeafSchema = import_zod6.z.discriminatedUnion("type", [
790
810
  AppTextSchema,
791
811
  AppDialSchema,
@@ -793,13 +813,25 @@ var AppLeafSchema = import_zod6.z.discriminatedUnion("type", [
793
813
  AppBarSchema,
794
814
  AppStatusSchema,
795
815
  AppSpriteSchema,
796
- AppImageSchema
816
+ AppImageSchema,
817
+ AppIconSchema
797
818
  ]);
798
819
  var AppGroupSchema = import_zod6.z.object({
799
820
  type: import_zod6.z.literal("group"),
800
821
  direction: import_zod6.z.enum(["row", "stack"]),
801
822
  gap: import_zod6.z.number().int().min(0).max(64).default(4),
802
823
  align: AppAlignSchema.default("start"),
824
+ /**
825
+ * A row whose children take their own width, `gap` apart, placed together
826
+ * at the row's `align` — "68°" with its icon right beside it, "H 68° L 56°"
827
+ * as one line. Without it a row splits into equal cells, which put a short
828
+ * temperature and its icon half a screen apart. Text is as wide as the
829
+ * board draws it (six pixels in eight, per character); bars, dials,
830
+ * sparklines and status lights have no width of their own and share what is
831
+ * left. Ignored by a stack, and by firmware older than 2026-10-17, which
832
+ * falls back to equal cells.
833
+ */
834
+ pack: import_zod6.z.boolean().optional(),
803
835
  children: import_zod6.z.array(AppLeafSchema).min(1).max(8)
804
836
  });
805
837
  var AppBlockSchema = import_zod6.z.union([AppLeafSchema, AppGroupSchema]);
@@ -816,6 +848,23 @@ var AppDocumentSchema = import_zod6.z.object({
816
848
  author: import_zod6.z.string().max(32).optional(),
817
849
  screen: AppScreenSizeSchema.default("320x240"),
818
850
  background: AppColorSchema.default("background"),
851
+ /**
852
+ * Where the blocks sit on the screen as a whole: from the top, or in the
853
+ * middle with the space shared above and below. A document taller than the
854
+ * screen starts at the top either way, so centring never pushes the first
855
+ * block off the glass. Older firmware draws from the top.
856
+ */
857
+ valign: import_zod6.z.enum(["start", "center"]).optional(),
858
+ /**
859
+ * Where the blocks sit across the screen as a whole. `center` makes a column
860
+ * as wide as the widest block and centres that column, so left-aligned lines
861
+ * stay aligned with each other and the group sits in the middle — rather
862
+ * than every line hugging the left edge with the right half empty. Widths
863
+ * are the board's (see `pack`); a block with no width of its own, like an
864
+ * equal-celled row or a bar, fills the screen and leaves nothing to centre.
865
+ * Older firmware draws from the left.
866
+ */
867
+ halign: import_zod6.z.enum(["start", "center"]).optional(),
819
868
  /** Named so bindings can refer to them. */
820
869
  sources: import_zod6.z.record(AppSourceSchema).default({}),
821
870
  blocks: import_zod6.z.array(AppBlockSchema).min(1).max(12)
@@ -1175,6 +1224,73 @@ var DEVICE_TIMEZONES = [
1175
1224
  ];
1176
1225
  var DEVICE_TIMEZONE_FALLBACK = "UTC0";
1177
1226
 
1227
+ // src/apps/weather.ts
1228
+ var WEATHER_ICON_NAMES = ["sun", "partly", "cloud", "fog", "rain", "snow", "storm"];
1229
+ var WEATHER_CODES = [
1230
+ { upTo: 0, word: "Clear", icon: "sun" },
1231
+ { upTo: 1, word: "Mostly clear", icon: "sun" },
1232
+ { upTo: 2, word: "Partly cloudy", icon: "partly" },
1233
+ { upTo: 3, word: "Cloudy", icon: "cloud" },
1234
+ { upTo: 48, word: "Fog", icon: "fog" },
1235
+ { upTo: 57, word: "Drizzle", icon: "rain" },
1236
+ { upTo: 67, word: "Rain", icon: "rain" },
1237
+ { upTo: 77, word: "Snow", icon: "snow" },
1238
+ { upTo: 82, word: "Showers", icon: "rain" },
1239
+ { upTo: 86, word: "Snow showers", icon: "snow" },
1240
+ { upTo: 99, word: "Storm", icon: "storm" }
1241
+ ];
1242
+ var ICON_GRID = 48;
1243
+ var ICON_STROKE = 3;
1244
+ var WEATHER_ICONS = {
1245
+ sun: [
1246
+ [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],
1247
+ [37, 24, 43, 24],
1248
+ [33, 33, 37, 37],
1249
+ [24, 37, 24, 43],
1250
+ [15, 33, 11, 37],
1251
+ [11, 24, 5, 24],
1252
+ [15, 15, 11, 11],
1253
+ [24, 11, 24, 5],
1254
+ [33, 15, 37, 11]
1255
+ ],
1256
+ partly: [
1257
+ [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],
1258
+ [28, 16, 32, 16],
1259
+ [9, 24, 6, 27],
1260
+ [6, 16, 2, 16],
1261
+ [9, 8, 6, 5],
1262
+ [17, 5, 17, 1],
1263
+ [25, 8, 28, 5],
1264
+ [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]
1265
+ ],
1266
+ cloud: [
1267
+ [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]
1268
+ ],
1269
+ fog: [
1270
+ [8, 16, 40, 16],
1271
+ [12, 24, 36, 24],
1272
+ [8, 32, 40, 32]
1273
+ ],
1274
+ rain: [
1275
+ [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],
1276
+ [15, 36, 12, 43],
1277
+ [24, 36, 21, 43],
1278
+ [33, 36, 30, 43]
1279
+ ],
1280
+ snow: [
1281
+ [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],
1282
+ [14, 39, 14, 39],
1283
+ [24, 42, 24, 42],
1284
+ [34, 39, 34, 39],
1285
+ [19, 45, 19, 45],
1286
+ [29, 45, 29, 45]
1287
+ ],
1288
+ storm: [
1289
+ [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],
1290
+ [26, 33, 20, 41, 27, 41, 22, 47]
1291
+ ]
1292
+ };
1293
+
1178
1294
  // src/ai/tools.ts
1179
1295
  var import_zod10 = require("zod");
1180
1296
  var telemetryGraphParameters = import_zod10.z.object({
@@ -1458,7 +1574,8 @@ THE SHAPE
1458
1574
 
1459
1575
  BLOCKS \u2014 up to 12, drawn top to bottom. Each is one of:
1460
1576
 
1461
- { "type": "text", "value": V, "size": S, "align": A, "color": C, "suffix": "\xB0" }
1577
+ { "type": "text", "value": V, "size": S, "align": A, "color": C, "prefix": "H ", "suffix": "\xB0" }
1578
+ { "type": "icon", "value": V, "size": "sm"|"md"|"lg"|"xl", "align": A, "color": C }
1462
1579
  { "type": "dial", "value": V, "min": 0, "max": 100, "label": "CPU", "color": C }
1463
1580
  { "type": "bar", "value": V, "min": 0, "max": 100, "color": C }
1464
1581
  { "type": "sparkline", "series": V, "color": C }
@@ -1467,7 +1584,20 @@ BLOCKS \u2014 up to 12, drawn top to bottom. Each is one of:
1467
1584
  0110
1468
1585
  1100
1469
1586
  0011", "align": A }
1470
- { "type": "group", "direction": "row"|"stack", "gap": 8, "align": A, "children": [ ...leaves... ] }
1587
+ { "type": "group", "direction": "row"|"stack", "gap": 8, "align": A, "pack": true, "children": [ ...leaves... ] }
1588
+
1589
+ A row splits the width into equal cells. Add "pack": true and each child takes
1590
+ only its own width, "gap" apart \u2014 a number with its icon right beside it, or
1591
+ "H 68\xB0 L 56\xB0" as one line. Put "valign": "center" at the top level of the
1592
+ document to centre the blocks on the screen rather than start at the top, and
1593
+ "halign": "center" to centre them across it \u2014 the lines keep their own
1594
+ alignment inside a column as wide as the widest, and the column is centred.
1595
+
1596
+ AN ICON is the sky drawn in outline: "sun", "partly", "cloud", "fog", "rain",
1597
+ "snow" or "storm". Bind its value to a weather source's "icon" field so it
1598
+ follows the weather \u2014 { "source": "forecast", "field": "icon" } \u2014 or write one
1599
+ of those names as a literal. Sizes are 24, 48, 72 and 96 pixels square. Prefer
1600
+ it to drawing a weather sprite: it costs nothing and the board draws it crisply.
1471
1601
 
1472
1602
  DRAWING A SPRITE \u2014 you may, and here is the only form that works.
1473
1603
 
@@ -1549,7 +1679,7 @@ SOURCES \u2014 declare what the app reads, then bind to it by name:
1549
1679
 
1550
1680
  "forecast": { "kind": "weather", "latitude": 39.95, "longitude": -75.17,
1551
1681
  "units": "imperial", "refreshSeconds": 600 }
1552
- fields: temperature, condition, high, low
1682
+ fields: temperature, condition, icon, high, low
1553
1683
  "now": { "kind": "clock", "timezone": "America/New_York", "twentyFourHour": false }
1554
1684
  fields: time, date, weekday, hour (hour is 0-23, for rules about time of day)
1555
1685
  "until": { "kind": "countdown", "target": "2026-12-25", "label": "Christmas" }
@@ -1970,6 +2100,7 @@ var EXCLUDED_SOURCES = {
1970
2100
  AppDialSchema,
1971
2101
  AppDocumentSchema,
1972
2102
  AppGroupSchema,
2103
+ AppIconSchema,
1973
2104
  AppImageSchema,
1974
2105
  AppLeafSchema,
1975
2106
  AppOperandSchema,
@@ -2047,6 +2178,9 @@ var EXCLUDED_SOURCES = {
2047
2178
  FloraTelemetrySchema,
2048
2179
  GENESIS_LIBRARY_CONTEXT,
2049
2180
  GENESIS_VALID_COMPONENTS,
2181
+ ICON_GRID,
2182
+ ICON_SIZE_PX,
2183
+ ICON_STROKE,
2050
2184
  IMAGE_MAX_DRAWN,
2051
2185
  IMAGE_MAX_SCALE,
2052
2186
  IMPACT_FLAG_THRESHOLD,
@@ -2108,6 +2242,9 @@ var EXCLUDED_SOURCES = {
2108
2242
  TriggerSchema,
2109
2243
  UserSchema,
2110
2244
  VitalSourceSchema,
2245
+ WEATHER_CODES,
2246
+ WEATHER_ICONS,
2247
+ WEATHER_ICON_NAMES,
2111
2248
  WeatherAppConfigSchema,
2112
2249
  WorkflowSchema,
2113
2250
  architectureReferenceParameters,