mirror of
https://github.com/mauriceboe/TREK.git
synced 2026-11-25 14:17:31 +00:00
fix(map): pin mapbox-gl to 3.32.0 so vector tiles load beside maplibre-gl
mapbox-gl 3.33 and later read the worker class registry key before they handle Set and Error. maplibre-gl, which ships in the same bundle, stamps that key on both built-ins, so mapbox-gl looks up a registry entry it never made and every vector tile fails with "Cannot read properties of undefined (reading 'omit')". The Mapbox basemap stays blank while raster layers such as satellite still load. 5.2.0 shipped mapbox-gl 3.35.2; 3.36.0-rc.1 still has the same order. Pin the last release that handles the built-ins first, keep Dependabot off 3.33 and later, and add a test that reads the shipped serializer and fails on a version with the registry read first.
This commit is contained in:
@@ -35,6 +35,13 @@ updates:
|
||||
# tooling supports it.
|
||||
- dependency-name: typescript
|
||||
update-types: [version-update:semver-major]
|
||||
# mapbox-gl 3.33 and later read the worker registry key before handling
|
||||
# Set and Error, and maplibre-gl, bundled beside it, stamps that key on
|
||||
# both built-ins: every vector tile then fails with "reading 'omit'".
|
||||
# glWorkerRegistry.test.ts fails on a version with that order; it moves
|
||||
# by hand once mapbox-gl checks the built-ins first again.
|
||||
- dependency-name: mapbox-gl
|
||||
versions: ['>=3.33.0']
|
||||
|
||||
# plugin-sdk is standalone with a lockfile of its own and ships to npm.
|
||||
- package-ecosystem: npm
|
||||
|
||||
+1
-1
@@ -112,7 +112,7 @@
|
||||
"iso-3166-2": "^1.0.0",
|
||||
"leaflet": "^1.9.4",
|
||||
"lucide-react": "^0.577.0",
|
||||
"mapbox-gl": "^3.35.2",
|
||||
"mapbox-gl": "3.32.0",
|
||||
"maplibre-gl": "6.19.0",
|
||||
"modern-screenshot": "4.7.0",
|
||||
"plyr": "^3.8.5",
|
||||
|
||||
@@ -0,0 +1,45 @@
|
||||
import { readFileSync } from 'node:fs';
|
||||
import { createRequire } from 'node:module';
|
||||
import { dirname, join } from 'node:path';
|
||||
import { describe, expect, it } from 'vitest';
|
||||
|
||||
// mapbox-gl and maplibre-gl ship in the same bundle, and both pass messages to
|
||||
// their workers through a class registry that stamps `_classRegistryKey` on
|
||||
// constructors. maplibre stamps the built-ins Set and Error globally. mapbox-gl
|
||||
// 3.33 and later read that key before their own Set and Error handling, find no
|
||||
// entry for "Set" in their registry and throw "Cannot read properties of
|
||||
// undefined (reading 'omit')" for every vector tile, so the Mapbox basemap stays
|
||||
// blank while raster layers still load. These read the shipped files because the
|
||||
// clash only exists between the two real libraries.
|
||||
const requireFromClient = createRequire(import.meta.url);
|
||||
|
||||
function distFile(pkg: string, file: string): string {
|
||||
const root = dirname(requireFromClient.resolve(`${pkg}/package.json`));
|
||||
return readFileSync(join(root, 'dist', file), 'utf8');
|
||||
}
|
||||
|
||||
function functionBody(source: string, signature: string): string {
|
||||
const start = source.indexOf(signature);
|
||||
expect(start, `${signature} not found`).toBeGreaterThan(-1);
|
||||
return source.slice(start, source.indexOf('\n}\n', start));
|
||||
}
|
||||
|
||||
describe('GL worker class registry', () => {
|
||||
it('FE-COMP-GLWORKERREGISTRY-001: maplibre-gl stamps the global Set and Error', () => {
|
||||
const maplibre = distFile('maplibre-gl', 'maplibre-gl-dev.mjs');
|
||||
expect(maplibre).toMatch(/register\("Set", Set\)/);
|
||||
expect(maplibre).toMatch(/register\("Error", Error\)/);
|
||||
});
|
||||
|
||||
it('FE-COMP-GLWORKERREGISTRY-002: mapbox-gl handles Set and Error before it reads the registry key', () => {
|
||||
const serialize = functionBody(
|
||||
distFile('mapbox-gl', 'mapbox-gl-dev.js'),
|
||||
'function serialize(input, transferables)'
|
||||
);
|
||||
const registryRead = serialize.indexOf('._classRegistryKey');
|
||||
expect(registryRead).toBeGreaterThan(-1);
|
||||
expect(serialize.indexOf('instanceof Set')).toBeGreaterThan(-1);
|
||||
expect(serialize.indexOf('instanceof Set')).toBeLessThan(registryRead);
|
||||
expect(serialize.indexOf('instanceof Error')).toBeLessThan(registryRead);
|
||||
});
|
||||
});
|
||||
Generated
+4
-4
@@ -91,7 +91,7 @@
|
||||
"iso-3166-2": "^1.0.0",
|
||||
"leaflet": "^1.9.4",
|
||||
"lucide-react": "^0.577.0",
|
||||
"mapbox-gl": "^3.35.2",
|
||||
"mapbox-gl": "3.32.0",
|
||||
"maplibre-gl": "6.19.0",
|
||||
"modern-screenshot": "4.7.0",
|
||||
"plyr": "^3.8.5",
|
||||
@@ -17859,9 +17859,9 @@
|
||||
}
|
||||
},
|
||||
"node_modules/mapbox-gl": {
|
||||
"version": "3.35.2",
|
||||
"resolved": "https://registry.npmjs.org/mapbox-gl/-/mapbox-gl-3.35.2.tgz",
|
||||
"integrity": "sha512-xM+0319FNTS2iOxl0Jelousi31L+ckzOxaXKkIlelanSe2jMlRRNVv3ESezPj6eUGlTDrfaxefk5QM6wQ3ICgg==",
|
||||
"version": "3.32.0",
|
||||
"resolved": "https://registry.npmjs.org/mapbox-gl/-/mapbox-gl-3.32.0.tgz",
|
||||
"integrity": "sha512-+P4qrlyejQYLyz1Bfzoe+d5Ff5vAghH54RNHm1q2VeAZqkSjQ5e1XlovQoSHlf4xqpRJtJG58kn8nkLwPMQung==",
|
||||
"license": "SEE LICENSE IN LICENSE.txt",
|
||||
"workspaces": [
|
||||
"src/style-spec",
|
||||
|
||||
Reference in New Issue
Block a user