react-native-radar 3.31.0 → 4.0.0

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.
@@ -143,7 +143,7 @@ class RadarModule(reactContext: ReactApplicationContext) :
143
143
  override fun initialize(publishableKey: String, fraud: Boolean): Unit {
144
144
  val editor = reactApplicationContext.getSharedPreferences("RadarSDK", Context.MODE_PRIVATE).edit()
145
145
  editor.putString("x_platform_sdk_type", "ReactNative")
146
- editor.putString("x_platform_sdk_version", "3.31.0")
146
+ editor.putString("x_platform_sdk_version", "4.0.0")
147
147
  editor.apply()
148
148
 
149
149
  Radar.initialize(reactApplicationContext, publishableKey, radarReceiver, Radar.RadarLocationServicesProvider.GOOGLE, fraud, null, radarInAppMessageReceiver, currentActivity)
@@ -102,7 +102,7 @@ public class RadarModule extends ReactContextBaseJavaModule implements Permissio
102
102
  this.fraud = fraud;
103
103
  SharedPreferences.Editor editor = getReactApplicationContext().getSharedPreferences("RadarSDK", Context.MODE_PRIVATE).edit();
104
104
  editor.putString("x_platform_sdk_type", "ReactNative");
105
- editor.putString("x_platform_sdk_version", "3.31.0");
105
+ editor.putString("x_platform_sdk_version", "4.0.0");
106
106
  editor.apply();
107
107
  Radar.initialize(getReactApplicationContext(), publishableKey, receiver, Radar.RadarLocationServicesProvider.GOOGLE, fraud, null, inAppMessageReceiver, getCurrentActivity());
108
108
  if (fraud) {
@@ -1,3 +1,5 @@
1
+ import React from "react";
2
+ import type { MapRef } from "@maplibre/maplibre-react-native";
1
3
  export type RadarMetadata = Record<string, string | number | boolean>;
2
4
  export interface RadarTrackOnceOptions {
3
5
  location?: Location;
@@ -544,7 +546,8 @@ export type RadarTripStatus = "unknown" | "started" | "approaching" | "arrived"
544
546
  export interface RadarMapOptions {
545
547
  mapStyle?: string;
546
548
  showUserLocation?: boolean;
547
- onRegionDidChange?: (feature: RadarMapRegionChangeEvent) => void;
549
+ mapRef?: React.Ref<MapRef>;
550
+ onRegionDidChange?: (event: RadarMapRegionChangeEvent) => void;
548
551
  onDidFinishLoadingMap?: () => void;
549
552
  onWillStartLoadingMap?: () => void;
550
553
  onDidFailLoadingMap?: () => void;
@@ -552,7 +555,9 @@ export interface RadarMapOptions {
552
555
  export interface RadarMapRegionChangeEvent {
553
556
  center: [number, number];
554
557
  zoom: number;
555
- bounds?: [number, number, number, number];
558
+ bounds?: [[number, number], [number, number]];
556
559
  bearing?: number;
557
560
  pitch?: number;
561
+ animated: boolean;
562
+ userInteraction: boolean;
558
563
  }
@@ -48,6 +48,13 @@ Object.defineProperty(exports, "__esModule", { value: true });
48
48
  // Autocomplete.js
49
49
  const react_1 = __importStar(require("react"));
50
50
  const react_native_1 = require("react-native");
51
+ let SafeAreaView;
52
+ try {
53
+ SafeAreaView = require('react-native-safe-area-context').SafeAreaView;
54
+ }
55
+ catch (e) {
56
+ SafeAreaView = require('react-native').SafeAreaView;
57
+ }
51
58
  const index_native_1 = __importDefault(require("../index.native"));
52
59
  const images_1 = require("./images");
53
60
  const styles_1 = __importDefault(require("./styles"));
@@ -183,7 +190,7 @@ const autocompleteUI = ({ options = {} }) => {
183
190
  </react_native_1.Animated.View>
184
191
  <react_native_1.Modal animationType="slide" transparent={false} visible={isOpen} onRequestClose={() => setIsOpen(false)}>
185
192
  <react_native_1.Animated.View style={{ flex: 1, opacity: modalOpacity }}>
186
- <react_native_1.SafeAreaView>
193
+ <SafeAreaView>
187
194
  <react_native_1.KeyboardAvoidingView behavior={react_native_1.Platform.OS === "ios" ? "padding" : "height"} keyboardVerticalOffset={50} style={styles.container}>
188
195
  <react_native_1.View style={styles.modalInputContainer}>
189
196
  <react_native_1.TouchableOpacity onPress={() => {
@@ -208,7 +215,7 @@ const autocompleteUI = ({ options = {} }) => {
208
215
  {renderFooter()}
209
216
  </react_native_1.View>)}
210
217
  </react_native_1.KeyboardAvoidingView>
211
- </react_native_1.SafeAreaView>
218
+ </SafeAreaView>
212
219
  </react_native_1.Animated.View>
213
220
  </react_native_1.Modal>
214
221
  </react_native_1.View>);
@@ -14,10 +14,15 @@ import {
14
14
  Dimensions,
15
15
  Easing,
16
16
  Keyboard,
17
- SafeAreaView,
18
17
  Pressable,
19
18
  Platform,
20
19
  } from 'react-native';
20
+ let SafeAreaView;
21
+ try {
22
+ SafeAreaView = require('react-native-safe-area-context').SafeAreaView;
23
+ } catch (e) {
24
+ SafeAreaView = require('react-native').SafeAreaView;
25
+ }
21
26
  import Radar from '../index.native';
22
27
  import {
23
28
  BACK_ICON,
package/dist/ui/map.jsx CHANGED
@@ -5,10 +5,19 @@ import { getHost, getPublishableKey } from '../helpers';
5
5
  import styles from './styles';
6
6
 
7
7
  let MapLibreGL;
8
+ let MapLibreMap;
9
+ let GeoJSONSource;
10
+ let Layer;
8
11
  try {
9
12
  MapLibreGL = require('@maplibre/maplibre-react-native');
13
+ MapLibreMap = MapLibreGL.Map;
14
+ GeoJSONSource = MapLibreGL.GeoJSONSource;
15
+ Layer = MapLibreGL.Layer;
10
16
  } catch (e) {
11
17
  MapLibreGL = null;
18
+ MapLibreMap = null;
19
+ GeoJSONSource = null;
20
+ Layer = null;
12
21
  }
13
22
 
14
23
  const DEFAULT_STYLE = 'radar-default-v1';
@@ -25,8 +34,9 @@ const createStyleURL = async (style = DEFAULT_STYLE) => {
25
34
  * @param {Object} [props.mapOptions] - Map configuration options
26
35
  * @param {string} [props.mapOptions.mapStyle] - Map style identifier (defaults to 'radar-default-v1')
27
36
  * @param {boolean} [props.mapOptions.showUserLocation] - Whether to show the user's location on the map (default: true)
37
+ * @param {React.Ref} [props.mapOptions.mapRef] - Ref to the underlying MapLibre Map component
28
38
  * @param {function} [props.mapOptions.onRegionDidChange] - Callback fired when the map region changes
29
- * @param {Object} props.mapOptions.onRegionDidChange.feature - The region feature data
39
+ * @param {Object} props.mapOptions.onRegionDidChange.event - The region event data
30
40
  * @param {function} [props.mapOptions.onDidFinishLoadingMap] - Callback fired when the map finishes loading
31
41
  * @param {function} [props.mapOptions.onWillStartLoadingMap] - Callback fired when the map starts loading
32
42
  * @param {function} [props.mapOptions.onDidFailLoadingMap] - Callback fired when the map fails to load
@@ -80,54 +90,61 @@ const RadarMap = ({ mapOptions, children }) => {
80
90
  };
81
91
 
82
92
  const userLocationMapIndicator = (
83
- <MapLibreGL.ShapeSource
93
+ <GeoJSONSource
84
94
  id="user-location"
85
- shape={geoJSONUserLocation}
95
+ data={JSON.stringify(geoJSONUserLocation)}
86
96
  >
87
- <MapLibreGL.CircleLayer
97
+ <Layer
88
98
  id="user-location-inner"
89
- style={{
90
- circleRadius: 15,
91
- circleColor: '#000257',
92
- circleOpacity: 0.2,
93
- circlePitchAlignment: 'map',
99
+ type="circle"
100
+ paint={{
101
+ 'circle-radius': 15,
102
+ 'circle-color': '#000257',
103
+ 'circle-opacity': 0.2,
104
+ 'circle-pitch-alignment': 'map',
94
105
  }}
95
106
  />
96
- <MapLibreGL.CircleLayer
107
+ <Layer
97
108
  id="user-location-middle"
98
- style={{
99
- circleRadius: 9,
100
- circleColor: '#fff',
101
- circlePitchAlignment: 'map',
109
+ type="circle"
110
+ paint={{
111
+ 'circle-radius': 9,
112
+ 'circle-color': '#fff',
113
+ 'circle-pitch-alignment': 'map',
102
114
  }}
103
115
  />
104
- <MapLibreGL.CircleLayer
116
+ <Layer
105
117
  id="user-location-outer"
106
- style={{
107
- circleRadius: 6,
108
- circleColor: '#000257',
109
- circlePitchAlignment: 'map',
118
+ type="circle"
119
+ paint={{
120
+ 'circle-radius': 6,
121
+ 'circle-color': '#000257',
122
+ 'circle-pitch-alignment': 'map',
110
123
  }}
111
124
  />
112
- </MapLibreGL.ShapeSource>
125
+ </GeoJSONSource>
113
126
  );
114
127
 
115
128
  return (
116
129
  <View style={styles.mapContainer}>
117
- <MapLibreGL.MapView
130
+ <MapLibreMap
131
+ ref={mapOptions?.mapRef}
118
132
  style={styles.map}
119
- pitchEnabled={false}
120
- compassEnabled={false}
121
- logoEnabled={false}
122
- attributionEnabled
123
- onRegionDidChange={mapOptions?.onRegionDidChange ? mapOptions.onRegionDidChange : null}
133
+ touchPitch={false}
134
+ compass={false}
135
+ logo={false}
136
+ attribution
137
+ onRegionDidChange={ mapOptions?.onRegionDidChange
138
+ ? (event) => mapOptions.onRegionDidChange(event.nativeEvent)
139
+ : null
140
+ }
124
141
  onDidFinishLoadingMap={mapOptions?.onDidFinishLoadingMap ? mapOptions.onDidFinishLoadingMap : null}
125
142
  onWillStartLoadingMap={mapOptions?.onWillStartLoadingMap ? mapOptions.onWillStartLoadingMap : null}
126
143
  onDidFailLoadingMap={mapOptions?.onDidFailLoadingMap ? mapOptions.onDidFailLoadingMap : null}
127
144
  mapStyle={styleURL}>
128
145
  {mapOptions?.showUserLocation !== false && userLocationMapIndicator}
129
146
  {children}
130
- </MapLibreGL.MapView>
147
+ </MapLibreMap>
131
148
  <Image
132
149
  source={require('./map-logo.png')}
133
150
  style={styles.mapLogo}
package/dist/version.d.ts CHANGED
@@ -1 +1 @@
1
- export declare const VERSION = "3.31.0";
1
+ export declare const VERSION = "4.0.0";
package/dist/version.js CHANGED
@@ -3,4 +3,4 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.VERSION = void 0;
4
4
  // This file contains the version of the react-native-radar package
5
5
  // It should be updated to match the version in package.json
6
- exports.VERSION = '3.31.0';
6
+ exports.VERSION = '4.0.0';
package/ios/RNRadar.mm CHANGED
@@ -217,7 +217,7 @@ RCT_EXPORT_MODULE()
217
217
  RCT_EXPORT_METHOD(initialize:(NSString *)publishableKey fraud:(BOOL)fraud) {
218
218
  _publishableKey = publishableKey;
219
219
  [[NSUserDefaults standardUserDefaults] setObject:@"ReactNative" forKey:@"radar-xPlatformSDKType"];
220
- [[NSUserDefaults standardUserDefaults] setObject:@"3.31.0" forKey:@"radar-xPlatformSDKVersion"];
220
+ [[NSUserDefaults standardUserDefaults] setObject:@"4.0.0" forKey:@"radar-xPlatformSDKVersion"];
221
221
  [Radar initializeWithPublishableKey:publishableKey];
222
222
  }
223
223
 
package/package.json CHANGED
@@ -3,7 +3,7 @@
3
3
  "description": "React Native module for Radar, the leading geofencing and location tracking platform",
4
4
  "homepage": "https://radar.com",
5
5
  "license": "Apache-2.0",
6
- "version": "3.31.0",
6
+ "version": "4.0.0",
7
7
  "main": "dist/index.js",
8
8
  "files": [
9
9
  "dist",
@@ -56,10 +56,11 @@
56
56
  ]
57
57
  },
58
58
  "peerDependencies": {
59
- "@maplibre/maplibre-react-native": ">=10.2.1",
59
+ "@maplibre/maplibre-react-native": ">=11.0.0-beta.10",
60
60
  "expo": ">=43.0.5",
61
- "react": ">= 16.8.6",
62
- "react-native": ">= 0.60.0"
61
+ "react": ">= 19.1.0",
62
+ "react-native": ">= 0.80.0",
63
+ "react-native-safe-area-context": "^5.6.2"
63
64
  },
64
65
  "peerDependenciesMeta": {
65
66
  "@maplibre/maplibre-react-native": {
@@ -67,6 +68,9 @@
67
68
  },
68
69
  "expo": {
69
70
  "optional": true
71
+ },
72
+ "react-native-safe-area-context": {
73
+ "optional": true
70
74
  }
71
75
  },
72
76
  "devDependencies": {
@@ -0,0 +1,16 @@
1
+ declare module "@maplibre/maplibre-react-native" {
2
+ export interface MapRef {
3
+ getCenter(): Promise<{ lng: number; lat: number }>;
4
+ getZoom(): Promise<number>;
5
+ getBearing(): Promise<number>;
6
+ getPitch(): Promise<number>;
7
+ getBounds(): Promise<{ ne: [number, number]; sw: [number, number] }>;
8
+ project(coordinate: [number, number]): Promise<{ x: number; y: number }>;
9
+ unproject(point: { x: number; y: number }): Promise<[number, number]>;
10
+ queryRenderedFeatures(
11
+ point: [number, number] | [[number, number], [number, number]],
12
+ filter?: string[],
13
+ layerIDs?: string[],
14
+ ): Promise<GeoJSON.FeatureCollection>;
15
+ }
16
+ }
@@ -1,4 +1,6 @@
1
+ import React from "react";
1
2
  import { Platform } from "react-native";
3
+ import type { MapRef } from "@maplibre/maplibre-react-native";
2
4
  const platform = Platform.OS;
3
5
 
4
6
  export type RadarMetadata = Record<string, string | number | boolean>;
@@ -850,7 +852,8 @@ export type RadarTripStatus =
850
852
  export interface RadarMapOptions {
851
853
  mapStyle?: string;
852
854
  showUserLocation?: boolean;
853
- onRegionDidChange?: (feature: RadarMapRegionChangeEvent) => void;
855
+ mapRef?: React.Ref<MapRef>;
856
+ onRegionDidChange?: (event: RadarMapRegionChangeEvent) => void;
854
857
  onDidFinishLoadingMap?: () => void;
855
858
  onWillStartLoadingMap?: () => void;
856
859
  onDidFailLoadingMap?: () => void;
@@ -859,7 +862,9 @@ export interface RadarMapOptions {
859
862
  export interface RadarMapRegionChangeEvent {
860
863
  center: [number, number];
861
864
  zoom: number;
862
- bounds?: [number, number, number, number];
865
+ bounds?: [[number, number], [number, number]];
863
866
  bearing?: number;
864
867
  pitch?: number;
868
+ animated: boolean;
869
+ userInteraction: boolean;
865
870
  }
@@ -14,10 +14,15 @@ import {
14
14
  Dimensions,
15
15
  Easing,
16
16
  Keyboard,
17
- SafeAreaView,
18
17
  Pressable,
19
18
  Platform,
20
19
  } from 'react-native';
20
+ let SafeAreaView;
21
+ try {
22
+ SafeAreaView = require('react-native-safe-area-context').SafeAreaView;
23
+ } catch (e) {
24
+ SafeAreaView = require('react-native').SafeAreaView;
25
+ }
21
26
  import Radar from '../index.native';
22
27
  import {
23
28
  BACK_ICON,
package/src/ui/map.jsx CHANGED
@@ -5,10 +5,19 @@ import { getHost, getPublishableKey } from '../helpers';
5
5
  import styles from './styles';
6
6
 
7
7
  let MapLibreGL;
8
+ let MapLibreMap;
9
+ let GeoJSONSource;
10
+ let Layer;
8
11
  try {
9
12
  MapLibreGL = require('@maplibre/maplibre-react-native');
13
+ MapLibreMap = MapLibreGL.Map;
14
+ GeoJSONSource = MapLibreGL.GeoJSONSource;
15
+ Layer = MapLibreGL.Layer;
10
16
  } catch (e) {
11
17
  MapLibreGL = null;
18
+ MapLibreMap = null;
19
+ GeoJSONSource = null;
20
+ Layer = null;
12
21
  }
13
22
 
14
23
  const DEFAULT_STYLE = 'radar-default-v1';
@@ -25,8 +34,9 @@ const createStyleURL = async (style = DEFAULT_STYLE) => {
25
34
  * @param {Object} [props.mapOptions] - Map configuration options
26
35
  * @param {string} [props.mapOptions.mapStyle] - Map style identifier (defaults to 'radar-default-v1')
27
36
  * @param {boolean} [props.mapOptions.showUserLocation] - Whether to show the user's location on the map (default: true)
37
+ * @param {React.Ref} [props.mapOptions.mapRef] - Ref to the underlying MapLibre Map component
28
38
  * @param {function} [props.mapOptions.onRegionDidChange] - Callback fired when the map region changes
29
- * @param {Object} props.mapOptions.onRegionDidChange.feature - The region feature data
39
+ * @param {Object} props.mapOptions.onRegionDidChange.event - The region event data
30
40
  * @param {function} [props.mapOptions.onDidFinishLoadingMap] - Callback fired when the map finishes loading
31
41
  * @param {function} [props.mapOptions.onWillStartLoadingMap] - Callback fired when the map starts loading
32
42
  * @param {function} [props.mapOptions.onDidFailLoadingMap] - Callback fired when the map fails to load
@@ -80,54 +90,61 @@ const RadarMap = ({ mapOptions, children }) => {
80
90
  };
81
91
 
82
92
  const userLocationMapIndicator = (
83
- <MapLibreGL.ShapeSource
93
+ <GeoJSONSource
84
94
  id="user-location"
85
- shape={geoJSONUserLocation}
95
+ data={JSON.stringify(geoJSONUserLocation)}
86
96
  >
87
- <MapLibreGL.CircleLayer
97
+ <Layer
88
98
  id="user-location-inner"
89
- style={{
90
- circleRadius: 15,
91
- circleColor: '#000257',
92
- circleOpacity: 0.2,
93
- circlePitchAlignment: 'map',
99
+ type="circle"
100
+ paint={{
101
+ 'circle-radius': 15,
102
+ 'circle-color': '#000257',
103
+ 'circle-opacity': 0.2,
104
+ 'circle-pitch-alignment': 'map',
94
105
  }}
95
106
  />
96
- <MapLibreGL.CircleLayer
107
+ <Layer
97
108
  id="user-location-middle"
98
- style={{
99
- circleRadius: 9,
100
- circleColor: '#fff',
101
- circlePitchAlignment: 'map',
109
+ type="circle"
110
+ paint={{
111
+ 'circle-radius': 9,
112
+ 'circle-color': '#fff',
113
+ 'circle-pitch-alignment': 'map',
102
114
  }}
103
115
  />
104
- <MapLibreGL.CircleLayer
116
+ <Layer
105
117
  id="user-location-outer"
106
- style={{
107
- circleRadius: 6,
108
- circleColor: '#000257',
109
- circlePitchAlignment: 'map',
118
+ type="circle"
119
+ paint={{
120
+ 'circle-radius': 6,
121
+ 'circle-color': '#000257',
122
+ 'circle-pitch-alignment': 'map',
110
123
  }}
111
124
  />
112
- </MapLibreGL.ShapeSource>
125
+ </GeoJSONSource>
113
126
  );
114
127
 
115
128
  return (
116
129
  <View style={styles.mapContainer}>
117
- <MapLibreGL.MapView
130
+ <MapLibreMap
131
+ ref={mapOptions?.mapRef}
118
132
  style={styles.map}
119
- pitchEnabled={false}
120
- compassEnabled={false}
121
- logoEnabled={false}
122
- attributionEnabled
123
- onRegionDidChange={mapOptions?.onRegionDidChange ? mapOptions.onRegionDidChange : null}
133
+ touchPitch={false}
134
+ compass={false}
135
+ logo={false}
136
+ attribution
137
+ onRegionDidChange={ mapOptions?.onRegionDidChange
138
+ ? (event) => mapOptions.onRegionDidChange(event.nativeEvent)
139
+ : null
140
+ }
124
141
  onDidFinishLoadingMap={mapOptions?.onDidFinishLoadingMap ? mapOptions.onDidFinishLoadingMap : null}
125
142
  onWillStartLoadingMap={mapOptions?.onWillStartLoadingMap ? mapOptions.onWillStartLoadingMap : null}
126
143
  onDidFailLoadingMap={mapOptions?.onDidFailLoadingMap ? mapOptions.onDidFailLoadingMap : null}
127
144
  mapStyle={styleURL}>
128
145
  {mapOptions?.showUserLocation !== false && userLocationMapIndicator}
129
146
  {children}
130
- </MapLibreGL.MapView>
147
+ </MapLibreMap>
131
148
  <Image
132
149
  source={require('./map-logo.png')}
133
150
  style={styles.mapLogo}
package/src/version.ts CHANGED
@@ -1,3 +1,3 @@
1
1
  // This file contains the version of the react-native-radar package
2
2
  // It should be updated to match the version in package.json
3
- export const VERSION = '3.31.0';
3
+ export const VERSION = '4.0.0';