@rainbow-robotics/preview-host 0.1.2-dev.9 → 0.10.1-dev.1
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 +236 -26
- package/build.mjs +3 -14
- package/dist/assets/AmrCapabilityControl.oytFydB2.js +1 -0
- package/dist/assets/RbLocalizationProvider.CI7oesfV.js +311 -0
- package/dist/assets/__federation_expose_App.BvIAEUou.js +1356 -0
- package/dist/assets/__federation_fn_import.DdkEuT6t.js +23 -0
- package/dist/assets/__federation_shared_@emotion/{styled.wOy85H_m.js → styled.ETfwMsQo.js} +1 -1
- package/dist/assets/__federation_shared_@tanstack/{react-query.BqXJhb-5.js → react-query.fVz8BOIk.js} +1 -1
- package/dist/assets/__federation_shared_react-dom.CHMAxKsQ.js +1 -0
- package/dist/assets/{__federation_shared_react-simple-keyboard.BDWRGEbM.js → __federation_shared_react-simple-keyboard.CycbmZUL.js} +3 -3
- package/dist/assets/__federation_shared_react.DhiB56zQ.js +1 -0
- package/dist/assets/{cssMode.CxPsxiNP.js → cssMode.z2-NHYcV.js} +1 -1
- package/dist/assets/{emotion-styled-base.browser.esm.JngGwqgu.js → emotion-styled-base.browser.esm.BIcjgOzg.js} +1 -1
- package/dist/assets/{freemarker2.e18W-vVC.js → freemarker2.Bt8q4fBg.js} +1 -1
- package/dist/assets/{handlebars.DpGUQTlC.js → handlebars.BoqVl5GV.js} +1 -1
- package/dist/assets/{html.qS8AwR-R.js → html.8ZwYdhzS.js} +1 -1
- package/dist/assets/{htmlMode.D4pEgAMn.js → htmlMode.DPTRrtXh.js} +1 -1
- package/dist/assets/{index.CHuCXVak.js → index.B3zY1kf7.js} +1 -1
- package/dist/assets/index.Bfb-Nfl_.js +1 -0
- package/dist/assets/index.C-pJrSSC.js +1 -0
- package/dist/assets/index.Di1B_zOl.js +26 -0
- package/dist/assets/index.P6snMalu.js +9 -0
- package/dist/assets/{javascript.CIRAbwTJ.js → javascript.CIU7xZo3.js} +1 -1
- package/dist/assets/{jsonMode.CJcA6JGm.js → jsonMode.D1_Izqyt.js} +1 -1
- package/dist/assets/jsx-runtime.CBqCNPYB.js +9 -0
- package/dist/assets/{liquid.Cd_ynsyQ.js → liquid.DCMgNe71.js} +1 -1
- package/dist/assets/{lspLanguageFeatures.ZrhgItxw.js → lspLanguageFeatures.DWKaU1VK.js} +1 -1
- package/dist/assets/{mdx.E9Mhxtu7.js → mdx.8gVroNDk.js} +1 -1
- package/dist/assets/parseLasPointCloud.worker-BZeU-mt8.js +1 -0
- package/dist/assets/{python.BUTzvd2f.js → python.RKnDkd3D.js} +1 -1
- package/dist/assets/{razor.CI_gj0Fd.js → razor.uyZvm_ly.js} +1 -1
- package/dist/assets/remoteEntry.js +1 -1
- package/dist/assets/{tsMode.DBpdjX7n.js → tsMode.BniqA017.js} +1 -1
- package/dist/assets/{typescript.WM3o_g0z.js → typescript.BZLvAXt-.js} +1 -1
- package/dist/assets/useFileDownload.BuzVN3F3.js +4753 -0
- package/dist/assets/{xml.D7f39jWM.js → xml.IzNtcHww.js} +1 -1
- package/dist/assets/{yaml.BLLpRCf_.js → yaml.PJSBTl4g.js} +1 -1
- package/dist/data/service-info.json +129 -46
- package/dist/imgs/muscat_404.jpg +0 -0
- package/dist/imgs/nexus/forms/gripper/g11_help.png +0 -0
- package/dist/imgs/nexus/forms/gripper/g7_grip_dir_0.png +0 -0
- package/dist/imgs/nexus/forms/gripper/g7_grip_dir_1.png +0 -0
- package/dist/imgs/nexus/forms/gripper/g7_offset.png +0 -0
- package/dist/imgs/nexus/forms/gripper/g7_orientation_0.png +0 -0
- package/dist/imgs/nexus/forms/gripper/g7_orientation_1.png +0 -0
- package/dist/imgs/nexus/forms/gripper/g7_tip_width.png +0 -0
- package/dist/imgs/nexus/forms/gripper/gripper_10.png +0 -0
- package/dist/imgs/nexus/forms/gripper/gripper_11.png +0 -0
- package/dist/imgs/nexus/forms/gripper/gripper_12.png +0 -0
- package/dist/imgs/nexus/forms/gripper/gripper_13.png +0 -0
- package/dist/imgs/nexus/forms/gripper/gripper_14.png +0 -0
- package/dist/imgs/nexus/forms/gripper/gripper_15.png +0 -0
- package/dist/imgs/nexus/forms/gripper/gripper_16.png +0 -0
- package/dist/imgs/nexus/forms/gripper/gripper_17.png +0 -0
- package/dist/imgs/nexus/forms/gripper/gripper_18.png +0 -0
- package/dist/imgs/nexus/forms/gripper/gripper_19_0.png +0 -0
- package/dist/imgs/nexus/forms/gripper/gripper_19_1.png +0 -0
- package/dist/imgs/nexus/forms/gripper/gripper_20.png +0 -0
- package/dist/imgs/nexus/forms/gripper/gripper_21.png +0 -0
- package/dist/imgs/nexus/forms/gripper/gripper_22.png +0 -0
- package/dist/imgs/nexus/forms/gripper/gripper_23.png +0 -0
- package/dist/imgs/nexus/forms/gripper/gripper_7.png +0 -0
- package/dist/imgs/nexus/forms/gripper/gripper_8.png +0 -0
- package/dist/imgs/nexus/forms/gripper/gripper_9.png +0 -0
- package/dist/imgs/nexus/forms/weaving/weaving_desc.jpg +0 -0
- package/dist/imgs/nexus/no-image.png +0 -0
- package/dist/index.html +12 -10
- package/dist/plugin-shared/plugin-ui_host-ui.js +3 -0
- package/dist/plugin-shared/plugin-ui_react.js +3 -0
- package/dist/plugin-shared/plugin-ui_sdk.js +3 -0
- package/dist/plugin-shared/plugin-ui_ws.js +3 -0
- package/dist/plugin-shared/react-dom.js +4 -0
- package/dist/plugin-shared/react-dom_client.js +3 -0
- package/dist/plugin-shared/react.js +4 -0
- package/dist/plugin-shared/react_jsx-dev-runtime.js +3 -0
- package/dist/plugin-shared/react_jsx-runtime.js +3 -0
- package/package.json +4 -4
- package/serve.mjs +159 -31
- package/dist/assets/AmrCapabilityControl.BppT8lfW.js +0 -1
- package/dist/assets/ConveyorBelt.DYgETvU-.png +0 -0
- package/dist/assets/FactoryMap.CBpf9N92.js +0 -4881
- package/dist/assets/MapInfo.Bit_2DfJ.js +0 -1
- package/dist/assets/__federation_expose_App.DTILpvFM.js +0 -1126
- package/dist/assets/__federation_fn_import.Drmbxo5T.js +0 -23
- package/dist/assets/__federation_shared_react-dom.znG_qyPl.js +0 -1
- package/dist/assets/__federation_shared_react.Wsh8dz5j.js +0 -1
- package/dist/assets/_commonjsHelpers.Cpj98o6Y.js +0 -1
- package/dist/assets/index.ChsGqxH_.js +0 -9
- package/dist/assets/index.Dxudgz78.js +0 -1
- package/dist/assets/index.FxRLAiU5.js +0 -1
- package/dist/assets/index.ayADrA9_.js +0 -1
- package/dist/assets/jsx-runtime.CKZTQYsb.js +0 -9
- package/dist/assets/keymapTileIndex.worker-C2HCGd-D.js +0 -1
- package/dist/plugin-demo/assets/icon.svg +0 -3
- package/dist/plugin-demo/content.js +0 -9149
- package/dist/plugin-demo/manifest.json +0 -25
- package/dist/plugin-demo/sandbox.html +0 -10
- package/dist/plugin-runtime/@rainbow-robotics/plugin-ui/chunks/chunk-37HVFFJB.js +0 -1
- package/dist/plugin-runtime/@rainbow-robotics/plugin-ui/chunks/chunk-4MGSRUAS.js +0 -1
- package/dist/plugin-runtime/@rainbow-robotics/plugin-ui/chunks/chunk-Q6XGCIPE.js +0 -1
- package/dist/plugin-runtime/@rainbow-robotics/plugin-ui/connect.js +0 -1
- package/dist/plugin-runtime/@rainbow-robotics/plugin-ui/elements.js +0 -1
- package/dist/plugin-runtime/@rainbow-robotics/plugin-ui/react.js +0 -1
- package/dist/plugin-runtime/@rainbow-robotics/plugin-ui/sdk.js +0 -1
- package/dist/plugin-runtime/vendor/react-dom-client.js +0 -1
- package/dist/plugin-runtime/vendor/react-jsx-dev-runtime.js +0 -1
- package/dist/plugin-runtime/vendor/react-jsx-runtime.js +0 -1
- package/dist/plugin-runtime/vendor/react-runtime.js +0 -65
- package/dist/plugin-runtime/vendor/react.js +0 -1
package/serve.mjs
CHANGED
|
@@ -1,15 +1,10 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
// Serves the standalone preview-host bundle: the mini-Muscat shell (dist/) plus
|
|
3
|
-
// the developer's built plugin mounted at /plugin-dev/. No robot/back end.
|
|
4
|
-
//
|
|
5
2
|
// Usage:
|
|
6
|
-
// rb-preview-host --plugin <
|
|
7
|
-
//
|
|
8
|
-
// The plugin dir must contain manifest.json, sandbox.html, content.js and any
|
|
9
|
-
// assets/ — i.e. the output of `muscat-pk build`.
|
|
3
|
+
// rb-preview-host --plugin <staged-dir> [--port 4180] [--dist <dir>]
|
|
10
4
|
import { createServer } from "node:http";
|
|
11
|
-
import { createReadStream, existsSync, readFileSync, statSync } from "node:fs";
|
|
12
|
-
import {
|
|
5
|
+
import { createReadStream, existsSync, mkdirSync, readFileSync, renameSync, statSync, watch, writeFileSync } from "node:fs";
|
|
6
|
+
import { homedir } from "node:os";
|
|
7
|
+
import { dirname, extname, join, resolve, sep } from "node:path";
|
|
13
8
|
import { fileURLToPath } from "node:url";
|
|
14
9
|
|
|
15
10
|
const here = dirname(fileURLToPath(import.meta.url));
|
|
@@ -21,14 +16,14 @@ function arg(name, fallback) {
|
|
|
21
16
|
|
|
22
17
|
const port = Number(arg("port", "4180"));
|
|
23
18
|
const distDir = resolve(arg("dist", join(here, "dist")));
|
|
24
|
-
// plugin-runtime is bundled into dist/ at build time — no runtime dep on @rainbow-robotics/plugin-ui
|
|
25
|
-
const runtimeDir = resolve(arg("runtime", join(here, "dist", "plugin-runtime")));
|
|
26
19
|
const pluginDir = arg("plugin", "")
|
|
27
20
|
? resolve(arg("plugin", ""))
|
|
28
21
|
: "";
|
|
29
22
|
const socketUrl = arg("socket-url", "");
|
|
23
|
+
const robotHost = arg("robot-host", "");
|
|
24
|
+
const devServerUrl = arg("dev-server-url", "");
|
|
30
25
|
const PLUGIN_BASE = "/plugin-dev";
|
|
31
|
-
const
|
|
26
|
+
const RELOAD_PATH = "/__preview_reload";
|
|
32
27
|
|
|
33
28
|
const CONTENT_TYPE = {
|
|
34
29
|
".html": "text/html; charset=utf-8",
|
|
@@ -56,43 +51,177 @@ if (!existsSync(distDir)) {
|
|
|
56
51
|
process.exit(1);
|
|
57
52
|
}
|
|
58
53
|
|
|
59
|
-
|
|
54
|
+
|
|
55
|
+
let previewPluginId = "";
|
|
56
|
+
// Core SW category the preview program pretends to run on (command forms are keyed by it).
|
|
57
|
+
let previewBeService = "manipulate";
|
|
58
|
+
if (pluginDir) {
|
|
59
|
+
try {
|
|
60
|
+
const manifest = JSON.parse(readFileSync(resolve(pluginDir, "manifest.json"), "utf8"));
|
|
61
|
+
previewPluginId = manifest.id || "";
|
|
62
|
+
if (Array.isArray(manifest.targetCategorys) && manifest.targetCategorys[0]) {
|
|
63
|
+
previewBeService = manifest.targetCategorys[0];
|
|
64
|
+
}
|
|
65
|
+
} catch {
|
|
66
|
+
/* manifest missing/unreadable — no preview id */
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
|
|
60
70
|
const injectedLines = [
|
|
61
71
|
" <script>",
|
|
62
72
|
" window.__RB_PLUGIN_PREVIEW_HOST__ = true;",
|
|
63
73
|
" window.__RB_ASSETS_BASE_URL__ = window.location.origin;",
|
|
64
74
|
` window.__RB_PLUGIN_PREVIEW_BASE__ = ${JSON.stringify(PLUGIN_BASE)};`,
|
|
65
75
|
];
|
|
76
|
+
if (previewPluginId) {
|
|
77
|
+
injectedLines.push(` window.__RB_PREVIEW_PLUGIN_ID__ = ${JSON.stringify(previewPluginId)};`);
|
|
78
|
+
}
|
|
79
|
+
injectedLines.push(` window.__RB_PREVIEW_BE_SERVICE__ = ${JSON.stringify(previewBeService)};`);
|
|
80
|
+
if (devServerUrl) {
|
|
81
|
+
injectedLines.push(` window.__RB_PLUGIN_DEV_SERVER_URL__ = ${JSON.stringify(devServerUrl)};`);
|
|
82
|
+
}
|
|
66
83
|
if (socketUrl) {
|
|
67
84
|
injectedLines.push(` window.__RB_PLUGIN_PREVIEW_SOCKET_URL__ = ${JSON.stringify(socketUrl)};`);
|
|
68
85
|
}
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
);
|
|
86
|
+
if (robotHost) {
|
|
87
|
+
|
|
88
|
+
injectedLines.push(` window.__RB_ROBOT_HOST__ = ${JSON.stringify(robotHost)};`);
|
|
89
|
+
}
|
|
90
|
+
injectedLines.push(" </script>");
|
|
74
91
|
|
|
75
|
-
|
|
92
|
+
if (pluginDir) {
|
|
93
|
+
injectedLines.push(
|
|
94
|
+
" <script>",
|
|
95
|
+
` new EventSource(${JSON.stringify(RELOAD_PATH)}).onmessage = () => location.reload();`,
|
|
96
|
+
" </script>",
|
|
97
|
+
);
|
|
98
|
+
}
|
|
99
|
+
injectedLines.push(" </head>");
|
|
100
|
+
|
|
101
|
+
function renderIndexHtml() {
|
|
102
|
+
return readFileSync(join(distDir, "index.html"), "utf8").replace(
|
|
103
|
+
"</head>",
|
|
104
|
+
injectedLines.join("\n"),
|
|
105
|
+
);
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
function sendFile(res, filePath, { noStore = false } = {}) {
|
|
76
109
|
res.setHeader("Access-Control-Allow-Origin", "*");
|
|
110
|
+
if (noStore) res.setHeader("Cache-Control", "no-store");
|
|
77
111
|
const type = CONTENT_TYPE[extname(filePath)];
|
|
78
112
|
if (type) res.setHeader("Content-Type", type);
|
|
79
113
|
createReadStream(filePath).pipe(res);
|
|
80
114
|
}
|
|
81
115
|
|
|
82
|
-
function tryServe(res, baseDir, relPath) {
|
|
116
|
+
function tryServe(res, baseDir, relPath, opts) {
|
|
83
117
|
const filePath = resolve(baseDir, `.${relPath}`);
|
|
84
118
|
if (!filePath.startsWith(baseDir)) return false;
|
|
85
119
|
if (existsSync(filePath) && statSync(filePath).isFile()) {
|
|
86
|
-
sendFile(res, filePath);
|
|
120
|
+
sendFile(res, filePath, opts);
|
|
87
121
|
return true;
|
|
88
122
|
}
|
|
89
123
|
return false;
|
|
90
124
|
}
|
|
91
125
|
|
|
126
|
+
|
|
127
|
+
// models/ (URDF + meshes, ~800MB) isn't bundled — too large for npm. Each file is fetched from the
|
|
128
|
+
// kit's S3 copy on first use and kept in ~/.muscat-pk/models, so the 3D robot view works with any
|
|
129
|
+
// robot or a local core SW, and offline once a model has been seen.
|
|
130
|
+
// ponytail: cached by path only; a changed model needs ~/.muscat-pk/models cleared.
|
|
131
|
+
// Tried in order: the kit's S3 copy, then the assets server (:5177) of the robot / local Muscat,
|
|
132
|
+
// which has the models that Muscat ships — so a model missing from S3 (or no internet) still shows.
|
|
133
|
+
const MODEL_SOURCES = [
|
|
134
|
+
...new Set([
|
|
135
|
+
process.env.MUSCAT_PK_MODELS_URL || "https://rainbow-deploy.s3.ap-northeast-2.amazonaws.com/muscat-plugin-kit/models",
|
|
136
|
+
...(robotHost ? [`http://${robotHost}:5177/models`] : []),
|
|
137
|
+
"http://localhost:5177/models",
|
|
138
|
+
]),
|
|
139
|
+
];
|
|
140
|
+
const MODELS_CACHE = resolve(homedir(), ".muscat-pk", "models");
|
|
141
|
+
|
|
142
|
+
const unreachable = new Set(); // a source that didn't answer is skipped from then on
|
|
143
|
+
|
|
144
|
+
async function fetchModel(rel) {
|
|
145
|
+
const path = rel.split("/").map(encodeURIComponent).join("/");
|
|
146
|
+
for (const base of MODEL_SOURCES) {
|
|
147
|
+
if (unreachable.has(base)) continue;
|
|
148
|
+
try {
|
|
149
|
+
const r = await fetch(`${base}/${path}`, { signal: AbortSignal.timeout(15_000) });
|
|
150
|
+
// S3 answers 403 for a missing key; a web server may answer 200 with an HTML fallback page.
|
|
151
|
+
if (r.ok && !(r.headers.get("content-type") ?? "").startsWith("text/html")) return Buffer.from(await r.arrayBuffer());
|
|
152
|
+
} catch {
|
|
153
|
+
unreachable.add(base);
|
|
154
|
+
}
|
|
155
|
+
}
|
|
156
|
+
return null;
|
|
157
|
+
}
|
|
158
|
+
|
|
159
|
+
async function serveModel(res, url) {
|
|
160
|
+
const rel = decodeURIComponent(url.slice("/models/".length));
|
|
161
|
+
const file = resolve(MODELS_CACHE, rel);
|
|
162
|
+
if (!file.startsWith(MODELS_CACHE + sep)) {
|
|
163
|
+
res.statusCode = 400;
|
|
164
|
+
res.end();
|
|
165
|
+
return;
|
|
166
|
+
}
|
|
167
|
+
if (!existsSync(file)) {
|
|
168
|
+
const data = await fetchModel(rel);
|
|
169
|
+
if (!data) {
|
|
170
|
+
res.statusCode = 404;
|
|
171
|
+
res.end(`model file not found: ${rel}`);
|
|
172
|
+
return;
|
|
173
|
+
}
|
|
174
|
+
mkdirSync(dirname(file), { recursive: true });
|
|
175
|
+
const part = `${file}.${process.pid}.part`;
|
|
176
|
+
writeFileSync(part, data);
|
|
177
|
+
renameSync(part, file);
|
|
178
|
+
}
|
|
179
|
+
sendFile(res, file);
|
|
180
|
+
}
|
|
181
|
+
|
|
182
|
+
const reloadClients = new Set();
|
|
183
|
+
if (pluginDir && existsSync(pluginDir)) {
|
|
184
|
+
let timer = null;
|
|
185
|
+
const notify = (_event, file) => {
|
|
186
|
+
if (String(file ?? "").startsWith("sysroot")) return;
|
|
187
|
+
clearTimeout(timer);
|
|
188
|
+
timer = setTimeout(() => {
|
|
189
|
+
for (const c of reloadClients) c.write("data: reload\n\n");
|
|
190
|
+
}, 100);
|
|
191
|
+
};
|
|
192
|
+
// Only what the page uses: the staged root files and assets/. The same dir also holds the editor's
|
|
193
|
+
// C++ SDK headers (sysroot/), which a recursive watch would scan and trip over while it is replaced.
|
|
194
|
+
// A watcher error must not take the preview down.
|
|
195
|
+
watch(pluginDir, notify).on("error", () => {});
|
|
196
|
+
const assetsDir = join(pluginDir, "assets");
|
|
197
|
+
if (existsSync(assetsDir)) {
|
|
198
|
+
try {
|
|
199
|
+
// Recursive: macOS/Windows always, Linux on Node 20.13+.
|
|
200
|
+
watch(assetsDir, { recursive: true }, notify).on("error", () => {});
|
|
201
|
+
} catch {
|
|
202
|
+
watch(assetsDir, notify).on("error", () => {});
|
|
203
|
+
}
|
|
204
|
+
}
|
|
205
|
+
}
|
|
206
|
+
|
|
92
207
|
const server = createServer((req, res) => {
|
|
93
208
|
const url = (req.url || "/").split("?")[0];
|
|
94
209
|
|
|
95
|
-
|
|
210
|
+
|
|
211
|
+
if (url === RELOAD_PATH) {
|
|
212
|
+
res.writeHead(200, {
|
|
213
|
+
"Content-Type": "text/event-stream",
|
|
214
|
+
"Cache-Control": "no-cache",
|
|
215
|
+
Connection: "keep-alive",
|
|
216
|
+
"Access-Control-Allow-Origin": "*",
|
|
217
|
+
});
|
|
218
|
+
res.write("retry: 1000\n\n");
|
|
219
|
+
reloadClients.add(res);
|
|
220
|
+
req.on("close", () => reloadClients.delete(res));
|
|
221
|
+
return;
|
|
222
|
+
}
|
|
223
|
+
|
|
224
|
+
|
|
96
225
|
if (url.startsWith(PLUGIN_BASE)) {
|
|
97
226
|
if (!pluginDir) {
|
|
98
227
|
res.statusCode = 404;
|
|
@@ -100,18 +229,18 @@ const server = createServer((req, res) => {
|
|
|
100
229
|
return;
|
|
101
230
|
}
|
|
102
231
|
const rel = url.slice(PLUGIN_BASE.length) || "/";
|
|
103
|
-
|
|
232
|
+
// no-store so the browser always re-fetches the freshly staged manifest/assets.
|
|
233
|
+
if (tryServe(res, pluginDir, rel, { noStore: true })) return;
|
|
104
234
|
res.statusCode = 404;
|
|
105
235
|
res.end("plugin asset not found");
|
|
106
236
|
return;
|
|
107
237
|
}
|
|
108
238
|
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
res.end("plugin runtime asset not found");
|
|
239
|
+
if (url.startsWith("/models/")) {
|
|
240
|
+
serveModel(res, url).catch((e) => {
|
|
241
|
+
res.statusCode = 502;
|
|
242
|
+
res.end(`model download failed: ${e.message}`);
|
|
243
|
+
});
|
|
115
244
|
return;
|
|
116
245
|
}
|
|
117
246
|
|
|
@@ -120,13 +249,12 @@ const server = createServer((req, res) => {
|
|
|
120
249
|
|
|
121
250
|
// SPA fallback → injected index.html
|
|
122
251
|
res.setHeader("Content-Type", "text/html; charset=utf-8");
|
|
123
|
-
res.end(
|
|
252
|
+
res.end(renderIndexHtml());
|
|
124
253
|
});
|
|
125
254
|
|
|
126
255
|
server.listen(port, () => {
|
|
127
256
|
console.log(`[preview-host] mini-Muscat → http://localhost:${port}`);
|
|
128
257
|
console.log(`[preview-host] dist: ${distDir}`);
|
|
129
|
-
console.log(`[preview-host] runtime: ${runtimeDir} → ${RUNTIME_BASE}`);
|
|
130
258
|
console.log(
|
|
131
259
|
`[preview-host] plugin: ${pluginDir || "(none — pass --plugin <dir>)"} → ${PLUGIN_BASE}`,
|
|
132
260
|
);
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{ay as u,ao as s,I as a,cw as v,aq as p,K as d,av as i,dy as N,dz as C}from"./FactoryMap.CBpf9N92.js";import{a as S,R as k,b as T}from"./index.ayADrA9_.js";import{importShared as D}from"./__federation_fn_import.Drmbxo5T.js";const{useQuery:I}=await D("@tanstack/react-query"),f=[{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"}],A=e=>typeof e=="object"&&e!==null&&"enabled"in e&&e.enabled===!1,O=e=>{if(e instanceof Error)return e.message;if(typeof e=="object"&&e!==null&&"message"in e){const t=e.message;if(typeof t=="string")return t}},E=async({robot_model:e})=>{const t=await Promise.allSettled(f.map(l=>{const n=l.endpoint.replace("{robot_model}",e);return S.get(n)}));return f.map((l,n)=>{const r=t[n];return r.status==="fulfilled"?{...l,supported:!A(r.value),data:r.value}:{...l,supported:!1,data:null,errorMessage:O(r.reason)}})},P=({robot_model:e,enabled:t=!0})=>I({queryKey:["amrCapabilities",e],queryFn:()=>E({robot_model:e}),enabled:!!e&&t,staleTime:5*1e3,gcTime:60*1e3}),F={0:"NONE",1:"CHARGING",2:"COMPLETE",3:"FAIL",4:"CANCEL"},B={0:"DEFAULT",1:"TABOS"},w={0:"CABLE",1:"CONTACT",2:"INDUCTIVE"},_={0:"RPLIDAR",1:"SICK",2:"LAKI",3:"LIVOX",4:"HOKUYO"},L={0:"ORBBEC"},o=({label:e,children:t})=>s(p,{className:"items-center justify-between gap-3",children:[a("span",{className:"typo-compact-xs-normal text-fg-subtle shrink-0",children:e}),a("span",{className:d("typo-compact-xs-normal text-right",t!=null?"text-fg-default":"text-fg-subtler"),children:t??"—"})]}),K={default:"gray",success:"green",warning:"orange",danger:"red"},c=({label:e,variant:t="default"})=>a(T,{type:"soft",color:K[t],children:e}),y=({label:e,value:t})=>a(o,{label:e,children:a(c,{label:t?"ON":"OFF",variant:t?"success":"default"})}),m=({label:e,bits:t})=>s(i,{className:"gap-1",children:[a("span",{className:"typo-compact-xs-normal text-fg-subtle",children:e}),t?.length?a(p,{className:"gap-1",children:t.map((l,n)=>a("div",{className:d("size-4 rounded-sm border text-center leading-4",l?"border-fg-success bg-fill-success-subtlest":"border-border-subtler bg-fill-disabled"),children:a("span",{className:d("typo-compact-2xs-normal",l?"text-fg-success":"text-fg-subtler"),children:n})},n))}):a("span",{className:"typo-compact-xs-normal text-fg-subtler",children:"—"})]}),g=({label:e,connection:t,rows:l})=>s(i,{className:"bg-fill-disabled gap-1.5 rounded-md p-2.5",children:[a("span",{className:"typo-compact-xs-semibold text-fg-default",children:e}),s(p,{className:"items-center justify-between gap-3",children:[a("span",{className:"typo-compact-xs-normal text-fg-subtle shrink-0",children:"Connection"}),s(p,{className:"items-center gap-1",children:[a(C,{color:t?"green":"gray"}),a("span",{className:"typo-compact-2xs-normal text-fg-subtle",children:t?"Connected":"Disconnected"})]})]}),l.map(({key:n,value:r})=>a(o,{label:n,children:r},n))]}),x=({flags:e})=>a(p,{className:"flex-wrap gap-1.5",children:e.map(({label:t,value:l})=>a(c,{label:t,variant:l?"success":"default"},t))}),R=({data:e})=>{const t=F[e.chargeState??-1]??String(e.chargeState),l=e.chargeState===1?"success":e.chargeState===3?"danger":e.chargeState===4?"warning":"default";return s(i,{className:"gap-2",children:[s(i,{className:"bg-fill-disabled gap-2 rounded-md p-2.5",children:[a(y,{label:"Dock State",value:e.dockState}),a(o,{label:"Charge State",children:a(c,{label:t,variant:l})}),s(o,{label:"Battery",children:[e.batteryPercent?.toFixed(1)," %"]}),s(o,{label:"Charge Current",children:[e.chargeCurrent?.toFixed(2)," A"]}),s(o,{label:"Contact Voltage",children:[e.contactVoltage?.toFixed(2)," V"]}),a(o,{label:"Battery Type",children:a(c,{label:B[e.batteryType??0]??"—"})})]}),s(p,{className:"items-center gap-1.5 px-0.5",children:[a("span",{className:"typo-compact-xs-normal text-fg-subtle shrink-0",children:"Charge Type"}),e.chargeType?.length?a(p,{className:"flex-wrap gap-1.5",children:e.chargeType.map(n=>a(c,{label:w[n]??String(n),variant:"default"},n))}):a("span",{className:"typo-compact-xs-normal text-fg-subtler",children:"—"})]})]})},M=({data:e})=>s(i,{className:"gap-3 p-0.5",children:[a(m,{label:"MCU0 DIO",bits:e.mcu0Dio}),a(m,{label:"MCU1 DIO",bits:e.mcu1Dio}),a(m,{label:"MCU0 DIN",bits:e.mcu0Din}),a(m,{label:"MCU1 DIN",bits:e.mcu1Din})]}),V=({data:e})=>s(i,{className:"gap-2",children:[a(x,{flags:[{label:"Enabled",value:e.enabled},{label:"Obstacle",value:e.enabledObs},{label:"Depth",value:e.enabledDepth},{label:"Filter",value:e.enabledFilter}]}),e.info?.length?e.info.map((t,l)=>{const n=typeof t.type=="number"?L[t.type]??String(t.type):t.type??"—",r=t.camId??t.index??l;return a(g,{label:`Camera ${r}${t.serial?` · ${t.serial}`:""}`,connection:t.connection,rows:[{key:"Type",value:a(c,{label:n})},{key:"TF",value:t.tf?.length?t.tf.map(b=>b.toFixed(2)).join(", "):void 0}]},l)}):a("span",{className:"typo-compact-xs-normal text-fg-subtler px-0.5",children:"—"})]}),h=({data:e,is3d:t=!1})=>s(i,{className:"gap-2",children:[a(x,{flags:[{label:"Enabled",value:e.enabled},{label:"Obstacle",value:e.enabledObs}]}),e.info?.length?e.info.map((l,n)=>a(g,{label:`Lidar ${l.index??n}${l.serial?` · ${l.serial}`:""}`,connection:l.connection,rows:[{key:"Type",value:a(c,{label:_[l.type]??String(l.type??"—")})},...t?[]:[{key:"IP",value:l.ip}],{key:"Safety",value:l.safety!==void 0?a(c,{label:l.safety?"Safety":"Normal",variant:l.safety?"warning":"default"}):void 0},{key:"TF",value:l.tf?.length?l.tf.map(r=>r.toFixed(2)).join(", "):void 0}]},n)):a("span",{className:"typo-compact-xs-normal text-fg-subtler px-0.5",children:"—"})]}),U=({data:e})=>a(i,{className:"gap-2",children:e.info?.length?e.info.map((t,l)=>a(g,{label:`IMU ${t.index??l}${t.serial?` · ${t.serial}`:""}`,connection:t.connection,rows:[{key:"Type",value:a(c,{label:t.type===1?"IMU":"DEFAULT"})}]},l)):a("span",{className:"typo-compact-xs-normal text-fg-subtler px-0.5",children:"—"})}),j=({data:e})=>{const t=[{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(i,{className:"bg-fill-disabled gap-2 rounded-md p-2.5",children:[a(y,{label:"Enabled",value:e.enabled}),t.map(l=>a(y,{label:l.label,value:l.value},l.label))]})},$=({data:e})=>s(i,{className:"bg-fill-disabled gap-2 rounded-md p-2.5",children:[s(o,{label:"Voltage",children:[e.tabosVoltage?.toFixed(2)," V"]}),s(o,{label:"Current",children:[e.tabosCurrent?.toFixed(2)," A"]}),s(o,{label:"SOC",children:[e.tabosSoc?.toFixed(1)," %"]}),s(o,{label:"SOH",children:[e.tabosSoh?.toFixed(1)," %"]}),s(o,{label:"Temp",children:[e.tabosTemp?.toFixed(1)," °C"]})]}),G=({capKey:e,data:t})=>{switch(e){case"dock":return a(R,{data:t});case"io":return a(M,{data:t});case"camera":return a(V,{data:t});case"lidar2d":return a(h,{data:t});case"lidar3d":return a(h,{data:t,is3d:!0});case"imu":return a(U,{data:t});case"tabos":return a($,{data:t});default:return a(j,{data:t})}},Y=({item:e})=>{const{t}=u();return e.supported?e.data?a("div",{className:"pb-1",children:a(G,{capKey:e.key,data:e.data})}):null:a("p",{className:"typo-compact-xs-normal text-fg-disabled px-1 py-2",children:t("move.amr.rightPanel.capability.status.notSupported")})},H=()=>{const{t:e}=u();return a(N,{className:"flex-1 [&_[data-slot='empty-view-section']]:h-full",type:"icon",icon:a(k,{size:20}),message:e("move.amr.rightPanel.capability.status.loading")})},X=({className:e,robotModel:t})=>{const{t:l}=u(),{data:n,isLoading:r}=P({robot_model:t});return s(i,{className:d("AmrCapabilityControl h-full min-h-0",e),children:[r&&a(H,{}),(n??[]).map(b=>a("div",{className:"border-subtler border-b px-1 py-1",children:a(v,{disabled:!b.supported,title:a(p,{className:"w-full items-center justify-between gap-2",children:a("span",{className:d("typo-compact-sm2-semibold min-w-0 truncate",b.supported?"text-fg-default":"text-fg-disabled"),children:l(b.labelKey)})}),children:a(Y,{item:b})})},b.key))]})};export{X as default};
|
|
Binary file
|