@ranamaps/maps-react-native 0.0.0-stage → 0.4.0-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.
Files changed (41) hide show
  1. package/BETA-STATUS.md +13 -0
  2. package/CHANGELOG.md +40 -0
  3. package/LICENSE.md +13 -0
  4. package/NOTICES.md +230 -0
  5. package/README.md +61 -2
  6. package/RanaMapsReactNative.podspec +17 -0
  7. package/android/build.gradle +25 -0
  8. package/android/src/main/AndroidManifest.xml +1 -0
  9. package/android/src/main/java/com/ranamaps/reactnative/RanaMapManager.kt +115 -0
  10. package/android/src/main/java/com/ranamaps/reactnative/RanaMapsModule.kt +41 -0
  11. package/android/src/main/java/com/ranamaps/reactnative/RanaMapsPackage.kt +11 -0
  12. package/app.plugin.js +127 -0
  13. package/ios/RanaMapViewComponentView.mm +116 -0
  14. package/ios/RanaMapsModule.mm +32 -0
  15. package/ios/RanaNativeRuntime.swift +42 -0
  16. package/lib/bridge.d.ts +40 -0
  17. package/lib/bridge.js +152 -0
  18. package/lib/index.d.ts +31 -0
  19. package/lib/index.js +113 -0
  20. package/lib/map-lifecycle.d.ts +5 -0
  21. package/lib/map-lifecycle.js +10 -0
  22. package/lib/models.d.ts +509 -0
  23. package/lib/models.js +2 -0
  24. package/lib/sdk.d.ts +309 -0
  25. package/lib/sdk.js +588 -0
  26. package/lib/specs/NativeRanaMaps.d.ts +8 -0
  27. package/lib/specs/NativeRanaMaps.js +4 -0
  28. package/lib/specs/RanaMapViewNativeComponent.d.ts +13 -0
  29. package/lib/specs/RanaMapViewNativeComponent.js +4 -0
  30. package/lib/specs/RanaMarkerViewNativeComponent.d.ts +9 -0
  31. package/lib/specs/RanaMarkerViewNativeComponent.js +4 -0
  32. package/package.json +59 -4
  33. package/react-native.config.js +12 -0
  34. package/src/bridge.ts +184 -0
  35. package/src/index.tsx +168 -0
  36. package/src/map-lifecycle.ts +11 -0
  37. package/src/models.ts +510 -0
  38. package/src/sdk.ts +732 -0
  39. package/src/specs/NativeRanaMaps.ts +16 -0
  40. package/src/specs/RanaMapViewNativeComponent.ts +10 -0
  41. package/src/specs/RanaMarkerViewNativeComponent.ts +9 -0
package/lib/sdk.js ADDED
@@ -0,0 +1,588 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.RanaMapController = exports.RanaOfflineManager = exports.RanaOfflineRegion = exports.RanaClient = exports.JourneyTraceRecorder = exports.RanaStyleLayer = exports.RanaGeoJsonSource = exports.RanaVehicle = exports.TravellerAppearance = exports.VehicleAppearance = exports.RanaPolyline = exports.RanaMarker = exports.MarkerContent = exports.RanaOverlay = exports.RanaResource = exports.RanaError = void 0;
4
+ exports.decodePolyline = decodePolyline;
5
+ var bridge_1 = require("./bridge");
6
+ Object.defineProperty(exports, "RanaError", { enumerable: true, get: function () { return bridge_1.RanaError; } });
7
+ class RanaResource {
8
+ runtime;
9
+ handle;
10
+ cleanup = [];
11
+ constructor(runtime, handle) {
12
+ this.runtime = runtime;
13
+ this.handle = handle;
14
+ }
15
+ onEvent(listener) {
16
+ const off = this.runtime.on(this.handle, listener);
17
+ this.cleanup.push(off);
18
+ return off;
19
+ }
20
+ call(method, args = {}, signal) {
21
+ return this.runtime.call(this.handle, method, args, signal);
22
+ }
23
+ async dispose() {
24
+ try {
25
+ await this.call("dispose");
26
+ }
27
+ finally {
28
+ this.runtime.forgetHandle(this.handle);
29
+ this.cleanup.splice(0).forEach((fn) => fn());
30
+ }
31
+ }
32
+ }
33
+ exports.RanaResource = RanaResource;
34
+ class RanaOverlay extends RanaResource {
35
+ async remove() {
36
+ await this.call("remove");
37
+ this.cleanup.splice(0).forEach((fn) => fn());
38
+ }
39
+ }
40
+ exports.RanaOverlay = RanaOverlay;
41
+ /** Builders for each marker family, e.g. `addMarker(p, MarkerContent.badge("₦2,500"))`. */
42
+ exports.MarkerContent = {
43
+ pin: (glyph = "dot", size = "m") => ({ kind: "pin", glyph, size }),
44
+ labelledPin: (label, size = "m") => ({ kind: "pin", label, size }),
45
+ badge: (text, icon) => (icon ? { kind: "badge", text, icon } : { kind: "badge", text }),
46
+ /** The "pick a spot" pin shown while a user chooses a place. */
47
+ dropPin: (glyph = "dot") => ({ kind: "pin", glyph, size: "m", drop: true }),
48
+ avatar: (name, live = false) => (live ? { kind: "avatar", name, live } : { kind: "avatar", name }),
49
+ dot: () => ({ kind: "dot" }),
50
+ photo: (imageBase64) => ({ kind: "photo", imageBase64 }),
51
+ routeStart: () => ({ kind: "stop", role: "start" }),
52
+ routeStop: (label) => (label === undefined ? { kind: "stop", role: "waypoint" } : { kind: "stop", role: "waypoint", label }),
53
+ routeDestination: () => ({ kind: "stop", role: "destination" }),
54
+ image: (imageBase64, anchor = "bottom", size = "m") => ({ kind: "image", imageBase64, anchor, size }),
55
+ };
56
+ /** The bridge form of marker content (MarkerContentWire in cross-platform/models.json). */
57
+ function contentWire(content) {
58
+ switch (content.kind) {
59
+ case "pin":
60
+ case "badge":
61
+ case "avatar":
62
+ case "dot":
63
+ case "image":
64
+ case "photo":
65
+ case "stop": return { ...content };
66
+ default: throw new TypeError(`Unknown marker content: ${content.kind}`);
67
+ }
68
+ }
69
+ class RanaMarker extends RanaOverlay {
70
+ setPosition(point) {
71
+ return this.call("setPosition", { point });
72
+ }
73
+ /** Replaces what the marker shows, keeping its position, style and taps (a live price keeps its marker). */
74
+ setContent(content) {
75
+ return this.call("setContent", { content: contentWire(content) });
76
+ }
77
+ /** Restyles the marker. Fields left out take their defaults. */
78
+ setStyle(style) {
79
+ return this.call("setStyle", { style });
80
+ }
81
+ setVisible(visible) {
82
+ return this.call("setVisible", { visible });
83
+ }
84
+ /** Calls `listener` on each tap on the marker. Returns a function that stops listening. */
85
+ onTap(listener) {
86
+ return this.onEvent((event) => { if (event.type === "tap")
87
+ listener(); });
88
+ }
89
+ callout;
90
+ calloutPresses;
91
+ /** Gives the marker a callout that opens when the marker is tapped; null removes it. */
92
+ setCallout(callout) {
93
+ if (callout && !callout.title?.trim())
94
+ throw new TypeError("A callout needs a title");
95
+ this.callout = callout;
96
+ this.calloutPresses ??= this.onEvent((event) => {
97
+ if (event.type !== "callout")
98
+ return;
99
+ const action = event.value?.action;
100
+ (action === "primary" ? this.callout?.primary : action === "secondary" ? this.callout?.secondary : undefined)?.onPress();
101
+ });
102
+ const wire = callout
103
+ ? { title: callout.title, detail: callout.detail, primary: callout.primary?.label, secondary: callout.secondary?.label }
104
+ : null;
105
+ return this.call("setCallout", { callout: wire });
106
+ }
107
+ /** Opens the marker's callout now (one callout is open per map at a time). */
108
+ showCallout() {
109
+ return this.call("showCallout");
110
+ }
111
+ hideCallout() {
112
+ return this.call("hideCallout");
113
+ }
114
+ }
115
+ exports.RanaMarker = RanaMarker;
116
+ class RanaPolyline extends RanaOverlay {
117
+ setProgress(progress) {
118
+ return this.call("setProgress", { progress });
119
+ }
120
+ /** Restyles the line in place (a tapped alternative becomes the chosen route). */
121
+ setOptions(options) {
122
+ return this.call("setOptions", { options });
123
+ }
124
+ tappable;
125
+ /** Calls `listener` with the point of each tap on the line, with a generous touch area. */
126
+ onTap(listener) {
127
+ this.tappable ??= this.call("setTappable", { tappable: true });
128
+ return this.onEvent((event) => { if (event.type === "tap")
129
+ listener(event.value); });
130
+ }
131
+ }
132
+ exports.RanaPolyline = RanaPolyline;
133
+ /**
134
+ * What a vehicle looks like: a Rana Kit vehicle in any colour, or your own artwork (base64 PNG or JPEG). Images and
135
+ * frames should face north (up) at heading 0; they turn with the heading unless `rotates` is false.
136
+ */
137
+ exports.VehicleAppearance = {
138
+ kit: (vehicle, options = {}) => ({ kind: "kit", vehicle, ...options }),
139
+ image: (imageBase64, options = {}) => ({ kind: "image", imageBase64, ...options }),
140
+ /** Frames played in a loop, one every `frameMs` (default 100). Holds the first frame when animations are off. */
141
+ animated: (framesBase64, options = {}) => {
142
+ if (framesBase64.length === 0)
143
+ throw new TypeError("An animated vehicle needs at least one frame");
144
+ return { kind: "animated", framesBase64, ...options };
145
+ },
146
+ };
147
+ /** How the traveller (your own position) is drawn. The puck is the default. */
148
+ exports.TravellerAppearance = {
149
+ /** The Rana Kit puck: an arrow that turns with the heading. Without a heading it shows as the dot. */
150
+ puck: () => ({ kind: "puck" }),
151
+ dot: () => ({ kind: "dot" }),
152
+ /** Any vehicle appearance: a kit vehicle, your image or animation. It keeps its last heading. */
153
+ vehicle: (vehicle) => ({ kind: "vehicle", vehicle }),
154
+ };
155
+ class RanaVehicle extends RanaOverlay {
156
+ update(point, heading = 0, durationMs = 0) {
157
+ return this.call("update", { point, heading, durationMs });
158
+ }
159
+ setState(state) {
160
+ return this.call("setState", { state });
161
+ }
162
+ /** Swaps the look in place (a rider picks a new bike), keeping position, heading, state and taps. */
163
+ setAppearance(appearance) {
164
+ return this.call("setAppearance", { appearance });
165
+ }
166
+ }
167
+ exports.RanaVehicle = RanaVehicle;
168
+ class RanaGeoJsonSource extends RanaOverlay {
169
+ setData(geoJson) {
170
+ return this.call("setData", { geoJson });
171
+ }
172
+ }
173
+ exports.RanaGeoJsonSource = RanaGeoJsonSource;
174
+ class RanaStyleLayer extends RanaOverlay {
175
+ setOptions(options) {
176
+ return this.call("setOptions", options);
177
+ }
178
+ }
179
+ exports.RanaStyleLayer = RanaStyleLayer;
180
+ class JourneyTraceRecorder extends RanaResource {
181
+ record(fix) {
182
+ return this.call("record", fix);
183
+ }
184
+ flush(signal) {
185
+ return this.call("flush", {}, signal);
186
+ }
187
+ stop() {
188
+ return this.call("stop");
189
+ }
190
+ status() {
191
+ return this.call("status");
192
+ }
193
+ }
194
+ exports.JourneyTraceRecorder = JourneyTraceRecorder;
195
+ class RanaClient extends RanaResource {
196
+ static async create(runtime, key, transport) {
197
+ const cb = transport
198
+ ? runtime.registerCallback((_, value, signal) => transport(value, signal))
199
+ : undefined;
200
+ try {
201
+ const client = new RanaClient(runtime, await runtime.call("runtime", "createClient", {
202
+ key,
203
+ transportId: cb?.id,
204
+ }));
205
+ if (cb)
206
+ client.cleanup.push(cb.dispose);
207
+ return client;
208
+ }
209
+ catch (error) {
210
+ cb?.dispose();
211
+ throw error;
212
+ }
213
+ }
214
+ describeKey(signal) {
215
+ return this.call("describeKey", {}, signal);
216
+ }
217
+ directions(options, signal) {
218
+ return this.call("directions", options, signal);
219
+ }
220
+ matrix(options, signal) {
221
+ return this.call("matrix", options, signal);
222
+ }
223
+ snapToRoads(options, signal) {
224
+ return this.call("snapToRoads", options, signal);
225
+ }
226
+ reverseGeocode(point, signal) {
227
+ return this.call("reverseGeocode", { point }, signal);
228
+ }
229
+ geocode(options, signal) {
230
+ return this.call("geocode", options, signal);
231
+ }
232
+ places = {
233
+ autocomplete: (options, signal) => this.call("places.autocomplete", options, signal),
234
+ details: (placeId, signal) => this.call("places.details", { placeId }, signal),
235
+ nearby: (options, signal) => this.call("places.nearby", options, signal),
236
+ };
237
+ uploadJourneyTrace(batch, signal) {
238
+ return this.call("uploadJourneyTrace", batch, signal);
239
+ }
240
+ async createTraceRecorder(options, uploader) {
241
+ const cb = uploader
242
+ ? this.runtime.registerCallback((_, value, signal) => uploader(value, signal))
243
+ : undefined;
244
+ try {
245
+ const recorder = new JourneyTraceRecorder(this.runtime, await this.call("createTraceRecorder", {
246
+ ...options,
247
+ uploaderId: cb?.id,
248
+ }));
249
+ if (cb)
250
+ recorder.cleanup.push(cb.dispose);
251
+ return recorder;
252
+ }
253
+ catch (error) {
254
+ cb?.dispose();
255
+ throw error;
256
+ }
257
+ }
258
+ }
259
+ exports.RanaClient = RanaClient;
260
+ class RanaOfflineRegion extends RanaResource {
261
+ info;
262
+ constructor(runtime, handle, info) {
263
+ super(runtime, handle);
264
+ this.info = info;
265
+ }
266
+ progress() {
267
+ return this.call("progress");
268
+ }
269
+ resume() {
270
+ return this.call("resume");
271
+ }
272
+ pause() {
273
+ return this.call("pause");
274
+ }
275
+ refresh(signal) {
276
+ return this.call("refresh", {}, signal);
277
+ }
278
+ async remove(signal) {
279
+ await this.call("remove", {}, signal);
280
+ this.cleanup.splice(0).forEach((fn) => fn());
281
+ }
282
+ }
283
+ exports.RanaOfflineRegion = RanaOfflineRegion;
284
+ class RanaOfflineManager extends RanaResource {
285
+ static async create(runtime, key) {
286
+ return new RanaOfflineManager(runtime, await runtime.call("runtime", "createOfflineManager", { key }));
287
+ }
288
+ async regions() {
289
+ const entries = await this.call("regions");
290
+ return entries.map((e) => new RanaOfflineRegion(this.runtime, e.handle, e.info));
291
+ }
292
+ async createRegion(options) {
293
+ const e = await this.call("createRegion", options);
294
+ return new RanaOfflineRegion(this.runtime, e.handle, e.info);
295
+ }
296
+ }
297
+ exports.RanaOfflineManager = RanaOfflineManager;
298
+ class RanaMapController extends RanaResource {
299
+ providerCleanup;
300
+ reroutingCleanup;
301
+ onMarkerDrag(listener) {
302
+ return this.onEvent((e) => {
303
+ if (e.type === "markerDrag")
304
+ listener(e.value);
305
+ });
306
+ }
307
+ onCameraMove(listener) {
308
+ return this.onEvent((e) => {
309
+ if (e.type === "cameraMove")
310
+ listener(e.value);
311
+ });
312
+ }
313
+ onCameraIdle(listener) {
314
+ return this.onEvent((e) => {
315
+ if (e.type === "cameraIdle")
316
+ listener(e.value);
317
+ });
318
+ }
319
+ onReroutingChanged(listener) {
320
+ return this.onEvent((e) => {
321
+ if (e.type === "reroutingChanged")
322
+ listener(e.value);
323
+ });
324
+ }
325
+ onRerouted(listener) {
326
+ return this.onEvent((e) => {
327
+ if (e.type === "rerouted")
328
+ listener(e.value);
329
+ });
330
+ }
331
+ /** Each accepted measured location fix, from the connected provider or `updateLocation`. */
332
+ onLocation(listener) {
333
+ return this.onEvent((e) => {
334
+ if (e.type === "location")
335
+ listener(e.value);
336
+ });
337
+ }
338
+ onLocationRouteChanged(listener) {
339
+ return this.onEvent((e) => {
340
+ if (e.type === "locationRouteChanged")
341
+ listener(e.value);
342
+ });
343
+ }
344
+ setControls(controls) {
345
+ return this.update({ controls });
346
+ }
347
+ setAttribution(attribution) {
348
+ return this.update({ settings: { attribution } });
349
+ }
350
+ applySettings(settings) {
351
+ return this.update({ settings });
352
+ }
353
+ moveTo(center, zoom, animated = true) {
354
+ return this.setCamera({ center, zoom }, animated);
355
+ }
356
+ update(options) {
357
+ return this.call("update", options);
358
+ }
359
+ cameraState() {
360
+ return this.call("cameraState");
361
+ }
362
+ setCamera(camera, animated = true, durationMs = 300, signal) {
363
+ return this.call("setCamera", { camera, animated, durationMs }, signal);
364
+ }
365
+ fitPoints(points, padding = 40) {
366
+ return this.call("fitPoints", { points, padding });
367
+ }
368
+ setStyle(style) {
369
+ return this.call("setStyle", style);
370
+ }
371
+ setPadding(padding) {
372
+ return this.call("setPadding", padding);
373
+ }
374
+ setTracking(tracking) {
375
+ return this.call("setTracking", { tracking });
376
+ }
377
+ setLocateState(state) {
378
+ return this.call("setLocateState", { state });
379
+ }
380
+ project(points) {
381
+ return this.call("project", { points });
382
+ }
383
+ unproject(points) {
384
+ return this.call("unproject", { points });
385
+ }
386
+ setProjectionPoints(points) {
387
+ return this.call("setProjectionPoints", { points });
388
+ }
389
+ /** Adds a marker: any Rana Kit family (`MarkerContent.pin()`, `.badge()`, `.avatar()`, `.dot()`) or your own image. */
390
+ /** Adds many markers with one redraw and one call across the bridge, returning their handles in the same order. */
391
+ async addMarkers(entries) {
392
+ const handles = await this.call("addMarkers", {
393
+ markers: entries.map((e) => ({ point: e.point, content: contentWire(e.content ?? { kind: "pin" }), style: e.style ?? {} })),
394
+ });
395
+ return handles.map((handle) => new RanaMarker(this.runtime, handle));
396
+ }
397
+ async addMarker(point, content = { kind: "pin" }, style = {}) {
398
+ return new RanaMarker(this.runtime, await this.call("addMarker", { point, content: contentWire(content), style }));
399
+ }
400
+ async addPoints(points, options = {}) {
401
+ return new RanaOverlay(this.runtime, await this.call("addPoints", { points, options }));
402
+ }
403
+ /** A vehicle that glides between updates: a Rana Kit vehicle (default a car) or your own image or animation. */
404
+ async addVehicle(point, appearance = exports.VehicleAppearance.kit("car"), options = {}) {
405
+ return new RanaVehicle(this.runtime, await this.call("addVehicle", { point, appearance, options }));
406
+ }
407
+ async addPolyline(points, options = {}) {
408
+ return new RanaPolyline(this.runtime, await this.call("addPolyline", { points, options }));
409
+ }
410
+ showRoute(route, options = {}) {
411
+ return this.addPolyline(decodePolyline(route.geometry), options);
412
+ }
413
+ async addPolygon(rings, options = {}) {
414
+ return new RanaOverlay(this.runtime, await this.call("addPolygon", { rings, options }));
415
+ }
416
+ async addCircle(center, radiusMetres, options = {}) {
417
+ return new RanaOverlay(this.runtime, await this.call("addCircle", { center, radiusMetres, options }));
418
+ }
419
+ showUserLocation(point, options = {}) {
420
+ return this.call("showUserLocation", { point, options });
421
+ }
422
+ hideUserLocation() {
423
+ return this.call("hideUserLocation");
424
+ }
425
+ updateLocation(fix) {
426
+ return this.call("updateLocation", fix);
427
+ }
428
+ updateDeviceHeading(fix) {
429
+ return this.call("updateDeviceHeading", fix);
430
+ }
431
+ useNativeLocationProvider(options = {}) {
432
+ this.providerCleanup?.();
433
+ this.providerCleanup = undefined;
434
+ return this.call("setLocationProvider", {
435
+ provider: "native",
436
+ options,
437
+ });
438
+ }
439
+ async setLocationProvider(provider) {
440
+ this.providerCleanup?.();
441
+ this.providerCleanup = undefined;
442
+ if (typeof provider === "string" || provider === null) {
443
+ await this.call("setLocationProvider", { provider: provider ?? "none" });
444
+ return;
445
+ }
446
+ const callbackId = `location-${this.handle}-${Date.now()}`;
447
+ let handle;
448
+ let generation = 0;
449
+ let headingGeneration = 0;
450
+ const fixes = [];
451
+ const deliver = (method, value) => {
452
+ const send = () => {
453
+ if (handle)
454
+ void this.runtime.call(handle, method, value);
455
+ };
456
+ if (handle)
457
+ send();
458
+ else
459
+ fixes.push(send);
460
+ };
461
+ const off = this.runtime.on(callbackId, (event) => {
462
+ if (event.type === "providerStart") {
463
+ const token = ++generation;
464
+ provider.start((f) => {
465
+ if (token === generation)
466
+ deliver("location", f);
467
+ }, (e) => {
468
+ if (token === generation)
469
+ deliver("error", e);
470
+ });
471
+ }
472
+ if (event.type === "providerStop") {
473
+ generation++;
474
+ provider.stop();
475
+ }
476
+ if (event.type === "headingStart") {
477
+ const token = ++headingGeneration;
478
+ provider.startHeading?.((f) => {
479
+ if (token === headingGeneration)
480
+ deliver("heading", f);
481
+ });
482
+ }
483
+ if (event.type === "headingStop") {
484
+ headingGeneration++;
485
+ provider.stopHeading?.();
486
+ }
487
+ });
488
+ const cleanup = () => {
489
+ generation++;
490
+ headingGeneration++;
491
+ off();
492
+ provider.stop();
493
+ provider.stopHeading?.();
494
+ fixes.length = 0;
495
+ };
496
+ try {
497
+ handle = await this.call("setLocationProvider", {
498
+ provider: "custom",
499
+ callbackId,
500
+ });
501
+ fixes.splice(0).forEach((send) => send());
502
+ this.providerCleanup = cleanup;
503
+ }
504
+ catch (error) {
505
+ cleanup();
506
+ throw error;
507
+ }
508
+ }
509
+ setLocationRoute(points, options = {}) {
510
+ return this.call("setLocationRoute", { points, options });
511
+ }
512
+ locationRouteStatus() {
513
+ return this.call("locationRouteStatus");
514
+ }
515
+ async setAutomaticRerouting(options, provider) {
516
+ this.reroutingCleanup?.();
517
+ this.reroutingCleanup = undefined;
518
+ const cb = typeof provider === "function"
519
+ ? this.runtime.registerCallback((_, value, signal) => provider(value, signal))
520
+ : undefined;
521
+ try {
522
+ await this.call("setAutomaticRerouting", {
523
+ options,
524
+ client: provider instanceof RanaClient ? provider.handle : undefined,
525
+ providerId: cb?.id,
526
+ });
527
+ this.reroutingCleanup = cb?.dispose;
528
+ }
529
+ catch (error) {
530
+ cb?.dispose();
531
+ throw error;
532
+ }
533
+ }
534
+ setJourneyTraceRecorder(recorder) {
535
+ return this.call("setJourneyTraceRecorder", {
536
+ recorder: recorder?.handle ?? null,
537
+ });
538
+ }
539
+ async addGeoJsonSource(id, geoJson) {
540
+ return new RanaGeoJsonSource(this.runtime, await this.call("addGeoJsonSource", { id, geoJson }));
541
+ }
542
+ async addLayer(id, sourceId, options) {
543
+ return new RanaStyleLayer(this.runtime, await this.call("addLayer", { id, sourceId, options }));
544
+ }
545
+ layerIds() {
546
+ return this.call("layerIds");
547
+ }
548
+ setLayerVisibility(id, visible) {
549
+ return this.call("setLayerVisibility", { id, visible });
550
+ }
551
+ setLayerColor(id, color) {
552
+ return this.call("setLayerColor", { id, color });
553
+ }
554
+ queryFeatures(point, layerIds = []) {
555
+ return this.call("queryFeatures", { point, layerIds });
556
+ }
557
+ async dispose() {
558
+ this.cleanup.splice(0).forEach((fn) => fn());
559
+ this.providerCleanup?.();
560
+ this.reroutingCleanup?.();
561
+ await super.dispose();
562
+ }
563
+ }
564
+ exports.RanaMapController = RanaMapController;
565
+ function decodePolyline(value, precision = 6) {
566
+ let index = 0, latitude = 0, longitude = 0;
567
+ const next = () => {
568
+ let result = 0, shift = 0, b;
569
+ do {
570
+ if (index >= value.length || shift > 30)
571
+ throw new Error("Invalid polyline");
572
+ b = value.charCodeAt(index++) - 63;
573
+ if (b < 0 || b > 63)
574
+ throw new Error("Invalid polyline");
575
+ result |= (b & 31) << shift;
576
+ shift += 5;
577
+ } while (b >= 32);
578
+ return result & 1 ? ~(result >>> 1) : result >>> 1;
579
+ };
580
+ const points = [];
581
+ const scale = 10 ** precision;
582
+ while (index < value.length) {
583
+ latitude += next();
584
+ longitude += next();
585
+ points.push({ latitude: latitude / scale, longitude: longitude / scale });
586
+ }
587
+ return points;
588
+ }
@@ -0,0 +1,8 @@
1
+ import { type TurboModule, type CodegenTypes } from "react-native";
2
+ export interface Spec extends TurboModule {
3
+ execute(requestId: string, target: string, method: string, argumentsJson: string): Promise<string>;
4
+ cancel(requestId: string): void;
5
+ readonly onEvent: CodegenTypes.EventEmitter<string>;
6
+ }
7
+ declare const _default: Spec;
8
+ export default _default;
@@ -0,0 +1,4 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ const react_native_1 = require("react-native");
4
+ exports.default = react_native_1.TurboModuleRegistry.getEnforcing("RanaMaps");
@@ -0,0 +1,13 @@
1
+ import type { ViewProps, CodegenTypes } from "react-native";
2
+ export interface NativeProps extends ViewProps {
3
+ optionsJSON: string;
4
+ onMapError?: CodegenTypes.DirectEventHandler<Readonly<{
5
+ errorJSON: string;
6
+ }>>;
7
+ onMapCreated?: CodegenTypes.DirectEventHandler<Readonly<{
8
+ mapId: string;
9
+ ready: boolean;
10
+ }>>;
11
+ }
12
+ declare const _default: import("react-native").HostComponent<NativeProps>;
13
+ export default _default;
@@ -0,0 +1,4 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ const react_native_1 = require("react-native");
4
+ exports.default = (0, react_native_1.codegenNativeComponent)("RanaMapView");
@@ -0,0 +1,9 @@
1
+ import type { ViewProps } from "react-native";
2
+ export interface NativeProps extends ViewProps {
3
+ mapId: string;
4
+ positionJSON: string;
5
+ optionsJSON: string;
6
+ visible: boolean;
7
+ }
8
+ declare const _default: import("react-native").HostComponent<NativeProps>;
9
+ export default _default;
@@ -0,0 +1,4 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ const react_native_1 = require("react-native");
4
+ exports.default = (0, react_native_1.codegenNativeComponent)("RanaMarkerView");