@ranamaps/maps-js 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/LICENSE.md +13 -0
- package/NOTICES.md +230 -0
- package/README.md +119 -2
- package/dist/VERSION +1 -0
- package/dist/client.d.ts +69 -0
- package/dist/errors.d.ts +21 -0
- package/dist/index.d.ts +79 -0
- package/dist/index.js +818 -0
- package/dist/index.js.map +7 -0
- package/dist/journey-trace.d.ts +62 -0
- package/dist/kit-render.d.ts +61 -0
- package/dist/kit.d.ts +609 -0
- package/dist/location-motion.d.ts +35 -0
- package/dist/location-route.d.ts +30 -0
- package/dist/location.d.ts +38 -0
- package/dist/map.d.ts +356 -0
- package/dist/polyline.d.ts +3 -0
- package/dist/rana-maps-worker.js +10 -0
- package/dist/rerouting.d.ts +88 -0
- package/dist/search.d.ts +21 -0
- package/dist/settings.d.ts +139 -0
- package/dist/style.css +112 -0
- package/dist/telemetry.d.ts +26 -0
- package/dist/types.d.ts +234 -0
- package/dist/vehicle.d.ts +77 -0
- package/dist/version.d.ts +1 -0
- package/dist/worker.d.ts +15 -0
- package/package.json +40 -4
package/dist/types.d.ts
ADDED
|
@@ -0,0 +1,234 @@
|
|
|
1
|
+
export interface LatLng {
|
|
2
|
+
lat: number;
|
|
3
|
+
lng: number;
|
|
4
|
+
}
|
|
5
|
+
export type Mode = "car" | "okada" | "keke" | "bicycle" | "walk" | "transit";
|
|
6
|
+
export type Avoid = "tolls" | "highways" | "ferries";
|
|
7
|
+
export type Location = LatLng | {
|
|
8
|
+
place_id: string;
|
|
9
|
+
};
|
|
10
|
+
export interface GeoJsonLine {
|
|
11
|
+
type: "LineString";
|
|
12
|
+
coordinates: Array<[number, number]>;
|
|
13
|
+
}
|
|
14
|
+
/** polyline6 (default) or GeoJSON, as asked with `geometry`. */
|
|
15
|
+
export type Line = string | GeoJsonLine;
|
|
16
|
+
export interface DirectionsRequest {
|
|
17
|
+
origin: Location;
|
|
18
|
+
destination: Location;
|
|
19
|
+
waypoints?: LatLng[];
|
|
20
|
+
mode?: Mode;
|
|
21
|
+
alternatives?: boolean;
|
|
22
|
+
avoid?: Avoid[];
|
|
23
|
+
/** ISO time with offset. Used for gate opening hours; there is no live traffic. */
|
|
24
|
+
departure_time?: string;
|
|
25
|
+
geometry?: "polyline6" | "geojson";
|
|
26
|
+
}
|
|
27
|
+
export interface Step {
|
|
28
|
+
instruction: string;
|
|
29
|
+
maneuver: string | null;
|
|
30
|
+
distance_m: number;
|
|
31
|
+
duration_s: number;
|
|
32
|
+
street_names: string[];
|
|
33
|
+
location: LatLng;
|
|
34
|
+
geometry: Line;
|
|
35
|
+
}
|
|
36
|
+
export interface Leg {
|
|
37
|
+
distance_m: number;
|
|
38
|
+
duration_s: number;
|
|
39
|
+
start: LatLng;
|
|
40
|
+
end: LatLng;
|
|
41
|
+
steps: Step[];
|
|
42
|
+
}
|
|
43
|
+
export interface Route {
|
|
44
|
+
distance_m: number;
|
|
45
|
+
duration_s: number;
|
|
46
|
+
geometry: Line;
|
|
47
|
+
legs: Leg[];
|
|
48
|
+
}
|
|
49
|
+
export interface DirectionsResponse {
|
|
50
|
+
routes: Route[];
|
|
51
|
+
attribution: string;
|
|
52
|
+
}
|
|
53
|
+
export interface MatrixRequest {
|
|
54
|
+
origins: LatLng[];
|
|
55
|
+
destinations: LatLng[];
|
|
56
|
+
mode?: Mode;
|
|
57
|
+
avoid?: Avoid[];
|
|
58
|
+
}
|
|
59
|
+
export interface MatrixCell {
|
|
60
|
+
distance_m: number | null;
|
|
61
|
+
duration_s: number | null;
|
|
62
|
+
}
|
|
63
|
+
export interface MatrixResponse {
|
|
64
|
+
rows: Array<{
|
|
65
|
+
cells: MatrixCell[];
|
|
66
|
+
}>;
|
|
67
|
+
attribution: string;
|
|
68
|
+
}
|
|
69
|
+
export interface SnapRequest {
|
|
70
|
+
points: LatLng[];
|
|
71
|
+
mode?: Exclude<Mode, "transit">;
|
|
72
|
+
interpolate?: boolean;
|
|
73
|
+
geometry?: "polyline6" | "geojson";
|
|
74
|
+
}
|
|
75
|
+
export interface SnapResponse {
|
|
76
|
+
points: Array<LatLng & {
|
|
77
|
+
original_index: number | null;
|
|
78
|
+
}>;
|
|
79
|
+
distance_m: number;
|
|
80
|
+
geometry: Line;
|
|
81
|
+
attribution: string;
|
|
82
|
+
}
|
|
83
|
+
export interface Address {
|
|
84
|
+
street: string | null;
|
|
85
|
+
street_source: "rana" | "openstreetmap" | null;
|
|
86
|
+
area: string | null;
|
|
87
|
+
ward: string | null;
|
|
88
|
+
city: string | null;
|
|
89
|
+
lga: string | null;
|
|
90
|
+
state: string | null;
|
|
91
|
+
country: "NG" | null;
|
|
92
|
+
formatted: string | null;
|
|
93
|
+
attribution: string;
|
|
94
|
+
}
|
|
95
|
+
/** Where a search result came from (API 1.1.0-beta, decision 0025). */
|
|
96
|
+
export type ResultSource = "rana" | "osm";
|
|
97
|
+
/** The OpenStreetMap tag behind an OSM result: `class` is the tag key, `kind` its value, e.g. shop / supermarket. */
|
|
98
|
+
export interface OsmTag {
|
|
99
|
+
class: string;
|
|
100
|
+
kind: string;
|
|
101
|
+
}
|
|
102
|
+
/** An OpenStreetMap id that place details resolves: osm-poi-…, osm-stop-…, osm-street-… or osm-addr-… (address point). */
|
|
103
|
+
export type OsmPlaceId = `osm-poi-${string}` | `osm-stop-${string}` | `osm-street-${string}` | `osm-addr-${string}`;
|
|
104
|
+
/**
|
|
105
|
+
* Kinds of OpenStreetMap result. `address` is an OSM address point (osm-addr-…, 19 November 2026). The server may add
|
|
106
|
+
* kinds later: result `kind` fields stay `string`, and anything unrecognised should be treated as `place`
|
|
107
|
+
* (`resultKind()` does that).
|
|
108
|
+
*/
|
|
109
|
+
export type OsmResultKind = "place" | "street" | "stop" | "address";
|
|
110
|
+
/** One credit in a response's `attributions` list (19 November 2026). */
|
|
111
|
+
export interface AttributionEntry {
|
|
112
|
+
source: string;
|
|
113
|
+
text: string;
|
|
114
|
+
licence: string;
|
|
115
|
+
url: string | null;
|
|
116
|
+
}
|
|
117
|
+
/** Optional attribution fields every places/geocode answer may carry (19 November 2026). `attribution` stays a string. */
|
|
118
|
+
export interface AttributionFields {
|
|
119
|
+
/** The credits as a list, Rana first. Older servers leave it out. */
|
|
120
|
+
attributions?: AttributionEntry[];
|
|
121
|
+
/** The page that lists every credit in full. */
|
|
122
|
+
attributions_url?: string;
|
|
123
|
+
}
|
|
124
|
+
/**
|
|
125
|
+
* Fields every search result gains in API 1.1.0-beta. All optional in this type so answers from older servers
|
|
126
|
+
* still fit: use `resultSource()` to read the source with the old-server fallback.
|
|
127
|
+
*/
|
|
128
|
+
export interface SearchResultSource {
|
|
129
|
+
/** `rana` or `osm`. Older servers leave it out. */
|
|
130
|
+
source?: ResultSource;
|
|
131
|
+
/** Only on OSM results other than areas. */
|
|
132
|
+
osm?: OsmTag;
|
|
133
|
+
/** The other source's name(s) for the same feature. */
|
|
134
|
+
alsoKnownAs?: string[];
|
|
135
|
+
/** Every source whose data is shown in this result, e.g. `["rana", "osm"]`. Older servers leave it out. */
|
|
136
|
+
sources?: string[];
|
|
137
|
+
}
|
|
138
|
+
export interface GeocodeResult extends SearchResultSource {
|
|
139
|
+
label: string;
|
|
140
|
+
point: LatLng;
|
|
141
|
+
kind: string;
|
|
142
|
+
place_id: string;
|
|
143
|
+
}
|
|
144
|
+
export interface GeocodeResponse extends AttributionFields {
|
|
145
|
+
results: GeocodeResult[];
|
|
146
|
+
attribution: string;
|
|
147
|
+
}
|
|
148
|
+
export interface PlaceSuggestion extends SearchResultSource {
|
|
149
|
+
place_id: string;
|
|
150
|
+
name: string;
|
|
151
|
+
secondary: string;
|
|
152
|
+
kind: string;
|
|
153
|
+
point: LatLng;
|
|
154
|
+
}
|
|
155
|
+
export interface AutocompleteResponse extends AttributionFields {
|
|
156
|
+
suggestions: PlaceSuggestion[];
|
|
157
|
+
attribution: string;
|
|
158
|
+
}
|
|
159
|
+
export interface Gate {
|
|
160
|
+
name: string;
|
|
161
|
+
role: string;
|
|
162
|
+
point: LatLng;
|
|
163
|
+
status: "open" | "closed" | "unknown";
|
|
164
|
+
hours: string | null;
|
|
165
|
+
}
|
|
166
|
+
export interface PlaceDetails {
|
|
167
|
+
place_id: string;
|
|
168
|
+
/** Added in API 1.1.0-beta; older servers leave it out. */
|
|
169
|
+
source?: "rana";
|
|
170
|
+
name: string;
|
|
171
|
+
aliases: string[];
|
|
172
|
+
kind: string;
|
|
173
|
+
point: LatLng;
|
|
174
|
+
street: string | null;
|
|
175
|
+
house_number: string | null;
|
|
176
|
+
how_to_find: string | null;
|
|
177
|
+
gates: Gate[];
|
|
178
|
+
photos: Array<{
|
|
179
|
+
id: string;
|
|
180
|
+
url: string;
|
|
181
|
+
}>;
|
|
182
|
+
updated_at: string | null;
|
|
183
|
+
attribution: string;
|
|
184
|
+
}
|
|
185
|
+
/** An OpenStreetMap POI, stop, street or address point from place details (API 1.1.0-beta). It has no gates, photos or aliases. */
|
|
186
|
+
export interface OsmPlaceDetails extends AttributionFields {
|
|
187
|
+
id: string;
|
|
188
|
+
source: "osm";
|
|
189
|
+
type: OsmResultKind;
|
|
190
|
+
name: string;
|
|
191
|
+
lat: number;
|
|
192
|
+
lng: number;
|
|
193
|
+
osm: OsmTag;
|
|
194
|
+
address?: {
|
|
195
|
+
street?: string;
|
|
196
|
+
housenumber?: string;
|
|
197
|
+
city?: string;
|
|
198
|
+
};
|
|
199
|
+
/** The OSM opening_hours value, unparsed. */
|
|
200
|
+
openingHours?: string;
|
|
201
|
+
attribution: string;
|
|
202
|
+
}
|
|
203
|
+
export interface NearbyRequest {
|
|
204
|
+
lat: number;
|
|
205
|
+
lng: number;
|
|
206
|
+
radius_m?: number;
|
|
207
|
+
kind?: string;
|
|
208
|
+
keyword?: string;
|
|
209
|
+
limit?: number;
|
|
210
|
+
}
|
|
211
|
+
export interface NearbyPlace extends SearchResultSource {
|
|
212
|
+
place_id: string;
|
|
213
|
+
name: string;
|
|
214
|
+
kind: string;
|
|
215
|
+
point: LatLng;
|
|
216
|
+
distance_m: number;
|
|
217
|
+
}
|
|
218
|
+
export interface NearbyResponse extends AttributionFields {
|
|
219
|
+
results: NearbyPlace[];
|
|
220
|
+
attribution: string;
|
|
221
|
+
}
|
|
222
|
+
export interface KeyInfo {
|
|
223
|
+
organisation_id: string;
|
|
224
|
+
key: {
|
|
225
|
+
id: string;
|
|
226
|
+
kind: "public" | "secret";
|
|
227
|
+
};
|
|
228
|
+
plan: "trial" | "payg" | "starter" | "business" | "custom";
|
|
229
|
+
limits: {
|
|
230
|
+
per_minute: Record<string, number>;
|
|
231
|
+
per_day: Record<string, number>;
|
|
232
|
+
};
|
|
233
|
+
attribution: string;
|
|
234
|
+
}
|
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
export type VehicleKind = "car" | "okada" | "delivery" | "keke" | "danfo" | "bicycle" | "walker";
|
|
2
|
+
export type VehicleState = "moving" | "selected" | "offline";
|
|
3
|
+
/**
|
|
4
|
+
* What a vehicle looks like: one of the Rana Kit vehicles in any colour, or your own artwork. Images and animation
|
|
5
|
+
* frames should face north (up) at heading 0; they turn with the heading unless `rotates` is false.
|
|
6
|
+
*/
|
|
7
|
+
export type VehicleAppearance = {
|
|
8
|
+
kind: "kit";
|
|
9
|
+
vehicle: VehicleKind;
|
|
10
|
+
color?: string;
|
|
11
|
+
base?: "none" | "disc";
|
|
12
|
+
} | {
|
|
13
|
+
kind: "image";
|
|
14
|
+
image: HTMLImageElement;
|
|
15
|
+
size?: number;
|
|
16
|
+
rotates?: boolean;
|
|
17
|
+
}
|
|
18
|
+
/** Frames played in a loop every `frameMs` (default 100). Shows the first frame when the user asks for reduced motion. */
|
|
19
|
+
| {
|
|
20
|
+
kind: "animated";
|
|
21
|
+
frames: HTMLImageElement[];
|
|
22
|
+
frameMs?: number;
|
|
23
|
+
size?: number;
|
|
24
|
+
rotates?: boolean;
|
|
25
|
+
}
|
|
26
|
+
/** Your own element. It handles its own events and does not turn with the heading unless `rotates` is true. */
|
|
27
|
+
| {
|
|
28
|
+
kind: "view";
|
|
29
|
+
element: HTMLElement;
|
|
30
|
+
rotates?: boolean;
|
|
31
|
+
};
|
|
32
|
+
export declare const VehicleAppearance: {
|
|
33
|
+
kit: (vehicle: VehicleKind, options?: {
|
|
34
|
+
color?: string;
|
|
35
|
+
base?: "none" | "disc";
|
|
36
|
+
}) => VehicleAppearance;
|
|
37
|
+
image: (image: HTMLImageElement, options?: {
|
|
38
|
+
size?: number;
|
|
39
|
+
rotates?: boolean;
|
|
40
|
+
}) => VehicleAppearance;
|
|
41
|
+
animated: (frames: HTMLImageElement[], options?: {
|
|
42
|
+
frameMs?: number;
|
|
43
|
+
size?: number;
|
|
44
|
+
rotates?: boolean;
|
|
45
|
+
}) => VehicleAppearance;
|
|
46
|
+
view: (element: HTMLElement, options?: {
|
|
47
|
+
rotates?: boolean;
|
|
48
|
+
}) => VehicleAppearance;
|
|
49
|
+
};
|
|
50
|
+
/** How the traveller (your own position) is drawn. The puck is the default. */
|
|
51
|
+
export type TravellerAppearance = {
|
|
52
|
+
kind: "puck";
|
|
53
|
+
} | {
|
|
54
|
+
kind: "dot";
|
|
55
|
+
} | {
|
|
56
|
+
kind: "vehicle";
|
|
57
|
+
vehicle: VehicleAppearance;
|
|
58
|
+
};
|
|
59
|
+
export declare const TravellerAppearance: {
|
|
60
|
+
/** The Rana Kit puck: an arrow that turns with the heading. Without a heading it shows as the dot. */
|
|
61
|
+
puck: () => TravellerAppearance;
|
|
62
|
+
dot: () => TravellerAppearance;
|
|
63
|
+
/** Any vehicle appearance: a kit vehicle, your image, animation or element. */
|
|
64
|
+
vehicle: (vehicle: VehicleAppearance) => TravellerAppearance;
|
|
65
|
+
};
|
|
66
|
+
export declare function validateVehicleAppearance(appearance: VehicleAppearance): VehicleAppearance;
|
|
67
|
+
export declare function validateTravellerAppearance(appearance: TravellerAppearance): TravellerAppearance;
|
|
68
|
+
/** The drawn body of a vehicle inside `content`. Heading changes touch only a transform, never rebuild the drawing. */
|
|
69
|
+
export interface VehicleBody {
|
|
70
|
+
setHeading(heading: number): void;
|
|
71
|
+
dispose(): void;
|
|
72
|
+
}
|
|
73
|
+
/**
|
|
74
|
+
* Draws `appearance` into `content` in `state` at `size` px (default: the kit's 48). Kit vehicles turn inside their
|
|
75
|
+
* SVG so the shadow stays put; your own artwork turns as a whole.
|
|
76
|
+
*/
|
|
77
|
+
export declare function drawVehicle(content: HTMLElement, appearance: VehicleAppearance, state: VehicleState, heading: number, size?: number): VehicleBody;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const VERSION = "0.4.0-beta.0";
|
package/dist/worker.d.ts
ADDED
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
export declare class WorkerConfiguration {
|
|
2
|
+
private readonly source;
|
|
3
|
+
private url?;
|
|
4
|
+
private initialized;
|
|
5
|
+
constructor(source: () => string);
|
|
6
|
+
setUrl(url: string): void;
|
|
7
|
+
install(lib: {
|
|
8
|
+
setWorkerUrl(url: string): void;
|
|
9
|
+
}): void;
|
|
10
|
+
}
|
|
11
|
+
/** Optional process-wide override for CSPs without blob workers. Call before creating any maps. */
|
|
12
|
+
export declare function setWorkerUrl(url: string): void;
|
|
13
|
+
export declare function installWorker(lib: {
|
|
14
|
+
setWorkerUrl(url: string): void;
|
|
15
|
+
}): void;
|
package/package.json
CHANGED
|
@@ -1,6 +1,42 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ranamaps/maps-js",
|
|
3
|
-
"version": "0.0.0
|
|
4
|
-
"
|
|
5
|
-
"
|
|
6
|
-
|
|
3
|
+
"version": "0.4.0-beta.0",
|
|
4
|
+
"description": "Rana Maps for the web: the Rana map and its web services (Nigeria first). One package, nothing else to install.",
|
|
5
|
+
"license": "SEE LICENSE IN LICENSE.md",
|
|
6
|
+
"type": "module",
|
|
7
|
+
"main": "./dist/index.js",
|
|
8
|
+
"module": "./dist/index.js",
|
|
9
|
+
"types": "./dist/index.d.ts",
|
|
10
|
+
"exports": {
|
|
11
|
+
".": {
|
|
12
|
+
"types": "./dist/index.d.ts",
|
|
13
|
+
"import": "./dist/index.js"
|
|
14
|
+
},
|
|
15
|
+
"./style.css": "./dist/style.css",
|
|
16
|
+
"./worker.js": "./dist/rana-maps-worker.js"
|
|
17
|
+
},
|
|
18
|
+
"files": [
|
|
19
|
+
"dist",
|
|
20
|
+
"LICENSE.md",
|
|
21
|
+
"NOTICES.md",
|
|
22
|
+
"README.md"
|
|
23
|
+
],
|
|
24
|
+
"sideEffects": [
|
|
25
|
+
"*.css"
|
|
26
|
+
],
|
|
27
|
+
"scripts": {
|
|
28
|
+
"build": "node scripts/build.mjs",
|
|
29
|
+
"typecheck": "tsc --noEmit",
|
|
30
|
+
"test": "vitest run",
|
|
31
|
+
"test:consumer": "npm run build && node scripts/test-bundled-consumer.mjs"
|
|
32
|
+
},
|
|
33
|
+
"devDependencies": {
|
|
34
|
+
"esbuild": "0.28.2",
|
|
35
|
+
"typescript": "5.9.3",
|
|
36
|
+
"vite": "^8.3.5",
|
|
37
|
+
"vitest": "5.0.5"
|
|
38
|
+
},
|
|
39
|
+
"dependencies": {
|
|
40
|
+
"maplibre-gl": "6.16.0"
|
|
41
|
+
}
|
|
42
|
+
}
|