mirror of
https://github.com/mauriceboe/TREK.git
synced 2026-11-27 15:17:30 +00:00
1696162d22
GHSA-jrc7-96c5-q579 covers every maplibre-gl up to 6.4.0 and has no 5.x release, so npm audit kept flagging the patched 5.24.0. Moving to 6.15.0 retires the local backport: patch-maplibre.mjs and its postinstall, predev and prebuild hooks go, along with the Dockerfile copy and its format-baseline entry. 6.x sanitizes attributions against an allow list. What the major changes for TREK: - ESM only, no default export: the engine module imports the namespace and hands that out as its default, so every caller stays as it was. - The worker is no longer inlined, and inside a bundle MapLibre cannot find it next to its own module. The engine sets it from Vite's ?worker&url build before any map, the Leaflet bridge's included. - WebGL2 only: the probe asks for webgl2 alone, so a WebGL1-only browser gets the raster basemap instead of a GPUInitializationError. - 6.9 shapes right-to-left text itself and deprecated setRTLTextPlugin; the old plugin would replace that and could only run through eval in the module worker, so MapLibre no longer registers it. Mapbox does. The lockfile moves maplibre-gl and its own dependencies only; the Leaflet bridge already allows ^6.0.0 as its peer.
32 lines
1.5 KiB
TypeScript
32 lines
1.5 KiB
TypeScript
import * as maplibregl from 'maplibre-gl'
|
|
import 'maplibre-gl/dist/maplibre-gl.css'
|
|
import workerUrl from 'maplibre-gl/dist/maplibre-gl-worker.mjs?worker&url'
|
|
|
|
/**
|
|
* The only module in the client that pulls maplibre-gl in at runtime. Same rule as
|
|
* its mapbox sibling: reachable through a dynamic import and no other way.
|
|
*
|
|
* The two engines share their API surface for everything TREK uses — Map, Marker,
|
|
* Popup, LngLatBounds — which is why the components take the engine as a prop and
|
|
* stay engine-agnostic. Where the two genuinely differ, the caller already guards
|
|
* on the provider (projection, accessToken, aroundCenter).
|
|
*
|
|
* MapLibre 6 ships as ES modules only and has no default export any more, so the
|
|
* namespace is what goes out as this module's default. It is a frozen module
|
|
* namespace: nothing may assign to it, which is why the accessToken writes stay
|
|
* behind their mapbox-only guard.
|
|
*/
|
|
|
|
// MapLibre 6 finds its worker next to its own module, which inside a bundle is a
|
|
// chunk in /assets/ with no worker beside it. Vite builds the worker into its own
|
|
// file and hands back the URL; set before any Map is constructed, the
|
|
// maplibre-gl-leaflet bridge included, since it only ever reaches the engine
|
|
// together with this module.
|
|
maplibregl.setWorkerUrl(workerUrl)
|
|
|
|
// No RTL text plugin here, unlike mapbox. MapLibre 6.9 shapes Arabic and orders
|
|
// bidirectional text itself; the old plugin would replace that implementation, and
|
|
// a v6 worker can only load the plugin's UMD build through eval.
|
|
|
|
export default maplibregl
|