Quickly discover which web apps are running on the page and the React version they depend on.
Running multiple versions of React on the same page is inefficient and can increase load times. Use this tool to quickly spot outdated apps and identify which ones should be updated to reduce overhead.
const versionsText =(()=>{ switch(loadedVersions.length){ case0: return"Could not find any React version at all, which is probably good."; case1: return`Found one version of React (${loadedVersions[0]}) which is good. This means that you are not loading multiple versions, which would have resulted in a heavier page load.`; default: return`Found multiple versions of React (${loadedVersions.join(', ')}) which is bad. This most likely results in a heavier page load for the users.`; } })(); container.appendChild(createElement(`<p>${versionsText}</p>`));
let first =true; for(const group of groupedApps){ const{ hasReactVersion }= group; container.appendChild(createElement(` <table class="env-table env-table--zebra env-table--small env-w--100 ${first ?'':'env-m-top--large'}"> <caption>${group.title}</caption> <thead><tr><th>App identifier</th><th>App version</th>${hasReactVersion ?'<th>React version</th>':''}</tr></thead> <tbody>${group.items.map(({ appId, appVersion, reactVersion })=> `<tr><td>${appId}</td><td>${appVersion}</td>${hasReactVersion ?`<td>${reactVersion}</td>`:''}</tr>`).join('')} </tbody> </table> `)); first =false; }
/** * Creates the HTML markup for an envision dialog. * * @param {object} options An object literal with options. * @param {string} options.dialogId A unique html ID for the dialog. * @param {string} options.title * @returns {string} */
/** * Shortcut for Document.getElementById() for improved minification. * * @param {string} id An identifier for an HTMLElement. * @returns {(HTMLElement|null)} */ el(id){ returnDOCUMENT.getElementById(id); }
/** * Initializes the dialog if it hasn't already been initialized. * * @param {(Function|String|HTMLElement)} initialContent * @returns {Dialog} Returns self for chainability. */ asyncinit(initialContent){ const dialogId =this.id; const titleId =this.tid;
onClose(callback){ if(typeof callback ==='function'){ // TODO: should probably start using new Dialog api instead of old ModalDialog so we can // remove jQuery as a dependency. jQuery('#'+this.id).on('hide.env-modal-dialog',(e)=>{ callback.call(null,this, e); }); }
returnthis; }
onClosed(callback){ if(typeof callback ==='function'){ // TODO: should probably start using new Dialog api instead of old ModalDialog so we can // remove jQuery as a dependency. jQuery('#'+this.id).on('hidden.env-modal-dialog',(e)=>{ callback.call(null,this, e); }); }
/** * Returns version as array of integers. Assumes no text suffix with hyphen exists in string. * * @param {string} versionString * @ * @returns {number[]} */ exportconstparseVersion=(versionString)=> versionString.split('.').map((part)=>parseInt(part,10));
/** * Sort callback for comparing and sorting semver strings. * * @param {string} versionStringA * @param {string} versionStringB * @returns */ exportconstcompareSemver=(versionStringA, versionStringB)=>{ const pa =parseVersion(versionStringA); const pb =parseVersion(versionStringB); const n = Math.max(pa.length, pb.length);
for(let i =0; i < n; i++){ const na = pa[i]||0; const nb = pb[i]||0;