@7365admin1/layer-common 4.97.1-staging.619 → 4.97.1-staging.621

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.
@@ -78,18 +78,23 @@
78
78
  </details>
79
79
 
80
80
  <details class="hero-can hero-can--fold">
81
- <summary class="hero-can__title">Parts wear, power schedule and lifts</summary>
81
+ <!-- Power schedule and lifts only when the brand sends them (VIGGO has neither: no lift protocol). -->
82
+ <summary class="hero-can__title">{{ has.has("power") || has.has("lifts") ? "Parts wear, power schedule and lifts" : "Parts wear" }}</summary>
82
83
  <div class="hero-sched__note">Parts wear (hours worked since last reset in {{ makerApp }})</div>
83
84
  <div v-if="!parts.length" class="hero-sched__empty">No parts reported.</div>
84
85
  <div v-for="p in parts" :key="p.key" class="hero-sched__row"><b>{{ p.part }}</b><span>{{ p.worked }}</span><span>{{ p.days }}</span></div>
85
- <div class="hero-sched__note mt-2">Timed switch on / off</div>
86
- <div v-if="!power.length" class="hero-sched__empty">No timed switch on / off.</div>
87
- <div v-for="p in power" :key="p.key" class="hero-sched__row">
88
- <b>{{ p.days }}</b><span>{{ p.time }}</span><span>{{ p.action }}{{ p.enabled ? "" : " · off" }}</span>
89
- </div>
90
- <div class="hero-sched__note mt-2">Lifts linked in {{ makerApp }}</div>
91
- <div v-if="!lifts.length" class="hero-sched__empty">No lifts linked to this robot's building.</div>
92
- <div v-for="l in lifts" :key="l.key" class="hero-sched__row"><b>{{ l.name }}</b><span>{{ l.state }}</span></div>
86
+ <template v-if="has.has('power')">
87
+ <div class="hero-sched__note mt-2">Timed switch on / off</div>
88
+ <div v-if="!power.length" class="hero-sched__empty">No timed switch on / off.</div>
89
+ <div v-for="p in power" :key="p.key" class="hero-sched__row">
90
+ <b>{{ p.days }}</b><span>{{ p.time }}</span><span>{{ p.action }}{{ p.enabled ? "" : " · off" }}</span>
91
+ </div>
92
+ </template>
93
+ <template v-if="has.has('lifts')">
94
+ <div class="hero-sched__note mt-2">Lifts linked in {{ makerApp }}</div>
95
+ <div v-if="!lifts.length" class="hero-sched__empty">No lifts linked to this robot's building.</div>
96
+ <div v-for="l in lifts" :key="l.key" class="hero-sched__row"><b>{{ l.name }}</b><span>{{ l.state }}</span></div>
97
+ </template>
93
98
  </details>
94
99
 
95
100
  <details v-if="has.has('mapVersions') || has.has('mapHistory') || has.has('mapLayers') || has.has('obstacles')" class="hero-can hero-can--fold">
@@ -80,7 +80,15 @@
80
80
  <!-- Above the fold: camera | map, with the commands under the map they act on. -->
81
81
  <div v-if="!noInterface" class="hero-detail__main" :class="{ 'hero-detail__main--single': !hasCamera }">
82
82
  <section v-if="hasCamera" class="hero-detail__cam" aria-label="Camera">
83
- <RobotLiveView v-if="caps?.liveVideo === true" ref="livePanel" panel :robot-id="robotId" :name="record?.name" :offline="!online" />
83
+ <RobotLiveView
84
+ v-if="caps?.liveVideo === true"
85
+ ref="livePanel"
86
+ panel
87
+ :robot-id="robotId"
88
+ :name="record?.name"
89
+ :offline="!online"
90
+ :camera-control="cmdOk === true && caps?.cameraControl === true && online"
91
+ />
84
92
  <p v-if="caps?.liveVideo === true && reportsPosition" class="hero-muted hero-detail__lag">{{ VIDEO_LAG_NOTE }}</p>
85
93
  <div v-if="canDrive" class="hero-detail__video">
86
94
  <v-btn variant="outlined" @click="driveOpen = true">Manual control</v-btn>
@@ -87,6 +87,7 @@
87
87
  </div>
88
88
  </div>
89
89
  </div>
90
+ <div v-if="modelsNote" class="hero-dialog__note">{{ modelsNote }}</div>
90
91
  <div class="hero-dialog__note">{{ credentialsNote(credentialsEncrypted) }} Capability: {{ note }}</div>
91
92
  <div v-if="error" class="hero-notice hero-notice--error" role="alert">{{ error }}</div>
92
93
  <div class="hero-dialog__actions">
@@ -111,6 +112,7 @@ import { credentialsNote } from "../../utils/robot-floorplan";
111
112
  import {
112
113
  credentialDiscoverable,
113
114
  credentialLabels,
115
+ credentialModelsNote,
114
116
  credentialTokenPlaceholder,
115
117
  credentialMissingMessage,
116
118
  credentialTokenDefault,
@@ -205,6 +207,7 @@ watch(
205
207
  },
206
208
  { immediate: true },
207
209
  );
210
+ const modelsNote = computed(() => credentialModelsNote(brand.value, brands.value));
208
211
  const note = computed(() => capabilityNote(options.value.find((o) => o.value === brand.value)?.capabilities, type.value));
209
212
 
210
213
  const siteOptions = computed(() => {
@@ -53,9 +53,15 @@
53
53
  </template>
54
54
  </div>
55
55
 
56
+ <div v-if="camError" class="hero-notice" role="alert">{{ camError }}</div>
56
57
  <div v-if="on || !panel" class="hero-dialog__actions">
57
58
  <v-btn v-if="error && !offline" variant="outlined" size="small" @click="restart">Retry</v-btn>
58
59
  <v-btn v-if="url && plays && !error" variant="outlined" size="small" @click="fullScreen">Full screen</v-btn>
60
+ <span v-if="cameraControl && !offline" class="hero-live__cam" role="group" aria-label="Camera">
61
+ <v-btn variant="outlined" size="small" :disabled="camBusy" @click="camera('center')">Centre camera</v-btn>
62
+ <v-btn variant="outlined" size="small" :disabled="camBusy" aria-label="Zoom in" @click="camera('zoom-in')">Zoom +</v-btn>
63
+ <v-btn variant="outlined" size="small" :disabled="camBusy" aria-label="Zoom out" @click="camera('zoom-out')">Zoom −</v-btn>
64
+ </span>
59
65
  <a v-if="url && !plays && kind !== 'rtmp'" class="hero-live__open" :href="url" target="_blank" rel="noopener noreferrer">Open in new tab</a>
60
66
  <span class="hero-head__spacer" />
61
67
  <v-btn v-if="!panel" variant="outlined" @click="emit('close')">Close</v-btn>
@@ -79,9 +85,26 @@ import {
79
85
  writeLivePref,
80
86
  } from "../../utils/robot-control";
81
87
 
82
- const props = defineProps<{ robotId: string; name?: string; panel?: boolean; offline?: boolean }>();
88
+ // `cameraControl`: the brand turns / zooms its camera (OneWay) AND this person may command the robot.
89
+ const props = defineProps<{ robotId: string; name?: string; panel?: boolean; offline?: boolean; cameraControl?: boolean }>();
83
90
  const emit = defineEmits<{ close: [] }>();
84
- const { getLiveVideo } = useRobots();
91
+ const { getLiveVideo, sendRobotCommand } = useRobots();
92
+
93
+ /** One camera step (centre / zoom), sent once per press; the robot cloud's refusal is shown as it said it. */
94
+ const camBusy = ref(false);
95
+ const camError = ref("");
96
+ async function camera(action: "center" | "zoom-in" | "zoom-out") {
97
+ if (camBusy.value) return;
98
+ camBusy.value = true;
99
+ camError.value = "";
100
+ try {
101
+ await sendRobotCommand(props.robotId, { kind: "camera", action });
102
+ } catch (e: any) {
103
+ camError.value = e?.data?.message || e?.message || "The camera did not move.";
104
+ } finally {
105
+ camBusy.value = false;
106
+ }
107
+ }
85
108
 
86
109
  const titleId = `hero-live-title-${Math.random().toString(36).slice(2, 8)}`;
87
110
  // "Always show live view": one choice per browser, like a dashboard layout. ponytail: localStorage, no table.
@@ -97,20 +97,20 @@
97
97
 
98
98
  <!-- Names, dock, floor, settings (Ounitech) -->
99
99
  <section v-if="caps.setupSettings === true" class="hero-setup__section" aria-label="Robot settings">
100
- <div class="hero-section__title">Names, dock and floor</div>
101
- <div class="hero-setup__form">
100
+ <div v-if="setup.robotName !== undefined || setup.sceneName !== undefined || setup.docked !== undefined" class="hero-section__title">Names, dock and floor</div>
101
+ <div v-if="setup.robotName !== undefined" class="hero-setup__form">
102
102
  <label>Name in the Ounitech app <input v-model="names.robot" class="hero-input" maxlength="40" /></label>
103
103
  <v-btn size="small" variant="outlined" :disabled="busy || !names.robot.trim() || names.robot.trim() === setup.robotName" @click="ask({ action: 'robot-name', name: names.robot.trim() })">Rename robot</v-btn>
104
104
  </div>
105
- <div class="hero-setup__form">
105
+ <div v-if="setup.sceneName !== undefined" class="hero-setup__form">
106
106
  <label>Ounitech site name <input v-model="names.scene" class="hero-input" maxlength="40" /></label>
107
107
  <v-btn size="small" variant="outlined" :disabled="busy || !names.scene.trim() || names.scene.trim() === setup.sceneName" @click="ask({ action: 'scene-name', name: names.scene.trim() })">Rename site</v-btn>
108
108
  </div>
109
- <div v-if="currentMap" class="hero-setup__form">
109
+ <div v-if="currentMap && setup.robotName !== undefined" class="hero-setup__form">
110
110
  <label>Name of map shown ({{ currentMap.name }}) <input v-model="names.map" class="hero-input" maxlength="40" /></label>
111
111
  <v-btn size="small" variant="outlined" :disabled="busy || !names.map.trim() || names.map.trim() === currentMap.name" @click="ask({ action: 'map-name', mapId: currentMap.mapId, name: names.map.trim() }, { map: currentMap.name })">Rename map</v-btn>
112
112
  </div>
113
- <div class="hero-setup__form">
113
+ <div v-if="setup.docked !== undefined" class="hero-setup__form">
114
114
  <span>Dock: {{ setup.docked ? "the robot is on its dock and charging now." : "push the robot onto its dock (it must show Charging) to save the dock from here." }}</span>
115
115
  <v-btn size="small" variant="outlined" :disabled="busy || !setup.docked" @click="ask({ action: 'dock-here' })">Save dock where the robot is</v-btn>
116
116
  </div>
@@ -123,7 +123,8 @@
123
123
  </div>
124
124
 
125
125
  <div class="hero-section__title">Settings</div>
126
- <p class="hero-muted">Only settings we can name are listed. Safety sensors, the time zone and Wi-Fi stay in the Ounitech app. Speeds can only be lowered here.</p>
126
+ <p v-if="setup.settingsNote" class="hero-muted">{{ setup.settingsNote }}</p>
127
+ <p v-else class="hero-muted">Only settings we can name are listed. Safety sensors, the time zone and Wi-Fi stay in the Ounitech app. Speeds can only be lowered here.</p>
127
128
  <div v-if="setup.settings?.error" class="hero-notice hero-notice--error">{{ setup.settings.error }}</div>
128
129
  <div v-for="s in settings" :key="s.key" class="hero-sched__row hero-setup__row">
129
130
  <b>{{ s.label }}</b>
@@ -135,10 +136,10 @@
135
136
  </div>
136
137
  <v-btn v-if="settings.length" size="small" color="primary" variant="flat" :disabled="busy || !Object.keys(changedSettings).length" @click="ask({ action: 'settings', values: changedSettings })">Save settings</v-btn>
137
138
 
138
- <div class="hero-section__title">Parts replaced</div>
139
- <p class="hero-muted">After a brush, mop, filter or bag is replaced, reset its hours so the wear count starts again.</p>
139
+ <div v-if="setup.parts !== undefined" class="hero-section__title">Parts replaced</div>
140
+ <p v-if="setup.parts !== undefined" class="hero-muted">After a brush, mop, filter or bag is replaced, reset its hours so the wear count starts again.</p>
140
141
  <div v-if="setup.parts?.error" class="hero-notice hero-notice--error">{{ setup.parts.error }}</div>
141
- <div v-else-if="!parts.length" class="hero-sched__empty">The robot reports no parts.</div>
142
+ <div v-else-if="setup.parts !== undefined && !parts.length" class="hero-sched__empty">The robot reports no parts.</div>
142
143
  <div v-for="p in parts" :key="p.code" class="hero-sched__row hero-setup__row">
143
144
  <b>{{ p.part }}</b>
144
145
  <span>{{ p.hours != null ? `${p.hours} h` : "hours not reported" }}{{ p.days != null ? ` · ${p.days} days` : "" }}</span>
@@ -284,6 +284,7 @@ export default function useRobots() {
284
284
  | { kind: "area"; areas: string[]; cleanTimes?: number; modeFlag?: number; subModeFlag?: number; levelFlag?: number }
285
285
  | { kind: "spot"; points: Array<{ x: number; y: number }>; cleanTimes?: number; modeFlag?: number; subModeFlag?: number; levelFlag?: number }
286
286
  | { kind: "pause" | "resume" | "cancel" | "patrol-resume" }
287
+ | { kind: "camera"; action: "center" | "zoom-in" | "zoom-out" }
287
288
  | { kind: "navigate"; x: number; y: number; theta?: number }
288
289
  | { kind: "relocalize"; floorNo: number; x: number; y: number; theta: number },
289
290
  ) {
package/package.json CHANGED
@@ -2,7 +2,7 @@
2
2
  "name": "@7365admin1/layer-common",
3
3
  "license": "MIT",
4
4
  "type": "module",
5
- "version": "4.97.1-staging.619",
5
+ "version": "4.97.1-staging.621",
6
6
  "author": "7365admin1",
7
7
  "main": "./nuxt.config.ts",
8
8
  "//files": "What a consumer extending this layer actually loads. Without this npm ships the whole working tree - the changesets, the CI workflows, the render harness in tools/ and any scratch directory that happened to exist at publish time. Nuxt resolves a layer by directory, so every runtime directory below has to stay listed; adding a new top-level runtime directory means adding it here too.",
@@ -66,6 +66,8 @@ export function settingsDiff(loaded: Array<{ key: string; value: unknown }> | nu
66
66
  for (const s of loaded ?? []) {
67
67
  if (!(s.key in edited)) continue;
68
68
  const v = edited[s.key];
69
+ // An empty box is no change (a setting the robot does not report back starts empty).
70
+ if (v === null || v === undefined || v === "") continue;
69
71
  const want = typeof s.value === "boolean" ? v === true : Number(v);
70
72
  if (typeof want === "number" && !Number.isFinite(want)) continue;
71
73
  if (want !== s.value) out[s.key] = want;
@@ -43,6 +43,17 @@ export function credentialTokenPlaceholder(brand: unknown, saved: unknown): stri
43
43
  return brand === "viggo" && saved !== true ? "Type each robot's VIN, separated by commas" : null;
44
44
  }
45
45
 
46
+ /**
47
+ * The models a brand's connection covers, under Add robot (VIGGO 30 Oct: this
48
+ * API is the SC50, SC80 and V50 only; S100N and Mix1 use other interfaces).
49
+ * null = no line (every other brand, unchanged).
50
+ */
51
+ export function credentialModelsNote(brand: unknown, brands: Array<{ brand?: unknown; models?: Array<{ name?: unknown }> }> | null | undefined): string | null {
52
+ if (brand !== "viggo") return null;
53
+ const names = (brands ?? []).find((b) => b?.brand === brand)?.models?.map((m) => String(m?.name ?? "").replace(/^VIGGO\s+/i, "")).filter(Boolean) ?? [];
54
+ return names.length ? `Models: ${names.join(", ")} only (S100N and Mix1 use a different VIGGO connection).` : null;
55
+ }
56
+
46
57
  /** Brands whose one company credential lists its robots, so Add robot picks the serial (Find robots). */
47
58
  export function credentialDiscoverable(brand: unknown): boolean {
48
59
  return brand === "ounitech" || brand === "padbot" || brand === "oneway" || brand === "viggo";
@@ -57,17 +68,19 @@ export function credentialMissingMessage(labels: { key: string; token: string },
57
68
 
58
69
  /**
59
70
  * Discovered robots as picker options: "Lobby Q3 · OT-SN-A", marking ones this
60
- * client already added (disabled - one serial, one record) and offline ones.
71
+ * client already added (disabled - one serial, one record), a model this
72
+ * connection does not cover (disabled - VIGGO S100N / Mix1) and offline ones.
61
73
  */
62
74
  export function discoveredRobotOptions(
63
- items: Array<{ robotSn?: unknown; name?: unknown; online?: unknown; added?: unknown }> | null | undefined,
75
+ items: Array<{ robotSn?: unknown; name?: unknown; online?: unknown; added?: unknown; unsupported?: unknown }> | null | undefined,
64
76
  ): Array<{ value: string; label: string; disabled: boolean }> {
65
77
  return (items ?? [])
66
78
  .filter((r) => typeof r?.robotSn === "string" && r.robotSn)
67
79
  .map((r) => {
68
80
  const sn = String(r.robotSn);
69
81
  const name = typeof r.name === "string" && r.name.trim() ? `${r.name.trim()} · ${sn}` : sn;
70
- const tags = [r.added === true ? "already added" : "", r.online === false ? "offline" : ""].filter(Boolean);
71
- return { value: sn, label: tags.length ? `${name} (${tags.join(", ")})` : name, disabled: r.added === true };
82
+ const unsupported = typeof r.unsupported === "string" && r.unsupported !== "";
83
+ const tags = [r.added === true ? "already added" : "", unsupported ? "model not supported" : r.online === false ? "offline" : ""].filter(Boolean);
84
+ return { value: sn, label: tags.length ? `${name} (${tags.join(", ")})` : name, disabled: r.added === true || unsupported };
72
85
  });
73
86
  }
@@ -317,6 +317,7 @@ const COMMAND_NEEDS: Readonly<Record<string, string>> = {
317
317
  cancel: "pauseProcess",
318
318
  navigate: "navigateToPoint",
319
319
  relocalize: "relocalize",
320
+ // Not `camera` (cameraControl): a live-view step, not a job - it does not move the badge.
320
321
  };
321
322
 
322
323
  /** Telemetry a brand may declare - reporting only, never a command. */
@@ -461,7 +462,8 @@ export function visibleCommands(input: {
461
462
  const caps = input.capabilities ?? {};
462
463
  const patrol = input.type === "security" && caps.patrolControl === true;
463
464
  return COMMANDS.filter((c) => {
464
- if (c.kind === "patrol-resume") return patrol && (input.mode === "PAUSED" || (input.resumable === true && input.mode !== "WORKING" && input.mode !== "IN_TRANSIT"));
465
+ // A brand with its own Resume (OneWay §4.14) carries on from where it paused: no second "Resume patrol" then.
466
+ if (c.kind === "patrol-resume") return patrol && ((input.mode === "PAUSED" && caps.pauseResume !== true) || (input.resumable === true && input.mode !== "WORKING" && input.mode !== "IN_TRANSIT" && input.mode !== "PAUSED"));
465
467
  if (caps[COMMAND_NEEDS[c.kind]!] !== true) return false;
466
468
  if (c.kind === "pause" && input.mode !== "WORKING") return false;
467
469
  if (c.kind === "resume" && input.mode !== "PAUSED") return false;
@@ -1721,6 +1723,7 @@ export function robotAbilities(input: {
1721
1723
  on("relocalize") && "can be told where it is",
1722
1724
  on("sendToDock") && "returns to its charger",
1723
1725
  on("liveVideo") && "streams live video",
1726
+ on("cameraControl") && "centres and zooms its camera",
1724
1727
  on("manualDrive") && "can be driven by hand",
1725
1728
  on("emergencyStop") && "stops at once with Emergency stop",
1726
1729
  ].filter(Boolean) as string[];