Files
TREK/client/src/components/Map/glLazy.tsx
T
Maurice b7951baf23 fix(ci): green the dev gates after the native and popup rounds
- RTL: the measured pills and centred controls use logical forms or a marked line
- i18n: the two native widget numbers are positions, not counts (NOT_PLURAL)
- Types: styleOverride on the lazy GL map, the location and shared-file payloads,
  the capabilities fallback, the transport sheet's stay metadata
- ESLint: latest-value refs move to layout effects, usePresence keeps the last
  open state in state, the booking import opens clean with a shared document
  kept in the list (the reset effect used to clear it again)
- Layers: the phone import sheet lives under mobile/ and reads through tripRepo;
  the offline host check moves to utils/tileUrl
- Sizes: plugin layer geometry, hardNavigate and the exit animations get
  modules of their own
- Tests follow the status radios, the stay chip overview, the dock + button
  for the first list and the field token; store registry lists the new stores
2026-11-06 18:24:25 +01:00

87 lines
3.8 KiB
TypeScript

import type { ComponentType } from 'react'
import { lazyWithRetry } from '../../utils/lazyWithRetry'
import type { GlMapProvider } from './glProviders'
import type { MapViewProps } from './mapViewContract'
/** What a caller hands the GL trip map: the shared map contract and which provider's style to load. */
export type MapViewGLProps = MapViewProps & {
glProvider?: GlMapProvider
/** A style URL that replaces the provider's, as the offline fallback map (MapViewAuto). */
styleOverride?: string
}
/**
* The six ways into a GL map, one chunk per engine.
*
* mapbox-gl and maplibre-gl used to be static imports inside MapViewGL,
* JourneyMapGL and the settings preview, so rollup put both SDKs into a single
* 2.8 MB chunk. Every map user downloaded 1.8 MB of mapbox plus 1.1 MB of
* maplibre and then ran exactly one of them.
*
* Pairing the component with its engine behind the lazy boundary is what
* separates them: no module reaches both SDKs statically any more, so rolldown
* emits one shared core chunk and two engine chunks. The engine arrives as a
* prop — see the `gl` prop on each component.
*
* Both imports start together rather than in sequence: the engine is by far the
* larger of the two, and waiting for the component first would add its round
* trip in front of the download that actually costs time.
*/
export const MapViewGLMapbox = lazyWithRetry(async () => {
const [component, engine] = await Promise.all([import('./MapViewGL'), import('./engines/mapbox')])
const MapViewGL = component.MapViewGL
const bound = (props: MapViewGLProps) => <MapViewGL {...props} gl={engine.default} />
return { default: bound satisfies ComponentType<MapViewGLProps> }
})
export const MapViewGLMaplibre = lazyWithRetry(async () => {
const [component, engine] = await Promise.all([import('./MapViewGL'), import('./engines/maplibre')])
const MapViewGL = component.MapViewGL
const bound = (props: MapViewGLProps) => <MapViewGL {...props} gl={engine.default} />
return { default: bound satisfies ComponentType<MapViewGLProps> }
})
export const JourneyMapGLMapbox = lazyWithRetry(async () => {
const [component, engine] = await Promise.all([
import('../Journey/JourneyMapGL'),
import('./engines/mapbox'),
])
const JourneyMapGL = component.default
// The journey map exposes an imperative handle (highlightMarker / focusMarker /
// invalidateSize). Since React 19 its ref is an ordinary prop, so it rides
// through the spread and the binding needs no forwardRef wrapper.
// eslint-disable-next-line @typescript-eslint/no-explicit-any
return { default: (props: any) => <JourneyMapGL {...props} gl={engine.default} /> }
})
export const JourneyMapGLMaplibre = lazyWithRetry(async () => {
const [component, engine] = await Promise.all([
import('../Journey/JourneyMapGL'),
import('./engines/maplibre'),
])
const JourneyMapGL = component.default
// eslint-disable-next-line @typescript-eslint/no-explicit-any
return { default: (props: any) => <JourneyMapGL {...props} gl={engine.default} /> }
})
export const GlMapPreviewMapbox = lazyWithRetry(async () => {
const [component, engine] = await Promise.all([
import('../Settings/MapboxPreview'),
import('./engines/mapbox'),
])
const GlMapPreview = component.default
// eslint-disable-next-line @typescript-eslint/no-explicit-any
return { default: (props: any) => <GlMapPreview {...props} gl={engine.default} /> }
})
export const GlMapPreviewMaplibre = lazyWithRetry(async () => {
const [component, engine] = await Promise.all([
import('../Settings/MapboxPreview'),
import('./engines/maplibre'),
])
const GlMapPreview = component.default
// eslint-disable-next-line @typescript-eslint/no-explicit-any
return { default: (props: any) => <GlMapPreview {...props} gl={engine.default} /> }
})