@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.d.ts ADDED
@@ -0,0 +1,309 @@
1
+ import { RanaRuntime, type RanaEvent } from "./bridge";
2
+ import type * as M from "./models";
3
+ export type * from "./models";
4
+ export { RanaError } from "./bridge";
5
+ export interface HttpRequest {
6
+ url: string;
7
+ method: string;
8
+ headers: Readonly<Record<string, string>>;
9
+ body: string | null;
10
+ }
11
+ export interface HttpAnswer {
12
+ status: number;
13
+ headers: Readonly<Record<string, string>>;
14
+ body: string;
15
+ }
16
+ export type HttpTransport = (request: HttpRequest, signal: AbortSignal) => Promise<HttpAnswer>;
17
+ export type ReroutingProvider = (request: M.ReroutingRequest, signal: AbortSignal) => Promise<M.ReroutingResult>;
18
+ export type JourneyTraceUploader = (batch: M.JourneyTraceBatch, signal: AbortSignal) => Promise<M.JourneyTraceReceipt>;
19
+ export interface LocationProvider {
20
+ start(onLocation: (fix: M.LocationFix) => void, onError: (error: M.ErrorInfo) => void): void;
21
+ stop(): void;
22
+ startHeading?(onHeading: (fix: M.HeadingFix) => void): void;
23
+ stopHeading?(): void;
24
+ }
25
+ export type StyleExpression = {
26
+ kind: "number";
27
+ value: number;
28
+ } | {
29
+ kind: "text" | "color";
30
+ value: string;
31
+ } | {
32
+ kind: "get";
33
+ property: string;
34
+ } | {
35
+ kind: "match";
36
+ property: string;
37
+ cases: Readonly<Record<string, StyleExpression>>;
38
+ fallback: StyleExpression;
39
+ } | {
40
+ kind: "zoom";
41
+ stops: ReadonlyArray<{
42
+ zoom: number;
43
+ value: number;
44
+ }>;
45
+ };
46
+ export interface FeatureFilter {
47
+ property: string;
48
+ equals: string;
49
+ }
50
+ export interface DataLayerOptions {
51
+ kind: M.DataLayerKind;
52
+ color?: StyleExpression;
53
+ opacity?: StyleExpression;
54
+ width?: StyleExpression;
55
+ radius?: StyleExpression;
56
+ text?: StyleExpression;
57
+ textSize?: StyleExpression;
58
+ filter?: FeatureFilter;
59
+ visible?: boolean;
60
+ belowLayerId?: string;
61
+ }
62
+ export declare class RanaResource {
63
+ readonly runtime: RanaRuntime;
64
+ readonly handle: string;
65
+ readonly cleanup: Array<() => void>;
66
+ constructor(runtime: RanaRuntime, handle: string);
67
+ onEvent(listener: (event: RanaEvent) => void): () => void;
68
+ protected call<T>(method: string, args?: unknown, signal?: AbortSignal): Promise<T>;
69
+ dispose(): Promise<void>;
70
+ }
71
+ export declare class RanaOverlay extends RanaResource {
72
+ remove(): Promise<void>;
73
+ }
74
+ /**
75
+ * What a marker shows: one member per Rana Kit marker family, plus your own image. Kit families are drawn from
76
+ * Rana Kit in any colour (see MarkerStyle); "image" keeps your own artwork. For an interactive React element,
77
+ * render a <Marker> child of the map instead.
78
+ */
79
+ export type MarkerContent =
80
+ /** `label` (up to 3 characters: a stop letter, a number) replaces the glyph. */
81
+ /** `drop: true` is the kit's "pick a spot" pin: a white head ringed in the colour, lifted off the ground. */
82
+ {
83
+ kind: "pin";
84
+ glyph?: M.PinGlyph;
85
+ label?: string;
86
+ size?: M.MarkerSize;
87
+ drop?: boolean;
88
+ } | {
89
+ kind: "badge";
90
+ text: string;
91
+ icon?: M.PinGlyph;
92
+ }
93
+ /** `live: true` adds the kit's green presence dot. */
94
+ | {
95
+ kind: "avatar";
96
+ name: string;
97
+ live?: boolean;
98
+ } | {
99
+ kind: "dot";
100
+ }
101
+ /** A pin whose head is your photo (base64 PNG or JPEG), clipped to the kit's head shape. */
102
+ | {
103
+ kind: "photo";
104
+ imageBase64: string;
105
+ }
106
+ /** A route stop: the start ring, a lettered stop or the destination flag. Night unless the style gives a colour. */
107
+ | {
108
+ kind: "stop";
109
+ role: M.RouteStopRole;
110
+ label?: string;
111
+ }
112
+ /** Base64 PNG or JPEG bytes. */
113
+ | {
114
+ kind: "image";
115
+ imageBase64: string;
116
+ anchor?: M.MarkerAnchor;
117
+ size?: M.MarkerSize;
118
+ };
119
+ /** One callout button. */
120
+ export interface CalloutAction {
121
+ label: string;
122
+ onPress: () => void;
123
+ }
124
+ /**
125
+ * The Rana Kit callout: a name, one line of facts and up to two actions, opened above a marker when it is tapped.
126
+ * Its layout is fixed by the kit (260 wide, 48 dp buttons) and follows the map's day or night theme.
127
+ */
128
+ export interface Callout {
129
+ title: string;
130
+ detail?: string;
131
+ primary?: CalloutAction;
132
+ secondary?: CalloutAction;
133
+ }
134
+ /** Builders for each marker family, e.g. `addMarker(p, MarkerContent.badge("₦2,500"))`. */
135
+ export declare const MarkerContent: {
136
+ pin: (glyph?: M.PinGlyph, size?: M.MarkerSize) => MarkerContent;
137
+ labelledPin: (label: string, size?: M.MarkerSize) => MarkerContent;
138
+ badge: (text: string, icon?: M.PinGlyph) => MarkerContent;
139
+ /** The "pick a spot" pin shown while a user chooses a place. */
140
+ dropPin: (glyph?: M.PinGlyph) => MarkerContent;
141
+ avatar: (name: string, live?: boolean) => MarkerContent;
142
+ dot: () => MarkerContent;
143
+ photo: (imageBase64: string) => MarkerContent;
144
+ routeStart: () => MarkerContent;
145
+ routeStop: (label?: string) => MarkerContent;
146
+ routeDestination: () => MarkerContent;
147
+ image: (imageBase64: string, anchor?: M.MarkerAnchor, size?: M.MarkerSize) => MarkerContent;
148
+ };
149
+ export declare class RanaMarker extends RanaOverlay {
150
+ setPosition(point: M.LatLng): Promise<void>;
151
+ /** Replaces what the marker shows, keeping its position, style and taps (a live price keeps its marker). */
152
+ setContent(content: MarkerContent): Promise<void>;
153
+ /** Restyles the marker. Fields left out take their defaults. */
154
+ setStyle(style: M.MarkerStyle): Promise<void>;
155
+ setVisible(visible: boolean): Promise<void>;
156
+ /** Calls `listener` on each tap on the marker. Returns a function that stops listening. */
157
+ onTap(listener: () => void): () => void;
158
+ private callout?;
159
+ private calloutPresses?;
160
+ /** Gives the marker a callout that opens when the marker is tapped; null removes it. */
161
+ setCallout(callout: Callout | null): Promise<void>;
162
+ /** Opens the marker's callout now (one callout is open per map at a time). */
163
+ showCallout(): Promise<void>;
164
+ hideCallout(): Promise<void>;
165
+ }
166
+ export declare class RanaPolyline extends RanaOverlay {
167
+ setProgress(progress: number): Promise<void>;
168
+ /** Restyles the line in place (a tapped alternative becomes the chosen route). */
169
+ setOptions(options: M.PolylineOptions): Promise<void>;
170
+ private tappable?;
171
+ /** Calls `listener` with the point of each tap on the line, with a generous touch area. */
172
+ onTap(listener: (point: M.LatLng) => void): () => void;
173
+ }
174
+ /**
175
+ * What a vehicle looks like: a Rana Kit vehicle in any colour, or your own artwork (base64 PNG or JPEG). Images and
176
+ * frames should face north (up) at heading 0; they turn with the heading unless `rotates` is false.
177
+ */
178
+ export declare const VehicleAppearance: {
179
+ kit: (vehicle: M.VehicleKind, options?: {
180
+ color?: string;
181
+ base?: M.VehicleBase;
182
+ }) => M.VehicleAppearanceWire;
183
+ image: (imageBase64: string, options?: {
184
+ size?: number;
185
+ rotates?: boolean;
186
+ }) => M.VehicleAppearanceWire;
187
+ /** Frames played in a loop, one every `frameMs` (default 100). Holds the first frame when animations are off. */
188
+ animated: (framesBase64: string[], options?: {
189
+ frameMs?: number;
190
+ size?: number;
191
+ rotates?: boolean;
192
+ }) => M.VehicleAppearanceWire;
193
+ };
194
+ /** How the traveller (your own position) is drawn. The puck is the default. */
195
+ export declare const TravellerAppearance: {
196
+ /** The Rana Kit puck: an arrow that turns with the heading. Without a heading it shows as the dot. */
197
+ puck: () => M.TravellerAppearanceWire;
198
+ dot: () => M.TravellerAppearanceWire;
199
+ /** Any vehicle appearance: a kit vehicle, your image or animation. It keeps its last heading. */
200
+ vehicle: (vehicle: M.VehicleAppearanceWire) => M.TravellerAppearanceWire;
201
+ };
202
+ export declare class RanaVehicle extends RanaOverlay {
203
+ update(point: M.LatLng, heading?: number, durationMs?: number): Promise<void>;
204
+ setState(state: M.VehicleState): Promise<void>;
205
+ /** Swaps the look in place (a rider picks a new bike), keeping position, heading, state and taps. */
206
+ setAppearance(appearance: M.VehicleAppearanceWire): Promise<void>;
207
+ }
208
+ export declare class RanaGeoJsonSource extends RanaOverlay {
209
+ setData(geoJson: string): Promise<void>;
210
+ }
211
+ export declare class RanaStyleLayer extends RanaOverlay {
212
+ setOptions(options: DataLayerOptions): Promise<void>;
213
+ }
214
+ export declare class JourneyTraceRecorder extends RanaResource {
215
+ record(fix: M.LocationFix): Promise<void>;
216
+ flush(signal?: AbortSignal): Promise<void>;
217
+ stop(): Promise<void>;
218
+ status(): Promise<M.JourneyTraceStatus>;
219
+ }
220
+ export declare class RanaClient extends RanaResource {
221
+ static create(runtime: RanaRuntime, key?: string, transport?: HttpTransport): Promise<RanaClient>;
222
+ describeKey(signal?: AbortSignal): Promise<M.KeyInfo>;
223
+ directions(options: M.DirectionsOptions, signal?: AbortSignal): Promise<M.DirectionsResult>;
224
+ matrix(options: M.MatrixOptions, signal?: AbortSignal): Promise<M.MatrixResult>;
225
+ snapToRoads(options: M.SnapOptions, signal?: AbortSignal): Promise<M.SnapResult>;
226
+ reverseGeocode(point: M.LatLng, signal?: AbortSignal): Promise<M.Address>;
227
+ geocode(options: M.SearchOptions, signal?: AbortSignal): Promise<M.GeocodeResult[]>;
228
+ readonly places: {
229
+ autocomplete: (options: M.SearchOptions, signal?: AbortSignal) => Promise<M.PlaceSuggestion[]>;
230
+ details: (placeId: string, signal?: AbortSignal) => Promise<M.PlaceDetails>;
231
+ nearby: (options: M.NearbyOptions, signal?: AbortSignal) => Promise<M.NearbyPlace[]>;
232
+ };
233
+ uploadJourneyTrace(batch: M.JourneyTraceBatch, signal?: AbortSignal): Promise<M.JourneyTraceReceipt>;
234
+ createTraceRecorder(options: M.JourneyTraceOptions, uploader?: JourneyTraceUploader): Promise<JourneyTraceRecorder>;
235
+ }
236
+ export declare class RanaOfflineRegion extends RanaResource {
237
+ readonly info: M.OfflineRegionInfo;
238
+ constructor(runtime: RanaRuntime, handle: string, info: M.OfflineRegionInfo);
239
+ progress(): Promise<M.OfflineProgress | null>;
240
+ resume(): Promise<void>;
241
+ pause(): Promise<void>;
242
+ refresh(signal?: AbortSignal): Promise<void>;
243
+ remove(signal?: AbortSignal): Promise<void>;
244
+ }
245
+ export declare class RanaOfflineManager extends RanaResource {
246
+ static create(runtime: RanaRuntime, key?: string): Promise<RanaOfflineManager>;
247
+ regions(): Promise<RanaOfflineRegion[]>;
248
+ createRegion(options: M.OfflineRegionOptions): Promise<RanaOfflineRegion>;
249
+ }
250
+ export declare class RanaMapController extends RanaResource {
251
+ private providerCleanup?;
252
+ private reroutingCleanup?;
253
+ onMarkerDrag(listener: (event: M.MarkerDragEvent) => void): () => void;
254
+ onCameraMove(listener: (state: M.CameraState) => void): () => void;
255
+ onCameraIdle(listener: (state: M.CameraState) => void): () => void;
256
+ onReroutingChanged(listener: (state: M.ReroutingStatus) => void): () => void;
257
+ onRerouted(listener: (result: M.ReroutingResult) => void): () => void;
258
+ /** Each accepted measured location fix, from the connected provider or `updateLocation`. */
259
+ onLocation(listener: (fix: M.LocationFix) => void): () => void;
260
+ onLocationRouteChanged(listener: (status: M.LocationRouteStatus) => void): () => void;
261
+ setControls(controls: M.ControlsOptions): Promise<void>;
262
+ setAttribution(attribution: M.AttributionOptions): Promise<void>;
263
+ applySettings(settings: M.MapSettings): Promise<void>;
264
+ moveTo(center: M.LatLng, zoom?: number, animated?: boolean): Promise<boolean>;
265
+ update(options: M.MapOptions): Promise<void>;
266
+ cameraState(): Promise<M.CameraState>;
267
+ setCamera(camera: M.CameraOptions, animated?: boolean, durationMs?: number, signal?: AbortSignal): Promise<boolean>;
268
+ fitPoints(points: ReadonlyArray<M.LatLng>, padding?: number): Promise<void>;
269
+ setStyle(style: M.RanaStyle): Promise<void>;
270
+ setPadding(padding: M.MapPadding): Promise<void>;
271
+ setTracking(tracking: M.LocationTracking): Promise<void>;
272
+ setLocateState(state: M.LocateState): Promise<void>;
273
+ project(points: ReadonlyArray<M.LatLng>): Promise<M.ScreenPoint[]>;
274
+ unproject(points: ReadonlyArray<M.ScreenPoint>): Promise<M.LatLng[]>;
275
+ setProjectionPoints(points: Readonly<Record<string, M.LatLng>>): Promise<void>;
276
+ /** Adds a marker: any Rana Kit family (`MarkerContent.pin()`, `.badge()`, `.avatar()`, `.dot()`) or your own image. */
277
+ /** Adds many markers with one redraw and one call across the bridge, returning their handles in the same order. */
278
+ addMarkers(entries: ReadonlyArray<{
279
+ point: M.LatLng;
280
+ content?: MarkerContent;
281
+ style?: M.MarkerStyle;
282
+ }>): Promise<RanaMarker[]>;
283
+ addMarker(point: M.LatLng, content?: MarkerContent, style?: M.MarkerStyle): Promise<RanaMarker>;
284
+ addPoints(points: ReadonlyArray<M.LatLng>, options?: M.ClusterOptions): Promise<RanaOverlay>;
285
+ /** A vehicle that glides between updates: a Rana Kit vehicle (default a car) or your own image or animation. */
286
+ addVehicle(point: M.LatLng, appearance?: M.VehicleAppearanceWire, options?: M.VehicleOptions): Promise<RanaVehicle>;
287
+ addPolyline(points: ReadonlyArray<M.LatLng>, options?: M.PolylineOptions): Promise<RanaPolyline>;
288
+ showRoute(route: M.Route, options?: M.PolylineOptions): Promise<RanaPolyline>;
289
+ addPolygon(rings: ReadonlyArray<ReadonlyArray<M.LatLng>>, options?: M.ShapeOptions): Promise<RanaOverlay>;
290
+ addCircle(center: M.LatLng, radiusMetres: number, options?: M.ShapeOptions): Promise<RanaOverlay>;
291
+ showUserLocation(point: M.LatLng, options?: M.UserLocationOptions): Promise<void>;
292
+ hideUserLocation(): Promise<void>;
293
+ updateLocation(fix: M.LocationFix): Promise<void>;
294
+ updateDeviceHeading(fix: M.HeadingFix): Promise<void>;
295
+ useNativeLocationProvider(options?: M.NativeLocationOptions): Promise<void>;
296
+ setLocationProvider(provider: "native" | LocationProvider | null): Promise<void>;
297
+ setLocationRoute(points: ReadonlyArray<M.LatLng> | null, options?: M.LocationRouteOptions): Promise<void>;
298
+ locationRouteStatus(): Promise<M.LocationRouteStatus>;
299
+ setAutomaticRerouting(options: M.ReroutingOptions | null, provider?: RanaClient | ReroutingProvider): Promise<void>;
300
+ setJourneyTraceRecorder(recorder: JourneyTraceRecorder | null): Promise<void>;
301
+ addGeoJsonSource(id: string, geoJson: string): Promise<RanaGeoJsonSource>;
302
+ addLayer(id: string, sourceId: string, options: DataLayerOptions): Promise<RanaStyleLayer>;
303
+ layerIds(): Promise<string[]>;
304
+ setLayerVisibility(id: string, visible: boolean): Promise<void>;
305
+ setLayerColor(id: string, color: string): Promise<void>;
306
+ queryFeatures(point: M.LatLng, layerIds?: ReadonlyArray<string>): Promise<string[]>;
307
+ dispose(): Promise<void>;
308
+ }
309
+ export declare function decodePolyline(value: string, precision?: number): M.LatLng[];