@rnmapbox/maps 10.1.0-rc.1 → 10.1.0-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.
package/README.md CHANGED
@@ -220,7 +220,7 @@ const styles = StyleSheet.create({
220
220
 
221
221
  ### Misc
222
222
 
223
- - [Mapbox](/docs/MapboxGL.md)
223
+ - [Mapbox](/docs/Mapbox.md)
224
224
  - [CustomHttpHeaders](/docs/CustomHttpHeaders.md)
225
225
  - [Logger](/docs/Logger.md)
226
226
 
@@ -14,12 +14,15 @@ import com.facebook.react.bridge.ReactMethod
14
14
  import com.facebook.react.common.MapBuilder
15
15
  import com.mapbox.common.*
16
16
  import com.mapbox.maps.MapView
17
+ import com.mapbox.maps.MapboxMap
17
18
  import com.mapbox.maps.Style
18
19
  import com.mapbox.maps.plugin.attribution.attribution
19
20
  import com.rnmapbox.rnmbx.components.camera.constants.CameraMode
21
+ import com.rnmapbox.rnmbx.utils.Logger
20
22
  import java.util.HashMap
21
23
 
22
24
  import com.rnmapbox.rnmbx.v11compat.resourceoption.*
25
+ import com.rnmapbox.rnmbx.v11compat.mapboxmap.*
23
26
 
24
27
  @ReactModule(name = RNMBXModule.REACT_CLASS)
25
28
  class RNMBXModule(private val mReactContext: ReactApplicationContext) : ReactContextBaseJavaModule(
@@ -128,6 +131,19 @@ class RNMBXModule(private val mReactContext: ReactApplicationContext) : ReactCon
128
131
  }
129
132
  }
130
133
 
134
+ @ReactMethod
135
+ fun clearData(promise: Promise) {
136
+ mReactContext.runOnUiQueueThread {
137
+ MapboxMap.clearData(mReactContext) {
138
+ if (it.isValue) {
139
+ promise.resolve(it.value)
140
+ } else {
141
+ promise.reject("error", "RNMBXModule.clearError ${it.error}")
142
+ }
143
+ }
144
+ }
145
+ }
146
+
131
147
  @ReactMethod
132
148
  fun setAccessToken(accessToken: String?, promise: Promise) {
133
149
  mReactContext.runOnUiQueueThread(Runnable {
@@ -138,7 +154,7 @@ class RNMBXModule(private val mReactContext: ReactApplicationContext) : ReactCon
138
154
 
139
155
  @ReactMethod
140
156
  fun setWellKnownTileServer(tileServer: String?) {
141
- // NO-OP
157
+ Logger.e(LOG_TAG, "setWellKnownTileServer is deprecated and will be removed")
142
158
  }
143
159
 
144
160
  @ReactMethod
@@ -153,6 +169,7 @@ class RNMBXModule(private val mReactContext: ReactApplicationContext) : ReactCon
153
169
 
154
170
  companion object {
155
171
  const val REACT_CLASS = "RNMBXModule"
172
+ const val LOG_TAG = "RNMBXModule"
156
173
  private val customHeaderInterceptorAdded = false
157
174
  @JvmStatic
158
175
  fun getAccessToken(reactContext: ReactApplicationContext?): String {
@@ -1,7 +1,14 @@
1
1
  package com.rnmapbox.rnmbx.v11compat.mapboxmap;
2
2
 
3
3
  import android.animation.Animator
4
+ import android.app.Activity
5
+ import android.content.Context
6
+ import android.content.ContextWrapper
7
+ import androidx.activity.result.contract.ActivityResultContracts
8
+ import com.mapbox.bindgen.Expected
9
+ import com.mapbox.bindgen.None
4
10
  import com.mapbox.maps.CameraOptions
11
+ import com.mapbox.maps.MapView
5
12
  import com.mapbox.maps.MapboxMap
6
13
  import com.mapbox.maps.plugin.animation.MapAnimationOptions
7
14
  import com.mapbox.maps.plugin.animation.easeTo
@@ -29,3 +36,7 @@ fun MapboxMap.easeToV11(
29
36
 
30
37
  )
31
38
  }
39
+
40
+ fun MapboxMap.Companion.clearData(context: Context, callback: (result: Expected<String, None>) -> Unit) {
41
+ MapView(context).getMapboxMap().clearData(callback)
42
+ }
@@ -1,6 +1,7 @@
1
1
  package com.rnmapbox.rnmbx.v11compat.mapboxmap
2
2
 
3
3
  import android.animation.Animator
4
+ import android.content.Context
4
5
  import com.mapbox.maps.AsyncOperationResultCallback
5
6
  import com.mapbox.maps.CameraOptions
6
7
  import com.mapbox.maps.MapboxMap
@@ -34,4 +35,8 @@ fun MapboxMap.easeToV11(
34
35
 
35
36
  fun MapboxMap.clearData(callback: AsyncOperationResultCallback) {
36
37
  return MapboxMap.clearData(callback)
38
+ }
39
+
40
+ fun MapboxMap.Companion.clearData(context: Context, callback: AsyncOperationResultCallback) {
41
+ this.clearData(callback)
37
42
  }
@@ -9,6 +9,6 @@ RCT_EXTERN_METHOD(removeCustomHeader:(NSString *)headerName)
9
9
 
10
10
  RCT_EXTERN_METHOD(setTelemetryEnabled:(BOOL)telemetryEnabled)
11
11
  RCT_EXTERN_METHOD(setWellKnownTileServer:(NSString *)tileServer)
12
-
12
+ RCT_EXTERN_METHOD(clearData:(RCTPromiseResolveBlock)resolve rejecter:(RCTPromiseRejectBlock)reject)
13
13
 
14
14
  @end
@@ -113,4 +113,28 @@ class RNMBXModule : NSObject {
113
113
  Logger.error("setWellKnownTileServer: \(tileServer) should be mapbox")
114
114
  }
115
115
  }
116
+
117
+ @objc func clearData(_ resolver: @escaping RCTPromiseResolveBlock,
118
+ rejecter: @escaping RCTPromiseRejectBlock) {
119
+
120
+ DispatchQueue.main.async {
121
+ #if RNMBX_11
122
+ MapboxMap.clearData { error in
123
+ if let error = error {
124
+ rejecter("error", error.localizedDescription, error)
125
+ } else {
126
+ resolver(nil)
127
+ }
128
+ }
129
+ #else
130
+ MapboxMap.clearData(for: ResourceOptions(accessToken: RNMBXModule.accessToken ?? "")) { error in
131
+ if let error = error {
132
+ rejecter("error", error.localizedDescription, error)
133
+ } else {
134
+ resolver(nil)
135
+ }
136
+ }
137
+ #endif
138
+ }
139
+ }
116
140
  }
@@ -3,7 +3,7 @@
3
3
  Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
- exports.setWellKnownTileServer = exports.setTelemetryEnabled = exports.setConnected = exports.setAccessToken = exports.removeCustomHeader = exports.getAccessToken = exports.addCustomHeader = exports.TileServers = exports.StyleURL = exports.StyleSource = exports.OfflinePackDownloadState = exports.LineJoin = void 0;
6
+ exports.setWellKnownTileServer = exports.setTelemetryEnabled = exports.setConnected = exports.setAccessToken = exports.removeCustomHeader = exports.getAccessToken = exports.clearData = exports.addCustomHeader = exports.TileServers = exports.StyleURL = exports.StyleSource = exports.OfflinePackDownloadState = exports.LineJoin = void 0;
7
7
  var _reactNative = require("react-native");
8
8
  const RNMBXModule = {
9
9
  ..._reactNative.NativeModules.RNMBXModule
@@ -18,6 +18,7 @@ const {
18
18
  addCustomHeader,
19
19
  setAccessToken,
20
20
  setWellKnownTileServer,
21
+ clearData,
21
22
  getAccessToken,
22
23
  setTelemetryEnabled,
23
24
  setConnected
@@ -25,6 +26,7 @@ const {
25
26
  exports.setConnected = setConnected;
26
27
  exports.setTelemetryEnabled = setTelemetryEnabled;
27
28
  exports.getAccessToken = getAccessToken;
29
+ exports.clearData = clearData;
28
30
  exports.setWellKnownTileServer = setWellKnownTileServer;
29
31
  exports.setAccessToken = setAccessToken;
30
32
  exports.addCustomHeader = addCustomHeader;
@@ -1 +1 @@
1
- {"version":3,"names":["_reactNative","require","RNMBXModule","NativeModules","StyleURL","OfflinePackDownloadState","LineJoin","StyleSource","TileServers","removeCustomHeader","addCustomHeader","setAccessToken","setWellKnownTileServer","getAccessToken","setTelemetryEnabled","setConnected","exports"],"sourceRoot":"../../src","sources":["RNMBXModule.ts"],"mappings":";;;;;;AAAA,IAAAA,YAAA,GAAAC,OAAA;AAsCA,MAAMC,WAAwB,GAAG;EAAE,GAAGC,0BAAa,CAACD;AAAY,CAAC;AAE1D,MAAM;EACXE,QAAQ;EACRC,wBAAwB;EACxBC,QAAQ;EACRC,WAAW;EACXC,WAAW;EACXC,kBAAkB;EAClBC,eAAe;EACfC,cAAc;EACdC,sBAAsB;EACtBC,cAAc;EACdC,mBAAmB;EACnBC;AACF,CAAC,GAAGb,WAAW;AAACc,OAAA,CAAAD,YAAA,GAAAA,YAAA;AAAAC,OAAA,CAAAF,mBAAA,GAAAA,mBAAA;AAAAE,OAAA,CAAAH,cAAA,GAAAA,cAAA;AAAAG,OAAA,CAAAJ,sBAAA,GAAAA,sBAAA;AAAAI,OAAA,CAAAL,cAAA,GAAAA,cAAA;AAAAK,OAAA,CAAAN,eAAA,GAAAA,eAAA;AAAAM,OAAA,CAAAP,kBAAA,GAAAA,kBAAA;AAAAO,OAAA,CAAAR,WAAA,GAAAA,WAAA;AAAAQ,OAAA,CAAAT,WAAA,GAAAA,WAAA;AAAAS,OAAA,CAAAV,QAAA,GAAAA,QAAA;AAAAU,OAAA,CAAAX,wBAAA,GAAAA,wBAAA;AAAAW,OAAA,CAAAZ,QAAA,GAAAA,QAAA"}
1
+ {"version":3,"names":["_reactNative","require","RNMBXModule","NativeModules","StyleURL","OfflinePackDownloadState","LineJoin","StyleSource","TileServers","removeCustomHeader","addCustomHeader","setAccessToken","setWellKnownTileServer","clearData","getAccessToken","setTelemetryEnabled","setConnected","exports"],"sourceRoot":"../../src","sources":["RNMBXModule.ts"],"mappings":";;;;;;AAAA,IAAAA,YAAA,GAAAC,OAAA;AAuCA,MAAMC,WAAwB,GAAG;EAAE,GAAGC,0BAAa,CAACD;AAAY,CAAC;AAE1D,MAAM;EACXE,QAAQ;EACRC,wBAAwB;EACxBC,QAAQ;EACRC,WAAW;EACXC,WAAW;EACXC,kBAAkB;EAClBC,eAAe;EACfC,cAAc;EACdC,sBAAsB;EACtBC,SAAS;EACTC,cAAc;EACdC,mBAAmB;EACnBC;AACF,CAAC,GAAGd,WAAW;AAACe,OAAA,CAAAD,YAAA,GAAAA,YAAA;AAAAC,OAAA,CAAAF,mBAAA,GAAAA,mBAAA;AAAAE,OAAA,CAAAH,cAAA,GAAAA,cAAA;AAAAG,OAAA,CAAAJ,SAAA,GAAAA,SAAA;AAAAI,OAAA,CAAAL,sBAAA,GAAAA,sBAAA;AAAAK,OAAA,CAAAN,cAAA,GAAAA,cAAA;AAAAM,OAAA,CAAAP,eAAA,GAAAA,eAAA;AAAAO,OAAA,CAAAR,kBAAA,GAAAA,kBAAA;AAAAQ,OAAA,CAAAT,WAAA,GAAAA,WAAA;AAAAS,OAAA,CAAAV,WAAA,GAAAA,WAAA;AAAAU,OAAA,CAAAX,QAAA,GAAAA,QAAA;AAAAW,OAAA,CAAAZ,wBAAA,GAAAA,wBAAA;AAAAY,OAAA,CAAAb,QAAA,GAAAA,QAAA"}
@@ -12,6 +12,7 @@ export const {
12
12
  addCustomHeader,
13
13
  setAccessToken,
14
14
  setWellKnownTileServer,
15
+ clearData,
15
16
  getAccessToken,
16
17
  setTelemetryEnabled,
17
18
  setConnected
@@ -1 +1 @@
1
- {"version":3,"names":["NativeModules","RNMBXModule","StyleURL","OfflinePackDownloadState","LineJoin","StyleSource","TileServers","removeCustomHeader","addCustomHeader","setAccessToken","setWellKnownTileServer","getAccessToken","setTelemetryEnabled","setConnected"],"sourceRoot":"../../src","sources":["RNMBXModule.ts"],"mappings":"AAAA,SAASA,aAAa,QAAQ,cAAc;AAsC5C,MAAMC,WAAwB,GAAG;EAAE,GAAGD,aAAa,CAACC;AAAY,CAAC;AAEjE,OAAO,MAAM;EACXC,QAAQ;EACRC,wBAAwB;EACxBC,QAAQ;EACRC,WAAW;EACXC,WAAW;EACXC,kBAAkB;EAClBC,eAAe;EACfC,cAAc;EACdC,sBAAsB;EACtBC,cAAc;EACdC,mBAAmB;EACnBC;AACF,CAAC,GAAGZ,WAAW"}
1
+ {"version":3,"names":["NativeModules","RNMBXModule","StyleURL","OfflinePackDownloadState","LineJoin","StyleSource","TileServers","removeCustomHeader","addCustomHeader","setAccessToken","setWellKnownTileServer","clearData","getAccessToken","setTelemetryEnabled","setConnected"],"sourceRoot":"../../src","sources":["RNMBXModule.ts"],"mappings":"AAAA,SAASA,aAAa,QAAQ,cAAc;AAuC5C,MAAMC,WAAwB,GAAG;EAAE,GAAGD,aAAa,CAACC;AAAY,CAAC;AAEjE,OAAO,MAAM;EACXC,QAAQ;EACRC,wBAAwB;EACxBC,QAAQ;EACRC,WAAW;EACXC,WAAW;EACXC,kBAAkB;EAClBC,eAAe;EACfC,cAAc;EACdC,sBAAsB;EACtBC,SAAS;EACTC,cAAc;EACdC,mBAAmB;EACnBC;AACF,CAAC,GAAGb,WAAW"}
@@ -18,5 +18,5 @@ export declare const StyleURL: {
18
18
  DefaultSourceID: string;
19
19
  }, TileServers: {
20
20
  Mapbox: string;
21
- }, removeCustomHeader: (headerName: string) => void, addCustomHeader: (headerName: string, headerValue: string) => void, setAccessToken: (accessToken: string | null) => Promise<string | null>, setWellKnownTileServer: (tileServer: string) => void, getAccessToken: () => Promise<string>, setTelemetryEnabled: (telemetryEnabled: boolean) => void, setConnected: (connected: boolean) => void;
21
+ }, removeCustomHeader: (headerName: string) => void, addCustomHeader: (headerName: string, headerValue: string) => void, setAccessToken: (accessToken: string | null) => Promise<string | null>, setWellKnownTileServer: (tileServer: string) => void, clearData: () => Promise<void>, getAccessToken: () => Promise<string>, setTelemetryEnabled: (telemetryEnabled: boolean) => void, setConnected: (connected: boolean) => void;
22
22
  //# sourceMappingURL=RNMBXModule.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"RNMBXModule.d.ts","sourceRoot":"","sources":["../../../src/RNMBXModule.ts"],"names":[],"mappings":"AAwCA,eAAO,MACL,QAAQ;YArCE,GAAG;cACD,GAAG;WACN,GAAG;UACJ,GAAG;eACE,GAAG;qBACG,GAAG;GAiCtB,wBAAwB;cA9BZ,MAAM,GAAG,MAAM;YACjB,MAAM,GAAG,MAAM;cACb,MAAM,GAAG,MAAM;;GA6B3B,QAAQ;WAzBC,MAAM,GAAG,MAAM;WACf,MAAM,GAAG,MAAM;WACf,MAAM,GAAG,MAAM;GAwBxB,WAAW;qBArBQ,MAAM;GAsBzB,WAAW;YAnBD,MAAM;GAoBhB,kBAAkB,eAjBa,MAAM,KAAG,IAAI,EAkB5C,eAAe,eAjBa,MAAM,eAAe,MAAM,KAAG,IAAI,EAkB9D,cAAc,gBAjBc,MAAM,GAAG,IAAI,KAAG,QAAQ,MAAM,GAAG,IAAI,CAAC,EAkBlE,sBAAsB,eAjBa,MAAM,KAAG,IAAI,EAkBhD,cAAc,QAjBI,QAAQ,MAAM,CAAC,EAkBjC,mBAAmB,qBAjBmB,OAAO,KAAG,IAAI,EAkBpD,YAAY,cAjBY,OAAO,KAAG,IAkBrB,CAAC"}
1
+ {"version":3,"file":"RNMBXModule.d.ts","sourceRoot":"","sources":["../../../src/RNMBXModule.ts"],"names":[],"mappings":"AAyCA,eAAO,MACL,QAAQ;YAtCE,GAAG;cACD,GAAG;WACN,GAAG;UACJ,GAAG;eACE,GAAG;qBACG,GAAG;GAkCtB,wBAAwB;cA/BZ,MAAM,GAAG,MAAM;YACjB,MAAM,GAAG,MAAM;cACb,MAAM,GAAG,MAAM;;GA8B3B,QAAQ;WA1BC,MAAM,GAAG,MAAM;WACf,MAAM,GAAG,MAAM;WACf,MAAM,GAAG,MAAM;GAyBxB,WAAW;qBAtBQ,MAAM;GAuBzB,WAAW;YApBD,MAAM;GAqBhB,kBAAkB,eAlBa,MAAM,KAAG,IAAI,EAmB5C,eAAe,eAlBa,MAAM,eAAe,MAAM,KAAG,IAAI,EAmB9D,cAAc,gBAlBc,MAAM,GAAG,IAAI,KAAG,QAAQ,MAAM,GAAG,IAAI,CAAC,EAmBlE,sBAAsB,eAlBa,MAAM,KAAG,IAAI,EAmBhD,SAAS,QAlBI,QAAQ,IAAI,CAAC,EAmB1B,cAAc,QAlBI,QAAQ,MAAM,CAAC,EAmBjC,mBAAmB,qBAlBmB,OAAO,KAAG,IAAI,EAmBpD,YAAY,cAlBY,OAAO,KAAG,IAmBrB,CAAC"}
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.1.0-rc.1",
4
+ "version": "10.1.0-rc.2",
5
5
  "publishConfig": {
6
6
  "access": "public"
7
7
  },
package/setup-jest.js CHANGED
@@ -98,6 +98,7 @@ NativeModules.RNMBXModule = {
98
98
  getAccessToken: () => Promise.resolve('test-token'),
99
99
  setTelemetryEnabled: jest.fn(),
100
100
  setConnected: jest.fn(),
101
+ clearData: jest.fn(),
101
102
 
102
103
  MapboxV10: true,
103
104
  };
@@ -31,6 +31,7 @@ interface RNMBXModule {
31
31
  addCustomHeader(headerName: string, headerValue: string): void;
32
32
  setAccessToken(accessToken: string | null): Promise<string | null>;
33
33
  setWellKnownTileServer(tileServer: string): void;
34
+ clearData(): Promise<void>;
34
35
  getAccessToken(): Promise<string>;
35
36
  setTelemetryEnabled(telemetryEnabled: boolean): void;
36
37
  setConnected(connected: boolean): void;
@@ -48,6 +49,7 @@ export const {
48
49
  addCustomHeader,
49
50
  setAccessToken,
50
51
  setWellKnownTileServer,
52
+ clearData,
51
53
  getAccessToken,
52
54
  setTelemetryEnabled,
53
55
  setConnected,