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.
60 lines
1.7 KiB
JSON
60 lines
1.7 KiB
JSON
{
|
|
"name": "spa",
|
|
"private": true,
|
|
"version": "0.0.0",
|
|
"type": "module",
|
|
"scripts": {
|
|
"dev": "vite",
|
|
"build": "pnpm route-tree && tsc -b && vite build",
|
|
"preview": "vite preview",
|
|
"lint": "eslint .",
|
|
"typecheck": "pnpm route-tree && tsc -b --noEmit",
|
|
"format": "prettier --write .",
|
|
"format:check": "prettier --check .",
|
|
"route-tree": "tsr generate",
|
|
"test": "echo \"no tests yet\" && exit 0"
|
|
},
|
|
"dependencies": {
|
|
"@directus/sdk": "^21.3.0",
|
|
"@hookform/resolvers": "^5.2.2",
|
|
"@tanstack/react-query": "^5.100.8",
|
|
"@tanstack/react-router": "^1.169.1",
|
|
"class-variance-authority": "^0.7.1",
|
|
"clsx": "^2.1.1",
|
|
"lucide-react": "^1.14.0",
|
|
"maplibre-gl": "^5.24.0",
|
|
"maplibre-google-maps": "^1.1.0",
|
|
"radix-ui": "^1.4.3",
|
|
"react": "^19.2.5",
|
|
"react-dom": "^19.2.5",
|
|
"react-hook-form": "^7.75.0",
|
|
"tailwind-merge": "^3.5.0",
|
|
"zod": "^4.4.2",
|
|
"zustand": "^5.0.12"
|
|
},
|
|
"devDependencies": {
|
|
"@eslint/js": "^10.0.1",
|
|
"@tailwindcss/vite": "^4.2.4",
|
|
"@tanstack/react-query-devtools": "^5.100.8",
|
|
"@tanstack/react-router-devtools": "^1.166.13",
|
|
"@tanstack/router-cli": "^1.166.40",
|
|
"@tanstack/router-plugin": "^1.167.32",
|
|
"@types/geojson": "^7946.0.16",
|
|
"@types/node": "^24.12.2",
|
|
"@types/react": "^19.2.14",
|
|
"@types/react-dom": "^19.2.3",
|
|
"@vitejs/plugin-react": "^6.0.1",
|
|
"eslint": "^10.2.1",
|
|
"eslint-config-prettier": "^10.1.8",
|
|
"eslint-plugin-prettier": "^5.5.5",
|
|
"eslint-plugin-react-hooks": "^7.1.1",
|
|
"eslint-plugin-react-refresh": "^0.5.2",
|
|
"globals": "^17.5.0",
|
|
"prettier": "^3.8.3",
|
|
"tailwindcss": "^4.2.4",
|
|
"typescript": "~6.0.2",
|
|
"typescript-eslint": "^8.58.2",
|
|
"vite": "^8.0.10"
|
|
}
|
|
}
|