@rnmapbox/maps 10.0.10-rc.1 → 10.0.10-rc.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,5 +1,5 @@
1
1
  def defaultMapboxMapsImpl = "maplibre"
2
- def defaultMapboxMapsVersion = "10.14.0"
2
+ def defaultMapboxMapsVersion = "10.14.1"
3
3
 
4
4
  def safeExtGet(prop, fallback) {
5
5
  rootProject.ext.has(prop) ? rootProject.ext.get(prop) : fallback
@@ -362,11 +362,30 @@ class RCTMGLStyleValue {
362
362
  func mglStyleValueLineCap() -> Value<LineCap> {
363
363
  return mglStyleValueEnum()
364
364
  }
365
+
366
+ func parseExpression(_ expression: [Any]) throws -> Expression {
367
+ let data = try JSONSerialization.data(withJSONObject: expression, options: .prettyPrinted)
368
+ let decodedExpression = try JSONDecoder().decode(Expression.self, from: data)
369
+ return decodedExpression
370
+ }
365
371
 
366
372
  func mglStyleValueEnum<Enum : RawRepresentable>() -> Value<Enum> where Enum.RawValue == String {
367
373
  if let value = value as? Dictionary<String,Any> {
368
374
  let value = RCTMGLStyleValue.convert(value["stylevalue"] as! [String:Any])
369
- return Value.constant(Enum(rawValue: value as! String)!)
375
+ if let value = value as? String {
376
+ return Value.constant(Enum(rawValue: value )!)
377
+ } else if let value = value as? [Any] {
378
+ if let parsedExpression = (logged("mglStyleValueEnum: failed to parse expression") {
379
+ try parseExpression(value)
380
+ }) {
381
+ return .expression(parsedExpression)
382
+ } else {
383
+ return Value.constant(Enum(rawValue: value[0] as! String)!)
384
+ }
385
+ } else {
386
+ Logger.log(level: .error, message:"Invalid value for enum (nor string, not array): \(value) returning something")
387
+ return Value.constant(Enum(rawValue: value as! String)!)
388
+ }
370
389
  } else {
371
390
  Logger.log(level: .error, message:"Invalid value for enum: \(value) returning something")
372
391
  return Value.constant(Enum(rawValue: value as! String)!)
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@rnmapbox/maps",
3
3
  "description": "A Mapbox react native module for creating custom maps",
4
- "version": "10.0.10-rc.1",
4
+ "version": "10.0.10-rc.2",
5
5
  "publishConfig": {
6
6
  "access": "public"
7
7
  },