@rainbow-robotics/preview-host 0.1.2-dev.46 → 0.1.2-dev.49
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/README.md +104 -98
- package/dist/assets/{AmrCapabilityControl.DEC-3ZAW.js → AmrCapabilityControl.V6oiR3_5.js} +1 -1
- package/dist/assets/{__federation_expose_App.CEGQzKIi.js → __federation_expose_App.rWoLmFNr.js} +197 -205
- package/dist/assets/{cssMode.DbVSjsLx.js → cssMode.CiNmHTFv.js} +1 -1
- package/dist/assets/{freemarker2._fexy6pR.js → freemarker2.B7r_V28s.js} +1 -1
- package/dist/assets/{handlebars.CmIcCyqS.js → handlebars.3_K0j9Im.js} +1 -1
- package/dist/assets/{html.DRR6RUxW.js → html.DKWAB1mf.js} +1 -1
- package/dist/assets/{htmlMode.CoHatVoq.js → htmlMode.CZ2KmtuG.js} +1 -1
- package/dist/assets/{index.B_7c3sM4.js → index.Cn3FZx5U.js} +1 -1
- package/dist/assets/{index.FZ9eMVCs.js → index.DhDDHapK.js} +1 -1
- package/dist/assets/{javascript.pVVbdZDk.js → javascript.DE-dWGjy.js} +1 -1
- package/dist/assets/{jsonMode.DgG2kYVi.js → jsonMode.BoVz1jWE.js} +1 -1
- package/dist/assets/{liquid.DvX7AUBT.js → liquid.UXJC-JKJ.js} +1 -1
- package/dist/assets/{lspLanguageFeatures.Br1RlGKu.js → lspLanguageFeatures.BbVTGB6M.js} +1 -1
- package/dist/assets/{mdx.BXnm0chj.js → mdx.B7jHdcUF.js} +1 -1
- package/dist/assets/{python.C2Xd8iVA.js → python.DqZWylvN.js} +1 -1
- package/dist/assets/{razor.D0mLj0p_.js → razor.Dwj_e3ac.js} +1 -1
- package/dist/assets/remoteEntry.js +1 -1
- package/dist/assets/{tsMode.Dqbl0l0j.js → tsMode.DLDaOd78.js} +1 -1
- package/dist/assets/{typescript.Buj1nTDy.js → typescript.B4V2Badx.js} +1 -1
- package/dist/assets/{xml.DHpVTYfo.js → xml.BpqV0vd6.js} +1 -1
- package/dist/assets/{yaml.Dz87BMLn.js → yaml.BlIeL5XV.js} +1 -1
- package/dist/index.html +3 -3
- package/package.json +2 -2
package/README.md
CHANGED
|
@@ -1,62 +1,62 @@
|
|
|
1
|
-
# `@
|
|
1
|
+
# `@rainbow-robotics/preview-host`
|
|
2
2
|
|
|
3
|
-
`@
|
|
3
|
+
`@rainbow-robotics/preview-host` is a standalone **mini-Muscat (nexus) shell** for previewing Muscat plugins without a robot or backend.
|
|
4
4
|
|
|
5
|
-
`apps/web/nexus
|
|
5
|
+
It's built by building `apps/web/nexus` in `plugin-preview` mode.
|
|
6
6
|
|
|
7
|
-
|
|
7
|
+
This preview shell provides a UI as close as possible to the real Muscat environment.
|
|
8
8
|
|
|
9
|
-
*
|
|
10
|
-
*
|
|
11
|
-
*
|
|
12
|
-
*
|
|
13
|
-
*
|
|
9
|
+
* Real Header
|
|
10
|
+
* Real LNB
|
|
11
|
+
* Real panel structure
|
|
12
|
+
* Real `rb-components`
|
|
13
|
+
* Plugin manifest-based loading
|
|
14
14
|
|
|
15
|
-
|
|
15
|
+
Robot- and backend-related dependencies, on the other hand, are all mocked.
|
|
16
16
|
|
|
17
|
-
*
|
|
18
|
-
*
|
|
19
|
-
* API
|
|
20
|
-
*
|
|
21
|
-
* RB
|
|
17
|
+
* No robot connection required
|
|
18
|
+
* No backend server required
|
|
19
|
+
* API-failure toasts hidden
|
|
20
|
+
* Query retry disabled
|
|
21
|
+
* RB static resources served locally
|
|
22
22
|
|
|
23
|
-
|
|
23
|
+
This package is used by `muscat-plugin-kit`'s:
|
|
24
24
|
|
|
25
25
|
```bash
|
|
26
26
|
muscat-pk dev:ui
|
|
27
27
|
```
|
|
28
28
|
|
|
29
|
-
|
|
29
|
+
This lets external plugin developers preview their plugin in a Muscat-like environment without the `web-rainbow-ui` monorepo source.
|
|
30
30
|
|
|
31
|
-
##
|
|
31
|
+
## Build
|
|
32
32
|
|
|
33
33
|
```bash
|
|
34
34
|
node build.mjs
|
|
35
35
|
```
|
|
36
36
|
|
|
37
|
-
`nexus
|
|
37
|
+
Builds `nexus` in `plugin-preview` mode, then assembles the files needed to run into the `./dist` directory.
|
|
38
38
|
|
|
39
|
-
|
|
39
|
+
If `nexus` has already been built, you can use:
|
|
40
40
|
|
|
41
41
|
```bash
|
|
42
42
|
node build.mjs --skip-build
|
|
43
43
|
```
|
|
44
44
|
|
|
45
|
-
|
|
45
|
+
This skips rebuilding `nexus` and only reassembles `./dist` from the existing build output.
|
|
46
46
|
|
|
47
|
-
|
|
47
|
+
The generated `dist/` directory is excluded from Git.
|
|
48
48
|
|
|
49
|
-
`dist
|
|
49
|
+
`dist/` is structured to be runnable standalone.
|
|
50
50
|
|
|
51
|
-
|
|
51
|
+
Main contents:
|
|
52
52
|
|
|
53
|
-
* nexus
|
|
54
|
-
* RB
|
|
55
|
-
*
|
|
56
|
-
*
|
|
57
|
-
*
|
|
53
|
+
* nexus bundle
|
|
54
|
+
* RB static resources
|
|
55
|
+
* images
|
|
56
|
+
* fonts
|
|
57
|
+
* other runtime resources
|
|
58
58
|
|
|
59
|
-
|
|
59
|
+
Static resources are served at the same paths used at real runtime.
|
|
60
60
|
|
|
61
61
|
```text
|
|
62
62
|
/imgs
|
|
@@ -64,23 +64,23 @@ node build.mjs --skip-build
|
|
|
64
64
|
...
|
|
65
65
|
```
|
|
66
66
|
|
|
67
|
-
##
|
|
67
|
+
## Run
|
|
68
68
|
|
|
69
69
|
```bash
|
|
70
70
|
rb-preview-host --plugin <built-plugin-dir> [--port 4180] [--dist <dir>]
|
|
71
71
|
```
|
|
72
72
|
|
|
73
|
-
###
|
|
73
|
+
### Options
|
|
74
74
|
|
|
75
|
-
`--plugin
|
|
75
|
+
`--plugin` points to a plugin build directory produced by `muscat-pk build`.
|
|
76
76
|
|
|
77
77
|
```bash
|
|
78
78
|
rb-preview-host --plugin ./dist/plugin
|
|
79
79
|
```
|
|
80
80
|
|
|
81
|
-
`--port
|
|
81
|
+
`--port` sets the port preview-host runs on.
|
|
82
82
|
|
|
83
|
-
|
|
83
|
+
Defaults to `4180`.
|
|
84
84
|
|
|
85
85
|
```bash
|
|
86
86
|
rb-preview-host \
|
|
@@ -88,7 +88,7 @@ rb-preview-host \
|
|
|
88
88
|
--port 4180
|
|
89
89
|
```
|
|
90
90
|
|
|
91
|
-
`--dist
|
|
91
|
+
`--dist` overrides the preview-host static bundle directory.
|
|
92
92
|
|
|
93
93
|
```bash
|
|
94
94
|
rb-preview-host \
|
|
@@ -96,153 +96,159 @@ rb-preview-host \
|
|
|
96
96
|
--dist ./preview-host-dist
|
|
97
97
|
```
|
|
98
98
|
|
|
99
|
-
|
|
99
|
+
The following options are also supported (all optional — `muscat-pk dev` fills them in internally).
|
|
100
100
|
|
|
101
|
-
`--
|
|
101
|
+
* `--socket-url`: the Socket.IO URL the plugin connects to (`window.__RB_PLUGIN_PREVIEW_SOCKET_URL__`)
|
|
102
|
+
* `--robot-host`: robot host override (`window.__RB_ROBOT_HOST__`)
|
|
103
|
+
* `--dev-server-url`: the plugin's own Vite dev server URL (`window.__RB_PLUGIN_DEV_SERVER_URL__`) — used when mounting a `dev` UI entry directly
|
|
102
104
|
|
|
103
|
-
|
|
105
|
+
## Plugin build directory requirements
|
|
106
|
+
|
|
107
|
+
The directory passed to `--plugin` must be an output directory from `muscat-pk build`.
|
|
108
|
+
|
|
109
|
+
It must contain:
|
|
104
110
|
|
|
105
111
|
```text
|
|
106
112
|
manifest.json
|
|
107
|
-
|
|
108
|
-
content.js
|
|
113
|
+
<ui-entry>.js (e.g. content.js — one is generated per manifest contributes[].ui entry)
|
|
109
114
|
assets/
|
|
110
115
|
```
|
|
111
116
|
|
|
112
|
-
`
|
|
117
|
+
The host mounts `<ui-entry>.js` by importing it directly as a plain ESM module — no `sandbox.html`/iframe is involved.
|
|
118
|
+
|
|
119
|
+
`assets/` is only present if the plugin uses its own static resources.
|
|
113
120
|
|
|
114
|
-
|
|
121
|
+
The plugin directory you specify is mounted in preview host at:
|
|
115
122
|
|
|
116
123
|
```text
|
|
117
124
|
/plugin-dev/
|
|
118
125
|
```
|
|
119
126
|
|
|
120
|
-
|
|
127
|
+
The preview shell resolves the plugin and static-resource locations through the global variables `serve.mjs` injects.
|
|
121
128
|
|
|
122
|
-
##
|
|
129
|
+
## Global variables
|
|
123
130
|
|
|
124
131
|
### `window.__RB_PLUGIN_PREVIEW_HOST__`
|
|
125
132
|
|
|
126
|
-
preview-host
|
|
133
|
+
Activates preview-host mode.
|
|
127
134
|
|
|
128
135
|
```ts
|
|
129
136
|
window.__RB_PLUGIN_PREVIEW_HOST__ = true;
|
|
130
137
|
```
|
|
131
138
|
|
|
132
|
-
|
|
139
|
+
When set, nexus runs against a mock environment instead of the real backend.
|
|
133
140
|
|
|
134
|
-
|
|
141
|
+
Typical effects:
|
|
135
142
|
|
|
136
|
-
*
|
|
137
|
-
*
|
|
138
|
-
* API
|
|
139
|
-
* query
|
|
143
|
+
* Mocked robot connection
|
|
144
|
+
* Mocked backend API
|
|
145
|
+
* Suppressed API-failure toasts
|
|
146
|
+
* Disabled query retry
|
|
140
147
|
|
|
141
148
|
### `window.__RB_PLUGIN_PREVIEW_BASE__`
|
|
142
149
|
|
|
143
|
-
|
|
150
|
+
The base URL the plugin is served from.
|
|
144
151
|
|
|
145
|
-
|
|
152
|
+
Defaults to:
|
|
146
153
|
|
|
147
154
|
```text
|
|
148
155
|
/plugin-dev
|
|
149
156
|
```
|
|
150
157
|
|
|
151
|
-
|
|
158
|
+
Example:
|
|
152
159
|
|
|
153
160
|
```ts
|
|
154
161
|
window.__RB_PLUGIN_PREVIEW_BASE__ = "/plugin-dev";
|
|
155
162
|
```
|
|
156
163
|
|
|
157
|
-
|
|
164
|
+
The preview shell reads the following files relative to this path:
|
|
158
165
|
|
|
159
166
|
```text
|
|
160
167
|
/plugin-dev/manifest.json
|
|
161
|
-
/plugin-dev
|
|
162
|
-
/plugin-dev/content.js
|
|
168
|
+
/plugin-dev/<ui-entry>.js
|
|
163
169
|
/plugin-dev/assets/*
|
|
164
170
|
```
|
|
165
171
|
|
|
166
172
|
### `window.__RB_ASSETS_BASE_URL__`
|
|
167
173
|
|
|
168
|
-
RB
|
|
174
|
+
The origin RB static resources are served from.
|
|
169
175
|
|
|
170
|
-
|
|
176
|
+
Example:
|
|
171
177
|
|
|
172
178
|
```ts
|
|
173
179
|
window.__RB_ASSETS_BASE_URL__ = "http://localhost:4180";
|
|
174
180
|
```
|
|
175
181
|
|
|
176
|
-
|
|
182
|
+
This lets preview host load the static resources used by nexus and `rb-components`.
|
|
177
183
|
|
|
178
|
-
|
|
184
|
+
Typical resource paths:
|
|
179
185
|
|
|
180
186
|
```text
|
|
181
187
|
/imgs
|
|
182
188
|
/fonts
|
|
183
189
|
```
|
|
184
190
|
|
|
185
|
-
##
|
|
191
|
+
## Global variable summary
|
|
186
192
|
|
|
187
|
-
|
|
|
193
|
+
| Global variable | Meaning |
|
|
188
194
|
| ----------------------------------- | --------------------------------------- |
|
|
189
|
-
| `window.__RB_PLUGIN_PREVIEW_HOST__` | preview-host
|
|
190
|
-
| `window.__RB_PLUGIN_PREVIEW_BASE__` |
|
|
191
|
-
| `window.__RB_ASSETS_BASE_URL__` | RB
|
|
195
|
+
| `window.__RB_PLUGIN_PREVIEW_HOST__` | Activates preview-host mode and mocks backend dependencies |
|
|
196
|
+
| `window.__RB_PLUGIN_PREVIEW_BASE__` | Base URL the plugin is mounted at. Defaults to `/plugin-dev` |
|
|
197
|
+
| `window.__RB_ASSETS_BASE_URL__` | Origin serving RB images, fonts, and other static resources |
|
|
192
198
|
|
|
193
|
-
##
|
|
199
|
+
## Relationship to dev mode
|
|
194
200
|
|
|
195
|
-
`muscat-pk dev:ui
|
|
201
|
+
`muscat-pk dev:ui` runs nexus's Vite dev server directly.
|
|
196
202
|
|
|
197
203
|
```bash
|
|
198
204
|
vite --mode plugin-preview
|
|
199
205
|
```
|
|
200
206
|
|
|
201
|
-
|
|
207
|
+
This is a dev-mode preview-host runtime with HMR enabled.
|
|
202
208
|
|
|
203
|
-
|
|
209
|
+
In other words, `muscat-pk dev:ui` and `@rainbow-robotics/preview-host` aren't separate implementations — they're the same preview-host runtime used in two different forms.
|
|
204
210
|
|
|
205
211
|
### `muscat-pk dev:ui`
|
|
206
212
|
|
|
207
|
-
|
|
213
|
+
Runs the Vite dev server directly against the monorepo source.
|
|
208
214
|
|
|
209
|
-
|
|
215
|
+
Characteristics:
|
|
210
216
|
|
|
211
|
-
* Vite
|
|
212
|
-
* HMR
|
|
213
|
-
*
|
|
214
|
-
*
|
|
217
|
+
* Vite-based dev server
|
|
218
|
+
* HMR support
|
|
219
|
+
* Source changes reflected immediately
|
|
220
|
+
* Suited for development
|
|
215
221
|
|
|
216
|
-
### `@
|
|
222
|
+
### `@rainbow-robotics/preview-host`
|
|
217
223
|
|
|
218
|
-
|
|
224
|
+
The same runtime packaged as a static bundle for distribution.
|
|
219
225
|
|
|
220
|
-
|
|
226
|
+
Characteristics:
|
|
221
227
|
|
|
222
|
-
*
|
|
223
|
-
*
|
|
224
|
-
*
|
|
225
|
-
*
|
|
228
|
+
* No monorepo source required
|
|
229
|
+
* Uses a prebuilt nexus bundle
|
|
230
|
+
* Runs standalone
|
|
231
|
+
* Distributable to external plugin developers
|
|
226
232
|
|
|
227
|
-
|
|
233
|
+
The overall relationship:
|
|
228
234
|
|
|
229
235
|
```text
|
|
230
236
|
apps/web/nexus
|
|
231
|
-
└─ plugin-preview
|
|
237
|
+
└─ plugin-preview mode
|
|
232
238
|
├─ muscat-pk dev:ui
|
|
233
|
-
│ └─ Vite
|
|
234
|
-
│ └─ HMR
|
|
239
|
+
│ └─ runs the Vite dev server directly
|
|
240
|
+
│ └─ HMR support
|
|
235
241
|
│
|
|
236
|
-
└─ @
|
|
237
|
-
└─
|
|
238
|
-
└─
|
|
242
|
+
└─ @rainbow-robotics/preview-host
|
|
243
|
+
└─ packaged as a static bundle
|
|
244
|
+
└─ runs without the monorepo source
|
|
239
245
|
```
|
|
240
246
|
|
|
241
|
-
|
|
247
|
+
As a result, external developers get a Muscat-like preview environment — without holding a copy of the `web-rainbow-ui` source — that includes:
|
|
242
248
|
|
|
243
|
-
*
|
|
244
|
-
*
|
|
245
|
-
*
|
|
246
|
-
*
|
|
247
|
-
*
|
|
248
|
-
*
|
|
249
|
+
* Real nexus layout
|
|
250
|
+
* Real Header and LNB
|
|
251
|
+
* Real panels
|
|
252
|
+
* Real `rb-components`
|
|
253
|
+
* Real manifest-based plugin loading
|
|
254
|
+
* Mocked robot and backend environment
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{importShared as f}from"./__federation_fn_import.DdkEuT6t.js";import{dr as g,aE as s,_ as t,aM as v,dl as p,a0 as b,dk as c,cv as O,bL as E,aC as F,aL as B,cg as P,cs as w,aO as D,f1 as _,fJ as L}from"./RBQrBarCodeGuideModal.CegVepfq.js";import{f as T}from"./index.FZ9eMVCs.js";const{useQuery:M}=await f("@tanstack/react-query"),C=[{key:"dock",endpoint:"/{robot_model}/capability/dock",labelKey:"move.amr.rightPanel.capability.dock"},{key:"io",endpoint:"/{robot_model}/capability/Io",labelKey:"move.amr.rightPanel.capability.io"},{key:"camera",endpoint:"/{robot_model}/capability/camera",labelKey:"move.amr.rightPanel.capability.camera"},{key:"lidar2d",endpoint:"/{robot_model}/capability/lidar2d",labelKey:"move.amr.rightPanel.capability.lidar2d"},{key:"lidar3d",endpoint:"/{robot_model}/capability/lidar3d",labelKey:"move.amr.rightPanel.capability.lidar3d"},{key:"imu",endpoint:"/{robot_model}/capability/imu",labelKey:"move.amr.rightPanel.capability.imu"},{key:"safetyBumper",endpoint:"/{robot_model}/capability/safetyBumper",labelKey:"move.amr.rightPanel.capability.safetyBumper"},{key:"safetyInterlock",endpoint:"/{robot_model}/capability/safetyInterlock",labelKey:"move.amr.rightPanel.capability.safetyInterlock"},{key:"safetyObstacle",endpoint:"/{robot_model}/capability/safetyObstacle",labelKey:"move.amr.rightPanel.capability.safetyObstacle"},{key:"safetyOperationStop",endpoint:"/{robot_model}/capability/safetyOperationStop",labelKey:"move.amr.rightPanel.capability.safetyOperationStop"},{key:"safetySpeedControl",endpoint:"/{robot_model}/capability/safetySpeedControl",labelKey:"move.amr.rightPanel.capability.safetySpeedControl"},{key:"tabos",endpoint:"/{robot_model}/capability/tabos",labelKey:"move.amr.rightPanel.capability.tabos"}],R=e=>typeof e=="object"&&e!==null&&"enabled"in e&&e.enabled===!1,K=e=>{if(e instanceof Error)return e.message;if(typeof e=="object"&&e!==null&&"message"in e){const a=e.message;if(typeof a=="string")return a}},q=async({robot_model:e})=>{const a=await Promise.allSettled(C.map(l=>{const n=l.endpoint.replace("{robot_model}",e);return T.get(n)}));return C.map((l,n)=>{const r=a[n];return r.status==="fulfilled"?{...l,supported:!R(r.value),data:r.value}:{...l,supported:!1,data:null,errorMessage:K(r.reason)}})},$=({robot_model:e,enabled:a=!0})=>M({queryKey:["amrCapabilities",e],queryFn:()=>q({robot_model:e}),enabled:!!e&&a,staleTime:5*1e3,gcTime:60*1e3}),{useMutation:U}=await f("@tanstack/react-query"),V=()=>U({mutationFn:({robot_model:e,target:a,frequency:l})=>T.post(`/${e}/control/streamFrequency`,{target:a,frequency:Math.min(10,Math.max(0,l))})}),{useState:k}=await f("react"),j=4294967295,x=e=>{if(!(e==null||e===j))return`${e} ms`},z={0:"NONE",1:"CHARGING",2:"COMPLETE",3:"FAIL",4:"CANCEL"},G={0:"DEFAULT",1:"TABOS"},Y={0:"CABLE",1:"CONTACT",2:"INDUCTIVE"},H={0:"RPLIDAR",1:"SICK",2:"LAKI",3:"LIVOX",4:"HOKUYO"},Q={0:"ORBBEC"},i=({label:e,children:a})=>s(p,{className:"items-center justify-between gap-3",children:[t("span",{className:"typo-compact-xs-normal text-fg-subtle shrink-0",children:e}),t("span",{className:b("typo-compact-xs-normal text-right",a!=null?"text-fg-default":"text-fg-subtler"),children:a??"—"})]}),X={default:"gray",success:"green",warning:"orange",danger:"red"},y=({label:e,variant:a="default"})=>t(D,{type:"soft",color:X[a],children:e}),h=({label:e,value:a})=>t(i,{label:e,children:t(y,{label:a?"ON":"OFF",variant:a?"success":"default"})}),u=({label:e,bits:a})=>s(c,{className:"gap-1",children:[t("span",{className:"typo-compact-xs-normal text-fg-subtle",children:e}),a?.length?t(p,{className:"gap-1",children:a.map((l,n)=>t("div",{className:b("size-4 rounded-sm border text-center leading-4",l?"border-fg-success bg-fill-success-subtlest":"border-border-subtler bg-fill-disabled"),children:t("span",{className:b("typo-compact-2xs-normal",l?"text-fg-success":"text-fg-subtler"),children:n})},n))}):t("span",{className:"typo-compact-xs-normal text-fg-subtler",children:"—"})]}),N=({label:e,connection:a,rows:l,children:n})=>{const{t:r}=g();return s(c,{className:"bg-fill-disabled gap-1.5 rounded-md p-2.5",children:[s(p,{className:"items-center justify-between gap-3",children:[t("span",{className:"typo-compact-xs-semibold text-fg-default min-w-0 break-words",children:e}),t("span",{className:b("typo-compact-2xs-medium shrink-0",a?"text-fg-success":"text-fg-subtler"),children:r(a?"settings.amr.frs.status.connected":"settings.amr.frs.status.disconnected")})]}),l.map(({key:o,value:d})=>t(i,{label:o,children:d},o)),n]})},J=({label:e,value:a})=>t(D,{type:"soft",color:a?"green":"gray",children:s(p,{className:"items-center gap-1",children:[a?t(_,{className:"size-3"}):t(L,{className:"size-3"}),t("span",{children:e}),t("span",{className:"font-semibold",children:a?"On":"Off"})]})}),I=({flags:e})=>t(p,{className:"flex-wrap gap-1.5",children:e.map(({label:a,value:l})=>t(J,{label:a,value:l},a))}),W=({streams:e})=>e.length?s(c,{className:"border-subtle mt-0.5 gap-1 border-t pt-1.5",children:[t("span",{className:"typo-compact-xs-normal text-fg-subtle",children:"Streams"}),t(p,{className:"flex-wrap gap-1",children:e.map(a=>s(p,{className:"border-subtle bg-alt-1 items-center gap-1 rounded px-1.5 py-1",children:[t("span",{className:"typo-compact-2xs-semibold text-fg-default",children:a.quality}),s("span",{className:"typo-compact-2xs-normal text-fg-subtle",children:[a.width,"x",a.height]}),s("span",{className:"typo-compact-2xs-normal text-fg-subtler",children:[a.fps,"fps"]})]},`${a.camId}-${a.quality}`))})]}):null,Z=({data:e})=>{const a=z[e.chargeState??-1]??String(e.chargeState),l=e.chargeState===1?"success":e.chargeState===3?"danger":e.chargeState===4?"warning":"default";return s(c,{className:"gap-2",children:[s(c,{className:"bg-fill-disabled gap-2 rounded-md p-2.5",children:[t(h,{label:"Dock State",value:e.dockState}),t(i,{label:"Charge State",children:t(y,{label:a,variant:l})}),s(i,{label:"Battery",children:[e.batteryPercent?.toFixed(1)," %"]}),s(i,{label:"Charge Current",children:[e.chargeCurrent?.toFixed(2)," A"]}),s(i,{label:"Contact Voltage",children:[e.contactVoltage?.toFixed(2)," V"]}),t(i,{label:"Battery Type",children:t(y,{label:G[e.batteryType??0]??"—"})})]}),s(p,{className:"items-center gap-1.5 px-0.5",children:[t("span",{className:"typo-compact-xs-normal text-fg-subtle shrink-0",children:"Charge Type"}),e.chargeType?.length?t(p,{className:"flex-wrap gap-1.5",children:e.chargeType.map(n=>t(y,{label:Y[n]??String(n),variant:"default"},n))}):t("span",{className:"typo-compact-xs-normal text-fg-subtler",children:"—"})]})]})},ee=({data:e})=>s(c,{className:"gap-3 p-0.5",children:[t(u,{label:"MCU0 DIO",bits:e.mcu0Dio}),t(u,{label:"MCU1 DIO",bits:e.mcu1Dio}),t(u,{label:"MCU0 DIN",bits:e.mcu0Din}),t(u,{label:"MCU1 DIN",bits:e.mcu1Din})]}),ae=({data:e})=>s(c,{className:"gap-2",children:[t(I,{flags:[{label:"Obstacle",value:e.enabledObs},{label:"Depth",value:e.enabledDepth},{label:"Filter",value:e.enabledFilter}]}),e.info?.length?e.info.map((a,l)=>{const n=typeof a.type=="number"?Q[a.type]??String(a.type):a.type??"—",r=a.camId??a.index??l,o=e.rtspInfo?.filter(d=>d.camId===r)??[];return t(N,{label:`Camera ${r}${a.serial?` · ${a.serial}`:""}`,connection:a.connection,rows:[{key:"Type",value:n},{key:"TF",value:a.tf?.length?a.tf.map(d=>d.toFixed(2)).join(", "):void 0},{key:"Data Age",value:x(a.dataAgeMs)}],children:t(W,{streams:o})},l)}):t("span",{className:"typo-compact-xs-normal text-fg-subtler px-0.5",children:"—"})]}),A=({data:e,is3d:a=!1})=>s(c,{className:"gap-2",children:[t(I,{flags:[{label:"Obstacle",value:e.enabledObs}]}),e.info?.length?e.info.map((l,n)=>t(N,{label:`Lidar ${l.index??n}${l.serial?` · ${l.serial}`:""}`,connection:l.connection,rows:[{key:"Type",value:H[l.type]??String(l.type??"—")},...a?[]:[{key:"IP",value:l.ip}],{key:"Safety",value:l.safety!==void 0?l.safety?"Safety":"Normal":void 0},{key:"TF",value:l.tf?.length?l.tf.map(r=>r.toFixed(2)).join(", "):void 0},{key:"Data Age",value:x(l.dataAgeMs)}]},n)):t("span",{className:"typo-compact-xs-normal text-fg-subtler px-0.5",children:"—"})]}),te=({data:e})=>t(c,{className:"gap-2",children:e.info?.length?e.info.map((a,l)=>t(N,{label:`IMU ${a.index??l}${a.serial?` · ${a.serial}`:""}`,connection:a.connection,rows:[{key:"Type",value:a.type===1?"IMU":"DEFAULT"},{key:"Data Age",value:x(a.dataAgeMs)}]},l)):t("span",{className:"typo-compact-xs-normal text-fg-subtler px-0.5",children:"—"})}),le=({data:e})=>{const a=[{label:"Bumper State",value:e.bumperState},{label:"Interlock State",value:e.interlockState},{label:"Obstacle Detect",value:e.obsDetect},{label:"Operation Stop",value:e.operationStopState},{label:"Speed Control",value:e.speedControlState}].filter(l=>l.value!==void 0);return s(c,{className:"bg-fill-disabled gap-2 rounded-md p-2.5",children:[t(h,{label:"Enabled",value:e.enabled}),a.map(l=>t(h,{label:l.label,value:l.value},l.label))]})},se=({data:e})=>s(c,{className:"bg-fill-disabled gap-2 rounded-md p-2.5",children:[s(i,{label:"Voltage",children:[e.tabosVoltage?.toFixed(2)," V"]}),s(i,{label:"Current",children:[e.tabosCurrent?.toFixed(2)," A"]}),s(i,{label:"SOC",children:[e.tabosSoc?.toFixed(1)," %"]}),s(i,{label:"SOH",children:[e.tabosSoh?.toFixed(1)," %"]}),s(i,{label:"Temp",children:[e.tabosTemp?.toFixed(1)," °C"]})]}),ne=({capKey:e,data:a})=>{switch(e){case"dock":return t(Z,{data:a});case"io":return t(ee,{data:a});case"camera":return t(ae,{data:a});case"lidar2d":return t(A,{data:a});case"lidar3d":return t(A,{data:a,is3d:!0});case"imu":return t(te,{data:a});case"tabos":return t(se,{data:a});default:return t(le,{data:a})}},re=[{label:"LiDAR 2D",value:"lidar2d"},{label:"LiDAR 3D",value:"lidar3d"},{label:"OBS Map",value:"obsMap"}],ce=({robotModel:e})=>{const[a,l]=k("lidar2d"),[n,r]=k("1"),{mutate:o,isPending:d}=V();return s(c,{className:"gap-2 pb-1",children:[s(p,{className:"items-center justify-between gap-2",children:[t("span",{className:"typo-compact-xs-normal text-fg-subtle",children:"Target"}),t(F,{size:"2xs",variant:"brand",disabled:d,onClick:()=>{const m=Math.min(10,Math.max(0,Number(n)));o({robot_model:e,target:a,frequency:m})},children:"Set"})]}),t(P,{size:"sm",value:a,handleChange:m=>l(m),children:re.map(({label:m,value:S})=>t(B,{value:S,children:m},S))}),t(p,{className:"items-center gap-2",children:t(w,{className:"flex-1",size:"sm",value:n,step:1,digit:0,fixedDigit:0,min:"0",max:"10",handleChange:m=>r(m)})})]})},oe=({item:e})=>{const{t:a}=g();return e.supported?e.data?t("div",{className:"pb-1",children:t(ne,{capKey:e.key,data:e.data})}):null:t("p",{className:"typo-compact-xs-normal text-fg-disabled px-1 py-2",children:a("move.amr.rightPanel.capability.status.notSupported")})},ie=()=>{const{t:e}=g();return t(E,{className:"flex-1 [&_[data-slot='empty-view-section']]:h-full",type:"icon",icon:t(O,{size:20}),message:e("move.amr.rightPanel.capability.status.loading")})},ue=({className:e,robotModel:a})=>{const{t:l}=g(),{data:n,isLoading:r}=$({robot_model:a});return s(c,{className:b("AmrCapabilityControl h-full min-h-0",e),children:[r&&t(ie,{}),(n??[]).map(o=>t("div",{className:"border-subtler border-b px-1 py-1",children:t(v,{disabled:!o.supported,title:t(p,{className:"w-full items-center justify-between gap-2",children:t("span",{className:b("typo-compact-sm2-semibold min-w-0 truncate",o.supported?"text-fg-default":"text-fg-disabled"),children:l(o.labelKey)})}),children:t(oe,{item:o})})},o.key)),t("div",{className:"border-subtler border-b px-1 py-1",children:t(v,{title:t("span",{className:"typo-compact-sm2-semibold text-fg-default",children:l("move.amr.rightPanel.capability.streamFrequency")}),children:t(ce,{robotModel:a})})})]})};export{ue as default};
|
|
1
|
+
import{importShared as f}from"./__federation_fn_import.DdkEuT6t.js";import{dr as g,aE as s,_ as t,aM as v,dl as p,a0 as b,dk as c,cv as O,bL as E,aC as F,aL as B,cg as P,cs as w,aO as D,f1 as _,fJ as L}from"./RBQrBarCodeGuideModal.CegVepfq.js";import{f as T}from"./index.DhDDHapK.js";const{useQuery:M}=await f("@tanstack/react-query"),C=[{key:"dock",endpoint:"/{robot_model}/capability/dock",labelKey:"move.amr.rightPanel.capability.dock"},{key:"io",endpoint:"/{robot_model}/capability/Io",labelKey:"move.amr.rightPanel.capability.io"},{key:"camera",endpoint:"/{robot_model}/capability/camera",labelKey:"move.amr.rightPanel.capability.camera"},{key:"lidar2d",endpoint:"/{robot_model}/capability/lidar2d",labelKey:"move.amr.rightPanel.capability.lidar2d"},{key:"lidar3d",endpoint:"/{robot_model}/capability/lidar3d",labelKey:"move.amr.rightPanel.capability.lidar3d"},{key:"imu",endpoint:"/{robot_model}/capability/imu",labelKey:"move.amr.rightPanel.capability.imu"},{key:"safetyBumper",endpoint:"/{robot_model}/capability/safetyBumper",labelKey:"move.amr.rightPanel.capability.safetyBumper"},{key:"safetyInterlock",endpoint:"/{robot_model}/capability/safetyInterlock",labelKey:"move.amr.rightPanel.capability.safetyInterlock"},{key:"safetyObstacle",endpoint:"/{robot_model}/capability/safetyObstacle",labelKey:"move.amr.rightPanel.capability.safetyObstacle"},{key:"safetyOperationStop",endpoint:"/{robot_model}/capability/safetyOperationStop",labelKey:"move.amr.rightPanel.capability.safetyOperationStop"},{key:"safetySpeedControl",endpoint:"/{robot_model}/capability/safetySpeedControl",labelKey:"move.amr.rightPanel.capability.safetySpeedControl"},{key:"tabos",endpoint:"/{robot_model}/capability/tabos",labelKey:"move.amr.rightPanel.capability.tabos"}],R=e=>typeof e=="object"&&e!==null&&"enabled"in e&&e.enabled===!1,K=e=>{if(e instanceof Error)return e.message;if(typeof e=="object"&&e!==null&&"message"in e){const a=e.message;if(typeof a=="string")return a}},q=async({robot_model:e})=>{const a=await Promise.allSettled(C.map(l=>{const n=l.endpoint.replace("{robot_model}",e);return T.get(n)}));return C.map((l,n)=>{const r=a[n];return r.status==="fulfilled"?{...l,supported:!R(r.value),data:r.value}:{...l,supported:!1,data:null,errorMessage:K(r.reason)}})},$=({robot_model:e,enabled:a=!0})=>M({queryKey:["amrCapabilities",e],queryFn:()=>q({robot_model:e}),enabled:!!e&&a,staleTime:5*1e3,gcTime:60*1e3}),{useMutation:U}=await f("@tanstack/react-query"),V=()=>U({mutationFn:({robot_model:e,target:a,frequency:l})=>T.post(`/${e}/control/streamFrequency`,{target:a,frequency:Math.min(10,Math.max(0,l))})}),{useState:k}=await f("react"),j=4294967295,x=e=>{if(!(e==null||e===j))return`${e} ms`},z={0:"NONE",1:"CHARGING",2:"COMPLETE",3:"FAIL",4:"CANCEL"},G={0:"DEFAULT",1:"TABOS"},Y={0:"CABLE",1:"CONTACT",2:"INDUCTIVE"},H={0:"RPLIDAR",1:"SICK",2:"LAKI",3:"LIVOX",4:"HOKUYO"},Q={0:"ORBBEC"},i=({label:e,children:a})=>s(p,{className:"items-center justify-between gap-3",children:[t("span",{className:"typo-compact-xs-normal text-fg-subtle shrink-0",children:e}),t("span",{className:b("typo-compact-xs-normal text-right",a!=null?"text-fg-default":"text-fg-subtler"),children:a??"—"})]}),X={default:"gray",success:"green",warning:"orange",danger:"red"},y=({label:e,variant:a="default"})=>t(D,{type:"soft",color:X[a],children:e}),h=({label:e,value:a})=>t(i,{label:e,children:t(y,{label:a?"ON":"OFF",variant:a?"success":"default"})}),u=({label:e,bits:a})=>s(c,{className:"gap-1",children:[t("span",{className:"typo-compact-xs-normal text-fg-subtle",children:e}),a?.length?t(p,{className:"gap-1",children:a.map((l,n)=>t("div",{className:b("size-4 rounded-sm border text-center leading-4",l?"border-fg-success bg-fill-success-subtlest":"border-border-subtler bg-fill-disabled"),children:t("span",{className:b("typo-compact-2xs-normal",l?"text-fg-success":"text-fg-subtler"),children:n})},n))}):t("span",{className:"typo-compact-xs-normal text-fg-subtler",children:"—"})]}),N=({label:e,connection:a,rows:l,children:n})=>{const{t:r}=g();return s(c,{className:"bg-fill-disabled gap-1.5 rounded-md p-2.5",children:[s(p,{className:"items-center justify-between gap-3",children:[t("span",{className:"typo-compact-xs-semibold text-fg-default min-w-0 break-words",children:e}),t("span",{className:b("typo-compact-2xs-medium shrink-0",a?"text-fg-success":"text-fg-subtler"),children:r(a?"settings.amr.frs.status.connected":"settings.amr.frs.status.disconnected")})]}),l.map(({key:o,value:d})=>t(i,{label:o,children:d},o)),n]})},J=({label:e,value:a})=>t(D,{type:"soft",color:a?"green":"gray",children:s(p,{className:"items-center gap-1",children:[a?t(_,{className:"size-3"}):t(L,{className:"size-3"}),t("span",{children:e}),t("span",{className:"font-semibold",children:a?"On":"Off"})]})}),I=({flags:e})=>t(p,{className:"flex-wrap gap-1.5",children:e.map(({label:a,value:l})=>t(J,{label:a,value:l},a))}),W=({streams:e})=>e.length?s(c,{className:"border-subtle mt-0.5 gap-1 border-t pt-1.5",children:[t("span",{className:"typo-compact-xs-normal text-fg-subtle",children:"Streams"}),t(p,{className:"flex-wrap gap-1",children:e.map(a=>s(p,{className:"border-subtle bg-alt-1 items-center gap-1 rounded px-1.5 py-1",children:[t("span",{className:"typo-compact-2xs-semibold text-fg-default",children:a.quality}),s("span",{className:"typo-compact-2xs-normal text-fg-subtle",children:[a.width,"x",a.height]}),s("span",{className:"typo-compact-2xs-normal text-fg-subtler",children:[a.fps,"fps"]})]},`${a.camId}-${a.quality}`))})]}):null,Z=({data:e})=>{const a=z[e.chargeState??-1]??String(e.chargeState),l=e.chargeState===1?"success":e.chargeState===3?"danger":e.chargeState===4?"warning":"default";return s(c,{className:"gap-2",children:[s(c,{className:"bg-fill-disabled gap-2 rounded-md p-2.5",children:[t(h,{label:"Dock State",value:e.dockState}),t(i,{label:"Charge State",children:t(y,{label:a,variant:l})}),s(i,{label:"Battery",children:[e.batteryPercent?.toFixed(1)," %"]}),s(i,{label:"Charge Current",children:[e.chargeCurrent?.toFixed(2)," A"]}),s(i,{label:"Contact Voltage",children:[e.contactVoltage?.toFixed(2)," V"]}),t(i,{label:"Battery Type",children:t(y,{label:G[e.batteryType??0]??"—"})})]}),s(p,{className:"items-center gap-1.5 px-0.5",children:[t("span",{className:"typo-compact-xs-normal text-fg-subtle shrink-0",children:"Charge Type"}),e.chargeType?.length?t(p,{className:"flex-wrap gap-1.5",children:e.chargeType.map(n=>t(y,{label:Y[n]??String(n),variant:"default"},n))}):t("span",{className:"typo-compact-xs-normal text-fg-subtler",children:"—"})]})]})},ee=({data:e})=>s(c,{className:"gap-3 p-0.5",children:[t(u,{label:"MCU0 DIO",bits:e.mcu0Dio}),t(u,{label:"MCU1 DIO",bits:e.mcu1Dio}),t(u,{label:"MCU0 DIN",bits:e.mcu0Din}),t(u,{label:"MCU1 DIN",bits:e.mcu1Din})]}),ae=({data:e})=>s(c,{className:"gap-2",children:[t(I,{flags:[{label:"Obstacle",value:e.enabledObs},{label:"Depth",value:e.enabledDepth},{label:"Filter",value:e.enabledFilter}]}),e.info?.length?e.info.map((a,l)=>{const n=typeof a.type=="number"?Q[a.type]??String(a.type):a.type??"—",r=a.camId??a.index??l,o=e.rtspInfo?.filter(d=>d.camId===r)??[];return t(N,{label:`Camera ${r}${a.serial?` · ${a.serial}`:""}`,connection:a.connection,rows:[{key:"Type",value:n},{key:"TF",value:a.tf?.length?a.tf.map(d=>d.toFixed(2)).join(", "):void 0},{key:"Data Age",value:x(a.dataAgeMs)}],children:t(W,{streams:o})},l)}):t("span",{className:"typo-compact-xs-normal text-fg-subtler px-0.5",children:"—"})]}),A=({data:e,is3d:a=!1})=>s(c,{className:"gap-2",children:[t(I,{flags:[{label:"Obstacle",value:e.enabledObs}]}),e.info?.length?e.info.map((l,n)=>t(N,{label:`Lidar ${l.index??n}${l.serial?` · ${l.serial}`:""}`,connection:l.connection,rows:[{key:"Type",value:H[l.type]??String(l.type??"—")},...a?[]:[{key:"IP",value:l.ip}],{key:"Safety",value:l.safety!==void 0?l.safety?"Safety":"Normal":void 0},{key:"TF",value:l.tf?.length?l.tf.map(r=>r.toFixed(2)).join(", "):void 0},{key:"Data Age",value:x(l.dataAgeMs)}]},n)):t("span",{className:"typo-compact-xs-normal text-fg-subtler px-0.5",children:"—"})]}),te=({data:e})=>t(c,{className:"gap-2",children:e.info?.length?e.info.map((a,l)=>t(N,{label:`IMU ${a.index??l}${a.serial?` · ${a.serial}`:""}`,connection:a.connection,rows:[{key:"Type",value:a.type===1?"IMU":"DEFAULT"},{key:"Data Age",value:x(a.dataAgeMs)}]},l)):t("span",{className:"typo-compact-xs-normal text-fg-subtler px-0.5",children:"—"})}),le=({data:e})=>{const a=[{label:"Bumper State",value:e.bumperState},{label:"Interlock State",value:e.interlockState},{label:"Obstacle Detect",value:e.obsDetect},{label:"Operation Stop",value:e.operationStopState},{label:"Speed Control",value:e.speedControlState}].filter(l=>l.value!==void 0);return s(c,{className:"bg-fill-disabled gap-2 rounded-md p-2.5",children:[t(h,{label:"Enabled",value:e.enabled}),a.map(l=>t(h,{label:l.label,value:l.value},l.label))]})},se=({data:e})=>s(c,{className:"bg-fill-disabled gap-2 rounded-md p-2.5",children:[s(i,{label:"Voltage",children:[e.tabosVoltage?.toFixed(2)," V"]}),s(i,{label:"Current",children:[e.tabosCurrent?.toFixed(2)," A"]}),s(i,{label:"SOC",children:[e.tabosSoc?.toFixed(1)," %"]}),s(i,{label:"SOH",children:[e.tabosSoh?.toFixed(1)," %"]}),s(i,{label:"Temp",children:[e.tabosTemp?.toFixed(1)," °C"]})]}),ne=({capKey:e,data:a})=>{switch(e){case"dock":return t(Z,{data:a});case"io":return t(ee,{data:a});case"camera":return t(ae,{data:a});case"lidar2d":return t(A,{data:a});case"lidar3d":return t(A,{data:a,is3d:!0});case"imu":return t(te,{data:a});case"tabos":return t(se,{data:a});default:return t(le,{data:a})}},re=[{label:"LiDAR 2D",value:"lidar2d"},{label:"LiDAR 3D",value:"lidar3d"},{label:"OBS Map",value:"obsMap"}],ce=({robotModel:e})=>{const[a,l]=k("lidar2d"),[n,r]=k("1"),{mutate:o,isPending:d}=V();return s(c,{className:"gap-2 pb-1",children:[s(p,{className:"items-center justify-between gap-2",children:[t("span",{className:"typo-compact-xs-normal text-fg-subtle",children:"Target"}),t(F,{size:"2xs",variant:"brand",disabled:d,onClick:()=>{const m=Math.min(10,Math.max(0,Number(n)));o({robot_model:e,target:a,frequency:m})},children:"Set"})]}),t(P,{size:"sm",value:a,handleChange:m=>l(m),children:re.map(({label:m,value:S})=>t(B,{value:S,children:m},S))}),t(p,{className:"items-center gap-2",children:t(w,{className:"flex-1",size:"sm",value:n,step:1,digit:0,fixedDigit:0,min:"0",max:"10",handleChange:m=>r(m)})})]})},oe=({item:e})=>{const{t:a}=g();return e.supported?e.data?t("div",{className:"pb-1",children:t(ne,{capKey:e.key,data:e.data})}):null:t("p",{className:"typo-compact-xs-normal text-fg-disabled px-1 py-2",children:a("move.amr.rightPanel.capability.status.notSupported")})},ie=()=>{const{t:e}=g();return t(E,{className:"flex-1 [&_[data-slot='empty-view-section']]:h-full",type:"icon",icon:t(O,{size:20}),message:e("move.amr.rightPanel.capability.status.loading")})},ue=({className:e,robotModel:a})=>{const{t:l}=g(),{data:n,isLoading:r}=$({robot_model:a});return s(c,{className:b("AmrCapabilityControl h-full min-h-0",e),children:[r&&t(ie,{}),(n??[]).map(o=>t("div",{className:"border-subtler border-b px-1 py-1",children:t(v,{disabled:!o.supported,title:t(p,{className:"w-full items-center justify-between gap-2",children:t("span",{className:b("typo-compact-sm2-semibold min-w-0 truncate",o.supported?"text-fg-default":"text-fg-disabled"),children:l(o.labelKey)})}),children:t(oe,{item:o})})},o.key)),t("div",{className:"border-subtler border-b px-1 py-1",children:t(v,{title:t("span",{className:"typo-compact-sm2-semibold text-fg-default",children:l("move.amr.rightPanel.capability.streamFrequency")}),children:t(ce,{robotModel:a})})})]})};export{ue as default};
|