radar-sdk-js 5.0.0-beta.5 → 5.0.0-beta.6
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 +39 -30
- package/dist/api/geocoding.d.ts +1 -1
- package/dist/api.d.ts +1 -1
- package/dist/config.d.ts +1 -1
- package/dist/errors.d.ts +1 -1
- package/dist/iife-entry.d.ts +1 -1
- package/dist/navigator.d.ts +1 -1
- package/dist/plugin.d.ts +7 -7
- package/dist/radar.js +246 -244
- package/dist/radar.js.map +1 -1
- package/dist/types.d.ts +8 -11
- package/dist/version.d.ts +1 -1
- package/package.json +22 -15
- package/src/api/config.ts +1 -2
- package/src/api/context.ts +1 -8
- package/src/api/conversions.ts +6 -5
- package/src/api/geocoding.ts +3 -2
- package/src/api/routing.ts +10 -25
- package/src/api/search.ts +10 -30
- package/src/api/track.ts +3 -22
- package/src/api/trips.ts +2 -1
- package/src/api.ts +15 -22
- package/src/config.ts +2 -2
- package/src/device.ts +11 -6
- package/src/errors.ts +1 -1
- package/src/http.ts +10 -13
- package/src/iife-entry.ts +3 -3
- package/src/logger.ts +1 -2
- package/src/navigator.ts +11 -12
- package/src/plugin.ts +7 -7
- package/src/session.ts +1 -1
- package/src/storage.ts +2 -3
- package/src/types.ts +15 -40
- package/src/version.ts +1 -1
package/README.md
CHANGED
|
@@ -21,16 +21,18 @@
|
|
|
21
21
|
</p>
|
|
22
22
|
|
|
23
23
|
🔥 Try it! 🔥
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
24
|
+
|
|
25
|
+
- <a href="https://radar.com/demo/js">Geofencing</a>
|
|
26
|
+
- <a href="https://radar.com/demo/api">Maps APIs</a>
|
|
27
|
+
- <a href="https://radar.com/documentation/maps/maps">Maps UI</a>
|
|
28
|
+
- <a href="https://radar.com/documentation/maps/autocomplete">Autocomplete UI</a>
|
|
28
29
|
|
|
29
30
|
## 🚀 Installation and Usage
|
|
30
31
|
|
|
31
32
|
### With npm
|
|
32
33
|
|
|
33
34
|
Install the core SDK:
|
|
35
|
+
|
|
34
36
|
```bash
|
|
35
37
|
# with npm
|
|
36
38
|
npm install radar-sdk-js
|
|
@@ -40,21 +42,27 @@ yarn add radar-sdk-js
|
|
|
40
42
|
```
|
|
41
43
|
|
|
42
44
|
Then import and initialize:
|
|
45
|
+
|
|
43
46
|
```js
|
|
44
47
|
import Radar from 'radar-sdk-js';
|
|
45
48
|
|
|
46
49
|
// initialize with your test or live publishable key
|
|
47
|
-
Radar.initialize('prj_test_pk_...', {
|
|
50
|
+
Radar.initialize('prj_test_pk_...', {
|
|
51
|
+
/* options */
|
|
52
|
+
});
|
|
48
53
|
```
|
|
49
54
|
|
|
50
55
|
### With a script tag
|
|
51
56
|
|
|
52
57
|
Add the following to your HTML:
|
|
58
|
+
|
|
53
59
|
```html
|
|
54
|
-
<script src="https://js.radar.com/v5.0.0-beta.
|
|
60
|
+
<script src="https://js.radar.com/v5.0.0-beta.6/radar.min.js"></script>
|
|
55
61
|
|
|
56
62
|
<script>
|
|
57
|
-
Radar.initialize('prj_test_pk_...', {
|
|
63
|
+
Radar.initialize('prj_test_pk_...', {
|
|
64
|
+
/* options */
|
|
65
|
+
});
|
|
58
66
|
</script>
|
|
59
67
|
```
|
|
60
68
|
|
|
@@ -99,19 +107,21 @@ Radar.initialize('prj_test_pk_...');
|
|
|
99
107
|
|
|
100
108
|
Radar.ui.autocomplete({
|
|
101
109
|
container: 'autocomplete',
|
|
102
|
-
onSelection: (result) => {
|
|
110
|
+
onSelection: (result) => {
|
|
111
|
+
console.log(result);
|
|
112
|
+
},
|
|
103
113
|
});
|
|
104
114
|
```
|
|
105
115
|
|
|
106
116
|
### Fraud plugin (npm)
|
|
107
117
|
|
|
108
118
|
```bash
|
|
109
|
-
npm install @radarlabs/fraud
|
|
119
|
+
npm install @radarlabs/plugin-fraud
|
|
110
120
|
```
|
|
111
121
|
|
|
112
122
|
```js
|
|
113
123
|
import Radar from 'radar-sdk-js';
|
|
114
|
-
import { createFraudPlugin } from '@radarlabs/fraud
|
|
124
|
+
import { createFraudPlugin } from '@radarlabs/plugin-fraud';
|
|
115
125
|
|
|
116
126
|
Radar.registerPlugin(createFraudPlugin());
|
|
117
127
|
Radar.initialize('prj_live_pk_...');
|
|
@@ -125,10 +135,10 @@ Plugin CDN bundles auto-register with the core SDK when loaded. Load
|
|
|
125
135
|
the core SDK first, then any plugins you need:
|
|
126
136
|
|
|
127
137
|
```html
|
|
128
|
-
<link href="https://js.radar.com/maps/v5.0.0-beta.4/radar-maps.css" rel="stylesheet"
|
|
129
|
-
<link href="https://js.radar.com/autocomplete/v5.0.0-beta.4/radar-autocomplete.css" rel="stylesheet"
|
|
138
|
+
<link href="https://js.radar.com/maps/v5.0.0-beta.4/radar-maps.css" rel="stylesheet" />
|
|
139
|
+
<link href="https://js.radar.com/autocomplete/v5.0.0-beta.4/radar-autocomplete.css" rel="stylesheet" />
|
|
130
140
|
|
|
131
|
-
<script src="https://js.radar.com/v5.0.0-beta.
|
|
141
|
+
<script src="https://js.radar.com/v5.0.0-beta.6/radar.min.js"></script>
|
|
132
142
|
<script src="https://js.radar.com/maps/v5.0.0-beta.4/radar-maps.min.js"></script>
|
|
133
143
|
<script src="https://js.radar.com/autocomplete/v5.0.0-beta.4/radar-autocomplete.min.js"></script>
|
|
134
144
|
<script src="https://js.radar.com/fraud/v5.0.0-beta.1/radar-fraud.min.js"></script>
|
|
@@ -144,8 +154,8 @@ by ID or element reference.
|
|
|
144
154
|
```html
|
|
145
155
|
<html>
|
|
146
156
|
<head>
|
|
147
|
-
<link href="https://js.radar.com/maps/v5.0.0-beta.4/radar-maps.css" rel="stylesheet"
|
|
148
|
-
<script src="https://js.radar.com/v5.0.0-beta.
|
|
157
|
+
<link href="https://js.radar.com/maps/v5.0.0-beta.4/radar-maps.css" rel="stylesheet" />
|
|
158
|
+
<script src="https://js.radar.com/v5.0.0-beta.6/radar.min.js"></script>
|
|
149
159
|
<script src="https://js.radar.com/maps/v5.0.0-beta.4/radar-maps.min.js"></script>
|
|
150
160
|
</head>
|
|
151
161
|
|
|
@@ -171,8 +181,8 @@ by ID or element reference.
|
|
|
171
181
|
```html
|
|
172
182
|
<html>
|
|
173
183
|
<head>
|
|
174
|
-
<link href="https://js.radar.com/autocomplete/v5.0.0-beta.4/radar-autocomplete.css" rel="stylesheet"
|
|
175
|
-
<script src="https://js.radar.com/v5.0.0-beta.
|
|
184
|
+
<link href="https://js.radar.com/autocomplete/v5.0.0-beta.4/radar-autocomplete.css" rel="stylesheet" />
|
|
185
|
+
<script src="https://js.radar.com/v5.0.0-beta.6/radar.min.js"></script>
|
|
176
186
|
<script src="https://js.radar.com/autocomplete/v5.0.0-beta.4/radar-autocomplete.min.js"></script>
|
|
177
187
|
</head>
|
|
178
188
|
|
|
@@ -182,7 +192,6 @@ by ID or element reference.
|
|
|
182
192
|
<script>
|
|
183
193
|
Radar.initialize('<RADAR_PUBLISHABLE_KEY>');
|
|
184
194
|
|
|
185
|
-
|
|
186
195
|
// create autocomplete widget
|
|
187
196
|
Radar.ui.autocomplete({
|
|
188
197
|
container: 'autocomplete', // OR document.getElementById('autocomplete')
|
|
@@ -206,17 +215,16 @@ are needed for geofencing.
|
|
|
206
215
|
```html
|
|
207
216
|
<html>
|
|
208
217
|
<head>
|
|
209
|
-
<script src="https://js.radar.com/v5.0.0-beta.
|
|
218
|
+
<script src="https://js.radar.com/v5.0.0-beta.6/radar.min.js"></script>
|
|
210
219
|
</head>
|
|
211
220
|
|
|
212
221
|
<body>
|
|
213
222
|
<script>
|
|
214
223
|
Radar.initialize('<RADAR_PUBLISHABLE_KEY>');
|
|
215
224
|
|
|
216
|
-
Radar.trackOnce({ userId: 'example-user-id' })
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
});
|
|
225
|
+
Radar.trackOnce({ userId: 'example-user-id' }).then(({ location, user, events }) => {
|
|
226
|
+
// do something with user location or events
|
|
227
|
+
});
|
|
220
228
|
</script>
|
|
221
229
|
</body>
|
|
222
230
|
</html>
|
|
@@ -224,12 +232,12 @@ are needed for geofencing.
|
|
|
224
232
|
|
|
225
233
|
## Packages
|
|
226
234
|
|
|
227
|
-
| Package
|
|
228
|
-
|
|
229
|
-
| `radar-sdk-js`
|
|
230
|
-
| `@radarlabs/plugin-maps`
|
|
231
|
-
| `@radarlabs/plugin-autocomplete` | [](https://www.npmjs.com/package/@radarlabs/plugin-autocomplete) | Autocomplete UI widget
|
|
232
|
-
| `@radarlabs/fraud
|
|
235
|
+
| Package | npm | Description |
|
|
236
|
+
| -------------------------------- | --------------------------------------------------------------------------------------------------------------------------------------- | --------------------------------------------------------- |
|
|
237
|
+
| `radar-sdk-js` | [](https://www.npmjs.com/package/radar-sdk-js) | Core SDK — tracking, geocoding, search, routing |
|
|
238
|
+
| `@radarlabs/plugin-maps` | [](https://www.npmjs.com/package/@radarlabs/plugin-maps) | Maps UI — RadarMap, RadarMarker, RadarPopup (MapLibre GL) |
|
|
239
|
+
| `@radarlabs/plugin-autocomplete` | [](https://www.npmjs.com/package/@radarlabs/plugin-autocomplete) | Autocomplete UI widget |
|
|
240
|
+
| `@radarlabs/plugin-fraud` | [](https://www.npmjs.com/package/@radarlabs/plugin-fraud) | Fraud detection — verified tracking, location tokens |
|
|
233
241
|
|
|
234
242
|
## Plugin system
|
|
235
243
|
|
|
@@ -241,7 +249,7 @@ plugins before or after calling `Radar.initialize()`:
|
|
|
241
249
|
import Radar from 'radar-sdk-js';
|
|
242
250
|
import { createMapsPlugin } from '@radarlabs/plugin-maps';
|
|
243
251
|
import { createAutocompletePlugin } from '@radarlabs/plugin-autocomplete';
|
|
244
|
-
import { createFraudPlugin } from '@radarlabs/fraud
|
|
252
|
+
import { createFraudPlugin } from '@radarlabs/plugin-fraud';
|
|
245
253
|
|
|
246
254
|
Radar.registerPlugin(createMapsPlugin());
|
|
247
255
|
Radar.registerPlugin(createAutocompletePlugin());
|
|
@@ -257,6 +265,7 @@ import type { RadarPlugin, RadarPluginContext } from 'radar-sdk-js/plugin';
|
|
|
257
265
|
```
|
|
258
266
|
|
|
259
267
|
## 🔗 Other links
|
|
268
|
+
|
|
260
269
|
- [Contributing](CONTRIBUTING.md)
|
|
261
270
|
- [Migrating from 3.x to 4.x](https://github.com/radarlabs/radar-sdk-js/blob/v4-beta/MIGRATION.md)
|
|
262
271
|
- [Migrating from 4.x to 5.x](MIGRATION.md)
|
package/dist/api/geocoding.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { RadarForwardGeocodeParams, RadarReverseGeocodeParams, RadarGeocodeResponse, RadarIPGeocodeResponse } from '../types';
|
|
1
|
+
import type { RadarForwardGeocodeParams, RadarReverseGeocodeParams, RadarGeocodeResponse, RadarIPGeocodeResponse } from '../types';
|
|
2
2
|
/** @internal geocoding API — use Radar.forwardGeocode / reverseGeocode / ipGeocode instead */
|
|
3
3
|
declare class Geocoding {
|
|
4
4
|
/**
|
package/dist/api.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { RadarError } from './errors';
|
|
1
|
+
import type { RadarError } from './errors';
|
|
2
2
|
import type { RadarPlugin } from './plugin';
|
|
3
3
|
import type { Location, NavigatorPosition, RadarAutocompleteParams, RadarAutocompleteResponse, RadarContextResponse, RadarConversionParams, RadarConversionResponse, RadarDistanceParams, RadarForwardGeocodeParams, RadarGeocodeResponse, RadarIPGeocodeResponse, RadarMatrixParams, RadarMatrixResponse, RadarMetadata, RadarOptions, RadarReverseGeocodeParams, RadarRouteResponse, RadarSearchGeofencesParams, RadarSearchGeofencesResponse, RadarSearchPlacesParams, RadarSearchPlacesResponse, RadarTrackParams, RadarTrackResponse, RadarTripOptions, RadarTripResponse, RadarValidateAddressParams, RadarValidateAddressResponse } from './types';
|
|
4
4
|
/**
|
package/dist/config.d.ts
CHANGED
package/dist/errors.d.ts
CHANGED
package/dist/iife-entry.d.ts
CHANGED
package/dist/navigator.d.ts
CHANGED
package/dist/plugin.d.ts
CHANGED
|
@@ -1,11 +1,4 @@
|
|
|
1
1
|
import type Radar from './api';
|
|
2
|
-
import type Config from './config';
|
|
3
|
-
import type Http from './http';
|
|
4
|
-
import type Storage from './storage';
|
|
5
|
-
import type Device from './device';
|
|
6
|
-
import type Session from './session';
|
|
7
|
-
import type Logger from './logger';
|
|
8
|
-
import type Navigator from './navigator';
|
|
9
2
|
import type AddressesAPI from './api/addresses';
|
|
10
3
|
import type ConfigAPI from './api/config';
|
|
11
4
|
import type ContextAPI from './api/context';
|
|
@@ -15,7 +8,14 @@ import type RoutingAPI from './api/routing';
|
|
|
15
8
|
import type SearchAPI from './api/search';
|
|
16
9
|
import type TrackAPI from './api/track';
|
|
17
10
|
import type TripsAPI from './api/trips';
|
|
11
|
+
import type Config from './config';
|
|
12
|
+
import type Device from './device';
|
|
18
13
|
import type * as errors from './errors';
|
|
14
|
+
import type Http from './http';
|
|
15
|
+
import type Logger from './logger';
|
|
16
|
+
import type Navigator from './navigator';
|
|
17
|
+
import type Session from './session';
|
|
18
|
+
import type Storage from './storage';
|
|
19
19
|
/** interface that all Radar plugins must implement */
|
|
20
20
|
export interface RadarPlugin {
|
|
21
21
|
/** unique plugin name (e.g. `'maps'`, `'autocomplete'`) */
|