Publish Federal Reserve currency collection and editorial menu controls

This commit is contained in:
unimatrixgit 2026-11-15 16:47:21 +01:00
commit db61e7ad6c
6 changed files with 432 additions and 200 deletions

View file

@ -9,7 +9,7 @@ const oldIds=new Set(Object.keys(JSON.parse(oldSource.slice(start,oldSource.inde
const oldLayout=await readFile(new URL('../control-panel/public/panel-layout.mjs',import.meta.url),'utf8');for(const match of oldLayout.matchAll(/item\([^,]+,'([^']+)'/g))oldIds.add(match[1]);
for(const id of ['dev-panel','dev-queue','dev-approvals','dev-new','dev-archive'])oldIds.add(id);
export const designAliases={'realm/company-directory':'realm/companies','realm/company-registration':'realm/companies','realm/company-profile':'realm/companies','realm/company-members':'realm/companies','realm/company-finance':'realm/companies','realm/company-permissions':'realm/companies','realm/company-applications':'realm/companies','market/company-directory':'market/companies','market/company-profile':'market/companies'};
const implementedBankPages=new Set(['bank-authorisations','federal-reserve']);
const implementedBankPages=new Set(['bank-authorisations','federal-reserve','dunemark-collection']);
export function auditDesign(){return menu.workspaces.flatMap(w=>w.groups.flatMap(g=>g.items.map(item=>{const key=w.id+'/'+item.id,design=DESIGN_PAGES[key],preserved=['quests','kits'].includes(w.id)||w.id==='clan'&&!['clan-campaigns','clan-quests'].includes(item.id)||w.id==='bank'&&(item.id==='bank-information'||implementedBankPages.has(item.id))||w.id==='politics'||w.id==='market'&&['commodity-listings','commodity-mine'].includes(item.id)||w.id==='bureau'&&item.id!=='kit-claims'||w.id==='forge'&&['dev-panel','dev-queue','dev-approvals','dev-new','dev-archive','git-workspace','git-repositories','git-administration'].includes(item.id);return{workspace:w.label,group:g.label,key,title:item.label,existedInV1:oldIds.has(item.id),classification:w.id==='events'||['clan-campaigns','clan-quests'].includes(item.id)?'planned-placeholder':design?'new-design-only':preserved?'preserved-implemented':oldIds.has(item.id)?'v1-integration-next':'needs-design-spec',tabs:design?.tabs.map(t=>t.label)||[],fields:design?[...new Set(design.tabs.flatMap(t=>t.fields.map(f=>f.label)))]:[]};})));}
export async function writeDesignAudit(destination){const rows=auditDesign(),summary={menus:rows.length,designed:rows.filter(r=>r.classification==='new-design-only').length,integrationNext:rows.filter(r=>r.classification==='v1-integration-next').length,preserved:rows.filter(r=>r.classification==='preserved-implemented').length,uncovered:rows.filter(r=>r.classification==='needs-design-spec').map(r=>r.key),featureTabs:Object.values(DESIGN_PAGES).reduce((n,p)=>n+p.tabs.length,0)};await mkdir(destination,{recursive:true});await writeFile(path.join(destination,'design-batch.json'),JSON.stringify({summary,rows,aliases:designAliases},null,2));const lines=['DUNEREALMS V2 — NEW PAGE DESIGN BATCH','Design only. No API integration or live business changes.','',JSON.stringify(summary,null,2),''];for(const workspace of menu.workspaces){lines.push(workspace.label);for(const r of rows.filter(r=>r.workspace===workspace.label)){lines.push(' '+r.title+' ['+r.classification+'] — '+r.key);if(r.tabs.length)lines.push(' Tabs: '+r.tabs.join(' | '));}lines.push('');}lines.push('COMPANY BOOKMARK ALIASES');for(const [from,to]of Object.entries(designAliases))lines.push(from+' -> '+to);await writeFile(path.join(destination,'design-batch.txt'),lines.join('\n'));return summary;}
if(process.argv[1]&&path.resolve(process.argv[1])===fileURLToPath(import.meta.url)){const result=await writeDesignAudit(process.argv[2]||'output/cp-v2-design-batch');console.log(JSON.stringify(result));if(result.uncovered.length)process.exitCode=1;}

View file

@ -1,15 +1,15 @@
import {readFileSync,writeFileSync} from 'node:fs';
import {renderDunemarkCollection} from '../control-panel/public/cp-v2/dunemark-catalogue.mjs';
import {updatePortalNavigation} from './portal-navigation.mjs';
const web=new URL('../web/',import.meta.url);
const series=[[1,'Stilgar','Desert stewardship and water cisterns'],[5,'Aliah','Ceremonial archives and celestial instruments'],[100,'Mira Vesk','Cartography, caravans and reservoirs'],[1000,'Ghanima','Imperial astronomy and gardens'],[5000,'Leto','An imagined game victory over House Harkonnen']];
const cards=series.map(([value,name,scene])=>`<figure class="dunemark-banknote" id="dunemark-${value}"><a href="assets/dunemark-${value}.webp" target="_blank" rel="noopener"><img src="assets/dunemark-${value}.webp" alt="Front and reverse of the ${value}-Dunemark note: Minecraft-style ${name}, ${scene.toLowerCase()}, and the original imperial seal" loading="lazy" width="1920" height="818"></a><figcaption><img class="currency-note-icon" src="assets/dunemark-${value}-icon-128.png" alt="${value}-Dunemark GUI icon" width="48" height="48"><strong>${value.toLocaleString('en')} Dunemarks · ${name}</strong> — ${scene}. Vaerkring Reserve.<br><a href="assets/dunemark-${value}-icon-64.png" download>64px transparent GUI icon</a> · <a href="assets/dunemark-${value}-icon-128.png" download>128px icon</a> · <a href="assets/dunemark-${value}.webp" download>Full note artwork</a></figcaption></figure>`).join('');
const zero='<h3>0 Dunemarks · In the search for Leto II</h3><p>A separate commemorative design. Not an in-game denomination, item, reward or redeemable note.</p><figure class="dunemark-banknote" id="dunemark-0"><a href="assets/dunemark-0-commemorative.webp" target="_blank" rel="noopener"><img src="assets/dunemark-0-commemorative.webp" alt="Commemorative zero-Dunemark front and reverse: Minecraft-style Leto II and a lantern-lit desert search party beneath twin moons" loading="lazy" width="1920" height="819"></a><figcaption>In the search for Leto II · Commemorative design · No cash value. <a href="assets/dunemark-0-commemorative.webp" download>Download the design →</a></figcaption></figure>';
const intro=`<section class="dunemark-art" id="dunemark-art"><div class="dunemark-heading"><img src="assets/imperial-seal-128.png" width="72" height="72" alt="Original imperial seal: crown, desert sun and dunes"><div><p class="eyebrow">VAERKRING RESERVE</p><h2>The Dunemark collection</h2></div></div><p>Five denominations, five distinctive designs. Parchment, deep teal and imperial gold connect the series; each note has its own Minecraft-style portrait, reverse scene and colour accents. The original crown, sun and dunes seal appears on every denomination.</p><p>${series.map(([v])=>`<a href="exchange.html#dunemark-${v}">${v.toLocaleString('en')} Dunemarks</a>`).join(' · ')}</p>${cards}${zero}<p>These are decorative game-currency designs with no cash value. They do not grant a balance, function as bearer tokens or replace the server’s currency ledger. The character editions are unofficial Dune fan artwork; the 5,000 scene is an imagined game interpretation, not a claim of book accuracy. No merchandise licence or rights-holder approval is implied.</p><p><a href="assets/imperial-seal.png" download>Download the original imperial seal →</a> · <a href="downloads/Dunemarks-ResourcePack-1.21.4.zip" download>Java GUI resource pack →</a></p></section>`;
const exchangeFile=new URL('exchange.html',web);
writeFileSync(exchangeFile,readFileSync(exchangeFile,'utf8').replace(/<section class="dunemark-art"[\s\S]*?<\/section>/g,''));
const manualFile=new URL('manual-data.json',web),chapters=JSON.parse(readFileSync(manualFile,'utf8'));
const currency=chapters.find(chapter=>chapter.id==='solaris-spice-sales-and-guild-travel');
const currency=chapters.find(c=>c.id==='solaris-spice-sales-and-guild-travel');
if(!currency)throw Error('Currency chapter missing');
currency.body=currency.body.replace(/<section class="dunemark-art"[\s\S]*?<\/section>/g,'');
currency.body=intro+currency.body;
currency.body=currency.body.replace(/<section class="dunemark-art"[\s\S]*?<\/section>/g,'').replace(/<p data-dunemark-collection>[\s\S]*?<\/p>/g,'');
currency.body='<p data-dunemark-collection><a href="https://cp.dunerealms.com/#bank/dunemark-collection">View the Dunemark Collection at Imperial Postbank →</a></p>'+currency.body;
writeFileSync(manualFile,JSON.stringify(chapters)+'\n');
const exchangeFile=new URL('exchange.html',web);let html=readFileSync(exchangeFile,'utf8').replace(/<section class="dunemark-art"[\s\S]*?<\/section>/g,'');
html=html.replace('</main>',intro+'</main>');writeFileSync(exchangeFile,html);
console.log('Built five Vaerkring Reserve denominations, icons and imperial seal');
const html='<!doctype html><html lang="en"><head><meta charset="utf-8"><meta name="viewport" content="width=device-width,initial-scale=1"><title>The Dunemark Collection · Imperial Postbank</title><link rel="stylesheet" href="styles.css"><link rel="stylesheet" href="dunemark-collection.css"></head><body><main class="dm-public"><header><p>FEDERAL IMPERIAL RESERVE</p><h1>The Dunemark Collection</h1><p><a href="https://cp.dunerealms.com/#bank/dunemark-collection">Open at Imperial Postbank →</a></p></header>'+'<!-- currency-artwork-start -->'+renderDunemarkCollection()+'<!-- currency-artwork-end -->'+'</main></body></html>';
writeFileSync(new URL('dunemark-collection.html',web),updatePortalNavigation(html));
console.log('Built Federal Imperial Reserve collection under Postbank; removed Exchange gallery.');

View file

@ -1,3 +1,4 @@
import {HOUSE_STYLE_CSS} from './house-style.mjs';
import {bankRatesPage} from './bank-rates-page.mjs';
import{withCanonicalMenu,MAIN_MENU}from'./main-menu.mjs';
import{recordPageUpdates,withMenuBadges}from'./menu-updates.mjs';
@ -31,7 +32,7 @@ function preparePublicHtml(html){
}
writeFileSync(path.join(web,'rates-and-charges.html'),bankRatesPage());
let assetCount=0;let assetWriter=null;const types={'.html':'text/html; charset=utf-8','.css':'text/css; charset=utf-8','.js':'text/javascript; charset=utf-8','.json':'application/json; charset=utf-8','.webp':'image/webp','.png':'image/png','.mp4':'video/mp4','.zip':'application/zip','.svg':'image/svg+xml'};
function collect(directory){for(const entry of readdirSync(directory).sort()){const p=path.join(directory,entry);if(statSync(p).isDirectory())collect(p);else{const relative=path.relative(web,p).split(path.sep).join('/');if(/^assets\/seals\/[^/]+-provenance\.txt$/.test(relative))continue;const type=types[path.extname(entry)];if(!type)throw Error('Unexpected asset: '+entry);const bytes=readFileSync(p);const payload=relative.endsWith('.html')?Buffer.from(preparePublicHtml(bytes.toString('utf8'))):relative==='portal-navigation.js'?Buffer.from(withCanonicalMenu(withMenuBadges(bytes.toString('utf8')))):bytes;writeSync(assetWriter,JSON.stringify('/'+relative)+':['+JSON.stringify(type)+','+JSON.stringify(payload.toString('base64'))+'],');assetCount++}}}if(existsSync(dist)){const resolved=path.resolve(dist);if(resolved!==path.join(root,'dist'))throw Error('Invalid dist directory');rmSync(resolved,{recursive:true,force:true})}
function collect(directory){for(const entry of readdirSync(directory).sort()){const p=path.join(directory,entry);if(statSync(p).isDirectory())collect(p);else{const relative=path.relative(web,p).split(path.sep).join('/');if(/^assets\/seals\/[^/]+-provenance\.txt$/.test(relative))continue;const type=types[path.extname(entry)];if(!type)throw Error('Unexpected asset: '+entry);const bytes=readFileSync(p);const payload=relative.endsWith('.html')?Buffer.from(preparePublicHtml(bytes.toString('utf8'))):relative==='portal-navigation.js'?Buffer.from(withCanonicalMenu(withMenuBadges(bytes.toString('utf8')))):relative==='portal-navigation.css'?Buffer.concat([bytes,Buffer.from(HOUSE_STYLE_CSS)]):bytes;writeSync(assetWriter,JSON.stringify('/'+relative)+':['+JSON.stringify(type)+','+JSON.stringify(payload.toString('base64'))+'],');assetCount++}}}if(existsSync(dist)){const resolved=path.resolve(dist);if(resolved!==path.join(root,'dist'))throw Error('Invalid dist directory');rmSync(resolved,{recursive:true,force:true})}
mkdirSync(path.join(dist,'server'),{recursive:true});mkdirSync(path.join(dist,'.openai'),{recursive:true});assetWriter=openSync(path.join(dist,'server/index.js'),'w');writeSync(assetWriter,'const ASSET_DATA={');collect(web);writeSync(assetWriter,'};\n');
let api=['feed-api.mjs','exchange-api.mjs','forum-api.mjs','community-api.mjs','portal-api.mjs'].map(file=>readFileSync(path.join(root,'worker',file),'utf8').replace(/export /g,'')).join('\n');let runtime=readFileSync(path.join(root,'worker/runtime.mjs'),'utf8').replace(/^import .*;$/gm,'');
writeSync(assetWriter,api+'\n'+runtime);closeSync(assetWriter);cpSync(path.join(root,'.openai/hosting.json'),path.join(dist,'.openai/hosting.json'));console.log('Built Worker with',assetCount,'embedded website assets');
@ -43,6 +44,7 @@ const shared=path.join(dist,'shared-chrome');mkdirSync(shared,{recursive:true});
for(const name of ['portal-navigation.js','portal-navigation.css','release.json','menu-new-items.json','rates-and-charges.html','bank-rates.css']){
let content=readFileSync(path.join(web,name));
if(name==='portal-navigation.js')content=Buffer.from(withCanonicalMenu(withMenuBadges(content.toString('utf8'))));
if(name==='portal-navigation.css')content=Buffer.concat([content,Buffer.from(HOUSE_STYLE_CSS)]);
if(name.endsWith('.html'))content=Buffer.from(preparePublicHtml(content.toString('utf8')));
writeFileSync(path.join(shared,name),content);
}

View file

@ -0,0 +1,14 @@
// Shared public-page finish. Native workspaces keep their approved local accents.
export const HOUSE_STYLE_CSS=`
/* DuneRealms public house style */
body.dune-public-page{--dune-bg:#0b241c;--dune-panel:#17392d;--dune-gold:#d2b66d;--dune-paper:#eee6ce;background-color:var(--dune-bg);color:var(--dune-paper)}
.dune-public-page main h1,.dune-public-page main h2,.dune-public-page main h3{font-family:Georgia,serif;color:#ead39b;line-height:1.25;overflow-wrap:anywhere}
.dune-public-page main h1 em,.dune-public-page main h2 em{color:#e3c678}
.dune-public-page main :is(.page-intro,.hero){border:1px solid #a58d50;border-radius:14px;background:linear-gradient(105deg,#1c3e30f2,#102d26e8),url('https://www.dunerealms.com/assets/sietch.webp') center/cover;padding:clamp(22px,3vw,42px);margin-bottom:28px}
.dune-public-page main :is(.panel,.response,.guide,.private,.stats>div){border-color:#7a8050;background-color:#143328;color:#e5e4cd}
.dune-public-page main :is(input,select,textarea){max-width:100%;box-sizing:border-box}
.dune-public-page main :is(pre,code){overflow-wrap:anywhere}.dune-public-page main pre{max-width:100%;overflow-x:auto}
.dune-public-page main :focus-visible{outline:3px solid #f0d392;outline-offset:3px}
.dune-public-page .account-example{max-width:1320px;margin:36px auto;padding:0 clamp(16px,3vw,36px)}
@media(max-width:650px){.dune-public-page main :is(.page-intro,.hero){border-radius:10px}.dune-public-page main h1{font-size:clamp(26px,8vw,42px)}}
`;

View file

@ -1,8 +1,8 @@
import {MAIN_MENU} from './main-menu.mjs';
import{existsSync,readFileSync,writeFileSync}from'node:fs';import{execFileSync}from'node:child_process';import{fileURLToPath}from'node:url';import path from'node:path';import{RELEASE_VERSION}from'./release-branding.mjs';
export function pagesForChanges(paths){const pages=new Set();for(let p of paths){p=p.replaceAll('\\','/');if(!p.includes('/tests/')){if(/^website\/(?:web\/portal-navigation\.(?:css|js)|scripts\/(?:portal-navigation|main-menu)\.mjs)$/.test(p))for(const [,href]of MAIN_MENU)pages.add(href);const scopes=[[/postbank|bank-rates/,'bank'],[/politic|election|charter/,'politics'],[/internal-mail|mail-service|post-pages/,'post'],[/organisation-|citizen-directory|account-admin|honours|permissions/,'bureau'],[/forge-pages|dev-request|git-identity/,'forge'],[/exchange-public|commodity/,'market'],[/passport|personal-records|user-pages/,'realm']];for(const [pattern,scope]of scopes)if(pattern.test(p)){pages.add('https://cp.dunerealms.com/');pages.add('https://cp.dunerealms.com/#'+scope);}}if(/website\/node\/staff-roster\.mjs$/.test(p))pages.add('https://www.dunerealms.com/staff.html');if(/website\/node\/memorials\.mjs$|website\/node\/public\/memorial\./.test(p))pages.add('https://www.dunerealms.com/');if(/website\/control-panel\//.test(p)||/website\/node\/(auth|permissions|account-admin|account-archive|honours|profile)\.mjs$/.test(p))pages.add('https://cp.dunerealms.com/');if(/website\/integrations\/azuriom\//.test(p))pages.add('https://www.dunerealms.com/shop.html');if(/website\/integrations\/osticket\//.test(p))pages.add('https://support.dunerealms.com/');if(/website\/web\/([a-z-]+)\.html$/.test(p)){const name=p.match(/([^/]+)\.html$/)[1];pages.add('https://www.dunerealms.com/'+(['index','portal'].includes(name)?'':name+'.html'));}}return[...pages].sort();}
export function recordPageUpdates({root=fileURLToPath(new URL('../',import.meta.url)),paths,newPages=[],version=RELEASE_VERSION}={}){if(!/^\d+(?:\.\d+){3}$/.test(version))throw Error('Invalid release');const repo=path.resolve(root,'..');const publication=path.join(root,'publication-changes.json');if(paths===undefined&&existsSync(publication)){const change=JSON.parse(readFileSync(publication,'utf8'));if(!Array.isArray(change.paths)||!Array.isArray(change.added))throw Error('Invalid publication change record.');paths=change.paths;newPages=pagesForChanges(change.added).filter(href=>!href.startsWith('https://cp.dunerealms.com/'));}if(paths===undefined){let changed='';try{const gitRoot=execFileSync('git',['rev-parse','--show-toplevel'],{cwd:repo,encoding:'utf8',stdio:['ignore','pipe','ignore']}).trim();if(path.resolve(gitRoot)===repo)changed=execFileSync('git',['diff','--name-only','HEAD'],{cwd:repo,encoding:'utf8'}).trim();}catch(error){if(error?.status!==128&&error?.status!==129&&error?.code!=='ENOENT')throw error;}paths=changed?changed.split('\n'):[];}const file=path.join(root,'web/menu-new-items.json'),data=JSON.parse(readFileSync(file,'utf8'));const pages=pagesForChanges(paths);if(paths.includes('website/web/release.json')){const releaseFile=path.join(root,'web/release.json');if(existsSync(releaseFile)){const release=JSON.parse(readFileSync(releaseFile,'utf8'));if(release.version===version&&Array.isArray(release.menuUpdates)){const allowed=new Set([...MAIN_MENU.map(([,href])=>href),...['realm','bureau','forge','politics','post','bank','market'].map(id=>'https://cp.dunerealms.com/#'+id)]);for(const update of release.menuUpdates){if(!allowed.has(update.href)||!['NEW','UPDATE'].includes(update.badge))throw Error('Invalid release menu highlight.');if(!pages.includes(update.href))pages.push(update.href);if(update.badge==='NEW'&&!newPages.includes(update.href))newPages.push(update.href);}}}}if(paths.length||existsSync(publication)){for(const item of data.items)delete item.badge;}for(const href of pages){let entry=data.items.find(x=>x.href===href);if(!entry){entry={href};data.items.push(entry);}entry.updatedIn=version;entry.badge=newPages.includes(href)?'NEW':'UPDATE';}writeFileSync(file,JSON.stringify(data,null,2)+'\n');return pages;}
export function menuBadgeScript(){const data=JSON.parse(readFileSync(new URL('../web/menu-new-items.json',import.meta.url),'utf8'));return `\n/* Central automatic release menu badges */\n(()=>{let items=${JSON.stringify(data.items)};function mark(){const release=document.querySelector('.dune-release-badge')?.textContent.match(/\\d+(?:\\.\\d+){3}/)?.[0];for(const a of document.querySelectorAll('header nav[aria-label="Main navigation"] a,#portals .portal[data-id]')){const href=a.matches('#portals .portal')?'https://cp.dunerealms.com/#'+a.dataset.id:a.href;const item=items.find(x=>x.href===href),label=['NEW','UPDATE'].includes(item?.badge)?item.badge:null;let tag=a.querySelector('.dune-new-overlay');if(label){if(!tag){tag=document.createElement('span');tag.className='dune-new-overlay';a.append(tag);}if(tag.textContent!==label)tag.textContent=label;tag.classList.toggle('dune-update-overlay',label==='UPDATE');tag.setAttribute('aria-label',label==='NEW'?'New this release':'Updated this release');}else if(tag)tag.remove();}}fetch('/menu-new-items.json',{cache:'no-store'}).then(r=>r.ok?r.json():null).then(data=>{if(Array.isArray(data?.items)){items=data.items;mark();}}).catch(()=>{});mark();new MutationObserver(mark).observe(document.body,{childList:true,subtree:true,characterData:true});})();\n`;}
export function recordPageUpdates({root=fileURLToPath(new URL('../',import.meta.url)),paths,newPages=[],version=RELEASE_VERSION}={}){if(!/^\d+(?:\.\d+){3}$/.test(version))throw Error('Invalid release');const repo=path.resolve(root,'..');const publication=path.join(root,'publication-changes.json');if(paths===undefined&&existsSync(publication)){const change=JSON.parse(readFileSync(publication,'utf8'));if(!Array.isArray(change.paths)||!Array.isArray(change.added))throw Error('Invalid publication change record.');paths=change.paths;newPages=pagesForChanges(change.added).filter(href=>!href.startsWith('https://cp.dunerealms.com/'));}if(paths===undefined){let changed='';try{const gitRoot=execFileSync('git',['rev-parse','--show-toplevel'],{cwd:repo,encoding:'utf8',stdio:['ignore','pipe','ignore']}).trim();if(path.resolve(gitRoot)===repo)changed=execFileSync('git',['diff','--name-only','HEAD'],{cwd:repo,encoding:'utf8'}).trim();}catch(error){if(error?.status!==128&&error?.status!==129&&error?.code!=='ENOENT')throw error;}paths=changed?changed.split('\n'):[];}const file=path.join(root,'web/menu-new-items.json'),data=JSON.parse(readFileSync(file,'utf8'));const pages=pagesForChanges(paths);if(paths.includes('website/web/release.json')){const releaseFile=path.join(root,'web/release.json');if(existsSync(releaseFile)){const release=JSON.parse(readFileSync(releaseFile,'utf8'));if(release.version===version&&Array.isArray(release.menuUpdates)){const allowed=new Set([...MAIN_MENU.map(([,href])=>href),...['realm','bureau','forge','politics','post','bank','market'].map(id=>'https://cp.dunerealms.com/#'+id)]);for(const update of release.menuUpdates){if(!allowed.has(update.href)||!['NEW','UPDATE'].includes(update.badge))throw Error('Invalid release menu highlight.');if(!pages.includes(update.href))pages.push(update.href);if(update.badge==='NEW'&&!newPages.includes(update.href))newPages.push(update.href);}}}}if(paths.length||existsSync(publication)){for(const item of data.items)delete item.badge;}for(const href of pages){let entry=data.items.find(x=>x.href===href);if(!entry){entry={href};data.items.push(entry);}entry.updatedIn=version;entry.badge=newPages.includes(href)?'NEW':'UPDATE';}if(data.headerBadges){for(const item of data.items){if(!item.href.includes('/#')){delete item.badge;if(['NEW','UPDATE'].includes(data.headerBadges[item.href]))item.badge=data.headerBadges[item.href];}}}writeFileSync(file,JSON.stringify(data,null,2)+'\n');return pages;}
export function menuBadgeScript(){const data=JSON.parse(readFileSync(new URL('../web/menu-new-items.json',import.meta.url),'utf8'));return `\n/* Central automatic release menu badges */\n(()=>{let items=${JSON.stringify(data.items)};function mark(){const release=document.querySelector('.dune-release-badge')?.textContent.match(/\\d+(?:\\.\\d+){3}/)?.[0];for(const a of document.querySelectorAll('header nav[aria-label="Main navigation"] a,#portals .portal[data-id]')){const href=a.matches('#portals .portal')?'https://cp.dunerealms.com/#'+a.dataset.id:a.href;const item=items.find(x=>x.href===href),label=['NEW','UPDATE'].includes(item?.badge)?item.badge:null;let tag=a.querySelector('.dune-new-overlay');if(label){if(!tag){tag=document.createElement('span');tag.className='dune-new-overlay';a.append(tag);}if(tag.textContent!==label)tag.textContent=label;tag.classList.toggle('dune-update-overlay',label==='UPDATE');tag.setAttribute('aria-label',label==='NEW'?'New this release':'Updated this release');}else if(tag)tag.remove();}}fetch('https://cp.dunerealms.com/api/menu-badges',{cache:'no-store'}).then(r=>r.ok?r.json():null).then(data=>{if(Array.isArray(data?.items)){items=data.items;mark();}}).catch(()=>{});mark();new MutationObserver(mark).observe(document.body,{childList:true,subtree:true,characterData:true});})();\n`;}
export function withMenuBadges(s){return s.replace(/\n?\/\* Central automatic release menu badges \*\/[\s\S]*?(?=\n\/\*|$)/,'').replace(/\(\(\)=>\{const items=\[[\s\S]*?new MutationObserver\(mark\)\.observe\(document.body,\{childList:true,subtree:true,characterData:true\}\);\}\)\(\);/,'')+menuBadgeScript();}
export function patchMenuBadges(root=fileURLToPath(new URL('../',import.meta.url))){const file=path.join(root,'web/portal-navigation.js');writeFileSync(file,withMenuBadges(readFileSync(file,'utf8')));}
if(process.argv[1]&&path.resolve(process.argv[1])===fileURLToPath(import.meta.url)){const pages=recordPageUpdates();patchMenuBadges();console.log('Central release badges updated for '+pages.length+' changed pages.');}

File diff suppressed because one or more lines are too long