fix(atlas): name the globe hook dependencies, cover the mesh routes

The second run of the globe Atlas was red on:

- Client lint: the engine getter is a stable callback now, so the hooks
  that call it name it (and the refs and setters they read); an unused
  navigate and a seven parameter label helper are gone.
- Atlas coverage: the mesh controller and the people and flights routes
  get unit tests, an unused region name helper is removed.
- The French "Atlas" is marked as the same word, index.css is back at its
  length, the server people service is formatted, and the baselines drop
  the deleted AtlasPage and follow the lower counts.
This commit is contained in:
Maurice
2026-11-28 23:48:47 +01:00
parent 10713e41cd
commit 06b08cd9d5
11 changed files with 211 additions and 52 deletions
@@ -46,14 +46,12 @@ export function placeLabels(
const m = engine.manifest;
if (!m) return;
const zoom = engine.zoom;
const { width, height } = engine.vp;
const { width } = engine.vp;
const cands: Candidate[] = [];
const minArea = minAreaFor(zoom);
const regionA = engine.regionAlpha;
const regionsOn = zoom >= (width < NARROW_WIDTH ? REGION_LABEL_ZOOM_PHONE : REGION_LABEL_ZOOM_WIDE);
const named = regionsOn ? regionCandidates(engine, cands) : new Set<string>();
countryCandidates(engine, cands, named, minArea, regionA, labelFor, labelRegionsOf);
countryCandidates(engine, cands, named, labelFor, labelRegionsOf);
cands.sort((a, b) => b.rank - a.rank);
let regionCount = 0;
@@ -132,14 +130,14 @@ function countryCandidates(
engine: GlobeEngine,
cands: Candidate[],
named: Set<string>,
minArea: number,
regionA: number,
labelFor: (a2: string) => string | null,
labelRegionsOf?: (a2: string) => boolean
): void {
const m = engine.manifest;
if (!m) return;
const { width, height } = engine.vp;
const minArea = minAreaFor(engine.zoom);
const regionA = engine.regionAlpha;
for (const c of m.countries) {
if (!c.a2 || !c.anchor || named.has(c.a2)) continue;
const mine = labelRegionsOf ? labelRegionsOf(c.a2) : false;
+1 -3
View File
@@ -356,9 +356,7 @@ input, textarea, select {
transform: translateX(-2px);
}
/* Global focus-visible ring — konsistent überall. Containers that only take the
focus from code (a dialog panel with tabindex="-1") never draw it: the ring and
its 4px radius would sit on the whole panel and square off its corners. */
/* Global focus-visible ring, not on panels focused from code (tabindex="-1"). */
:focus-visible:not([tabindex="-1"]) {
outline: 2px solid var(--accent);
outline-offset: 2px;
@@ -1,6 +1,6 @@
import { Globe2, Layers, X } from 'lucide-react';
import React from 'react';
import { useNavigate, useSearchParams } from 'react-router';
import { useSearchParams } from 'react-router';
import AtlasGlobe, { type AtlasGlobeHandle } from '../../../components/AtlasGlobe/AtlasGlobe';
import type { GlobeEngine } from '../../../components/AtlasGlobe/GlobeEngine';
import GlobePins, { type GlobePinsHandle } from '../../../components/AtlasGlobe/GlobePins';
@@ -31,7 +31,6 @@ export default function MAtlasGlobe(): React.ReactElement {
const skyRef = React.useRef<GlobeSkyHandle>(null);
const s = useAtlasGlobe({ globeRef, skyRef });
const stats = useGlobeStats(s);
const navigate = useNavigate();
const [layersOpen, setLayersOpen] = React.useState(false);
const pinsRef = React.useRef<GlobePinsHandle>(null);
// The dock's search button hands over with ?search=1, as on every screen: take
+34 -28
View File
@@ -116,7 +116,7 @@ export function useAtlasGlobe({ globeRef, skyRef }: AtlasGlobeRefs) {
setRegions(regs as VisitedRegionMap);
setBucket(items as BucketItem[]);
setFlights(fl);
}, []);
}, [setBucket]);
// Flight arcs, grouped by how often a route was flown so busy routes draw thicker (#1369).
const arcLayers = useMemo<ArcLayer[]>(() => {
@@ -134,7 +134,7 @@ export function useAtlasGlobe({ globeRef, skyRef }: AtlasGlobeRefs) {
useEffect(() => {
if (!manifest) return;
globeRef.current?.engine?.setArcs(showFlights ? arcLayers : []);
}, [arcLayers, showFlights, manifest]);
}, [arcLayers, showFlights, manifest, globeRef]);
// The first read, tried again with growing pauses before it counts as failed:
// a server that restarts or a connection that drops for a moment answers
@@ -238,22 +238,25 @@ export function useAtlasGlobe({ globeRef, skyRef }: AtlasGlobeRefs) {
const planned = data.countries.filter((c) => countryStatus(c) !== 'visited').map((c) => c.code);
const wished = bucket.map((b) => b.country_code).filter((c): c is string => !!c && c.length === 2);
e.prefetchRegions([...visited, ...planned, ...wished]);
}, [manifest, data, bucket]);
}, [engine, manifest, data, bucket]);
const selectCountry = useCallback((a2: string, fly = true) => {
const e = engine();
const m = e?.manifest;
if (!e || !m) return;
const index = m.countries.findIndex((c) => c.a2 === a2);
if (index < 0) return;
setSelection({ kind: 'country', a2, index });
e.setSelected(index, null);
if (fly) {
const c = m.countries[index];
if (c.anchor) e.flyTo(c.anchor[0], c.anchor[1], Math.max(e.zoom, 1.15));
}
void e.loadRegionIndex(a2).then(() => setRegionTick((n) => n + 1));
}, []);
const selectCountry = useCallback(
(a2: string, fly = true) => {
const e = engine();
const m = e?.manifest;
if (!e || !m) return;
const index = m.countries.findIndex((c) => c.a2 === a2);
if (index < 0) return;
setSelection({ kind: 'country', a2, index });
e.setSelected(index, null);
if (fly) {
const c = m.countries[index];
if (c.anchor) e.flyTo(c.anchor[0], c.anchor[1], Math.max(e.zoom, 1.15));
}
void e.loadRegionIndex(a2).then(() => setRegionTick((n) => n + 1));
},
[engine]
);
// ---- the classic Atlas dialogs: choose / unmark / bucket (shared with the phone) and the country detail
const [confirmAction, setConfirmAction] = useState<AtlasConfirmAction | null>(null);
@@ -317,7 +320,7 @@ export function useAtlasGlobe({ globeRef, skyRef }: AtlasGlobeRefs) {
selectCountry(hit.a2, false);
openCountry(hit.a2);
},
[selectCountry, openCountry, regions, resolveName]
[engine, selectCountry, openCountry, regions, resolveName]
);
/** From the detail of a country marked by hand: ask to take the mark off. */
@@ -333,7 +336,7 @@ export function useAtlasGlobe({ globeRef, skyRef }: AtlasGlobeRefs) {
setDetail(null);
setSelection(null);
engine()?.setSelected(-1, null);
}, []);
}, [engine]);
const executeConfirmAction = useCallback(async () => {
const a = confirmAction;
@@ -370,7 +373,7 @@ export function useAtlasGlobe({ globeRef, skyRef }: AtlasGlobeRefs) {
if (i >= 0 && anchor) e.startInk(i, anchor[0], anchor[1]);
skyRef.current?.shootingStar();
}
}, [data]);
}, [data, engine, skyRef]);
const countryRow = useMemo(() => {
if (selection?.kind !== 'country') return null;
@@ -488,7 +491,7 @@ export function useAtlasGlobe({ globeRef, skyRef }: AtlasGlobeRefs) {
setRegionTick((n) => n + 1);
});
},
[selectCountry, openCountry]
[engine, selectCountry, openCountry]
);
// Places from the geocoder under the countries and regions (#1115): the globe flies
@@ -514,7 +517,7 @@ export function useAtlasGlobe({ globeRef, skyRef }: AtlasGlobeRefs) {
countryName: resolveName(info.country_code),
});
},
[regions, resolveName, selectCountry]
[engine, regions, resolveName, selectCountry]
);
// Badges are rules over the data on screen; nothing is stored (shared/src/atlas/atlas-badges.ts).
@@ -585,10 +588,13 @@ export function useAtlasGlobe({ globeRef, skyRef }: AtlasGlobeRefs) {
return [...people, mine].sort((a, b) => b.countries - a.countries || b.continents - a.continents);
}, [people, me, totals, flights]);
const flyToPoint = useCallback((lon: number, lat: number) => {
setPassportOpen(false);
engine()?.flyTo(lon, lat, 6);
}, []);
const flyToPoint = useCallback(
(lon: number, lat: number) => {
setPassportOpen(false);
engine()?.flyTo(lon, lat, 6);
},
[engine]
);
const pins = useMemo<GlobePin[]>(
() =>
@@ -605,8 +611,8 @@ export function useAtlasGlobe({ globeRef, skyRef }: AtlasGlobeRefs) {
[bucket, openPassport]
);
const zoomIn = useCallback(() => engine()?.zoomBy(1.6), []);
const zoomOut = useCallback(() => engine()?.zoomBy(1 / 1.6), []);
const zoomIn = useCallback(() => engine()?.zoomBy(1.6), [engine]);
const zoomOut = useCallback(() => engine()?.zoomBy(1 / 1.6), [engine]);
return {
t,