mirror of
https://github.com/mauriceboe/TREK.git
synced 2026-12-03 09:38:54 +00:00
fix(deps): maplibre-gl 6.15.0 past the attribution sanitizer advisory
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.
This commit is contained in:
@@ -42,15 +42,15 @@ describe('hasWebGL', () => {
|
||||
expect(hasWebGL()).toBe(false)
|
||||
})
|
||||
|
||||
it('FE-UTIL-WEBGL-003: falls back to webgl1 when only webgl2 is refused', () => {
|
||||
// Exactly the order maplibre-gl asks in. A stricter probe would black out
|
||||
// maps that would in fact have drawn.
|
||||
it('FE-UTIL-WEBGL-003: says no when only webgl1 is on offer', () => {
|
||||
// MapLibre 6 asks for webgl2 and nothing else. A probe that settled for
|
||||
// webgl1 would wave the map through to a GPUInitializationError.
|
||||
const { ctx } = fakeContext()
|
||||
const getContext = vi.fn((type: string) => (type === 'webgl2' ? null : ctx))
|
||||
HTMLCanvasElement.prototype.getContext = getContext as unknown as typeof realGetContext
|
||||
|
||||
expect(hasWebGL()).toBe(true)
|
||||
expect(getContext.mock.calls.map((c) => c[0])).toEqual(['webgl2', 'webgl'])
|
||||
expect(hasWebGL()).toBe(false)
|
||||
expect(getContext.mock.calls.map((c) => c[0])).toEqual(['webgl2'])
|
||||
})
|
||||
|
||||
it('FE-UTIL-WEBGL-004: gives the probe context straight back', () => {
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/**
|
||||
* Whether this browser will hand MapLibre a WebGL context.
|
||||
* Whether this browser will hand MapLibre a WebGL2 context.
|
||||
*
|
||||
* The default basemap has been a vector style since 4.1.0, and maplibre-gl builds
|
||||
* its GL context inside the Map constructor: no context, no map, and the throw
|
||||
@@ -45,12 +45,13 @@ function probe(): boolean {
|
||||
canvas.width = 1
|
||||
canvas.height = 1
|
||||
|
||||
// Exactly the order maplibre-gl asks in (Map._setupPainter): webgl2 first,
|
||||
// webgl1 second. A stricter probe would black out maps that would in fact
|
||||
// have drawn; a looser one would let the throw through anyway.
|
||||
const gl = (canvas.getContext('webgl2') ?? canvas.getContext('webgl')) as WebGLRenderingContext | null
|
||||
// Exactly what maplibre-gl asks for (Map._setupPainter): WebGL2 and nothing
|
||||
// else, since MapLibre 6 dropped WebGL1. A browser that only offers WebGL1
|
||||
// passes a looser probe and then throws GPUInitializationError out of the Map
|
||||
// constructor, which is the crash this probe exists to prevent.
|
||||
const gl = canvas.getContext('webgl2')
|
||||
if (!gl) {
|
||||
console.warn('[basemap] this browser refuses a WebGL context, vector basemaps are unavailable')
|
||||
console.warn('[basemap] this browser refuses a WebGL2 context, vector basemaps are unavailable')
|
||||
return false
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user