frontend-patterns/research/experiments/feature-release/host.js
tegwick e34ec3fafe Exercise feature activation rollback and old-session artifact retention
Assistant: codex
Assistant-Model: gpt-6-astra
Assistant-Session: 01a0cffe-206f-7323-89d3-b20ca4cf4bf9
2026-09-26 23:14:34 +02:00

29 lines
1.3 KiB
JavaScript

const HOST_API = 1;
window.observed = {mounts: [], errors: [], evaluations: [], hostApi: HOST_API};
const report = document.getElementById('reports');
const account = document.getElementById('account');
async function load(name, target) {
try {
const feature = name === 'reports' ? await import('reports') : await import('account');
// Compatibility gate, not a security boundary: module evaluation already happened.
if (feature.hostApi !== HOST_API) throw new Error('incompatible host API');
feature.mount(target);
window.observed.mounts.push({name, version: feature.version});
return {ok: true, version: feature.version};
} catch (error) {
target.textContent = `${name} unavailable`;
window.observed.errors.push({name, message: error.message});
return {ok: false, message: error.message};
}
}
window.loadReports = () => load('reports', report);
window.loadAccount = () => load('account', account);
try {
await import('shared');
for (const button of document.querySelectorAll('button')) button.disabled = false;
document.getElementById('status').textContent = 'ready';
} catch {
document.getElementById('status').textContent = 'startup failed';
}
document.getElementById('reports-nav').onclick = window.loadReports;
document.getElementById('account-nav').onclick = window.loadAccount;