@maplibre/maplibre-react-native 11.3.0 → 11.3.2

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.
@@ -1,4 +1,5 @@
1
1
  require "json"
2
+ require "securerandom"
2
3
 
3
4
  package = JSON.parse(File.read(File.join(__dir__, "package.json")))
4
5
 
@@ -15,19 +16,31 @@ $MLRN_SPM_SPEC ||= {
15
16
 
16
17
  $MLRN = Object.new
17
18
 
19
+ # Prevent UUID collisions https://github.com/maplibre/maplibre-react-native/issues/1499
20
+ def $MLRN._mlrn_unique_uuid(project)
21
+ loop do
22
+ candidate = SecureRandom.hex(12).upcase
23
+ return candidate unless project.objects_by_uuid.key?(candidate)
24
+ end
25
+ end
26
+
18
27
  def $MLRN._add_spm_to_target(project, target, url, requirement, product_name)
19
28
  pkg_class = Xcodeproj::Project::Object::XCRemoteSwiftPackageReference
20
29
  ref_class = Xcodeproj::Project::Object::XCSwiftPackageProductDependency
21
30
  pkg = project.root_object.package_references.find { |p| p.class == pkg_class && p.repositoryURL == url }
22
31
  if !pkg
23
- pkg = project.new(pkg_class)
32
+ pkg_uuid = self._mlrn_unique_uuid(project)
33
+ pkg = pkg_class.new(project, pkg_uuid)
34
+ project.objects_by_uuid[pkg_uuid] = pkg
24
35
  pkg.repositoryURL = url
25
36
  project.root_object.package_references << pkg
26
37
  end
27
38
  pkg.requirement = requirement
28
39
  ref = target.package_product_dependencies.find { |r| r.class == ref_class && r.package == pkg && r.product_name == product_name }
29
40
  if !ref
30
- ref = project.new(ref_class)
41
+ ref_uuid = self._mlrn_unique_uuid(project)
42
+ ref = ref_class.new(project, ref_uuid)
43
+ project.objects_by_uuid[ref_uuid] = ref
31
44
  ref.package = pkg
32
45
  ref.product_name = product_name
33
46
  target.package_product_dependencies << ref
@@ -136,20 +136,26 @@ abstract class MLRNSource<T : Source?>(
136
136
  }
137
137
 
138
138
  fun removeLayer(childPosition: Int) {
139
+ val queuedLayers = mQueuedLayers
139
140
  val layer: MLRNLayer? =
140
- if (mQueuedLayers != null && mQueuedLayers!!.isNotEmpty()) {
141
- mQueuedLayers!![childPosition]
141
+ if (!queuedLayers.isNullOrEmpty()) {
142
+ queuedLayers.getOrNull(childPosition)
142
143
  } else {
143
- mLayers[childPosition]
144
+ mLayers.getOrNull(childPosition)
144
145
  }
146
+
147
+ if (layer == null) return
148
+
145
149
  removeLayerFromMap(layer, childPosition)
146
150
  }
147
151
 
148
152
  fun getLayerAt(childPosition: Int): MLRNLayer? {
149
- if (mQueuedLayers != null && mQueuedLayers!!.isNotEmpty()) {
150
- return mQueuedLayers!![childPosition]
153
+ val queuedLayers = mQueuedLayers
154
+ if (!queuedLayers.isNullOrEmpty()) {
155
+ return queuedLayers.getOrNull(childPosition)
151
156
  }
152
- return mLayers[childPosition]
157
+
158
+ return mLayers.getOrNull(childPosition)
153
159
  }
154
160
 
155
161
  protected fun addLayerToMap(
@@ -273,18 +273,16 @@ static double const M2PI = M_PI * 2;
273
273
  NSMutableArray<MLRNSource *> *hitTouchableSources = [[NSMutableArray alloc] init];
274
274
  for (MLRNSource *touchableSource in touchableSources) {
275
275
  NSDictionary<NSString *, NSNumber *> *hitbox = touchableSource.hitbox;
276
- float halfWidth = [hitbox[@"width"] floatValue] / 2.f;
277
- float halfHeight = [hitbox[@"height"] floatValue] / 2.f;
278
-
279
- CGFloat top = screenPoint.y - halfHeight;
280
- CGFloat left = screenPoint.x - halfWidth;
276
+ float top = [hitbox[@"top"] floatValue];
277
+ float right = [hitbox[@"right"] floatValue];
278
+ float bottom = [hitbox[@"bottom"] floatValue];
279
+ float left = [hitbox[@"left"] floatValue];
281
280
  CGRect hitboxRect =
282
- CGRectMake(left, top, [hitbox[@"width"] floatValue], [hitbox[@"height"] floatValue]);
281
+ CGRectMake(screenPoint.x - left, screenPoint.y - top, left + right, top + bottom);
283
282
 
284
283
  NSArray<id<MLNFeature>> *features =
285
284
  [self visibleFeaturesInRect:hitboxRect
286
- inStyleLayersWithIdentifiers:[NSSet setWithArray:[touchableSource getLayerIDs]]
287
- predicate:nil];
285
+ inStyleLayersWithIdentifiers:[NSSet setWithArray:[touchableSource getLayerIDs]]];
288
286
 
289
287
  if (features.count > 0) {
290
288
  hits[touchableSource.id] = features;
@@ -5,13 +5,11 @@
5
5
 
6
6
  @implementation MLRNSource
7
7
 
8
- double const DEFAULT_HITBOX_AREA = 44.0;
9
-
10
8
  - (instancetype)initWithFrame:(CGRect)frame {
11
9
  if (self = [super initWithFrame:frame]) {
12
10
  _layers = [[NSMutableArray alloc] init];
13
11
  _reactSubviews = [[NSMutableArray alloc] init];
14
- _hitbox = @{@"width" : @(DEFAULT_HITBOX_AREA), @"height" : @(DEFAULT_HITBOX_AREA)};
12
+ _hitbox = @{@"top" : @22.0f, @"right" : @22.0f, @"bottom" : @22.0f, @"left" : @22.0f};
15
13
  }
16
14
  return self;
17
15
  }
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@maplibre/maplibre-react-native",
3
3
  "description": "React Native library for creating maps with MapLibre Native for Android & iOS",
4
- "version": "11.3.0",
4
+ "version": "11.3.2",
5
5
  "publishConfig": {
6
6
  "access": "public",
7
7
  "provenance": true