fix(20-02): remove static maplibre-gl.css import, fix type errors, wire onTimeRangeChanged

- Remove static maplibre-gl.css import from main.ts (now co-located in MapContainer.ts)
- Move onTimeRangeChanged callback into map init callback (map is lazy now)
- Fix IntersectionObserver entry destructure for strict TypeScript
- MapLibre CSS loads only when MapContainer is dynamically imported

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
Sebastien Melki
2026-04-15 19:58:06 +03:00
parent 9ba1eddee4
commit 07a4930222
3 changed files with 9 additions and 8 deletions

View File

@@ -688,8 +688,9 @@ export class PanelLayoutManager implements AppModule {
mapContainer.appendChild(mapPlaceholder);
const mapObserver = new IntersectionObserver(
async ([entry]) => {
if (!entry.isIntersecting) return;
async (entries) => {
const entry = entries[0];
if (!entry?.isIntersecting) return;
mapObserver.disconnect();
try {
@@ -717,6 +718,11 @@ export class PanelLayoutManager implements AppModule {
this.ctx.map.initEscalationGetters();
this.ctx.currentTimeRange = this.ctx.map.getTimeRange();
this.ctx.map.onTimeRangeChanged((range) => {
this.ctx.currentTimeRange = range;
this.applyTimeRangeFilterDebounced();
});
// Panels using this.ctx.map?.setCenter() already use optional chaining
// so they gracefully handle the map being null before this point.
} catch (err) {
@@ -1419,11 +1425,6 @@ export class PanelLayoutManager implements AppModule {
window.addEventListener('resize', () => this.ensureCorrectZones());
this.ctx.map.onTimeRangeChanged((range) => {
this.ctx.currentTimeRange = range;
this.applyTimeRangeFilterDebounced();
});
this.applyPanelSettings();
this.applyInitialUrlState();

View File

@@ -3,6 +3,7 @@
* Renders DeckGLMap (WebGL) on desktop, fallback to D3/SVG MapComponent on mobile.
* Supports an optional 3D globe mode (globe.gl) selectable from Settings.
*/
import 'maplibre-gl/dist/maplibre-gl.css';
import { isMobileDevice } from '@/utils';
import { MapComponent } from './Map';
import { DeckGLMap, type DeckMapView, type CountryClickPayload } from './DeckGLMap';

View File

@@ -1,6 +1,5 @@
import './styles/base-layer.css';
import './styles/happy-theme.css';
import 'maplibre-gl/dist/maplibre-gl.css';
// === Pre-Sentry error buffer ===
// Captures errors thrown before Sentry loads (deferred to requestIdleCallback).