In this section
- JavaScript V8 Fast Runtime energy-data · pipelinenews / ui/javascript/202608270055-v8-fast-runtime.js lines 673–862
- JavaScript V8 Live News Runtime energy-data · pipelinenews / ui/javascript/202608270844-v8-live-news-runtime.js lines 1–510
JavaScript V8 Fast Runtime
A JavaScript file in PipelineNews covering the Renewable Energy Planning Database (REPD) register, battery storage (BESS), solar and wind, using EPSG:27700 and SHA-256, and uses data from the GridAtlas repository.
energy-datapipelinenews / ui/javascript/202608270055-v8-fast-runtime.js · lines 673–862 of 862 · version 2026-08-27 00:55 (continued from section 1060) · Not reached from any entry point (candidate for review) · pattern ensureSearchSupplement (shared by 6 files)
- What it does
- It draws the REPD register, battery storage (BESS), solar and wind. Defines 48 functions or classes, including FetchQueue, escapeHtml, normalise, invariant, arraysEqual. Side effects: changes the web page (DOM); makes network requests.
- Why it exists in the grid workflow
- Domain stage upstream_foresight (repository name word 'pipelinenews'): upstream engineering foresight over GB transmission and distribution topology (TSO/DNO, 132kV and above, the REPD pipeline, data centres), which Ventus Ltd states it models for foresight. Domain terms in the code: the REPD register, battery storage (BESS), solar, wind.
- Inputs & outputs
- In: data source: gridatlas data. Coordinate systems named: OSGB36 / EPSG:27700 (British National Grid), WGS84 / EPSG:4326.
- What it achieves
- It fetches queue (`FetchQueue`), hashes JSON (`hashJson`) and fetches immutable (`fetchImmutable`). Its `downloadCsv` function gives CSV download or refusal from active table owner, filtered register rows and official detail partitions (VEDIC: export filtered projects). It responds to click, change and input events.
- Why it matters
- No other file in the estate was found to import it.
- Application
- pipelinenews · ui/javascript · script
- VEDIC
- EXPORT FILTERED PROJECTS (GG2050-VEDIC-000060): Pipeline News · Renewable project register. active_table_owner, filtered_register_rows, official_detail_partitions → csv_download_or_refusal
- Uses
- none found
- Used by
- mentioned in Standalone (comment link)
- Produces
- FetchQueue, escapeHtml, normalise, invariant, arraysEqual, hashJson, fetchImmutable, promise, dictionary, project, compactSearchText, formatNumber
- Defines here
- newsMatches, newsHtml, drawNews, bindNewsControls, loadNews, createGauge, loadCharts, scheduleOptionalLoads, boot
- Cannot conclude
- Whether this code runs, is used by a live app today, or is correct. This is a static reading.
- Evidence
- pipelinenews@45c944c8640a9d7ae65edb51d66032ba204f3f46 ui/javascript/202608270055-v8-fast-runtime.js:673-862 · blob f5ac4eb56e96b8036c47f08c874f94a8d1970121 · GitHub at these lines
- State
- achieves: code · context: readme_derived · stage: output · effects: dom, network · domain stage: upstream_foresight · users: IPP_developer, ICP_grid_engineer · canonical: duplicate_candidate
return String(row[NEWS_FIELD.technology] || row[NEWS_FIELD.regionalTechnology] || "").toUpperCase();
}
function newsMatches(row) {
const event = String(row[NEWS_FIELD.event] || "").toUpperCase();
const newsTechnologyValue = newsTechnology(row);
const regional = row[NEWS_FIELD.region];
if (newsMode === "UK" && row[NEWS_FIELD.canonical] !== true) return false;
if (newsMode === "INTERNATIONAL" && !regional) return false;
if (newsMode === "US" && regional !== "US") return false;
if (newsMode === "EUROPE" && regional !== "EUROPE") return false;
if (newsMode === "SOLAR" && !newsTechnologyValue.includes("SOLAR")) return false;
if (newsMode === "BESS" && !newsTechnologyValue.includes("BESS")) return false;
if (newsMode === "CONSENT" && event !== "CONSENT") return false;
if (newsMode === "CONSTRUCTION" && event !== "CONSTRUCTION") return false;
if (newsMode === "OPERATIONAL" && event !== "OPERATIONAL") return false;
if (newsMode === "FINANCE" && !FINANCE_EVENTS.has(event)) return false;
if (newsQuery) {
const haystack = normalise([row[NEWS_FIELD.headline], row[NEWS_FIELD.project], row[NEWS_FIELD.operator], row[NEWS_FIELD.county], row[NEWS_FIELD.source], row[NEWS_FIELD.event], row[NEWS_FIELD.repdRef], row[NEWS_FIELD.projectId]].join(" "));
const tokens = normalise(newsQuery).split(" ").filter(Boolean);
if (!tokens.every((token) => haystack.includes(token))) return false;
}
return true;
}
function newsHtml(row) {
const regional = row[NEWS_FIELD.region];
const technologyValue = newsTechnology(row);
const articleClass = technologyValue.includes("BESS") ? "bess" : "solar";
const projectName = row[NEWS_FIELD.project] || "";
const capacity = Number(row[NEWS_FIELD.capacity] || 0);
const quality = row[NEWS_FIELD.canonical] === true
? `<span class="news-quality relevant">RELEVANT ${Number(row[NEWS_FIELD.confidence] || 0)}%</span> · PRIMARY_MATCH · REPD ${escapeHtml(row[NEWS_FIELD.repdRef])}`
: regional
? `<span class="news-quality relevant">${escapeHtml(regional === "INTERNATIONAL_OTHER" ? "INTERNATIONAL" : regional)}</span> · ${escapeHtml(row[NEWS_FIELD.regionalEvidence])} · regional discovery only · no REPD project signal`
: '<span class="news-quality unverified">DISCOVERY ONLY</span> · no project signal';
return `<a class="story ${articleClass}" data-article-id="${escapeHtml(row[NEWS_FIELD.articleId])}" href="${escapeHtml(row[NEWS_FIELD.url])}" target="_blank" rel="noopener"><div class="kicker">${escapeHtml(technologyValue || "ENERGY")} · ${escapeHtml(row[NEWS_FIELD.event] || "PROJECT UPDATE")} · ${escapeHtml(row[NEWS_FIELD.published] || "")}</div><h3>${escapeHtml(row[NEWS_FIELD.headline] || proj … [line shortened here: 817 characters; full line on GitHub]
}
function drawNews() {
const matches = newsRows.filter(newsMatches);
const stories = document.getElementById("stories");
if (newsStart >= matches.length) newsStart = 0;
if (!matches.length) {
stories.innerHTML = '<div class="news-empty">No headlines match this newspaper filter.</div>';
} else {
stories.innerHTML = matches.slice(newsStart, newsStart + NEWS_WINDOW_SIZE).map(newsHtml).join("");
}
let pager = document.getElementById("newsPager");
if (!pager) {
pager = document.createElement("div");
pager.id = "newsPager";
pager.className = "news-pager";
pager.innerHTML = '<button id="newsPrevious" type="button">PREVIOUS 30</button><span id="newsWindowRange"></span><button id="newsMore" type="button">NEXT 30</button>';
document.querySelector(".paper").after(pager);
pager.querySelector("#newsPrevious").addEventListener("click", () => {
newsStart = Math.max(0, newsStart - NEWS_WINDOW_SIZE);
drawNews();
});
pager.querySelector("#newsMore").addEventListener("click", () => {
newsStart += NEWS_WINDOW_SIZE;
drawNews();
});
}
const end = Math.min(matches.length, newsStart + NEWS_WINDOW_SIZE);
const previous = pager.querySelector("#newsPrevious");
const more = pager.querySelector("#newsMore");
previous.disabled = newsStart === 0;
more.disabled = end >= matches.length;
pager.querySelector("#newsWindowRange").textContent = matches.length
? `${newsStart + 1}–${end} of ${matches.length.toLocaleString("en-GB")}`
: "0 headlines";
more.textContent = `NEXT ${Math.min(NEWS_WINDOW_SIZE, Math.max(0, matches.length - end))} · ${matches.length.toLocaleString("en-GB")} MATCHES`;
}
function bindNewsControls() {
document.querySelectorAll("#newsTools button").forEach((button) => {
button.addEventListener("click", () => {
document.querySelectorAll("#newsTools button").forEach((candidate) => candidate.classList.remove("active"));
button.classList.add("active");
newsMode = button.dataset.news;
newsStart = 0;
drawNews();
});
});
document.getElementById("newsSearch").addEventListener("input", (event) => {
newsQuery = event.target.value.trim();
newsStart = 0;
drawNews();
});
}
async function loadNews() {
if (runtimeEvidence.newsReady) return;
runtimeEvidence.newsRequests += 1;
try {
const payload = await fetchImmutable(registry.assets.news.path);
invariant(payload.schema === registry.assets.news.schema, "news schema mismatch");
invariant(payload.generation === GENERATION, "news generation mismatch");
invariant(payload.cache_identity === EXPECTED_CACHE_IDENTITY, "news cache identity mismatch");
invariant(arraysEqual(payload.fields, NEWS_FIELDS), "news field contract mismatch");
invariant(payload.rows.length === registry.news_counts.all, "news count mismatch");
newsRows = payload.rows;
runtimeEvidence.newsReady = true;
document.getElementById("newsMeta").textContent = `${registry.news_counts.uk} UK · ${registry.news_counts.international} international (${registry.news_counts.us} US · ${registry.news_counts.europe} Europe · ${registry.news_counts.other} other) · ${registry.news_counts.all} headlines · immutable compact edition`;
drawNews();
} catch (error) {
console.error(error);
document.getElementById("stories").innerHTML = '<div class="news-empty">Newspaper unavailable. REPD analytics remain live.</div>';
document.getElementById("newsMeta").textContent = "newspaper unavailable";
}
}
function createGauge(canvasId, colour) {
const options = { responsive: true, maintainAspectRatio: false, circumference: 180, rotation: 270, cutout: "80%", plugins: { tooltip: { enabled: false }, legend: { display: false } } };
return new globalThis.Chart(document.getElementById(canvasId), { type: "doughnut", data: { datasets: [{ data: [0, 1], backgroundColor: [colour, "#222"], borderWidth: 0 }] }, options });
}
async function loadCharts() {
if (runtimeEvidence.chartsReady) return;
await new Promise((resolve, reject) => {
const script = document.createElement("script");
script.src = registry.assets.chart.path;
script.async = true;
script.onload = resolve;
script.onerror = () => reject(new Error("pinned Chart.js failed to load"));
document.head.appendChild(script);
});
invariant(typeof globalThis.Chart === "function", "pinned Chart.js API unavailable");
charts.capacity = createGauge("g1", "#ff00ff");
charts.projects = createGauge("g2", "#00ffff");
charts.largest = createGauge("g3", "#00ff88");
runtimeEvidence.chartsReady = true;
updateGauges({ count: filtered.length, capacity: filtered.reduce((sum, index) => sum + Number(rows[index][FIELD.capacity]), 0), largest: filtered.reduce((maximum, index) => Math.max(maximum, Number(rows[index][FIELD.capacity])), 0) });
}
function scheduleOptionalLoads() {
setTimeout(() => {
const schedule = globalThis.requestIdleCallback || ((callback) => setTimeout(callback, 0));
schedule(() => loadNews(), { timeout: 1500 });
schedule(() => loadCharts().catch((error) => console.error(error)), { timeout: 2000 });
}, 1000);
}
async function boot() {
registry = await fetchImmutable(REGISTRY_URL);
invariant(registry.schema === "pipelinenews.v8.fast-registry.v1", "registry schema mismatch");
invariant(registry.generation === GENERATION, "registry generation mismatch");
invariant(registry.compiler_method === EXPECTED_COMPILER_METHOD, "registry compiler method mismatch");
invariant(registry.cache_identity === EXPECTED_CACHE_IDENTITY, "registry cache identity mismatch");
invariant(await hashJson(registry.cache_contract) === EXPECTED_CACHE_IDENTITY, "registry cache contract digest mismatch");
invariant(registry.cache_contract.compiler_method === EXPECTED_COMPILER_METHOD, "cache compiler method mismatch");
invariant(arraysEqual(registry.cache_contract.project_index.fields, PROJECT_FIELDS), "registry project field contract mismatch");
invariant(arraysEqual(registry.cache_contract.news_index.fields, NEWS_FIELDS), "registry news field contract mismatch");
invariant(registry.cache_contract.news_index.stable_key === "gg_article_id", "registry news key contract mismatch");
invariant(registry.cache_contract.runtime.physical_project_rows === WINDOW_SIZE, "project window contract mismatch");
invariant(registry.cache_contract.runtime.physical_news_rows === NEWS_WINDOW_SIZE, "news window contract mismatch");
invariant(registry.cache_contract.runtime.detail_fetch_concurrency === DETAIL_CONCURRENCY, "detail concurrency contract mismatch");
projectPayload = await fetchImmutable(registry.assets.projects.path);
invariant(projectPayload.schema === registry.assets.projects.schema, "project index schema mismatch");
invariant(projectPayload.generation === GENERATION, "project generation mismatch");
invariant(projectPayload.cache_identity === EXPECTED_CACHE_IDENTITY, "project cache identity mismatch");
invariant(arraysEqual(projectPayload.fields, PROJECT_FIELDS), "project field contract mismatch");
invariant(projectPayload.rows.length === registry.totals.project_count, "project index count mismatch");
rows = projectPayload.rows;
dictionaries = projectPayload.dictionaries;
updatedTimes = rows.map((row) => {
const value = row[FIELD.updated];
const timestamp = value ? Date.parse(`${value}T00:00:00Z`) : NaN;
return Number.isFinite(timestamp) ? timestamp : null;
});
bindProjectControls();
bindNewsControls();
populateCounties();
hydrateFiltersFromUrl();
if (query) await ensureSearchSupplement();
apply({ syncUrl: false });
document.getElementById("releaseMeta").textContent = `V8 fast candidate · ${rows.length.toLocaleString("en-GB")} canonical projects · ${registry.performance.maximum_physical_project_rows} physical rows · full details loaded only on demand`;
document.body.dataset.fastReady = "true";
document.body.dataset.fastGeneration = GENERATION;
globalThis.dispatchEvent(new CustomEvent("pipelinenews-fast-ready", { detail: { generation: GENERATION } }));
scheduleOptionalLoads();
}
boot().catch((error) => {
console.error(error);
document.getElementById("tbody").innerHTML = '<tr><td colspan="11" class="fast-fail">Canonical Q2 REPD data unavailable. The fast candidate has failed closed.</td></tr>';
document.getElementById("resultsMeta").textContent = "canonical data unavailable";
document.body.dataset.fastFailed = "true";
});JavaScript V8 Live News Runtime
A JavaScript file in PipelineNews covering the Renewable Energy Planning Database (REPD) register, battery storage (BESS), solar and wind, using EPSG:27700 and SHA-256, and uses data from the GridAtlas repository.
Set aside from the main view: 93% of its lines are the same as releases/javascript/202609010719-v8-fast-runtime.js (pipelinenews), which stays. (near-copy-of, proposed by families.py). 92% of lines shared with JavaScript V8 Fast Runtime; read that one first. All set-aside files, with reasons. Nothing was deleted.
Evidence
- line-jaccard 0.927 to pipelinenews@45c944c8640a9d7ae65edb51d66032ba204f3f46 releases/javascript/202609010719-v8-fast-runtime.js:1-942 8c5440bde1530575ada1a7f17cbfacd84f7903f4
- sha256 6c39694b32fe7b1364ef655bc3865833d74a063e9c5ce625e11d8d06ce2b0383
- target sha256 483ffd99803fbf1d8e0e5befc8de860d8530b63727532b748baa9d0cf1f0dcd6
- group of 2 (identity.json near-copy edges >= 0.9)
- canonical rule: reachable, newest stamp, core repo, most lines
energy-datapipelinenews / ui/javascript/202608270844-v8-live-news-runtime.js · lines 1–510 of 900 · version 2026-08-27 08:44 · Not reached from any entry point (candidate for review) · pattern ensureSearchSupplement (shared by 6 files)
- What it does
- It draws the REPD register, battery storage (BESS), solar and wind. Defines 48 functions or classes, including FetchQueue, escapeHtml, normalise, invariant, arraysEqual. Side effects: changes the web page (DOM); makes network requests.
- Why it exists in the grid workflow
- Domain stage upstream_foresight (repository name word 'pipelinenews'): upstream engineering foresight over GB transmission and distribution topology (TSO/DNO, 132kV and above, the REPD pipeline, data centres), which Ventus Ltd states it models for foresight. Domain terms in the code: the REPD register, battery storage (BESS), solar, wind.
- Inputs & outputs
- In: data source: gridatlas data. Coordinate systems named: OSGB36 / EPSG:27700 (British National Grid), WGS84 / EPSG:4326.
- What it achieves
- It fetches queue (`FetchQueue`), hashes JSON (`hashJson`) and fetches immutable (`fetchImmutable`). Its `downloadCsv` function gives CSV download or refusal from active table owner, filtered register rows and official detail partitions (VEDIC: export filtered projects). It responds to click, change and input events.
- Why it matters
- No other file in the estate was found to import it.
- Application
- pipelinenews · ui/javascript · script
- VEDIC
- EXPORT FILTERED PROJECTS (GG2050-VEDIC-000060): Pipeline News · Renewable project register. active_table_owner, filtered_register_rows, official_detail_partitions → csv_download_or_refusal
- Uses
- none found
- Used by
- none found
- Produces
- FetchQueue, escapeHtml, normalise, invariant, arraysEqual, hashJson, fetchImmutable, promise, dictionary, project, compactSearchText, formatNumber
- Defines here
- FetchQueue, escapeHtml, normalise, invariant, arraysEqual, hashJson, fetchImmutable, promise, dictionary, project, compactSearchText, formatNumber, displayDate, updatedTimestamp, atlasUrl, signalFor, relationshipSummary, rowHtml, ensureWindowControls, renderTable, updateSortHeader, updateChart, updateGauges, updateSummary, syncFilterUrl, apply, populateCounties, setButtonState, hydrateFiltersFromUrl, ensureSearchSupplement
- Cannot conclude
- Whether this code runs, is used by a live app today, or is correct. This is a static reading.
- Evidence
- pipelinenews@45c944c8640a9d7ae65edb51d66032ba204f3f46 ui/javascript/202608270844-v8-live-news-runtime.js:1-510 · blob 8887e581d1c2e0b6d9a78b3119c2f50ff560dc62 · GitHub at these lines
- State
- achieves: code · context: readme_derived · stage: output · effects: dom, network · domain stage: upstream_foresight · users: IPP_developer, ICP_grid_engineer · canonical: unreached_review
const GENERATION = "__FAST_GENERATION__";
const EXPECTED_COMPILER_METHOD = "__FAST_COMPILER_METHOD__";
const EXPECTED_CACHE_IDENTITY = "__FAST_CACHE_IDENTITY__";
const REGISTRY_URL = `data/${GENERATION}-v8-fast-registry.json`;
const WINDOW_SIZE = 50;
const NEWS_WINDOW_SIZE = 30;
const DETAIL_CONCURRENCY = 4;
const PROJECT_FIELDS = Object.freeze([
"repd_ref",
"gg_project_id",
"name",
"technology",
"status",
"capacity_mw",
"county",
"region",
"operator",
"repd_record_updated",
"geometry_status",
"latitude",
"longitude",
]);
const NEWS_FIELDS = Object.freeze([
"gg_article_id",
"repd_ref",
"gg_project_id",
"project",
"technology",
"capacity_mw",
"operator",
"county",
"country",
"event",
"headline",
"published",
"source",
"url",
"confidence",
"canonical_relevant",
"role",
"eligible_for_news_signal",
"regional_classification",
"regional_technology",
"regional_evidence",
"event_detail",
"relationship",
"related_context_repd_ref",
"related_context_project",
"binding_label",
"related_components",
"evidence_snippet",
]);
const FIELD = Object.freeze({
repdRef: 0,
projectId: 1,
name: 2,
technology: 3,
status: 4,
capacity: 5,
county: 6,
region: 7,
operator: 8,
updated: 9,
geometry: 10,
latitude: 11,
longitude: 12,
});
const NEWS_FIELD = Object.freeze({
articleId: 0,
repdRef: 1,
projectId: 2,
project: 3,
technology: 4,
capacity: 5,
operator: 6,
county: 7,
country: 8,
event: 9,
headline: 10,
published: 11,
source: 12,
url: 13,
confidence: 14,
canonical: 15,
role: 16,
eligible: 17,
region: 18,
regionalTechnology: 19,
regionalEvidence: 20,
eventDetail: 21,
relationship: 22,
relatedContextRepdRef: 23,
relatedContextProject: 24,
bindingLabel: 25,
relatedComponents: 26,
evidenceSnippet: 27,
});
const LABELS = Object.freeze({
solar: "Solar",
bess: "Battery Storage",
wind_onshore: "Onshore Wind",
wind_offshore: "Offshore Wind",
});
const COLOURS = Object.freeze({
solar: "#ffff00",
bess: "#ffae00",
wind_onshore: "#00ffff",
wind_offshore: "#0066ff",
});
const UNITS = Object.freeze({ solar: "MWp", bess: "MW", wind_onshore: "MW", wind_offshore: "MW" });
const TECHNOLOGIES = new Set(["all", "solar", "bess", "wind_onshore", "wind_offshore"]);
const STATUSES = new Set(["All", "Operational", "Under Construction", "Awaiting Construction", "Application Submitted"]);
const SORTS = new Set(["capacity_desc", "updated_desc", "updated_asc"]);
const FINANCE_EVENTS = new Set(["FINANCIAL CLOSE", "ACQUISITION"]);
const immutablePromises = new Map();
class FetchQueue {
constructor(limit) {
this.limit = limit;
this.active = 0;
this.maximumActive = 0;
this.pending = [];
}
add(task) {
return new Promise((resolve, reject) => {
this.pending.push({ task, resolve, reject });
this.drain();
});
}
drain() {
while (this.active < this.limit && this.pending.length) {
const entry = this.pending.shift();
this.active += 1;
this.maximumActive = Math.max(this.maximumActive, this.active);
Promise.resolve()
.then(entry.task)
.then(entry.resolve, entry.reject)
.finally(() => {
this.active -= 1;
this.drain();
});
}
}
}
const detailQueue = new FetchQueue(DETAIL_CONCURRENCY);
const detailPromises = new Map();
const detailByRef = new Map();
const charts = { capacity: null, projects: null, largest: null };
let registry = null;
let projectPayload = null;
let rows = [];
let dictionaries = null;
let searchSupplement = null;
let newsRows = [];
let filtered = [];
let updatedTimes = [];
let windowStart = 0;
let newsStart = 0;
let technology = "all";
let status = "All";
let county = "All";
let query = "";
let sortMode = "capacity_desc";
let newsMode = "ALL";
let newsQuery = "";
let searchTimer = null;
let controlsBound = false;
const runtimeEvidence = {
generation: GENERATION,
detailConcurrency: DETAIL_CONCURRENCY,
maximumDetailConcurrency: 0,
detailRequests: 0,
newsRequests: 0,
searchRequests: 0,
chartsReady: false,
newsReady: false,
searchReady: false,
};
globalThis.__PIPELINENEWS_FAST__ = runtimeEvidence;
function escapeHtml(value) {
return String(value ?? "").replace(/[&<>"']/g, (character) => ({
"&": "&",
"<": "<",
">": ">",
'"': """,
"'": "'",
})[character]);
}
function normalise(value) {
return String(value ?? "")
.normalize("NFKD")
.replace(/[\u0300-\u036f]/g, "")
.toLocaleLowerCase("en-GB")
.replace(/&/g, " and ")
.replace(/[^a-z0-9.-]+/g, " ")
.replace(/\s+/g, " ")
.trim();
}
function invariant(condition, message) {
if (!condition) throw new Error(`PipelineNews V8 fast runtime: ${message}`);
}
function arraysEqual(left, right) {
return Array.isArray(left) && Array.isArray(right)
&& left.length === right.length
&& left.every((value, index) => value === right[index]);
}
async function hashJson(value) {
invariant(globalThis.crypto?.subtle, "Web Crypto unavailable for cache-contract verification");
const digest = await crypto.subtle.digest("SHA-256", new TextEncoder().encode(JSON.stringify(value)));
return [...new Uint8Array(digest)].map((value) => value.toString(16).padStart(2, "0")).join("");
}
async function fetchImmutable(url, { timeoutMs = 15000 } = {}) {
const target = new URL(url, document.baseURI);
invariant(target.origin === location.origin, `cross-origin cartridge rejected: ${target.href}`);
const key = target.href;
if (immutablePromises.has(key)) return immutablePromises.get(key);
const promise = (async () => {
const controller = new AbortController();
const timeout = setTimeout(() => controller.abort(), timeoutMs);
try {
const response = await fetch(target, { cache: "force-cache", signal: controller.signal });
invariant(response.ok, `${target.pathname} returned HTTP ${response.status}`);
return response.json();
} finally {
clearTimeout(timeout);
}
})();
immutablePromises.set(key, promise);
promise.catch(() => immutablePromises.delete(key));
return promise;
}
function dictionary(name, index) {
return dictionaries[name][index] ?? "";
}
function project(index) {
const row = rows[index];
return {
index,
row,
repd_ref: row[FIELD.repdRef],
gg_project_id: row[FIELD.projectId],
name: row[FIELD.name],
technology: dictionary("technology", row[FIELD.technology]),
status: dictionary("status", row[FIELD.status]),
capacity_mw: Number(row[FIELD.capacity]),
county: dictionary("county", row[FIELD.county]),
region: dictionary("region", row[FIELD.region]),
operator: dictionary("operator", row[FIELD.operator]),
repd_record_updated: row[FIELD.updated],
geometry_status: dictionary("geometry_status", row[FIELD.geometry]),
latitude: row[FIELD.latitude],
longitude: row[FIELD.longitude],
};
}
function compactSearchText(index) {
const item = project(index);
return normalise([
item.name,
item.operator,
item.repd_ref,
item.gg_project_id,
item.technology,
item.status,
item.capacity_mw,
item.county,
item.region,
item.repd_record_updated,
item.geometry_status,
].join(" "));
}
function formatNumber(value) {
return (Number(value) || 0).toLocaleString("en-GB", { maximumFractionDigits: 2 });
}
function displayDate(value) {
if (!value) return "not supplied by REPD";
const [year, month, day] = String(value).split("-");
return year && month && day ? `${day}/${month}/${year}` : String(value);
}
function updatedTimestamp(index) {
return updatedTimes[index] ?? null;
}
function atlasUrl(item) {
if (item.geometry_status !== "valid") return "";
const url = new URL("https://ventusltd.github.io/gridatlas/202608300453-atlas-v9/");
url.searchParams.set("repd_ref", item.repd_ref);
url.searchParams.set("technology", item.technology);
url.searchParams.set("longitude", item.longitude);
url.searchParams.set("latitude", item.latitude);
return url.href;
}
function signalFor(item) {
const signal = registry.signals[item.repd_ref];
if (!signal) return { label: "—", cls: "none", note: "no exact canonical PRIMARY_MATCH" };
const [eventValue, confidence, published] = signal;
const event = String(eventValue || "PROJECT UPDATE").toUpperCase();
if (event === "CONSENT") return { label: "APPROVED*", cls: "approved", note: `canonical PRIMARY_MATCH ${confidence}% · unverified event · ${published}` };
if (event === "OPERATIONAL") return { label: "OPERATIONAL*", cls: "operational", note: `canonical PRIMARY_MATCH ${confidence}% · unverified event · ${published}` };
if (event === "CONSTRUCTION") return { label: "CONSTRUCTION*", cls: "construction", note: `canonical PRIMARY_MATCH ${confidence}% · unverified event · ${published}` };
if (FINANCE_EVENTS.has(event)) return { label: event === "ACQUISITION" ? "M&A*" : "FINANCED*", cls: "finance", note: `canonical PRIMARY_MATCH ${confidence}% · unverified event · ${published}` };
return { label: `${event}*`.slice(0, 22), cls: "", note: `canonical PRIMARY_MATCH ${confidence}% · unverified event · ${published}` };
}
function relationshipSummary(item) {
const development = Array.isArray(item.development_repd_refs) ? item.development_repd_refs.length : 0;
const direct = Array.isArray(item.direct_related_repd_refs) ? item.direct_related_repd_refs.length : 0;
const siblings = Array.isArray(item.planning_sibling_repd_refs) ? item.planning_sibling_repd_refs.length : 0;
return `${development} development · ${direct} direct · ${siblings} planning sibling record(s)`;
}
function rowHtml(index) {
const item = project(index);
const label = LABELS[item.technology];
const signal = signalFor(item);
const locationText = [item.county, item.region].filter(Boolean).join(" · ");
const news = new URL("https://www.google.com/search");
news.searchParams.set("q", `${item.name} ${label} UK`);
news.searchParams.set("tbm", "nws");
const atlas = atlasUrl(item);
const mapAction = atlas
? `<a class="action-link atlaslink" target="_blank" rel="noopener" href="${escapeHtml(atlas)}">MAP ↗</a>`
: '<span class="action-disabled" title="REPD geometry is unavailable; the record remains searchable and exportable">NO MAP</span>';
return `<tr id="repd-${escapeHtml(item.repd_ref)}" data-project-index="${index}"><td class="site">${escapeHtml(item.name)}<div class="project-meta">REPD ${escapeHtml(item.repd_ref)} · ${escapeHtml(item.gg_project_id)} · UPDATED ${escapeHtml(displayDate(item.repd_record_updated))}</div><div class="mobile-extra">${escapeHtml([locationText, item.operator].filter(Boolean).join(" | "))}</div><details … [line shortened here: 1,648 characters; full line on GitHub]
}
function ensureWindowControls() {
let panel = document.getElementById("projectWindowControls");
if (panel) return panel;
panel = document.createElement("div");
panel.id = "projectWindowControls";
panel.className = "project-window-controls";
panel.innerHTML = '<button type="button" data-window="previous">PREVIOUS 50</button><span data-window-range></span><button type="button" data-window="next">NEXT 50</button>';
document.querySelector(".tablewrap").after(panel);
panel.addEventListener("click", (event) => {
const action = event.target.closest("[data-window]")?.dataset.window;
if (!action) return;
if (action === "previous") windowStart = Math.max(0, windowStart - WINDOW_SIZE);
if (action === "next") windowStart = Math.min(Math.floor(Math.max(0, filtered.length - 1) / WINDOW_SIZE) * WINDOW_SIZE, windowStart + WINDOW_SIZE);
renderTable();
});
return panel;
}
function renderTable() {
const body = document.getElementById("tbody");
const page = filtered.slice(windowStart, windowStart + WINDOW_SIZE);
body.innerHTML = page.map(rowHtml).join("");
const panel = ensureWindowControls();
const end = Math.min(filtered.length, windowStart + WINDOW_SIZE);
panel.querySelector("[data-window-range]").textContent = filtered.length
? `${windowStart + 1}–${end} of ${filtered.length.toLocaleString("en-GB")}`
: "0 records";
panel.querySelector('[data-window="previous"]').disabled = windowStart === 0;
panel.querySelector('[data-window="next"]').disabled = end >= filtered.length;
}
function updateSortHeader() {
const header = document.getElementById("repdUpdatedHeader");
const indicator = document.getElementById("updatedSortIndicator");
const button = document.getElementById("sortUpdated");
if (sortMode === "updated_desc") {
header.setAttribute("aria-sort", "descending");
indicator.textContent = "▼";
button.title = "Newest first — click for oldest first";
} else if (sortMode === "updated_asc") {
header.setAttribute("aria-sort", "ascending");
indicator.textContent = "▲";
button.title = "Oldest first — click for newest first";
} else {
header.setAttribute("aria-sort", "none");
indicator.textContent = "↕";
button.title = "Click for newest first";
}
}
function updateChart(chart, value, maximum) {
if (!chart) return;
chart.data.datasets[0].data = [value, Math.max(maximum - value, 0)];
chart.update("none");
}
function updateGauges(summary) {
document.getElementById("v1").textContent = formatNumber(summary.capacity);
document.getElementById("v2").textContent = summary.count.toLocaleString("en-GB");
document.getElementById("v3").textContent = formatNumber(summary.largest);
updateChart(charts.capacity, summary.capacity, registry.totals.capacity_mw || 1);
updateChart(charts.projects, summary.count, registry.totals.project_count || 1);
updateChart(charts.largest, summary.largest, registry.totals.largest_mw || 1);
}
function updateSummary(summary) {
const element = document.getElementById("resultsMeta");
element.textContent = `${summary.count.toLocaleString("en-GB")} of ${rows.length.toLocaleString("en-GB")} records · ${formatNumber(summary.capacity)} MW · largest ${formatNumber(summary.largest)} MW`;
element.classList.toggle("is-filtered", summary.count !== rows.length);
element.dataset.filteredCount = String(summary.count);
element.dataset.totalCount = String(rows.length);
}
function syncFilterUrl() {
const url = new URL(location.href);
for (const parameter of ["technology", "status", "county", "q", "sort"]) url.searchParams.delete(parameter);
if (technology !== "all") url.searchParams.set("technology", technology);
if (status !== "All") url.searchParams.set("status", status);
if (county !== "All") url.searchParams.set("county", county);
if (query) url.searchParams.set("q", query);
if (sortMode !== "capacity_desc") url.searchParams.set("sort", sortMode);
history.replaceState(null, "", url);
}
function apply({ syncUrl = true } = {}) {
const tokens = normalise(query).split(" ").filter(Boolean);
const next = [];
let capacity = 0;
let largest = 0;
for (let index = 0; index < rows.length; index += 1) {
const item = project(index);
if (technology !== "all" && item.technology !== technology) continue;
if (status !== "All" && !item.status.includes(status)) continue;
if (county !== "All" && item.county !== county) continue;
if (tokens.length) {
const searchable = searchSupplement?.[index] || compactSearchText(index);
if (!tokens.every((token) => searchable.includes(token))) continue;
}
next.push(index);
capacity += item.capacity_mw;
largest = Math.max(largest, item.capacity_mw);
}
if (sortMode === "updated_desc" || sortMode === "updated_asc") {
const direction = sortMode === "updated_asc" ? 1 : -1;
next.sort((left, right) => {
const leftTime = updatedTimestamp(left);
const rightTime = updatedTimestamp(right);
if (leftTime === null && rightTime === null) return left - right;
if (leftTime === null) return 1;
if (rightTime === null) return -1;
return direction * (leftTime - rightTime) || left - right;
});
}
filtered = next;
windowStart = 0;
const summary = { count: next.length, capacity: Math.round((capacity + Number.EPSILON) * 100) / 100, largest };
renderTable();
updateSummary(summary);
updateGauges(summary);
updateSortHeader();
if (syncUrl) syncFilterUrl();
}
function populateCounties() {
const select = document.getElementById("county");
select.replaceChildren(new Option("🌍 ALL COUNTIES", "All"));
dictionaries.county.filter(Boolean).sort((left, right) => left.localeCompare(right, "en-GB"))
.forEach((value) => select.add(new Option(`📍 ${value}`, value)));
}
function setButtonState(container, dataKey, selected) {
document.querySelectorAll(`${container} .btn`).forEach((button) => {
const active = button.dataset[dataKey] === selected;
button.classList.toggle("active", active);
button.setAttribute("aria-pressed", String(active));
});
}
function hydrateFiltersFromUrl() {
const parameters = new URLSearchParams(location.search);
const requestedTechnology = parameters.get("technology") || "all";
const requestedStatus = parameters.get("status") || "All";
const requestedCounty = parameters.get("county") || "All";
const requestedSort = parameters.get("sort") || "capacity_desc";
technology = TECHNOLOGIES.has(requestedTechnology) ? requestedTechnology : "all";
status = STATUSES.has(requestedStatus) ? requestedStatus : "All";
county = dictionaries.county.includes(requestedCounty) ? requestedCounty : "All";
query = parameters.get("q") || "";
sortMode = SORTS.has(requestedSort) ? requestedSort : "capacity_desc";
setButtonState("#tech", "technology", technology);
setButtonState("#status", "officialStatus", status);
document.getElementById("county").value = county;
document.getElementById("search").value = query;
document.getElementById("sortProjects").value = sortMode;
}
async function ensureSearchSupplement() {
if (searchSupplement) return searchSupplement;
runtimeEvidence.searchRequests += 1;
const payload = await fetchImmutable(registry.assets.search.path);
invariant(payload.schema === registry.assets.search.schema, "search schema mismatch");