|
1 | 1 | /** |
2 | | - * Platform-aware map components |
3 | | - * Automatically selects native (@rnmapbox/maps) or web (mapbox-gl) implementation |
| 2 | + * TypeScript type resolution shim for platform-specific Mapbox implementations. |
| 3 | + * Metro resolves mapbox.native.ts on iOS/Android and mapbox.web.ts on web, |
| 4 | + * but TypeScript needs a base file to satisfy module resolution. |
| 5 | + * This file re-exports from the native implementation so types are available. |
4 | 6 | */ |
5 | | -import { Platform } from 'react-native'; |
6 | | - |
7 | | -import * as MapboxNative from './map-view.native'; |
8 | | -import * as MapboxWeb from './map-view.web'; |
9 | | - |
10 | | -// Import the platform-specific implementation |
11 | | -// Metro bundler will resolve to the correct file based on platform |
12 | | -const MapboxImpl = Platform.OS === 'web' ? MapboxWeb.default : MapboxNative.default; |
13 | | - |
14 | | -// Re-export all components |
15 | | -export const MapView = MapboxImpl.MapView || MapboxImpl; |
16 | | -export const Camera = Platform.OS === 'web' ? MapboxWeb.Camera : MapboxNative.Camera; |
17 | | -export const PointAnnotation = Platform.OS === 'web' ? MapboxWeb.PointAnnotation : MapboxNative.PointAnnotation; |
18 | | -export const UserLocation = Platform.OS === 'web' ? MapboxWeb.UserLocation : MapboxNative.UserLocation; |
19 | | -export const MarkerView = Platform.OS === 'web' ? MapboxWeb.MarkerView : MapboxNative.MarkerView; |
20 | | -export const ShapeSource = Platform.OS === 'web' ? MapboxWeb.ShapeSource : MapboxNative.ShapeSource; |
21 | | -export const SymbolLayer = Platform.OS === 'web' ? MapboxWeb.SymbolLayer : MapboxNative.SymbolLayer; |
22 | | -export const CircleLayer = Platform.OS === 'web' ? MapboxWeb.CircleLayer : MapboxNative.CircleLayer; |
23 | | -export const LineLayer = Platform.OS === 'web' ? MapboxWeb.LineLayer : MapboxNative.LineLayer; |
24 | | -export const FillLayer = Platform.OS === 'web' ? MapboxWeb.FillLayer : MapboxNative.FillLayer; |
25 | | -export const Images = Platform.OS === 'web' ? MapboxWeb.Images : MapboxNative.Images; |
26 | | -export const Callout = Platform.OS === 'web' ? MapboxWeb.Callout : MapboxNative.Callout; |
27 | | - |
28 | | -// Export style URL constants |
29 | | -export const StyleURL = Platform.OS === 'web' ? MapboxWeb.StyleURL : MapboxNative.StyleURL; |
30 | | - |
31 | | -// Export UserTrackingMode |
32 | | -export const UserTrackingMode = Platform.OS === 'web' ? MapboxWeb.UserTrackingMode : MapboxNative.UserTrackingMode; |
33 | | - |
34 | | -// Export setAccessToken |
35 | | -export const setAccessToken = Platform.OS === 'web' ? MapboxWeb.setAccessToken : MapboxNative.setAccessToken; |
36 | | - |
37 | | -// Default export matching Mapbox structure with all properties |
38 | | -const Mapbox = { |
39 | | - ...MapboxImpl, |
40 | | - MapView: MapView, |
41 | | - Camera: Camera, |
42 | | - PointAnnotation: PointAnnotation, |
43 | | - UserLocation: UserLocation, |
44 | | - MarkerView: MarkerView, |
45 | | - ShapeSource: ShapeSource, |
46 | | - SymbolLayer: SymbolLayer, |
47 | | - CircleLayer: CircleLayer, |
48 | | - LineLayer: LineLayer, |
49 | | - FillLayer: FillLayer, |
50 | | - Images: Images, |
51 | | - Callout: Callout, |
52 | | - StyleURL: StyleURL, |
53 | | - UserTrackingMode: UserTrackingMode, |
54 | | - setAccessToken: setAccessToken, |
55 | | -}; |
56 | | - |
57 | | -export default Mapbox; |
| 7 | +export { Callout, Camera, CircleLayer, FillLayer, Images, LineLayer, MapView, MarkerView, PointAnnotation, setAccessToken, ShapeSource, StyleURL, SymbolLayer, UserLocation, UserTrackingMode } from './mapbox.native'; |
| 8 | +export { default } from './mapbox.native'; |
0 commit comments