1/*** 2 * Deployed loader â fetches per-remote pointer files and loads versioned artifacts. 3 * Owned here (deployer ConfigMap), mounted into the Fastify container's public/. 4 * Wrapped in an IIFE: this and loadCss.js are both classic (non-module) scripts 5 * sharing the global scope, so top-level `const CDN_URL` etc. would otherwise 6 * collide ("Identifier already declared"). The IIFE gives each file its own scope. 7 ***/ 8(() => { 9 const GLOBAL_CDN_URL = "https://static.myqnapcloud.com"; 10 const CHINA_CDN_URL = "https://static.myqnapcloud.cn"; 11 const CDN_URL = window.location.hostname?.toLocaleLowerCase().endsWith('cn') ? CHINA_CDN_URL : GLOBAL_CDN_URL; 12 13 const REMOTES = ['common', 'account', 'auth', 'root']; 14 15 function loadScript(source, { id = null, defer = false, async = false } = {}) { 16 const script = document.createElement('script'); 17 script.src = source; // no ?t= â versioned path is immutable 18 if (id) script.id = id; 19 if (defer) script.defer = defer; 20 if (async) script.async = async; 21 return new Promise((resolve, reject) => { 22 script.onload = resolve; 23 script.onerror = reject; 24 document.head.appendChild(script); 25 }); 26 } 27 28 async function fetchPointers() { 29 const records = await Promise.all(REMOTES.map(async (r) => { 30 const res = await fetch(`${CDN_URL}/acc-mf/versions/${r}.json`, { cache: 'no-cache' }); 31 if (!res.ok) throw new Error(`pointer ${r} â HTTP ${res.status}`); 32 const rec = await res.json(); 33 if (!rec.deployId) throw new Error(`pointer ${r} missing deployId`); 34 return [r, rec]; 35 })); 36 const byRemote = Object.fromEntries(records); // { common: {deployId,version,commit,builtAt}, ... } 37 // Expose deployed versions for RD/QA to inspect in the browser console on the 38 // regular domain â `window.acc_mf.versions` (replaces the old window.Versions habit). 39 // env-config.js appends .common/.account/.auth to the same object, so preserve it. 40 window.acc_mf = window.acc_mf || {}; 41 window.acc_mf.versions = byRemote; 42 return Object.fromEntries(REMOTES.map((r) => [r, byRemote[r].deployId])); // { common:'<id>', ... } 43 } 44 45 function base(remote, ver) { return `${CDN_URL}/acc-mf/${remote}/${ver[remote]}`; } 46 47 async function loadModules() { 48 const ver = await fetchPointers(); 49 await loadScript(`${base('common', ver)}/env-config.js`); 50 // reCAPTCHA is an independent third-party script (often blocked by ad-blockers). 51 // Fire-and-forget with a non-fatal catch â it must NOT block the MF bootstrap 52 // (matches the original loader's effective non-blocking behavior). 53 loadScript(`${CDN_URL}/acc-mf/recaptcha/enterprise.js`, { id: 'reCaptcha', async: true }) 54 .catch((e) => console.warn('[loadModules] reCAPTCHA load failed (non-fatal)', e)); 55 await Promise.all([ 56 loadScript(`${base('account', ver)}/env-config.js`), 57 loadScript(`${base('auth', ver)}/env-config.js`), 58 ]); 59 await Promise.all([ 60 loadScript(`${base('common', ver)}/remoteEntry.js`, { id: 'common' }), 61 loadScript(`${base('account', ver)}/remoteEntry.js`, { id: 'account' }), 62 loadScript(`${base('auth', ver)}/remoteEntry.js`, { id: 'auth' }), 63 ]); 64 await loadScript(`${base('root', ver)}/main.js`, { id: 'main' }); 65 } 66 67 loadModules().catch((error) => console.error('[loadModules] failed', error)); 68})();
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.