generated from adobe/aem-boilerplate
-
Notifications
You must be signed in to change notification settings - Fork 1
/
unifiedshell-runtime-loader.min.js
1 lines (1 loc) · 1.73 KB
/
unifiedshell-runtime-loader.min.js
1
!function(e,t){const n="exc-module-runtime";t.config&&(t.config.mrlv="mrl:692fe126");const o=t.parent;if(t.location===o.location)throw new Error("Module Runtime: Needs to be within an iframe!");if(t[n]&&t[n].Runtime)return;try{if(!t[n]&&o[n]&&o[n].bootstrapRuntime)return o[n].bootstrapRuntime(t,((e,t)=>o.postMessage(e,t)))}catch{}let r=function(e){const t=new URL(e.location.href).searchParams.get("_mr");return t||!e.EXC_US_HMR?t?decodeURIComponent(t):t:e.sessionStorage.getItem("unifiedShellMRScript")}(t);if(!r)throw new Error("Module Runtime: Missing script!");if(r.startsWith("http")){if(r=new URL(r),"https:"!==r.protocol)throw new Error("Module Runtime: Must be HTTPS!");if(!/^(exc-unifiedcontent\.|cdn\.)?experience(-qa|-stage)?\.adobe\.(com|net)$/.test(r.hostname)&&!/localhost\.corp\.adobe\.com$/.test(r.hostname))throw new Error("Module Runtime: Invalid domain!");if(!/\.js$/.test(r.pathname))throw new Error("Module Runtime: Must be a JavaScript file!")}else r=function(e){const[n,o,r]=e.split("_"),i={p:"",q:"-qa",s:"-stage"};if(!r||!["q","s","p"].includes(n)||!["fd","cf"].includes(o))throw new Error("Module Runtime: Invalid Parameter!");const s=r.endsWith(".js")?r:`${r}.js`;let a=t._srp?.resourceURL;return a||(a="https://","q"!==n&&(a=`${a}${"cf"===o?"cdn.":"exc-unifiedcontent."}`),a=`${a}experience${i[n]}.adobe.net`),`${a}/assets/${s}`}(r);t.EXC_US_HMR&&t.sessionStorage.setItem("unifiedShellMRScript",r.toString());let i=e.createElement("script");i.async=!0,i.src=r.toString(),i.onload=i.onreadystatechange=function(){i.readyState&&!/loaded|complete/.test(i.readyState)||(i.onload=i.onreadystatechange=null,i=void 0,"EXC_MR_READY"in t&&t.EXC_MR_READY())},t._srp?.handleError&&(i.onerror=t._srp.handleError),e.head.appendChild(i)}(document,window);