react-native-radar 3.10.4-beta.1 → 3.10.4-beta.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,15 +1,4 @@
1
1
  "use strict";
2
- var __assign = (this && this.__assign) || function () {
3
- __assign = Object.assign || function(t) {
4
- for (var s, i = 1, n = arguments.length; i < n; i++) {
5
- s = arguments[i];
6
- for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
7
- t[p] = s[p];
8
- }
9
- return t;
10
- };
11
- return __assign.apply(this, arguments);
12
- };
13
2
  var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
14
3
  if (k2 === undefined) k2 = k;
15
4
  var desc = Object.getOwnPropertyDescriptor(m, k);
@@ -42,44 +31,17 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
42
31
  step((generator = generator.apply(thisArg, _arguments || [])).next());
43
32
  });
44
33
  };
45
- var __generator = (this && this.__generator) || function (thisArg, body) {
46
- var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
47
- return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
48
- function verb(n) { return function (v) { return step([n, v]); }; }
49
- function step(op) {
50
- if (f) throw new TypeError("Generator is already executing.");
51
- while (g && (g = 0, op[0] && (_ = 0)), _) try {
52
- if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
53
- if (y = 0, t) op = [op[0] & 2, t.value];
54
- switch (op[0]) {
55
- case 0: case 1: t = op; break;
56
- case 4: _.label++; return { value: op[1], done: false };
57
- case 5: _.label++; y = op[1]; op = [0]; continue;
58
- case 7: op = _.ops.pop(); _.trys.pop(); continue;
59
- default:
60
- if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
61
- if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
62
- if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
63
- if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
64
- if (t[2]) _.ops.pop();
65
- _.trys.pop(); continue;
66
- }
67
- op = body.call(thisArg, _);
68
- } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
69
- if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
70
- }
71
- };
72
34
  var __importDefault = (this && this.__importDefault) || function (mod) {
73
35
  return (mod && mod.__esModule) ? mod : { "default": mod };
74
36
  };
75
37
  Object.defineProperty(exports, "__esModule", { value: true });
76
38
  // Autocomplete.js
77
- var react_1 = __importStar(require("react"));
78
- var react_native_1 = require("react-native");
79
- var index_native_1 = __importDefault(require("../index.native"));
80
- var images_1 = require("./images");
81
- var styles_1 = __importDefault(require("./styles"));
82
- var defaultAutocompleteOptions = {
39
+ const react_1 = __importStar(require("react"));
40
+ const react_native_1 = require("react-native");
41
+ const index_native_1 = __importDefault(require("../index.native"));
42
+ const images_1 = require("./images");
43
+ const styles_1 = __importDefault(require("./styles"));
44
+ const defaultAutocompleteOptions = {
83
45
  debounceMS: 200, // Debounce time in milliseconds
84
46
  minCharacters: 3, // Minimum number of characters to trigger autocomplete
85
47
  limit: 8, // Maximum number of results to return
@@ -87,51 +49,38 @@ var defaultAutocompleteOptions = {
87
49
  showMarkers: true,
88
50
  disabled: false,
89
51
  };
90
- var autocompleteUI = function (_a) {
91
- var _b = _a.options, options = _b === void 0 ? {} : _b;
92
- var _c = (0, react_1.useState)(""), query = _c[0], setQuery = _c[1];
93
- var _d = (0, react_1.useState)([]), results = _d[0], setResults = _d[1];
94
- var _e = (0, react_1.useState)(false), isOpen = _e[0], setIsOpen = _e[1];
95
- var animationValue = (0, react_1.useRef)(new react_native_1.Animated.Value(0)).current; // animation value
96
- var timerRef = (0, react_1.useRef)(null);
97
- var textInputRef = (0, react_1.useRef)(null);
98
- var config = __assign(__assign({}, defaultAutocompleteOptions), options);
99
- var style = config.style || {};
100
- var fetchResults = (0, react_1.useCallback)(function (searchQuery) { return __awaiter(void 0, void 0, void 0, function () {
101
- var limit, layers, countryCode, params, result, error_1;
102
- return __generator(this, function (_a) {
103
- switch (_a.label) {
104
- case 0:
105
- if (searchQuery.length < config.minCharacters)
106
- return [2 /*return*/];
107
- limit = config.limit, layers = config.layers, countryCode = config.countryCode;
108
- params = { query: searchQuery, limit: limit, layers: layers, countryCode: countryCode };
109
- if (config.near && config.near.latitude && config.near.longitude) {
110
- params.near = config.near;
111
- }
112
- _a.label = 1;
113
- case 1:
114
- _a.trys.push([1, 3, , 4]);
115
- return [4 /*yield*/, index_native_1.default.autocomplete(params)];
116
- case 2:
117
- result = _a.sent();
118
- if (config.onResults && typeof config.onResults === "function") {
119
- config.onResults(result.addresses);
120
- }
121
- setResults(result.addresses);
122
- setIsOpen(true);
123
- return [3 /*break*/, 4];
124
- case 3:
125
- error_1 = _a.sent();
126
- if (config.onError && typeof config.onError === "function") {
127
- config.onError(error_1);
128
- }
129
- return [3 /*break*/, 4];
130
- case 4: return [2 /*return*/];
52
+ const autocompleteUI = ({ options = {} }) => {
53
+ const [query, setQuery] = (0, react_1.useState)("");
54
+ const [results, setResults] = (0, react_1.useState)([]);
55
+ const [isOpen, setIsOpen] = (0, react_1.useState)(false);
56
+ const animationValue = (0, react_1.useRef)(new react_native_1.Animated.Value(0)).current; // animation value
57
+ const timerRef = (0, react_1.useRef)(null);
58
+ const textInputRef = (0, react_1.useRef)(null);
59
+ const config = Object.assign(Object.assign({}, defaultAutocompleteOptions), options);
60
+ const style = config.style || {};
61
+ const fetchResults = (0, react_1.useCallback)((searchQuery) => __awaiter(void 0, void 0, void 0, function* () {
62
+ if (searchQuery.length < config.minCharacters)
63
+ return;
64
+ const { limit, layers, countryCode } = config;
65
+ const params = { query: searchQuery, limit, layers, countryCode };
66
+ if (config.near && config.near.latitude && config.near.longitude) {
67
+ params.near = config.near;
68
+ }
69
+ try {
70
+ const result = yield index_native_1.default.autocomplete(params);
71
+ if (config.onResults && typeof config.onResults === "function") {
72
+ config.onResults(result.addresses);
73
+ }
74
+ setResults(result.addresses);
75
+ setIsOpen(true);
76
+ }
77
+ catch (error) {
78
+ if (config.onError && typeof config.onError === "function") {
79
+ config.onError(error);
131
80
  }
132
- });
133
- }); }, [config]);
134
- var handleInput = (0, react_1.useCallback)(function (text) {
81
+ }
82
+ }), [config]);
83
+ const handleInput = (0, react_1.useCallback)((text) => {
135
84
  setQuery(text);
136
85
  // Clear the existing timer
137
86
  if (timerRef.current) {
@@ -141,18 +90,18 @@ var autocompleteUI = function (_a) {
141
90
  return;
142
91
  }
143
92
  // Set the new timer
144
- timerRef.current = setTimeout(function () {
93
+ timerRef.current = setTimeout(() => {
145
94
  fetchResults(text);
146
95
  }, config.debounceMS);
147
96
  }, [config, fetchResults]);
148
- var handleSelect = function (item) {
97
+ const handleSelect = (item) => {
149
98
  setQuery(item.formattedAddress);
150
99
  setIsOpen(false);
151
100
  if (typeof config.onSelection === "function") {
152
101
  config.onSelection(item);
153
102
  }
154
103
  };
155
- var renderFooter = function () {
104
+ const renderFooter = () => {
156
105
  if (results.length === 0)
157
106
  return null;
158
107
  return (<react_native_1.View style={styles.footerContainer}>
@@ -162,17 +111,13 @@ var autocompleteUI = function (_a) {
162
111
  </react_native_1.View>
163
112
  </react_native_1.View>);
164
113
  };
165
- var renderItem = function (_a) {
166
- var _b;
167
- var item = _a.item;
168
- return (<react_native_1.Pressable style={function (_a) {
169
- var pressed = _a.pressed;
170
- return [
171
- __assign(__assign({}, styles.resultItem), { backgroundColor: pressed
172
- ? styles.resultItem.pressedBackgroundColor
173
- : styles.resultItem.backgroundColor }),
174
- ];
175
- }} onPress={function () { return handleSelect(item); }}>
114
+ const renderItem = ({ item }) => {
115
+ var _a;
116
+ return (<react_native_1.Pressable style={({ pressed }) => [
117
+ Object.assign(Object.assign({}, styles.resultItem), { backgroundColor: pressed
118
+ ? styles.resultItem.pressedBackgroundColor
119
+ : styles.resultItem.backgroundColor }),
120
+ ]} onPress={() => handleSelect(item)}>
176
121
  <react_native_1.View style={styles.addressContainer}>
177
122
  <react_native_1.View style={styles.pinIconContainer}>
178
123
  {config.showMarkers ? (<react_native_1.Image source={images_1.MARKER_ICON} style={styles.pinIcon}/>) : null}
@@ -182,14 +127,14 @@ var autocompleteUI = function (_a) {
182
127
  {item.addressLabel || (item === null || item === void 0 ? void 0 : item.placeLabel)}
183
128
  </react_native_1.Text>
184
129
  {(item === null || item === void 0 ? void 0 : item.formattedAddress.length) > 0 && (<react_native_1.Text numberOfLines={1} style={styles.addressSubtext}>
185
- {(_b = item === null || item === void 0 ? void 0 : item.formattedAddress) === null || _b === void 0 ? void 0 : _b.replace("".concat((item === null || item === void 0 ? void 0 : item.addressLabel) || (item === null || item === void 0 ? void 0 : item.placeLabel), ", "), "")}
130
+ {(_a = item === null || item === void 0 ? void 0 : item.formattedAddress) === null || _a === void 0 ? void 0 : _a.replace(`${(item === null || item === void 0 ? void 0 : item.addressLabel) || (item === null || item === void 0 ? void 0 : item.placeLabel)}, `, "")}
186
131
  </react_native_1.Text>)}
187
132
  </react_native_1.View>
188
133
  </react_native_1.View>
189
134
  </react_native_1.Pressable>);
190
135
  };
191
- var styles = __assign(__assign({}, styles_1.default), { container: react_native_1.StyleSheet.compose(styles_1.default.container, style.container), input: react_native_1.StyleSheet.compose(styles_1.default.input, style.input), inputContainer: react_native_1.StyleSheet.compose(styles_1.default.inputContainer, style.inputContainer), modalInputContainer: react_native_1.StyleSheet.compose(styles_1.default.modalInputContainer, style.modalInputContainer), resultList: react_native_1.StyleSheet.compose(styles_1.default.resultList, style.resultList), resultItem: react_native_1.StyleSheet.compose(__assign(__assign({}, styles_1.default.resultItem), { pressedBackgroundColor: '#F6FAFC' }), style.resultItem), addressContainer: react_native_1.StyleSheet.compose(styles_1.default.addressContainer, style.addressContainer), pinIconContainer: react_native_1.StyleSheet.compose(styles_1.default.pinIconContainer, style.pinIconContainer), pinIcon: react_native_1.StyleSheet.compose(styles_1.default.pinIcon, style.pinIcon), addressTextContainer: react_native_1.StyleSheet.compose(styles_1.default.addressTextContainer, style.addressTextContainer), addressText: react_native_1.StyleSheet.compose(styles_1.default.addressText, style.addressText), addressSubtext: react_native_1.StyleSheet.compose(styles_1.default.addressSubtext, style.addressSubtext), footerContainer: react_native_1.StyleSheet.compose(styles_1.default.footerContainer, style.footerContainer), footerText: react_native_1.StyleSheet.compose(styles_1.default.footerText, style.footerText) });
192
- (0, react_1.useEffect)(function () {
136
+ const styles = Object.assign(Object.assign({}, styles_1.default), { container: react_native_1.StyleSheet.compose(styles_1.default.container, style.container), input: react_native_1.StyleSheet.compose(styles_1.default.input, style.input), inputContainer: react_native_1.StyleSheet.compose(styles_1.default.inputContainer, style.inputContainer), modalInputContainer: react_native_1.StyleSheet.compose(styles_1.default.modalInputContainer, style.modalInputContainer), resultList: react_native_1.StyleSheet.compose(styles_1.default.resultList, style.resultList), resultItem: react_native_1.StyleSheet.compose(Object.assign(Object.assign({}, styles_1.default.resultItem), { pressedBackgroundColor: '#F6FAFC' }), style.resultItem), addressContainer: react_native_1.StyleSheet.compose(styles_1.default.addressContainer, style.addressContainer), pinIconContainer: react_native_1.StyleSheet.compose(styles_1.default.pinIconContainer, style.pinIconContainer), pinIcon: react_native_1.StyleSheet.compose(styles_1.default.pinIcon, style.pinIcon), addressTextContainer: react_native_1.StyleSheet.compose(styles_1.default.addressTextContainer, style.addressTextContainer), addressText: react_native_1.StyleSheet.compose(styles_1.default.addressText, style.addressText), addressSubtext: react_native_1.StyleSheet.compose(styles_1.default.addressSubtext, style.addressSubtext), footerContainer: react_native_1.StyleSheet.compose(styles_1.default.footerContainer, style.footerContainer), footerText: react_native_1.StyleSheet.compose(styles_1.default.footerText, style.footerText) });
137
+ (0, react_1.useEffect)(() => {
193
138
  react_native_1.Animated.timing(animationValue, {
194
139
  toValue: isOpen ? 1 : 0,
195
140
  duration: 300,
@@ -197,61 +142,59 @@ var autocompleteUI = function (_a) {
197
142
  useNativeDriver: false,
198
143
  }).start();
199
144
  }, [isOpen]);
200
- var screenHeight = react_native_1.Dimensions.get("window").height;
201
- var inputHeight = animationValue.interpolate({
145
+ const screenHeight = react_native_1.Dimensions.get("window").height;
146
+ const inputHeight = animationValue.interpolate({
202
147
  inputRange: [0, 1],
203
148
  outputRange: [40, screenHeight],
204
149
  });
205
- var modalOpacity = animationValue.interpolate({
150
+ const modalOpacity = animationValue.interpolate({
206
151
  inputRange: [0, 0.5, 1],
207
152
  outputRange: [0, 0, 1],
208
153
  });
209
154
  return (<react_native_1.View style={styles.container}>
210
155
  <react_native_1.Animated.View style={{ height: inputHeight }}>
211
- <react_native_1.TouchableOpacity style={styles.inputContainer} onPress={function () {
156
+ <react_native_1.TouchableOpacity style={styles.inputContainer} onPress={() => {
212
157
  if (config.disabled)
213
158
  return;
214
159
  setIsOpen(true);
215
160
  // Set the focus on the other textinput after it opens
216
- setTimeout(function () {
161
+ setTimeout(() => {
217
162
  textInputRef.current.focus();
218
163
  }, 100);
219
164
  }}>
220
165
  <react_native_1.Image source={images_1.SEARCH_ICON} style={styles.inputIcon}/>
221
- <react_native_1.TextInput style={styles.input} onFocus={function () {
166
+ <react_native_1.TextInput style={styles.input} onFocus={() => {
222
167
  setIsOpen(true);
223
- setTimeout(function () {
168
+ setTimeout(() => {
224
169
  textInputRef.current.focus();
225
170
  }, 100);
226
171
  }} value={query} returnKeyType="done" placeholder={config.placeholder} placeholderTextColor="#acbdc8"/>
227
172
  </react_native_1.TouchableOpacity>
228
173
  </react_native_1.Animated.View>
229
- <react_native_1.Modal animationType="slide" transparent={false} visible={isOpen} onRequestClose={function () { return setIsOpen(false); }}>
174
+ <react_native_1.Modal animationType="slide" transparent={false} visible={isOpen} onRequestClose={() => setIsOpen(false)}>
230
175
  <react_native_1.Animated.View style={{ flex: 1, opacity: modalOpacity }}>
231
176
  <react_native_1.SafeAreaView>
232
177
  <react_native_1.KeyboardAvoidingView behavior={Platform.OS === "ios" ? "padding" : "height"} keyboardVerticalOffset={50} style={styles.container}>
233
178
  <react_native_1.View style={styles.modalInputContainer}>
234
- <react_native_1.TouchableOpacity onPress={function () {
179
+ <react_native_1.TouchableOpacity onPress={() => {
235
180
  setIsOpen(false);
236
181
  }}>
237
182
  <react_native_1.Image source={images_1.BACK_ICON} style={styles.inputIcon}/>
238
183
  </react_native_1.TouchableOpacity>
239
- <react_native_1.TextInput ref={textInputRef} style={styles.input} onChangeText={handleInput} value={query} placeholder={config.placeholder} returnKeyType="done" onSubmitEditing={function () {
184
+ <react_native_1.TextInput ref={textInputRef} style={styles.input} onChangeText={handleInput} value={query} placeholder={config.placeholder} returnKeyType="done" onSubmitEditing={() => {
240
185
  setIsOpen(false);
241
186
  }} placeholderTextColor="#acbdc8"/>
242
- <react_native_1.TouchableOpacity onPress={function () {
187
+ <react_native_1.TouchableOpacity onPress={() => {
243
188
  setQuery("");
244
189
  }}>
245
190
  <react_native_1.Image source={images_1.CLOSE_ICON} style={styles.closeIcon}/>
246
191
  </react_native_1.TouchableOpacity>
247
192
  </react_native_1.View>
248
193
  {results.length > 0 && (<react_native_1.View style={styles.resultListWrapper}>
249
- <react_native_1.FlatList style={styles.resultList} data={results} onScroll={function () {
194
+ <react_native_1.FlatList style={styles.resultList} data={results} onScroll={() => {
250
195
  textInputRef.current.blur();
251
196
  react_native_1.Keyboard.dismiss();
252
- }} keyboardShouldPersistTaps="handled" renderItem={renderItem} keyExtractor={function (item) {
253
- return item.formattedAddress + item.postalCode;
254
- }}/>
197
+ }} keyboardShouldPersistTaps="handled" renderItem={renderItem} keyExtractor={(item) => item.formattedAddress + item.postalCode}/>
255
198
  {renderFooter()}
256
199
  </react_native_1.View>)}
257
200
  </react_native_1.KeyboardAvoidingView>
@@ -31,78 +31,38 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
31
31
  step((generator = generator.apply(thisArg, _arguments || [])).next());
32
32
  });
33
33
  };
34
- var __generator = (this && this.__generator) || function (thisArg, body) {
35
- var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
36
- return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
37
- function verb(n) { return function (v) { return step([n, v]); }; }
38
- function step(op) {
39
- if (f) throw new TypeError("Generator is already executing.");
40
- while (g && (g = 0, op[0] && (_ = 0)), _) try {
41
- if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
42
- if (y = 0, t) op = [op[0] & 2, t.value];
43
- switch (op[0]) {
44
- case 0: case 1: t = op; break;
45
- case 4: _.label++; return { value: op[1], done: false };
46
- case 5: _.label++; y = op[1]; op = [0]; continue;
47
- case 7: op = _.ops.pop(); _.trys.pop(); continue;
48
- default:
49
- if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
50
- if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
51
- if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
52
- if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
53
- if (t[2]) _.ops.pop();
54
- _.trys.pop(); continue;
55
- }
56
- op = body.call(thisArg, _);
57
- } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
58
- if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
59
- }
60
- };
61
34
  var __importDefault = (this && this.__importDefault) || function (mod) {
62
35
  return (mod && mod.__esModule) ? mod : { "default": mod };
63
36
  };
64
37
  Object.defineProperty(exports, "__esModule", { value: true });
65
- var react_1 = __importStar(require("react"));
66
- var react_native_1 = require("react-native");
67
- var index_native_1 = __importDefault(require("../index.native"));
68
- var helpers_1 = require("../helpers");
69
- var styles_1 = __importDefault(require("./styles"));
70
- var MapLibreGL;
38
+ const react_1 = __importStar(require("react"));
39
+ const react_native_1 = require("react-native");
40
+ const index_native_1 = __importDefault(require("../index.native"));
41
+ const helpers_1 = require("../helpers");
42
+ const styles_1 = __importDefault(require("./styles"));
43
+ let MapLibreGL;
71
44
  try {
72
45
  MapLibreGL = require('@maplibre/maplibre-react-native');
73
46
  }
74
47
  catch (e) {
75
48
  MapLibreGL = null;
76
49
  }
77
- var DEFAULT_STYLE = 'radar-default-v1';
78
- var createStyleURL = function (style) {
79
- if (style === void 0) { style = DEFAULT_STYLE; }
80
- return __awaiter(void 0, void 0, void 0, function () {
81
- var host, publishableKey;
82
- return __generator(this, function (_a) {
83
- switch (_a.label) {
84
- case 0: return [4 /*yield*/, (0, helpers_1.getHost)()];
85
- case 1:
86
- host = _a.sent();
87
- return [4 /*yield*/, (0, helpers_1.getPublishableKey)()];
88
- case 2:
89
- publishableKey = _a.sent();
90
- return [2 /*return*/, "".concat(host, "/maps/styles/").concat(style, "?publishableKey=").concat(publishableKey)];
91
- }
92
- });
93
- });
94
- };
95
- var RadarMap = function (_a) {
96
- var mapOptions = _a.mapOptions, children = _a.children;
97
- var _b = (0, react_1.useState)(null), styleURL = _b[0], setStyleURL = _b[1];
98
- var _c = (0, react_1.useState)(null), userLocation = _c[0], setUserLocation = _c[1];
99
- (0, react_1.useEffect)(function () {
100
- createStyleURL((mapOptions === null || mapOptions === void 0 ? void 0 : mapOptions.mapStyle) || DEFAULT_STYLE).then(function (result) {
50
+ const DEFAULT_STYLE = 'radar-default-v1';
51
+ const createStyleURL = (style = DEFAULT_STYLE) => __awaiter(void 0, void 0, void 0, function* () {
52
+ const host = yield (0, helpers_1.getHost)();
53
+ const publishableKey = yield (0, helpers_1.getPublishableKey)();
54
+ return `${host}/maps/styles/${style}?publishableKey=${publishableKey}`;
55
+ });
56
+ const RadarMap = ({ mapOptions, children }) => {
57
+ const [styleURL, setStyleURL] = (0, react_1.useState)(null);
58
+ const [userLocation, setUserLocation] = (0, react_1.useState)(null);
59
+ (0, react_1.useEffect)(() => {
60
+ createStyleURL((mapOptions === null || mapOptions === void 0 ? void 0 : mapOptions.mapStyle) || DEFAULT_STYLE).then((result) => {
101
61
  setStyleURL(result);
102
62
  });
103
63
  }, [mapOptions]);
104
- (0, react_1.useEffect)(function () {
105
- index_native_1.default.getLocation().then(function (result) {
64
+ (0, react_1.useEffect)(() => {
65
+ index_native_1.default.getLocation().then((result) => {
106
66
  var _a, _b;
107
67
  if (((_a = result === null || result === void 0 ? void 0 : result.location) === null || _a === void 0 ? void 0 : _a.latitude) && ((_b = result === null || result === void 0 ? void 0 : result.location) === null || _b === void 0 ? void 0 : _b.longitude)) {
108
68
  setUserLocation({
@@ -110,9 +70,9 @@ var RadarMap = function (_a) {
110
70
  longitude: result.location.longitude,
111
71
  });
112
72
  }
113
- }).catch(function (err) {
73
+ }).catch((err) => {
114
74
  // eslint-disable-next-line no-console
115
- console.warn("Radar SDK: Failed to get location: ".concat(err));
75
+ console.warn(`Radar SDK: Failed to get location: ${err}`);
116
76
  });
117
77
  }, [mapOptions]);
118
78
  if (!styleURL) {
@@ -121,7 +81,7 @@ var RadarMap = function (_a) {
121
81
  if (!MapLibreGL) {
122
82
  return null;
123
83
  }
124
- var geoJSONUserLocation = {
84
+ const geoJSONUserLocation = {
125
85
  type: 'FeatureCollection',
126
86
  features: (userLocation === null || userLocation === void 0 ? void 0 : userLocation.longitude) !== undefined ? [
127
87
  {
@@ -133,7 +93,7 @@ var RadarMap = function (_a) {
133
93
  },
134
94
  ] : [],
135
95
  };
136
- var userLocationMapIndicator = (<MapLibreGL.ShapeSource id="user-location" shape={geoJSONUserLocation}>
96
+ const userLocationMapIndicator = (<MapLibreGL.ShapeSource id="user-location" shape={geoJSONUserLocation}>
137
97
  <MapLibreGL.CircleLayer id="user-location-inner" style={{
138
98
  circleRadius: 15,
139
99
  circleColor: '#000257',
@@ -1,7 +1,7 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- var react_native_1 = require("react-native");
4
- var styles = react_native_1.StyleSheet.create({
3
+ const react_native_1 = require("react-native");
4
+ const styles = react_native_1.StyleSheet.create({
5
5
  container: {
6
6
  width: '100%',
7
7
  height: '100%',
package/ios/RNRadar.m CHANGED
@@ -99,7 +99,8 @@ RCT_EXPORT_MODULE();
99
99
  }
100
100
 
101
101
  RCT_EXPORT_METHOD(initialize:(NSString *)publishableKey fraud:(BOOL)fraud) {
102
- [Radar initializeWithPublishableKey:publishableKey];
102
+ [Radar initializeWithPublishableKey:publishableKey];
103
+ [[NSUserDefaults standardUserDefaults] setObject:@"3.10.4-beta.2" forKey:@"radar-xPlatformSDKVersion"];
103
104
  }
104
105
 
105
106
  RCT_EXPORT_METHOD(setLogLevel:(NSString *)level) {
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.10.4-beta.1",
6
+ "version": "3.10.4-beta.2",
7
7
  "main": "dist/src/index.js",
8
8
  "files": [
9
9
  "android",
@@ -37,7 +37,7 @@ import {
37
37
  } from "./types";
38
38
 
39
39
  export interface RadarNativeInterface {
40
- initialize: (publishableKey: string, fraud: boolean) => void;
40
+ initialize: (publishableKey: string, fraud?: boolean) => void;
41
41
  setLogLevel: (level: RadarLogLevel) => void;
42
42
  setUserId: (userId: string) => void;
43
43
  getUserId: () => Promise<string>;
@@ -1,3 +1,5 @@
1
+ import { Platform } from 'react-native';
2
+
1
3
  export type RadarMetadata = Record<string, string | number | boolean>;
2
4
 
3
5
  export interface RadarTrackOnceOptions {
@@ -40,6 +42,150 @@ export interface RadarTrackingOptions {
40
42
  foregroundServiceEnabled?: boolean;
41
43
  }
42
44
 
45
+
46
+
47
+ export const presetContinuousIOS: RadarTrackingOptions = {
48
+ desiredStoppedUpdateInterval: 30,
49
+ desiredMovingUpdateInterval: 30,
50
+ desiredSyncInterval: 20,
51
+ desiredAccuracy:'high',
52
+ stopDuration: 140,
53
+ stopDistance: 70,
54
+ replay: 'none',
55
+ useStoppedGeofence: false,
56
+ showBlueBar: true,
57
+ startTrackingAfter: undefined,
58
+ stopTrackingAfter: undefined,
59
+ stoppedGeofenceRadius: 0,
60
+ useMovingGeofence: false,
61
+ movingGeofenceRadius: 0,
62
+ syncGeofences: true,
63
+ useVisits: false,
64
+ useSignificantLocationChanges: false,
65
+ beacons: false,
66
+ sync: 'all',
67
+ };
68
+
69
+ export const presetContinuousAndroid: RadarTrackingOptions = {
70
+ desiredStoppedUpdateInterval: 30,
71
+ fastestStoppedUpdateInterval: 30,
72
+ desiredMovingUpdateInterval: 30,
73
+ fastestMovingUpdateInterval: 30,
74
+ desiredSyncInterval: 20,
75
+ desiredAccuracy: 'high',
76
+ stopDuration: 140,
77
+ stopDistance: 70,
78
+ replay: 'none',
79
+ sync: 'all',
80
+ useStoppedGeofence: false,
81
+ stoppedGeofenceRadius: 0,
82
+ useMovingGeofence: false,
83
+ movingGeofenceRadius: 0,
84
+ syncGeofences: true,
85
+ syncGeofencesLimit: 0,
86
+ foregroundServiceEnabled: true,
87
+ beacons: false,
88
+ startTrackingAfter: undefined,
89
+ stopTrackingAfter: undefined,
90
+ };
91
+
92
+ export const presetContinuous: RadarTrackingOptions = Platform.OS === 'ios' ? presetContinuousIOS : presetContinuousAndroid;
93
+
94
+ export const presetResponsiveIOS: RadarTrackingOptions = {
95
+ desiredStoppedUpdateInterval: 0,
96
+ desiredMovingUpdateInterval: 150,
97
+ desiredSyncInterval: 20,
98
+ desiredAccuracy:'medium',
99
+ stopDuration: 140,
100
+ stopDistance: 70,
101
+ replay: 'stops',
102
+ useStoppedGeofence: true,
103
+ showBlueBar: false,
104
+ startTrackingAfter: undefined,
105
+ stopTrackingAfter: undefined,
106
+ stoppedGeofenceRadius: 100,
107
+ useMovingGeofence: true,
108
+ movingGeofenceRadius: 100,
109
+ syncGeofences: true,
110
+ useVisits: true,
111
+ useSignificantLocationChanges: true,
112
+ beacons: false,
113
+ sync: 'all',
114
+ };
115
+
116
+ export const presetResponsiveAndroid: RadarTrackingOptions = {
117
+ desiredStoppedUpdateInterval: 0,
118
+ fastestStoppedUpdateInterval: 0,
119
+ desiredMovingUpdateInterval: 150,
120
+ fastestMovingUpdateInterval: 30,
121
+ desiredSyncInterval: 20,
122
+ desiredAccuracy:"medium",
123
+ stopDuration: 140,
124
+ stopDistance: 70,
125
+ replay: 'stops',
126
+ sync: 'all',
127
+ useStoppedGeofence: true,
128
+ stoppedGeofenceRadius: 100,
129
+ useMovingGeofence: true,
130
+ movingGeofenceRadius: 100,
131
+ syncGeofences: true,
132
+ syncGeofencesLimit: 10,
133
+ foregroundServiceEnabled: false,
134
+ beacons: false,
135
+ startTrackingAfter: undefined,
136
+ stopTrackingAfter: undefined,
137
+ };
138
+
139
+ export const presetResponsive: RadarTrackingOptions = Platform.OS === 'ios' ? presetResponsiveIOS : presetResponsiveAndroid;
140
+
141
+ export const presetEfficientIOS: RadarTrackingOptions = {
142
+ desiredStoppedUpdateInterval: 0,
143
+ desiredMovingUpdateInterval: 0,
144
+ desiredSyncInterval: 0,
145
+ desiredAccuracy: "medium",
146
+ stopDuration: 0,
147
+ stopDistance: 0,
148
+ replay: 'stops',
149
+ useStoppedGeofence: false,
150
+ showBlueBar: false,
151
+ startTrackingAfter: undefined,
152
+ stopTrackingAfter: undefined,
153
+ stoppedGeofenceRadius: 0,
154
+ useMovingGeofence: false,
155
+ movingGeofenceRadius: 0,
156
+ syncGeofences: true,
157
+ useVisits: true,
158
+ useSignificantLocationChanges: false,
159
+ beacons: false,
160
+ sync: 'all',
161
+ };
162
+
163
+ export const presetEfficientAndroid: RadarTrackingOptions = {
164
+ desiredStoppedUpdateInterval: 3600,
165
+ fastestStoppedUpdateInterval: 1200,
166
+ desiredMovingUpdateInterval: 1200,
167
+ fastestMovingUpdateInterval: 360,
168
+ desiredSyncInterval: 140,
169
+ desiredAccuracy: 'medium',
170
+ stopDuration: 140,
171
+ stopDistance: 70,
172
+ replay: 'stops',
173
+ sync: 'all',
174
+ useStoppedGeofence: false,
175
+ stoppedGeofenceRadius: 0,
176
+ useMovingGeofence: false,
177
+ movingGeofenceRadius: 0,
178
+ syncGeofences: true,
179
+ syncGeofencesLimit: 10,
180
+ foregroundServiceEnabled: false,
181
+ beacons: false,
182
+ startTrackingAfter: undefined,
183
+ stopTrackingAfter: undefined,
184
+ };
185
+
186
+ export const presetEfficient: RadarTrackingOptions = Platform.OS === 'ios' ? presetEfficientIOS : presetEfficientAndroid;
187
+
188
+
43
189
  export interface RadarMockTrackingOptions {
44
190
  origin: Location;
45
191
  destination: Location;
@@ -584,6 +730,8 @@ export interface RadarTrackingOptionsForegroundService {
584
730
  importance?: number;
585
731
  id?: number;
586
732
  channelName?: string;
733
+ iconString?: string;
734
+ iconColor?: string;
587
735
  }
588
736
 
589
737
  export type RadarTripStatus =
@@ -47,6 +47,7 @@ if (
47
47
  }
48
48
 
49
49
  const eventEmitter = new NativeEventEmitter(NativeModules.RNRadar);
50
+
50
51
  const initialize = (publishableKey: string, fraud: boolean = false): void => {
51
52
  NativeModules.RNRadar.initialize(publishableKey, fraud);
52
53
  };