@camstack/types 1.2.541 → 1.2.542

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.
@@ -5,7 +5,7 @@ export { HERO_CAP_CONTRIBUTIONS, type HeroContribution, } from './hero-contribut
5
5
  export type { HeroContext, HeroFragment, StateReading, StateSource, } from './hero-fragment.js';
6
6
  export { HERO_LAYOUT_BY_TYPE, HERO_LAYOUT_DEFAULT, resolveHeroLayout, type HeroLayout, } from './hero-layout.js';
7
7
  export { allHeroLooks, HERO_LOOK_BY_ROLE, HERO_LOOK_BY_TYPE, HERO_LOOK_DEFAULT, resolveHeroLook, } from './hero-look.js';
8
- export { HERO_ROW_IDS, HERO_ROW_LABELS, heroArgsWithValue, type HeroAction, type HeroArgs, type HeroBackground, type HeroBadge, type HeroCall, type HeroConfirm, type HeroConsumableItem, type HeroConsumablesSlot, type HeroConsumptionSlot, type HeroControl, type HeroDetail, type HeroFact, type HeroSideTile, type HeroSideTiles, type HeroModel, type HeroOwnPowerSlot, type HeroPowerSupplySlot, type HeroProvenance, type HeroRemoteSlot, type HeroRow, type HeroRowId, type HeroTimedRunSlot, } from './hero-model.js';
8
+ export { HERO_ROW_IDS, HERO_ROW_LABELS, heroArgsWithValue, type HeroAction, type HeroArgs, type HeroBackground, type HeroBadge, type HeroCall, type HeroConfirm, type HeroConsumableItem, type HeroConsumablesSlot, type HeroConsumptionSlot, type HeroControl, type HeroDetail, type HeroFact, type HeroSideTile, type HeroSideTiles, type HeroModel, type HeroOwnPowerSlot, type HeroPowerSupplySlot, type HeroProvenance, type HeroRemoteSlot, REMOTE_OPEN_ACTION_ID, type HeroRow, type HeroRowId, type HeroTimedRunSlot, } from './hero-model.js';
9
9
  export { HERO_ANIMATIONS, HERO_BACKGROUNDS, HERO_STATES, HERO_TONES, type HeroAnimation, type HeroBackgroundToken, type HeroLook, type HeroState, type HeroTone, type StateLook, } from './hero-state.js';
10
10
  export { HERO_SCENE_BY_ROLE, HERO_SCENE_BY_TYPE, HERO_SCENES, HERO_SCENE_MODES, resolveHeroSceneId, type HeroScene, type HeroSceneId, type HeroSceneMode, } from './hero-scene.js';
11
11
  export { HeroRowModelSchema, projectDeviceRow, type HeroRowModel, } from './hero-row.js';
package/dist/index.js CHANGED
@@ -56795,13 +56795,11 @@ var HeroConfirmSchema = zod.z.enum([
56795
56795
  "press"
56796
56796
  ]);
56797
56797
  var HeroActionSchema = zod.z.object({
56798
- /** Unique within the model; the `gated` list and the specs name it. */
56799
56798
  id: zod.z.string(),
56800
56799
  label: HeroTextSchema,
56801
56800
  icon: IconKeySchema,
56802
56801
  call: HeroCallSchema,
56803
56802
  emphasis: zod.z.enum(["primary", "normal"]),
56804
- /** Ask before running it. */
56805
56803
  confirm: HeroConfirmSchema.nullable()
56806
56804
  });
56807
56805
  var HeroControlSchema = zod.z.discriminatedUnion("kind", [
@@ -56897,9 +56895,18 @@ var HeroBadgeSchema = zod.z.object({
56897
56895
  value: zod.z.number().nullable(),
56898
56896
  label: HeroTextSchema
56899
56897
  });
56900
- var HeroRemoteSlotSchema = zod.z.object({
56901
- /** Saved commands; `null` = not known yet (the button still shows). */
56902
- commands: zod.z.number().int().nullable() });
56898
+ /** The id of the action a row recognises as "open the device's remote". */
56899
+ var REMOTE_OPEN_ACTION_ID = "remote.open";
56900
+ var HeroRemoteSlotSchema = zod.z.object({
56901
+ /** Saved commands; `null` = not known yet (the button still shows). */
56902
+ commands: zod.z.number().int().nullable(),
56903
+ /**
56904
+ * The control a list row draws as the "open the remote" icon. Recognised by its id
56905
+ * ({@link REMOTE_OPEN_ACTION_ID}); it changes no state, so a client opens the remote
56906
+ * instead of running `call`. Absent on a model from an older server.
56907
+ */
56908
+ open: HeroActionSchema.optional()
56909
+ });
56903
56910
  var HeroConsumableItemSchema = zod.z.object({
56904
56911
  key: zod.z.string(),
56905
56912
  label: zod.z.string(),
@@ -57070,6 +57077,8 @@ var HeroModelSchema = zod.z.object({
57070
57077
  * the FIRST row that has any (a later row's control is never promoted). When
57071
57078
  * the model lists that part in `gated`, the row has no inline control: the
57072
57079
  * projection never falls through to another control the caller could use.
57080
+ * - a climate or thermostat row's primary is its `climate.mode` control (no power
57081
+ * toggle: "off" is a mode); when the model gates it the rule above applies as before;
57073
57082
  * - a timed run, when the model carries the slot, sits beside that primary:
57074
57083
  * Run while idle, Stop while armed. Gating the slot hides the control.
57075
57084
  * - the status line is the head (what plays, else the state) plus at most
@@ -57077,6 +57086,13 @@ var HeroModelSchema = zod.z.object({
57077
57086
  * time left on an armed timed run;
57078
57087
  * - the trailing fact is the first of power, battery, consumables.
57079
57088
  *
57089
+ * - `extras` are the further inline controls of the types that carry more than one
57090
+ * ({@link ROW_EXTRAS_BY_TYPE}): climate setpoint, a robot's return to base,
57091
+ * a player's volume and remote. Each is a control the model already has, named by id,
57092
+ * in that order and at most {@link ROW_EXTRAS_MAX}; one the model lacks, or lists in
57093
+ * `gated`, is absent, and the one `primary` already is never repeats. Empty = the
57094
+ * row of an older server: `primary` alone.
57095
+ *
57080
57096
  * `projectDeviceRow` is pure and computes nothing: it selects from a
57081
57097
  * {@link HeroModel}. A row that needed a value the hero lacks would mean the
57082
57098
  * model is missing it, so the fix goes in the model.
@@ -57108,6 +57124,12 @@ var HeroRowModelSchema = zod.z.object({
57108
57124
  * while armed. `null` when there is no slot, or the caller may not act.
57109
57125
  */
57110
57126
  timedRun: HeroRowTimedRunSchema.nullable(),
57127
+ /**
57128
+ * The further inline controls after `primary`, in order (see the header). The remote
57129
+ * is an `action` with id `remote.open`: the client opens the remote, it does not run
57130
+ * the call. Absent or empty = `primary` alone.
57131
+ */
57132
+ extras: zod.z.array(HeroControlSchema).max(2).optional(),
57111
57133
  trailing: HeroFactSchema.nullable()
57112
57134
  });
57113
57135
  /** The trailing fact, in order of preference. */
@@ -57123,7 +57145,20 @@ function trailingOf(facts) {
57123
57145
  }
57124
57146
  return null;
57125
57147
  }
57148
+ /**
57149
+ * A type whose primary is a named control, not its power: a climate row is the mode
57150
+ * (which carries "off") and the setpoint, with no power toggle.
57151
+ */
57152
+ var ROW_PRIMARY_BY_TYPE = {
57153
+ [require_composed_stable_id.DeviceType.Climate]: "climate.mode",
57154
+ [require_composed_stable_id.DeviceType.Thermostat]: "climate.mode"
57155
+ };
57126
57156
  function primaryOf(model) {
57157
+ const named = ROW_PRIMARY_BY_TYPE[model.type];
57158
+ if (named !== void 0) {
57159
+ const found = extraOf(model, named);
57160
+ if (found !== null) return found;
57161
+ }
57127
57162
  const power = model.ownPower;
57128
57163
  if (power !== null) {
57129
57164
  if (model.gated.includes("own-power")) return null;
@@ -57143,6 +57178,43 @@ function primaryOf(model) {
57143
57178
  }
57144
57179
  return null;
57145
57180
  }
57181
+ /**
57182
+ * The extras of a type, by control id, in the order they are drawn. The ids are the
57183
+ * model's own: a `remote.open` is read from the model's remote slot, every other
57184
+ * from the rows. A type not listed has no extras.
57185
+ */
57186
+ var ROW_EXTRAS_BY_TYPE = {
57187
+ [require_composed_stable_id.DeviceType.Climate]: ["climate.target"],
57188
+ [require_composed_stable_id.DeviceType.Thermostat]: ["climate.target"],
57189
+ [require_composed_stable_id.DeviceType.Vacuum]: ["vacuum.base"],
57190
+ [require_composed_stable_id.DeviceType.LawnMower]: ["mower.dock"],
57191
+ [require_composed_stable_id.DeviceType.MediaPlayer]: ["volume.level", REMOTE_OPEN_ACTION_ID]
57192
+ };
57193
+ var controlId = (c) => c.kind === "action" ? c.action.id : c.id;
57194
+ function extraOf(model, id) {
57195
+ if (id === "remote.open") {
57196
+ const open = model.remote?.open;
57197
+ if (open === void 0 || model.gated.includes("remote")) return null;
57198
+ return {
57199
+ kind: "action",
57200
+ action: open
57201
+ };
57202
+ }
57203
+ for (const row of model.rows) {
57204
+ if (model.gated.includes(row.id)) continue;
57205
+ const found = row.controls.find((c) => controlId(c) === id);
57206
+ if (found !== void 0) return found;
57207
+ }
57208
+ return null;
57209
+ }
57210
+ function extrasOf(model, primary) {
57211
+ const ids = ROW_EXTRAS_BY_TYPE[model.type] ?? [];
57212
+ const taken = primary === null ? null : controlId(primary);
57213
+ return ids.filter((id) => id !== taken).flatMap((id) => {
57214
+ const found = extraOf(model, id);
57215
+ return found === null ? [] : [found];
57216
+ }).slice(0, 2);
57217
+ }
57146
57218
  function statusLineOf(model, trailing) {
57147
57219
  const head = model.rows.find((r) => r.id === "now-playing")?.status ?? null ?? model.title;
57148
57220
  const rest = model.facts.filter((f) => f !== trailing).map((f) => f.text).slice(0, 3);
@@ -57171,6 +57243,7 @@ function timedRunOf(model) {
57171
57243
  }
57172
57244
  function projectDeviceRow(model) {
57173
57245
  const trailing = trailingOf(model.facts);
57246
+ const primary = primaryOf(model);
57174
57247
  return {
57175
57248
  deviceId: model.deviceId,
57176
57249
  name: model.name,
@@ -57180,8 +57253,9 @@ function projectDeviceRow(model) {
57180
57253
  look: model.look,
57181
57254
  scene: model.scene,
57182
57255
  statusLine: statusLineOf(model, trailing),
57183
- primary: primaryOf(model),
57256
+ primary,
57184
57257
  timedRun: timedRunOf(model),
57258
+ extras: extrasOf(model, primary),
57185
57259
  trailing
57186
57260
  };
57187
57261
  }
@@ -104217,7 +104291,10 @@ var powerSourceContribution = contribution("power-source", PowerSourceStateSchem
104217
104291
  /** The remote cap has no status: the model's input carries how many commands it holds. */
104218
104292
  var remoteContribution = {
104219
104293
  cap: "remote",
104220
- contribute: (_slice, ctx) => ctx.remoteCommands === 0 ? {} : { remote: { commands: ctx.remoteCommands } }
104294
+ contribute: (_slice, ctx) => ctx.remoteCommands === 0 ? {} : { remote: {
104295
+ commands: ctx.remoteCommands,
104296
+ open: action(REMOTE_OPEN_ACTION_ID, require_sleep.t("Remote", "Telecomando"), "gamepad-2", "remote", "open")
104297
+ } }
104221
104298
  };
104222
104299
  var ATTENTION_STATUSES = [
104223
104300
  "low",
@@ -137377,6 +137454,7 @@ exports.REMOTE_GROUP_FRAMES = REMOTE_GROUP_FRAMES;
137377
137454
  exports.REMOTE_KNOWN_ROLES = REMOTE_KNOWN_ROLES;
137378
137455
  exports.REMOTE_MAX_REPEAT = REMOTE_MAX_REPEAT;
137379
137456
  exports.REMOTE_MEDIA_COMMANDS = REMOTE_MEDIA_COMMANDS;
137457
+ exports.REMOTE_OPEN_ACTION_ID = REMOTE_OPEN_ACTION_ID;
137380
137458
  exports.REMOTE_REFUSAL_REASONS = REMOTE_REFUSAL_REASONS;
137381
137459
  exports.REMOTE_ROLE_VOCABULARY = REMOTE_ROLE_VOCABULARY;
137382
137460
  exports.REMOTE_SOURCE_KINDS = REMOTE_SOURCE_KINDS;