@cloudparse/up-miniapps-sdk 0.1.6 → 0.2.1
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/README.md +167 -2
- package/dist/chunk-S4UHRBSM.js +252 -0
- package/dist/chunk-S4UHRBSM.js.map +1 -0
- package/dist/host/index.d.cts +2 -0
- package/dist/host/index.d.ts +2 -0
- package/dist/host.cjs +279 -0
- package/dist/host.cjs.map +1 -0
- package/dist/host.js +11 -0
- package/dist/host.js.map +1 -0
- package/dist/index-B9dDciJq.d.cts +65 -0
- package/dist/index-B9dDciJq.d.ts +65 -0
- package/dist/index.browser.min.js +879 -1
- package/dist/index.browser.min.js.map +1 -1
- package/dist/index.cjs +3859 -0
- package/dist/index.cjs.map +1 -0
- package/dist/index.css +2 -0
- package/dist/index.css.map +1 -0
- package/dist/index.d.cts +1146 -0
- package/dist/index.d.ts +770 -152
- package/dist/index.js +3257 -57
- package/dist/index.js.map +1 -1
- package/dist/style.css +2291 -0
- package/package.json +55 -13
- package/dist/index.d.mts +0 -528
- package/dist/index.mjs +0 -348
- package/dist/index.mjs.map +0 -1
package/dist/index.d.cts
ADDED
|
@@ -0,0 +1,1146 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { R as RouteResponse, a as RouteStep, b as RouteRequest, c as RoutingBackendConfig } from './index-B9dDciJq.cjs';
|
|
3
|
+
export { C as ClearRouteRequest, D as DrawRouteRequest, h as handleClearRoute, d as handleDrawRoute, e as handleRouteRequest } from './index-B9dDciJq.cjs';
|
|
4
|
+
import { ViewState } from '@vis.gl/react-maplibre';
|
|
5
|
+
import * as react_dom_client from 'react-dom/client';
|
|
6
|
+
import 'maplibre-gl';
|
|
7
|
+
|
|
8
|
+
interface BridgeMockerProps {
|
|
9
|
+
/** Optional appId to return in INITIALIZE response */
|
|
10
|
+
appId?: string;
|
|
11
|
+
/** Initial simulated location [lng, lat] */
|
|
12
|
+
initialLocation?: [number, number];
|
|
13
|
+
/** Whether the simulated user should be moving */
|
|
14
|
+
isMoving?: boolean;
|
|
15
|
+
/** An array of coordinates to follow. If provided, overrides random movement. */
|
|
16
|
+
simulationPath?: [number, number][];
|
|
17
|
+
/** Speed multiplier for the simulation interval. Default is 1. Higher is faster. */
|
|
18
|
+
simulationSpeed?: number;
|
|
19
|
+
/** Mock JWT token for NETWORK_REQUEST mocking */
|
|
20
|
+
mockJWTToken?: string;
|
|
21
|
+
children: React.ReactNode;
|
|
22
|
+
}
|
|
23
|
+
/**
|
|
24
|
+
* A utility component for Storybook that intercepts SDK bridge calls,
|
|
25
|
+
* simulates the behavior of the native shell app.
|
|
26
|
+
*
|
|
27
|
+
* NOTE: Logs are now handled by the standalone DebugConsole component.
|
|
28
|
+
*/
|
|
29
|
+
declare const BridgeMocker: React.FC<BridgeMockerProps>;
|
|
30
|
+
|
|
31
|
+
interface DebugConsoleProps {
|
|
32
|
+
/**
|
|
33
|
+
* Whether to show the console initially.
|
|
34
|
+
* Can also be controlled via the 'debug' prop on SDKProvider.
|
|
35
|
+
*/
|
|
36
|
+
isOpen?: boolean;
|
|
37
|
+
/**
|
|
38
|
+
* Optional callback when the console is closed.
|
|
39
|
+
*/
|
|
40
|
+
onClose?: () => void;
|
|
41
|
+
}
|
|
42
|
+
/**
|
|
43
|
+
* A standalone debug console that intercepts and displays all Bridge communication.
|
|
44
|
+
* Useful for debugging both in mock mode (BridgeMocker) and on real devices.
|
|
45
|
+
*/
|
|
46
|
+
declare const DebugConsole: React.FC<DebugConsoleProps>;
|
|
47
|
+
|
|
48
|
+
/**
|
|
49
|
+
* UP Mini-App SDK Types
|
|
50
|
+
*/
|
|
51
|
+
/**
|
|
52
|
+
* Represents the user's profile information.
|
|
53
|
+
*/
|
|
54
|
+
interface IUserProfile {
|
|
55
|
+
/** Unique identifier for the user. */
|
|
56
|
+
uuid: string;
|
|
57
|
+
/** Full legal name of the user. */
|
|
58
|
+
fullName: string;
|
|
59
|
+
/** Primary email address. */
|
|
60
|
+
email: string;
|
|
61
|
+
/** Chosen username within the UP ecosystem. */
|
|
62
|
+
username: string;
|
|
63
|
+
/** ISO country code (e.g., "FR", "US"). */
|
|
64
|
+
countryCode: string;
|
|
65
|
+
/** Phone number without country code. */
|
|
66
|
+
localNumber: string;
|
|
67
|
+
}
|
|
68
|
+
/**
|
|
69
|
+
* Geographic location data.
|
|
70
|
+
*/
|
|
71
|
+
interface ILocationData {
|
|
72
|
+
coords: {
|
|
73
|
+
/** Latitude in decimal degrees. */
|
|
74
|
+
latitude: number;
|
|
75
|
+
/** Longitude in decimal degrees. */
|
|
76
|
+
longitude: number;
|
|
77
|
+
/** Altitude in meters above the WGS 84 reference ellipsoid, or null if not available. */
|
|
78
|
+
altitude: number | null;
|
|
79
|
+
/** Accuracy of the latitude and longitude properties in meters. */
|
|
80
|
+
accuracy: number | null;
|
|
81
|
+
/** Accuracy of the altitude property in meters. */
|
|
82
|
+
altitudeAccuracy: number | null;
|
|
83
|
+
/** The direction in which the device is traveling, in degrees (0-360). */
|
|
84
|
+
heading: number | null;
|
|
85
|
+
/** The velocity of the device in meters per second. */
|
|
86
|
+
speed: number | null;
|
|
87
|
+
};
|
|
88
|
+
/** The time at which the location was retrieved (Unix timestamp). */
|
|
89
|
+
timestamp: number;
|
|
90
|
+
}
|
|
91
|
+
/**
|
|
92
|
+
* Request payload for triggering a payment flow.
|
|
93
|
+
*/
|
|
94
|
+
interface IPaymentRequest {
|
|
95
|
+
/** The specific amount to charge. */
|
|
96
|
+
amount: number;
|
|
97
|
+
/** ISO currency code (e.g., "EUR", "USD"). */
|
|
98
|
+
currency: string;
|
|
99
|
+
/** Total amount including taxes/fees. */
|
|
100
|
+
total: number;
|
|
101
|
+
/** Itemized breakdown of the purchase. */
|
|
102
|
+
items: Array<{
|
|
103
|
+
/** Name or description of the item. */
|
|
104
|
+
item: string;
|
|
105
|
+
/** Price per unit. */
|
|
106
|
+
price?: number;
|
|
107
|
+
/** Number of units. */
|
|
108
|
+
quantity?: number;
|
|
109
|
+
}>;
|
|
110
|
+
}
|
|
111
|
+
/**
|
|
112
|
+
* Style of haptic feedback.
|
|
113
|
+
*/
|
|
114
|
+
type HapticStyleType = "light" | "medium" | "heavy" | "rigid" | "soft" | "success" | "warning" | "error";
|
|
115
|
+
/**
|
|
116
|
+
* Network Proxy Types
|
|
117
|
+
*/
|
|
118
|
+
/**
|
|
119
|
+
* The HTTP method to use as request method
|
|
120
|
+
*/
|
|
121
|
+
type NetworkMethodType = "GET" | "POST" | "PUT" | "DELETE" | "PATCH";
|
|
122
|
+
/**
|
|
123
|
+
* Configuration for network proxy requests.
|
|
124
|
+
*/
|
|
125
|
+
interface INetworkOptions {
|
|
126
|
+
/** Full URL for the request. */
|
|
127
|
+
url: string;
|
|
128
|
+
/** HTTP method to use. */
|
|
129
|
+
method: NetworkMethodType;
|
|
130
|
+
/** Request body for POST/PUT/PATCH. */
|
|
131
|
+
body?: unknown;
|
|
132
|
+
/** Custom HTTP headers. */
|
|
133
|
+
headers?: Record<string, string>;
|
|
134
|
+
}
|
|
135
|
+
/**
|
|
136
|
+
* Response from a network proxy request.
|
|
137
|
+
*/
|
|
138
|
+
interface INetworkResponse<T = unknown> {
|
|
139
|
+
/** HTTP status code. */
|
|
140
|
+
status: number;
|
|
141
|
+
/** Response data payload. */
|
|
142
|
+
data: T;
|
|
143
|
+
/** Response headers. */
|
|
144
|
+
headers: Headers;
|
|
145
|
+
}
|
|
146
|
+
/**
|
|
147
|
+
* Fidelity & Rewards Types
|
|
148
|
+
*/
|
|
149
|
+
/**
|
|
150
|
+
* Fidelity program balance information.
|
|
151
|
+
*/
|
|
152
|
+
interface IFidelityBalance {
|
|
153
|
+
/** Current point or currency balance. */
|
|
154
|
+
balance: number;
|
|
155
|
+
/** Name or symbol of the fidelity currency (e.g., "FPoints"). */
|
|
156
|
+
currency: string;
|
|
157
|
+
}
|
|
158
|
+
/**
|
|
159
|
+
* Parameters for retrieving fidelity transaction history.
|
|
160
|
+
*/
|
|
161
|
+
interface IFidelityHistoryParams {
|
|
162
|
+
/** Maximum number of records to return. */
|
|
163
|
+
limit?: number;
|
|
164
|
+
/** Cursor for pagination; null for the first page. */
|
|
165
|
+
cursor?: string | null;
|
|
166
|
+
}
|
|
167
|
+
/** Type of transaction: credit (add) or debit (remove). */
|
|
168
|
+
type FidelityTransactionTypeType = "credit" | "debit";
|
|
169
|
+
/**
|
|
170
|
+
* A single fidelity program transaction.
|
|
171
|
+
*/
|
|
172
|
+
interface IFidelityTransaction {
|
|
173
|
+
/** Unique identifier for the transaction. */
|
|
174
|
+
id: string;
|
|
175
|
+
/** Amount of the transaction. */
|
|
176
|
+
amount: number;
|
|
177
|
+
/** Human-readable description. */
|
|
178
|
+
description: string;
|
|
179
|
+
/** ISO 8601 date string. */
|
|
180
|
+
date: string;
|
|
181
|
+
/** Type of transaction */
|
|
182
|
+
type: FidelityTransactionTypeType;
|
|
183
|
+
}
|
|
184
|
+
/**
|
|
185
|
+
* The initialization options required to set up the Mini-App SDK.
|
|
186
|
+
*/
|
|
187
|
+
type IInitializationOptions = {};
|
|
188
|
+
/**
|
|
189
|
+
* The post initialization response
|
|
190
|
+
*/
|
|
191
|
+
interface IInitializationResponse<Env extends Record<string, unknown> = Record<string, unknown>, UserData extends Record<string, unknown> = Record<string, unknown>, Params extends Record<string, unknown> = Record<string, unknown>> {
|
|
192
|
+
/** The name of the mini app */
|
|
193
|
+
name: string;
|
|
194
|
+
/** The uuid of the mini app */
|
|
195
|
+
uuid: string;
|
|
196
|
+
/** The description of the mini app */
|
|
197
|
+
description: string;
|
|
198
|
+
/** The authors of the mini app */
|
|
199
|
+
authors?: string;
|
|
200
|
+
/** The current version in the registry */
|
|
201
|
+
version?: string;
|
|
202
|
+
/** The scoped profile based on the requested fields during initialization or the getUserProfile call */
|
|
203
|
+
profile: Partial<IUserProfile | null>;
|
|
204
|
+
/** The environment variables defined for the mini app in the shell's backend */
|
|
205
|
+
env: Env;
|
|
206
|
+
/** The user data passed during the initialization or the setUserData call */
|
|
207
|
+
userData: UserData;
|
|
208
|
+
/** The params passed during the initialization */
|
|
209
|
+
params: Params;
|
|
210
|
+
/** The edge insets of the mini app, representing the padding around the mini app's view within the Host Shell. */
|
|
211
|
+
insets: IEdgeInsets;
|
|
212
|
+
}
|
|
213
|
+
/**
|
|
214
|
+
* Events emitted by the UI module.
|
|
215
|
+
*/
|
|
216
|
+
declare enum UIEvent {
|
|
217
|
+
/** Triggered when the user performs a native "Pull-to-Refresh". */
|
|
218
|
+
TOP_SCROLL_MORE = "TOP_SCROLL_MORE",
|
|
219
|
+
/** Triggered when the user scrolls near the bottom of the page (within 200px threshold). */
|
|
220
|
+
BOTTOM_SCROLL_MORE = "BOTTOM_SCROLL_MORE",
|
|
221
|
+
/** Triggered when the user performs a native back gesture or presses the native back button. */
|
|
222
|
+
BACK_GESTURE = "BACK_GESTURE"
|
|
223
|
+
}
|
|
224
|
+
/**
|
|
225
|
+
* Events emitted by the Geolocation module.
|
|
226
|
+
*/
|
|
227
|
+
declare enum GeolocationEvent {
|
|
228
|
+
/** Triggered when the user's location is updated (legacy polling). */
|
|
229
|
+
LOCATION_UPDATE = "LOCATION_UPDATE",
|
|
230
|
+
/** Triggered by the continuous location stream. */
|
|
231
|
+
LOCATION_STREAM_UPDATE = "LOCATION_STREAM_UPDATE"
|
|
232
|
+
}
|
|
233
|
+
/**
|
|
234
|
+
* Configuration options for the location stream.
|
|
235
|
+
*/
|
|
236
|
+
interface LocationStreamConfig {
|
|
237
|
+
/** Polling cycle rate in milliseconds. Default: 250 */
|
|
238
|
+
interval?: number;
|
|
239
|
+
/** Distance change in meters to trigger an update. Default: 5 */
|
|
240
|
+
distanceFilter?: number;
|
|
241
|
+
/** Heading change in degrees to trigger an update. Default: 5 */
|
|
242
|
+
headingThreshold?: number;
|
|
243
|
+
/** Accelerometer delta in G-force to trigger an update. Default: 0.1 */
|
|
244
|
+
accelerometerThreshold?: number;
|
|
245
|
+
}
|
|
246
|
+
interface StreamLocationData {
|
|
247
|
+
coords: {
|
|
248
|
+
latitude: number;
|
|
249
|
+
longitude: number;
|
|
250
|
+
altitude: number | null;
|
|
251
|
+
accuracy: number | null;
|
|
252
|
+
altitudeAccuracy: number | null;
|
|
253
|
+
heading: number | null;
|
|
254
|
+
speed: number | null;
|
|
255
|
+
};
|
|
256
|
+
timestamp: number;
|
|
257
|
+
}
|
|
258
|
+
interface StreamHeadingData {
|
|
259
|
+
magneticHeading: number;
|
|
260
|
+
trueHeading: number;
|
|
261
|
+
accuracy: number;
|
|
262
|
+
}
|
|
263
|
+
interface StreamAccelerometerData {
|
|
264
|
+
x: number;
|
|
265
|
+
y: number;
|
|
266
|
+
z: number;
|
|
267
|
+
}
|
|
268
|
+
interface StreamUpdatePayload {
|
|
269
|
+
location: StreamLocationData;
|
|
270
|
+
heading: StreamHeadingData;
|
|
271
|
+
accelerometer: StreamAccelerometerData | null;
|
|
272
|
+
timestamp: number;
|
|
273
|
+
}
|
|
274
|
+
/**
|
|
275
|
+
* Global events emitted by the Host Shell that may affect the mini-app's context.
|
|
276
|
+
*/
|
|
277
|
+
declare enum GlobalEvent {
|
|
278
|
+
/** Triggered when the Host Shell sends an update event to the mini-app, indicating changes in context. */
|
|
279
|
+
UPDATE_CONTEXT = "UPDATE_CONTEXT"
|
|
280
|
+
}
|
|
281
|
+
/**
|
|
282
|
+
* Union type for all SDK events, allowing for both known enums and custom strings.
|
|
283
|
+
* The (string & {}) pattern preserves IntelliSense for enum members.
|
|
284
|
+
*/
|
|
285
|
+
type SDKEvent = UIEvent | GeolocationEvent | GlobalEvent | (string & {});
|
|
286
|
+
/**
|
|
287
|
+
* Configuration for native scroll interactions managed by the Host Shell.
|
|
288
|
+
*/
|
|
289
|
+
interface ScrollConfig {
|
|
290
|
+
/** Configuration for Pull-to-Refresh (Top). */
|
|
291
|
+
topScrollMore?: {
|
|
292
|
+
/** Show/hide the native RefreshControl. */
|
|
293
|
+
enabled: boolean;
|
|
294
|
+
/** Set to true to show the loading spinner, false to hide it. */
|
|
295
|
+
refreshing?: boolean;
|
|
296
|
+
};
|
|
297
|
+
/** Configuration for Infinite Scroll (Bottom). */
|
|
298
|
+
bottomScrollMore?: {
|
|
299
|
+
/** Enable/disable bottom scroll detection. */
|
|
300
|
+
enabled: boolean;
|
|
301
|
+
/** If false, detection stops and the indicator is hidden. */
|
|
302
|
+
hasMore?: boolean;
|
|
303
|
+
/** Set to true to show the bottom ActivityIndicator. */
|
|
304
|
+
loadingMore?: boolean;
|
|
305
|
+
};
|
|
306
|
+
}
|
|
307
|
+
/**
|
|
308
|
+
* Edge insets representing padding or margins around a component, typically used for layout purposes.
|
|
309
|
+
*/
|
|
310
|
+
interface IEdgeInsets {
|
|
311
|
+
top: number;
|
|
312
|
+
right: number;
|
|
313
|
+
bottom: number;
|
|
314
|
+
left: number;
|
|
315
|
+
}
|
|
316
|
+
/**
|
|
317
|
+
* The context state of the mini-app, which includes dynamic properties provided by the Host Shell, such as edge insets for layout adjustments. This type can be extended with additional properties as needed.
|
|
318
|
+
*/
|
|
319
|
+
type IContextState = Record<string, any> & {
|
|
320
|
+
insets: IEdgeInsets;
|
|
321
|
+
};
|
|
322
|
+
|
|
323
|
+
/**
|
|
324
|
+
* Internal message envelope for bridge communication.
|
|
325
|
+
* @internal
|
|
326
|
+
*/
|
|
327
|
+
interface IBridgeEnvelope<P = unknown, V = unknown> {
|
|
328
|
+
/** Unique identifier to match responses with requests. */
|
|
329
|
+
callbackId?: string;
|
|
330
|
+
/** The type/action of the message. */
|
|
331
|
+
type?: string;
|
|
332
|
+
/** Event name for pushed notifications (new protocol). */
|
|
333
|
+
eventName?: string;
|
|
334
|
+
/** Data payload for the message. */
|
|
335
|
+
payload?: P;
|
|
336
|
+
/** Whether the operation was successful. */
|
|
337
|
+
success?: boolean;
|
|
338
|
+
/** Error message if success is false. */
|
|
339
|
+
error?: string;
|
|
340
|
+
/** The result value for successful operations. */
|
|
341
|
+
value?: V;
|
|
342
|
+
/** Event name for pushed notifications (legacy protocol). */
|
|
343
|
+
event?: string;
|
|
344
|
+
}
|
|
345
|
+
/**
|
|
346
|
+
* The messages the bridge can ask for
|
|
347
|
+
*/
|
|
348
|
+
type BridgeMessageType = {
|
|
349
|
+
type: "STORAGE_SET";
|
|
350
|
+
payload: {
|
|
351
|
+
key: string;
|
|
352
|
+
value: string;
|
|
353
|
+
};
|
|
354
|
+
callbackId: string;
|
|
355
|
+
} | {
|
|
356
|
+
type: "STORAGE_GET";
|
|
357
|
+
payload: {
|
|
358
|
+
key: string;
|
|
359
|
+
};
|
|
360
|
+
callbackId: string;
|
|
361
|
+
} | {
|
|
362
|
+
type: "STORAGE_GET_ALL";
|
|
363
|
+
payload?: unknown;
|
|
364
|
+
callbackId: string;
|
|
365
|
+
} | {
|
|
366
|
+
type: "GET_LOCATION";
|
|
367
|
+
payload?: unknown;
|
|
368
|
+
callbackId: string;
|
|
369
|
+
} | {
|
|
370
|
+
type: "INITIALIZE";
|
|
371
|
+
payload: {
|
|
372
|
+
options: IInitializationOptions;
|
|
373
|
+
};
|
|
374
|
+
callbackId: string;
|
|
375
|
+
} | {
|
|
376
|
+
type: "DEBUG_LOG";
|
|
377
|
+
payload: {
|
|
378
|
+
message: unknown[];
|
|
379
|
+
};
|
|
380
|
+
callbackId: string;
|
|
381
|
+
} | {
|
|
382
|
+
type: "SECURE_SET";
|
|
383
|
+
payload: {
|
|
384
|
+
key: string;
|
|
385
|
+
value: string;
|
|
386
|
+
};
|
|
387
|
+
callbackId: string;
|
|
388
|
+
} | {
|
|
389
|
+
type: "SECURE_GET";
|
|
390
|
+
payload: {
|
|
391
|
+
key: string;
|
|
392
|
+
};
|
|
393
|
+
callbackId: string;
|
|
394
|
+
} | {
|
|
395
|
+
type: "PAYMENT_REQUEST";
|
|
396
|
+
payload: unknown;
|
|
397
|
+
callbackId: string;
|
|
398
|
+
} | {
|
|
399
|
+
type: "START_ACTIVITY";
|
|
400
|
+
payload: unknown;
|
|
401
|
+
callbackId: string;
|
|
402
|
+
} | {
|
|
403
|
+
type: "GET_USER_PROFILE";
|
|
404
|
+
payload?: {
|
|
405
|
+
fields?: string[];
|
|
406
|
+
};
|
|
407
|
+
callbackId: string;
|
|
408
|
+
} | {
|
|
409
|
+
type: "SPEND_FPOINTS";
|
|
410
|
+
payload: {
|
|
411
|
+
intentUuid: string;
|
|
412
|
+
};
|
|
413
|
+
callbackId: string;
|
|
414
|
+
} | {
|
|
415
|
+
type: "GET_FIDELITY_BALANCE";
|
|
416
|
+
payload?: unknown;
|
|
417
|
+
callbackId: string;
|
|
418
|
+
} | {
|
|
419
|
+
type: "GET_FIDELITY_HISTORY";
|
|
420
|
+
payload: IFidelityHistoryParams;
|
|
421
|
+
callbackId: string;
|
|
422
|
+
} | {
|
|
423
|
+
type: "EXIT";
|
|
424
|
+
payload?: unknown;
|
|
425
|
+
callbackId: string;
|
|
426
|
+
} | {
|
|
427
|
+
type: "DATABASE_GET_USER_DATA";
|
|
428
|
+
payload?: unknown;
|
|
429
|
+
callbackId: string;
|
|
430
|
+
} | {
|
|
431
|
+
type: "DATABASE_SET_USER_DATA";
|
|
432
|
+
payload: {
|
|
433
|
+
data: unknown;
|
|
434
|
+
};
|
|
435
|
+
callbackId: string;
|
|
436
|
+
} | {
|
|
437
|
+
type: "REQUEST_PERMISSION";
|
|
438
|
+
payload: {
|
|
439
|
+
type: "location" | "profile";
|
|
440
|
+
fields?: string[];
|
|
441
|
+
};
|
|
442
|
+
callbackId: string;
|
|
443
|
+
} | {
|
|
444
|
+
type: "TRIGGER_HAPTIC";
|
|
445
|
+
payload?: {
|
|
446
|
+
style?: HapticStyleType;
|
|
447
|
+
};
|
|
448
|
+
callbackId: string;
|
|
449
|
+
} | {
|
|
450
|
+
type: "NETWORK_REQUEST";
|
|
451
|
+
payload: {
|
|
452
|
+
url: string;
|
|
453
|
+
method?: string;
|
|
454
|
+
headers?: Record<string, string>;
|
|
455
|
+
body?: unknown;
|
|
456
|
+
};
|
|
457
|
+
callbackId: string;
|
|
458
|
+
} | {
|
|
459
|
+
type: "SET_SCROLL_CONFIG";
|
|
460
|
+
payload: ScrollConfig;
|
|
461
|
+
callbackId: string;
|
|
462
|
+
} | {
|
|
463
|
+
type: "SDK_ROUTING_GETROUTE";
|
|
464
|
+
payload: {
|
|
465
|
+
sdkVersion: string;
|
|
466
|
+
requestId: string;
|
|
467
|
+
payload: {
|
|
468
|
+
origin: [number, number];
|
|
469
|
+
destination: [number, number];
|
|
470
|
+
waypoints?: [number, number][];
|
|
471
|
+
profile: "driving" | "cycling" | "walking";
|
|
472
|
+
language?: string;
|
|
473
|
+
};
|
|
474
|
+
};
|
|
475
|
+
callbackId: string;
|
|
476
|
+
} | {
|
|
477
|
+
type: "SDK_ROUTING_DRAWROUTE";
|
|
478
|
+
payload: {
|
|
479
|
+
sdkVersion: string;
|
|
480
|
+
requestId: string;
|
|
481
|
+
payload: {
|
|
482
|
+
routeData: unknown;
|
|
483
|
+
};
|
|
484
|
+
};
|
|
485
|
+
callbackId: string;
|
|
486
|
+
} | {
|
|
487
|
+
type: "SDK_ROUTING_CLEARROUTE";
|
|
488
|
+
payload: {
|
|
489
|
+
sdkVersion: string;
|
|
490
|
+
requestId: string;
|
|
491
|
+
};
|
|
492
|
+
callbackId: string;
|
|
493
|
+
} | {
|
|
494
|
+
type: "UPDATE_CONTEXT";
|
|
495
|
+
payload: Record<string, unknown>;
|
|
496
|
+
callbackId: string;
|
|
497
|
+
} | {
|
|
498
|
+
type: "START_LOCATION_STREAM";
|
|
499
|
+
payload?: LocationStreamConfig;
|
|
500
|
+
callbackId: string;
|
|
501
|
+
} | {
|
|
502
|
+
type: "STOP_LOCATION_STREAM";
|
|
503
|
+
payload?: never;
|
|
504
|
+
callbackId: string;
|
|
505
|
+
} | {
|
|
506
|
+
type: string;
|
|
507
|
+
payload: unknown;
|
|
508
|
+
callbackId: string;
|
|
509
|
+
};
|
|
510
|
+
|
|
511
|
+
type DrawerState = "closed" | "peek" | "full";
|
|
512
|
+
interface POI {
|
|
513
|
+
id: string | number;
|
|
514
|
+
name: string;
|
|
515
|
+
longitude: number;
|
|
516
|
+
latitude: number;
|
|
517
|
+
type?: "bar" | "restaurant" | "shop" | string;
|
|
518
|
+
description?: string;
|
|
519
|
+
rating?: number;
|
|
520
|
+
metadata?: Record<string, unknown>;
|
|
521
|
+
/**
|
|
522
|
+
* Custom image URL for GL layer.
|
|
523
|
+
* If provided, the SDK will automatically load and cache this image.
|
|
524
|
+
*/
|
|
525
|
+
imageUrl?: string;
|
|
526
|
+
/**
|
|
527
|
+
* Emoji character to display in GL layer (fallback if no icon).
|
|
528
|
+
*/
|
|
529
|
+
emoji?: string;
|
|
530
|
+
/**
|
|
531
|
+
* Name of a sprite from the map style's sprite sheet (e.g., 'beer', 'cafe').
|
|
532
|
+
* If provided, this takes priority over emoji and default types.
|
|
533
|
+
*/
|
|
534
|
+
spriteName?: string;
|
|
535
|
+
/**
|
|
536
|
+
* Whether to render as a native GL layer (performant) or a React Marker (flexible).
|
|
537
|
+
* Defaults to 'gl'.
|
|
538
|
+
*/
|
|
539
|
+
displayMode?: "gl" | "marker";
|
|
540
|
+
/**
|
|
541
|
+
* Optional custom React component when displayMode is 'marker'.
|
|
542
|
+
*/
|
|
543
|
+
markerComponent?: React.ReactNode;
|
|
544
|
+
}
|
|
545
|
+
interface MapProps {
|
|
546
|
+
/** Initial view state of the map. */
|
|
547
|
+
initialViewState?: Partial<ViewState>;
|
|
548
|
+
/** Inline styles for the map container. */
|
|
549
|
+
style?: React.CSSProperties;
|
|
550
|
+
/** Minimum and maximum bounds for the map. */
|
|
551
|
+
maxBounds?: [[number, number], [number, number]];
|
|
552
|
+
/** MapLibre style URL. Defaults to local server. */
|
|
553
|
+
mapStyle?: string;
|
|
554
|
+
/** Children components (Source, Layer, etc.) */
|
|
555
|
+
children?: React.ReactNode;
|
|
556
|
+
/** Additional CSS classes for the map container. */
|
|
557
|
+
className?: string;
|
|
558
|
+
/** Callback when the map is clicked. */
|
|
559
|
+
onClick?: (e: any) => void;
|
|
560
|
+
/** Callback when the map is clicked, but no interactive layers or POIs are hit. */
|
|
561
|
+
onMapClickMiss?: (e: any) => void;
|
|
562
|
+
/** Callback when the map is right-clicked or long-pressed. */
|
|
563
|
+
onContextMenu?: (e: any) => void;
|
|
564
|
+
/** IDs of layers that should be interactive. */
|
|
565
|
+
interactiveLayerIds?: string[];
|
|
566
|
+
/** Callback when the map is loaded. */
|
|
567
|
+
onLoad?: (e: any) => void;
|
|
568
|
+
/**
|
|
569
|
+
* Whether to show the user's current location on the map.
|
|
570
|
+
* Defaults to true.
|
|
571
|
+
*/
|
|
572
|
+
showUserLocation?: boolean;
|
|
573
|
+
/**
|
|
574
|
+
* Whether the map should follow the user's location.
|
|
575
|
+
* Usually combined with showUserLocationButton for manual override.
|
|
576
|
+
* Note: The camera automatically locks when a route is provided.
|
|
577
|
+
*/
|
|
578
|
+
followUser?: boolean;
|
|
579
|
+
/**
|
|
580
|
+
* Whether to show the built-in "Center on User" button.
|
|
581
|
+
* Defaults to true.
|
|
582
|
+
*/
|
|
583
|
+
showUserLocationButton?: boolean;
|
|
584
|
+
/**
|
|
585
|
+
* Custom renderer for the user's location marker.
|
|
586
|
+
* If provided, overrides the default pulsating blue dot.
|
|
587
|
+
*/
|
|
588
|
+
renderUserLocation?: (props: {
|
|
589
|
+
coords: [number, number];
|
|
590
|
+
heading: number | null;
|
|
591
|
+
}) => React.ReactNode;
|
|
592
|
+
/** A list of POIs to display. */
|
|
593
|
+
pois?: POI[];
|
|
594
|
+
/** Callback when a POI is clicked. */
|
|
595
|
+
onPoiClick?: (poi: POI) => void;
|
|
596
|
+
/** Route geometry to display on the map. */
|
|
597
|
+
route?: GeoJSON.LineString;
|
|
598
|
+
/** Whether to show the out-of-the-box navigation UI. */
|
|
599
|
+
showNavigationUI?: boolean;
|
|
600
|
+
/** Callback triggered when the user aborts/closes the navigation UI. */
|
|
601
|
+
onNavigationAbort?: () => void;
|
|
602
|
+
/**
|
|
603
|
+
* Integrated navigation configuration.
|
|
604
|
+
* If provided, the Map component will internally manage route calculation and tracking.
|
|
605
|
+
*/
|
|
606
|
+
navigation?: {
|
|
607
|
+
/** Destination coordinates [lng, lat] */
|
|
608
|
+
destination: [number, number] | null;
|
|
609
|
+
/** Transport profile. Defaults to 'driving'. */
|
|
610
|
+
profile?: "driving" | "cycling" | "walking";
|
|
611
|
+
/** Minimum distance in meters the user must move before recalculating path geometry. Defaults to 50. */
|
|
612
|
+
recalculateThreshold?: number;
|
|
613
|
+
/** Whether to automatically show the navigation UI. Defaults to true if destination is set. */
|
|
614
|
+
showUI?: boolean;
|
|
615
|
+
/** Optional manual origin. Defaults to real-time user location. */
|
|
616
|
+
origin?: [number, number] | null;
|
|
617
|
+
/**
|
|
618
|
+
* Initial mode for the navigation.
|
|
619
|
+
* 'preview' shows the full route overview.
|
|
620
|
+
* 'navigation' starts active turn-by-turn tracking.
|
|
621
|
+
* Defaults to 'preview'.
|
|
622
|
+
*/
|
|
623
|
+
mode?: "preview" | "navigation";
|
|
624
|
+
};
|
|
625
|
+
/** Callback triggered when the navigation mode changes (e.g. from preview to navigation). */
|
|
626
|
+
onNavigationModeChange?: (mode: "preview" | "navigation") => void;
|
|
627
|
+
/**
|
|
628
|
+
* The data for the navigation UI.
|
|
629
|
+
* Usually provided by the useLiveRouting hook.
|
|
630
|
+
* Note: This is automatically populated if the 'navigation' prop is used.
|
|
631
|
+
*/
|
|
632
|
+
navigationData?: {
|
|
633
|
+
route: RouteResponse["data"] | null;
|
|
634
|
+
currentDistanceMeters?: number | null;
|
|
635
|
+
totalDistance?: number | null;
|
|
636
|
+
isCalculating?: boolean;
|
|
637
|
+
error?: string | null;
|
|
638
|
+
/** Current mode: 'preview' (overview) or 'navigation' (active guidance) */
|
|
639
|
+
mode?: "preview" | "navigation";
|
|
640
|
+
/** Function to transition to active navigation mode */
|
|
641
|
+
start?: () => void;
|
|
642
|
+
};
|
|
643
|
+
/** Whether to show the vertical drawer and floating right controls. Defaults to true. */
|
|
644
|
+
showControls?: boolean;
|
|
645
|
+
/** Custom menu items to display in the vertical drawer. */
|
|
646
|
+
menuItems?: MenuItem[];
|
|
647
|
+
/** Custom React node to render inside the drawer menu container instead of menuItems list. */
|
|
648
|
+
menuContent?: React.ReactNode;
|
|
649
|
+
/** Programmatically control the drawer state. */
|
|
650
|
+
drawerState?: DrawerState;
|
|
651
|
+
/** Ref to the drawer's scrollable container. */
|
|
652
|
+
drawerContentRef?: React.Ref<HTMLDivElement>;
|
|
653
|
+
/** Custom controls (e.g. buttons) to display floating above the recenter button. */
|
|
654
|
+
controlProps?: MapControlsProps;
|
|
655
|
+
/** Whether to enable touch drag gestures for the bottom sheet drawer. Defaults to false. */
|
|
656
|
+
enableTouchDrag?: boolean;
|
|
657
|
+
}
|
|
658
|
+
interface MenuItem {
|
|
659
|
+
id: string;
|
|
660
|
+
label: string;
|
|
661
|
+
icon: React.ReactNode;
|
|
662
|
+
onPress: () => void;
|
|
663
|
+
badge?: string | number;
|
|
664
|
+
disabled?: boolean;
|
|
665
|
+
}
|
|
666
|
+
interface CustomControl {
|
|
667
|
+
id: string;
|
|
668
|
+
icon: React.ReactNode;
|
|
669
|
+
onPress: () => void;
|
|
670
|
+
position: "above-recenter" | "below-recenter";
|
|
671
|
+
tooltip?: string;
|
|
672
|
+
activeState?: boolean;
|
|
673
|
+
}
|
|
674
|
+
interface EtaData {
|
|
675
|
+
etaMins: number;
|
|
676
|
+
distanceRemainingKm: number;
|
|
677
|
+
label?: string;
|
|
678
|
+
progress?: number;
|
|
679
|
+
mode?: "preview" | "navigation";
|
|
680
|
+
onAbort?: () => void;
|
|
681
|
+
onStart?: () => void;
|
|
682
|
+
isCalculating?: boolean;
|
|
683
|
+
error?: string | null;
|
|
684
|
+
}
|
|
685
|
+
|
|
686
|
+
interface MapInsets {
|
|
687
|
+
top: number;
|
|
688
|
+
bottom: number;
|
|
689
|
+
left: number;
|
|
690
|
+
right: number;
|
|
691
|
+
}
|
|
692
|
+
interface MapControlsState {
|
|
693
|
+
isFollowing: boolean;
|
|
694
|
+
setIsFollowing: (following: boolean) => void;
|
|
695
|
+
centerOnUser: (params?: CenterCallbackParams) => void;
|
|
696
|
+
bearing: number;
|
|
697
|
+
setBearing: (bearing: number) => void;
|
|
698
|
+
pitch: number;
|
|
699
|
+
setPitch: (pitch: number) => void;
|
|
700
|
+
resetBearing: (params?: CenterCallbackParams) => void;
|
|
701
|
+
etaData?: EtaData;
|
|
702
|
+
setEtaData: (data?: EtaData) => void;
|
|
703
|
+
hasControls: boolean;
|
|
704
|
+
setHasControls: (hasControls: boolean) => void;
|
|
705
|
+
drawerState: DrawerState;
|
|
706
|
+
setDrawerState: (state: DrawerState) => void;
|
|
707
|
+
/** Stable ref to the drawer's scrollable container. Always available. */
|
|
708
|
+
drawerContentRef: React.RefObject<HTMLDivElement | null>;
|
|
709
|
+
insets: MapInsets;
|
|
710
|
+
setInsets: (insets: Partial<MapInsets>) => void;
|
|
711
|
+
}
|
|
712
|
+
interface CenterCallbackParams {
|
|
713
|
+
pitch?: number;
|
|
714
|
+
}
|
|
715
|
+
interface MapControlsContextType extends MapControlsState {
|
|
716
|
+
_registerCenterCallback: (cb: (params?: CenterCallbackParams) => void) => void;
|
|
717
|
+
_registerResetBearingCallback: (cb: (params?: CenterCallbackParams) => void) => void;
|
|
718
|
+
}
|
|
719
|
+
declare const MapControlsContext: React.Context<MapControlsContextType | null>;
|
|
720
|
+
declare const SDKMapProvider: React.FC<{
|
|
721
|
+
children: React.ReactNode;
|
|
722
|
+
}>;
|
|
723
|
+
declare const useMapControls: () => MapControlsState;
|
|
724
|
+
|
|
725
|
+
interface MapControlsProps {
|
|
726
|
+
menuItems?: MenuItem[];
|
|
727
|
+
drawerSide?: "left" | "bottom";
|
|
728
|
+
defaultState?: DrawerState;
|
|
729
|
+
menuContent?: React.ReactNode;
|
|
730
|
+
children?: React.ReactNode;
|
|
731
|
+
customControls?: CustomControl[];
|
|
732
|
+
etaBarHeight?: number;
|
|
733
|
+
onRecenter?: (params?: CenterCallbackParams) => void;
|
|
734
|
+
isMapCentered?: boolean;
|
|
735
|
+
mapBearing?: number;
|
|
736
|
+
initialViewState?: Partial<ViewState>;
|
|
737
|
+
onResetBearing?: (params?: CenterCallbackParams) => void;
|
|
738
|
+
etaData?: EtaData;
|
|
739
|
+
customRecenterButton?: React.ReactNode;
|
|
740
|
+
customCompassButton?: React.ReactNode;
|
|
741
|
+
drawerPeekHeight?: string | number;
|
|
742
|
+
drawerFullHeight?: string | number;
|
|
743
|
+
drawerContentRef?: React.Ref<HTMLDivElement>;
|
|
744
|
+
enableTouchDrag?: boolean;
|
|
745
|
+
showScrollToTopButton?: boolean;
|
|
746
|
+
scrollToTopThreshold?: number;
|
|
747
|
+
isInternal?: boolean;
|
|
748
|
+
}
|
|
749
|
+
declare const MapControls: React.FC<MapControlsProps>;
|
|
750
|
+
|
|
751
|
+
interface MapMenuProps {
|
|
752
|
+
children?: React.ReactNode;
|
|
753
|
+
}
|
|
754
|
+
declare const MapMenu: React.FC<MapMenuProps>;
|
|
755
|
+
interface MapMenuItemProps {
|
|
756
|
+
id: string;
|
|
757
|
+
label: string;
|
|
758
|
+
icon?: React.ReactNode;
|
|
759
|
+
onPress?: () => void;
|
|
760
|
+
badge?: string | number;
|
|
761
|
+
disabled?: boolean;
|
|
762
|
+
children?: React.ReactNode;
|
|
763
|
+
}
|
|
764
|
+
declare const MapMenuItem: React.FC<MapMenuItemProps>;
|
|
765
|
+
interface MapMenuTitleProps {
|
|
766
|
+
children: React.ReactNode;
|
|
767
|
+
className?: string;
|
|
768
|
+
showDivider?: boolean;
|
|
769
|
+
}
|
|
770
|
+
declare const MapMenuTitle: React.FC<MapMenuTitleProps>;
|
|
771
|
+
interface MapMenuDividerProps {
|
|
772
|
+
className?: string;
|
|
773
|
+
}
|
|
774
|
+
declare const MapMenuDivider: React.FC<MapMenuDividerProps>;
|
|
775
|
+
interface MapMenuFooterProps {
|
|
776
|
+
children: React.ReactNode;
|
|
777
|
+
className?: string;
|
|
778
|
+
}
|
|
779
|
+
declare const MapMenuFooter: React.FC<MapMenuFooterProps>;
|
|
780
|
+
|
|
781
|
+
interface LiveRoutingOptions {
|
|
782
|
+
/** Origin coordinates [lng, lat]. If not provided, uses device location. */
|
|
783
|
+
origin?: [number, number] | null;
|
|
784
|
+
/** Destination coordinates [lng, lat] */
|
|
785
|
+
destination: [number, number] | null;
|
|
786
|
+
/** Transport profile. Defaults to 'driving'. */
|
|
787
|
+
profile?: "driving" | "cycling" | "walking";
|
|
788
|
+
/** Minimum distance in meters the user must move before recalculating path geometry. Defaults to 50. */
|
|
789
|
+
recalculateThreshold?: number;
|
|
790
|
+
/** Whether live routing is active. */
|
|
791
|
+
enabled?: boolean;
|
|
792
|
+
/** Initial mode: 'preview' or 'navigation'. Defaults to 'preview'. */
|
|
793
|
+
initialMode?: "preview" | "navigation";
|
|
794
|
+
}
|
|
795
|
+
interface LiveRoutingResult {
|
|
796
|
+
/** The calculated route data from the last API call */
|
|
797
|
+
route: RouteResponse["data"] | null;
|
|
798
|
+
/** Real-time distance to destination in meters */
|
|
799
|
+
currentDistanceMeters: number | null;
|
|
800
|
+
/** The initial total distance when the destination was first set */
|
|
801
|
+
totalDistance: number | null;
|
|
802
|
+
/** Whether a new calculation is in progress */
|
|
803
|
+
isCalculating: boolean;
|
|
804
|
+
/** Any error message from the routing service */
|
|
805
|
+
error: string | null;
|
|
806
|
+
/** Force a manual recalculation */
|
|
807
|
+
recalculate: () => void;
|
|
808
|
+
/** Current mode: 'preview' (overview) or 'navigation' (active guidance) */
|
|
809
|
+
mode: "preview" | "navigation";
|
|
810
|
+
/** Start active navigation (switch mode to 'navigation') */
|
|
811
|
+
start: () => void;
|
|
812
|
+
}
|
|
813
|
+
declare const useLiveRouting: ({ origin: manualOrigin, destination, profile, recalculateThreshold, enabled, initialMode, }: LiveRoutingOptions) => LiveRoutingResult;
|
|
814
|
+
/**
|
|
815
|
+
* A simple hook to fetch a route once between two points.
|
|
816
|
+
* Does not automatically recalculate or track user location.
|
|
817
|
+
*/
|
|
818
|
+
declare const useRoute: (origin: [number, number] | null, destination: [number, number] | null, profile?: "driving" | "cycling" | "walking") => {
|
|
819
|
+
error: string | null;
|
|
820
|
+
isCalculating: boolean;
|
|
821
|
+
route: {
|
|
822
|
+
geometry: GeoJSON.LineString;
|
|
823
|
+
distanceMeters: number;
|
|
824
|
+
durationSeconds: number;
|
|
825
|
+
steps?: RouteStep[];
|
|
826
|
+
} | null | undefined;
|
|
827
|
+
};
|
|
828
|
+
|
|
829
|
+
/**
|
|
830
|
+
* Slices a LineString to start at the point closest to the provided coordinates.
|
|
831
|
+
* This removes the "already traveled" portion of the route.
|
|
832
|
+
*/
|
|
833
|
+
declare const useTrimmedRoute: (route: GeoJSON.LineString | undefined, userLocation: [number, number] | null) => GeoJSON.LineString | undefined;
|
|
834
|
+
|
|
835
|
+
interface UserLocationState {
|
|
836
|
+
coords: [number, number] | null;
|
|
837
|
+
heading: number | null;
|
|
838
|
+
accuracy: number | null;
|
|
839
|
+
}
|
|
840
|
+
declare const useUserLocation: () => UserLocationState;
|
|
841
|
+
|
|
842
|
+
interface RouteLayerProps {
|
|
843
|
+
/** The route geometry as a GeoJSON LineString */
|
|
844
|
+
geometry?: GeoJSON.LineString;
|
|
845
|
+
/** Color of the route line. Defaults to #3b82f6 (blue-500). */
|
|
846
|
+
color?: string;
|
|
847
|
+
/** Width of the route line. Defaults to 5. */
|
|
848
|
+
width?: number;
|
|
849
|
+
/** Opacity of the route line. Defaults to 0.8. */
|
|
850
|
+
opacity?: number;
|
|
851
|
+
}
|
|
852
|
+
declare const RouteLayer: React.FC<RouteLayerProps>;
|
|
853
|
+
|
|
854
|
+
declare const Map: React.FC<MapProps>;
|
|
855
|
+
|
|
856
|
+
/**
|
|
857
|
+
* Renders the Map component into a DOM element.
|
|
858
|
+
* Useful for non-React environments (UMD/IIFE).
|
|
859
|
+
*
|
|
860
|
+
* @param containerId The ID of the HTML element where the map should be rendered.
|
|
861
|
+
* @param props The props to pass to the Map component.
|
|
862
|
+
* @returns The React root instance.
|
|
863
|
+
*/
|
|
864
|
+
declare function renderMap(containerId: string, props?: MapProps): react_dom_client.Root;
|
|
865
|
+
|
|
866
|
+
/**
|
|
867
|
+
* Hook to check if the SDK is currently running in mock mode (browser)
|
|
868
|
+
* or native mode (shell app).
|
|
869
|
+
*/
|
|
870
|
+
declare const useIsMocked: () => boolean;
|
|
871
|
+
interface SDKProviderProps extends Partial<Omit<BridgeMockerProps, "children">> {
|
|
872
|
+
children: React.ReactNode;
|
|
873
|
+
/**
|
|
874
|
+
* If true, shows the standalone DebugConsole for bridge traffic.
|
|
875
|
+
*/
|
|
876
|
+
debug?: boolean;
|
|
877
|
+
}
|
|
878
|
+
/**
|
|
879
|
+
* A wrapper component that automatically enables the BridgeMocker
|
|
880
|
+
* when running outside the native shell app.
|
|
881
|
+
*/
|
|
882
|
+
declare const SDKProvider: React.FC<SDKProviderProps>;
|
|
883
|
+
|
|
884
|
+
declare class MiniAppSDK {
|
|
885
|
+
/**
|
|
886
|
+
* Map services.
|
|
887
|
+
* Provides access to MapLibre-based mapping components.
|
|
888
|
+
*/
|
|
889
|
+
readonly maps: Readonly<{
|
|
890
|
+
/**
|
|
891
|
+
* Renders a MapLibre map into a DOM element.
|
|
892
|
+
* Useful for non-React environments.
|
|
893
|
+
*/
|
|
894
|
+
render: typeof renderMap;
|
|
895
|
+
}>;
|
|
896
|
+
private bridge;
|
|
897
|
+
/**
|
|
898
|
+
* Local SQLite Storage.
|
|
899
|
+
* Data is persisted on the device and is isolated per Mini-App.
|
|
900
|
+
*/
|
|
901
|
+
readonly storage: Readonly<{
|
|
902
|
+
/** Retrieves a value by key. */
|
|
903
|
+
get: (key: string) => Promise<string | null>;
|
|
904
|
+
/** Retrieves all key-value pairs stored for this Mini-App. */
|
|
905
|
+
getAll: () => Promise<Record<string, string>>;
|
|
906
|
+
/** Sets a value for a specific key. */
|
|
907
|
+
set: (key: string, value: string) => Promise<void>;
|
|
908
|
+
}>;
|
|
909
|
+
/**
|
|
910
|
+
* Hardware-level Secure Storage.
|
|
911
|
+
* Data is stored in the device's secure enclave (Keychain/Keystore) and is isolated per Mini-App.
|
|
912
|
+
*/
|
|
913
|
+
readonly secureStore: Readonly<{
|
|
914
|
+
/** Retrieves a value by key from secure storage. */
|
|
915
|
+
get: (key: string) => Promise<string | null>;
|
|
916
|
+
/** Sets a value for a specific key in secure storage. */
|
|
917
|
+
set: (key: string, value: string) => Promise<void>;
|
|
918
|
+
}>;
|
|
919
|
+
/**
|
|
920
|
+
* Database Storage.
|
|
921
|
+
* Access to user-app specific persistent database storage.
|
|
922
|
+
*/
|
|
923
|
+
readonly database: Readonly<{
|
|
924
|
+
/** Retrieves the user data stored in the backend database. */
|
|
925
|
+
getUserData: <T = unknown>() => Promise<T>;
|
|
926
|
+
/** Updates the user data stored in the backend database. */
|
|
927
|
+
setUserData: <T = unknown>(data: T) => Promise<void>;
|
|
928
|
+
}>;
|
|
929
|
+
/**
|
|
930
|
+
* Device Location services.
|
|
931
|
+
*/
|
|
932
|
+
readonly location: Readonly<{
|
|
933
|
+
/**
|
|
934
|
+
* Retrieves the current GPS position of the device.
|
|
935
|
+
*/
|
|
936
|
+
getCurrentPosition: () => Promise<ILocationData>;
|
|
937
|
+
/**
|
|
938
|
+
* Starts the continuous location and sensor stream.
|
|
939
|
+
* @param config Optional configuration for thresholds and intervals.
|
|
940
|
+
*/
|
|
941
|
+
startStream: (config?: LocationStreamConfig) => Promise<void>;
|
|
942
|
+
/**
|
|
943
|
+
* Stops the continuous location and sensor stream.
|
|
944
|
+
*/
|
|
945
|
+
stopStream: () => Promise<void>;
|
|
946
|
+
}>;
|
|
947
|
+
/**
|
|
948
|
+
* Identity & Profile management.
|
|
949
|
+
*/
|
|
950
|
+
readonly user: Readonly<{
|
|
951
|
+
/**
|
|
952
|
+
* Fetch user profile data.
|
|
953
|
+
* @param fields Optional list of specific fields to retrieve (e.g., ['fullName', 'username']).
|
|
954
|
+
*/
|
|
955
|
+
getProfile: <T extends keyof IUserProfile>(fields?: T[]) => Promise<Partial<IUserProfile>>;
|
|
956
|
+
}>;
|
|
957
|
+
/**
|
|
958
|
+
* Explicit Permission Management.
|
|
959
|
+
* Allows requesting access to sensitive device features or user data.
|
|
960
|
+
*/
|
|
961
|
+
readonly permission: Readonly<{
|
|
962
|
+
/**
|
|
963
|
+
* Explicitly request access to sensitive data.
|
|
964
|
+
* @param type The type of permission to request ('location' or 'profile').
|
|
965
|
+
* @param fields If requesting 'profile', the specific fields required.
|
|
966
|
+
*/
|
|
967
|
+
request: {
|
|
968
|
+
(type: "location"): Promise<boolean>;
|
|
969
|
+
(type: "profile", fields: (keyof IUserProfile)[]): Promise<boolean>;
|
|
970
|
+
};
|
|
971
|
+
}>;
|
|
972
|
+
/**
|
|
973
|
+
* Payments integration.
|
|
974
|
+
*/
|
|
975
|
+
readonly payment: Readonly<{
|
|
976
|
+
/**
|
|
977
|
+
* Triggers the native payment flow.
|
|
978
|
+
* @param payload Amount, currency, and itemized list for the payment.
|
|
979
|
+
*/
|
|
980
|
+
request: (payload: IPaymentRequest) => Promise<{
|
|
981
|
+
success: true;
|
|
982
|
+
transactionId: string;
|
|
983
|
+
}>;
|
|
984
|
+
}>;
|
|
985
|
+
/**
|
|
986
|
+
* Live Activities & Notifications.
|
|
987
|
+
* Allows the Mini-App to display real-time updates in the host shell.
|
|
988
|
+
*/
|
|
989
|
+
readonly activity: Readonly<{
|
|
990
|
+
/**
|
|
991
|
+
* Starts a new live activity.
|
|
992
|
+
* @param id Unique identifier for the activity.
|
|
993
|
+
* @param title Display title for the activity.
|
|
994
|
+
* @param status Initial status message.
|
|
995
|
+
*/
|
|
996
|
+
start: (id: string, title: string, status: string) => Promise<void>;
|
|
997
|
+
}>;
|
|
998
|
+
/**
|
|
999
|
+
* Haptic feedback.
|
|
1000
|
+
*/
|
|
1001
|
+
readonly haptic: Readonly<{
|
|
1002
|
+
/**
|
|
1003
|
+
* Triggers a haptic vibration on the device.
|
|
1004
|
+
* @param style The style of haptic feedback (e.g., 'light', 'medium', 'heavy', 'success', 'warning', 'error').
|
|
1005
|
+
*/
|
|
1006
|
+
trigger: (style: HapticStyleType) => Promise<void>;
|
|
1007
|
+
}>;
|
|
1008
|
+
/**
|
|
1009
|
+
* Network Proxy.
|
|
1010
|
+
* Allows the Mini-App to make network requests through the host shell to bypass CORS or use host-level authentication.
|
|
1011
|
+
*/
|
|
1012
|
+
readonly network: Readonly<{
|
|
1013
|
+
/**
|
|
1014
|
+
* Performs a network request via the host shell.
|
|
1015
|
+
* @param options Request method, URL, headers, and body.
|
|
1016
|
+
*/
|
|
1017
|
+
request: <T = unknown>(options: INetworkOptions) => Promise<INetworkResponse<T>>;
|
|
1018
|
+
}>;
|
|
1019
|
+
/**
|
|
1020
|
+
* Navigation and Journey controls.
|
|
1021
|
+
* Allows programmatically starting itineraries and managing navigation state.
|
|
1022
|
+
*/
|
|
1023
|
+
readonly navigation: Readonly<{
|
|
1024
|
+
/**
|
|
1025
|
+
* Aborts the current navigation journey.
|
|
1026
|
+
*/
|
|
1027
|
+
abort: () => void;
|
|
1028
|
+
/**
|
|
1029
|
+
* Creates a new itinerary preview.
|
|
1030
|
+
* @param options Destination and routing options.
|
|
1031
|
+
*/
|
|
1032
|
+
createJourney: (options: {
|
|
1033
|
+
destination: [number, number];
|
|
1034
|
+
origin?: [number, number];
|
|
1035
|
+
profile?: "driving" | "cycling" | "walking";
|
|
1036
|
+
}) => void;
|
|
1037
|
+
/**
|
|
1038
|
+
* Starts the active navigation (active guidance).
|
|
1039
|
+
*/
|
|
1040
|
+
start: () => void;
|
|
1041
|
+
}>;
|
|
1042
|
+
/**
|
|
1043
|
+
* Fidelity & Rewards program integration.
|
|
1044
|
+
*/
|
|
1045
|
+
readonly fidelity: Readonly<{
|
|
1046
|
+
/** Returns current fidelity balance. */
|
|
1047
|
+
getFidelityBalance: () => Promise<IFidelityBalance>;
|
|
1048
|
+
/**
|
|
1049
|
+
* Retrieves fidelity transaction history.
|
|
1050
|
+
* @param params Filtering and pagination parameters.
|
|
1051
|
+
*/
|
|
1052
|
+
getFidelityHistory: (params?: IFidelityHistoryParams) => Promise<IFidelityTransaction[]>;
|
|
1053
|
+
/**
|
|
1054
|
+
* Triggers the native fidelity history view.
|
|
1055
|
+
*/
|
|
1056
|
+
showHistory: () => Promise<void>;
|
|
1057
|
+
/**
|
|
1058
|
+
* Authorize spending fidelity points (FPoints) via Two-Phase Authorization.
|
|
1059
|
+
* @param intentUuid UUID generated by your backend for the transaction.
|
|
1060
|
+
*/
|
|
1061
|
+
spendFPoints: (intentUuid: string) => Promise<{
|
|
1062
|
+
success: boolean;
|
|
1063
|
+
transactionId: string;
|
|
1064
|
+
}>;
|
|
1065
|
+
}>;
|
|
1066
|
+
/**
|
|
1067
|
+
* UI and Navigation controls.
|
|
1068
|
+
*/
|
|
1069
|
+
readonly ui: Readonly<{
|
|
1070
|
+
/** Closes the Mini-App and returns to the host shell. */
|
|
1071
|
+
exit: () => Promise<void>;
|
|
1072
|
+
/**
|
|
1073
|
+
* Configures native scroll behaviors like Pull-to-Refresh and Infinite Scroll.
|
|
1074
|
+
* @param config Scroll configuration for top/bottom detection.
|
|
1075
|
+
*/
|
|
1076
|
+
setScrollConfig: (config: ScrollConfig) => Promise<void>;
|
|
1077
|
+
}>;
|
|
1078
|
+
/**
|
|
1079
|
+
* Debug controls
|
|
1080
|
+
*/
|
|
1081
|
+
readonly debug: Readonly<{
|
|
1082
|
+
/**
|
|
1083
|
+
* Log to the shell app
|
|
1084
|
+
* @param message
|
|
1085
|
+
*/
|
|
1086
|
+
log: (...message: unknown[]) => Promise<unknown>;
|
|
1087
|
+
}>;
|
|
1088
|
+
/**
|
|
1089
|
+
* Routing integration (OSRM / Valhalla).
|
|
1090
|
+
* Provides access to route calculation and rendering on the host map.
|
|
1091
|
+
*/
|
|
1092
|
+
readonly routing: Readonly<{
|
|
1093
|
+
/**
|
|
1094
|
+
* Clears the currently rendered route.
|
|
1095
|
+
*/
|
|
1096
|
+
clearRoute: () => Promise<void>;
|
|
1097
|
+
/**
|
|
1098
|
+
* Draws the calculated route on the host map.
|
|
1099
|
+
* @param routeData The route data returned by getRoute.
|
|
1100
|
+
*/
|
|
1101
|
+
drawRoute: (routeData: NonNullable<RouteResponse["data"]>) => Promise<void>;
|
|
1102
|
+
/**
|
|
1103
|
+
* Calculates a route between points.
|
|
1104
|
+
* @param payload Request payload containing origin, destination, and options.
|
|
1105
|
+
*/
|
|
1106
|
+
getRoute: (payload: RouteRequest["payload"]) => Promise<NonNullable<RouteResponse["data"]>>;
|
|
1107
|
+
}>;
|
|
1108
|
+
constructor();
|
|
1109
|
+
/**
|
|
1110
|
+
* Configures global SDK settings.
|
|
1111
|
+
*/
|
|
1112
|
+
config(options: {
|
|
1113
|
+
routingBackend?: RoutingBackendConfig;
|
|
1114
|
+
}): void;
|
|
1115
|
+
/**
|
|
1116
|
+
* Updates the global context shared between the Mini-App and the native shell.
|
|
1117
|
+
* Useful for synchronizing state like theme preferences, UI flags, or custom app-specific context.
|
|
1118
|
+
* @param context Partial context object to merge into the existing shell context.
|
|
1119
|
+
*/
|
|
1120
|
+
updateContext(context: Record<string, unknown>): Promise<void>;
|
|
1121
|
+
/**
|
|
1122
|
+
* The starting point for the Mini-App. Must be called before any other SDK methods.
|
|
1123
|
+
* @param options The options to provide to the shell app
|
|
1124
|
+
*/
|
|
1125
|
+
initialize(options: IInitializationOptions): Promise<IInitializationResponse>;
|
|
1126
|
+
/**
|
|
1127
|
+
* Registers a callback for a specific event from the native shell.
|
|
1128
|
+
* @param event The name of the event to listen for.
|
|
1129
|
+
* @param callback The function to execute when the event is triggered.
|
|
1130
|
+
* @returns A function to unregister the listener.
|
|
1131
|
+
*/
|
|
1132
|
+
on<T = unknown>(event: SDKEvent, callback: (data: T) => void): () => void;
|
|
1133
|
+
/**
|
|
1134
|
+
* Unregisters a previously registered event listener.
|
|
1135
|
+
* @param event The name of the event.
|
|
1136
|
+
* @param callback The callback function to remove.
|
|
1137
|
+
*/
|
|
1138
|
+
off<T = unknown>(event: SDKEvent, callback: (data: T) => void): void;
|
|
1139
|
+
}
|
|
1140
|
+
/**
|
|
1141
|
+
* Singleton instance of the MiniAppSDK.
|
|
1142
|
+
* Frozen to prevent tampering.
|
|
1143
|
+
*/
|
|
1144
|
+
declare const sdk: MiniAppSDK;
|
|
1145
|
+
|
|
1146
|
+
export { type BridgeMessageType, BridgeMocker, type BridgeMockerProps, type CenterCallbackParams, type CustomControl, DebugConsole, type DebugConsoleProps, type DrawerState, type EtaData, type FidelityTransactionTypeType, GeolocationEvent, GlobalEvent, type HapticStyleType, type IBridgeEnvelope, type IContextState, type IEdgeInsets, type IFidelityBalance, type IFidelityHistoryParams, type IFidelityTransaction, type IInitializationOptions, type IInitializationResponse, type ILocationData, type INetworkOptions, type INetworkResponse, type IPaymentRequest, type IUserProfile, type LiveRoutingOptions, type LiveRoutingResult, type LocationStreamConfig, Map, MapControls, MapControlsContext, type MapControlsProps, type MapControlsState, type MapInsets, MapMenu, MapMenuDivider, type MapMenuDividerProps, MapMenuFooter, type MapMenuFooterProps, MapMenuItem, type MapMenuItemProps, type MapMenuProps, MapMenuTitle, type MapMenuTitleProps, type MapProps, type MenuItem, MiniAppSDK, type NetworkMethodType, type POI, RouteLayer, type RouteLayerProps, RouteRequest, RouteResponse, RouteStep, type SDKEvent, SDKMapProvider, SDKProvider, type SDKProviderProps, type ScrollConfig, type StreamAccelerometerData, type StreamHeadingData, type StreamLocationData, type StreamUpdatePayload, UIEvent, type UserLocationState, sdk as default, renderMap, sdk, useIsMocked, useLiveRouting, useMapControls, useRoute, useTrimmedRoute, useUserLocation };
|