4 lines
2.7 KiB
JavaScript
4 lines
2.7 KiB
JavaScript
/*! third party licenses: js/vendor.LICENSE.txt */
|
||
import{r as n,R as t,l as A}from"./whiteboard-main.mjs";import{t as l}from"./translation-DoG5ZELJ-DKBzIEvm.chunk.mjs";import{u as S,I as N,M as C,i as T,s as j}from"./percentages-BXMCSKIN-Cw9SI0WV.chunk.mjs";import"./index-Anv74-sp.chunk.mjs";import"./vendor-BeFBwUwf.chunk.mjs";import"./index-Bn0s6V7w.chunk.mjs";const I=n.memo(N),M=e=>Array.isArray(e)?C(e,null):[],O=e=>e&&typeof e=="object"?e:{},V=e=>{const r={...T.appState};if(!e||typeof e!="object")return r;const a=j(e);return{...r,...a}},F=e=>{try{return new URL(e,window.location.origin).toString()}catch{return e}};function L({fileName:e,versionSource:r,fileVersion:a}){const[m,c]=n.useState(null),[p,d]=n.useState(null),[v,u]=n.useState(!1),{theme:g}=S(),h=n.useMemo(()=>document.documentElement.lang||"en",[]);n.useEffect(()=>{if(!r){d(l("whiteboard","This version is missing its source file")),c(null);return}const o=new AbortController;return(async()=>{u(!0),d(null);try{const i=await fetch(F(r),{method:"GET",credentials:"include",signal:o.signal,headers:{Accept:"application/json"}});if(!i.ok)throw new Error(`Unexpected response ${i.status}`);const f=await i.text();if(o.signal.aborted)return;let s={};if(f.trim().length>0)try{s=JSON.parse(f)}catch{throw new Error("Failed to parse version JSON")}const b=M(s.elements),E=O(s.files),x=V(s.appState);c({elements:b,files:E,appState:x,scrollToContent:s.scrollToContent??!0})}catch(i){if(o.signal.aborted)return;A.error("[ReadOnlyViewer] Failed to load scene",i),d(l("whiteboard","Could not load this version")),c(null)}finally{o.signal.aborted||u(!1)}})(),()=>{o.abort()}},[r]);const w=n.useMemo(()=>a?l("whiteboard","{fileName} – Version {version}",{fileName:e,version:a}):e,[e,a]);if(p)return t.createElement("div",{className:"App App--version-preview",style:{display:"flex",alignItems:"center",justifyContent:"center"}},t.createElement("div",null,p));if(v||!m)return t.createElement("div",{className:"App",style:{display:"flex",flexDirection:"column"}},t.createElement("div",{className:"App-loading",style:{flex:1,display:"flex",alignItems:"center",justifyContent:"center"}},l("whiteboard","Loading version...")));const y={changeViewBackgroundColor:!1,clearCanvas:!1,export:!1,loadScene:!1,saveAsImage:!1,saveToActiveFile:!1,toggleTheme:!1};return t.createElement("div",{className:"App App--version-preview",style:{display:"flex",flexDirection:"column"}},t.createElement("div",{className:"excalidraw-wrapper",style:{flex:1,height:"100%",position:"relative"}},t.createElement(I,{initialData:m,viewModeEnabled:!0,zenModeEnabled:!1,gridModeEnabled:!1,theme:g,name:w,UIOptions:{canvasActions:y},langCode:h})))}export{L as default};
|
||
//# sourceMappingURL=ReadOnlyViewer-BHxi7oIo.chunk.mjs.map
|