@rainbow-robotics/preview-host 0.11.2-dev.1 → 0.11.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/assets/{AmrCapabilityControl.D4HD0FBi.js → AmrCapabilityControl.DHlClNfl.js} +1 -1
- package/dist/assets/{RbLocalizationProvider.C7JmvgEO.js → RbLocalizationProvider.Bjp-XasT.js} +35 -35
- package/dist/assets/{__federation_expose_App.DPUatSMA.js → __federation_expose_App.BoAD7rmq.js} +320 -328
- package/dist/assets/__federation_fn_import.DdkEuT6t.js +2 -2
- package/dist/assets/{cssMode.B1px729a.js → cssMode.DvbQhRWp.js} +1 -1
- package/dist/assets/{freemarker2.OD1Bbb0z.js → freemarker2.D4QgvvAA.js} +1 -1
- package/dist/assets/{handlebars.BJCu6PJm.js → handlebars.aNWQrcY9.js} +1 -1
- package/dist/assets/{html.CpC9wtPB.js → html.De5DHXNR.js} +1 -1
- package/dist/assets/{htmlMode.BhX8e4Sz.js → htmlMode.LxOTVQQu.js} +1 -1
- package/dist/assets/index.DKZKIW-y.js +1 -0
- package/dist/assets/{index.BGGQNuhF.js → index.aaHIZMQG.js} +2 -2
- package/dist/assets/{index.Kr6nB87s.js → index.lzV92Wx_.js} +1 -1
- package/dist/assets/{javascript.DI8Ap6Lq.js → javascript.Cvwtihkn.js} +1 -1
- package/dist/assets/{jsonMode.CoSpzqYN.js → jsonMode.DhyMqrQK.js} +1 -1
- package/dist/assets/{liquid.CcxmpVrP.js → liquid.BteD4Gob.js} +1 -1
- package/dist/assets/{lspLanguageFeatures.N-Yg4jY5.js → lspLanguageFeatures.B0QqnvEK.js} +1 -1
- package/dist/assets/{mdx.B2lB-vor.js → mdx.DswheUlM.js} +1 -1
- package/dist/assets/{python.Cxe3yqdH.js → python.BoMGDtn_.js} +1 -1
- package/dist/assets/{razor.DoTecAgD.js → razor.D9ppbGyZ.js} +1 -1
- package/dist/assets/remoteEntry.js +1 -1
- package/dist/assets/{tsMode.CnonrAVV.js → tsMode.CI_2C2BP.js} +1 -1
- package/dist/assets/{typescript.C8lsJkH9.js → typescript.B-PscPZM.js} +1 -1
- package/dist/assets/{useParsedPointCloudData.DhrtQ8uK.js → useParsedPointCloudData.By3wmxd4.js} +2 -2
- package/dist/assets/{xml.D2cv4eHv.js → xml.BR2Tjm_U.js} +1 -1
- package/dist/assets/{yaml.PCLiScIm.js → yaml.CO5muCL7.js} +1 -1
- package/dist/index.html +5 -5
- package/package.json +1 -1
- package/serve.mjs +61 -14
- package/dist/assets/index.CiLZXPON.js +0 -1
package/dist/index.html
CHANGED
|
@@ -6,16 +6,16 @@
|
|
|
6
6
|
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
|
7
7
|
<title>Rainbow Robotics System</title>
|
|
8
8
|
<script type="importmap">{"imports":{"react":"/plugin-shared/react.js","react/jsx-runtime":"/plugin-shared/react_jsx-runtime.js","react/jsx-dev-runtime":"/plugin-shared/react_jsx-dev-runtime.js","react-dom":"/plugin-shared/react-dom.js","react-dom/client":"/plugin-shared/react-dom_client.js","@rainbow-robotics/plugin-ui/react":"/plugin-shared/plugin-ui_react.js","@rainbow-robotics/plugin-ui/sdk":"/plugin-shared/plugin-ui_sdk.js","@rainbow-robotics/plugin-ui/host-ui":"/plugin-shared/plugin-ui_host-ui.js","@rainbow-robotics/plugin-ui/ws":"/plugin-shared/plugin-ui_ws.js"}}</script>
|
|
9
|
-
<script type="module" crossorigin src="/assets/index.
|
|
9
|
+
<script type="module" crossorigin src="/assets/index.lzV92Wx_.js"></script>
|
|
10
10
|
<link rel="modulepreload" crossorigin href="/assets/__federation_fn_import.DdkEuT6t.js">
|
|
11
11
|
<link rel="modulepreload" crossorigin href="/assets/index.P6snMalu.js">
|
|
12
12
|
<link rel="modulepreload" crossorigin href="/assets/jsx-runtime.CBqCNPYB.js">
|
|
13
13
|
<link rel="modulepreload" crossorigin href="/assets/emotion-styled-base.browser.esm.BIcjgOzg.js">
|
|
14
|
-
<link rel="modulepreload" crossorigin href="/assets/RbLocalizationProvider.
|
|
14
|
+
<link rel="modulepreload" crossorigin href="/assets/RbLocalizationProvider.Bjp-XasT.js">
|
|
15
15
|
<link rel="modulepreload" crossorigin href="/assets/index.B3zY1kf7.js">
|
|
16
|
-
<link rel="modulepreload" crossorigin href="/assets/useParsedPointCloudData.
|
|
17
|
-
<link rel="modulepreload" crossorigin href="/assets/index.
|
|
18
|
-
<link rel="modulepreload" crossorigin href="/assets/__federation_expose_App.
|
|
16
|
+
<link rel="modulepreload" crossorigin href="/assets/useParsedPointCloudData.By3wmxd4.js">
|
|
17
|
+
<link rel="modulepreload" crossorigin href="/assets/index.DKZKIW-y.js">
|
|
18
|
+
<link rel="modulepreload" crossorigin href="/assets/__federation_expose_App.BoAD7rmq.js">
|
|
19
19
|
|
|
20
20
|
|
|
21
21
|
|
package/package.json
CHANGED
package/serve.mjs
CHANGED
|
@@ -21,6 +21,11 @@ const pluginDir = arg("plugin", "")
|
|
|
21
21
|
: "";
|
|
22
22
|
const socketUrl = arg("socket-url", "");
|
|
23
23
|
const robotHost = arg("robot-host", "");
|
|
24
|
+
const robotPort = arg("robot-port", "");
|
|
25
|
+
const robotGatewayPort = arg("robot-gateway-port", "");
|
|
26
|
+
// The Muscat Sim launcher sets this: it suppresses real-robot onboarding (e.g. the initial
|
|
27
|
+
// robot-info registration modal), which makes no sense against a simulator.
|
|
28
|
+
const sim = process.argv.includes("--sim");
|
|
24
29
|
const devServerUrl = arg("dev-server-url", "");
|
|
25
30
|
const PLUGIN_BASE = "/plugin-dev";
|
|
26
31
|
const RELOAD_PATH = "/__preview_reload";
|
|
@@ -87,6 +92,15 @@ if (robotHost) {
|
|
|
87
92
|
|
|
88
93
|
injectedLines.push(` window.__RB_ROBOT_HOST__ = ${JSON.stringify(robotHost)};`);
|
|
89
94
|
}
|
|
95
|
+
if (robotPort) {
|
|
96
|
+
injectedLines.push(` window.__RB_ROBOT_PORT__ = ${JSON.stringify(robotPort)};`);
|
|
97
|
+
}
|
|
98
|
+
if (robotGatewayPort) {
|
|
99
|
+
injectedLines.push(` window.__RB_ROBOT_GATEWAY_PORT__ = ${JSON.stringify(robotGatewayPort)};`);
|
|
100
|
+
}
|
|
101
|
+
if (sim) {
|
|
102
|
+
injectedLines.push(` window.__RB_SIM__ = true;`);
|
|
103
|
+
}
|
|
90
104
|
injectedLines.push(" </script>");
|
|
91
105
|
|
|
92
106
|
if (pluginDir) {
|
|
@@ -110,7 +124,14 @@ function sendFile(res, filePath, { noStore = false } = {}) {
|
|
|
110
124
|
if (noStore) res.setHeader("Cache-Control", "no-store");
|
|
111
125
|
const type = CONTENT_TYPE[extname(filePath)];
|
|
112
126
|
if (type) res.setHeader("Content-Type", type);
|
|
113
|
-
|
|
127
|
+
// An unreadable path (a directory, a file removed meanwhile) ends this response, not the server:
|
|
128
|
+
// a stream 'error' with no listener is thrown and takes the whole process down.
|
|
129
|
+
createReadStream(filePath)
|
|
130
|
+
.on("error", () => {
|
|
131
|
+
if (!res.headersSent) res.statusCode = 404;
|
|
132
|
+
res.end();
|
|
133
|
+
})
|
|
134
|
+
.pipe(res);
|
|
114
135
|
}
|
|
115
136
|
|
|
116
137
|
function tryServe(res, baseDir, relPath, opts) {
|
|
@@ -127,7 +148,8 @@ function tryServe(res, baseDir, relPath, opts) {
|
|
|
127
148
|
// models/ (URDF + meshes, ~800MB) isn't bundled — too large for npm. Each file is fetched from the
|
|
128
149
|
// kit's S3 copy on first use and kept in ~/.muscat-pk/models, so the 3D robot view works with any
|
|
129
150
|
// robot or a local core SW, and offline once a model has been seen.
|
|
130
|
-
//
|
|
151
|
+
// A cached file is checked against where it came from once per run (If-None-Match on the ETag kept
|
|
152
|
+
// beside it), so a model fixed upstream replaces the cached one; offline, the cached file is served.
|
|
131
153
|
// Tried in order: the kit's S3 copy, then the assets server (:5177) of the robot / local Muscat,
|
|
132
154
|
// which has the models that Muscat ships — so a model missing from S3 (or no internet) still shows.
|
|
133
155
|
const MODEL_SOURCES = [
|
|
@@ -141,16 +163,30 @@ const MODELS_CACHE = resolve(homedir(), ".muscat-pk", "models");
|
|
|
141
163
|
|
|
142
164
|
const unreachable = new Set(); // a source that didn't answer is skipped from then on
|
|
143
165
|
|
|
144
|
-
|
|
166
|
+
const checked = new Set(); // model files already compared with their source in this run
|
|
167
|
+
let noRecheck = false; // a recheck timed out: serve the cache for the rest of this run
|
|
168
|
+
|
|
169
|
+
// The file from the first source that has it: { data, tag } where tag is "<source>\n<etag>", "same"
|
|
170
|
+
// when `have` (the tag of the cached copy) still matches, or null when no source has it.
|
|
171
|
+
async function fetchModel(rel, have = null) {
|
|
145
172
|
const path = rel.split("/").map(encodeURIComponent).join("/");
|
|
173
|
+
const [haveBase, haveEtag] = have ? have.split("\n") : [];
|
|
146
174
|
for (const base of MODEL_SOURCES) {
|
|
147
175
|
if (unreachable.has(base)) continue;
|
|
148
176
|
try {
|
|
149
|
-
const r = await fetch(`${base}/${path}`, {
|
|
177
|
+
const r = await fetch(`${base}/${path}`, {
|
|
178
|
+
headers: haveEtag && base === haveBase ? { "If-None-Match": haveEtag } : {},
|
|
179
|
+
signal: AbortSignal.timeout(have ? 5_000 : 15_000),
|
|
180
|
+
});
|
|
181
|
+
if (r.status === 304) return "same";
|
|
150
182
|
// 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"))
|
|
152
|
-
|
|
153
|
-
|
|
183
|
+
if (r.ok && !(r.headers.get("content-type") ?? "").startsWith("text/html"))
|
|
184
|
+
return { data: Buffer.from(await r.arrayBuffer()), tag: `${base}\n${r.headers.get("etag") ?? ""}` };
|
|
185
|
+
} catch (e) {
|
|
186
|
+
// A slow recheck must not make the source look gone for files that still need downloading.
|
|
187
|
+
if (have && e.name === "TimeoutError") noRecheck = true;
|
|
188
|
+
else unreachable.add(base);
|
|
189
|
+
if (have) return null;
|
|
154
190
|
}
|
|
155
191
|
}
|
|
156
192
|
return null;
|
|
@@ -164,17 +200,28 @@ async function serveModel(res, url) {
|
|
|
164
200
|
res.end();
|
|
165
201
|
return;
|
|
166
202
|
}
|
|
167
|
-
if (
|
|
168
|
-
|
|
169
|
-
|
|
203
|
+
if (existsSync(file) && !statSync(file).isFile()) {
|
|
204
|
+
res.statusCode = 404; // a model folder, not a file in it
|
|
205
|
+
res.end();
|
|
206
|
+
return;
|
|
207
|
+
}
|
|
208
|
+
const cached = existsSync(file);
|
|
209
|
+
const tagFile = `${file}.etag`;
|
|
210
|
+
if (!cached || (!checked.has(rel) && !noRecheck)) {
|
|
211
|
+
checked.add(rel);
|
|
212
|
+
const have = cached ? (existsSync(tagFile) ? readFileSync(tagFile, "utf8") : "\n") : null;
|
|
213
|
+
const got = await fetchModel(rel, have);
|
|
214
|
+
if (got && got !== "same") {
|
|
215
|
+
mkdirSync(dirname(file), { recursive: true });
|
|
216
|
+
const part = `${file}.${process.pid}.part`;
|
|
217
|
+
writeFileSync(part, got.data);
|
|
218
|
+
renameSync(part, file);
|
|
219
|
+
writeFileSync(tagFile, got.tag);
|
|
220
|
+
} else if (!cached) {
|
|
170
221
|
res.statusCode = 404;
|
|
171
222
|
res.end(`model file not found: ${rel}`);
|
|
172
223
|
return;
|
|
173
224
|
}
|
|
174
|
-
mkdirSync(dirname(file), { recursive: true });
|
|
175
|
-
const part = `${file}.${process.pid}.part`;
|
|
176
|
-
writeFileSync(part, data);
|
|
177
|
-
renameSync(part, file);
|
|
178
225
|
}
|
|
179
226
|
sendFile(res, file);
|
|
180
227
|
}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{j as g,co as F,U as V,a$ as K,x as _,bg as Y,cx as Q,e_ as x,el as E,gf as X,de as P,ek as M,cv as Z,gN as u}from"./RbLocalizationProvider.C7JmvgEO.js";import{importShared as k}from"./__federation_fn_import.DdkEuT6t.js";const J=()=>!0,ee=()=>J()&&!L(),L=()=>typeof window<"u"&&window.__RB_ROBOT_HOST__||void 0||void 0,te=()=>ee(),ye=(e,t)=>e?.find(s=>s.point===t),_e=(e,t)=>{if(typeof e=="string")return e;const s=String(t);return e?.[s]},Pe=(e,t)=>{if(typeof e=="string")return e;const s=String(t);return e?.[s]||e?.en},Me=e=>e.toLocaleLowerCase()==="rainbowrobotics",Ue=e=>e===void 0?"—":`${e.toFixed(1)}%`,be=e=>{if(e===void 0)return"—";const t=e/1024/1024;return t<1024?`${Math.round(t)} MB`:`${(t/1024).toFixed(1)} GB`};var y=(e=>(e[e.SUPERVISOR=0]="SUPERVISOR",e[e.ADMIN=1]="ADMIN",e[e.MANAGER=2]="MANAGER",e[e.OPERATOR=3]="OPERATOR",e[e.USER=4]="USER",e[e.GUEST=999999]="GUEST",e))(y||{});const we={SUPERVISOR:0,ADMIN:1,MANAGER:2,OPERATOR:3,USER:4,GUEST:999999};function v(e){try{const t=e.split(".")[1].replace(/-/g,"+").replace(/_/g,"/");return JSON.parse(atob(t))}catch{return null}}function U(e){if(!e)return null;const t=v(e);return t?t.exp*1e3:null}function O(){const e=c();return e?v(e)?.sid??"":""}const o={isAutoLogin:"isAutoLogin",accessToken:"access_token",refreshToken:"refresh_token"};function A(){localStorage.removeItem(o.accessToken),localStorage.removeItem(o.refreshToken),sessionStorage.removeItem(o.accessToken),sessionStorage.removeItem(o.refreshToken)}function h(){return localStorage.getItem(o.isAutoLogin)==="true"}function xe(e){localStorage.setItem(o.isAutoLogin,e?"true":"false")}function c(){return h()?localStorage.getItem(o.accessToken):sessionStorage.getItem(o.accessToken)}function p(){return h()?localStorage.getItem(o.refreshToken):sessionStorage.getItem(o.refreshToken)}function se(e,t,s){s?(localStorage.setItem(o.isAutoLogin,"true"),localStorage.setItem(o.accessToken,e),localStorage.setItem(o.refreshToken,t)):(localStorage.setItem(o.isAutoLogin,"false"),sessionStorage.setItem(o.accessToken,e),sessionStorage.setItem(o.refreshToken,t))}const{useQuery:ne}=await k("@tanstack/react-query"),N="/auth/me",oe=[N],re=()=>z.get(N,{}),ae=({enabled:e})=>ne({queryKey:oe,queryFn:re,enabled:e}),{createContext:ie,useCallback:ce,useContext:ue,useEffect:C,useState:le}=await k("react"),de={id:"GUEST",username:"게스트",role:y.SUPERVISOR,sid:""},G=ie({isLoggedIn:!1,setLoggedIn:()=>{}});let T=null;function D(e){T?.(e)}function ve({children:e}){const[t,s]=le(!!c()),n=ce(r=>{s(r)},[]);return C(()=>(T=n,()=>{T=null}),[n]),g(G.Provider,{value:{isLoggedIn:t,setLoggedIn:n},children:e})}function fe(){const{isLoggedIn:e,setLoggedIn:t}=ue(G),s=c(),n=p(),r=h(),{data:a}=ae({enabled:e}),i=a?{id:a.user_id,username:a.username??a.user_id,role:a.role??y.GUEST,sid:O()}:de;return C(()=>{const f=!!s&&!!n;e!==f&&t(f)},[e,s,n,t]),{isLoggedIn:e,setLoggedIn:t,user:i,accessToken:s,refreshToken:n,isAutoLogin:r,isAtLeast:f=>i.role<=f,hasRole:f=>i.role===f}}const ge=({className:e,open:t,onOpenChange:s,onConfirm:n})=>{const{t:r}=F(),a=()=>{s(!1),n()};return g(Y,{className:_(e,"w-100 max-w-full border-none p-0"),enableDimClose:!1,hideCloseButton:!0,open:t,onOpenChange:s,header:{title:r("login.modal.title.sessionExpired")},footer:g(V,{className:_("w-full gap-1","[&_button]:h-8 [&_button]:w-20"),justifyContent:"end",children:g(K,{variant:"brand",size:"sm",onClick:a,children:r("login.modal.button.sessionExpiredConfirm")})}),children:g("div",{className:"px-4 pt-3 pb-0",children:g("span",{className:"text-fg-default typo-compact-sm-normal",children:r("login.modal.desc.sessionExpired")})})})},Oe="/muscat/app/log",R="/muscat/app/login",{useMutation:me}=await k("@tanstack/react-query"),he="/logout",$=async e=>z.post(he,{sid:e}),Ne=()=>{const{setLoggedIn:e,user:t}=fe(),s=Q();return me({mutationFn:async()=>{if(t?.sid)return $(t.sid)},onSettled:()=>{A(),e(!1),s(R)}})},pe=x(L()||window.location.hostname,void 0),Se=1e4,Ae=1e4,b=5e3;let j=null,H=null;function Ce(e){j=e}function Ge(e){H=e}let I=!1,B=0;function Ee(){return!!(I||Date.now()-B<Se)}const w=()=>{if(window.location.pathname===R)return;const e=async()=>{const t=O();if(t)try{await $(t)}catch{}A(),D(!1),H?.(R)};X.openModal({component:ge,props:{onConfirm:e,onClose:e},options:{componentName:"SessionExpiredModal"}})};async function W(){if(Ee())return null;const e=p();if(!e)return w(),null;I=!0;try{const t=await E.post(`${pe}/common/refresh`,{refresh_token:e}),{access_token:s,refresh_token:n}=t.data;return se(s,n,h()),D(!0),j?.("auth",{token:s,autoLogin:h()?"true":"false"}),B=Date.now(),S(),s}catch(t){console.log("Token refresh failed:",t);const s=E.isAxiosError(t)?t.response?.status:null;if(s===403||s===401||s===409)return A(),w(),null;throw t}finally{I=!1}}let m=null;function q(){m&&(clearTimeout(m),m=null)}function S(){q();const e=U(c());if(!e)return;const t=Math.max(e-Date.now(),0),s=Math.min(Math.max(e-Date.now()-Ae,b),t);m=setTimeout(async()=>{try{if(!p())return;!await W()&&p()&&S()}catch{if(c()){const n=U(c());if(n&&n>Date.now()){const r=Math.min(b*2,n-Date.now());r>0&&(m=setTimeout(S,r))}}}},s)}window.addEventListener("storage",e=>{e.key!==o.accessToken&&e.key!==o.refreshToken||(c()&&p()?S():q())});const l={onRequest({config:e}){if(e.url?.endsWith("/login")||e.url?.endsWith("/logout")||e.url?.endsWith("/refresh")||/^https?:\/\//i.test(e.url??"")&&!e.url?.startsWith(e.baseURL??""))return e;const n=c();return n&&e.headers&&(e.headers.Authorization=`Bearer ${n}`),e},onResponse({response:e}){return e?.data},async onResponseError({error:e}){const t=e.config;if(!t)return Promise.reject(e);if(t.url?.endsWith("/login")||t.url?.endsWith("/logout")||t.url?.endsWith("/refresh"))return A(),Promise.reject(e);if(e.response?.status===401&&!t._retry){t._retry=!0;try{const i=await W();return i?(t.headers.Authorization=`Bearer ${i}`,E(t)):Promise.reject(e)}catch(i){return Promise.reject(i)}}const n=e?.response?.data;P("useSimulator")!=="false"&&P("useSimulator");const r=typeof n=="object"&&"message"in n&&typeof n.message=="string"?n.message:M("common.toast.apiError.content"),a=e.status??e.response?.status;return[502,504].includes(a)||e.code==="ERR_NETWORK"||te()||t.skipErrorToast||Z.openToast({title:e.config.url?`[API Error] ${e.config.url}`:M("common.toast.apiError.title"),content:r,type:"basic",variant:"warning"}),Promise.reject(e)}},Te=3e3,d=x(L()||window.location.hostname,Te),z=u({baseURL:`${d}/common`},l),De=u({baseURL:`${d}/manipulate`},l),$e=u({baseURL:`${d}/log`},l),je=u({baseURL:`${d}/amr`},l),He=u({baseURL:`${d}/rby1`},l);u({baseURL:`${d}/deploy`},l);const Be=u({baseURL:`${d}/host`},l);export{S as A,xe as B,A as C,$ as D,ve as E,y as J,Oe as L,d as M,we as R,je as a,c as b,z as c,L as d,_e as e,ye as f,h as g,Be as h,ee as i,J as j,Pe as k,$e as l,De as m,Ue as n,be as o,R as p,Ne as q,He as r,Ce as s,W as t,fe as u,q as v,Ge as w,oe as x,Me as y,se as z};
|