bc54f1e811
- pnpm add maplibre-google-maps (runtime; lazy-imported on Google use). - src/map/core/styles.ts: BasemapDescriptor model with four entries (Esri Satellite / OpenTopoMap / OSM / Google Satellite). Google entry gated on cfg.googleMapsKey via available(cfg). styleCustom() builds a single-raster-source MapLibre style with a glyphs URL for future label rendering. ensureGoogleProtocol() lazy-loads maplibre-google-maps + addProtocol on first use; _googleRegistered guards re-registration. - src/map/core/map-pref-store.ts: Zustand + persist middleware (key: trm-map-prefs, version: 1). Holds basemapId + setBasemap. - src/map/core/basemap-switcher.tsx: floating control top-right of <MapView>. Filters by available(cfg), highlights active, applies via getMap().setStyle(). Mount-time bootstrap (no UI state) + user-driven onClick (with switching state) split to satisfy React 19's react-hooks/set-state-in-effect rule. - src/routes/_authed/monitor.tsx: renders <BasemapSwitcher /> as a child of <MapView>. - src/vite-env.d.ts: ambient module declaration for maplibre-google-maps (no .d.ts ships in the package). Deviations: - BasemapDescriptor.style is buildStyle(cfg): StyleSpecification, not the spec's StyleSpecification|string union. Google needs the cfg key at build time; uniform function shape across all entries is cleaner. - Bootstrap apply path doesn't use the switching UI state (no visual feedback needed during the silent first-paint flip from OSM to user preference). User-click path keeps setSwitching for the in-flight indicator. Bundle: MapLibre is now its own chunk (1MB / 273KB gz), shared across maplibre consumers. Main bundle 371KB / 114KB gz.
27 lines
1017 B
TypeScript
27 lines
1017 B
TypeScript
/// <reference types="vite/client" />
|
|
|
|
interface ImportMetaEnv {
|
|
/** Local-dev convenience: prefill the login form's email field. Only consumed when import.meta.env.DEV. */
|
|
readonly VITE_ADMIN_EMAIL?: string;
|
|
/** Local-dev convenience: prefill the login form's password field. Only consumed when import.meta.env.DEV. */
|
|
readonly VITE_ADMIN_PASSWORD?: string;
|
|
/** Override the dev proxy's Directus target. See vite.config.ts. */
|
|
readonly VITE_DEV_DIRECTUS_URL?: string;
|
|
/** Override the dev proxy's Processor WS target. See vite.config.ts. */
|
|
readonly VITE_DEV_PROCESSOR_WS_URL?: string;
|
|
}
|
|
|
|
interface ImportMeta {
|
|
readonly env: ImportMetaEnv;
|
|
}
|
|
|
|
/**
|
|
* `maplibre-google-maps` ships an `index.js` without type declarations.
|
|
* The protocol handler we consume has a stable signature documented in
|
|
* the package's README; declare the surface we use.
|
|
*/
|
|
declare module 'maplibre-google-maps' {
|
|
import type { AddProtocolAction } from 'maplibre-gl';
|
|
export const googleProtocol: AddProtocolAction;
|
|
}
|