@maplibre/maplibre-react-native 11.3.1 → 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(
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.1",
4
+ "version": "11.3.2",
5
5
  "publishConfig": {
6
6
  "access": "public",
7
7
  "provenance": true