@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.
- package/BETA-STATUS.md +13 -0
- package/CHANGELOG.md +40 -0
- package/LICENSE.md +13 -0
- package/NOTICES.md +230 -0
- package/README.md +61 -2
- package/RanaMapsReactNative.podspec +17 -0
- package/android/build.gradle +25 -0
- package/android/src/main/AndroidManifest.xml +1 -0
- package/android/src/main/java/com/ranamaps/reactnative/RanaMapManager.kt +115 -0
- package/android/src/main/java/com/ranamaps/reactnative/RanaMapsModule.kt +41 -0
- package/android/src/main/java/com/ranamaps/reactnative/RanaMapsPackage.kt +11 -0
- package/app.plugin.js +127 -0
- package/ios/RanaMapViewComponentView.mm +116 -0
- package/ios/RanaMapsModule.mm +32 -0
- package/ios/RanaNativeRuntime.swift +42 -0
- package/lib/bridge.d.ts +40 -0
- package/lib/bridge.js +152 -0
- package/lib/index.d.ts +31 -0
- package/lib/index.js +113 -0
- package/lib/map-lifecycle.d.ts +5 -0
- package/lib/map-lifecycle.js +10 -0
- package/lib/models.d.ts +509 -0
- package/lib/models.js +2 -0
- package/lib/sdk.d.ts +309 -0
- package/lib/sdk.js +588 -0
- package/lib/specs/NativeRanaMaps.d.ts +8 -0
- package/lib/specs/NativeRanaMaps.js +4 -0
- package/lib/specs/RanaMapViewNativeComponent.d.ts +13 -0
- package/lib/specs/RanaMapViewNativeComponent.js +4 -0
- package/lib/specs/RanaMarkerViewNativeComponent.d.ts +9 -0
- package/lib/specs/RanaMarkerViewNativeComponent.js +4 -0
- package/package.json +59 -4
- package/react-native.config.js +12 -0
- package/src/bridge.ts +184 -0
- package/src/index.tsx +168 -0
- package/src/map-lifecycle.ts +11 -0
- package/src/models.ts +510 -0
- package/src/sdk.ts +732 -0
- package/src/specs/NativeRanaMaps.ts +16 -0
- package/src/specs/RanaMapViewNativeComponent.ts +10 -0
- package/src/specs/RanaMarkerViewNativeComponent.ts +9 -0
package/BETA-STATUS.md
ADDED
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
# Beta status — 17 November 2026
|
|
2
|
+
|
|
3
|
+
Version: 0.4.0-beta.0. Unpublished; public 0.2.0-beta.1 native binaries cannot run these adapters.
|
|
4
|
+
|
|
5
|
+
Verified: React Native 0.88.1 / React 19.3.0, Expo 58.0.25, six TypeScript contract tests, Android/iOS development consumer builds, and actual TurboModule/host-transport/identity/stale-handle checks on Android hardware and iOS simulator. Separate official bare React Native 0.88.1 Android/iOS template consumers and isolated npm-archive Expo consumers also build against staged native artifacts. Additional packed bare Android/iOS consumers compile with React Native 0.87.0 / React 19.2.3. Native suites: Android 73 passes; iOS 84 passes and two optional live-network skips.
|
|
6
|
+
|
|
7
|
+
Live maps/services, all live marker composition cases, complete network-denied offline rendering, rerouting, full runtime acceptance across both declared React Native minors/older OS versions, accessibility, real GPS/heading, battery and release performance need separately recorded acceptance. Source builds and fake transports are not those acceptance results.
|
|
8
|
+
|
|
9
|
+
The native SDK retains one map/offline credential per process. Host-owned permission prompts, explicit rerouting/trace opt-in, zero-learning simulated traces, foreground-only native location and shared backend/data limits are preserved. No registry publication, deployment or new background-service guarantee is included.
|
|
10
|
+
|
|
11
|
+
The Expo example has a sample-only patch for expo-dev-launcher 58.0.21: its optional toolbar references an iOS 27.1 API when compiled with Swift 6.4 against the installed iOS 27.0 SDK. The patch disables that optional treatment until a later compiler. The SDK package has no such patch or dependency.
|
|
12
|
+
|
|
13
|
+
Beta.2 corrects shared iOS request cancellation after a native client wraps the transport error. Three real Pigeon/iOS checks pass on Flutter 3.44.9 and 3.50.0, including full error metadata and late callback suppression. Existing Android hardware and React Native runtime smoke evidence was collected on beta.1; the new native API is unchanged and beta.2 consumer verification is recorded separately in the shared verification record.
|
package/CHANGELOG.md
ADDED
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
## 0.4.0-beta.0
|
|
2
|
+
|
|
3
|
+
- New: `addMarkers` adds a whole fleet in one bridge call with one redraw.
|
|
4
|
+
- New: service calls retry dropped connections, timeouts, 429, 502, 503 and 504 with jittered backoff (in the
|
|
5
|
+
native clients these calls use).
|
|
6
|
+
- New: markers, vehicles and tappable routes are reachable with VoiceOver and TalkBack. `VehicleOptions` and
|
|
7
|
+
`PolylineOptions` gain `accessibilityLabel`; every kit family has a sensible default.
|
|
8
|
+
- **Breaking: vehicles and the traveller.** `addVehicle(point, { kind, color, ... })` is
|
|
9
|
+
`addVehicle(point, VehicleAppearance.kit("okada", { color }), { heading })`; `VehicleAppearance` also takes your
|
|
10
|
+
own `image(base64)` or `animated(frames)`, and `RanaVehicle.setAppearance` swaps it. `location.mode` is
|
|
11
|
+
`location.appearance` (`TravellerAppearance.puck()`, `.dot()`, `.vehicle(...)`); the default moved from the dot to
|
|
12
|
+
the puck.
|
|
13
|
+
- New route-line options: `travelledColor`, traffic `segments` (`{ from, to, traffic: "slow" }`), `glow` and
|
|
14
|
+
`belowLayerId`; `RanaPolyline.setOptions` restyles a line and `RanaPolyline.onTap` reports taps (pick an
|
|
15
|
+
alternative route).
|
|
16
|
+
- New: Rana Kit callouts (`setCallout`, `showCallout`, `hideCallout`) and typed marker taps (`onTap(listener)`).
|
|
17
|
+
- New kit families: `MarkerContent.dropPin()` (the "pick a spot" pin), `avatar(name, true)` (live), `photo(base64)`,
|
|
18
|
+
`routeStart()`, `routeStop("B")` and `routeDestination()`. Route stops default to Night; a style without a colour
|
|
19
|
+
now takes each family's kit colour. Dragged markers lift as Rana Kit draws them.
|
|
20
|
+
- **Breaking: markers.** `addMarker(point, options)` is now
|
|
21
|
+
`addMarker(point, MarkerContent.badge("₦2,500"), { color })`. `MarkerContent` has one builder per Rana Kit family
|
|
22
|
+
(`pin`, `labelledPin`, `badge`, `avatar`, `dot`) plus `image`; `MarkerGlyph` is `PinGlyph`.
|
|
23
|
+
`RanaMarker.setColor`/`setState` are `setStyle({ ... })`; new `setContent` and `setVisible`.
|
|
24
|
+
|
|
25
|
+
- New `onLocation(listener)`: each accepted location fix.
|
|
26
|
+
- New `LocationOptions.firstFixZoom`.
|
|
27
|
+
- Native smooth-navigation fixes (no puck shake, continuous movement at ~5 s fixes, navigation follow camera, grey travelled route, puck above routes, padding no longer reset by settings updates). See the developer changelog for behaviour changes.
|
|
28
|
+
- Search results (`GeocodeResult`, `PlaceSuggestion`, `NearbyPlace`) gain optional `source`, `osm` (`OsmTag`), `alsoKnownAs` and `sources`. `kind` can now be `address` (OpenStreetMap address points, ids `osm-addr-…`); it stays a string, so any future kind decodes without error and should be treated as `place`.
|
|
29
|
+
- Not yet exposed here: the response-level `attributions` and `attributions_url`. The bridge returns bare result lists; use the native SDKs' `*Results` calls, or add a bridge operation, to read them.
|
|
30
|
+
|
|
31
|
+
## 0.3.0-beta.2
|
|
32
|
+
|
|
33
|
+
- Preserve native Android bridge model fields in minified consumer apps.
|
|
34
|
+
|
|
35
|
+
- Preserve cancellation errors for iOS custom transports through the shared native bridge.
|
|
36
|
+
- Add connected key-free structured-error and in-flight cancellation verification.
|
|
37
|
+
|
|
38
|
+
## 0.3.0-beta.1
|
|
39
|
+
|
|
40
|
+
Initial unpublished React Native beta: Fabric map/marker components, TurboModule services, typed resource handles, native offline/journey controls, host providers/transports, Expo config plugin and sample. Native source fixes are included in the prepared 0.3.0-beta.1 dependency; public 0.2.0-beta.1 artifacts are unchanged. See BETA-STATUS.md for acceptance status.
|
package/LICENSE.md
ADDED
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
# Rana Maps SDK licence (draft)
|
|
2
|
+
|
|
3
|
+
Copyright © 2026 EL-Joy Technologies. All rights reserved.
|
|
4
|
+
|
|
5
|
+
The Rana Maps SDKs (`@ranamaps/maps-js`, `com.ranamaps:maps-android`, `RanaMapsSDK`) are proprietary. You may use them,
|
|
6
|
+
free of charge, inside your own web pages and apps, only with a valid Rana key and under the Rana Maps API and SDK
|
|
7
|
+
terms (https://ranamaps.com/api-terms). You may ship them inside your app. You may not sell them on their own, remove
|
|
8
|
+
the attribution "© Rana Maps © OpenStreetMap", or use them to copy Rana's map data in bulk. Using them after your key is
|
|
9
|
+
revoked is not allowed.
|
|
10
|
+
|
|
11
|
+
They include open-source parts under their own licences; NOTICES.md lists them and their notices, which must be kept.
|
|
12
|
+
|
|
13
|
+
This licence is a draft until a Nigerian lawyer has reviewed it (lawyer checklist item H5).
|
package/NOTICES.md
ADDED
|
@@ -0,0 +1,230 @@
|
|
|
1
|
+
# Third-party notices
|
|
2
|
+
|
|
3
|
+
The Rana Maps SDKs include open-source software. Their licences require these notices to travel with the SDKs. They
|
|
4
|
+
are the only place the parts are named; the SDKs' own API never exposes them (decision 0017).
|
|
5
|
+
|
|
6
|
+
## MapLibre GL JS (in @ranamaps/maps-js)
|
|
7
|
+
|
|
8
|
+
Copyright (c) 2023, MapLibre contributors
|
|
9
|
+
|
|
10
|
+
All rights reserved.
|
|
11
|
+
|
|
12
|
+
Redistribution and use in source and binary forms, with or without modification,
|
|
13
|
+
are permitted provided that the following conditions are met:
|
|
14
|
+
|
|
15
|
+
* Redistributions of source code must retain the above copyright notice,
|
|
16
|
+
this list of conditions and the following disclaimer.
|
|
17
|
+
* Redistributions in binary form must reproduce the above copyright notice,
|
|
18
|
+
this list of conditions and the following disclaimer in the documentation
|
|
19
|
+
and/or other materials provided with the distribution.
|
|
20
|
+
* Neither the name of MapLibre GL JS nor the names of its contributors
|
|
21
|
+
may be used to endorse or promote products derived from this software
|
|
22
|
+
without specific prior written permission.
|
|
23
|
+
|
|
24
|
+
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
|
25
|
+
"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
|
26
|
+
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
|
27
|
+
A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
|
|
28
|
+
CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
|
29
|
+
EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
|
30
|
+
PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
|
|
31
|
+
PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
|
|
32
|
+
LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
|
|
33
|
+
NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
|
34
|
+
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
35
|
+
|
|
36
|
+
|
|
37
|
+
-------------------------------------------------------------------------------
|
|
38
|
+
|
|
39
|
+
Contains code from mapbox-gl-js v1.13 and earlier
|
|
40
|
+
|
|
41
|
+
Version v1.13 of mapbox-gl-js and earlier are licensed under a BSD-3-Clause license
|
|
42
|
+
|
|
43
|
+
Copyright (c) 2020, Mapbox
|
|
44
|
+
Redistribution and use in source and binary forms, with or without modification,
|
|
45
|
+
are permitted provided that the following conditions are met:
|
|
46
|
+
|
|
47
|
+
* Redistributions of source code must retain the above copyright notice,
|
|
48
|
+
this list of conditions and the following disclaimer.
|
|
49
|
+
* Redistributions in binary form must reproduce the above copyright notice,
|
|
50
|
+
this list of conditions and the following disclaimer in the documentation
|
|
51
|
+
and/or other materials provided with the distribution.
|
|
52
|
+
* Neither the name of Mapbox GL JS nor the names of its contributors
|
|
53
|
+
may be used to endorse or promote products derived from this software
|
|
54
|
+
without specific prior written permission.
|
|
55
|
+
|
|
56
|
+
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
|
57
|
+
"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
|
58
|
+
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
|
59
|
+
A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
|
|
60
|
+
CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
|
61
|
+
EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
|
62
|
+
PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
|
|
63
|
+
PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
|
|
64
|
+
LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
|
|
65
|
+
NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
|
|
66
|
+
EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
67
|
+
|
|
68
|
+
|
|
69
|
+
-------------------------------------------------------------------------------
|
|
70
|
+
|
|
71
|
+
Contains code from glfx.js
|
|
72
|
+
|
|
73
|
+
Copyright (C) 2011 by Evan Wallace
|
|
74
|
+
|
|
75
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
76
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
77
|
+
in the Software without restriction, including without limitation the rights
|
|
78
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
79
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
80
|
+
furnished to do so, subject to the following conditions:
|
|
81
|
+
|
|
82
|
+
The above copyright notice and this permission notice shall be included in
|
|
83
|
+
all copies or substantial portions of the Software.
|
|
84
|
+
|
|
85
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
86
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
87
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
88
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
89
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
90
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
|
91
|
+
THE SOFTWARE.
|
|
92
|
+
|
|
93
|
+
--------------------------------------------------------------------------------
|
|
94
|
+
|
|
95
|
+
Contains a portion of d3-color https://github.com/d3/d3-color
|
|
96
|
+
|
|
97
|
+
Copyright 2010-2016 Mike Bostock
|
|
98
|
+
All rights reserved.
|
|
99
|
+
|
|
100
|
+
Redistribution and use in source and binary forms, with or without modification,
|
|
101
|
+
are permitted provided that the following conditions are met:
|
|
102
|
+
|
|
103
|
+
* Redistributions of source code must retain the above copyright notice, this
|
|
104
|
+
list of conditions and the following disclaimer.
|
|
105
|
+
|
|
106
|
+
* Redistributions in binary form must reproduce the above copyright notice,
|
|
107
|
+
this list of conditions and the following disclaimer in the documentation
|
|
108
|
+
and/or other materials provided with the distribution.
|
|
109
|
+
|
|
110
|
+
* Neither the name of the author nor the names of contributors may be used to
|
|
111
|
+
endorse or promote products derived from this software without specific prior
|
|
112
|
+
written permission.
|
|
113
|
+
|
|
114
|
+
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
|
|
115
|
+
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
|
116
|
+
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
|
117
|
+
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
|
|
118
|
+
ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
|
119
|
+
(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
|
120
|
+
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
|
|
121
|
+
ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
|
122
|
+
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
|
123
|
+
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
124
|
+
|
|
125
|
+
## MapLibre Native (in com.ranamaps:maps-android and RanaMapsSDK)
|
|
126
|
+
|
|
127
|
+
BSD 2-Clause licence, held by the MapLibre contributors (and Mapbox for older parts). The full text, with its exact
|
|
128
|
+
copyright lines, ships inside the engine's own package (its LICENSE.md) and must be kept with any copy of it. Copy that
|
|
129
|
+
text here when the first release is built.
|
|
130
|
+
|
|
131
|
+
## Plus Jakarta Sans (in com.ranamaps:maps-android and RanaMapsSDK)
|
|
132
|
+
|
|
133
|
+
The Rana Kit typeface, drawn into marker labels, badges, avatars and clusters. Bundled unmodified as
|
|
134
|
+
`PlusJakartaSans-Variable.ttf`, with its licence beside it as `PlusJakartaSans-OFL.txt`.
|
|
135
|
+
|
|
136
|
+
```
|
|
137
|
+
Copyright 2020 The Plus Jakarta Sans Project Authors (https://github.com/tokotype/PlusJakartaSans)
|
|
138
|
+
|
|
139
|
+
This Font Software is licensed under the SIL Open Font License, Version 1.1.
|
|
140
|
+
This license is copied below, and is also available with a FAQ at:
|
|
141
|
+
http://scripts.sil.org/OFL
|
|
142
|
+
|
|
143
|
+
|
|
144
|
+
-----------------------------------------------------------
|
|
145
|
+
SIL OPEN FONT LICENSE Version 1.1 - 26 February 2007
|
|
146
|
+
-----------------------------------------------------------
|
|
147
|
+
|
|
148
|
+
PREAMBLE
|
|
149
|
+
The goals of the Open Font License (OFL) are to stimulate worldwide
|
|
150
|
+
development of collaborative font projects, to support the font creation
|
|
151
|
+
efforts of academic and linguistic communities, and to provide a free and
|
|
152
|
+
open framework in which fonts may be shared and improved in partnership
|
|
153
|
+
with others.
|
|
154
|
+
|
|
155
|
+
The OFL allows the licensed fonts to be used, studied, modified and
|
|
156
|
+
redistributed freely as long as they are not sold by themselves. The
|
|
157
|
+
fonts, including any derivative works, can be bundled, embedded,
|
|
158
|
+
redistributed and/or sold with any software provided that any reserved
|
|
159
|
+
names are not used by derivative works. The fonts and derivatives,
|
|
160
|
+
however, cannot be released under any other type of license. The
|
|
161
|
+
requirement for fonts to remain under this license does not apply
|
|
162
|
+
to any document created using the fonts or their derivatives.
|
|
163
|
+
|
|
164
|
+
DEFINITIONS
|
|
165
|
+
"Font Software" refers to the set of files released by the Copyright
|
|
166
|
+
Holder(s) under this license and clearly marked as such. This may
|
|
167
|
+
include source files, build scripts and documentation.
|
|
168
|
+
|
|
169
|
+
"Reserved Font Name" refers to any names specified as such after the
|
|
170
|
+
copyright statement(s).
|
|
171
|
+
|
|
172
|
+
"Original Version" refers to the collection of Font Software components as
|
|
173
|
+
distributed by the Copyright Holder(s).
|
|
174
|
+
|
|
175
|
+
"Modified Version" refers to any derivative made by adding to, deleting,
|
|
176
|
+
or substituting -- in part or in whole -- any of the components of the
|
|
177
|
+
Original Version, by changing formats or by porting the Font Software to a
|
|
178
|
+
new environment.
|
|
179
|
+
|
|
180
|
+
"Author" refers to any designer, engineer, programmer, technical
|
|
181
|
+
writer or other person who contributed to the Font Software.
|
|
182
|
+
|
|
183
|
+
PERMISSION & CONDITIONS
|
|
184
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
|
185
|
+
a copy of the Font Software, to use, study, copy, merge, embed, modify,
|
|
186
|
+
redistribute, and sell modified and unmodified copies of the Font
|
|
187
|
+
Software, subject to the following conditions:
|
|
188
|
+
|
|
189
|
+
1) Neither the Font Software nor any of its individual components,
|
|
190
|
+
in Original or Modified Versions, may be sold by itself.
|
|
191
|
+
|
|
192
|
+
2) Original or Modified Versions of the Font Software may be bundled,
|
|
193
|
+
redistributed and/or sold with any software, provided that each copy
|
|
194
|
+
contains the above copyright notice and this license. These can be
|
|
195
|
+
included either as stand-alone text files, human-readable headers or
|
|
196
|
+
in the appropriate machine-readable metadata fields within text or
|
|
197
|
+
binary files as long as those fields can be easily viewed by the user.
|
|
198
|
+
|
|
199
|
+
3) No Modified Version of the Font Software may use the Reserved Font
|
|
200
|
+
Name(s) unless explicit written permission is granted by the corresponding
|
|
201
|
+
Copyright Holder. This restriction only applies to the primary font name as
|
|
202
|
+
presented to the users.
|
|
203
|
+
|
|
204
|
+
4) The name(s) of the Copyright Holder(s) or the Author(s) of the Font
|
|
205
|
+
Software shall not be used to promote, endorse or advertise any
|
|
206
|
+
Modified Version, except to acknowledge the contribution(s) of the
|
|
207
|
+
Copyright Holder(s) and the Author(s) or with their explicit written
|
|
208
|
+
permission.
|
|
209
|
+
|
|
210
|
+
5) The Font Software, modified or unmodified, in part or in whole,
|
|
211
|
+
must be distributed entirely under this license, and must not be
|
|
212
|
+
distributed under any other license. The requirement for fonts to
|
|
213
|
+
remain under this license does not apply to any document created
|
|
214
|
+
using the Font Software.
|
|
215
|
+
|
|
216
|
+
TERMINATION
|
|
217
|
+
This license becomes null and void if any of the above conditions are
|
|
218
|
+
not met.
|
|
219
|
+
|
|
220
|
+
DISCLAIMER
|
|
221
|
+
THE FONT SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
|
222
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO ANY WARRANTIES OF
|
|
223
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT
|
|
224
|
+
OF COPYRIGHT, PATENT, TRADEMARK, OR OTHER RIGHT. IN NO EVENT SHALL THE
|
|
225
|
+
COPYRIGHT HOLDER BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
|
|
226
|
+
INCLUDING ANY GENERAL, SPECIAL, INDIRECT, INCIDENTAL, OR CONSEQUENTIAL
|
|
227
|
+
DAMAGES, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
|
228
|
+
FROM, OUT OF THE USE OR INABILITY TO USE THE FONT SOFTWARE OR FROM
|
|
229
|
+
OTHER DEALINGS IN THE FONT SOFTWARE.
|
|
230
|
+
```
|
package/README.md
CHANGED
|
@@ -1,3 +1,62 @@
|
|
|
1
|
-
#
|
|
1
|
+
# Rana Maps for React Native — 0.4.0-beta.0
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
Native maps and services for modern React Native on Android API 26+ and iOS 17+. Uses Fabric components and TurboModules, with TypeScript value types. Expo development builds are supported through `app.plugin.js`. Expo Go and legacy architecture are not supported.
|
|
4
|
+
|
|
5
|
+
This is an unpublished beta under local verification. Its new native dependencies are not yet hosted publicly. Existing public native 0.2.0-beta.1 artifacts cannot run this package. See [beta status](BETA-STATUS.md) for staging instructions and current evidence.
|
|
6
|
+
|
|
7
|
+
```tsx
|
|
8
|
+
import {MarkerContent, RanaMap, RanaViewMarker, createClient} from '@ranamaps/maps-react-native';
|
|
9
|
+
|
|
10
|
+
<RanaMap
|
|
11
|
+
options={{center: {latitude: 6.5244, longitude: 3.3792}, zoom: 12}}
|
|
12
|
+
onReady={async map => {
|
|
13
|
+
await map.addMarker({latitude: 6.52, longitude: 3.38}, MarkerContent.badge('₦2,500'));
|
|
14
|
+
}}>
|
|
15
|
+
<RanaViewMarker point={{latitude: 6.52, longitude: 3.38}}
|
|
16
|
+
style={{width: 140, height: 44}}>
|
|
17
|
+
<YourInteractiveMarker />
|
|
18
|
+
</RanaViewMarker>
|
|
19
|
+
</RanaMap>
|
|
20
|
+
|
|
21
|
+
const client = await createClient();
|
|
22
|
+
const result = await client.directions({
|
|
23
|
+
origin: {latitude: 6.52, longitude: 3.38},
|
|
24
|
+
destination: {placeId: 'your-place-id'}, mode: 'okada',
|
|
25
|
+
});
|
|
26
|
+
await client.dispose();
|
|
27
|
+
```
|
|
28
|
+
|
|
29
|
+
`RanaMap` accepts a controller ref, `onMapCreated`, `onReady`, `onEvent` and `onError`. Use controller methods after readiness. Unchanged serialized component options do not reconfigure the map on rerenders. Keep view-marker React keys stable and give markers a measurable layout. Marker children remain live native React views. View markers do not cluster, participate in renderer collision or use native dragging. Use image/kit markers or GeoJSON for large collections.
|
|
30
|
+
|
|
31
|
+
Controllers expose camera/constraints/gestures/controls/padding, styles, tracking/location/heading, route matching, optional rerouting, trace attachment, overlays, GeoJSON sources/layers/expressions and feature queries. Methods return Promises and typed resource handles. `onEvent` returns an unsubscribe function. Remove overlays and dispose clients/managers/recorders when their owner is finished.
|
|
32
|
+
|
|
33
|
+
`createClient` works without a mounted map. It provides key info, directions, matrix, snapping, geocoding, `places.autocomplete/details/nearby`, raw trace upload and trace recorder creation. Native code supplies the host app identity. `RanaError` preserves code, message, status, request ID and Retry-After seconds. Async operations accept `AbortSignal` where applicable. Custom HTTP transports, rerouting providers and trace uploaders receive cancellation signals. Custom location providers have independent location/heading subscriptions and stop on replacement/lifecycle changes.
|
|
34
|
+
|
|
35
|
+
Units: named WGS84 latitude/longitude, logical pixels, metres, degrees clockwise from true north, millisecond durations/timestamps. GeoJSON keeps longitude/latitude order.
|
|
36
|
+
|
|
37
|
+
Permissions are host-owned. Rerouting and traces are off by default. Set a location route before enabling rerouting with a client or custom provider. Rerouting uses ordinary directions usage; the host updates route-line/UI from accepted replacement events. Trace recording requires explicit consent and a measured/simulated source. Simulated batches create zero learning evidence. `stop()` revokes collection and discards unsent fixes; diagnostics do not grant consent.
|
|
38
|
+
|
|
39
|
+
`createOfflineManager` is independent of the map. Create/list/restore region handles, observe progress, pause/resume/refresh/remove. Failed deletion retains a usable handle for retry. Offline regions cache maps, not routing/search services or background scheduling.
|
|
40
|
+
|
|
41
|
+
## Expo
|
|
42
|
+
|
|
43
|
+
Add `[@ranamaps/maps-react-native, options]` to the `plugins` array in app config (use a normal JSON string for the package name):
|
|
44
|
+
|
|
45
|
+
```json
|
|
46
|
+
["@ranamaps/maps-react-native", {
|
|
47
|
+
"locationWhenInUsePermission": "Show your position on the map.",
|
|
48
|
+
"locationPermission": true
|
|
49
|
+
}]
|
|
50
|
+
```
|
|
51
|
+
|
|
52
|
+
The plugin sets platform floors, adds the native Maven repository and CocoaPods spec, and optionally declares foreground location permissions. It does not prompt for permission or enable background location. Build a development client after prebuild. Set `RANA_PUBLIC_KEY` to a public app-restricted key when running `expo prebuild`. The plugin writes it to Android application metadata and iOS Info.plist, and inserts initialization in a Swift Expo AppDelegate. Re-run prebuild after changing the key. The key is packaged in the native app and is not a secret. Existing native values are preserved if the environment variable is absent. The plugin supports the standard Swift Expo AppDelegate launch method; other host layouts must configure iOS manually. Set `configureAppDelegate: false` in plugin options when the host already configures the SDK or uses an unsupported AppDelegate; then configure it manually before creating a map or service.
|
|
53
|
+
|
|
54
|
+
## Bare native setup
|
|
55
|
+
|
|
56
|
+
Add `<meta-data android:name="com.ranamaps.API_KEY" android:value="pk_live_..." />` inside the Android application element. In the iOS Swift AppDelegate, import `RanaMapsSDK` and call `try RanaMaps.configure(apiKey: "pk_live_...")` during launch before creating a map or service. Handle configuration errors at startup. Use a public key restricted to the host app; native app bundles do not conceal it. `createClient()` and `createOfflineManager()` use the host key; both also accept an explicit key when needed.
|
|
57
|
+
|
|
58
|
+
Android's host repositories must include `maven { url 'https://assets.ranamaps.com/maven' }`. For local verification set `RANA_MAVEN_REPOSITORY` to the prepared Maven directory.
|
|
59
|
+
|
|
60
|
+
Add `pod 'RanaMapsSDK', :podspec => 'https://assets.ranamaps.com/sdk/ios/0.4.0-beta.0/RanaMapsSDK.podspec'` inside the iOS application target, then run pod install. Local consumers can use `:path` with the prepared `RanaMapsSDK` directory; the Expo example accepts `RANA_IOS_BINARY_DIR`. SDK resources/privacy manifests/notices are included in the native archive. Do not link duplicate native copies through another dependency manager.
|
|
61
|
+
|
|
62
|
+
Run `npm ci`, `npm run build`, and `npm test`. Contract tests use fake transports and do not establish device acceptance. Current framework/native build evidence is tracked in the linked inventory.
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
require 'json'
|
|
2
|
+
package = JSON.parse(File.read(File.join(__dir__, 'package.json')))
|
|
3
|
+
Pod::Spec.new do |s|
|
|
4
|
+
s.name = 'RanaMapsReactNative'
|
|
5
|
+
s.module_name = 'RanaMapsReactNative'
|
|
6
|
+
s.version = package['version']
|
|
7
|
+
s.summary = package['description']
|
|
8
|
+
s.homepage = 'https://developers.ranamaps.com'
|
|
9
|
+
s.license = { :file => 'LICENSE.md' }
|
|
10
|
+
s.author = { 'Rana Maps' => 'https://ranamaps.com' }
|
|
11
|
+
s.source = { :git => 'https://github.com/jeremiahseun/RanaMapsSDK.git', :tag => s.version.to_s }
|
|
12
|
+
s.platform = :ios, '17.0'
|
|
13
|
+
s.source_files = 'ios/**/*.{h,m,mm,swift}'
|
|
14
|
+
s.swift_version = '5.9'
|
|
15
|
+
s.dependency 'RanaMapsSDK', '= 0.4.0-beta.0'
|
|
16
|
+
install_modules_dependencies(s)
|
|
17
|
+
end
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
buildscript {
|
|
2
|
+
repositories { google(); mavenCentral() }
|
|
3
|
+
dependencies { classpath 'com.android.tools.build:gradle:8.13.2'; classpath 'org.jetbrains.kotlin:kotlin-gradle-plugin:2.3.21' }
|
|
4
|
+
}
|
|
5
|
+
apply plugin: 'com.android.library'
|
|
6
|
+
if (com.android.Version.ANDROID_GRADLE_PLUGIN_VERSION.tokenize('.')[0].toInteger() < 9 || project.findProperty('android.builtInKotlin') == 'false') { apply plugin: 'org.jetbrains.kotlin.android' }
|
|
7
|
+
apply plugin: 'com.facebook.react'
|
|
8
|
+
react { libraryName = 'RanaMapsSpec'; codegenJavaPackageName = 'com.ranamaps.reactnative' }
|
|
9
|
+
android {
|
|
10
|
+
namespace 'com.ranamaps.reactnative'
|
|
11
|
+
compileSdk 37
|
|
12
|
+
defaultConfig { minSdk 26 }
|
|
13
|
+
compileOptions { sourceCompatibility JavaVersion.VERSION_17; targetCompatibility JavaVersion.VERSION_17 }
|
|
14
|
+
|
|
15
|
+
}
|
|
16
|
+
kotlin { compilerOptions { jvmTarget = org.jetbrains.kotlin.gradle.dsl.JvmTarget.JVM_17 } }
|
|
17
|
+
repositories {
|
|
18
|
+
google(); mavenCentral()
|
|
19
|
+
maven { url System.getenv('RANA_MAVEN_REPOSITORY') ?: 'https://assets.ranamaps.com/maven' }
|
|
20
|
+
}
|
|
21
|
+
dependencies {
|
|
22
|
+
implementation 'com.facebook.react:react-android'
|
|
23
|
+
implementation 'com.ranamaps:maps-android:0.4.0-beta.0'
|
|
24
|
+
implementation 'org.jetbrains.kotlinx:kotlinx-coroutines-android:1.10.2'
|
|
25
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
<manifest xmlns:android="http://schemas.android.com/apk/res/android"><uses-permission android:name="android.permission.INTERNET" /></manifest>
|
|
@@ -0,0 +1,115 @@
|
|
|
1
|
+
package com.ranamaps.reactnative
|
|
2
|
+
import android.view.View
|
|
3
|
+
import android.widget.FrameLayout
|
|
4
|
+
import com.facebook.react.bridge.*
|
|
5
|
+
import com.facebook.react.uimanager.*
|
|
6
|
+
import com.facebook.react.uimanager.annotations.ReactProp
|
|
7
|
+
import com.facebook.react.uimanager.events.Event
|
|
8
|
+
import com.facebook.react.viewmanagers.*
|
|
9
|
+
import com.ranamaps.sdk.bridge.RanaBridge
|
|
10
|
+
import com.ranamaps.sdk.RanaError
|
|
11
|
+
import org.json.JSONObject
|
|
12
|
+
import kotlinx.coroutines.*
|
|
13
|
+
|
|
14
|
+
class RanaMapHost(val react: ThemedReactContext): FrameLayout(react) {
|
|
15
|
+
var options = "{}"; var previousOptions = ""
|
|
16
|
+
var host: RanaBridge.MapHost? = null
|
|
17
|
+
val managedChildren = mutableListOf<View>()
|
|
18
|
+
private val module get() = react.getNativeModule(RanaMapsModule::class.java)!!
|
|
19
|
+
// React Native lays out only the views it manages and ignores requestLayout from native children, so the map's
|
|
20
|
+
// own controls (credit, compass, locate) would keep their first positions when padding changes. Lay them out here.
|
|
21
|
+
private val measureAndLayout = Runnable {
|
|
22
|
+
measure(MeasureSpec.makeMeasureSpec(width, MeasureSpec.EXACTLY), MeasureSpec.makeMeasureSpec(height, MeasureSpec.EXACTLY))
|
|
23
|
+
layout(left, top, right, bottom)
|
|
24
|
+
}
|
|
25
|
+
override fun requestLayout() { super.requestLayout(); post(measureAndLayout) }
|
|
26
|
+
fun apply() {
|
|
27
|
+
try {
|
|
28
|
+
if (host == null) {
|
|
29
|
+
dispose(); val next = module.runtime.createMap(options); host = next; previousOptions = options
|
|
30
|
+
addView(next.view, 0, LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT)); module.hosts.add(this)
|
|
31
|
+
next.view.onStart(); next.view.onResume()
|
|
32
|
+
post { if (host?.id == next.id) UIManagerHelper.getEventDispatcherForReactTag(react, id)?.dispatchEvent(MapCreatedEvent(UIManagerHelper.getSurfaceId(react), id, next.id, next.view.controller != null)) }
|
|
33
|
+
} else if (previousOptions != options) {
|
|
34
|
+
val next = host!!; previousOptions = options
|
|
35
|
+
CoroutineScope(Dispatchers.Main.immediate).launch {
|
|
36
|
+
try {
|
|
37
|
+
module.runtime.execute(next.id, "updateProps", options)
|
|
38
|
+
} catch (error: Exception) {
|
|
39
|
+
if (host?.id == next.id) report(error, creationFailed = false)
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
} catch (error: Exception) {
|
|
44
|
+
dispose()
|
|
45
|
+
report(error, creationFailed = true)
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
private fun report(error: Exception, creationFailed: Boolean) {
|
|
49
|
+
val e = error as? RanaError ?: RanaError("invalid_argument", error.message ?: "Invalid map options", 0)
|
|
50
|
+
val json = JSONObject().put("code", e.code).put("message", e.message).put("status", e.status).put("requestId", e.requestId).put("retryAfter", e.retryAfterSeconds).put("creationFailed", creationFailed).toString()
|
|
51
|
+
UIManagerHelper.getEventDispatcherForReactTag(react, id)?.dispatchEvent(MapErrorEvent(UIManagerHelper.getSurfaceId(react), id, json))
|
|
52
|
+
}
|
|
53
|
+
fun dispose() { host?.let { module.runtime.disposeMap(it.id); removeView(it.view) }; host = null; module.hosts.remove(this) }
|
|
54
|
+
}
|
|
55
|
+
private class MapErrorEvent(surface: Int, tag: Int, val json: String): Event<MapErrorEvent>(surface, tag) {
|
|
56
|
+
override fun getEventName() = "topMapError"
|
|
57
|
+
override fun getEventData(): WritableMap = Arguments.createMap().apply { putString("errorJSON", json) }
|
|
58
|
+
}
|
|
59
|
+
private class MapCreatedEvent(surface: Int, tag: Int, val mapId: String, val ready: Boolean): Event<MapCreatedEvent>(surface, tag) {
|
|
60
|
+
override fun getEventName() = "topMapCreated"
|
|
61
|
+
override fun getEventData(): WritableMap = Arguments.createMap().apply { putString("mapId", mapId); putBoolean("ready", ready) }
|
|
62
|
+
}
|
|
63
|
+
class RanaMapManager: ViewGroupManager<RanaMapHost>(), RanaMapViewManagerInterface<RanaMapHost> {
|
|
64
|
+
private val delegate = RanaMapViewManagerDelegate(this)
|
|
65
|
+
override fun getDelegate() = delegate
|
|
66
|
+
override fun getName() = "RanaMapView"
|
|
67
|
+
override fun createViewInstance(context: ThemedReactContext) = RanaMapHost(context)
|
|
68
|
+
@ReactProp(name = "optionsJSON") override fun setOptionsJSON(view: RanaMapHost, value: String?) { view.options = value ?: "{}" }
|
|
69
|
+
override fun onAfterUpdateTransaction(view: RanaMapHost) { super.onAfterUpdateTransaction(view); view.apply() }
|
|
70
|
+
override fun addView(parent: RanaMapHost, child: View, index: Int) { parent.managedChildren.add(index, child); if (child !is RanaMarkerHost) parent.addView(child) }
|
|
71
|
+
override fun getChildCount(parent: RanaMapHost) = parent.managedChildren.size
|
|
72
|
+
override fun getChildAt(parent: RanaMapHost, index: Int) = parent.managedChildren[index]
|
|
73
|
+
override fun removeViewAt(parent: RanaMapHost, index: Int) { val child = parent.managedChildren.removeAt(index); if (child is RanaMarkerHost) child.dispose() else parent.removeView(child) }
|
|
74
|
+
override fun onDropViewInstance(view: RanaMapHost) { view.dispose(); super.onDropViewInstance(view) }
|
|
75
|
+
override fun getExportedCustomDirectEventTypeConstants(): MutableMap<String, Any> = mutableMapOf("topMapCreated" to mapOf("registrationName" to "onMapCreated"), "topMapError" to mapOf("registrationName" to "onMapError"))
|
|
76
|
+
}
|
|
77
|
+
class RanaMarkerHost(val react: ThemedReactContext): FrameLayout(react) {
|
|
78
|
+
var mapId = ""; var point = ""; var options = "{}"; var shown = true
|
|
79
|
+
var handle: String? = null; private var mountedOptions = ""; private var mountedMap = ""
|
|
80
|
+
private val module get() = react.getNativeModule(RanaMapsModule::class.java)!!
|
|
81
|
+
// React Native lays out only the views it manages and ignores requestLayout from native children, so the map's
|
|
82
|
+
// own controls (credit, compass, locate) would keep their first positions when padding changes. Lay them out here.
|
|
83
|
+
private val measureAndLayout = Runnable {
|
|
84
|
+
measure(MeasureSpec.makeMeasureSpec(width, MeasureSpec.EXACTLY), MeasureSpec.makeMeasureSpec(height, MeasureSpec.EXACTLY))
|
|
85
|
+
layout(left, top, right, bottom)
|
|
86
|
+
}
|
|
87
|
+
override fun requestLayout() { super.requestLayout(); post(measureAndLayout) }
|
|
88
|
+
fun apply() {
|
|
89
|
+
if (mapId.isEmpty() || point.isEmpty()) return
|
|
90
|
+
try {
|
|
91
|
+
if (handle == null || mountedOptions != options || mountedMap != mapId) {
|
|
92
|
+
dispose(); (parent as? android.view.ViewGroup)?.removeView(this)
|
|
93
|
+
handle = module.runtime.attachViewMarker(mapId, this, point, options); mountedOptions = options; mountedMap = mapId
|
|
94
|
+
}
|
|
95
|
+
val id = handle!!
|
|
96
|
+
CoroutineScope(Dispatchers.Main.immediate).launch {
|
|
97
|
+
module.runtime.execute(id, "setPosition", "{\"point\":$point}")
|
|
98
|
+
module.runtime.execute(id, "setVisible", "{\"visible\":$shown}")
|
|
99
|
+
}
|
|
100
|
+
} catch (error: Exception) { react.handleException(error) }
|
|
101
|
+
}
|
|
102
|
+
fun dispose() { val id = handle ?: return; handle = null; CoroutineScope(Dispatchers.Main.immediate).launch { runCatching { module.runtime.execute(id, "remove", "{}") } } }
|
|
103
|
+
}
|
|
104
|
+
class RanaMarkerManager: ViewGroupManager<RanaMarkerHost>(), RanaMarkerViewManagerInterface<RanaMarkerHost> {
|
|
105
|
+
private val delegate = RanaMarkerViewManagerDelegate(this)
|
|
106
|
+
override fun getDelegate() = delegate
|
|
107
|
+
override fun getName() = "RanaMarkerView"
|
|
108
|
+
override fun createViewInstance(context: ThemedReactContext) = RanaMarkerHost(context)
|
|
109
|
+
@ReactProp(name = "mapId") override fun setMapId(view: RanaMarkerHost, value: String?) { view.mapId = value ?: "" }
|
|
110
|
+
@ReactProp(name = "positionJSON") override fun setPositionJSON(view: RanaMarkerHost, value: String?) { view.point = value ?: "" }
|
|
111
|
+
@ReactProp(name = "optionsJSON") override fun setOptionsJSON(view: RanaMarkerHost, value: String?) { view.options = value ?: "{}" }
|
|
112
|
+
@ReactProp(name = "visible", defaultBoolean = true) override fun setVisible(view: RanaMarkerHost, value: Boolean) { view.shown = value }
|
|
113
|
+
override fun onAfterUpdateTransaction(view: RanaMarkerHost) { super.onAfterUpdateTransaction(view); view.apply() }
|
|
114
|
+
override fun onDropViewInstance(view: RanaMarkerHost) { view.dispose(); super.onDropViewInstance(view) }
|
|
115
|
+
}
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
package com.ranamaps.reactnative
|
|
2
|
+
|
|
3
|
+
import com.facebook.react.bridge.*
|
|
4
|
+
import com.facebook.react.module.annotations.ReactModule
|
|
5
|
+
import com.ranamaps.sdk.bridge.RanaBridge
|
|
6
|
+
import com.ranamaps.sdk.RanaError
|
|
7
|
+
import kotlinx.coroutines.*
|
|
8
|
+
import org.json.JSONObject
|
|
9
|
+
|
|
10
|
+
@ReactModule(name = RanaMapsModule.NAME)
|
|
11
|
+
class RanaMapsModule(context: ReactApplicationContext): NativeRanaMapsSpec(context), LifecycleEventListener {
|
|
12
|
+
companion object { const val NAME = "RanaMaps" }
|
|
13
|
+
val runtime = RanaBridge(context)
|
|
14
|
+
val hosts = mutableSetOf<RanaMapHost>()
|
|
15
|
+
private val scope = CoroutineScope(SupervisorJob() + Dispatchers.Main.immediate)
|
|
16
|
+
private val requests = mutableMapOf<String, Job>()
|
|
17
|
+
init { runtime.onEvent = { emitOnEvent(it) }; context.addLifecycleEventListener(this) }
|
|
18
|
+
override fun execute(requestId: String, target: String, method: String, argumentsJson: String, promise: Promise) {
|
|
19
|
+
scope.launch {
|
|
20
|
+
if (requests.containsKey(requestId)) { promise.reject("duplicate_request", "Request ID already active"); return@launch }
|
|
21
|
+
val job = launch(start = CoroutineStart.LAZY) {
|
|
22
|
+
try { promise.resolve(runtime.execute(target, method, argumentsJson)) }
|
|
23
|
+
catch (error: Throwable) {
|
|
24
|
+
val e = error as? RanaError ?: RanaError(if (error is CancellationException) "cancelled" else "native_error", error.message ?: "Native operation failed", 0)
|
|
25
|
+
val json = JSONObject().put("code", e.code).put("message", e.message).put("status", e.status).put("requestId", e.requestId).put("retryAfter", e.retryAfterSeconds).toString()
|
|
26
|
+
promise.reject(e.code, e.message, e, Arguments.createMap().apply { putString("rana", json) })
|
|
27
|
+
} finally { requests.remove(requestId) }
|
|
28
|
+
}
|
|
29
|
+
requests[requestId] = job; job.start()
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
override fun cancel(requestId: String) { scope.launch { requests[requestId]?.cancel() } }
|
|
33
|
+
override fun onHostResume() { hosts.forEach { it.host?.view?.onStart(); it.host?.view?.onResume() } }
|
|
34
|
+
override fun onHostPause() { hosts.forEach { it.host?.view?.onPause(); it.host?.view?.onStop() } }
|
|
35
|
+
override fun onHostDestroy() { hosts.toList().forEach { it.dispose() } }
|
|
36
|
+
override fun invalidate() {
|
|
37
|
+
reactApplicationContext.removeLifecycleEventListener(this)
|
|
38
|
+
scope.launch { runtime.onEvent = null; hosts.toList().forEach { it.dispose() }; runtime.dispose(); scope.cancel() }
|
|
39
|
+
super.invalidate()
|
|
40
|
+
}
|
|
41
|
+
}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
package com.ranamaps.reactnative
|
|
2
|
+
import com.facebook.react.BaseReactPackage
|
|
3
|
+
import com.facebook.react.bridge.ReactApplicationContext
|
|
4
|
+
import com.facebook.react.uimanager.ViewManager
|
|
5
|
+
import com.facebook.react.module.model.ReactModuleInfo
|
|
6
|
+
import com.facebook.react.module.model.ReactModuleInfoProvider
|
|
7
|
+
class RanaMapsPackage: BaseReactPackage() {
|
|
8
|
+
override fun getModule(name: String, context: ReactApplicationContext) = if (name == RanaMapsModule.NAME) RanaMapsModule(context) else null
|
|
9
|
+
override fun getReactModuleInfoProvider() = ReactModuleInfoProvider { mapOf(RanaMapsModule.NAME to ReactModuleInfo(RanaMapsModule.NAME, RanaMapsModule::class.java.name, false, false, false, true)) }
|
|
10
|
+
override fun createViewManagers(context: ReactApplicationContext): List<ViewManager<in Nothing, in Nothing>> = listOf(RanaMapManager(), RanaMarkerManager())
|
|
11
|
+
}
|