doxa-maps/plugin-designs/pplr-data-maps
Doxa Maps 5d82899d18 Three maps asked the window which engine drew them; now they ask the map
C3, buckets A and B. Each site was sniffing `window.maplibregl.Map` directly,
which breaks the moment a leaf stops loading a static engine peer: the global is
simply absent and the sniff answers about whatever else the page happened to load.

A needed a helper that did not exist. Both A sites want a provider NAME from a
live map. engineFor() returns the engine NAMESPACE, and resolveMapProvider()
reads a CONFIG rather than a map, so on a dual-engine page it answers about the
wrong thing. Hence providerFor(map) -> 'mapbox' | 'maplibre' | undefined, with two
named consumers on arrival.

★ WHY providerFor RETURNS undefined INSTEAD OF A DEFAULT. The obvious rewrite was
in terms of the existing isMapboxMap(). It is wrong in a way no per-engine test
catches: both originals test for MAPLIBRE and fall through to mapbox/false, so an
isMapboxMap() version inverts the fall-through to maplibre/true. On a stub, a
destroyed map, or a page where neither global loaded, that changes what a
diagnostic field reports AND which attribution a poster prints -- while agreeing
on both real engines. Returning undefined forces each call site to keep its own
default visible:

    pplrData.js      engine: providerFor(map) || 'mapbox'
    research-map.vue const onMaplibre = providerFor(map.value) === 'maplibre'

Changing a default is not a curation migration.

B is engineGlobal(mapProvider), which already defaults to Mapbox for anything
unrecognised -- exactly what the ternary's else branch did.

All three files now carry zero raw window.mapboxgl|maplibregl references in code.

Verified by _qa-cycle/02-builder-cycle/_chk-c3-provider-helper-equivalence.mjs:
27 assertions, each old pattern against its replacement on both engines and on
{}, null and undefined, plus an executable proof of the isMapboxMap near-miss and
three negative controls.
2026-09-26 17:28:46 +00:00
..
scripts PPLR data maps (WIP): move the ten PPLR research views into plugin-designs 2026-09-25 06:33:49 +00:00
src Three maps asked the window which engine drew them; now they ask the map 2026-09-26 17:28:46 +00:00
index.html PPLR data maps (WIP): move the ten PPLR research views into plugin-designs 2026-09-25 06:33:49 +00:00
index.js Six entries hand-rolled the RTL text plugin; the library already installs it 2026-09-26 13:35:57 +00:00
pplr-data-maps.meta.json PPLR data maps (WIP): move the ten PPLR research views into plugin-designs 2026-09-25 06:33:49 +00:00
pplr-data-maps.vue PPLR data maps: tab labels and status lines speak the reader's language 2026-09-26 03:34:28 +00:00