radar-sdk-js 4.5.7 → 4.5.8-beta.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.
- package/README.md +7 -7
- package/dist/navigator.d.ts +1 -1
- package/dist/radar.js +21 -5
- package/dist/radar.js.map +1 -1
- package/dist/version.d.ts +1 -1
- package/package.json +1 -1
- package/src/api/track.ts +1 -1
- package/src/navigator.ts +25 -3
- package/src/version.ts +1 -1
package/README.md
CHANGED
|
@@ -56,7 +56,7 @@ Radar.initialize('prj_test_pk_...', { /* options */ });
|
|
|
56
56
|
|
|
57
57
|
Add the following script in your `html` file
|
|
58
58
|
```html
|
|
59
|
-
<script src="https://js.radar.com/v4.5.
|
|
59
|
+
<script src="https://js.radar.com/v4.5.8-beta.0/radar.min.js"></script>
|
|
60
60
|
```
|
|
61
61
|
|
|
62
62
|
Then initialize the Radar SDK
|
|
@@ -73,8 +73,8 @@ To create a map, first initialize the Radar SDK with your publishable key. Then
|
|
|
73
73
|
```html
|
|
74
74
|
<html>
|
|
75
75
|
<head>
|
|
76
|
-
<link href="https://js.radar.com/v4.5.
|
|
77
|
-
<script src="https://js.radar.com/v4.5.
|
|
76
|
+
<link href="https://js.radar.com/v4.5.8-beta.0/radar.css" rel="stylesheet">
|
|
77
|
+
<script src="https://js.radar.com/v4.5.8-beta.0/radar.min.js"></script>
|
|
78
78
|
</head>
|
|
79
79
|
|
|
80
80
|
<body>
|
|
@@ -98,8 +98,8 @@ To create an autocomplete input, first initialize the Radar SDK with your publis
|
|
|
98
98
|
```html
|
|
99
99
|
<html>
|
|
100
100
|
<head>
|
|
101
|
-
<link href="https://js.radar.com/v4.5.
|
|
102
|
-
<script src="https://js.radar.com/v4.5.
|
|
101
|
+
<link href="https://js.radar.com/v4.5.8-beta.0/radar.css" rel="stylesheet">
|
|
102
|
+
<script src="https://js.radar.com/v4.5.8-beta.0/radar.min.js"></script>
|
|
103
103
|
</head>
|
|
104
104
|
|
|
105
105
|
<body>
|
|
@@ -130,8 +130,8 @@ To power [geofencing](https://radar.com/documentation/geofencing/overview) exper
|
|
|
130
130
|
```html
|
|
131
131
|
<html>
|
|
132
132
|
<head>
|
|
133
|
-
<link href="https://js.radar.com/v4.5.
|
|
134
|
-
<script src="https://js.radar.com/v4.5.
|
|
133
|
+
<link href="https://js.radar.com/v4.5.8-beta.0/radar.css" rel="stylesheet">
|
|
134
|
+
<script src="https://js.radar.com/v4.5.8-beta.0/radar.min.js"></script>
|
|
135
135
|
</head>
|
|
136
136
|
|
|
137
137
|
<body>
|
package/dist/navigator.d.ts
CHANGED
|
@@ -3,7 +3,7 @@ interface PositionOptionOverrides {
|
|
|
3
3
|
desiredAccuracy?: string;
|
|
4
4
|
}
|
|
5
5
|
declare class Navigator {
|
|
6
|
-
static getCurrentPosition(overrides?: PositionOptionOverrides): Promise<NavigatorPosition>;
|
|
6
|
+
static getCurrentPosition(overrides?: PositionOptionOverrides, fraud?: Boolean): Promise<NavigatorPosition>;
|
|
7
7
|
static getPermissionStatus(): Promise<LocationAuthorization>;
|
|
8
8
|
static online(): Boolean;
|
|
9
9
|
}
|
package/dist/radar.js
CHANGED
|
@@ -316,6 +316,21 @@ class RadarAutocompleteContainerNotFound extends RadarError {
|
|
|
316
316
|
}
|
|
317
317
|
}
|
|
318
318
|
|
|
319
|
+
const radarGeolocation = (() => {
|
|
320
|
+
if (!navigator) {
|
|
321
|
+
return null;
|
|
322
|
+
}
|
|
323
|
+
const g = navigator.geolocation;
|
|
324
|
+
if (!g) {
|
|
325
|
+
return null;
|
|
326
|
+
}
|
|
327
|
+
const emptyFn = () => { };
|
|
328
|
+
return Object.freeze({
|
|
329
|
+
getCurrentPosition: g.getCurrentPosition ? g.getCurrentPosition.bind(g) : emptyFn,
|
|
330
|
+
watchPosition: g.watchPosition ? g.watchPosition.bind(g) : emptyFn,
|
|
331
|
+
clearWatch: g.clearWatch ? g.clearWatch.bind(g) : emptyFn,
|
|
332
|
+
});
|
|
333
|
+
})();
|
|
319
334
|
const DEFAULT_POSITION_OPTIONS = {
|
|
320
335
|
maximumAge: 0,
|
|
321
336
|
timeout: 1000 * 10,
|
|
@@ -324,11 +339,12 @@ const DEFAULT_POSITION_OPTIONS = {
|
|
|
324
339
|
// set "enableHighAccuracy" for navigator only when desiredAccuracy is "high"
|
|
325
340
|
const useHighAccuracy = (desiredAccuracy) => (Boolean(desiredAccuracy === 'high'));
|
|
326
341
|
class Navigator {
|
|
327
|
-
static getCurrentPosition(overrides = {}) {
|
|
342
|
+
static getCurrentPosition(overrides = {}, fraud = false) {
|
|
328
343
|
return __awaiter(this, void 0, void 0, function* () {
|
|
329
344
|
return new Promise((resolve, reject) => {
|
|
330
345
|
const options = Config.get();
|
|
331
|
-
|
|
346
|
+
const g = fraud ? radarGeolocation : navigator.geolocation;
|
|
347
|
+
if (!g) {
|
|
332
348
|
return reject(new RadarLocationError('navigator.geolocation is not available.'));
|
|
333
349
|
}
|
|
334
350
|
// use cached location if available and options are set
|
|
@@ -366,7 +382,7 @@ class Navigator {
|
|
|
366
382
|
}
|
|
367
383
|
Logger.info(`Using geolocation options: ${JSON.stringify(positionOptions)}`);
|
|
368
384
|
// get current location from browser
|
|
369
|
-
|
|
385
|
+
g.getCurrentPosition((position) => {
|
|
370
386
|
if (!position || !position.coords) {
|
|
371
387
|
return reject(new RadarLocationError('device location return empty coordinates.'));
|
|
372
388
|
}
|
|
@@ -421,7 +437,7 @@ class Navigator {
|
|
|
421
437
|
}
|
|
422
438
|
}
|
|
423
439
|
|
|
424
|
-
var SDK_VERSION = '4.5.
|
|
440
|
+
var SDK_VERSION = '4.5.8-beta.0';
|
|
425
441
|
|
|
426
442
|
const inFlightRequests = new Map();
|
|
427
443
|
class Http {
|
|
@@ -1204,7 +1220,7 @@ class TrackAPI {
|
|
|
1204
1220
|
// if latitude & longitude are not provided,
|
|
1205
1221
|
// try and retrieve device location (will prompt for location permissions)
|
|
1206
1222
|
if (!latitude || !longitude) {
|
|
1207
|
-
const deviceLocation = yield Navigator.getCurrentPosition({ desiredAccuracy });
|
|
1223
|
+
const deviceLocation = yield Navigator.getCurrentPosition({ desiredAccuracy }, fraud);
|
|
1208
1224
|
latitude = deviceLocation.latitude;
|
|
1209
1225
|
longitude = deviceLocation.longitude;
|
|
1210
1226
|
accuracy = deviceLocation.accuracy;
|
package/dist/radar.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"radar.js","sources":[],"sourcesContent":[],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"radar.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;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;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
|
package/dist/version.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
declare const _default: "4.5.
|
|
1
|
+
declare const _default: "4.5.8-beta.0";
|
|
2
2
|
export default _default;
|
package/package.json
CHANGED
package/src/api/track.ts
CHANGED
|
@@ -25,7 +25,7 @@ class TrackAPI {
|
|
|
25
25
|
// if latitude & longitude are not provided,
|
|
26
26
|
// try and retrieve device location (will prompt for location permissions)
|
|
27
27
|
if (!latitude || !longitude) {
|
|
28
|
-
const deviceLocation = await Navigator.getCurrentPosition({ desiredAccuracy });
|
|
28
|
+
const deviceLocation = await Navigator.getCurrentPosition({ desiredAccuracy }, fraud);
|
|
29
29
|
latitude = deviceLocation.latitude;
|
|
30
30
|
longitude = deviceLocation.longitude;
|
|
31
31
|
accuracy = deviceLocation.accuracy;
|
package/src/navigator.ts
CHANGED
|
@@ -5,6 +5,26 @@ import { RadarLocationError, RadarPermissionsError } from './errors';
|
|
|
5
5
|
|
|
6
6
|
import type { LocationAuthorization, NavigatorPosition } from './types';
|
|
7
7
|
|
|
8
|
+
const radarGeolocation = (() => {
|
|
9
|
+
if (!navigator) {
|
|
10
|
+
return null;
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
const g = navigator.geolocation;
|
|
14
|
+
|
|
15
|
+
if (!g) {
|
|
16
|
+
return null;
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
const emptyFn = () => {};
|
|
20
|
+
|
|
21
|
+
return Object.freeze({
|
|
22
|
+
getCurrentPosition: g.getCurrentPosition ? g.getCurrentPosition.bind(g) : emptyFn,
|
|
23
|
+
watchPosition: g.watchPosition ? g.watchPosition.bind(g) : emptyFn,
|
|
24
|
+
clearWatch: g.clearWatch ? g.clearWatch.bind(g) : emptyFn,
|
|
25
|
+
});
|
|
26
|
+
})();
|
|
27
|
+
|
|
8
28
|
interface PositionOptionOverrides {
|
|
9
29
|
desiredAccuracy?: string;
|
|
10
30
|
}
|
|
@@ -21,11 +41,13 @@ const useHighAccuracy = (desiredAccuracy?: string) => (
|
|
|
21
41
|
);
|
|
22
42
|
|
|
23
43
|
class Navigator {
|
|
24
|
-
public static async getCurrentPosition(overrides: PositionOptionOverrides = {}): Promise<NavigatorPosition> {
|
|
44
|
+
public static async getCurrentPosition(overrides: PositionOptionOverrides = {}, fraud: Boolean = false): Promise<NavigatorPosition> {
|
|
25
45
|
return new Promise((resolve, reject) => {
|
|
26
46
|
const options = Config.get();
|
|
27
47
|
|
|
28
|
-
|
|
48
|
+
const g = fraud ? radarGeolocation : navigator.geolocation;
|
|
49
|
+
|
|
50
|
+
if (!g) {
|
|
29
51
|
return reject(new RadarLocationError('navigator.geolocation is not available.'));
|
|
30
52
|
}
|
|
31
53
|
|
|
@@ -67,7 +89,7 @@ class Navigator {
|
|
|
67
89
|
Logger.info(`Using geolocation options: ${JSON.stringify(positionOptions)}`);
|
|
68
90
|
|
|
69
91
|
// get current location from browser
|
|
70
|
-
|
|
92
|
+
g.getCurrentPosition(
|
|
71
93
|
(position) => {
|
|
72
94
|
if (!position || !position.coords) {
|
|
73
95
|
return reject(new RadarLocationError('device location return empty coordinates.'));
|
package/src/version.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export default '4.5.
|
|
1
|
+
export default '4.5.8-beta.0';
|