87a738313e
- pnpm add maplibre-gl + -D @types/geojson. - src/map/core/styles.ts: defaultStyle (OSM raster bootstrap; 2.2 replaces with the basemap-switcher descriptor table). - src/map/core/map-view.tsx: module-level Map singleton lazily created on first <MapView> mount, attached to a class="trm-map-host" detached <div> that React refs append/remove on mount/unmount. Style-data lifecycle flips mapReady false on every styledata event, polls loaded() at 33ms intervals, flips ready true once the style is loaded — the canonical MapLibre style-swap dance. - Exports getMap()/getMapReady()/subscribeMapReady()/useMapReady (via useSyncExternalStore for SSR-safe + concurrent-safe reads). getMap() throws if called pre-mount; the explicit failure mode beats a null-able top-level export. - src/routes/_authed/monitor.tsx: new /monitor route, full-viewport <MapView /> for 2.1 (no children — subsequent tasks plug in here). - src/routes/_authed/index.tsx: home-page card now links to /monitor. - eslint.config.js: override for src/map/** + src/live/** disables react-refresh/only-export-components. Same pattern as the existing overrides for shadcn primitives and route files. Deviation: spec sketched a top-level `map` constant export; implemented as `getMap(): MapLibreMap` (a function) so the singleton stays lazy until <MapView> mounts. Top-level constant would either force eager init (breaks SSR/tests) or be nullable (footgun). The function form throws a clear error if called pre-mount. Bundle: /monitor lazy chunk is 1MB raw / 274KB gzipped (MapLibre + CSS). Other routes unaffected. Vite chunk-size warning is harmless.
58 lines
1.8 KiB
JavaScript
58 lines
1.8 KiB
JavaScript
import js from '@eslint/js';
|
|
import globals from 'globals';
|
|
import reactHooks from 'eslint-plugin-react-hooks';
|
|
import reactRefresh from 'eslint-plugin-react-refresh';
|
|
import tseslint from 'typescript-eslint';
|
|
import prettierRecommended from 'eslint-plugin-prettier/recommended';
|
|
import { defineConfig, globalIgnores } from 'eslint/config';
|
|
|
|
export default defineConfig([
|
|
globalIgnores([
|
|
'dist',
|
|
'src/routeTree.gen.ts',
|
|
// CI runners may use a project-local pnpm CAS at .pnpm-store.
|
|
'.pnpm-store',
|
|
'.pnpm',
|
|
'coverage',
|
|
]),
|
|
{
|
|
files: ['**/*.{ts,tsx}'],
|
|
extends: [
|
|
js.configs.recommended,
|
|
tseslint.configs.recommended,
|
|
reactHooks.configs.flat.recommended,
|
|
reactRefresh.configs.vite,
|
|
prettierRecommended,
|
|
],
|
|
languageOptions: {
|
|
globals: globals.browser,
|
|
},
|
|
},
|
|
{
|
|
// shadcn/ui primitives intentionally co-export helpers (variants, hooks)
|
|
// alongside components — disable the fast-refresh rule for these files only.
|
|
files: ['src/ui/primitives/**/*.{ts,tsx}'],
|
|
rules: {
|
|
'react-refresh/only-export-components': 'off',
|
|
},
|
|
},
|
|
{
|
|
// TanStack Router file-based routes export `Route` (the route definition)
|
|
// alongside the route's component. That's the canonical pattern; the
|
|
// fast-refresh rule doesn't apply usefully here.
|
|
files: ['src/routes/**/*.{ts,tsx}'],
|
|
rules: {
|
|
'react-refresh/only-export-components': 'off',
|
|
},
|
|
},
|
|
{
|
|
// Map and live modules co-export non-component utilities (singletons,
|
|
// factories, hooks) alongside React components. The fast-refresh rule
|
|
// doesn't apply usefully here.
|
|
files: ['src/map/**/*.{ts,tsx}', 'src/live/**/*.{ts,tsx}'],
|
|
rules: {
|
|
'react-refresh/only-export-components': 'off',
|
|
},
|
|
},
|
|
]);
|