Skip to content

Commit 934b096

Browse files
mfazekasclaude
andauthored
feat(ios): Remove Mapbox v10 legacy code, keep v11 only (#4126)
* feat(ios): Remove Mapbox v10 legacy code, keep v11 only This PR removes the #ifdef RNMBX_11 conditionals from iOS code, keeping only the v11 implementation as part of the 1.3.0 migration. Changes include: - Remove v10 code from offline module and legacy offline module - Clean up layer files (Circle, Fill, Line, Symbol, Heatmap, Raster, Model, Background, FillExtrusion, RasterParticle) - Clean up source files (Vector, Shape, Raster, RasterDem, Image, RasterArray) - Update style value helpers for v11-only types - Remove v10 location module, rename v11 version to main - Update component views (RasterParticle, RasterArraySource) - Clean up core components (Light, Atmosphere, Viewport, CustomHttpHeaders, MapViewManager, SnapshotModule) - Update code generation template (RNMBXStyle.swift.ejs) to not emit v11 conditionals - Update LayerPropsCommon.codepart-swift.ejs to not emit v11 conditionals This is part of the v11-only migration for @rnmapbox/maps 1.3.0. Note: Some files still have RNMBX_11 conditionals that require manual review (MapView, Camera, Layer base class, etc). * feat(ios): Remove remaining Mapbox v10 conditionals from iOS code Continue the v10 to v11-only migration by removing all remaining #if RNMBX_11 conditionals and keeping only the v11 implementations. Files updated: - RNMBXMapView.swift: Remove v10 event handlers, feature state API, cancelables - RNMBXCamera.swift: Remove v10 NSNumber extension guard, bounds API, location auth - RNMBXLayer.swift: Remove v10 styleLayerExists, slot handling, setOptions - RNMBXCameraGestureObserver.swift: Remove v10 conditional gesture handling - RNMBXCustomLocationProvider.swift: Remove v10 location provider implementation - RNMBXImages.swift: Remove v10 hasImage implementation - RNMBXMarkerView.swift: Remove v10 ViewAnnotationOptions conditionals - RNMBXModels.swift: Remove v10 removeStyleModel conditional - RNMBXModule.swift: Remove v10 accessToken and clearData implementations - RNMBXSource.swift: Remove v10 addSource signature - RNMBXStyleImport.swift: Remove v10 setStyleImportConfigProperties guard This is part of the 1.3.0 migration that only supports Mapbox v11. * yarn generate --------- Co-authored-by: Claude <noreply@anthropic.com>
1 parent 48d27a9 commit 934b096

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

45 files changed

+283
-1787
lines changed

ios/RNMBX/CustomHttpHeaders.swift

Lines changed: 0 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@ struct CustomHttpHeadersMapValue {
1010
}
1111

1212
class CustomHttpHeaders : HttpServiceInterceptorInterface {
13-
#if RNMBX_11
1413
func onRequest(for request: HttpRequest, continuation: @escaping HttpServiceInterceptorRequestContinuation) {
1514
let request = onRequest(for: request)
1615
continuation(HttpRequestOrResponse.fromHttpRequest(request))
@@ -19,7 +18,6 @@ class CustomHttpHeaders : HttpServiceInterceptorInterface {
1918
func onResponse(for response: HttpResponse, continuation: @escaping HttpServiceInterceptorResponseContinuation) {
2019
continuation(response)
2120
}
22-
#endif
2321

2422
static var shared : CustomHttpHeaders = {
2523
let headers = CustomHttpHeaders()
@@ -30,20 +28,11 @@ class CustomHttpHeaders : HttpServiceInterceptorInterface {
3028
var customHeaders : [String:CustomHttpHeadersMapValue] = [:]
3129

3230
func install() {
33-
#if RNMBX_11
3431
HttpServiceFactory.setHttpServiceInterceptorForInterceptor(self)
35-
#else
36-
HttpServiceFactory.getInstance().setInterceptorForInterceptor(self)
37-
#endif
3832
}
3933

4034
func reset() {
41-
#if RNMBX_11
4235
HttpServiceFactory.setHttpServiceInterceptorForInterceptor(nil)
43-
#else
44-
HttpServiceFactory.getInstance().setInterceptorForInterceptor(nil)
45-
46-
#endif
4736
}
4837

4938
// MARK: - HttpServiceInterceptorInterface
@@ -76,14 +65,6 @@ class CustomHttpHeaders : HttpServiceInterceptorInterface {
7665
return request
7766
}
7867

79-
#if !RNMBX_11
80-
func onDownload(forDownload download: DownloadOptions) -> DownloadOptions {
81-
let customHeaders = getCustomRequestHeaders(for: download.request, with: customHeaders)
82-
download.request.headers.merge(customHeaders) { (_, new) in new }
83-
return download
84-
}
85-
#endif
86-
8768
func onResponse(for response: HttpResponse) -> HttpResponse {
8869
return response
8970
}

ios/RNMBX/Offline/RNMBXOfflineModule.swift

Lines changed: 1 addition & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -31,19 +31,11 @@ class RNMBXOfflineModule: RCTEventEmitter {
3131
}
3232

3333
lazy var offlineManager : OfflineManager = {
34-
#if RNMBX_11
3534
return OfflineManager()
36-
#else
37-
return OfflineManager(resourceOptions: .init(accessToken: RNMBXModule.accessToken!))
38-
#endif
3935
}()
40-
36+
4137
lazy var offlineRegionManager: OfflineRegionManager = {
42-
#if RNMBX_11
4338
return OfflineRegionManager()
44-
#else
45-
return OfflineRegionManager(resourceOptions: .init(accessToken: RNMBXModule.accessToken!))
46-
#endif
4739
}()
4840

4941
lazy var tileStore : TileStore = {
@@ -363,7 +355,6 @@ class RNMBXOfflineModule: RCTEventEmitter {
363355

364356
let stylePackLoadOptions = StylePackLoadOptions(glyphsRasterizationMode: .ideographsRasterizedLocally, metadata: pack.metadata)!
365357

366-
#if RNMBX_11
367358
let threadedOfflineManager = OfflineManager()
368359
taskGroup.enter()
369360
let stylePackTask = threadedOfflineManager.loadStylePack(for: styleURI, loadOptions: stylePackLoadOptions) { progress in
@@ -391,20 +382,6 @@ class RNMBXOfflineModule: RCTEventEmitter {
391382
)
392383
let tilesetDescriptor = threadedOfflineManager.createTilesetDescriptor(for: descriptorOptions)
393384
let descriptors = [tilesetDescriptor]
394-
#else
395-
let descriptorOptions = TilesetDescriptorOptions(
396-
styleURI: styleURI,
397-
zoomRange: zoomRange,
398-
stylePackOptions: stylePackLoadOptions
399-
)
400-
let descriptor = self.offlineManager.createTilesetDescriptor(for: descriptorOptions)
401-
let tilesetDescriptorOptions = TilesetDescriptorOptionsForTilesets(tilesets: pack.tilesets, zoomRange: zoomRange)
402-
let tilesetDescriptor = self.offlineManager.createTilesetDescriptorForTilesetDescriptorOptions(tilesetDescriptorOptions)
403-
var descriptors = [descriptor]
404-
if (!pack.tilesets.isEmpty) {
405-
descriptors.append(tilesetDescriptor)
406-
}
407-
#endif
408385

409386
let loadOptions = TileRegionLoadOptions(
410387
geometry: bounds, // RNMBXFeatureUtils.geometryToGeometry(bounds),
@@ -452,11 +429,7 @@ class RNMBXOfflineModule: RCTEventEmitter {
452429
self.tileRegionPacks[id]!.state = downloadError ? .inactive : .complete
453430
}
454431

455-
#if RNMBX_11
456432
self.tileRegionPacks[id]!.cancelables = [task, stylePackTask]
457-
#else
458-
self.tileRegionPacks[id]!.cancelables = [task]
459-
#endif
460433
}
461434

462435
func convertRegionsToJSON(regions: [TileRegion], resolve: @escaping RCTPromiseResolveBlock, rejecter: @escaping RCTPromiseRejectBlock) {

ios/RNMBX/Offline/RNMBXOfflineModuleLegacy.swift

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,11 +6,7 @@ class RNMBXOfflineModuleLegacy: RCTEventEmitter {
66
final let CompleteRegionDownloadState = 2
77

88
lazy var offlineRegionManager: OfflineRegionManager = {
9-
#if RNMBX_11
109
return OfflineRegionManager()
11-
#else
12-
return OfflineRegionManager(resourceOptions: .init(accessToken: RNMBXModule.accessToken!))
13-
#endif
1410
}()
1511

1612
@objc

ios/RNMBX/RNMBXAtmosphere.swift

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,6 @@
11
import MapboxMaps
22

3-
#if RNMBX_11
43
public typealias Style = StyleManager
5-
#endif
64

75
@objc(RNMBXAtmosphere)
86
public class RNMBXAtmosphere : RNMBXSingletonLayer, RNMBXMapComponent, RNMBXSourceConsumer {

ios/RNMBX/RNMBXBackgroundLayer.swift

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,6 @@ public class RNMBXBackgroundLayer: RNMBXLayer {
66

77
override func makeLayer(style: Style) throws -> Layer {
88
var layer = LayerType(id: self.id!)
9-
#if !RNMBX_11
10-
layer.sourceLayer = self.sourceLayerID
11-
layer.source = sourceID
12-
#endif
139
return layer
1410
}
1511

ios/RNMBX/RNMBXCamera.swift

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -2,14 +2,12 @@ import Foundation
22
import MapboxMaps
33
import Turf
44

5-
#if RNMBX_11
65
extension NSNumber {
76
/// Converts an `NSNumber` to a `CGFloat` value from its `Double` representation.
87
internal var CGFloat: CGFloat {
98
CoreGraphics.CGFloat(doubleValue)
109
}
1110
}
12-
#endif
1311

1412
public enum RemovalReason {
1513
case ViewRemoval, StyleChange, OnDestroy, ComponentChange, Reorder
@@ -368,9 +366,6 @@ open class RNMBXCamera : RNMBXMapAndMapViewComponentBase {
368366
if let locationModule = RNMBXLocationModule.shared {
369367
locationModule.override(for: map.location)
370368
}
371-
#if !RNMBX_11
372-
map.location.locationProvider.requestWhenInUseAuthorization()
373-
#endif
374369
var trackingModeChanged = false
375370
var followOptions = FollowPuckViewportStateOptions()
376371
switch userTrackingMode {
@@ -518,11 +513,7 @@ open class RNMBXCamera : RNMBXMapAndMapViewComponentBase {
518513
}
519514

520515
withMapView { map in
521-
#if RNMBX_11
522516
let bounds = [sw, ne]
523-
#else
524-
let bounds = CoordinateBounds(southwest: sw, northeast: ne)
525-
#endif
526517

527518
camera = map.mapboxMap.camera(
528519
for: bounds,

ios/RNMBX/RNMBXCameraGestureObserver.swift

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -25,9 +25,7 @@ public class RNMBXCameraGestureObserver: RNMBXMapComponentBase, GestureManagerDe
2525
private var timeoutTimer: DispatchSourceTimer? = nil
2626
private var emittedForCurrentActivity: Bool = false
2727

28-
#if RNMBX_11
2928
private var _cancelables = Set<AnyCancelable>()
30-
#endif
3129

3230
private var quietMs: Double { (quietPeriodMs?.doubleValue) ?? 200.0 }
3331
private var maxMs: Double? { maxIntervalMs?.doubleValue }
@@ -43,9 +41,7 @@ public class RNMBXCameraGestureObserver: RNMBXMapComponentBase, GestureManagerDe
4341
switch gestureType {
4442
case .pan: return "pan"
4543
case .pinch: return "pinch"
46-
#if RNMBX_11
4744
case .rotation: return "rotate"
48-
#endif
4945
case .pitch: return "pitch"
5046
default: return "\(gestureType)"
5147
}
@@ -145,7 +141,6 @@ public class RNMBXCameraGestureObserver: RNMBXMapComponentBase, GestureManagerDe
145141

146142
guard hasOnMapSteady else { return }
147143

148-
#if RNMBX_11
149144
let camera = map.mapView.camera!
150145

151146
// Camera animator lifecycle
@@ -175,14 +170,11 @@ public class RNMBXCameraGestureObserver: RNMBXMapComponentBase, GestureManagerDe
175170
// Subscribe to gestures as a secondary observer (multicast from RNMBXMapView)
176171
map.addGestureDelegate(self)
177172
debugLog("addToMap and subscribed to gestures")
178-
#endif
179173
}
180174

181175
public override func removeFromMap(_ map: RNMBXMapView, reason: RemovalReason) -> Bool {
182-
#if RNMBX_11
183176
_cancelables.forEach { $0.cancel() }
184177
_cancelables.removeAll()
185-
#endif
186178
map.removeGestureDelegate(self)
187179
debugLog("removeFromMap and unsubscribed from gestures")
188180
cancelQuietTimer()

ios/RNMBX/RNMBXCircleLayer.swift

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -7,11 +7,7 @@ public class RNMBXCircleLayer: RNMBXVectorLayer {
77

88
override func makeLayer(style: Style) throws -> Layer {
99
let _ : VectorSource = try self.layerWithSourceID(in: style)
10-
#if RNMBX_11
1110
var layer = LayerType(id: self.id!, source: self.sourceID!)
12-
#else
13-
var layer = LayerType(id: self.id!)
14-
#endif
1511
layer.sourceLayer = self.sourceLayerID
1612
layer.source = sourceID
1713
return layer
@@ -26,7 +22,6 @@ public class RNMBXCircleLayer: RNMBXVectorLayer {
2622
func setCommonOptions(_ layer: inout CircleLayer) -> Bool {
2723
var changed = false
2824

29-
#if RNMBX_11
3025
if let sourceLayerID = sourceLayerID {
3126
layer.sourceLayer = sourceLayerID
3227
changed = true
@@ -49,7 +44,6 @@ public class RNMBXCircleLayer: RNMBXVectorLayer {
4944
Logger.log(level: .error, message: "parsing filters failed for layer \(optional: id): \(error.localizedDescription)")
5045
}
5146
}
52-
#endif
5347

5448
return changed
5549
}

0 commit comments

Comments
 (0)