@autobusal/common 1.33.5 → 1.33.6

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -1,5 +1,17 @@
1
1
  # Changelog
2
2
 
3
+ ## 1.33.6
4
+
5
+ ### Added
6
+
7
+ - **New `Map/Tiles` component - the one place the basemap comes from.** The same `TileLayer` line was copy-pasted into `Drive.tsx`, `@autobusal/map`'s `Display.tsx` and magus's own `RouteMap.tsx`, with a fourth copy in the mobile app, all hardcoding `tile.openstreetmap.org`. OSM's Tile Usage Policy does not cover commercial or heavy application use, and those servers throttle or block by referer and volume without notice - so the exposure was never the bill, it was that reacting to a block meant editing three repos, publishing to npm, redeploying both frontends and shipping a mobile store release.
8
+
9
+ The URL now comes from `/settings/get` (`map.tile_url`) rather than the build, so all four clients switch from one server env var. `null` - the state until a provider is chosen - means the built-in OpenStreetMap default, so this changes nothing for anyone on upgrade. Attribution is rendered by the component rather than travelling with the URL, since ODbL requires it whoever serves the tiles.
10
+
11
+ ### Changed
12
+
13
+ - `Drive.tsx` renders `<Tiles />` instead of its own `TileLayer`.
14
+
3
15
  ## 1.33.4
4
16
 
5
17
  ### Added
package/Drive/Drive.tsx CHANGED
@@ -1,7 +1,8 @@
1
1
  import { TFunction } from 'i18next';
2
- import { MapContainer, TileLayer, Marker, Popup, Polyline } from 'react-leaflet';
2
+ import { MapContainer, Marker, Popup, Polyline } from 'react-leaflet';
3
3
  import { latLngBounds } from 'leaflet';
4
4
  import { getCoordinates, getPosition, hasPosition, autobusMarker } from './utilities';
5
+ import Tiles from '../Map/Tiles';
5
6
  import { Container, Loading, Disclaimer } from './styles';
6
7
  import { LocationData } from '@autobusal/providers/types/locations';
7
8
  import { useGetDriveData } from './services';
@@ -79,7 +80,7 @@ const Drive = ({ locations, t }: Props): JSX.Element => {
79
80
  maxZoom={ 15 }
80
81
  scrollWheelZoom={ true }
81
82
  >
82
- <TileLayer attribution="&copy; <a href='http://osm.org/copyright'>OpenStreetMap</a> contributors" url="https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png" />
83
+ <Tiles />
83
84
 
84
85
  { markers }
85
86
 
package/Map/Tiles.tsx ADDED
@@ -0,0 +1,56 @@
1
+ import { TileLayer } from 'react-leaflet';
2
+ import { useGetSettings } from '@autobusal/providers/services';
3
+
4
+ /**
5
+ * The one place the basemap comes from.
6
+ *
7
+ * Added: Claude (audit) - Date: 2026-08-17
8
+ *
9
+ * The same TileLayer line was copy-pasted into common's Drive.tsx and map's
10
+ * Display.tsx, with a third copy in the mobile app's Leaflet HTML. All three
11
+ * hardcoded `tile.openstreetmap.org`, whose Tile Usage Policy does not cover
12
+ * commercial or heavy application use - those servers are donation funded for
13
+ * OSM's own purposes and they throttle or block by referer and volume, without
14
+ * notice.
15
+ *
16
+ * The exposure was never the bill, it was how long a switch would take. With
17
+ * the URL inlined in a published package, reacting to a block meant editing
18
+ * three repos, publishing to npm, redeploying both frontends AND shipping a
19
+ * mobile store release - days of broken maps, the last stretch of it waiting
20
+ * on app review.
21
+ *
22
+ * SO THE URL COMES FROM /settings/get, NOT FROM THE BUILD. That is the mobile
23
+ * app's constraint (a compiled-in URL there needs a store release to change),
24
+ * and following it here means all three clients switch from ONE place - a
25
+ * server env var and a cache flush - rather than each on its own release
26
+ * cadence. `useGetSettings` is already resolved at bootstrap with
27
+ * `staleTime: Infinity`, so this reads the warm cache and costs no request.
28
+ *
29
+ * `tile_url` is null until a provider is actually chosen, which means the
30
+ * OpenStreetMap default below - so this lands with nothing changing anywhere
31
+ * and waits on no decision.
32
+ *
33
+ * ATTRIBUTION IS NOT PART OF THE SWITCH. ODbL requires crediting OpenStreetMap
34
+ * for the underlying data whoever serves the tiles, so it is rendered here
35
+ * rather than travelling with the URL - a provider swap must not be able to
36
+ * drop it. A provider needing its own credit too should have it appended, not
37
+ * substituted.
38
+ */
39
+ const OPENSTREETMAP = 'https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png';
40
+
41
+ const ATTRIBUTION = "&copy; <a href='http://osm.org/copyright'>OpenStreetMap</a> contributors";
42
+
43
+ interface Props {
44
+ /** Overrides the configured basemap. Rarely needed - prefer the server setting. */
45
+ url?: string
46
+ }
47
+
48
+ const Tiles = ({ url }: Props): JSX.Element => {
49
+ const { data: settings } = useGetSettings();
50
+
51
+ return (
52
+ <TileLayer attribution={ ATTRIBUTION } url={ url ?? settings.map?.tile_url ?? OPENSTREETMAP } />
53
+ );
54
+ };
55
+
56
+ export default Tiles;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@autobusal/common",
3
- "version": "1.33.5",
3
+ "version": "1.33.6",
4
4
  "author": "Ferjolt Ozuni",
5
5
  "type": "module",
6
6
  "main": "index.ts"