@cloudparse/up-miniapps-sdk 0.5.5 → 0.5.6
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/index.browser.min.js +100 -96
- package/dist/index.browser.min.js.map +1 -1
- package/dist/index.cjs +398 -32
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +137 -2
- package/dist/index.d.ts +137 -2
- package/dist/index.js +395 -30
- package/dist/index.js.map +1 -1
- package/dist/style.css +6 -0
- package/package.json +3 -1
package/dist/index.d.cts
CHANGED
|
@@ -4,6 +4,7 @@ import { R as RouteResponse, a as RouteStep, b as RouteRequest, c as RoutingBack
|
|
|
4
4
|
export { C as ClearRouteRequest, D as DrawRouteRequest, h as handleClearRoute, d as handleDrawRoute, e as handleRouteRequest } from './index-B9dDciJq.cjs';
|
|
5
5
|
import { ViewState } from '@vis.gl/react-maplibre';
|
|
6
6
|
import * as react_dom_client from 'react-dom/client';
|
|
7
|
+
import { ShapeType, ErrorCorrectionLevel, DotType, Gradient, CornerSquareType, CornerDotType } from 'qr-code-styling';
|
|
7
8
|
import 'maplibre-gl';
|
|
8
9
|
|
|
9
10
|
interface BridgeMockerProps {
|
|
@@ -338,6 +339,88 @@ interface ISaveImageResult {
|
|
|
338
339
|
/** Whether the image was saved successfully. */
|
|
339
340
|
success: boolean;
|
|
340
341
|
}
|
|
342
|
+
/**
|
|
343
|
+
* Result of a `sdk.media.pickImage` call.
|
|
344
|
+
*/
|
|
345
|
+
interface IPickImageResult {
|
|
346
|
+
/** Whether an image was picked (false if permission was denied or the user canceled the picker). */
|
|
347
|
+
success: boolean;
|
|
348
|
+
/** Base64-encoded image data as a full data URI (e.g. `data:image/jpeg;base64,...`). Only set when `success` is true. */
|
|
349
|
+
base64?: string;
|
|
350
|
+
/** MIME type of the picked image (e.g. `image/jpeg`). Only set when `success` is true. */
|
|
351
|
+
mimeType?: string;
|
|
352
|
+
}
|
|
353
|
+
/**
|
|
354
|
+
* Options for `sdk.qrCode.generate`.
|
|
355
|
+
*/
|
|
356
|
+
interface IGenerateQrCodeOptions {
|
|
357
|
+
/** Square size of the QR code itself, in px. Default 512. */
|
|
358
|
+
size?: number;
|
|
359
|
+
/**
|
|
360
|
+
* Mini-app name shown as a "UP - <appName>" label above the QR code (e.g.
|
|
361
|
+
* the `name` field from `sdk.initialize()`'s response). Ignored if `label`
|
|
362
|
+
* is also set. Omit both for no label.
|
|
363
|
+
*/
|
|
364
|
+
appName?: string;
|
|
365
|
+
/**
|
|
366
|
+
* Explicit label text, overriding the "UP - <appName>" auto-format. Pass
|
|
367
|
+
* an empty string (or omit both this and `appName`) for no label.
|
|
368
|
+
*/
|
|
369
|
+
label?: string;
|
|
370
|
+
/** Dot/corner color. Default a neutral dark gray — kept theme-agnostic since this SDK serves every mini-app, not just one product's brand. */
|
|
371
|
+
color?: string;
|
|
372
|
+
/** Background color behind the QR (and the label, if any). Default white. */
|
|
373
|
+
backgroundColor?: string;
|
|
374
|
+
/** Optional center logo, as a URL or base64 data URI. */
|
|
375
|
+
logo?: string;
|
|
376
|
+
/** Overall QR frame shape. Default "square". */
|
|
377
|
+
shape?: ShapeType;
|
|
378
|
+
/** Quiet-zone margin around the raw QR modules, in px. Default 0. */
|
|
379
|
+
margin?: number;
|
|
380
|
+
/** Error correction level — higher tolerates more damage/logo overlap at the cost of density. Default "Q". */
|
|
381
|
+
errorCorrectionLevel?: ErrorCorrectionLevel;
|
|
382
|
+
/** Dot module style. Default "extra-rounded". */
|
|
383
|
+
dotsType?: DotType;
|
|
384
|
+
/** Gradient for the dots — overrides `color` for the dots when set. */
|
|
385
|
+
dotsGradient?: Gradient;
|
|
386
|
+
/** Corner square (the 3 big position markers) style. Default "extra-rounded". */
|
|
387
|
+
cornersSquareType?: CornerSquareType;
|
|
388
|
+
/** Corner square color override. Defaults to `color`. */
|
|
389
|
+
cornersSquareColor?: string;
|
|
390
|
+
/** Gradient for the corner squares — overrides the corner square color when set. */
|
|
391
|
+
cornersSquareGradient?: Gradient;
|
|
392
|
+
/** Corner dot (the small dot inside each position marker) style. Default "dot". */
|
|
393
|
+
cornersDotType?: CornerDotType;
|
|
394
|
+
/** Corner dot color override. Defaults to `color`. */
|
|
395
|
+
cornersDotColor?: string;
|
|
396
|
+
/** Gradient for the corner dots — overrides the corner dot color when set. */
|
|
397
|
+
cornersDotGradient?: Gradient;
|
|
398
|
+
/** Gradient for the background — overrides `backgroundColor` when set. */
|
|
399
|
+
backgroundGradient?: Gradient;
|
|
400
|
+
/** Hide the QR dots directly behind the logo. Default true when `logo` is set. */
|
|
401
|
+
hideBackgroundDots?: boolean;
|
|
402
|
+
/** Logo size, as a fraction of the QR width (0-1). Default 0.4. */
|
|
403
|
+
logoSize?: number;
|
|
404
|
+
/** Blank margin around the logo, in px. Default 4. */
|
|
405
|
+
logoMargin?: number;
|
|
406
|
+
/**
|
|
407
|
+
* Extra padding, in px, wrapped around the ENTIRE generated image (the QR
|
|
408
|
+
* code plus the label band, if any) — same `backgroundColor` fill on all
|
|
409
|
+
* four sides. Distinct from `margin`, which is `qr-code-styling`'s own
|
|
410
|
+
* internal quiet-zone around just the QR modules. Default 32.
|
|
411
|
+
*/
|
|
412
|
+
outerPadding?: number;
|
|
413
|
+
/**
|
|
414
|
+
* The final generated image is ALWAYS a square (padded on the shorter
|
|
415
|
+
* side to force it, even when a label band makes the QR+label content
|
|
416
|
+
* taller than it is wide) — this is the corner radius applied to that
|
|
417
|
+
* square, as a PERCENTAGE of its side length (0-50, like CSS
|
|
418
|
+
* `border-radius: N%` on a square element), not raw px. The area outside
|
|
419
|
+
* the rounded corners is left transparent, not `backgroundColor`-filled.
|
|
420
|
+
* Set to 0 for sharp corners, 50 for a full circle. Default 6.
|
|
421
|
+
*/
|
|
422
|
+
borderRadius?: number;
|
|
423
|
+
}
|
|
341
424
|
/**
|
|
342
425
|
* Edge insets representing padding or margins around a component, typically used for layout purposes.
|
|
343
426
|
*/
|
|
@@ -1049,6 +1132,28 @@ declare const useMockLocation: () => MockLocationContextType | null;
|
|
|
1049
1132
|
*/
|
|
1050
1133
|
declare function renderMap(containerId: string, props?: MapProps): react_dom_client.Root;
|
|
1051
1134
|
|
|
1135
|
+
interface QRScannerProps {
|
|
1136
|
+
/** Called once with the decoded string the moment a QR code is detected. Scanning stops immediately after. */
|
|
1137
|
+
onScan: (data: string) => void;
|
|
1138
|
+
/** Called with a user-facing error message (camera permission denied, no camera, etc.). */
|
|
1139
|
+
onError?: (message: string) => void;
|
|
1140
|
+
/** Additional className for the outer container (sizing/positioning — the component fills it). */
|
|
1141
|
+
className?: string;
|
|
1142
|
+
}
|
|
1143
|
+
/**
|
|
1144
|
+
* Camera-based QR code scanner — the single source of truth for every
|
|
1145
|
+
* Mini-App. Handles camera permission (via `sdk.permission.request`),
|
|
1146
|
+
* `getUserMedia` stream lifecycle, and the jsQR decode loop internally.
|
|
1147
|
+
* Mini-Apps must not reimplement this on their own — that duplication is
|
|
1148
|
+
* exactly what made this logic drift and painful to fix consistently across
|
|
1149
|
+
* apps.
|
|
1150
|
+
*
|
|
1151
|
+
* Renders its own default "scan frame" chrome (bordered square + scan-line
|
|
1152
|
+
* animation via inline styles, so it works with zero external CSS). Pass
|
|
1153
|
+
* `className` to control size/position; the video feed fills the container.
|
|
1154
|
+
*/
|
|
1155
|
+
declare function QRScanner({ onScan, onError, className }: QRScannerProps): React.JSX.Element;
|
|
1156
|
+
|
|
1052
1157
|
/**
|
|
1053
1158
|
* Hook to check if the SDK is currently running in mock mode (browser)
|
|
1054
1159
|
* or native mode (shell app).
|
|
@@ -1212,18 +1317,26 @@ declare class MiniAppSDK {
|
|
|
1212
1317
|
readonly permission: Readonly<{
|
|
1213
1318
|
/**
|
|
1214
1319
|
* Explicitly request access to sensitive data.
|
|
1215
|
-
* @param type The type of permission to request ('location' or '
|
|
1320
|
+
* @param type The type of permission to request ('location', 'profile', or 'camera').
|
|
1216
1321
|
* @param fields If requesting 'profile', the specific fields required.
|
|
1217
1322
|
*/
|
|
1218
1323
|
request: {
|
|
1219
1324
|
(type: "location"): Promise<boolean>;
|
|
1220
1325
|
(type: "profile", fields: (keyof IUserProfile)[]): Promise<boolean>;
|
|
1326
|
+
(type: "camera"): Promise<boolean>;
|
|
1221
1327
|
};
|
|
1222
1328
|
}>;
|
|
1223
1329
|
/**
|
|
1224
1330
|
* Media & Gallery integration.
|
|
1225
1331
|
*/
|
|
1226
1332
|
readonly media: Readonly<{
|
|
1333
|
+
/**
|
|
1334
|
+
* Opens the device's native photo gallery picker via the Host Shell and
|
|
1335
|
+
* returns the chosen image as base64. Distinct permission grant from
|
|
1336
|
+
* `saveImage` (read vs. write access to the photo library) — the Host
|
|
1337
|
+
* Shell requests it independently.
|
|
1338
|
+
*/
|
|
1339
|
+
pickImage: () => Promise<IPickImageResult>;
|
|
1227
1340
|
/**
|
|
1228
1341
|
* Saves a base64-encoded image to the device's photo gallery via the Host Shell.
|
|
1229
1342
|
* A plain browser `<a download>` does not work inside the native WebView (no
|
|
@@ -1234,6 +1347,28 @@ declare class MiniAppSDK {
|
|
|
1234
1347
|
*/
|
|
1235
1348
|
saveImage: (base64: string, filename?: string) => Promise<ISaveImageResult>;
|
|
1236
1349
|
}>;
|
|
1350
|
+
/**
|
|
1351
|
+
* QR code generation — the single source of truth for every Mini-App.
|
|
1352
|
+
* Runs entirely client-side (canvas, no Host Shell round-trip) and returns
|
|
1353
|
+
* a base64 PNG data URI, ready for an `<img src>` or `media.saveImage()`.
|
|
1354
|
+
* Mini-Apps must not reimplement this on their own.
|
|
1355
|
+
*/
|
|
1356
|
+
readonly qrCode: Readonly<{
|
|
1357
|
+
/**
|
|
1358
|
+
* @param data The value to encode (e.g. a deep link).
|
|
1359
|
+
* @param options Styling/labeling options — see {@link IGenerateQrCodeOptions}.
|
|
1360
|
+
* @returns A base64 PNG data URI.
|
|
1361
|
+
*/
|
|
1362
|
+
generate: (data: string, options?: IGenerateQrCodeOptions) => Promise<string>;
|
|
1363
|
+
/**
|
|
1364
|
+
* Decodes a QR code from a static image (base64 data URI or URL) —
|
|
1365
|
+
* e.g. a photo picked via `sdk.media.pickImage()` that already
|
|
1366
|
+
* contains a QR code, as an alternative to the live `<QRScanner>`.
|
|
1367
|
+
* @param imageDataUrl A base64 data URI (e.g. from `sdk.media.pickImage()`).
|
|
1368
|
+
* @returns The decoded string, or `null` if no QR code was found.
|
|
1369
|
+
*/
|
|
1370
|
+
decode: (imageDataUrl: string) => Promise<string | null>;
|
|
1371
|
+
}>;
|
|
1237
1372
|
/**
|
|
1238
1373
|
* Payments integration.
|
|
1239
1374
|
*/
|
|
@@ -1413,4 +1548,4 @@ declare class MiniAppSDK {
|
|
|
1413
1548
|
*/
|
|
1414
1549
|
declare const sdk: MiniAppSDK;
|
|
1415
1550
|
|
|
1416
|
-
export { type BridgeMessageType, BridgeMocker, type BridgeMockerProps, type CenterCallbackParams, type CustomControl, DebugConsole, type DebugConsoleProps, type DeclarativeJourneyOptions, type DrawerState, type EtaData, type FidelityTransactionTypeType, type FlyToParams, 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 ISaveImageResult, 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, MockLocationContext, type MockLocationContextType, 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, type SwipeAxisPriority, SwipeCarousel, type SwipeCarouselItem, type SwipeCarouselProps, type SwipeCarouselVerticalDragConfig, UIEvent, type UseJourneyOptions, type UseJourneyResult, type UserLocationState, sdk as default, renderMap, sdk, useIsMocked, useJourney, useLiveRouting, useMapControls, useMockLocation, useRoute, useTrimmedRoute, useUserLocation };
|
|
1551
|
+
export { type BridgeMessageType, BridgeMocker, type BridgeMockerProps, type CenterCallbackParams, type CustomControl, DebugConsole, type DebugConsoleProps, type DeclarativeJourneyOptions, type DrawerState, type EtaData, type FidelityTransactionTypeType, type FlyToParams, GeolocationEvent, GlobalEvent, type HapticStyleType, type IBridgeEnvelope, type IContextState, type IEdgeInsets, type IFidelityBalance, type IFidelityHistoryParams, type IFidelityTransaction, type IGenerateQrCodeOptions, type IInitializationOptions, type IInitializationResponse, type ILocationData, type INetworkOptions, type INetworkResponse, type IPaymentRequest, type IPickImageResult, type ISaveImageResult, 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, MockLocationContext, type MockLocationContextType, type NetworkMethodType, type POI, QRScanner, type QRScannerProps, RouteLayer, type RouteLayerProps, RouteRequest, RouteResponse, RouteStep, type SDKEvent, SDKMapProvider, SDKProvider, type SDKProviderProps, type ScrollConfig, type StreamAccelerometerData, type StreamHeadingData, type StreamLocationData, type StreamUpdatePayload, type SwipeAxisPriority, SwipeCarousel, type SwipeCarouselItem, type SwipeCarouselProps, type SwipeCarouselVerticalDragConfig, UIEvent, type UseJourneyOptions, type UseJourneyResult, type UserLocationState, sdk as default, renderMap, sdk, useIsMocked, useJourney, useLiveRouting, useMapControls, useMockLocation, useRoute, useTrimmedRoute, useUserLocation };
|
package/dist/index.d.ts
CHANGED
|
@@ -4,6 +4,7 @@ import { R as RouteResponse, a as RouteStep, b as RouteRequest, c as RoutingBack
|
|
|
4
4
|
export { C as ClearRouteRequest, D as DrawRouteRequest, h as handleClearRoute, d as handleDrawRoute, e as handleRouteRequest } from './index-B9dDciJq.js';
|
|
5
5
|
import { ViewState } from '@vis.gl/react-maplibre';
|
|
6
6
|
import * as react_dom_client from 'react-dom/client';
|
|
7
|
+
import { ShapeType, ErrorCorrectionLevel, DotType, Gradient, CornerSquareType, CornerDotType } from 'qr-code-styling';
|
|
7
8
|
import 'maplibre-gl';
|
|
8
9
|
|
|
9
10
|
interface BridgeMockerProps {
|
|
@@ -338,6 +339,88 @@ interface ISaveImageResult {
|
|
|
338
339
|
/** Whether the image was saved successfully. */
|
|
339
340
|
success: boolean;
|
|
340
341
|
}
|
|
342
|
+
/**
|
|
343
|
+
* Result of a `sdk.media.pickImage` call.
|
|
344
|
+
*/
|
|
345
|
+
interface IPickImageResult {
|
|
346
|
+
/** Whether an image was picked (false if permission was denied or the user canceled the picker). */
|
|
347
|
+
success: boolean;
|
|
348
|
+
/** Base64-encoded image data as a full data URI (e.g. `data:image/jpeg;base64,...`). Only set when `success` is true. */
|
|
349
|
+
base64?: string;
|
|
350
|
+
/** MIME type of the picked image (e.g. `image/jpeg`). Only set when `success` is true. */
|
|
351
|
+
mimeType?: string;
|
|
352
|
+
}
|
|
353
|
+
/**
|
|
354
|
+
* Options for `sdk.qrCode.generate`.
|
|
355
|
+
*/
|
|
356
|
+
interface IGenerateQrCodeOptions {
|
|
357
|
+
/** Square size of the QR code itself, in px. Default 512. */
|
|
358
|
+
size?: number;
|
|
359
|
+
/**
|
|
360
|
+
* Mini-app name shown as a "UP - <appName>" label above the QR code (e.g.
|
|
361
|
+
* the `name` field from `sdk.initialize()`'s response). Ignored if `label`
|
|
362
|
+
* is also set. Omit both for no label.
|
|
363
|
+
*/
|
|
364
|
+
appName?: string;
|
|
365
|
+
/**
|
|
366
|
+
* Explicit label text, overriding the "UP - <appName>" auto-format. Pass
|
|
367
|
+
* an empty string (or omit both this and `appName`) for no label.
|
|
368
|
+
*/
|
|
369
|
+
label?: string;
|
|
370
|
+
/** Dot/corner color. Default a neutral dark gray — kept theme-agnostic since this SDK serves every mini-app, not just one product's brand. */
|
|
371
|
+
color?: string;
|
|
372
|
+
/** Background color behind the QR (and the label, if any). Default white. */
|
|
373
|
+
backgroundColor?: string;
|
|
374
|
+
/** Optional center logo, as a URL or base64 data URI. */
|
|
375
|
+
logo?: string;
|
|
376
|
+
/** Overall QR frame shape. Default "square". */
|
|
377
|
+
shape?: ShapeType;
|
|
378
|
+
/** Quiet-zone margin around the raw QR modules, in px. Default 0. */
|
|
379
|
+
margin?: number;
|
|
380
|
+
/** Error correction level — higher tolerates more damage/logo overlap at the cost of density. Default "Q". */
|
|
381
|
+
errorCorrectionLevel?: ErrorCorrectionLevel;
|
|
382
|
+
/** Dot module style. Default "extra-rounded". */
|
|
383
|
+
dotsType?: DotType;
|
|
384
|
+
/** Gradient for the dots — overrides `color` for the dots when set. */
|
|
385
|
+
dotsGradient?: Gradient;
|
|
386
|
+
/** Corner square (the 3 big position markers) style. Default "extra-rounded". */
|
|
387
|
+
cornersSquareType?: CornerSquareType;
|
|
388
|
+
/** Corner square color override. Defaults to `color`. */
|
|
389
|
+
cornersSquareColor?: string;
|
|
390
|
+
/** Gradient for the corner squares — overrides the corner square color when set. */
|
|
391
|
+
cornersSquareGradient?: Gradient;
|
|
392
|
+
/** Corner dot (the small dot inside each position marker) style. Default "dot". */
|
|
393
|
+
cornersDotType?: CornerDotType;
|
|
394
|
+
/** Corner dot color override. Defaults to `color`. */
|
|
395
|
+
cornersDotColor?: string;
|
|
396
|
+
/** Gradient for the corner dots — overrides the corner dot color when set. */
|
|
397
|
+
cornersDotGradient?: Gradient;
|
|
398
|
+
/** Gradient for the background — overrides `backgroundColor` when set. */
|
|
399
|
+
backgroundGradient?: Gradient;
|
|
400
|
+
/** Hide the QR dots directly behind the logo. Default true when `logo` is set. */
|
|
401
|
+
hideBackgroundDots?: boolean;
|
|
402
|
+
/** Logo size, as a fraction of the QR width (0-1). Default 0.4. */
|
|
403
|
+
logoSize?: number;
|
|
404
|
+
/** Blank margin around the logo, in px. Default 4. */
|
|
405
|
+
logoMargin?: number;
|
|
406
|
+
/**
|
|
407
|
+
* Extra padding, in px, wrapped around the ENTIRE generated image (the QR
|
|
408
|
+
* code plus the label band, if any) — same `backgroundColor` fill on all
|
|
409
|
+
* four sides. Distinct from `margin`, which is `qr-code-styling`'s own
|
|
410
|
+
* internal quiet-zone around just the QR modules. Default 32.
|
|
411
|
+
*/
|
|
412
|
+
outerPadding?: number;
|
|
413
|
+
/**
|
|
414
|
+
* The final generated image is ALWAYS a square (padded on the shorter
|
|
415
|
+
* side to force it, even when a label band makes the QR+label content
|
|
416
|
+
* taller than it is wide) — this is the corner radius applied to that
|
|
417
|
+
* square, as a PERCENTAGE of its side length (0-50, like CSS
|
|
418
|
+
* `border-radius: N%` on a square element), not raw px. The area outside
|
|
419
|
+
* the rounded corners is left transparent, not `backgroundColor`-filled.
|
|
420
|
+
* Set to 0 for sharp corners, 50 for a full circle. Default 6.
|
|
421
|
+
*/
|
|
422
|
+
borderRadius?: number;
|
|
423
|
+
}
|
|
341
424
|
/**
|
|
342
425
|
* Edge insets representing padding or margins around a component, typically used for layout purposes.
|
|
343
426
|
*/
|
|
@@ -1049,6 +1132,28 @@ declare const useMockLocation: () => MockLocationContextType | null;
|
|
|
1049
1132
|
*/
|
|
1050
1133
|
declare function renderMap(containerId: string, props?: MapProps): react_dom_client.Root;
|
|
1051
1134
|
|
|
1135
|
+
interface QRScannerProps {
|
|
1136
|
+
/** Called once with the decoded string the moment a QR code is detected. Scanning stops immediately after. */
|
|
1137
|
+
onScan: (data: string) => void;
|
|
1138
|
+
/** Called with a user-facing error message (camera permission denied, no camera, etc.). */
|
|
1139
|
+
onError?: (message: string) => void;
|
|
1140
|
+
/** Additional className for the outer container (sizing/positioning — the component fills it). */
|
|
1141
|
+
className?: string;
|
|
1142
|
+
}
|
|
1143
|
+
/**
|
|
1144
|
+
* Camera-based QR code scanner — the single source of truth for every
|
|
1145
|
+
* Mini-App. Handles camera permission (via `sdk.permission.request`),
|
|
1146
|
+
* `getUserMedia` stream lifecycle, and the jsQR decode loop internally.
|
|
1147
|
+
* Mini-Apps must not reimplement this on their own — that duplication is
|
|
1148
|
+
* exactly what made this logic drift and painful to fix consistently across
|
|
1149
|
+
* apps.
|
|
1150
|
+
*
|
|
1151
|
+
* Renders its own default "scan frame" chrome (bordered square + scan-line
|
|
1152
|
+
* animation via inline styles, so it works with zero external CSS). Pass
|
|
1153
|
+
* `className` to control size/position; the video feed fills the container.
|
|
1154
|
+
*/
|
|
1155
|
+
declare function QRScanner({ onScan, onError, className }: QRScannerProps): React.JSX.Element;
|
|
1156
|
+
|
|
1052
1157
|
/**
|
|
1053
1158
|
* Hook to check if the SDK is currently running in mock mode (browser)
|
|
1054
1159
|
* or native mode (shell app).
|
|
@@ -1212,18 +1317,26 @@ declare class MiniAppSDK {
|
|
|
1212
1317
|
readonly permission: Readonly<{
|
|
1213
1318
|
/**
|
|
1214
1319
|
* Explicitly request access to sensitive data.
|
|
1215
|
-
* @param type The type of permission to request ('location' or '
|
|
1320
|
+
* @param type The type of permission to request ('location', 'profile', or 'camera').
|
|
1216
1321
|
* @param fields If requesting 'profile', the specific fields required.
|
|
1217
1322
|
*/
|
|
1218
1323
|
request: {
|
|
1219
1324
|
(type: "location"): Promise<boolean>;
|
|
1220
1325
|
(type: "profile", fields: (keyof IUserProfile)[]): Promise<boolean>;
|
|
1326
|
+
(type: "camera"): Promise<boolean>;
|
|
1221
1327
|
};
|
|
1222
1328
|
}>;
|
|
1223
1329
|
/**
|
|
1224
1330
|
* Media & Gallery integration.
|
|
1225
1331
|
*/
|
|
1226
1332
|
readonly media: Readonly<{
|
|
1333
|
+
/**
|
|
1334
|
+
* Opens the device's native photo gallery picker via the Host Shell and
|
|
1335
|
+
* returns the chosen image as base64. Distinct permission grant from
|
|
1336
|
+
* `saveImage` (read vs. write access to the photo library) — the Host
|
|
1337
|
+
* Shell requests it independently.
|
|
1338
|
+
*/
|
|
1339
|
+
pickImage: () => Promise<IPickImageResult>;
|
|
1227
1340
|
/**
|
|
1228
1341
|
* Saves a base64-encoded image to the device's photo gallery via the Host Shell.
|
|
1229
1342
|
* A plain browser `<a download>` does not work inside the native WebView (no
|
|
@@ -1234,6 +1347,28 @@ declare class MiniAppSDK {
|
|
|
1234
1347
|
*/
|
|
1235
1348
|
saveImage: (base64: string, filename?: string) => Promise<ISaveImageResult>;
|
|
1236
1349
|
}>;
|
|
1350
|
+
/**
|
|
1351
|
+
* QR code generation — the single source of truth for every Mini-App.
|
|
1352
|
+
* Runs entirely client-side (canvas, no Host Shell round-trip) and returns
|
|
1353
|
+
* a base64 PNG data URI, ready for an `<img src>` or `media.saveImage()`.
|
|
1354
|
+
* Mini-Apps must not reimplement this on their own.
|
|
1355
|
+
*/
|
|
1356
|
+
readonly qrCode: Readonly<{
|
|
1357
|
+
/**
|
|
1358
|
+
* @param data The value to encode (e.g. a deep link).
|
|
1359
|
+
* @param options Styling/labeling options — see {@link IGenerateQrCodeOptions}.
|
|
1360
|
+
* @returns A base64 PNG data URI.
|
|
1361
|
+
*/
|
|
1362
|
+
generate: (data: string, options?: IGenerateQrCodeOptions) => Promise<string>;
|
|
1363
|
+
/**
|
|
1364
|
+
* Decodes a QR code from a static image (base64 data URI or URL) —
|
|
1365
|
+
* e.g. a photo picked via `sdk.media.pickImage()` that already
|
|
1366
|
+
* contains a QR code, as an alternative to the live `<QRScanner>`.
|
|
1367
|
+
* @param imageDataUrl A base64 data URI (e.g. from `sdk.media.pickImage()`).
|
|
1368
|
+
* @returns The decoded string, or `null` if no QR code was found.
|
|
1369
|
+
*/
|
|
1370
|
+
decode: (imageDataUrl: string) => Promise<string | null>;
|
|
1371
|
+
}>;
|
|
1237
1372
|
/**
|
|
1238
1373
|
* Payments integration.
|
|
1239
1374
|
*/
|
|
@@ -1413,4 +1548,4 @@ declare class MiniAppSDK {
|
|
|
1413
1548
|
*/
|
|
1414
1549
|
declare const sdk: MiniAppSDK;
|
|
1415
1550
|
|
|
1416
|
-
export { type BridgeMessageType, BridgeMocker, type BridgeMockerProps, type CenterCallbackParams, type CustomControl, DebugConsole, type DebugConsoleProps, type DeclarativeJourneyOptions, type DrawerState, type EtaData, type FidelityTransactionTypeType, type FlyToParams, 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 ISaveImageResult, 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, MockLocationContext, type MockLocationContextType, 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, type SwipeAxisPriority, SwipeCarousel, type SwipeCarouselItem, type SwipeCarouselProps, type SwipeCarouselVerticalDragConfig, UIEvent, type UseJourneyOptions, type UseJourneyResult, type UserLocationState, sdk as default, renderMap, sdk, useIsMocked, useJourney, useLiveRouting, useMapControls, useMockLocation, useRoute, useTrimmedRoute, useUserLocation };
|
|
1551
|
+
export { type BridgeMessageType, BridgeMocker, type BridgeMockerProps, type CenterCallbackParams, type CustomControl, DebugConsole, type DebugConsoleProps, type DeclarativeJourneyOptions, type DrawerState, type EtaData, type FidelityTransactionTypeType, type FlyToParams, GeolocationEvent, GlobalEvent, type HapticStyleType, type IBridgeEnvelope, type IContextState, type IEdgeInsets, type IFidelityBalance, type IFidelityHistoryParams, type IFidelityTransaction, type IGenerateQrCodeOptions, type IInitializationOptions, type IInitializationResponse, type ILocationData, type INetworkOptions, type INetworkResponse, type IPaymentRequest, type IPickImageResult, type ISaveImageResult, 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, MockLocationContext, type MockLocationContextType, type NetworkMethodType, type POI, QRScanner, type QRScannerProps, RouteLayer, type RouteLayerProps, RouteRequest, RouteResponse, RouteStep, type SDKEvent, SDKMapProvider, SDKProvider, type SDKProviderProps, type ScrollConfig, type StreamAccelerometerData, type StreamHeadingData, type StreamLocationData, type StreamUpdatePayload, type SwipeAxisPriority, SwipeCarousel, type SwipeCarouselItem, type SwipeCarouselProps, type SwipeCarouselVerticalDragConfig, UIEvent, type UseJourneyOptions, type UseJourneyResult, type UserLocationState, sdk as default, renderMap, sdk, useIsMocked, useJourney, useLiveRouting, useMapControls, useMockLocation, useRoute, useTrimmedRoute, useUserLocation };
|