@colisweb/rescript-toolkit 5.9.0 → 5.9.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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@colisweb/rescript-toolkit",
3
- "version": "5.9.0",
3
+ "version": "5.9.2",
4
4
  "type": "module",
5
5
  "scripts": {
6
6
  "clean": "rescript clean",
@@ -34,6 +34,31 @@ module Document = {
34
34
  @val external addEventListener: (string, ReactEvent.Form.t => unit) => unit = "addEventListener"
35
35
  @val
36
36
  external removeEventListener: (string, ReactEvent.Form.t => unit) => unit = "removeEventListener"
37
+
38
+ module Element = {
39
+ type t
40
+
41
+ @val
42
+ external make: string => t = "document.createElement"
43
+ @set
44
+ external setSrc: (t, string) => unit = "src"
45
+ @set
46
+ external setHref: (t, string) => unit = "href"
47
+ @set
48
+ external setHref: (t, string) => unit = "href"
49
+ @set
50
+ external setRel: (t, string) => unit = "rel"
51
+ @set
52
+ external setAsync: (t, bool) => unit = "async"
53
+
54
+ @set
55
+ external onLoad: (t, unit => unit) => unit = "onload"
56
+ }
57
+
58
+ module Head = {
59
+ @val
60
+ external append: Element.t => unit = "document.head.append"
61
+ }
37
62
  }
38
63
 
39
64
  module DomElement = {
@@ -20,6 +20,31 @@ module Location: {
20
20
  module Document: {
21
21
  let addEventListener: (string, ReactEvent.Form.t => unit) => unit
22
22
  let removeEventListener: (string, ReactEvent.Form.t => unit) => unit
23
+
24
+ module Element: {
25
+ type t
26
+
27
+ @val
28
+ external make: string => t = "document.createElement"
29
+ @set
30
+ external setSrc: (t, string) => unit = "src"
31
+ @set
32
+ external setHref: (t, string) => unit = "href"
33
+ @set
34
+ external setHref: (t, string) => unit = "href"
35
+ @set
36
+ external setRel: (t, string) => unit = "rel"
37
+ @set
38
+ external setAsync: (t, bool) => unit = "async"
39
+
40
+ @set
41
+ external onLoad: (t, unit => unit) => unit = "onload"
42
+ }
43
+
44
+ module Head: {
45
+ @val
46
+ external append: Element.t => unit = "document.head.append"
47
+ }
23
48
  }
24
49
 
25
50
  module DomElement: {
@@ -2,6 +2,49 @@ type coordinates = {
2
2
  lat: float,
3
3
  lng: float,
4
4
  }
5
+
6
+ module Geo = {
7
+ module Point = {
8
+ type t
9
+
10
+ @new
11
+ external make: (float, float) => t = "H.geo.Point"
12
+ }
13
+ module Rect = {
14
+ type t
15
+ }
16
+ module LineString = {
17
+ type t
18
+ @val
19
+ external fromFlexiblePolyline: 'polyline => t = "H.geo.LineString.fromFlexiblePolyline"
20
+
21
+ @send
22
+ external getLatLngAltArray: (t, unit) => array<float> = "getLatLngAltArray"
23
+ }
24
+ }
25
+
26
+ module Event = {
27
+ type t<'data>
28
+
29
+ module Target = {
30
+ type t<'data>
31
+
32
+ type data = {maxZoom: int}
33
+
34
+ @send
35
+ external getData: (t<'data>, unit) => 'data = "getData"
36
+ @send
37
+ external getObjectData: (t<'data>, unit) => data = "getData"
38
+ @send
39
+ external getGeometry: (t<'data>, unit) => Geo.Point.t = "getGeometry"
40
+ @send
41
+ external getBoundingBox: (t<'data>, unit) => Geo.Rect.t = "getBoundingBox"
42
+ }
43
+
44
+ @get
45
+ external target: t<'data> => Target.t<'data> = "target"
46
+ }
47
+
5
48
  module Layers = {
6
49
  type map
7
50
 
@@ -9,6 +52,16 @@ module Layers = {
9
52
  and vector = {normal: normalVector}
10
53
  and normalVector = {map: map}
11
54
  }
55
+
56
+ module Url = {
57
+ module MultiValueQueryParameter = {
58
+ type t
59
+
60
+ @new
61
+ external make: array<string> => t = "H.service.Url.MultiValueQueryParameter"
62
+ }
63
+ }
64
+
12
65
  module Platform = {
13
66
  type t
14
67
  type options = {apikey: string}
@@ -18,28 +71,113 @@ module Platform = {
18
71
 
19
72
  type layersOptions = {pois: bool}
20
73
 
74
+ module Router = {
75
+ type t
76
+
77
+ type routeRequestParams = {
78
+ routingMode: string,
79
+ transportMode: string,
80
+ origin: string,
81
+ destination: string,
82
+ return: string,
83
+ via?: Url.MultiValueQueryParameter.t,
84
+ }
85
+
86
+ type rec result = {routes: array<route>}
87
+ and route = {sections: array<section>}
88
+ and section = {
89
+ polyline: string,
90
+ id: string,
91
+ arrival: location,
92
+ departure: location,
93
+ transport: transport,
94
+ }
95
+ and transport = {mode: string}
96
+ and location = {
97
+ place: place,
98
+ time: string,
99
+ }
100
+ and place = {
101
+ location: coordinates,
102
+ originalLocation: coordinates,
103
+ @as("type") type_: string,
104
+ waypoint?: int,
105
+ }
106
+
107
+ @send
108
+ external calculateRoute: (t, routeRequestParams, result => unit, 'error => unit) => unit =
109
+ "calculateRoute"
110
+ }
111
+
21
112
  @send
22
113
  external createDefaultLayers: (t, layersOptions) => Layers.t = "createDefaultLayers"
114
+ @send
115
+ external getRoutingService: (t, 'a, int) => Router.t = "getRoutingService"
23
116
  }
24
117
 
25
118
  module Map = {
26
119
  type instance
120
+ type object
121
+ type objectLayer
27
122
 
28
123
  type options = {
29
124
  zoom: int,
30
125
  center: coordinates,
31
126
  }
127
+
32
128
  @new
33
129
  external make: (Dom.element, Layers.map, options) => instance = "H.Map"
34
130
 
131
+ module Icon = {
132
+ type t
133
+
134
+ type rec options = {
135
+ size?: size,
136
+ anchor?: anchor,
137
+ }
138
+ and size = {
139
+ w: int,
140
+ h: int,
141
+ }
142
+ and anchor = {
143
+ x: float,
144
+ y: float,
145
+ }
146
+
147
+ @new
148
+ external make: (string, options) => t = "H.map.Icon"
149
+ }
150
+ module DomIcon = {
151
+ type t
152
+ @new
153
+ external make: string => t = "H.map.DomIcon"
154
+ }
155
+
35
156
  module Marker = {
36
157
  type t
37
158
 
159
+ type options = {icon?: Icon.t, min?: int, max?: int}
160
+ @new
161
+ external makeWithCoordinates: (coordinates, options) => t = "H.map.Marker"
38
162
  @new
39
- external make: coordinates => t = "H.map.Marker"
163
+ external makeWithGeoPoint: (Geo.Point.t, options) => t = "H.map.Marker"
40
164
 
41
165
  @send
42
166
  external setData: (t, string) => unit = "setData"
167
+
168
+ external toObject: t => object = "%identity"
169
+ }
170
+ module DomMarker = {
171
+ type t
172
+
173
+ type options = {icon?: DomIcon.t}
174
+ @new
175
+ external make: (coordinates, options) => t = "H.map.DomMarker"
176
+
177
+ @send
178
+ external setData: (t, string) => unit = "setData"
179
+
180
+ external toObject: t => object = "%identity"
43
181
  }
44
182
 
45
183
  module Viewport = {
@@ -48,26 +186,151 @@ module Map = {
48
186
  @send
49
187
  external resize: (t, unit) => unit = "resize"
50
188
  }
189
+ module ViewModel = {
190
+ type t
191
+
192
+ type options = {
193
+ zoom?: int,
194
+ bounds: Geo.Rect.t,
195
+ }
196
+
197
+ @send
198
+ external setLookAtData: (t, options) => unit = "setLookAtData"
199
+ }
51
200
 
52
201
  module Group = {
53
202
  type t
54
203
  @new
55
204
  external make: unit => t = "H.map.Group"
56
205
 
206
+ type makeOptions = {objects: array<object>}
207
+ @new
208
+ external makeFromObjects: makeOptions => t = "H.map.Group"
209
+
57
210
  @send
58
- external addEventListener: (t, string, 'event => unit) => unit = "addEventListener"
211
+ external addEventListener: (t, string, Event.t<'data> => unit) => unit = "addEventListener"
59
212
 
60
213
  @send
61
214
  external addMarker: (t, Marker.t) => unit = "addObject"
215
+
216
+ external toObject: t => object = "%identity"
217
+ }
218
+ module Polyline = {
219
+ type t
220
+
221
+ type style = {
222
+ ...JsxDOMStyle.t,
223
+ lineWidth: int,
224
+ strokeColor: string,
225
+ }
226
+ type options = {style?: style}
227
+
228
+ @new
229
+ external make: (Geo.LineString.t, options) => t = "H.map.Polyline"
230
+
231
+ @send
232
+ external getBoundingBox: (t, unit) => Geo.Rect.t = "getBoundingBox"
233
+ }
234
+ module Circle = {
235
+ type t
236
+
237
+ type rec options = {style?: style}
238
+ and style = {fillColor?: string}
239
+ @new
240
+ external make: (Geo.Point.t, int, options) => t = "H.map.Circle"
241
+ external toObject: t => object = "%identity"
242
+
243
+ type dataOptions = {maxZoom?: int}
244
+
245
+ @send
246
+ external setData: (t, dataOptions) => unit = "setData"
62
247
  }
63
248
 
64
249
  @send
65
250
  external addMarker: (instance, Marker.t) => unit = "addObject"
66
251
  @send
67
252
  external addGroup: (instance, Group.t) => unit = "addObject"
253
+ @send
254
+ external addObject: (instance, object) => unit = "addObject"
255
+ @send
256
+ external addPolyline: (instance, Polyline.t) => unit = "addObject"
257
+
258
+ @send
259
+ external addLayer: (instance, objectLayer) => unit = "addLayer"
260
+ @send
261
+ external setCenter: (instance, coordinates) => unit = "setCenter"
262
+ @send
263
+ external setCenterWithAnimation: (instance, Geo.Point.t, bool) => unit = "setCenter"
264
+ @send
265
+ external setZoom: (instance, int) => unit = "setZoom"
68
266
 
69
267
  @send
70
268
  external getViewPort: (instance, unit) => Viewport.t = "getViewPort"
269
+ @send
270
+ external getViewModel: (instance, unit) => ViewModel.t = "getViewModel"
271
+ }
272
+ module Clustering = {
273
+ module NoisePoint = {
274
+ type t
275
+
276
+ @send
277
+ external getData: (t, unit) => 'data = "getData"
278
+ @send
279
+ external setData: (t, 'data) => unit = "setData"
280
+ @send
281
+ external getPosition: (t, unit) => Geo.Point.t = "getPosition"
282
+ @send
283
+ external getMinZoom: (t, unit) => int = "getMinZoom"
284
+ }
285
+
286
+ module Cluster = {
287
+ type t
288
+
289
+ @send
290
+ external forEachDataPoint: (t, NoisePoint.t => unit) => unit = "forEachDataPoint"
291
+ @send
292
+ external getBoundingBox: (t, unit) => Geo.Rect.t = "getBoundingBox"
293
+ @send
294
+ external getPosition: (t, unit) => Geo.Point.t = "getPosition"
295
+ @send
296
+ external getMinZoom: (t, unit) => int = "getMinZoom"
297
+ @send
298
+ external getMaxZoom: (t, unit) => int = "getMaxZoom"
299
+ }
300
+
301
+ type theme = {
302
+ getClusterPresentation: Cluster.t => Map.Marker.t,
303
+ getNoisePresentation: NoisePoint.t => Map.Marker.t,
304
+ }
305
+
306
+ module DataPoint = {
307
+ type t<'a>
308
+ @new
309
+ external make: (float, float, Js.Nullable.t<float>, 'data) => t<'data> =
310
+ "H.clustering.DataPoint"
311
+ }
312
+ module Provider = {
313
+ type t<'a>
314
+
315
+ type rec options = {clusteringOptions: clusteringOptions, theme?: theme}
316
+ and clusteringOptions = {
317
+ eps: int,
318
+ // minimum weight of points required to form a cluster
319
+ minWeight: int,
320
+ }
321
+ @new
322
+ external make: (array<DataPoint.t<'a>>, options) => t<'a> = "H.clustering.Provider"
323
+
324
+ @send
325
+ external addEventListener: (t<'a>, string, Event.t<'a> => unit) => unit = "addEventListener"
326
+ }
327
+ }
328
+
329
+ module MapLayer = {
330
+ module ObjectLayer = {
331
+ @new
332
+ external make: Clustering.Provider.t<'data> => Map.objectLayer = "H.map.layer.ObjectLayer"
333
+ }
71
334
  }
72
335
 
73
336
  module MapEvents = {
@@ -90,8 +353,25 @@ module Ui = {
90
353
 
91
354
  module InfoBubble = {
92
355
  type t
356
+ type state =
357
+ | @as("open") Open
358
+ | @as("closed") Closed
359
+
360
+ type options = {
361
+ content: string,
362
+ onStateChange?: unknown => unit,
363
+ }
93
364
  @new
94
- external make: ('geometry, 'data) => t = "H.ui.InfoBubble"
365
+ external make: (Geo.Point.t, options) => t = "H.ui.InfoBubble"
366
+
367
+ @send
368
+ external setPosition: (t, Geo.Point.t) => unit = "setPosition"
369
+ @send
370
+ external setContent: (t, string) => unit = "setContent"
371
+ @send
372
+ external setState: (t, state) => unit = "setState"
373
+ @send
374
+ external open_: (t, unit) => unit = "open"
95
375
  }
96
376
 
97
377
  @send