@grabjs/superapp-sdk 2.0.0-beta.1 → 2.0.0-beta.7
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/dist/api.json +11473 -0
- package/dist/index.d.ts +1644 -96
- package/dist/index.esm.js +1 -1
- package/dist/index.js +1 -1
- package/package.json +14 -9
package/dist/index.d.ts
CHANGED
|
@@ -1,79 +1,1071 @@
|
|
|
1
|
-
|
|
2
|
-
/**
|
|
3
|
-
* Opens the camera to scan QR codes
|
|
4
|
-
* @param {Object} [config] - Configuration object for QR code scanning
|
|
5
|
-
* @param {string} [config.title] - Title to display in camera view
|
|
6
|
-
* @returns {Promise<Object>} Promise that resolves to response object with status_code:
|
|
7
|
-
* - 200: Success with result.qrCode containing the scanned QR code
|
|
8
|
-
* - 204: No result (user cancelled or no QR code detected)
|
|
9
|
-
* - 403: Camera access denied with error message
|
|
10
|
-
*/
|
|
11
|
-
scanQRCode(config?: {
|
|
12
|
-
title?: string;
|
|
13
|
-
}): Promise<any>;
|
|
14
|
-
}
|
|
1
|
+
import { DataStream as DataStream_2 } from '@grabjs/mobile-kit-bridge-sdk';
|
|
15
2
|
|
|
16
|
-
|
|
17
|
-
|
|
3
|
+
/**
|
|
4
|
+
* Base class for all JSBridge modules.
|
|
5
|
+
*
|
|
6
|
+
* @remarks
|
|
7
|
+
* On construction, the class wraps the JSBridge module on `window` (e.g., `WrappedContainerModule`).
|
|
8
|
+
* Requires the MiniApp to be running within the Grab SuperApp's webview.
|
|
9
|
+
*
|
|
10
|
+
* @public
|
|
11
|
+
*/
|
|
12
|
+
export declare class BaseModule {
|
|
13
|
+
/**
|
|
14
|
+
* The module name used to identify the JSBridge module.
|
|
15
|
+
*/
|
|
16
|
+
private readonly name;
|
|
17
|
+
/**
|
|
18
|
+
* Returns the wrapped JSBridge module from the global `window` object.
|
|
19
|
+
*
|
|
20
|
+
* @returns The wrapped module instance with native method bindings.
|
|
21
|
+
*
|
|
22
|
+
* @internal
|
|
23
|
+
*/
|
|
24
|
+
protected get wrappedModule(): WrappedModule;
|
|
25
|
+
/**
|
|
26
|
+
* Creates a new module instance and wraps it on the global `window` object.
|
|
27
|
+
*
|
|
28
|
+
* @param moduleName - The name of the module (e.g., "ContainerModule", "ProfileModule").
|
|
29
|
+
* @throws Error when the bridge SDK fails to wrap the module.
|
|
30
|
+
*/
|
|
31
|
+
constructor(moduleName: string);
|
|
18
32
|
}
|
|
19
33
|
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
34
|
+
/**
|
|
35
|
+
* Error response from the JSBridge method.
|
|
36
|
+
*
|
|
37
|
+
* @remarks
|
|
38
|
+
* Returned when a JSBridge method fails.
|
|
39
|
+
* The `error` field contains a human-readable message.
|
|
40
|
+
*
|
|
41
|
+
* @public
|
|
42
|
+
*/
|
|
43
|
+
export declare type BridgeErrorResponse = {
|
|
44
|
+
/**
|
|
45
|
+
* Status codes:
|
|
46
|
+
*
|
|
47
|
+
* - `400`: Bad request (invalid parameters)
|
|
48
|
+
* - `403`: Forbidden (permission denied)
|
|
49
|
+
* - `404`: Not found (resource not found)
|
|
50
|
+
* - `424`: Failed dependency
|
|
51
|
+
* - `500`: Internal server error
|
|
52
|
+
*/
|
|
53
|
+
status_code: 400 | 403 | 404 | 424 | 500;
|
|
54
|
+
/** Always undefined for error responses */
|
|
55
|
+
result?: undefined;
|
|
56
|
+
/** Error message describing what went wrong */
|
|
57
|
+
error: string;
|
|
58
|
+
};
|
|
59
|
+
|
|
60
|
+
/**
|
|
61
|
+
* No result response from the JSBridge method.
|
|
62
|
+
*
|
|
63
|
+
* @remarks
|
|
64
|
+
* Returned when a JSBridge method completes with no content (e.g., user cancelled a dialog, redirect occurred).
|
|
65
|
+
* No `result` or `error` data is returned.
|
|
66
|
+
*
|
|
67
|
+
* @public
|
|
68
|
+
*/
|
|
69
|
+
export declare type BridgeNoResultResponse = {
|
|
70
|
+
/**
|
|
71
|
+
* Status codes:
|
|
72
|
+
*
|
|
73
|
+
* - `204`: No content (user cancelled or operation returned no data)
|
|
74
|
+
* - `302`: Redirect occurred
|
|
75
|
+
*/
|
|
76
|
+
status_code: 204 | 302;
|
|
77
|
+
/** Always undefined for no-result JSBridge responses */
|
|
78
|
+
result?: undefined;
|
|
79
|
+
/** Always undefined for no-result JSBridge responses */
|
|
80
|
+
error?: undefined;
|
|
81
|
+
};
|
|
82
|
+
|
|
83
|
+
/**
|
|
84
|
+
* Universal response format for all JSBridge methods.
|
|
85
|
+
*
|
|
86
|
+
* @remarks
|
|
87
|
+
* All JSBridge method calls resolve to this union type.
|
|
88
|
+
*
|
|
89
|
+
* @public
|
|
90
|
+
*/
|
|
91
|
+
export declare type BridgeResponse<T> = BridgeSuccessResponse<T> | BridgeNoResultResponse | BridgeErrorResponse;
|
|
25
92
|
|
|
26
|
-
|
|
27
|
-
|
|
93
|
+
/**
|
|
94
|
+
* Copyright (c) Grab Taxi Holdings PTE LTD (GRAB)
|
|
95
|
+
*
|
|
96
|
+
* This source code is licensed under the MIT license found in the LICENSE file in the root
|
|
97
|
+
* directory of this source tree.
|
|
98
|
+
*/
|
|
99
|
+
/**
|
|
100
|
+
* Success response from the bridge SDK.
|
|
101
|
+
*
|
|
102
|
+
* @remarks
|
|
103
|
+
* Returned when a JSBridge method completes successfully.
|
|
104
|
+
* The `result` field contains the JSBridge method's data.
|
|
105
|
+
*
|
|
106
|
+
* @public
|
|
107
|
+
*/
|
|
108
|
+
export declare type BridgeSuccessResponse<T> = {
|
|
109
|
+
/** Status code: `200` - JSBridge method completed successfully */
|
|
110
|
+
status_code: 200;
|
|
111
|
+
/** The result data from the successful JSBridge method */
|
|
112
|
+
result: T;
|
|
113
|
+
/** Always undefined for success responses */
|
|
114
|
+
error?: undefined;
|
|
115
|
+
};
|
|
116
|
+
|
|
117
|
+
/**
|
|
118
|
+
* JSBridge module for accessing the device camera.
|
|
119
|
+
*
|
|
120
|
+
* @group Modules
|
|
121
|
+
*
|
|
122
|
+
* @remarks
|
|
123
|
+
* Provides access to native camera functionality including QR code scanning.
|
|
124
|
+
* This code must run on the Grab SuperApp's webview to function correctly.
|
|
125
|
+
*
|
|
126
|
+
* @example
|
|
127
|
+
* **ES Module:**
|
|
128
|
+
* ```typescript
|
|
129
|
+
* import { CameraModule } from '@grabjs/superapp-sdk';
|
|
130
|
+
* const cameraModule = new CameraModule();
|
|
131
|
+
* ```
|
|
132
|
+
*
|
|
133
|
+
* @example
|
|
134
|
+
* **CDN (UMD):**
|
|
135
|
+
* ```html
|
|
136
|
+
* <script src="https://cdn.jsdelivr.net/npm/@grabjs/superapp-sdk/dist/index.js"></script>
|
|
137
|
+
* <script>
|
|
138
|
+
* const cameraModule = new SuperAppSDK.CameraModule();
|
|
139
|
+
* </script>
|
|
140
|
+
* ```
|
|
141
|
+
*
|
|
142
|
+
* @public
|
|
143
|
+
*/
|
|
144
|
+
export declare class CameraModule extends BaseModule {
|
|
145
|
+
constructor();
|
|
146
|
+
/**
|
|
147
|
+
* Opens the native camera to scan a QR code.
|
|
148
|
+
*
|
|
149
|
+
* @param request - Configuration for the scan.
|
|
150
|
+
*
|
|
151
|
+
* @returns Resolves with the scanned QR code content on success, or error information on failure.
|
|
152
|
+
*
|
|
153
|
+
* @throws Error when the JSBridge method fails unexpectedly.
|
|
154
|
+
*
|
|
155
|
+
* @example
|
|
156
|
+
* With title
|
|
157
|
+
* ```typescript
|
|
158
|
+
* const response = await cameraModule.scanQRCode({ title: 'Scan Payment QR' });
|
|
159
|
+
* ```
|
|
160
|
+
*
|
|
161
|
+
* @example
|
|
162
|
+
* Without title
|
|
163
|
+
* ```typescript
|
|
164
|
+
* const response = await cameraModule.scanQRCode({});
|
|
165
|
+
* ```
|
|
166
|
+
*
|
|
167
|
+
* @example
|
|
168
|
+
* Handling the response
|
|
169
|
+
* ```typescript
|
|
170
|
+
* try {
|
|
171
|
+
* const { status_code, result, error } = await cameraModule.scanQRCode(params);
|
|
172
|
+
* switch (status_code) {
|
|
173
|
+
* case 200:
|
|
174
|
+
* console.log('QR Code scanned:', result.qrCode);
|
|
175
|
+
* break;
|
|
176
|
+
* case 204:
|
|
177
|
+
* console.log('User cancelled scanning');
|
|
178
|
+
* break;
|
|
179
|
+
* default:
|
|
180
|
+
* console.log(`Could not scan QR code${error ? `: ${error}` : ''}`);
|
|
181
|
+
* break;
|
|
182
|
+
* }
|
|
183
|
+
* } catch (error) {
|
|
184
|
+
* console.log(`Could not scan QR code${error ? `: ${error}` : ''}`);
|
|
185
|
+
* }
|
|
186
|
+
* ```
|
|
187
|
+
*
|
|
188
|
+
* @public
|
|
189
|
+
*/
|
|
190
|
+
scanQRCode(request: ScanQRCodeRequest): Promise<ScanQRCodeResponse>;
|
|
28
191
|
}
|
|
29
192
|
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
193
|
+
/**
|
|
194
|
+
* JSBridge module for triggering native payment flows.
|
|
195
|
+
*
|
|
196
|
+
* @group Modules
|
|
197
|
+
*
|
|
198
|
+
* @remarks
|
|
199
|
+
* Invokes the native Grab checkout/pay component to process payments.
|
|
200
|
+
* Requires the MiniApp to be running within the Grab SuperApp's webview.
|
|
201
|
+
*
|
|
202
|
+
* @example
|
|
203
|
+
* **ES Module:**
|
|
204
|
+
* ```typescript
|
|
205
|
+
* import { CheckoutModule } from '@grabjs/superapp-sdk';
|
|
206
|
+
* const checkoutModule = new CheckoutModule();
|
|
207
|
+
* ```
|
|
208
|
+
*
|
|
209
|
+
* @example
|
|
210
|
+
* **CDN (UMD):**
|
|
211
|
+
* ```html
|
|
212
|
+
* <script src="https://cdn.jsdelivr.net/npm/@grabjs/superapp-sdk/dist/index.js"></script>
|
|
213
|
+
* <script>
|
|
214
|
+
* const checkoutModule = new SuperAppSDK.CheckoutModule();
|
|
215
|
+
* </script>
|
|
216
|
+
* ```
|
|
217
|
+
*
|
|
218
|
+
* @public
|
|
219
|
+
*/
|
|
220
|
+
export declare class CheckoutModule extends BaseModule {
|
|
221
|
+
constructor();
|
|
222
|
+
triggerCheckout(checkoutDetails: any): Promise<BridgeResponse<unknown>> | DataStream<unknown>;
|
|
35
223
|
}
|
|
36
224
|
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
225
|
+
/**
|
|
226
|
+
* Response when closing the container.
|
|
227
|
+
*
|
|
228
|
+
* @public
|
|
229
|
+
*/
|
|
230
|
+
export declare type CloseResponse = BridgeResponse<null>;
|
|
231
|
+
|
|
232
|
+
/**
|
|
233
|
+
* Constants for container analytics event data.
|
|
234
|
+
*
|
|
235
|
+
* @public
|
|
236
|
+
*/
|
|
237
|
+
export declare const ContainerAnalyticsEventData: {
|
|
238
|
+
TRANSACTION_AMOUNT: string;
|
|
239
|
+
TRANSACTION_CURRENCY: string;
|
|
240
|
+
PAGE: string;
|
|
241
|
+
};
|
|
242
|
+
|
|
243
|
+
/**
|
|
244
|
+
* Constants for container analytics event names.
|
|
245
|
+
*
|
|
246
|
+
* @public
|
|
247
|
+
*/
|
|
248
|
+
export declare const ContainerAnalyticsEventName: {
|
|
249
|
+
DEFAULT: string;
|
|
250
|
+
};
|
|
251
|
+
|
|
252
|
+
/**
|
|
253
|
+
* Constants for container analytics event states.
|
|
254
|
+
*
|
|
255
|
+
* @public
|
|
256
|
+
*/
|
|
257
|
+
export declare const ContainerAnalyticsEventState: {
|
|
258
|
+
HOMEPAGE: string;
|
|
259
|
+
CHECKOUT_PAGE: string;
|
|
260
|
+
BOOKING_COMPLETION: string;
|
|
261
|
+
CUSTOM: string;
|
|
262
|
+
};
|
|
263
|
+
|
|
264
|
+
/**
|
|
265
|
+
* JSBridge module for controlling the webview container.
|
|
266
|
+
*
|
|
267
|
+
* @group Modules
|
|
268
|
+
*
|
|
269
|
+
* @remarks
|
|
270
|
+
* Provides methods to interact with the webview container.
|
|
271
|
+
* This code must run on the Grab SuperApp's webview to function correctly.
|
|
272
|
+
*
|
|
273
|
+
* @example
|
|
274
|
+
* **ES Module:**
|
|
275
|
+
* ```typescript
|
|
276
|
+
* import { ContainerModule } from '@grabjs/superapp-sdk';
|
|
277
|
+
* const containerModule = new ContainerModule();
|
|
278
|
+
* ```
|
|
279
|
+
*
|
|
280
|
+
* @example
|
|
281
|
+
* **CDN (UMD):**
|
|
282
|
+
* ```html
|
|
283
|
+
* <script src="https://cdn.jsdelivr.net/npm/@grabjs/superapp-sdk/dist/index.js"></script>
|
|
284
|
+
* <script>
|
|
285
|
+
* const containerModule = new SuperAppSDK.ContainerModule();
|
|
286
|
+
* </script>
|
|
287
|
+
* ```
|
|
288
|
+
*
|
|
289
|
+
* @public
|
|
290
|
+
*/
|
|
291
|
+
export declare class ContainerModule extends BaseModule {
|
|
292
|
+
constructor();
|
|
293
|
+
/**
|
|
294
|
+
* Set the background color of the container header.
|
|
295
|
+
*
|
|
296
|
+
* @param request - Hexadecimal color value (e.g., "#ffffff", "#000000").
|
|
297
|
+
*
|
|
298
|
+
* @returns Resolves when the background color has been applied, or with error information if the request fails.
|
|
299
|
+
*
|
|
300
|
+
* @throws Error when the JSBridge method fails unexpectedly.
|
|
301
|
+
*
|
|
302
|
+
* @example
|
|
303
|
+
* Set background color to white
|
|
304
|
+
* ```typescript
|
|
305
|
+
* await containerModule.setBackgroundColor("#ffffff");
|
|
306
|
+
* ```
|
|
307
|
+
*
|
|
308
|
+
* @example
|
|
309
|
+
* Set background color to dark
|
|
310
|
+
* ```typescript
|
|
311
|
+
* await containerModule.setBackgroundColor("#1a1a1a");
|
|
312
|
+
* ```
|
|
313
|
+
*
|
|
314
|
+
* @example
|
|
315
|
+
* Handling the response
|
|
316
|
+
* ```typescript
|
|
317
|
+
* try {
|
|
318
|
+
* const { status_code, result, error } = await containerModule.setBackgroundColor(backgroundColor);
|
|
319
|
+
* switch (status_code) {
|
|
320
|
+
* case 200:
|
|
321
|
+
* console.log('Background color set successfully');
|
|
322
|
+
* break;
|
|
323
|
+
* default:
|
|
324
|
+
* console.log(`Could not set background color${error ? `: ${error}` : ''}`);
|
|
325
|
+
* break;
|
|
326
|
+
* }
|
|
327
|
+
* } catch (error) {
|
|
328
|
+
* console.log(`Could not set background color${error ? `: ${error}` : ''}`);
|
|
329
|
+
* }
|
|
330
|
+
* ```
|
|
331
|
+
*
|
|
332
|
+
* @public
|
|
333
|
+
*/
|
|
334
|
+
setBackgroundColor(request: SetBackgroundColorRequest): Promise<SetBackgroundColorResponse>;
|
|
335
|
+
/**
|
|
336
|
+
* Set the title of the container header.
|
|
337
|
+
*
|
|
338
|
+
* @param request - Title of the page.
|
|
339
|
+
*
|
|
340
|
+
* @returns Resolves when the title has been set in the navigation bar, or with error information if the request fails.
|
|
341
|
+
*
|
|
342
|
+
* @throws Error when the JSBridge method fails unexpectedly.
|
|
343
|
+
*
|
|
344
|
+
* @example
|
|
345
|
+
* Set title
|
|
346
|
+
* ```typescript
|
|
347
|
+
* await containerModule.setTitle("Home");
|
|
348
|
+
* ```
|
|
349
|
+
*
|
|
350
|
+
* @example
|
|
351
|
+
* Handling the response
|
|
352
|
+
* ```typescript
|
|
353
|
+
* try {
|
|
354
|
+
* const { status_code, result, error } = await containerModule.setTitle(title);
|
|
355
|
+
* switch (status_code) {
|
|
356
|
+
* case 200:
|
|
357
|
+
* console.log('Title set successfully');
|
|
358
|
+
* break;
|
|
359
|
+
* default:
|
|
360
|
+
* console.log(`Could not set title${error ? `: ${error}` : ''}`);
|
|
361
|
+
* break;
|
|
362
|
+
* }
|
|
363
|
+
* } catch (error) {
|
|
364
|
+
* console.log(`Could not set title${error ? `: ${error}` : ''}`);
|
|
365
|
+
* }
|
|
366
|
+
* ```
|
|
367
|
+
*
|
|
368
|
+
* @public
|
|
369
|
+
*/
|
|
370
|
+
setTitle(request: SetTitleRequest): Promise<SetTitleResponse>;
|
|
371
|
+
/**
|
|
372
|
+
* Hide the back button on the container header.
|
|
373
|
+
*
|
|
374
|
+
* @returns Resolves when the back button is hidden, or with error information if the request fails.
|
|
375
|
+
*
|
|
376
|
+
* @throws Error when the JSBridge method fails unexpectedly.
|
|
377
|
+
*
|
|
378
|
+
* @example
|
|
379
|
+
* Hide back button
|
|
380
|
+
* ```typescript
|
|
381
|
+
* await containerModule.hideBackButton();
|
|
382
|
+
* ```
|
|
383
|
+
*
|
|
384
|
+
* @example
|
|
385
|
+
* Handling the response
|
|
386
|
+
* ```typescript
|
|
387
|
+
* try {
|
|
388
|
+
* const { status_code, result, error } = await containerModule.hideBackButton();
|
|
389
|
+
* switch (status_code) {
|
|
390
|
+
* case 200:
|
|
391
|
+
* console.log('Back button hidden successfully');
|
|
392
|
+
* break;
|
|
393
|
+
* default:
|
|
394
|
+
* console.log(`Could not hide back button${error ? `: ${error}` : ''}`);
|
|
395
|
+
* break;
|
|
396
|
+
* }
|
|
397
|
+
* } catch (error) {
|
|
398
|
+
* console.log(`Could not hide back button${error ? `: ${error}` : ''}`);
|
|
399
|
+
* }
|
|
400
|
+
* ```
|
|
401
|
+
*
|
|
402
|
+
* @public
|
|
403
|
+
*/
|
|
404
|
+
hideBackButton(): Promise<HideBackButtonResponse>;
|
|
405
|
+
/**
|
|
406
|
+
* Show the back button on the container header.
|
|
407
|
+
*
|
|
408
|
+
* @returns Resolves when the back button is shown, or with error information if the request fails.
|
|
409
|
+
*
|
|
410
|
+
* @throws Error when the JSBridge method fails unexpectedly.
|
|
411
|
+
*
|
|
412
|
+
* @example
|
|
413
|
+
* Show back button
|
|
414
|
+
* ```typescript
|
|
415
|
+
* await containerModule.showBackButton();
|
|
416
|
+
* ```
|
|
417
|
+
*
|
|
418
|
+
* @example
|
|
419
|
+
* Handling the response
|
|
420
|
+
* ```typescript
|
|
421
|
+
* try {
|
|
422
|
+
* const { status_code, result, error } = await containerModule.showBackButton();
|
|
423
|
+
* switch (status_code) {
|
|
424
|
+
* case 200:
|
|
425
|
+
* console.log('Back button shown successfully');
|
|
426
|
+
* break;
|
|
427
|
+
* default:
|
|
428
|
+
* console.log(`Could not show back button${error ? `: ${error}` : ''}`);
|
|
429
|
+
* break;
|
|
430
|
+
* }
|
|
431
|
+
* } catch (error) {
|
|
432
|
+
* console.log(`Could not show back button${error ? `: ${error}` : ''}`);
|
|
433
|
+
* }
|
|
434
|
+
* ```
|
|
435
|
+
*
|
|
436
|
+
* @public
|
|
437
|
+
*/
|
|
438
|
+
showBackButton(): Promise<ShowBackButtonResponse>;
|
|
439
|
+
/**
|
|
440
|
+
* Hide the refresh button on the container header.
|
|
441
|
+
*
|
|
442
|
+
* @returns Resolves when the refresh button is hidden, or with error information if the request fails.
|
|
443
|
+
*
|
|
444
|
+
* @throws Error when the JSBridge method fails unexpectedly.
|
|
445
|
+
*
|
|
446
|
+
* @example
|
|
447
|
+
* Hide refresh button
|
|
448
|
+
* ```typescript
|
|
449
|
+
* await containerModule.hideRefreshButton();
|
|
450
|
+
* ```
|
|
451
|
+
*
|
|
452
|
+
* @example
|
|
453
|
+
* Handling the response
|
|
454
|
+
* ```typescript
|
|
455
|
+
* try {
|
|
456
|
+
* const { status_code, result, error } = await containerModule.hideRefreshButton();
|
|
457
|
+
* switch (status_code) {
|
|
458
|
+
* case 200:
|
|
459
|
+
* console.log('Refresh button hidden successfully');
|
|
460
|
+
* break;
|
|
461
|
+
* default:
|
|
462
|
+
* console.log(`Could not hide refresh button${error ? `: ${error}` : ''}`);
|
|
463
|
+
* break;
|
|
464
|
+
* }
|
|
465
|
+
* } catch (error) {
|
|
466
|
+
* console.log(`Could not hide refresh button${error ? `: ${error}` : ''}`);
|
|
467
|
+
* }
|
|
468
|
+
* ```
|
|
469
|
+
*
|
|
470
|
+
* @public
|
|
471
|
+
*/
|
|
472
|
+
hideRefreshButton(): Promise<HideRefreshButtonResponse>;
|
|
473
|
+
/**
|
|
474
|
+
* Show the refresh button on the container header.
|
|
475
|
+
*
|
|
476
|
+
* @returns Resolves when the refresh button is shown, or with error information if the request fails.
|
|
477
|
+
*
|
|
478
|
+
* @throws Error when the JSBridge method fails unexpectedly.
|
|
479
|
+
*
|
|
480
|
+
* @example
|
|
481
|
+
* Show refresh button
|
|
482
|
+
* ```typescript
|
|
483
|
+
* await containerModule.showRefreshButton();
|
|
484
|
+
* ```
|
|
485
|
+
*
|
|
486
|
+
* @example
|
|
487
|
+
* Handling the response
|
|
488
|
+
* ```typescript
|
|
489
|
+
* try {
|
|
490
|
+
* const { status_code, result, error } = await containerModule.showRefreshButton();
|
|
491
|
+
* switch (status_code) {
|
|
492
|
+
* case 200:
|
|
493
|
+
* console.log('Refresh button shown successfully');
|
|
494
|
+
* break;
|
|
495
|
+
* default:
|
|
496
|
+
* console.log(`Could not show refresh button${error ? `: ${error}` : ''}`);
|
|
497
|
+
* break;
|
|
498
|
+
* }
|
|
499
|
+
* } catch (error) {
|
|
500
|
+
* console.log(`Could not show refresh button${error ? `: ${error}` : ''}`);
|
|
501
|
+
* }
|
|
502
|
+
* ```
|
|
503
|
+
*
|
|
504
|
+
* @public
|
|
505
|
+
*/
|
|
506
|
+
showRefreshButton(): Promise<ShowRefreshButtonResponse>;
|
|
507
|
+
/**
|
|
508
|
+
* Close the container and return to the previous screen.
|
|
509
|
+
*
|
|
510
|
+
* @returns Resolves when the container closes and the webview is dismissed, or with error information if the request fails.
|
|
511
|
+
*
|
|
512
|
+
* @throws Error when the JSBridge method fails unexpectedly.
|
|
513
|
+
*
|
|
514
|
+
* @example
|
|
515
|
+
* Close after completing a task
|
|
516
|
+
* ```typescript
|
|
517
|
+
* await containerModule.close();
|
|
518
|
+
* ```
|
|
519
|
+
*
|
|
520
|
+
* @example
|
|
521
|
+
* Close button handler
|
|
522
|
+
* ```typescript
|
|
523
|
+
* closeButton.addEventListener('click', async () => {
|
|
524
|
+
* await containerModule.close();
|
|
525
|
+
* });
|
|
526
|
+
* ```
|
|
527
|
+
*
|
|
528
|
+
* @example
|
|
529
|
+
* Handling the response
|
|
530
|
+
* ```typescript
|
|
531
|
+
* try {
|
|
532
|
+
* const { status_code, result, error } = await containerModule.close();
|
|
533
|
+
* switch (status_code) {
|
|
534
|
+
* case 200:
|
|
535
|
+
* console.log('Container closed successfully');
|
|
536
|
+
* break;
|
|
537
|
+
* default:
|
|
538
|
+
* console.log(`Could not close container${error ? `: ${error}` : ''}`);
|
|
539
|
+
* break;
|
|
540
|
+
* }
|
|
541
|
+
* } catch (error) {
|
|
542
|
+
* console.log(`Could not close container${error ? `: ${error}` : ''}`);
|
|
543
|
+
* }
|
|
544
|
+
* ```
|
|
545
|
+
*
|
|
546
|
+
* @public
|
|
547
|
+
*/
|
|
548
|
+
close(): Promise<CloseResponse>;
|
|
549
|
+
/**
|
|
550
|
+
* Notify the Grab SuperApp that the page content has loaded.
|
|
551
|
+
*
|
|
552
|
+
* @returns Resolves when the content loaded notification is sent, or with error information if the request fails.
|
|
553
|
+
*
|
|
554
|
+
* @throws Error when the JSBridge method fails unexpectedly.
|
|
555
|
+
*
|
|
556
|
+
* @example
|
|
557
|
+
* Notify on page load
|
|
558
|
+
* ```typescript
|
|
559
|
+
* await containerModule.onContentLoaded();
|
|
560
|
+
* ```
|
|
561
|
+
*
|
|
562
|
+
* @example
|
|
563
|
+
* Handling the response
|
|
564
|
+
* ```typescript
|
|
565
|
+
* try {
|
|
566
|
+
* const { status_code, result, error } = await containerModule.onContentLoaded();
|
|
567
|
+
* switch (status_code) {
|
|
568
|
+
* case 200:
|
|
569
|
+
* console.log('Content loaded notification sent successfully');
|
|
570
|
+
* break;
|
|
571
|
+
* default:
|
|
572
|
+
* console.log(`Could not notify content loaded${error ? `: ${error}` : ''}`);
|
|
573
|
+
* break;
|
|
574
|
+
* }
|
|
575
|
+
* } catch (error) {
|
|
576
|
+
* console.log(`Could not notify content loaded${error ? `: ${error}` : ''}`);
|
|
577
|
+
* }
|
|
578
|
+
* ```
|
|
579
|
+
*
|
|
580
|
+
* @public
|
|
581
|
+
*/
|
|
582
|
+
onContentLoaded(): Promise<OnContentLoadedResponse>;
|
|
583
|
+
/**
|
|
584
|
+
* Show the full-screen loading indicator.
|
|
585
|
+
*
|
|
586
|
+
* @remarks
|
|
587
|
+
* Remember to call {@link ContainerModule.hideLoader} when the operation completes.
|
|
588
|
+
*
|
|
589
|
+
* @returns Resolves when the loading indicator is displayed, or with error information if the request fails.
|
|
590
|
+
*
|
|
591
|
+
* @throws Error when the JSBridge method fails unexpectedly.
|
|
592
|
+
*
|
|
593
|
+
* @example
|
|
594
|
+
* Show loader indicator
|
|
595
|
+
* ```typescript
|
|
596
|
+
* await containerModule.showLoader();
|
|
597
|
+
* ```
|
|
598
|
+
*
|
|
599
|
+
* @example
|
|
600
|
+
* Handling the response
|
|
601
|
+
* ```typescript
|
|
602
|
+
* try {
|
|
603
|
+
* const { status_code, result, error } = await containerModule.showLoader();
|
|
604
|
+
* switch (status_code) {
|
|
605
|
+
* case 200:
|
|
606
|
+
* console.log('Loader shown successfully');
|
|
607
|
+
* break;
|
|
608
|
+
* default:
|
|
609
|
+
* console.log(`Could not show loader${error ? `: ${error}` : ''}`);
|
|
610
|
+
* break;
|
|
611
|
+
* }
|
|
612
|
+
* } catch (error) {
|
|
613
|
+
* console.log(`Could not show loader${error ? `: ${error}` : ''}`);
|
|
614
|
+
* }
|
|
615
|
+
* ```
|
|
616
|
+
*
|
|
617
|
+
* @public
|
|
618
|
+
*/
|
|
619
|
+
showLoader(): Promise<ShowLoaderResponse>;
|
|
620
|
+
/**
|
|
621
|
+
* Hide the full-screen loading indicator.
|
|
622
|
+
*
|
|
623
|
+
* @remarks
|
|
624
|
+
* Should be called when the entry point has finished loading.
|
|
625
|
+
*
|
|
626
|
+
* @returns Resolves when the loading indicator is hidden, or with error information if the request fails.
|
|
627
|
+
*
|
|
628
|
+
* @throws Error when the JSBridge method fails unexpectedly.
|
|
629
|
+
*
|
|
630
|
+
* @example
|
|
631
|
+
* Hide loader
|
|
632
|
+
* ```typescript
|
|
633
|
+
* await containerModule.hideLoader();
|
|
634
|
+
* ```
|
|
635
|
+
*
|
|
636
|
+
* @example
|
|
637
|
+
* Handling the response
|
|
638
|
+
* ```typescript
|
|
639
|
+
* try {
|
|
640
|
+
* const { status_code, result, error } = await containerModule.hideLoader();
|
|
641
|
+
* switch (status_code) {
|
|
642
|
+
* case 200:
|
|
643
|
+
* console.log('Loader hidden successfully');
|
|
644
|
+
* break;
|
|
645
|
+
* default:
|
|
646
|
+
* console.log(`Could not hide loader${error ? `: ${error}` : ''}`);
|
|
647
|
+
* break;
|
|
648
|
+
* }
|
|
649
|
+
* } catch (error) {
|
|
650
|
+
* console.log(`Could not hide loader${error ? `: ${error}` : ''}`);
|
|
651
|
+
* }
|
|
652
|
+
* ```
|
|
653
|
+
*
|
|
654
|
+
* @public
|
|
655
|
+
*/
|
|
656
|
+
hideLoader(): Promise<HideLoaderResponse>;
|
|
657
|
+
/**
|
|
658
|
+
* Open a link in the external browser.
|
|
659
|
+
*
|
|
660
|
+
* @remarks
|
|
661
|
+
* Call this method to open the specified URL in an external browser (outside of the Grab app).
|
|
662
|
+
*
|
|
663
|
+
* @param request - URL to open in external browser.
|
|
664
|
+
*
|
|
665
|
+
* @returns Resolves when the external browser opens with the URL, or with error information if the request fails.
|
|
666
|
+
*
|
|
667
|
+
* @throws Error when the JSBridge method fails unexpectedly.
|
|
668
|
+
*
|
|
669
|
+
* @example
|
|
670
|
+
* Open external link
|
|
671
|
+
* ```typescript
|
|
672
|
+
* await containerModule.openExternalLink("https://grab.com");
|
|
673
|
+
* ```
|
|
674
|
+
*
|
|
675
|
+
* @example
|
|
676
|
+
* Handling the response
|
|
677
|
+
* ```typescript
|
|
678
|
+
* try {
|
|
679
|
+
* const { status_code, result, error } = await containerModule.openExternalLink(url);
|
|
680
|
+
* switch (status_code) {
|
|
681
|
+
* case 200:
|
|
682
|
+
* console.log('External link opened successfully');
|
|
683
|
+
* break;
|
|
684
|
+
* default:
|
|
685
|
+
* console.log(`Could not open external link${error ? `: ${error}` : ''}`);
|
|
686
|
+
* break;
|
|
687
|
+
* }
|
|
688
|
+
* } catch (error) {
|
|
689
|
+
* console.log(`Could not open external link${error ? `: ${error}` : ''}`);
|
|
690
|
+
* }
|
|
691
|
+
* ```
|
|
692
|
+
*
|
|
693
|
+
* @public
|
|
694
|
+
*/
|
|
695
|
+
openExternalLink(request: OpenExternalLinkRequest): Promise<OpenExternalLinkResponse>;
|
|
696
|
+
/**
|
|
697
|
+
* Notify the client that the user has tapped a call-to-action (CTA).
|
|
698
|
+
*
|
|
699
|
+
* @param request - CTA action identifier (e.g., "AV_LANDING_PAGE_CONTINUE", "BOOKING_CONFIRMED").
|
|
700
|
+
*
|
|
701
|
+
* @returns Resolves when the CTA tap notification is sent, or with error information if the request fails.
|
|
702
|
+
*
|
|
703
|
+
* @throws Error when the JSBridge method fails unexpectedly.
|
|
704
|
+
*
|
|
705
|
+
* @example
|
|
706
|
+
* Notify CTA tap
|
|
707
|
+
* ```typescript
|
|
708
|
+
* await containerModule.onCtaTap("AV_LANDING_PAGE_CONTINUE");
|
|
709
|
+
* ```
|
|
710
|
+
*
|
|
711
|
+
* @example
|
|
712
|
+
* Handling the response
|
|
713
|
+
* ```typescript
|
|
714
|
+
* try {
|
|
715
|
+
* const { status_code, result, error } = await containerModule.onCtaTap(action);
|
|
716
|
+
* switch (status_code) {
|
|
717
|
+
* case 200:
|
|
718
|
+
* console.log('CTA tap notified successfully');
|
|
719
|
+
* break;
|
|
720
|
+
* default:
|
|
721
|
+
* console.log(`Could not notify CTA tap${error ? `: ${error}` : ''}`);
|
|
722
|
+
* break;
|
|
723
|
+
* }
|
|
724
|
+
* } catch (error) {
|
|
725
|
+
* console.log(`Could not notify CTA tap${error ? `: ${error}` : ''}`);
|
|
726
|
+
* }
|
|
727
|
+
* ```
|
|
728
|
+
*
|
|
729
|
+
* @public
|
|
730
|
+
*/
|
|
731
|
+
onCtaTap(request: OnCtaTapRequest): Promise<OnCtaTapResponse>;
|
|
732
|
+
/**
|
|
733
|
+
* Use this method to track user interactions and page transitions.
|
|
734
|
+
*
|
|
735
|
+
* @remarks
|
|
736
|
+
* You can use predefined constants to ensure consistency across the platform.
|
|
737
|
+
*
|
|
738
|
+
* **Predefined Values:**
|
|
739
|
+
* - **States:** {@link ContainerAnalyticsEventState}
|
|
740
|
+
* - **Names:** {@link ContainerAnalyticsEventName}
|
|
741
|
+
* - **Data Keys:** {@link ContainerAnalyticsEventData}
|
|
742
|
+
*
|
|
743
|
+
* @param request - Details of the analytics event to be sent to the container.
|
|
744
|
+
*
|
|
745
|
+
* @returns Resolves when the analytics event is sent to the container, or with error information if the request fails.
|
|
746
|
+
*
|
|
747
|
+
* @throws Error when the JSBridge method fails unexpectedly.
|
|
748
|
+
*
|
|
749
|
+
* @see {@link ContainerAnalyticsEventState}, {@link ContainerAnalyticsEventName}, {@link ContainerAnalyticsEventData}
|
|
750
|
+
*
|
|
751
|
+
* @example
|
|
752
|
+
* Send a DEFAULT event for HOMEPAGE state
|
|
753
|
+
* ```typescript
|
|
754
|
+
* import {
|
|
755
|
+
* ContainerAnalyticsEventState,
|
|
756
|
+
* ContainerAnalyticsEventName,
|
|
757
|
+
* } from "@grabjs/superapp-sdk";
|
|
758
|
+
*
|
|
759
|
+
* await containerModule.sendAnalyticsEvent({
|
|
760
|
+
* state: ContainerAnalyticsEventState.HOMEPAGE,
|
|
761
|
+
* name: ContainerAnalyticsEventName.DEFAULT,
|
|
762
|
+
* });
|
|
763
|
+
* ```
|
|
764
|
+
*
|
|
765
|
+
* @example
|
|
766
|
+
* Send a BOOK event for CHECKOUT_PAGE state with standard data keys
|
|
767
|
+
* ```typescript
|
|
768
|
+
* import {
|
|
769
|
+
* ContainerAnalyticsEventState,
|
|
770
|
+
* ContainerAnalyticsEventData,
|
|
771
|
+
* } from "@grabjs/superapp-sdk";
|
|
772
|
+
*
|
|
773
|
+
* await containerModule.sendAnalyticsEvent({
|
|
774
|
+
* state: ContainerAnalyticsEventState.CHECKOUT_PAGE,
|
|
775
|
+
* name: "BOOK",
|
|
776
|
+
* data: {
|
|
777
|
+
* [ContainerAnalyticsEventData.TRANSACTION_AMOUNT]: 100,
|
|
778
|
+
* [ContainerAnalyticsEventData.TRANSACTION_CURRENCY]: "SGD",
|
|
779
|
+
* },
|
|
780
|
+
* });
|
|
781
|
+
* ```
|
|
782
|
+
*
|
|
783
|
+
* @example
|
|
784
|
+
* Send a CLICK_RIDE event for CUSTOM state with custom metadata
|
|
785
|
+
* ```typescript
|
|
786
|
+
* import {
|
|
787
|
+
* ContainerAnalyticsEventState,
|
|
788
|
+
* ContainerAnalyticsEventData,
|
|
789
|
+
* } from "@grabjs/superapp-sdk";
|
|
790
|
+
*
|
|
791
|
+
* await containerModule.sendAnalyticsEvent({
|
|
792
|
+
* state: ContainerAnalyticsEventState.CUSTOM,
|
|
793
|
+
* name: "CLICK_RIDE",
|
|
794
|
+
* data: {
|
|
795
|
+
* [ContainerAnalyticsEventData.PAGE]: "LIST_RIDES",
|
|
796
|
+
* departure_time: "2025-06-01 08:00:00",
|
|
797
|
+
* arrival_time: "2025-06-01 10:30:00",
|
|
798
|
+
* departure_address: "6 Bayfront Ave, Singapore 018974",
|
|
799
|
+
* arrival_address:
|
|
800
|
+
* "Petronas Twin Tower, Kuala Lumpur City Centre, 50088 Kuala Lumpur, Malaysia",
|
|
801
|
+
* },
|
|
802
|
+
* });
|
|
803
|
+
* ```
|
|
804
|
+
*
|
|
805
|
+
* @example
|
|
806
|
+
* Handling the response
|
|
807
|
+
* ```typescript
|
|
808
|
+
* try {
|
|
809
|
+
* const { status_code, result, error } = await containerModule.sendAnalyticsEvent(params);
|
|
810
|
+
* switch (status_code) {
|
|
811
|
+
* case 200:
|
|
812
|
+
* console.log('Analytics event sent successfully');
|
|
813
|
+
* break;
|
|
814
|
+
* default:
|
|
815
|
+
* console.log(`Could not send analytics event${error ? `: ${error}` : ''}`);
|
|
816
|
+
* break;
|
|
817
|
+
* }
|
|
818
|
+
* } catch (error) {
|
|
819
|
+
* console.log(`Could not send analytics event${error ? `: ${error}` : ''}`);
|
|
820
|
+
* }
|
|
821
|
+
* ```
|
|
822
|
+
*
|
|
823
|
+
* @public
|
|
824
|
+
*/
|
|
825
|
+
sendAnalyticsEvent(request: SendAnalyticsEventRequest): Promise<SendAnalyticsEventResponse>;
|
|
826
|
+
/**
|
|
827
|
+
* Check if the web app is connected to the Grab SuperApp via JSBridge.
|
|
828
|
+
*
|
|
829
|
+
* @remarks
|
|
830
|
+
* Call this method to verify the connection status before using other features.
|
|
831
|
+
*
|
|
832
|
+
* @returns Resolves with the JSBridge connection status to the Grab SuperApp, or with error information if the request fails.
|
|
833
|
+
*
|
|
834
|
+
* @throws Error when the JSBridge method fails unexpectedly.
|
|
835
|
+
*
|
|
836
|
+
* @example
|
|
837
|
+
* Check connection status
|
|
838
|
+
* ```typescript
|
|
839
|
+
* const response = await containerModule.isConnected();
|
|
840
|
+
* ```
|
|
841
|
+
*
|
|
842
|
+
* @example
|
|
843
|
+
* Handling the response
|
|
844
|
+
* ```typescript
|
|
845
|
+
* try {
|
|
846
|
+
* const response = await containerModule.isConnected();
|
|
847
|
+
* if (response.status_code === 200) {
|
|
848
|
+
* console.log('Connected to Grab SuperApp');
|
|
849
|
+
* } else {
|
|
850
|
+
* console.log('Not connected to Grab SuperApp');
|
|
851
|
+
* }
|
|
852
|
+
* } catch (error) {
|
|
853
|
+
* console.log(`Could not check connection${error ? `: ${error}` : ''}`);
|
|
854
|
+
* }
|
|
855
|
+
* ```
|
|
856
|
+
*
|
|
857
|
+
* @public
|
|
858
|
+
*/
|
|
859
|
+
isConnected(): Promise<IsConnectedResponse>;
|
|
860
|
+
/**
|
|
861
|
+
* Get the session parameters from the container.
|
|
862
|
+
*
|
|
863
|
+
* @remarks
|
|
864
|
+
* The native layer returns session parameters as a JSON string.
|
|
865
|
+
* Parse with `JSON.parse(result.result)` to use as an object.
|
|
866
|
+
* Session parameters can contain primitives, base64 encoded strings, or nested objects.
|
|
867
|
+
*
|
|
868
|
+
* @returns Resolves with session parameters from the container, or with error information if the request fails.
|
|
869
|
+
*
|
|
870
|
+
* @throws Error when the JSBridge method fails unexpectedly.
|
|
871
|
+
*
|
|
872
|
+
* @example
|
|
873
|
+
* Get session parameters
|
|
874
|
+
* ```typescript
|
|
875
|
+
* const { result } = await containerModule.getSessionParams();
|
|
876
|
+
* if (result?.result) {
|
|
877
|
+
* const sessionParams = JSON.parse(result.result);
|
|
878
|
+
* console.log("Session parameters:", sessionParams);
|
|
879
|
+
* if (sessionParams.param1) {
|
|
880
|
+
* configureFeature(sessionParams.param1);
|
|
881
|
+
* }
|
|
882
|
+
* }
|
|
883
|
+
* ```
|
|
884
|
+
*
|
|
885
|
+
* @example
|
|
886
|
+
* Get user ID from session params
|
|
887
|
+
* ```typescript
|
|
888
|
+
* const { result } = await containerModule.getSessionParams();
|
|
889
|
+
* const params = JSON.parse(result?.result || '{}');
|
|
890
|
+
* return params.userId;
|
|
891
|
+
* ```
|
|
892
|
+
*
|
|
893
|
+
* @example
|
|
894
|
+
* Handling the response
|
|
895
|
+
* ```typescript
|
|
896
|
+
* try {
|
|
897
|
+
* const { status_code, result, error } = await containerModule.getSessionParams();
|
|
898
|
+
* switch (status_code) {
|
|
899
|
+
* case 200:
|
|
900
|
+
* const sessionParams = JSON.parse(result?.result || '{}');
|
|
901
|
+
* console.log('Session params retrieved:', sessionParams);
|
|
902
|
+
* break;
|
|
903
|
+
* default:
|
|
904
|
+
* console.log(`Could not get session params${error ? `: ${error}` : ''}`);
|
|
905
|
+
* break;
|
|
906
|
+
* }
|
|
907
|
+
* } catch (error) {
|
|
908
|
+
* console.log(`Could not get session params${error ? `: ${error}` : ''}`);
|
|
909
|
+
* }
|
|
910
|
+
* ```
|
|
911
|
+
*
|
|
912
|
+
* @public
|
|
913
|
+
*/
|
|
914
|
+
getSessionParams(): Promise<GetSessionParamsResponse>;
|
|
915
|
+
/**
|
|
916
|
+
* Validate the analytics event details.
|
|
917
|
+
*
|
|
918
|
+
* @param request - Analytics event details to be validated.
|
|
919
|
+
* @returns Error message if invalid, `null` if valid.
|
|
920
|
+
* @internal
|
|
921
|
+
*/
|
|
922
|
+
private validateAnalyticsEvent;
|
|
56
923
|
}
|
|
57
924
|
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
925
|
+
/**
|
|
926
|
+
* A stream for receiving continuous data from JSBridge methods (e.g., location updates).
|
|
927
|
+
*
|
|
928
|
+
* @remarks
|
|
929
|
+
* Provides both Observable-like and Promise-like interfaces:
|
|
930
|
+
* - Use `subscribe()` to receive all values over time
|
|
931
|
+
* - Use `then()` or `await` to receive only the first value
|
|
932
|
+
*
|
|
933
|
+
* Note: Each `subscribe()` call creates a fresh subscription, allowing multiple independent listeners.
|
|
934
|
+
*
|
|
935
|
+
* @typeParam T - The type of data emitted by the stream.
|
|
936
|
+
*
|
|
937
|
+
* @public
|
|
938
|
+
*/
|
|
939
|
+
export declare type DataStream<T> = Readonly<{
|
|
940
|
+
/**
|
|
941
|
+
* Subscribe to receive stream data.
|
|
942
|
+
* @param handlers - Optional callbacks for data (`next`) and completion (`complete`).
|
|
943
|
+
* @returns A `Subscription` to terminate the stream when needed.
|
|
944
|
+
*/
|
|
945
|
+
subscribe: (handlers?: DataStreamHandlers<T>) => Subscription;
|
|
946
|
+
}> & PromiseLike<BridgeResponse<T>>;
|
|
947
|
+
|
|
948
|
+
/**
|
|
949
|
+
* Callbacks for handling stream events.
|
|
950
|
+
*
|
|
951
|
+
* @remarks
|
|
952
|
+
* Pass these to `subscribe()` to receive data via `next` and completion via `complete`.
|
|
953
|
+
*
|
|
954
|
+
* @typeParam T - The type of data emitted by the stream.
|
|
955
|
+
*
|
|
956
|
+
* @public
|
|
957
|
+
*/
|
|
958
|
+
export declare type DataStreamHandlers<T> = Readonly<{
|
|
959
|
+
/** Called with each new value from the stream. */
|
|
960
|
+
next?: (data: BridgeResponse<T>) => unknown;
|
|
961
|
+
/** Called when the stream ends and no more data will arrive. */
|
|
962
|
+
complete?: () => unknown;
|
|
963
|
+
}>;
|
|
964
|
+
|
|
965
|
+
/**
|
|
966
|
+
* Response when getting the device coordinates.
|
|
967
|
+
*
|
|
968
|
+
* @public
|
|
969
|
+
*/
|
|
970
|
+
export declare type GetCoordinateResponse = BridgeResponse<GetCoordinateResult>;
|
|
971
|
+
|
|
972
|
+
/**
|
|
973
|
+
* Result object containing the geographic coordinates.
|
|
974
|
+
*
|
|
975
|
+
* @public
|
|
976
|
+
*/
|
|
977
|
+
export declare type GetCoordinateResult = {
|
|
978
|
+
/** Latitude in degrees */
|
|
979
|
+
lat: number;
|
|
980
|
+
/** Longitude in degrees */
|
|
981
|
+
lng: number;
|
|
982
|
+
};
|
|
983
|
+
|
|
984
|
+
/**
|
|
985
|
+
* Response when getting the country code.
|
|
986
|
+
*
|
|
987
|
+
* @public
|
|
988
|
+
*/
|
|
989
|
+
export declare type GetCountryCodeResponse = BridgeResponse<GetCountryCodeResult>;
|
|
990
|
+
|
|
991
|
+
/**
|
|
992
|
+
* Result object containing the country code.
|
|
993
|
+
*
|
|
994
|
+
* @public
|
|
995
|
+
*/
|
|
996
|
+
export declare type GetCountryCodeResult = {
|
|
997
|
+
/** ISO country code (e.g., "SG", "ID", "MY") */
|
|
998
|
+
countryCode: string;
|
|
999
|
+
};
|
|
1000
|
+
|
|
1001
|
+
/**
|
|
1002
|
+
* Response when getting session parameters.
|
|
1003
|
+
*
|
|
1004
|
+
* @public
|
|
1005
|
+
*/
|
|
1006
|
+
export declare type GetSessionParamsResponse = BridgeResponse<GetSessionParamsResult>;
|
|
1007
|
+
|
|
1008
|
+
/**
|
|
1009
|
+
* Result object containing session parameters as a JSON string.
|
|
1010
|
+
*
|
|
1011
|
+
* @public
|
|
1012
|
+
*/
|
|
1013
|
+
export declare type GetSessionParamsResult = {
|
|
1014
|
+
/** JSON string containing session parameters. Parse with `JSON.parse(result)` to use as an object. */
|
|
1015
|
+
result: string;
|
|
1016
|
+
};
|
|
1017
|
+
|
|
1018
|
+
/**
|
|
1019
|
+
* Response when hiding the back button.
|
|
1020
|
+
*
|
|
1021
|
+
* @public
|
|
1022
|
+
*/
|
|
1023
|
+
export declare type HideBackButtonResponse = BridgeResponse<null>;
|
|
1024
|
+
|
|
1025
|
+
/**
|
|
1026
|
+
* Response when hiding the loader.
|
|
1027
|
+
*
|
|
1028
|
+
* @public
|
|
1029
|
+
*/
|
|
1030
|
+
export declare type HideLoaderResponse = BridgeResponse<null>;
|
|
1031
|
+
|
|
1032
|
+
/**
|
|
1033
|
+
* Response when hiding the refresh button.
|
|
1034
|
+
*
|
|
1035
|
+
* @public
|
|
1036
|
+
*/
|
|
1037
|
+
export declare type HideRefreshButtonResponse = BridgeResponse<null>;
|
|
1038
|
+
|
|
1039
|
+
/**
|
|
1040
|
+
* JSBridge module for authenticating users via GrabID.
|
|
1041
|
+
*
|
|
1042
|
+
* @group Modules
|
|
1043
|
+
*
|
|
1044
|
+
* @remarks
|
|
1045
|
+
* Handles OAuth2/OIDC authentication flows with PKCE support, enabling MiniApps to obtain user identity tokens.
|
|
1046
|
+
* Supports both native in-app consent and web-based fallback flows.
|
|
1047
|
+
* Requires the MiniApp to be running within the Grab SuperApp's webview.
|
|
1048
|
+
*
|
|
1049
|
+
* @example
|
|
1050
|
+
* **ES Module:**
|
|
1051
|
+
* ```typescript
|
|
1052
|
+
* import { IdentityModule } from '@grabjs/superapp-sdk';
|
|
1053
|
+
* const identity = new IdentityModule();
|
|
1054
|
+
* ```
|
|
1055
|
+
*
|
|
1056
|
+
* @example
|
|
1057
|
+
* **CDN (UMD):**
|
|
1058
|
+
* ```html
|
|
1059
|
+
* <script src="https://cdn.jsdelivr.net/npm/@grabjs/superapp-sdk/dist/index.js"></script>
|
|
1060
|
+
* <script>
|
|
1061
|
+
* const identity = new SuperAppSDK.IdentityModule();
|
|
1062
|
+
* </script>
|
|
1063
|
+
* ```
|
|
1064
|
+
*
|
|
1065
|
+
* @public
|
|
1066
|
+
*/
|
|
1067
|
+
export declare class IdentityModule extends BaseModule {
|
|
1068
|
+
constructor();
|
|
77
1069
|
get NAMESPACE(): string;
|
|
78
1070
|
get CODE_CHALLENGE_METHOD(): string;
|
|
79
1071
|
get NONCE_LENGTH(): number;
|
|
@@ -84,6 +1076,10 @@ export declare class IdentityModule {
|
|
|
84
1076
|
production: string;
|
|
85
1077
|
};
|
|
86
1078
|
fetchAuthorizationEndpoint(environment: any): Promise<any>;
|
|
1079
|
+
static generateRandomString(length: any): string;
|
|
1080
|
+
static base64URLEncode(str: any): any;
|
|
1081
|
+
static generateCodeVerifier(len: any): any;
|
|
1082
|
+
static generateCodeChallenge(codeVerifier: any): any;
|
|
87
1083
|
generatePKCEArtifacts(): {
|
|
88
1084
|
nonce: string;
|
|
89
1085
|
state: string;
|
|
@@ -104,6 +1100,17 @@ export declare class IdentityModule {
|
|
|
104
1100
|
}>;
|
|
105
1101
|
setStorageItem(key: any, value: any): void;
|
|
106
1102
|
getStorageItem(key: any): string;
|
|
1103
|
+
static normalizeUrl(urlString: any): string;
|
|
1104
|
+
static buildAuthorizeUrl(authorizationEndpoint: any, requestMap: any): string;
|
|
1105
|
+
static parseGrabUserAgent(userAgent: any): {
|
|
1106
|
+
appName: string;
|
|
1107
|
+
major: number;
|
|
1108
|
+
minor: number;
|
|
1109
|
+
patch: number;
|
|
1110
|
+
platform: string;
|
|
1111
|
+
};
|
|
1112
|
+
static isVersionBelow(current: any, min: any): boolean;
|
|
1113
|
+
static shouldUseWebConsent(request: any): boolean;
|
|
107
1114
|
performWebAuthorization(params: any): Promise<{
|
|
108
1115
|
status_code: number;
|
|
109
1116
|
error: any;
|
|
@@ -111,28 +1118,338 @@ export declare class IdentityModule {
|
|
|
111
1118
|
status_code: number;
|
|
112
1119
|
result: any;
|
|
113
1120
|
}>;
|
|
114
|
-
|
|
1121
|
+
performNativeAuthorization(invokeParams: any): Promise<BridgeResponse<unknown>>;
|
|
1122
|
+
authorize(request: any): Promise<BridgeNoResultResponse | {
|
|
1123
|
+
status_code: number;
|
|
1124
|
+
error: any;
|
|
1125
|
+
} | {
|
|
1126
|
+
status_code: number;
|
|
1127
|
+
result: any;
|
|
1128
|
+
}>;
|
|
1129
|
+
static validateRequiredString(value: any, fieldName: any): string;
|
|
1130
|
+
static validateAuthorizeRequest(request: any): string;
|
|
115
1131
|
}
|
|
116
1132
|
|
|
117
|
-
|
|
118
|
-
|
|
1133
|
+
/**
|
|
1134
|
+
* Response when checking connection status.
|
|
1135
|
+
*
|
|
1136
|
+
* @public
|
|
1137
|
+
*/
|
|
1138
|
+
export declare type IsConnectedResponse = BridgeResponse<IsConnectedResult>;
|
|
1139
|
+
|
|
1140
|
+
/**
|
|
1141
|
+
* Result object containing the connection status.
|
|
1142
|
+
*
|
|
1143
|
+
* @public
|
|
1144
|
+
*/
|
|
1145
|
+
export declare type IsConnectedResult = {
|
|
1146
|
+
/** Whether the MiniApp is connected to the Grab app. */
|
|
1147
|
+
connected: boolean;
|
|
1148
|
+
};
|
|
1149
|
+
|
|
1150
|
+
/**
|
|
1151
|
+
* JSBridge module for accessing device locale settings.
|
|
1152
|
+
*
|
|
1153
|
+
* @group Modules
|
|
1154
|
+
*
|
|
1155
|
+
* @remarks
|
|
1156
|
+
* Provides the user's preferred language and region settings from the native device.
|
|
1157
|
+
* Requires the MiniApp to be running within the Grab SuperApp's webview.
|
|
1158
|
+
*
|
|
1159
|
+
* @example
|
|
1160
|
+
* **ES Module:**
|
|
1161
|
+
* ```typescript
|
|
1162
|
+
* import { LocaleModule } from '@grabjs/superapp-sdk';
|
|
1163
|
+
* const locale = new LocaleModule();
|
|
1164
|
+
* ```
|
|
1165
|
+
*
|
|
1166
|
+
* @example
|
|
1167
|
+
* **CDN (UMD):**
|
|
1168
|
+
* ```html
|
|
1169
|
+
* <script src="https://cdn.jsdelivr.net/npm/@grabjs/superapp-sdk/dist/index.js"></script>
|
|
1170
|
+
* <script>
|
|
1171
|
+
* const locale = new SuperAppSDK.LocaleModule();
|
|
1172
|
+
* </script>
|
|
1173
|
+
* ```
|
|
1174
|
+
*
|
|
1175
|
+
* @public
|
|
1176
|
+
*/
|
|
1177
|
+
export declare class LocaleModule extends BaseModule {
|
|
1178
|
+
constructor();
|
|
1179
|
+
getLanguageLocaleIdentifier(): Promise<BridgeResponse<unknown>> | DataStream<unknown>;
|
|
119
1180
|
}
|
|
120
1181
|
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
1182
|
+
/**
|
|
1183
|
+
* JSBridge module for accessing device location services.
|
|
1184
|
+
*
|
|
1185
|
+
* @group Modules
|
|
1186
|
+
*
|
|
1187
|
+
* @remarks
|
|
1188
|
+
* Provides access to the device's geolocation data including coordinates and country code.
|
|
1189
|
+
* Requires the MiniApp to be running within the Grab SuperApp's webview.
|
|
1190
|
+
*
|
|
1191
|
+
* @example
|
|
1192
|
+
* **ES Module:**
|
|
1193
|
+
* ```typescript
|
|
1194
|
+
* import { LocationModule } from '@grabjs/superapp-sdk';
|
|
1195
|
+
* const location = new LocationModule();
|
|
1196
|
+
* ```
|
|
1197
|
+
*
|
|
1198
|
+
* @example
|
|
1199
|
+
* **CDN (UMD):**
|
|
1200
|
+
* ```html
|
|
1201
|
+
* <script src="https://cdn.jsdelivr.net/npm/@grabjs/superapp-sdk/dist/index.js"></script>
|
|
1202
|
+
* <script>
|
|
1203
|
+
* const location = new SuperAppSDK.LocationModule();
|
|
1204
|
+
* </script>
|
|
1205
|
+
* ```
|
|
1206
|
+
*
|
|
1207
|
+
* @public
|
|
1208
|
+
*/
|
|
1209
|
+
export declare class LocationModule extends BaseModule {
|
|
1210
|
+
constructor();
|
|
1211
|
+
/**
|
|
1212
|
+
* Get the current geographic coordinates of the device.
|
|
1213
|
+
*
|
|
1214
|
+
* @returns Resolves with the device's latitude and longitude coordinates, or error information if the request fails.
|
|
1215
|
+
*
|
|
1216
|
+
* @throws Error when the JSBridge method fails unexpectedly.
|
|
1217
|
+
*
|
|
1218
|
+
* @example
|
|
1219
|
+
* Get current coordinates
|
|
1220
|
+
* ```typescript
|
|
1221
|
+
* const response = await locationModule.getCoordinate();
|
|
1222
|
+
* ```
|
|
1223
|
+
*
|
|
1224
|
+
* @example
|
|
1225
|
+
* Handling the response
|
|
1226
|
+
* ```typescript
|
|
1227
|
+
* try {
|
|
1228
|
+
* const { status_code, result, error } = await locationModule.getCoordinate();
|
|
1229
|
+
* switch (status_code) {
|
|
1230
|
+
* case 200:
|
|
1231
|
+
* console.log('Coordinates:', result.lat, result.lng);
|
|
1232
|
+
* break;
|
|
1233
|
+
* default:
|
|
1234
|
+
* console.log(`Could not get coordinates${error ? `: ${error}` : ''}`);
|
|
1235
|
+
* break;
|
|
1236
|
+
* }
|
|
1237
|
+
* } catch (error) {
|
|
1238
|
+
* console.log(`Could not get coordinates${error ? `: ${error}` : ''}`);
|
|
1239
|
+
* }
|
|
1240
|
+
* ```
|
|
1241
|
+
*
|
|
1242
|
+
* @public
|
|
1243
|
+
*/
|
|
1244
|
+
getCoordinate(): Promise<GetCoordinateResponse>;
|
|
1245
|
+
/**
|
|
1246
|
+
* Subscribe to location change updates from the device.
|
|
1247
|
+
*
|
|
1248
|
+
* @returns A `DataStream` that emits location updates as the device location changes.
|
|
1249
|
+
* Use `subscribe()` to listen for updates, or `await` to get the first value only.
|
|
1250
|
+
*
|
|
1251
|
+
* @throws Error when the JSBridge method fails unexpectedly.
|
|
1252
|
+
*
|
|
1253
|
+
* @example
|
|
1254
|
+
* Subscribe to location changes
|
|
1255
|
+
* ```typescript
|
|
1256
|
+
* const subscription = locationModule.observeLocationChange().subscribe({
|
|
1257
|
+
* next: (response) => {
|
|
1258
|
+
* if (response.status_code === 200) {
|
|
1259
|
+
* console.log('Location updated:', response.result.lat, response.result.lng);
|
|
1260
|
+
* }
|
|
1261
|
+
* },
|
|
1262
|
+
* complete: () => console.log('Location stream completed')
|
|
1263
|
+
* });
|
|
1264
|
+
*
|
|
1265
|
+
* // Later, to stop receiving updates:
|
|
1266
|
+
* subscription.unsubscribe();
|
|
1267
|
+
* ```
|
|
1268
|
+
*
|
|
1269
|
+
* @example
|
|
1270
|
+
* Get only the first location update
|
|
1271
|
+
* ```typescript
|
|
1272
|
+
* const response = await locationModule.observeLocationChange();
|
|
1273
|
+
* if (response.status_code === 200) {
|
|
1274
|
+
* console.log('First location:', response.result.lat, response.result.lng);
|
|
1275
|
+
* }
|
|
1276
|
+
* ```
|
|
1277
|
+
*
|
|
1278
|
+
* @public
|
|
1279
|
+
*/
|
|
1280
|
+
observeLocationChange(): ObserveLocationChangeResponse;
|
|
1281
|
+
/**
|
|
1282
|
+
* Get the country code based on the device's current location.
|
|
1283
|
+
*
|
|
1284
|
+
* @returns Resolves with the ISO country code (e.g., "SG", "ID", "MY"), or error information if the request fails.
|
|
1285
|
+
*
|
|
1286
|
+
* @throws Error when the JSBridge method fails unexpectedly.
|
|
1287
|
+
*
|
|
1288
|
+
* @example
|
|
1289
|
+
* Get country code
|
|
1290
|
+
* ```typescript
|
|
1291
|
+
* const response = await locationModule.getCountryCode();
|
|
1292
|
+
* ```
|
|
1293
|
+
*
|
|
1294
|
+
* @example
|
|
1295
|
+
* Handling the response
|
|
1296
|
+
* ```typescript
|
|
1297
|
+
* try {
|
|
1298
|
+
* const { status_code, result, error } = await locationModule.getCountryCode();
|
|
1299
|
+
* switch (status_code) {
|
|
1300
|
+
* case 200:
|
|
1301
|
+
* console.log('Country code:', result.countryCode);
|
|
1302
|
+
* break;
|
|
1303
|
+
* default:
|
|
1304
|
+
* console.log(`Could not get country code${error ? `: ${error}` : ''}`);
|
|
1305
|
+
* break;
|
|
1306
|
+
* }
|
|
1307
|
+
* } catch (error) {
|
|
1308
|
+
* console.log(`Could not get country code${error ? `: ${error}` : ''}`);
|
|
1309
|
+
* }
|
|
1310
|
+
* ```
|
|
1311
|
+
*
|
|
1312
|
+
* @public
|
|
1313
|
+
*/
|
|
1314
|
+
getCountryCode(): Promise<GetCountryCodeResponse>;
|
|
125
1315
|
}
|
|
126
1316
|
|
|
127
|
-
|
|
128
|
-
|
|
1317
|
+
/**
|
|
1318
|
+
* JSBridge module for playing DRM-protected media content.
|
|
1319
|
+
*
|
|
1320
|
+
* @group Modules
|
|
1321
|
+
*
|
|
1322
|
+
* @remarks
|
|
1323
|
+
* Provides access to the native media player with DRM support for secure content playback.
|
|
1324
|
+
* Requires the MiniApp to be running within the Grab SuperApp's webview.
|
|
1325
|
+
*
|
|
1326
|
+
* @example
|
|
1327
|
+
* **ES Module:**
|
|
1328
|
+
* ```typescript
|
|
1329
|
+
* import { MediaModule } from '@grabjs/superapp-sdk';
|
|
1330
|
+
* const media = new MediaModule();
|
|
1331
|
+
* ```
|
|
1332
|
+
*
|
|
1333
|
+
* @example
|
|
1334
|
+
* **CDN (UMD):**
|
|
1335
|
+
* ```html
|
|
1336
|
+
* <script src="https://cdn.jsdelivr.net/npm/@grabjs/superapp-sdk/dist/index.js"></script>
|
|
1337
|
+
* <script>
|
|
1338
|
+
* const media = new SuperAppSDK.MediaModule();
|
|
1339
|
+
* </script>
|
|
1340
|
+
* ```
|
|
1341
|
+
*
|
|
1342
|
+
* @public
|
|
1343
|
+
*/
|
|
1344
|
+
export declare class MediaModule extends BaseModule {
|
|
1345
|
+
constructor();
|
|
1346
|
+
playDRMContent(data: any): Promise<BridgeResponse<unknown>> | DataStream<unknown>;
|
|
1347
|
+
observePlayDRMContent(data: any): Promise<BridgeResponse<unknown>> | DataStream<unknown>;
|
|
129
1348
|
}
|
|
130
1349
|
|
|
131
|
-
|
|
132
|
-
|
|
1350
|
+
/**
|
|
1351
|
+
* Response when observing the device coordinates.
|
|
1352
|
+
*
|
|
1353
|
+
* @public
|
|
1354
|
+
*/
|
|
1355
|
+
export declare type ObserveLocationChangeResponse = DataStream_2<GetCoordinateResult>;
|
|
1356
|
+
|
|
1357
|
+
/**
|
|
1358
|
+
* Response when notifying content loaded.
|
|
1359
|
+
*
|
|
1360
|
+
* @public
|
|
1361
|
+
*/
|
|
1362
|
+
export declare type OnContentLoadedResponse = BridgeResponse<null>;
|
|
1363
|
+
|
|
1364
|
+
/**
|
|
1365
|
+
* Request parameters for notifying CTA tap.
|
|
1366
|
+
*
|
|
1367
|
+
* @public
|
|
1368
|
+
*/
|
|
1369
|
+
export declare type OnCtaTapRequest = string;
|
|
1370
|
+
|
|
1371
|
+
/**
|
|
1372
|
+
* Response when notifying CTA tap.
|
|
1373
|
+
*
|
|
1374
|
+
* @public
|
|
1375
|
+
*/
|
|
1376
|
+
export declare type OnCtaTapResponse = BridgeResponse<null>;
|
|
1377
|
+
|
|
1378
|
+
/**
|
|
1379
|
+
* Request parameters for opening an external link.
|
|
1380
|
+
*
|
|
1381
|
+
* @public
|
|
1382
|
+
*/
|
|
1383
|
+
export declare type OpenExternalLinkRequest = string;
|
|
1384
|
+
|
|
1385
|
+
/**
|
|
1386
|
+
* Response when opening an external link.
|
|
1387
|
+
*
|
|
1388
|
+
* @public
|
|
1389
|
+
*/
|
|
1390
|
+
export declare type OpenExternalLinkResponse = BridgeResponse<null>;
|
|
1391
|
+
|
|
1392
|
+
/**
|
|
1393
|
+
* JSBridge module for controlling platform navigation.
|
|
1394
|
+
*
|
|
1395
|
+
* @group Modules
|
|
1396
|
+
*
|
|
1397
|
+
* @remarks
|
|
1398
|
+
* Provides methods to interact with the native platform navigation stack, such as triggering the back action.
|
|
1399
|
+
* Requires the MiniApp to be running within the Grab SuperApp's webview.
|
|
1400
|
+
*
|
|
1401
|
+
* @example
|
|
1402
|
+
* **ES Module:**
|
|
1403
|
+
* ```typescript
|
|
1404
|
+
* import { PlatformModule } from '@grabjs/superapp-sdk';
|
|
1405
|
+
* const platform = new PlatformModule();
|
|
1406
|
+
* ```
|
|
1407
|
+
*
|
|
1408
|
+
* @example
|
|
1409
|
+
* **CDN (UMD):**
|
|
1410
|
+
* ```html
|
|
1411
|
+
* <script src="https://cdn.jsdelivr.net/npm/@grabjs/superapp-sdk/dist/index.js"></script>
|
|
1412
|
+
* <script>
|
|
1413
|
+
* const platform = new SuperAppSDK.PlatformModule();
|
|
1414
|
+
* </script>
|
|
1415
|
+
* ```
|
|
1416
|
+
*
|
|
1417
|
+
* @public
|
|
1418
|
+
*/
|
|
1419
|
+
export declare class PlatformModule extends BaseModule {
|
|
1420
|
+
constructor();
|
|
1421
|
+
back(): Promise<BridgeResponse<unknown>> | DataStream<unknown>;
|
|
133
1422
|
}
|
|
134
1423
|
|
|
135
|
-
|
|
1424
|
+
/**
|
|
1425
|
+
* JSBridge module for accessing user profile information.
|
|
1426
|
+
*
|
|
1427
|
+
* @group Modules
|
|
1428
|
+
*
|
|
1429
|
+
* @remarks
|
|
1430
|
+
* Provides access to user profile data such as email verification.
|
|
1431
|
+
* Requires the MiniApp to be running within the Grab SuperApp's webview.
|
|
1432
|
+
*
|
|
1433
|
+
* @example
|
|
1434
|
+
* **ES Module:**
|
|
1435
|
+
* ```typescript
|
|
1436
|
+
* import { ProfileModule } from '@grabjs/superapp-sdk';
|
|
1437
|
+
* const profile = new ProfileModule();
|
|
1438
|
+
* ```
|
|
1439
|
+
*
|
|
1440
|
+
* @example
|
|
1441
|
+
* **CDN (UMD):**
|
|
1442
|
+
* ```html
|
|
1443
|
+
* <script src="https://cdn.jsdelivr.net/npm/@grabjs/superapp-sdk/dist/index.js"></script>
|
|
1444
|
+
* <script>
|
|
1445
|
+
* const profile = new SuperAppSDK.ProfileModule();
|
|
1446
|
+
* </script>
|
|
1447
|
+
* ```
|
|
1448
|
+
*
|
|
1449
|
+
* @public
|
|
1450
|
+
*/
|
|
1451
|
+
export declare class ProfileModule extends BaseModule {
|
|
1452
|
+
constructor();
|
|
136
1453
|
static parseGrabUserAgent(userAgent: any): {
|
|
137
1454
|
appName: string;
|
|
138
1455
|
major: number;
|
|
@@ -142,30 +1459,261 @@ export declare class ProfileModule {
|
|
|
142
1459
|
};
|
|
143
1460
|
static isVersionBelow(current: any, min: any): boolean;
|
|
144
1461
|
static isSupported(): boolean;
|
|
145
|
-
fetchEmail():
|
|
146
|
-
|
|
1462
|
+
fetchEmail(): Promise<BridgeResponse<unknown>> | DataStream<unknown> | Promise<{
|
|
1463
|
+
status_code: number;
|
|
1464
|
+
error: string;
|
|
1465
|
+
}>;
|
|
1466
|
+
verifyEmail(verifyEmailDetails: any): Promise<BridgeResponse<unknown>> | DataStream<unknown> | Promise<{
|
|
1467
|
+
status_code: number;
|
|
1468
|
+
error: string;
|
|
1469
|
+
}>;
|
|
147
1470
|
}
|
|
148
1471
|
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
1472
|
+
/**
|
|
1473
|
+
* Request parameters for scanning QR codes
|
|
1474
|
+
*
|
|
1475
|
+
* @public
|
|
1476
|
+
*/
|
|
1477
|
+
export declare type ScanQRCodeRequest = {
|
|
1478
|
+
/** Optional title shown in the camera view header. */
|
|
1479
|
+
title?: string;
|
|
1480
|
+
};
|
|
1481
|
+
|
|
1482
|
+
/**
|
|
1483
|
+
* Response when scanning a QR code
|
|
1484
|
+
*
|
|
1485
|
+
* @public
|
|
1486
|
+
*/
|
|
1487
|
+
export declare type ScanQRCodeResponse = BridgeResponse<ScanQRCodeResult>;
|
|
1488
|
+
|
|
1489
|
+
/**
|
|
1490
|
+
* Result object containing the scanned QR code data
|
|
1491
|
+
*
|
|
1492
|
+
* @public
|
|
1493
|
+
*/
|
|
1494
|
+
export declare type ScanQRCodeResult = {
|
|
1495
|
+
/** The raw string content decoded from the scanned QR code. */
|
|
1496
|
+
qrCode: string;
|
|
1497
|
+
};
|
|
1498
|
+
|
|
1499
|
+
/**
|
|
1500
|
+
* JSBridge module for checking and refreshing API access permissions.
|
|
1501
|
+
*
|
|
1502
|
+
* @group Modules
|
|
1503
|
+
*
|
|
1504
|
+
* @remarks
|
|
1505
|
+
* Manages OAuth scope permissions to determine which JSBridge modules and methods the MiniApp has access to.
|
|
1506
|
+
* Requires the MiniApp to be running within the Grab SuperApp's webview.
|
|
1507
|
+
*
|
|
1508
|
+
* @example
|
|
1509
|
+
* **ES Module:**
|
|
1510
|
+
* ```typescript
|
|
1511
|
+
* import { ScopeModule } from '@grabjs/superapp-sdk';
|
|
1512
|
+
* const scope = new ScopeModule();
|
|
1513
|
+
* ```
|
|
1514
|
+
*
|
|
1515
|
+
* @example
|
|
1516
|
+
* **CDN (UMD):**
|
|
1517
|
+
* ```html
|
|
1518
|
+
* <script src="https://cdn.jsdelivr.net/npm/@grabjs/superapp-sdk/dist/index.js"></script>
|
|
1519
|
+
* <script>
|
|
1520
|
+
* const scope = new SuperAppSDK.ScopeModule();
|
|
1521
|
+
* </script>
|
|
1522
|
+
* ```
|
|
1523
|
+
*
|
|
1524
|
+
* @public
|
|
1525
|
+
*/
|
|
1526
|
+
export declare class ScopeModule extends BaseModule {
|
|
1527
|
+
constructor();
|
|
1528
|
+
hasAccessTo(module: any, method: any): Promise<BridgeResponse<unknown>> | DataStream<unknown>;
|
|
1529
|
+
reloadScopes(): Promise<BridgeResponse<unknown>> | DataStream<unknown>;
|
|
152
1530
|
}
|
|
153
1531
|
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
1532
|
+
/**
|
|
1533
|
+
* Request parameters for sending analytics events.
|
|
1534
|
+
*
|
|
1535
|
+
* @public
|
|
1536
|
+
*/
|
|
1537
|
+
export declare type SendAnalyticsEventRequest = {
|
|
1538
|
+
/** Analytics event state (e.g., "HOMEPAGE", "CHECKOUT_PAGE"). */
|
|
1539
|
+
state: string;
|
|
1540
|
+
/** Analytics event name (e.g., "DEFAULT", "BOOK"). */
|
|
1541
|
+
name: string;
|
|
1542
|
+
/** Optional additional data for the analytics event. */
|
|
1543
|
+
data?: Record<string, any>;
|
|
1544
|
+
};
|
|
1545
|
+
|
|
1546
|
+
/**
|
|
1547
|
+
* Response when sending analytics events.
|
|
1548
|
+
*
|
|
1549
|
+
* @public
|
|
1550
|
+
*/
|
|
1551
|
+
export declare type SendAnalyticsEventResponse = BridgeResponse<null>;
|
|
1552
|
+
|
|
1553
|
+
/**
|
|
1554
|
+
* Request parameters for setting the background color.
|
|
1555
|
+
*
|
|
1556
|
+
* @public
|
|
1557
|
+
*/
|
|
1558
|
+
export declare type SetBackgroundColorRequest = string;
|
|
1559
|
+
|
|
1560
|
+
/**
|
|
1561
|
+
* Response when setting the background color.
|
|
1562
|
+
*
|
|
1563
|
+
* @public
|
|
1564
|
+
*/
|
|
1565
|
+
export declare type SetBackgroundColorResponse = BridgeResponse<null>;
|
|
1566
|
+
|
|
1567
|
+
/**
|
|
1568
|
+
* Request parameters for setting the title.
|
|
1569
|
+
*
|
|
1570
|
+
* @public
|
|
1571
|
+
*/
|
|
1572
|
+
export declare type SetTitleRequest = string;
|
|
1573
|
+
|
|
1574
|
+
/**
|
|
1575
|
+
* Response when setting the title.
|
|
1576
|
+
*
|
|
1577
|
+
* @public
|
|
1578
|
+
*/
|
|
1579
|
+
export declare type SetTitleResponse = BridgeResponse<null>;
|
|
1580
|
+
|
|
1581
|
+
/**
|
|
1582
|
+
* Response when showing the back button.
|
|
1583
|
+
*
|
|
1584
|
+
* @public
|
|
1585
|
+
*/
|
|
1586
|
+
export declare type ShowBackButtonResponse = BridgeResponse<null>;
|
|
1587
|
+
|
|
1588
|
+
/**
|
|
1589
|
+
* Response when showing the loader.
|
|
1590
|
+
*
|
|
1591
|
+
* @public
|
|
1592
|
+
*/
|
|
1593
|
+
export declare type ShowLoaderResponse = BridgeResponse<null>;
|
|
1594
|
+
|
|
1595
|
+
/**
|
|
1596
|
+
* Response when showing the refresh button.
|
|
1597
|
+
*
|
|
1598
|
+
* @public
|
|
1599
|
+
*/
|
|
1600
|
+
export declare type ShowRefreshButtonResponse = BridgeResponse<null>;
|
|
1601
|
+
|
|
1602
|
+
/**
|
|
1603
|
+
* JSBridge module for persisting key-value data to native storage.
|
|
1604
|
+
*
|
|
1605
|
+
* @group Modules
|
|
1606
|
+
*
|
|
1607
|
+
* @remarks
|
|
1608
|
+
* Stores data in the native app's persistent storage, allowing data to survive webview restarts.
|
|
1609
|
+
* Requires the MiniApp to be running within the Grab SuperApp's webview.
|
|
1610
|
+
*
|
|
1611
|
+
* @example
|
|
1612
|
+
* **ES Module:**
|
|
1613
|
+
* ```typescript
|
|
1614
|
+
* import { StorageModule } from '@grabjs/superapp-sdk';
|
|
1615
|
+
* const storage = new StorageModule();
|
|
1616
|
+
* ```
|
|
1617
|
+
*
|
|
1618
|
+
* @example
|
|
1619
|
+
* **CDN (UMD):**
|
|
1620
|
+
* ```html
|
|
1621
|
+
* <script src="https://cdn.jsdelivr.net/npm/@grabjs/superapp-sdk/dist/index.js"></script>
|
|
1622
|
+
* <script>
|
|
1623
|
+
* const storage = new SuperAppSDK.StorageModule();
|
|
1624
|
+
* </script>
|
|
1625
|
+
* ```
|
|
1626
|
+
*
|
|
1627
|
+
* @public
|
|
1628
|
+
*/
|
|
1629
|
+
export declare class StorageModule extends BaseModule {
|
|
1630
|
+
constructor();
|
|
1631
|
+
setBoolean(key: any, value: any): Promise<BridgeResponse<unknown>> | DataStream<unknown>;
|
|
1632
|
+
getBoolean(key: any): Promise<BridgeResponse<unknown>> | DataStream<unknown>;
|
|
1633
|
+
setInt(key: any, value: any): Promise<BridgeResponse<unknown>> | DataStream<unknown>;
|
|
1634
|
+
getInt(key: any): Promise<BridgeResponse<unknown>> | DataStream<unknown>;
|
|
1635
|
+
setString(key: any, value: any): Promise<BridgeResponse<unknown>> | DataStream<unknown>;
|
|
1636
|
+
getString(key: any): Promise<BridgeResponse<unknown>> | DataStream<unknown>;
|
|
1637
|
+
setDouble(key: any, value: any): Promise<BridgeResponse<unknown>> | DataStream<unknown>;
|
|
1638
|
+
getDouble(key: any): Promise<BridgeResponse<unknown>> | DataStream<unknown>;
|
|
1639
|
+
remove(key: any): Promise<BridgeResponse<unknown>> | DataStream<unknown>;
|
|
1640
|
+
removeAll(): Promise<BridgeResponse<unknown>> | DataStream<unknown>;
|
|
1641
|
+
}
|
|
1642
|
+
|
|
1643
|
+
/**
|
|
1644
|
+
* Controls an active stream subscription. Call `unsubscribe()` to stop receiving data.
|
|
1645
|
+
*
|
|
1646
|
+
* @remarks
|
|
1647
|
+
* Returned by `subscribe()`. Use `unsubscribe()` to terminate the stream early.
|
|
1648
|
+
* Use `isUnsubscribed()` to check if already terminated.
|
|
1649
|
+
*
|
|
1650
|
+
* @public
|
|
1651
|
+
*/
|
|
1652
|
+
export declare type Subscription = Readonly<{
|
|
1653
|
+
/** Returns true if this subscription has been terminated. */
|
|
1654
|
+
isUnsubscribed: () => boolean;
|
|
1655
|
+
/** Terminates the subscription. No further data will be received. */
|
|
1656
|
+
unsubscribe: () => unknown;
|
|
1657
|
+
}>;
|
|
1658
|
+
|
|
1659
|
+
/**
|
|
1660
|
+
* JSBridge module for opening URLs in the device's system browser.
|
|
1661
|
+
*
|
|
1662
|
+
* @group Modules
|
|
1663
|
+
*
|
|
1664
|
+
* @remarks
|
|
1665
|
+
* Allows MiniApps to redirect users to external content using the native system webview.
|
|
1666
|
+
* Requires the MiniApp to be running within the Grab SuperApp's webview.
|
|
1667
|
+
*
|
|
1668
|
+
* @example
|
|
1669
|
+
* **ES Module:**
|
|
1670
|
+
* ```typescript
|
|
1671
|
+
* import { SystemWebViewKitModule } from '@grabjs/superapp-sdk';
|
|
1672
|
+
* const webViewKit = new SystemWebViewKitModule();
|
|
1673
|
+
* ```
|
|
1674
|
+
*
|
|
1675
|
+
* @example
|
|
1676
|
+
* **CDN (UMD):**
|
|
1677
|
+
* ```html
|
|
1678
|
+
* <script src="https://cdn.jsdelivr.net/npm/@grabjs/superapp-sdk/dist/index.js"></script>
|
|
1679
|
+
* <script>
|
|
1680
|
+
* const webViewKit = new SuperAppSDK.SystemWebViewKitModule();
|
|
1681
|
+
* </script>
|
|
1682
|
+
* ```
|
|
1683
|
+
*
|
|
1684
|
+
* @public
|
|
1685
|
+
*/
|
|
1686
|
+
export declare class SystemWebViewKitModule extends BaseModule {
|
|
1687
|
+
constructor();
|
|
1688
|
+
redirectToSystemWebView(payload: any): Promise<BridgeResponse<unknown>> | DataStream<unknown>;
|
|
165
1689
|
}
|
|
166
1690
|
|
|
167
|
-
|
|
168
|
-
|
|
1691
|
+
/**
|
|
1692
|
+
* Generic interface for all native JSBridge module wrappers.
|
|
1693
|
+
*
|
|
1694
|
+
* @remarks
|
|
1695
|
+
* This is the base interface that all Wrapped*Module interfaces implement.
|
|
1696
|
+
* Modules can use this directly for generic method invocation, or extend it
|
|
1697
|
+
* with method-specific overloads for stricter typing.
|
|
1698
|
+
*
|
|
1699
|
+
* @example
|
|
1700
|
+
* Using directly (CameraModule, ContainerModule):
|
|
1701
|
+
* ```typescript
|
|
1702
|
+
* invoke<ScanQRCodeResult>('scanQRCode', request)
|
|
1703
|
+
* ```
|
|
1704
|
+
*
|
|
1705
|
+
* @example
|
|
1706
|
+
* Extending with method overloads (ProfileModule, LocationModule):
|
|
1707
|
+
* ```typescript
|
|
1708
|
+
* export interface WrappedProfileModule extends WrappedModule {
|
|
1709
|
+
* invoke(method: 'fetchEmail', params?: any): Promise<BridgeResponse<string>>;
|
|
1710
|
+
* }
|
|
1711
|
+
* ```
|
|
1712
|
+
*
|
|
1713
|
+
* @public
|
|
1714
|
+
*/
|
|
1715
|
+
export declare interface WrappedModule {
|
|
1716
|
+
invoke<T>(method: string, params?: unknown): Promise<BridgeResponse<T>> | DataStream<T>;
|
|
169
1717
|
}
|
|
170
1718
|
|
|
171
1719
|
export { }
|