@rnmapbox/maps 10.3.0-rc.0 → 10.3.1

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.
Files changed (115) hide show
  1. package/android/src/main/java/com/rnmapbox/rnmbx/RNMBXPackage.kt +4 -0
  2. package/android/src/main/java/com/rnmapbox/rnmbx/components/annotation/RNMBXMarkerViewContent.kt +55 -0
  3. package/android/src/main/java/com/rnmapbox/rnmbx/components/annotation/RNMBXMarkerViewContentManager.kt +7 -2
  4. package/android/src/main/java/com/rnmapbox/rnmbx/components/annotation/RNMBXMarkerViewManager.kt +0 -2
  5. package/android/src/main/java/com/rnmapbox/rnmbx/components/location/RNMBXNativeUserLocationManager.kt +25 -24
  6. package/android/src/main/java/com/rnmapbox/rnmbx/components/mapview/NativeMapViewModule.kt +3 -2
  7. package/android/src/main/java/com/rnmapbox/rnmbx/components/mapview/RNMBXMapView.kt +57 -39
  8. package/android/src/main/java/com/rnmapbox/rnmbx/components/mapview/RNMBXMapViewManager.kt +0 -9
  9. package/android/src/main/java/com/rnmapbox/rnmbx/components/styles/RNMBXStyleFactory.kt +638 -0
  10. package/android/src/main/java/com/rnmapbox/rnmbx/components/styles/atmosphere/RNMBXAtmosphere.kt +4 -4
  11. package/android/src/main/java/com/rnmapbox/rnmbx/components/styles/atmosphere/RNMBXAtmosphereManager.kt +2 -1
  12. package/android/src/main/java/com/rnmapbox/rnmbx/components/styles/light/RNMBXLightManager.kt +2 -1
  13. package/android/src/main/java/com/rnmapbox/rnmbx/components/styles/rain/RNMBXRain.kt +83 -0
  14. package/android/src/main/java/com/rnmapbox/rnmbx/components/styles/rain/RNMBXRainManager.kt +40 -0
  15. package/android/src/main/java/com/rnmapbox/rnmbx/components/styles/snow/RNMBXSnow.kt +66 -0
  16. package/android/src/main/java/com/rnmapbox/rnmbx/components/styles/snow/RNMBXSnowManager.kt +40 -0
  17. package/android/src/main/java/com/rnmapbox/rnmbx/components/styles/sources/RNMBXSource.kt +2 -6
  18. package/android/src/main/java/com/rnmapbox/rnmbx/components/styles/terrain/RNMBXTerrainManager.kt +2 -1
  19. package/android/src/main/java/com/rnmapbox/rnmbx/events/FeatureClickEvent.java +5 -6
  20. package/android/src/main/java/com/rnmapbox/rnmbx/modules/RNMBXModule.kt +1 -0
  21. package/android/src/main/java/com/rnmapbox/rnmbx/utils/ConvertUtils.kt +0 -30
  22. package/android/src/main/java/com/rnmapbox/rnmbx/utils/extensions/Dynamic.kt +3 -1
  23. package/android/src/main/java/com/rnmapbox/rnmbx/utils/extensions/ReadableArray.kt +16 -14
  24. package/ios/RNMBX/RNMBXAtmosphereComponentView.mm +2 -1
  25. package/ios/RNMBX/RNMBXBackgroundLayerComponentView.mm +2 -1
  26. package/ios/RNMBX/RNMBXBridgeManager.h +8 -0
  27. package/ios/RNMBX/RNMBXBridgeManager.m +16 -0
  28. package/ios/RNMBX/RNMBXCircleLayerComponentView.mm +2 -1
  29. package/ios/RNMBX/RNMBXFillExtrusionLayerComponentView.mm +2 -1
  30. package/ios/RNMBX/RNMBXFillLayerComponentView.mm +2 -1
  31. package/ios/RNMBX/RNMBXHeatmapLayerComponentView.mm +2 -1
  32. package/ios/RNMBX/RNMBXHillshadeLayerComponentView.mm +2 -1
  33. package/ios/RNMBX/RNMBXImageModule.h +1 -0
  34. package/ios/RNMBX/RNMBXImageModule.mm +15 -2
  35. package/ios/RNMBX/RNMBXImageQueue.swift +9 -1
  36. package/ios/RNMBX/RNMBXImages.swift +4 -0
  37. package/ios/RNMBX/RNMBXImagesComponentView.mm +2 -1
  38. package/ios/RNMBX/RNMBXLightComponentView.mm +2 -1
  39. package/ios/RNMBX/RNMBXLineLayerComponentView.mm +2 -1
  40. package/ios/RNMBX/RNMBXMapViewModule.mm +1 -1
  41. package/ios/RNMBX/RNMBXModelLayerComponentView.mm +2 -1
  42. package/ios/RNMBX/RNMBXModule.swift +1 -0
  43. package/ios/RNMBX/RNMBXRain.swift +92 -0
  44. package/ios/RNMBX/RNMBXRainComponentView.h +14 -0
  45. package/ios/RNMBX/RNMBXRainComponentView.mm +80 -0
  46. package/ios/RNMBX/RNMBXRasterLayerComponentView.mm +2 -1
  47. package/ios/RNMBX/RNMBXRasterParticleLayerComponentView.mm +2 -1
  48. package/ios/RNMBX/RNMBXSkyLayerComponentView.mm +2 -1
  49. package/ios/RNMBX/RNMBXSnow.swift +76 -0
  50. package/ios/RNMBX/RNMBXSnowComponentView.h +14 -0
  51. package/ios/RNMBX/RNMBXSnowComponentView.mm +80 -0
  52. package/ios/RNMBX/RNMBXStyle.swift +415 -9
  53. package/ios/RNMBX/RNMBXStyleValue.swift +7 -1
  54. package/ios/RNMBX/RNMBXSymbolLayerComponentView.mm +2 -1
  55. package/ios/RNMBX/RNMBXTerrainComponentView.mm +2 -1
  56. package/lib/commonjs/plugin/install.md +2 -2
  57. package/lib/module/Mapbox.native.js +2 -0
  58. package/lib/module/Mapbox.native.js.map +1 -1
  59. package/lib/module/components/MapView.js +95 -113
  60. package/lib/module/components/MapView.js.map +1 -1
  61. package/lib/module/components/MarkerView.js +93 -76
  62. package/lib/module/components/MarkerView.js.map +1 -1
  63. package/lib/module/components/Rain.js +19 -0
  64. package/lib/module/components/Rain.js.map +1 -0
  65. package/lib/module/components/Snow.js +19 -0
  66. package/lib/module/components/Snow.js.map +1 -0
  67. package/lib/module/modules/offline/offlineManager.js +2 -12
  68. package/lib/module/modules/offline/offlineManager.js.map +1 -1
  69. package/lib/module/specs/RNMBXMarkerViewContentNativeComponent.ts +13 -1
  70. package/lib/module/specs/RNMBXRainNativeComponent.ts +13 -0
  71. package/lib/module/specs/RNMBXSnowNativeComponent.ts +13 -0
  72. package/lib/module/utils/styleMap.js +20 -0
  73. package/lib/module/utils/styleMap.js.map +1 -1
  74. package/lib/typescript/scripts/autogenHelpers/generateCodeWithEjs.d.mts +71 -2
  75. package/lib/typescript/scripts/autogenHelpers/generateCodeWithEjs.d.mts.map +1 -1
  76. package/lib/typescript/scripts/autogenHelpers/globals.d.mts +1 -1
  77. package/lib/typescript/scripts/autogenHelpers/globals.d.mts.map +1 -1
  78. package/lib/typescript/src/Mapbox.native.d.ts +3 -1
  79. package/lib/typescript/src/Mapbox.native.d.ts.map +1 -1
  80. package/lib/typescript/src/components/Callout.d.ts +3 -3
  81. package/lib/typescript/src/components/Camera.d.ts +2 -2
  82. package/lib/typescript/src/components/Camera.d.ts.map +1 -1
  83. package/lib/typescript/src/components/MapView.d.ts +53 -41
  84. package/lib/typescript/src/components/MapView.d.ts.map +1 -1
  85. package/lib/typescript/src/components/MarkerView.d.ts +10 -17
  86. package/lib/typescript/src/components/MarkerView.d.ts.map +1 -1
  87. package/lib/typescript/src/components/Rain.d.ts +17 -0
  88. package/lib/typescript/src/components/Rain.d.ts.map +1 -0
  89. package/lib/typescript/src/components/Snow.d.ts +8 -0
  90. package/lib/typescript/src/components/Snow.d.ts.map +1 -0
  91. package/lib/typescript/src/modules/offline/offlineManager.d.ts.map +1 -1
  92. package/lib/typescript/src/specs/RNMBXMarkerViewContentNativeComponent.d.ts +6 -0
  93. package/lib/typescript/src/specs/RNMBXMarkerViewContentNativeComponent.d.ts.map +1 -1
  94. package/lib/typescript/src/specs/RNMBXRainNativeComponent.d.ts +8 -0
  95. package/lib/typescript/src/specs/RNMBXRainNativeComponent.d.ts.map +1 -0
  96. package/lib/typescript/src/specs/RNMBXSnowNativeComponent.d.ts +8 -0
  97. package/lib/typescript/src/specs/RNMBXSnowNativeComponent.d.ts.map +1 -0
  98. package/lib/typescript/src/utils/MapboxStyles.d.ts +171 -1
  99. package/lib/typescript/src/utils/MapboxStyles.d.ts.map +1 -1
  100. package/lib/typescript/src/utils/styleMap.d.ts.map +1 -1
  101. package/package.json +12 -3
  102. package/plugin/install.md +2 -2
  103. package/setup-jest.js +1 -1
  104. package/src/Mapbox.native.ts +7 -1
  105. package/src/components/Camera.tsx +2 -2
  106. package/src/components/MapView.tsx +137 -154
  107. package/src/components/MarkerView.tsx +118 -95
  108. package/src/components/Rain.tsx +31 -0
  109. package/src/components/Snow.tsx +22 -0
  110. package/src/modules/offline/offlineManager.ts +2 -14
  111. package/src/specs/RNMBXMarkerViewContentNativeComponent.ts +13 -1
  112. package/src/specs/RNMBXRainNativeComponent.ts +13 -0
  113. package/src/specs/RNMBXSnowNativeComponent.ts +13 -0
  114. package/src/utils/MapboxStyles.ts +191 -0
  115. package/src/utils/styleMap.ts +22 -0
@@ -67,7 +67,15 @@ class RNMBXImageQueueOperation : Operation {
67
67
 
68
68
  DispatchQueue.global(qos: .default).async {
69
69
  if let weakSelf = weakSelf {
70
- let loader : RCTImageLoaderProtocol = weakSelf.bridge!.module(forName: "ImageLoader", lazilyLoadIfNecessary: true) as! RCTImageLoaderProtocol
70
+ guard let bridge = weakSelf.bridge else {
71
+ Logger.log(level: .error, message: "RNMBXImageQueue: bridge is nil, cannot load image")
72
+ if let completionHandler = weakSelf.completionHandler {
73
+ completionHandler(NSError(domain: "RNMBXImageQueue", code: 1, userInfo: [NSLocalizedDescriptionKey: "bridge is nil"]), nil)
74
+ }
75
+ _ = weakSelf.setState(state:.Finished, except:.Finished)
76
+ return
77
+ }
78
+ let loader : RCTImageLoaderProtocol = bridge.module(forName: "ImageLoader", lazilyLoadIfNecessary: true) as! RCTImageLoaderProtocol
71
79
 
72
80
  let cancellationBlock = loader.loadImage(with: weakSelf.urlRequest, size: .zero, scale: CGFloat(weakSelf.scale), clipped: true, resizeMode: .stretch, progressBlock: { _,_ in }, partialLoad: { _ in }) { error, image in
73
81
  if let completionHandler = weakSelf.completionHandler {
@@ -130,6 +130,10 @@ open class RNMBXImages : UIView, RNMBXMapComponent {
130
130
  }
131
131
 
132
132
  if missingImages.count > 0 {
133
+ guard let bridge = bridge else {
134
+ Logger.log(level: .error, message: "RNMBXImages: bridge is nil, cannot fetch images. Use nativeAssetImages instead.")
135
+ return
136
+ }
133
137
  RNMBXUtils.fetchImages(bridge, style: style, objects: missingImages, forceUpdate: true) { name, image in
134
138
  self.loadedImages.insert(name)
135
139
  self.imageManager?.resolve(name: name, image: image)
@@ -5,6 +5,7 @@
5
5
  #include "RNMBXImageComponentView.h"
6
6
 
7
7
  #import <React/RCTBridge+Private.h>
8
+ #import "RNMBXBridgeManager.h"
8
9
  #import <React/RCTConversions.h>
9
10
  #import <React/RCTFabricComponentsPlugins.h>
10
11
 
@@ -42,7 +43,7 @@ using namespace facebook::react;
42
43
  - (void)prepareView
43
44
  {
44
45
  _view = [[RNMBXImages alloc] init];
45
- _view.bridge = [RCTBridge currentBridge];
46
+ _view.bridge = [RNMBXBridgeManager currentBridge];
46
47
 
47
48
  // capture weak self reference to prevent retain cycle
48
49
  __weak __typeof__(self) weakSelf = self;
@@ -3,6 +3,7 @@
3
3
  #import "RNMBXFabricHelpers.h"
4
4
 
5
5
  #import <React/RCTBridge+Private.h>
6
+ #import "RNMBXBridgeManager.h"
6
7
  #import <React/RCTConversions.h>
7
8
  #import <React/RCTFabricComponentsPlugins.h>
8
9
 
@@ -40,7 +41,7 @@ using namespace facebook::react;
40
41
  - (void)prepareView
41
42
  {
42
43
  _view = [[RNMBXLight alloc] init];
43
- _view.bridge = [RCTBridge currentBridge];
44
+ _view.bridge = [RNMBXBridgeManager currentBridge];
44
45
  self.contentView = _view;
45
46
  }
46
47
 
@@ -5,6 +5,7 @@
5
5
  #import <React/RCTConversions.h>
6
6
  #import <React/RCTFabricComponentsPlugins.h>
7
7
  #import <React/RCTBridge+Private.h>
8
+ #import "RNMBXBridgeManager.h"
8
9
 
9
10
  #import <react/renderer/components/rnmapbox_maps_specs/ComponentDescriptors.h>
10
11
  #import <react/renderer/components/rnmapbox_maps_specs/EventEmitters.h>
@@ -40,7 +41,7 @@ using namespace facebook::react;
40
41
  - (void)prepareView
41
42
  {
42
43
  _view = [[RNMBXLineLayer alloc] init];
43
- _view.bridge = [RCTBridge currentBridge];
44
+ _view.bridge = [RNMBXBridgeManager currentBridge];
44
45
  self.contentView = _view;
45
46
  }
46
47
 
@@ -60,7 +60,7 @@ RCT_EXPORT_METHOD(getCoordinateFromView:(nonnull NSNumber*)viewRef atPoint:(NSAr
60
60
  NSNumber* a = [atPoint objectAtIndex:0];
61
61
  NSNumber* b = [atPoint objectAtIndex:1];
62
62
 
63
- [view getCoordinateFromViewWithAtPoint:CGPointMake(a.floatValue, b.floatValue) resolver:resolve rejecter:reject];
63
+ [view getCoordinateFromViewWithAtPoint:CGPointMake(a.doubleValue, b.doubleValue) resolver:resolve rejecter:reject];
64
64
  } reject:reject methodName:@"getCoordinateFromView"];
65
65
  }
66
66
 
@@ -5,6 +5,7 @@
5
5
  #import <React/RCTConversions.h>
6
6
  #import <React/RCTFabricComponentsPlugins.h>
7
7
  #import <React/RCTBridge+Private.h>
8
+ #import "RNMBXBridgeManager.h"
8
9
 
9
10
  #import <react/renderer/components/rnmapbox_maps_specs/ComponentDescriptors.h>
10
11
  #import <react/renderer/components/rnmapbox_maps_specs/EventEmitters.h>
@@ -40,7 +41,7 @@ using namespace facebook::react;
40
41
  - (void)prepareView
41
42
  {
42
43
  _view = [[RNMBXModelLayer alloc] init];
43
- _view.bridge = [RCTBridge currentBridge];
44
+ _view.bridge = [RNMBXBridgeManager currentBridge];
44
45
  self.contentView = _view;
45
46
  }
46
47
 
@@ -23,6 +23,7 @@ class RNMBXModule : NSObject {
23
23
  @objc
24
24
  func constantsToExport() -> [AnyHashable: Any]! {
25
25
  return [
26
+ // Deprecated: means v10 or later, always true. Will be removed in next major version.
26
27
  "MapboxV10":true,
27
28
  "StyleURL":
28
29
  [
@@ -0,0 +1,92 @@
1
+ @_spi(Experimental) import MapboxMaps
2
+
3
+ @objc(RNMBXRain)
4
+ public class RNMBXRain : RNMBXSingletonLayer, RNMBXMapComponent, RNMBXSourceConsumer {
5
+ var rain : Rain? = nil
6
+
7
+ func makeRain() -> Rain {
8
+ return Rain()
9
+ }
10
+
11
+ public func addToMap(_ map: RNMBXMapView, style: Style) {
12
+ self.map = map
13
+ self.style = style
14
+
15
+ warnIfMeasureLightUnavailable(style: style)
16
+
17
+ let rain = self.makeRain()
18
+ self.rain = rain
19
+ addStylesAndUpdate()
20
+ }
21
+
22
+ private func warnIfMeasureLightUnavailable(style: Style) {
23
+ let hasLights = !style.allLightIdentifiers.isEmpty
24
+ if hasLights { return }
25
+
26
+ let affectedProps = ["color", "opacity", "vignetteColor"]
27
+ let missingProps = affectedProps.filter { reactStyle?[$0] == nil }
28
+ if missingProps.isEmpty { return }
29
+
30
+ Logger.log(level: .warn, message: "RNMBXRain: The current style has no 3D lights, so " +
31
+ "measure-light(\"brightness\") expressions used in default rain " +
32
+ "\(missingProps.joined(separator: ", ")) will fail. Use a Standard style or set " +
33
+ "explicit values for: \(missingProps.joined(separator: ", "))")
34
+ }
35
+
36
+ public func removeFromMap(_ map: RNMBXMapView, reason _: RemovalReason) -> Bool {
37
+ self.map = nil
38
+
39
+ guard let mapboxMap = map.mapboxMap else {
40
+ return false
41
+ }
42
+
43
+ let style = mapboxMap.style
44
+ removeFromMap(map, style: style)
45
+ return true
46
+ }
47
+
48
+ public func waitForStyleLoad() -> Bool {
49
+ return true
50
+ }
51
+
52
+ func removeFromMap(_ map: RNMBXMapView, style: Style) {
53
+ logged("RNMBXRain.removeFromMap") {
54
+ try style.removeRain()
55
+ }
56
+ }
57
+
58
+ override func addStylesAndUpdate() {
59
+ guard rain != nil else {
60
+ return
61
+ }
62
+
63
+ super.addStylesAndUpdate()
64
+ }
65
+
66
+ override func addStyles() {
67
+ if let style : Style = self.style,
68
+ let reactStyle = self.reactStyle {
69
+ let styler = RNMBXStyle(style: style)
70
+ styler.bridge = self.bridge
71
+
72
+ if var rain = rain {
73
+ styler.rainLayer(
74
+ layer: &rain,
75
+ reactStyle: reactStyle,
76
+ oldReactStyle: oldReactStyle,
77
+ applyUpdater: { (updater) in fatalError("Rain: TODO - implement apply updater")},
78
+ isValid: { fatalError("Rain: TODO - no isValid") }
79
+ )
80
+ self.rain = rain
81
+ } else {
82
+ fatalError("[xxx] rain is nil \(optional: self.rain)")
83
+ }
84
+ }
85
+ }
86
+
87
+ override func apply(style : Style) throws {
88
+ if let rain = rain {
89
+ try style.setRain(rain)
90
+ }
91
+ }
92
+ }
@@ -0,0 +1,14 @@
1
+ #ifdef __cplusplus
2
+
3
+ #import <UIKit/UIKit.h>
4
+
5
+ #import <React/RCTUIManager.h>
6
+ #import <React/RCTViewComponentView.h>
7
+
8
+ NS_ASSUME_NONNULL_BEGIN
9
+
10
+ @interface RNMBXRainComponentView : RCTViewComponentView
11
+ @end
12
+
13
+ NS_ASSUME_NONNULL_END
14
+ #endif // __cplusplus
@@ -0,0 +1,80 @@
1
+
2
+ #import "RNMBXRainComponentView.h"
3
+ #import "RNMBXFabricHelpers.h"
4
+
5
+ #import <React/RCTBridge+Private.h>
6
+ #import "RNMBXBridgeManager.h"
7
+ #import <React/RCTConversions.h>
8
+ #import <React/RCTFabricComponentsPlugins.h>
9
+
10
+ #import <react/renderer/components/rnmapbox_maps_specs/ComponentDescriptors.h>
11
+ #import <react/renderer/components/rnmapbox_maps_specs/EventEmitters.h>
12
+ #import <react/renderer/components/rnmapbox_maps_specs/Props.h>
13
+ #import <react/renderer/components/rnmapbox_maps_specs/RCTComponentViewHelpers.h>
14
+
15
+ using namespace facebook::react;
16
+
17
+ @interface RNMBXRainComponentView () <RCTRNMBXRainViewProtocol>
18
+ @end
19
+
20
+ @implementation RNMBXRainComponentView {
21
+ RNMBXRain *_view;
22
+ }
23
+
24
+ // Needed because of this: https://github.com/facebook/react-native/pull/37274
25
+ + (void)load
26
+ {
27
+ [super load];
28
+ }
29
+
30
+ - (instancetype)initWithFrame:(CGRect)frame
31
+ {
32
+ if (self = [super initWithFrame:frame]) {
33
+ static const auto defaultProps = std::make_shared<const RNMBXRainProps>();
34
+ _props = defaultProps;
35
+ [self prepareView];
36
+ }
37
+
38
+ return self;
39
+ }
40
+
41
+ - (void)prepareView
42
+ {
43
+ _view = [[RNMBXRain alloc] init];
44
+ _view.bridge = [RNMBXBridgeManager currentBridge];
45
+
46
+ self.contentView = _view;
47
+ }
48
+
49
+ #pragma mark - RCTComponentViewProtocol
50
+
51
+ + (ComponentDescriptorProvider)componentDescriptorProvider
52
+ {
53
+ return concreteComponentDescriptorProvider<RNMBXRainComponentDescriptor>();
54
+ }
55
+
56
+
57
+ - (void)updateProps:(const Props::Shared &)props oldProps:(const Props::Shared &)oldProps
58
+ {
59
+ const auto &newProps = static_cast<const RNMBXRainProps &>(*props);
60
+ id reactStyle = RNMBXConvertFollyDynamicToId(newProps.reactStyle);
61
+ if (reactStyle != nil) {
62
+ _view.reactStyle = reactStyle;
63
+ }
64
+
65
+ [super updateProps:props oldProps:oldProps];
66
+ }
67
+
68
+ - (void)prepareForRecycle
69
+ {
70
+ [super prepareForRecycle];
71
+ [self prepareView];
72
+ }
73
+
74
+
75
+ @end
76
+
77
+ Class<RCTComponentViewProtocol> RNMBXRainCls(void)
78
+ {
79
+ return RNMBXRainComponentView.class;
80
+ }
@@ -5,6 +5,7 @@
5
5
  #import <React/RCTConversions.h>
6
6
  #import <React/RCTFabricComponentsPlugins.h>
7
7
  #import <React/RCTBridge+Private.h>
8
+ #import "RNMBXBridgeManager.h"
8
9
 
9
10
  #import <react/renderer/components/rnmapbox_maps_specs/ComponentDescriptors.h>
10
11
  #import <react/renderer/components/rnmapbox_maps_specs/EventEmitters.h>
@@ -40,7 +41,7 @@ using namespace facebook::react;
40
41
  - (void)prepareView
41
42
  {
42
43
  _view = [[RNMBXRasterLayer alloc] init];
43
- _view.bridge = [RCTBridge currentBridge];
44
+ _view.bridge = [RNMBXBridgeManager currentBridge];
44
45
  self.contentView = _view;
45
46
  }
46
47
 
@@ -5,6 +5,7 @@
5
5
  #import <React/RCTConversions.h>
6
6
  #import <React/RCTFabricComponentsPlugins.h>
7
7
  #import <React/RCTBridge+Private.h>
8
+ #import "RNMBXBridgeManager.h"
8
9
 
9
10
  #import <react/renderer/components/rnmapbox_maps_specs/ComponentDescriptors.h>
10
11
  #import <react/renderer/components/rnmapbox_maps_specs/EventEmitters.h>
@@ -40,7 +41,7 @@ using namespace facebook::react;
40
41
  - (void)prepareView
41
42
  {
42
43
  _view = [[RNMBXRasterParticleLayer alloc] init];
43
- _view.bridge = [RCTBridge currentBridge];
44
+ _view.bridge = [RNMBXBridgeManager currentBridge];
44
45
  self.contentView = _view;
45
46
  }
46
47
 
@@ -5,6 +5,7 @@
5
5
  #import <React/RCTConversions.h>
6
6
  #import <React/RCTFabricComponentsPlugins.h>
7
7
  #import <React/RCTBridge+Private.h>
8
+ #import "RNMBXBridgeManager.h"
8
9
 
9
10
  #import <react/renderer/components/rnmapbox_maps_specs/ComponentDescriptors.h>
10
11
  #import <react/renderer/components/rnmapbox_maps_specs/EventEmitters.h>
@@ -40,7 +41,7 @@ using namespace facebook::react;
40
41
  - (void)prepareView
41
42
  {
42
43
  _view = [[RNMBXSkyLayer alloc] init];
43
- _view.bridge = [RCTBridge currentBridge];
44
+ _view.bridge = [RNMBXBridgeManager currentBridge];
44
45
  self.contentView = _view;
45
46
  }
46
47
 
@@ -0,0 +1,76 @@
1
+ @_spi(Experimental) import MapboxMaps
2
+
3
+ @objc(RNMBXSnow)
4
+ public class RNMBXSnow : RNMBXSingletonLayer, RNMBXMapComponent, RNMBXSourceConsumer {
5
+ var snow : Snow? = nil
6
+
7
+ func makeSnow() -> Snow {
8
+ return Snow()
9
+ }
10
+
11
+ public func addToMap(_ map: RNMBXMapView, style: Style) {
12
+ self.map = map
13
+ self.style = style
14
+
15
+ let snow = self.makeSnow()
16
+ self.snow = snow
17
+ addStylesAndUpdate()
18
+ }
19
+
20
+ public func removeFromMap(_ map: RNMBXMapView, reason _: RemovalReason) -> Bool {
21
+ self.map = nil
22
+
23
+ guard let mapboxMap = map.mapboxMap else {
24
+ return false
25
+ }
26
+
27
+ let style = mapboxMap.style
28
+ removeFromMap(map, style: style)
29
+ return true
30
+ }
31
+
32
+ public func waitForStyleLoad() -> Bool {
33
+ return true
34
+ }
35
+
36
+ func removeFromMap(_ map: RNMBXMapView, style: Style) {
37
+ logged("RNMBXSnow.removeFromMap") {
38
+ try style.removeSnow()
39
+ }
40
+ }
41
+
42
+ override func addStylesAndUpdate() {
43
+ guard snow != nil else {
44
+ return
45
+ }
46
+
47
+ super.addStylesAndUpdate()
48
+ }
49
+
50
+ override func addStyles() {
51
+ if let style : Style = self.style,
52
+ let reactStyle = self.reactStyle {
53
+ let styler = RNMBXStyle(style: style)
54
+ styler.bridge = self.bridge
55
+
56
+ if var snow = snow {
57
+ styler.snowLayer(
58
+ layer: &snow,
59
+ reactStyle: reactStyle,
60
+ oldReactStyle: oldReactStyle,
61
+ applyUpdater: { (updater) in fatalError("Snow: TODO - implement apply updater")},
62
+ isValid: { fatalError("Snow: TODO - no isValid") }
63
+ )
64
+ self.snow = snow
65
+ } else {
66
+ fatalError("[xxx] snow is nil \(optional: self.snow)")
67
+ }
68
+ }
69
+ }
70
+
71
+ override func apply(style : Style) throws {
72
+ if let snow = snow {
73
+ try style.setSnow(snow)
74
+ }
75
+ }
76
+ }
@@ -0,0 +1,14 @@
1
+ #ifdef __cplusplus
2
+
3
+ #import <UIKit/UIKit.h>
4
+
5
+ #import <React/RCTUIManager.h>
6
+ #import <React/RCTViewComponentView.h>
7
+
8
+ NS_ASSUME_NONNULL_BEGIN
9
+
10
+ @interface RNMBXSnowComponentView : RCTViewComponentView
11
+ @end
12
+
13
+ NS_ASSUME_NONNULL_END
14
+ #endif // __cplusplus
@@ -0,0 +1,80 @@
1
+
2
+ #import "RNMBXSnowComponentView.h"
3
+ #import "RNMBXFabricHelpers.h"
4
+
5
+ #import <React/RCTBridge+Private.h>
6
+ #import "RNMBXBridgeManager.h"
7
+ #import <React/RCTConversions.h>
8
+ #import <React/RCTFabricComponentsPlugins.h>
9
+
10
+ #import <react/renderer/components/rnmapbox_maps_specs/ComponentDescriptors.h>
11
+ #import <react/renderer/components/rnmapbox_maps_specs/EventEmitters.h>
12
+ #import <react/renderer/components/rnmapbox_maps_specs/Props.h>
13
+ #import <react/renderer/components/rnmapbox_maps_specs/RCTComponentViewHelpers.h>
14
+
15
+ using namespace facebook::react;
16
+
17
+ @interface RNMBXSnowComponentView () <RCTRNMBXSnowViewProtocol>
18
+ @end
19
+
20
+ @implementation RNMBXSnowComponentView {
21
+ RNMBXSnow *_view;
22
+ }
23
+
24
+ // Needed because of this: https://github.com/facebook/react-native/pull/37274
25
+ + (void)load
26
+ {
27
+ [super load];
28
+ }
29
+
30
+ - (instancetype)initWithFrame:(CGRect)frame
31
+ {
32
+ if (self = [super initWithFrame:frame]) {
33
+ static const auto defaultProps = std::make_shared<const RNMBXSnowProps>();
34
+ _props = defaultProps;
35
+ [self prepareView];
36
+ }
37
+
38
+ return self;
39
+ }
40
+
41
+ - (void)prepareView
42
+ {
43
+ _view = [[RNMBXSnow alloc] init];
44
+ _view.bridge = [RNMBXBridgeManager currentBridge];
45
+
46
+ self.contentView = _view;
47
+ }
48
+
49
+ #pragma mark - RCTComponentViewProtocol
50
+
51
+ + (ComponentDescriptorProvider)componentDescriptorProvider
52
+ {
53
+ return concreteComponentDescriptorProvider<RNMBXSnowComponentDescriptor>();
54
+ }
55
+
56
+
57
+ - (void)updateProps:(const Props::Shared &)props oldProps:(const Props::Shared &)oldProps
58
+ {
59
+ const auto &newProps = static_cast<const RNMBXSnowProps &>(*props);
60
+ id reactStyle = RNMBXConvertFollyDynamicToId(newProps.reactStyle);
61
+ if (reactStyle != nil) {
62
+ _view.reactStyle = reactStyle;
63
+ }
64
+
65
+ [super updateProps:props oldProps:oldProps];
66
+ }
67
+
68
+ - (void)prepareForRecycle
69
+ {
70
+ [super prepareForRecycle];
71
+ [self prepareView];
72
+ }
73
+
74
+
75
+ @end
76
+
77
+ Class<RCTComponentViewProtocol> RNMBXSnowCls(void)
78
+ {
79
+ return RNMBXSnowComponentView.class;
80
+ }