refactor(fires): separate source, rendering and interaction components

This commit is contained in:
Sameh Khamis committed 2026-09-13 12:48:26 -07:00
1 parent e99cc8cf68
commit 6a9f13eab8
28 files changed
+2540 -1731

No files matched your search

+29
View File
@@ -0,0 +1,29 @@
/** Construct the existing live-fire endpoint without making a request. */
export function createFirmsSource({
fetchImpl = (...args) => globalThis.fetch(...args),
} = {}) {
return {
async getSnapshot({ signal } = {}) {
signal?.throwIfAborted();
const response = await fetchImpl('/api/firms', {
signal,
cache: 'no-store',
});
let payload;
try {
payload = await response.json();
} catch {
/* status below remains authoritative */
}
signal?.throwIfAborted();
if (!response.ok) {
if (response.status === 503 && payload?.error === 'no_key')
return { keyRequired: true };
throw new Error(`FIRMS HTTP ${response.status}`);
}
if (!Array.isArray(payload?.fires))
throw new Error('Malformed fire snapshot');
return payload;
},
};
}