@cloudparse/up-miniapps-sdk 0.6.1 → 0.6.3

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.d.cts CHANGED
@@ -2,7 +2,7 @@ import * as React from 'react';
2
2
  import React__default, { ReactNode } from 'react';
3
3
  import { R as RouteResponse, a as RouteStep, b as RouteRequest, c as RoutingBackendConfig } from './index-B9dDciJq.cjs';
4
4
  export { C as ClearRouteRequest, D as DrawRouteRequest, h as handleClearRoute, d as handleDrawRoute, e as handleRouteRequest } from './index-B9dDciJq.cjs';
5
- import { ViewState } from '@vis.gl/react-maplibre';
5
+ import { ViewState, StyleSpecification, ImmutableLike } from '@vis.gl/react-maplibre';
6
6
  import * as react_dom_client from 'react-dom/client';
7
7
  import { ShapeType, ErrorCorrectionLevel, DotType, Gradient, CornerSquareType, CornerDotType } from 'qr-code-styling';
8
8
  import 'maplibre-gl';
@@ -681,8 +681,8 @@ interface MapProps {
681
681
  style?: React__default.CSSProperties;
682
682
  /** Minimum and maximum bounds for the map. */
683
683
  maxBounds?: [[number, number], [number, number]];
684
- /** MapLibre style URL. Defaults to local server. */
685
- mapStyle?: string;
684
+ /** MapLibre style URL, or an inline style spec object. Defaults to local server. */
685
+ mapStyle?: string | StyleSpecification | ImmutableLike<StyleSpecification>;
686
686
  /** Children components (Source, Layer, etc.) */
687
687
  children?: React__default.ReactNode;
688
688
  /** Additional CSS classes for the map container. */
@@ -1243,6 +1243,28 @@ declare class MiniAppSDK {
1243
1243
  */
1244
1244
  render: typeof renderMap;
1245
1245
  }>;
1246
+ /**
1247
+ * QR code generation — the single source of truth for every Mini-App.
1248
+ * Runs entirely client-side (canvas, no Host Shell round-trip) and returns
1249
+ * a base64 PNG data URI, ready for an `<img src>` or `media.saveImage()`.
1250
+ * Mini-Apps must not reimplement this on their own.
1251
+ */
1252
+ readonly qrCode: Readonly<{
1253
+ /**
1254
+ * Decodes a QR code from a static image (base64 data URI or URL) —
1255
+ * e.g. a photo picked via `sdk.media.pickImage()` that already
1256
+ * contains a QR code, as an alternative to the live `<QRScanner>`.
1257
+ * @param imageDataUrl A base64 data URI (e.g. from `sdk.media.pickImage()`).
1258
+ * @returns The decoded string, or `null` if no QR code was found.
1259
+ */
1260
+ decode: (imageDataUrl: string) => Promise<string | null>;
1261
+ /**
1262
+ * @param data The value to encode (e.g. a deep link).
1263
+ * @param options Styling/labeling options — see {@link IGenerateQrCodeOptions}.
1264
+ * @returns A base64 PNG data URI.
1265
+ */
1266
+ generate: (data: string, options?: IGenerateQrCodeOptions) => Promise<string>;
1267
+ }>;
1246
1268
  private bridge;
1247
1269
  /**
1248
1270
  * Local SQLite Storage.
@@ -1349,28 +1371,6 @@ declare class MiniAppSDK {
1349
1371
  */
1350
1372
  saveImage: (base64: string, filename?: string) => Promise<ISaveImageResult>;
1351
1373
  }>;
1352
- /**
1353
- * QR code generation — the single source of truth for every Mini-App.
1354
- * Runs entirely client-side (canvas, no Host Shell round-trip) and returns
1355
- * a base64 PNG data URI, ready for an `<img src>` or `media.saveImage()`.
1356
- * Mini-Apps must not reimplement this on their own.
1357
- */
1358
- readonly qrCode: Readonly<{
1359
- /**
1360
- * @param data The value to encode (e.g. a deep link).
1361
- * @param options Styling/labeling options — see {@link IGenerateQrCodeOptions}.
1362
- * @returns A base64 PNG data URI.
1363
- */
1364
- generate: (data: string, options?: IGenerateQrCodeOptions) => Promise<string>;
1365
- /**
1366
- * Decodes a QR code from a static image (base64 data URI or URL) —
1367
- * e.g. a photo picked via `sdk.media.pickImage()` that already
1368
- * contains a QR code, as an alternative to the live `<QRScanner>`.
1369
- * @param imageDataUrl A base64 data URI (e.g. from `sdk.media.pickImage()`).
1370
- * @returns The decoded string, or `null` if no QR code was found.
1371
- */
1372
- decode: (imageDataUrl: string) => Promise<string | null>;
1373
- }>;
1374
1374
  /**
1375
1375
  * Payments integration.
1376
1376
  */
@@ -1614,6 +1614,15 @@ interface WsMessage {
1614
1614
  event?: string;
1615
1615
  [key: string]: unknown;
1616
1616
  }
1617
+ /**
1618
+ * `"open"` is the only state where the wire connection is actually live —
1619
+ * `"connecting"` covers both the initial handshake and every reconnect
1620
+ * backoff wait, `"closed"` covers not-yet-started and lost-and-not-yet-
1621
+ * retried. A consumer that wants a poll-based fallback (only meaningful
1622
+ * while genuinely disconnected) should treat anything other than `"open"`
1623
+ * as "poll".
1624
+ */
1625
+ type WsConnectionStatus = "connecting" | "open" | "closed";
1617
1626
  interface BaseWsServiceOptions<TMessage extends WsMessage> {
1618
1627
  /**
1619
1628
  * The REST client from `createApiService` — reused here for two things:
@@ -1720,6 +1729,21 @@ interface WsServiceClient<TMessage extends WsMessage = WsMessage> {
1720
1729
  * function.
1721
1730
  */
1722
1731
  onMessage(callback: (message: TMessage) => void): () => void;
1732
+ /**
1733
+ * Current connection status, read synchronously — no subscription needed
1734
+ * for a one-off check.
1735
+ */
1736
+ getStatus(): WsConnectionStatus;
1737
+ /**
1738
+ * Subscribes to connection status transitions. Fires once immediately
1739
+ * with the current status on subscribe, then again on every change.
1740
+ * Returns an unsubscribe function. Intended for a consumer that wants a
1741
+ * poll-based fallback only while genuinely disconnected (see
1742
+ * `WsConnectionStatus`'s own doc comment) — driving that off `onMessage`
1743
+ * pings alone can't distinguish "connected but quiet" from "never
1744
+ * connected".
1745
+ */
1746
+ onStatusChange(callback: (status: WsConnectionStatus) => void): () => void;
1723
1747
  }
1724
1748
  interface BroadcastWsServiceClient<TMessage extends WsMessage = WsMessage> {
1725
1749
  /** Opens the connection if not already open/connecting. Safe to call repeatedly. */
@@ -1733,6 +1757,10 @@ interface BroadcastWsServiceClient<TMessage extends WsMessage = WsMessage> {
1733
1757
  * client. Implicitly calls `connect()`. Returns an unsubscribe function.
1734
1758
  */
1735
1759
  onMessage(callback: (message: TMessage) => void): () => void;
1760
+ /** Current connection status, read synchronously. See `WsConnectionStatus`. */
1761
+ getStatus(): WsConnectionStatus;
1762
+ /** Subscribes to connection status transitions. See `WsServiceClient.onStatusChange`. */
1763
+ onStatusChange(callback: (status: WsConnectionStatus) => void): () => void;
1736
1764
  }
1737
1765
  /**
1738
1766
  * Creates a reconnecting, (usually) authenticated WebSocket client — the WS
@@ -1769,4 +1797,4 @@ interface BroadcastWsServiceClient<TMessage extends WsMessage = WsMessage> {
1769
1797
  declare function createWsService<TMessage extends WsMessage = WsMessage>(options: CreateChannelWsServiceOptions<TMessage>): WsServiceClient<TMessage>;
1770
1798
  declare function createWsService<TMessage extends WsMessage = WsMessage>(options: CreateBroadcastWsServiceOptions<TMessage>): BroadcastWsServiceClient<TMessage>;
1771
1799
 
1772
- export { type ApiServiceClient, type BridgeMessageType, BridgeMocker, type BridgeMockerProps, type BroadcastWsServiceClient, type CenterCallbackParams, type CreateApiServiceOptions, type CreateBroadcastWsServiceOptions, type CreateChannelWsServiceOptions, type CreateWsServiceOptions, 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, type WsMessage, type WsServiceClient, createApiService, createWsService, sdk as default, renderMap, sdk, useIsMocked, useJourney, useLiveRouting, useMapControls, useMockLocation, useRoute, useTrimmedRoute, useUserLocation };
1800
+ export { type ApiServiceClient, type BridgeMessageType, BridgeMocker, type BridgeMockerProps, type BroadcastWsServiceClient, type CenterCallbackParams, type CreateApiServiceOptions, type CreateBroadcastWsServiceOptions, type CreateChannelWsServiceOptions, type CreateWsServiceOptions, 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, type WsConnectionStatus, type WsMessage, type WsServiceClient, createApiService, createWsService, sdk as default, renderMap, sdk, useIsMocked, useJourney, useLiveRouting, useMapControls, useMockLocation, useRoute, useTrimmedRoute, useUserLocation };
package/dist/index.d.ts CHANGED
@@ -2,7 +2,7 @@ import * as React from 'react';
2
2
  import React__default, { ReactNode } from 'react';
3
3
  import { R as RouteResponse, a as RouteStep, b as RouteRequest, c as RoutingBackendConfig } from './index-B9dDciJq.js';
4
4
  export { C as ClearRouteRequest, D as DrawRouteRequest, h as handleClearRoute, d as handleDrawRoute, e as handleRouteRequest } from './index-B9dDciJq.js';
5
- import { ViewState } from '@vis.gl/react-maplibre';
5
+ import { ViewState, StyleSpecification, ImmutableLike } from '@vis.gl/react-maplibre';
6
6
  import * as react_dom_client from 'react-dom/client';
7
7
  import { ShapeType, ErrorCorrectionLevel, DotType, Gradient, CornerSquareType, CornerDotType } from 'qr-code-styling';
8
8
  import 'maplibre-gl';
@@ -681,8 +681,8 @@ interface MapProps {
681
681
  style?: React__default.CSSProperties;
682
682
  /** Minimum and maximum bounds for the map. */
683
683
  maxBounds?: [[number, number], [number, number]];
684
- /** MapLibre style URL. Defaults to local server. */
685
- mapStyle?: string;
684
+ /** MapLibre style URL, or an inline style spec object. Defaults to local server. */
685
+ mapStyle?: string | StyleSpecification | ImmutableLike<StyleSpecification>;
686
686
  /** Children components (Source, Layer, etc.) */
687
687
  children?: React__default.ReactNode;
688
688
  /** Additional CSS classes for the map container. */
@@ -1243,6 +1243,28 @@ declare class MiniAppSDK {
1243
1243
  */
1244
1244
  render: typeof renderMap;
1245
1245
  }>;
1246
+ /**
1247
+ * QR code generation — the single source of truth for every Mini-App.
1248
+ * Runs entirely client-side (canvas, no Host Shell round-trip) and returns
1249
+ * a base64 PNG data URI, ready for an `<img src>` or `media.saveImage()`.
1250
+ * Mini-Apps must not reimplement this on their own.
1251
+ */
1252
+ readonly qrCode: Readonly<{
1253
+ /**
1254
+ * Decodes a QR code from a static image (base64 data URI or URL) —
1255
+ * e.g. a photo picked via `sdk.media.pickImage()` that already
1256
+ * contains a QR code, as an alternative to the live `<QRScanner>`.
1257
+ * @param imageDataUrl A base64 data URI (e.g. from `sdk.media.pickImage()`).
1258
+ * @returns The decoded string, or `null` if no QR code was found.
1259
+ */
1260
+ decode: (imageDataUrl: string) => Promise<string | null>;
1261
+ /**
1262
+ * @param data The value to encode (e.g. a deep link).
1263
+ * @param options Styling/labeling options — see {@link IGenerateQrCodeOptions}.
1264
+ * @returns A base64 PNG data URI.
1265
+ */
1266
+ generate: (data: string, options?: IGenerateQrCodeOptions) => Promise<string>;
1267
+ }>;
1246
1268
  private bridge;
1247
1269
  /**
1248
1270
  * Local SQLite Storage.
@@ -1349,28 +1371,6 @@ declare class MiniAppSDK {
1349
1371
  */
1350
1372
  saveImage: (base64: string, filename?: string) => Promise<ISaveImageResult>;
1351
1373
  }>;
1352
- /**
1353
- * QR code generation — the single source of truth for every Mini-App.
1354
- * Runs entirely client-side (canvas, no Host Shell round-trip) and returns
1355
- * a base64 PNG data URI, ready for an `<img src>` or `media.saveImage()`.
1356
- * Mini-Apps must not reimplement this on their own.
1357
- */
1358
- readonly qrCode: Readonly<{
1359
- /**
1360
- * @param data The value to encode (e.g. a deep link).
1361
- * @param options Styling/labeling options — see {@link IGenerateQrCodeOptions}.
1362
- * @returns A base64 PNG data URI.
1363
- */
1364
- generate: (data: string, options?: IGenerateQrCodeOptions) => Promise<string>;
1365
- /**
1366
- * Decodes a QR code from a static image (base64 data URI or URL) —
1367
- * e.g. a photo picked via `sdk.media.pickImage()` that already
1368
- * contains a QR code, as an alternative to the live `<QRScanner>`.
1369
- * @param imageDataUrl A base64 data URI (e.g. from `sdk.media.pickImage()`).
1370
- * @returns The decoded string, or `null` if no QR code was found.
1371
- */
1372
- decode: (imageDataUrl: string) => Promise<string | null>;
1373
- }>;
1374
1374
  /**
1375
1375
  * Payments integration.
1376
1376
  */
@@ -1614,6 +1614,15 @@ interface WsMessage {
1614
1614
  event?: string;
1615
1615
  [key: string]: unknown;
1616
1616
  }
1617
+ /**
1618
+ * `"open"` is the only state where the wire connection is actually live —
1619
+ * `"connecting"` covers both the initial handshake and every reconnect
1620
+ * backoff wait, `"closed"` covers not-yet-started and lost-and-not-yet-
1621
+ * retried. A consumer that wants a poll-based fallback (only meaningful
1622
+ * while genuinely disconnected) should treat anything other than `"open"`
1623
+ * as "poll".
1624
+ */
1625
+ type WsConnectionStatus = "connecting" | "open" | "closed";
1617
1626
  interface BaseWsServiceOptions<TMessage extends WsMessage> {
1618
1627
  /**
1619
1628
  * The REST client from `createApiService` — reused here for two things:
@@ -1720,6 +1729,21 @@ interface WsServiceClient<TMessage extends WsMessage = WsMessage> {
1720
1729
  * function.
1721
1730
  */
1722
1731
  onMessage(callback: (message: TMessage) => void): () => void;
1732
+ /**
1733
+ * Current connection status, read synchronously — no subscription needed
1734
+ * for a one-off check.
1735
+ */
1736
+ getStatus(): WsConnectionStatus;
1737
+ /**
1738
+ * Subscribes to connection status transitions. Fires once immediately
1739
+ * with the current status on subscribe, then again on every change.
1740
+ * Returns an unsubscribe function. Intended for a consumer that wants a
1741
+ * poll-based fallback only while genuinely disconnected (see
1742
+ * `WsConnectionStatus`'s own doc comment) — driving that off `onMessage`
1743
+ * pings alone can't distinguish "connected but quiet" from "never
1744
+ * connected".
1745
+ */
1746
+ onStatusChange(callback: (status: WsConnectionStatus) => void): () => void;
1723
1747
  }
1724
1748
  interface BroadcastWsServiceClient<TMessage extends WsMessage = WsMessage> {
1725
1749
  /** Opens the connection if not already open/connecting. Safe to call repeatedly. */
@@ -1733,6 +1757,10 @@ interface BroadcastWsServiceClient<TMessage extends WsMessage = WsMessage> {
1733
1757
  * client. Implicitly calls `connect()`. Returns an unsubscribe function.
1734
1758
  */
1735
1759
  onMessage(callback: (message: TMessage) => void): () => void;
1760
+ /** Current connection status, read synchronously. See `WsConnectionStatus`. */
1761
+ getStatus(): WsConnectionStatus;
1762
+ /** Subscribes to connection status transitions. See `WsServiceClient.onStatusChange`. */
1763
+ onStatusChange(callback: (status: WsConnectionStatus) => void): () => void;
1736
1764
  }
1737
1765
  /**
1738
1766
  * Creates a reconnecting, (usually) authenticated WebSocket client — the WS
@@ -1769,4 +1797,4 @@ interface BroadcastWsServiceClient<TMessage extends WsMessage = WsMessage> {
1769
1797
  declare function createWsService<TMessage extends WsMessage = WsMessage>(options: CreateChannelWsServiceOptions<TMessage>): WsServiceClient<TMessage>;
1770
1798
  declare function createWsService<TMessage extends WsMessage = WsMessage>(options: CreateBroadcastWsServiceOptions<TMessage>): BroadcastWsServiceClient<TMessage>;
1771
1799
 
1772
- export { type ApiServiceClient, type BridgeMessageType, BridgeMocker, type BridgeMockerProps, type BroadcastWsServiceClient, type CenterCallbackParams, type CreateApiServiceOptions, type CreateBroadcastWsServiceOptions, type CreateChannelWsServiceOptions, type CreateWsServiceOptions, 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, type WsMessage, type WsServiceClient, createApiService, createWsService, sdk as default, renderMap, sdk, useIsMocked, useJourney, useLiveRouting, useMapControls, useMockLocation, useRoute, useTrimmedRoute, useUserLocation };
1800
+ export { type ApiServiceClient, type BridgeMessageType, BridgeMocker, type BridgeMockerProps, type BroadcastWsServiceClient, type CenterCallbackParams, type CreateApiServiceOptions, type CreateBroadcastWsServiceOptions, type CreateChannelWsServiceOptions, type CreateWsServiceOptions, 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, type WsConnectionStatus, type WsMessage, type WsServiceClient, createApiService, createWsService, sdk as default, renderMap, sdk, useIsMocked, useJourney, useLiveRouting, useMapControls, useMockLocation, useRoute, useTrimmedRoute, useUserLocation };
package/dist/index.js CHANGED
@@ -161,35 +161,6 @@ var Bridge = class {
161
161
  return this.send(type, payload, timeoutMs, retries - 1);
162
162
  });
163
163
  }
164
- sendOnce(type, payload, timeoutMs) {
165
- return new Promise((resolve, reject) => {
166
- const callbackId = `${type}_${Date.now()}_${Math.random().toString(36).substring(2, 9)}`;
167
- const timeout = setTimeout(() => {
168
- if (this.callbacks.has(callbackId)) {
169
- this.callbacks.delete(callbackId);
170
- reject(new BridgeTimeoutError(`Bridge request timeout: ${type}`));
171
- }
172
- }, timeoutMs);
173
- this.callbacks.set(callbackId, {
174
- reject,
175
- resolve,
176
- timeout
177
- });
178
- const message = {
179
- callbackId,
180
- payload,
181
- type
182
- };
183
- const win = window;
184
- if (win.ReactNativeWebView?.postMessage) {
185
- win.ReactNativeWebView.postMessage(JSON.stringify(message));
186
- } else {
187
- clearTimeout(timeout);
188
- this.callbacks.delete(callbackId);
189
- reject(new Error("Bridge not available"));
190
- }
191
- });
192
- }
193
164
  /**
194
165
  * Internal handler for all incoming messages from the native shell.
195
166
  * Matches incoming payloads to either pending callbacks or event listeners.
@@ -237,6 +208,35 @@ var Bridge = class {
237
208
  console.warn(`[Bridge] Mock mode active: Unhandled message type ${type}`);
238
209
  return Promise.resolve();
239
210
  }
211
+ sendOnce(type, payload, timeoutMs) {
212
+ return new Promise((resolve, reject) => {
213
+ const callbackId = `${type}_${Date.now()}_${Math.random().toString(36).substring(2, 9)}`;
214
+ const timeout = setTimeout(() => {
215
+ if (this.callbacks.has(callbackId)) {
216
+ this.callbacks.delete(callbackId);
217
+ reject(new BridgeTimeoutError(`Bridge request timeout: ${type}`));
218
+ }
219
+ }, timeoutMs);
220
+ this.callbacks.set(callbackId, {
221
+ reject,
222
+ resolve,
223
+ timeout
224
+ });
225
+ const message = {
226
+ callbackId,
227
+ payload,
228
+ type
229
+ };
230
+ const win = window;
231
+ if (win.ReactNativeWebView?.postMessage) {
232
+ win.ReactNativeWebView.postMessage(JSON.stringify(message));
233
+ } else {
234
+ clearTimeout(timeout);
235
+ this.callbacks.delete(callbackId);
236
+ reject(new Error("Bridge not available"));
237
+ }
238
+ });
239
+ }
240
240
  /**
241
241
  * Determine environment. Check flag or cache result.
242
242
  */
@@ -2444,18 +2444,6 @@ var RouteLayer = ({
2444
2444
  ] });
2445
2445
  };
2446
2446
 
2447
- // src/components/Map/Map.tsx
2448
- import { Map as MapLibre, MapProvider } from "@vis.gl/react-maplibre";
2449
- import React4, {
2450
- useCallback as useCallback6,
2451
- useContext as useContext5,
2452
- useEffect as useEffect7,
2453
- useMemo as useMemo6,
2454
- useRef as useRef7,
2455
- useState as useState8
2456
- } from "react";
2457
- import "maplibre-gl/dist/maplibre-gl.css";
2458
-
2459
2447
  // src/components/Map/utils/geoCircle.ts
2460
2448
  var EARTH_RADIUS_METERS = 6371e3;
2461
2449
  var buildGeoCircle = (center, radiusMeters, points = 64) => {
@@ -2847,6 +2835,16 @@ var UserLocationLayer = ({
2847
2835
  };
2848
2836
 
2849
2837
  // src/components/Map/Map.tsx
2838
+ import { Map as MapLibre, MapProvider } from "@vis.gl/react-maplibre";
2839
+ import React4, {
2840
+ useCallback as useCallback6,
2841
+ useContext as useContext5,
2842
+ useEffect as useEffect7,
2843
+ useMemo as useMemo6,
2844
+ useRef as useRef7,
2845
+ useState as useState8
2846
+ } from "react";
2847
+ import "maplibre-gl/dist/maplibre-gl.css";
2850
2848
  import { Fragment as Fragment4, jsx as jsx15, jsxs as jsxs11 } from "react/jsx-runtime";
2851
2849
  var MapInternal = ({
2852
2850
  initialViewState = {
@@ -3382,7 +3380,12 @@ async function generateQrCode(data, options = {}) {
3382
3380
  const outerPadding = options.outerPadding ?? 32;
3383
3381
  const borderRadiusPercent = options.borderRadius ?? DEFAULT_BORDER_RADIUS_PERCENT;
3384
3382
  const composed = label ? await composeWithLabel(qrDataUrl, label, size, backgroundColor, color) : qrDataUrl;
3385
- return finalizeImage(composed, outerPadding, borderRadiusPercent, backgroundColor);
3383
+ return finalizeImage(
3384
+ composed,
3385
+ outerPadding,
3386
+ borderRadiusPercent,
3387
+ backgroundColor
3388
+ );
3386
3389
  }
3387
3390
  var blobToDataUrl = (blob) => new Promise((resolve, reject) => {
3388
3391
  const reader = new FileReader();
@@ -3487,7 +3490,7 @@ var loadImage2 = (src) => new Promise((resolve, reject) => {
3487
3490
  });
3488
3491
 
3489
3492
  // package.json
3490
- var version = "0.6.1";
3493
+ var version = "0.6.3";
3491
3494
 
3492
3495
  // src/sdk.ts
3493
3496
  function deepFreeze(obj) {
@@ -3515,6 +3518,28 @@ var MiniAppSDK = class {
3515
3518
  */
3516
3519
  render: renderMap
3517
3520
  });
3521
+ /**
3522
+ * QR code generation — the single source of truth for every Mini-App.
3523
+ * Runs entirely client-side (canvas, no Host Shell round-trip) and returns
3524
+ * a base64 PNG data URI, ready for an `<img src>` or `media.saveImage()`.
3525
+ * Mini-Apps must not reimplement this on their own.
3526
+ */
3527
+ qrCode = Object.freeze({
3528
+ /**
3529
+ * Decodes a QR code from a static image (base64 data URI or URL) —
3530
+ * e.g. a photo picked via `sdk.media.pickImage()` that already
3531
+ * contains a QR code, as an alternative to the live `<QRScanner>`.
3532
+ * @param imageDataUrl A base64 data URI (e.g. from `sdk.media.pickImage()`).
3533
+ * @returns The decoded string, or `null` if no QR code was found.
3534
+ */
3535
+ decode: (imageDataUrl) => decodeQrCode(imageDataUrl),
3536
+ /**
3537
+ * @param data The value to encode (e.g. a deep link).
3538
+ * @param options Styling/labeling options — see {@link IGenerateQrCodeOptions}.
3539
+ * @returns A base64 PNG data URI.
3540
+ */
3541
+ generate: (data, options) => generateQrCode(data, options)
3542
+ });
3518
3543
  bridge;
3519
3544
  /**
3520
3545
  * Local SQLite Storage.
@@ -3618,28 +3643,6 @@ var MiniAppSDK = class {
3618
3643
  */
3619
3644
  saveImage: (base64, filename) => this.bridge.send("SAVE_IMAGE", { base64, filename })
3620
3645
  });
3621
- /**
3622
- * QR code generation — the single source of truth for every Mini-App.
3623
- * Runs entirely client-side (canvas, no Host Shell round-trip) and returns
3624
- * a base64 PNG data URI, ready for an `<img src>` or `media.saveImage()`.
3625
- * Mini-Apps must not reimplement this on their own.
3626
- */
3627
- qrCode = Object.freeze({
3628
- /**
3629
- * @param data The value to encode (e.g. a deep link).
3630
- * @param options Styling/labeling options — see {@link IGenerateQrCodeOptions}.
3631
- * @returns A base64 PNG data URI.
3632
- */
3633
- generate: (data, options) => generateQrCode(data, options),
3634
- /**
3635
- * Decodes a QR code from a static image (base64 data URI or URL) —
3636
- * e.g. a photo picked via `sdk.media.pickImage()` that already
3637
- * contains a QR code, as an alternative to the live `<QRScanner>`.
3638
- * @param imageDataUrl A base64 data URI (e.g. from `sdk.media.pickImage()`).
3639
- * @returns The decoded string, or `null` if no QR code was found.
3640
- */
3641
- decode: (imageDataUrl) => decodeQrCode(imageDataUrl)
3642
- });
3643
3646
  /**
3644
3647
  * Payments integration.
3645
3648
  */
@@ -3931,6 +3934,40 @@ function getMockAvatarUrl(seed) {
3931
3934
  const shortSeed = hashToShortSeed(seed);
3932
3935
  return `https://api.dicebear.com/10.x/notionists-neutral/png?seed=${shortSeed}&mouth=${AVATAR_MOUTH_VARIANTS}&eyes=${AVATAR_EYES_VARIANTS}&glassesProbability=50`;
3933
3936
  }
3937
+ function decodeMockJWTPayload(token) {
3938
+ try {
3939
+ const raw = token.startsWith("Bearer ") ? token.slice(7) : token;
3940
+ const base64Url = raw.split(".")[1];
3941
+ const base64 = base64Url.replace(/-/g, "+").replace(/_/g, "/");
3942
+ const jsonPayload = decodeURIComponent(
3943
+ atob(base64).split("").map((c) => `%${`00${c.charCodeAt(0).toString(16)}`.slice(-2)}`).join("")
3944
+ );
3945
+ return JSON.parse(jsonPayload);
3946
+ } catch {
3947
+ return null;
3948
+ }
3949
+ }
3950
+ function buildMockProfile(mockJWTToken) {
3951
+ const claims = mockJWTToken ? decodeMockJWTPayload(mockJWTToken) : null;
3952
+ const uuid = claims?.sub || "mock-user-42";
3953
+ const fullName = claims?.name || claims?.username || "Smart Caveman";
3954
+ const username = claims?.username || "smart_caveman";
3955
+ const [firstName, ...lastNameParts] = fullName.split(" ");
3956
+ return {
3957
+ admin: true,
3958
+ countryCode: "FR",
3959
+ createdAt: (/* @__PURE__ */ new Date()).toISOString(),
3960
+ email: "caveman@up.app",
3961
+ firstName: firstName || "Smart",
3962
+ fullName,
3963
+ lastName: lastNameParts.join(" ") || "Caveman",
3964
+ localNumber: "0600000000",
3965
+ ups: 100,
3966
+ username,
3967
+ uuid,
3968
+ xp: 500
3969
+ };
3970
+ }
3934
3971
  var getBearing = (p1, p2) => {
3935
3972
  const lat1 = p1[1] * Math.PI / 180;
3936
3973
  const lat2 = p2[1] * Math.PI / 180;
@@ -4162,20 +4199,7 @@ var BridgeMocker = ({
4162
4199
  insets: { bottom: 0, left: 0, right: 0, top: 0 },
4163
4200
  name: "Vite Dev (Mock)",
4164
4201
  params: {},
4165
- profile: {
4166
- admin: true,
4167
- countryCode: "FR",
4168
- createdAt: (/* @__PURE__ */ new Date()).toISOString(),
4169
- email: "caveman@up.app",
4170
- firstName: "Smart",
4171
- fullName: "Smart Caveman",
4172
- lastName: "Caveman",
4173
- localNumber: "0600000000",
4174
- ups: 100,
4175
- username: "smart_caveman",
4176
- uuid: "mock-user-42",
4177
- xp: 500
4178
- },
4202
+ profile: buildMockProfile(stateRef.current.mockJWTToken),
4179
4203
  success: true,
4180
4204
  userData: {},
4181
4205
  uuid: appId || "mock-app-id",
@@ -4216,20 +4240,7 @@ var BridgeMocker = ({
4216
4240
  return Promise.resolve();
4217
4241
  }
4218
4242
  if (type === "GET_USER_PROFILE") {
4219
- return Promise.resolve({
4220
- admin: true,
4221
- countryCode: "FR",
4222
- createdAt: (/* @__PURE__ */ new Date()).toISOString(),
4223
- email: "caveman@up.app",
4224
- firstName: "Smart",
4225
- fullName: "Smart Caveman",
4226
- lastName: "Caveman",
4227
- localNumber: "0600000000",
4228
- ups: 100,
4229
- username: "smart_caveman",
4230
- uuid: "mock-user-42",
4231
- xp: 500
4232
- });
4243
+ return Promise.resolve(buildMockProfile(stateRef.current.mockJWTToken));
4233
4244
  }
4234
4245
  if (type === "GET_PROFILE_PICTURE") {
4235
4246
  const uuids = payload?.uuids || [];
@@ -5093,6 +5104,13 @@ function createWsService(options) {
5093
5104
  let reconnectTimeout = null;
5094
5105
  let reconnectDelay = 1e3;
5095
5106
  let isConnecting = false;
5107
+ let status = "closed";
5108
+ const statusListeners = /* @__PURE__ */ new Set();
5109
+ const setStatus = (next) => {
5110
+ if (status === next) return;
5111
+ status = next;
5112
+ for (const cb of statusListeners) cb(status);
5113
+ };
5096
5114
  const getWsUrl = () => options.baseUrl || options.api.wsUrl || "";
5097
5115
  const sendAction = (action, channelId) => {
5098
5116
  if (ws?.readyState === WebSocket.OPEN) {
@@ -5111,6 +5129,7 @@ function createWsService(options) {
5111
5129
  return;
5112
5130
  }
5113
5131
  isConnecting = true;
5132
+ setStatus("connecting");
5114
5133
  try {
5115
5134
  const wsUrl = getWsUrl();
5116
5135
  if (!wsUrl) {
@@ -5118,6 +5137,7 @@ function createWsService(options) {
5118
5137
  "[WS] No WebSocket backend URL available, connection delayed."
5119
5138
  );
5120
5139
  isConnecting = false;
5140
+ setStatus("closed");
5121
5141
  return;
5122
5142
  }
5123
5143
  let authParams = {};
@@ -5133,6 +5153,7 @@ function createWsService(options) {
5133
5153
  } else {
5134
5154
  console.warn("[WS] No auth available, connection delayed.");
5135
5155
  isConnecting = false;
5156
+ setStatus("closed");
5136
5157
  return;
5137
5158
  }
5138
5159
  const params = new URLSearchParams({ ...options.query, ...authParams });
@@ -5140,6 +5161,7 @@ function createWsService(options) {
5140
5161
  ws = new WebSocket(query ? `${wsUrl}?${query}` : wsUrl);
5141
5162
  ws.onopen = () => {
5142
5163
  isConnecting = false;
5164
+ setStatus("open");
5143
5165
  reconnectDelay = 1e3;
5144
5166
  if (channelField) {
5145
5167
  for (const channelId of subscriptions.keys()) {
@@ -5166,6 +5188,7 @@ function createWsService(options) {
5166
5188
  };
5167
5189
  ws.onclose = () => {
5168
5190
  isConnecting = false;
5191
+ setStatus("closed");
5169
5192
  scheduleReconnect();
5170
5193
  };
5171
5194
  ws.onerror = (err) => {
@@ -5176,6 +5199,7 @@ function createWsService(options) {
5176
5199
  } catch (err) {
5177
5200
  console.error("[WS] Failed to establish connection:", err);
5178
5201
  isConnecting = false;
5202
+ setStatus("closed");
5179
5203
  scheduleReconnect();
5180
5204
  }
5181
5205
  };
@@ -5189,6 +5213,15 @@ function createWsService(options) {
5189
5213
  ws.close();
5190
5214
  ws = null;
5191
5215
  }
5216
+ setStatus("closed");
5217
+ };
5218
+ const getStatus = () => status;
5219
+ const onStatusChange = (callback) => {
5220
+ statusListeners.add(callback);
5221
+ callback(status);
5222
+ return () => {
5223
+ statusListeners.delete(callback);
5224
+ };
5192
5225
  };
5193
5226
  const subscribe = (channelId, callback) => {
5194
5227
  const isNewChannel = !subscriptions.has(channelId);
@@ -5214,9 +5247,16 @@ function createWsService(options) {
5214
5247
  };
5215
5248
  };
5216
5249
  if (channelField) {
5217
- return { connect, disconnect, onMessage, subscribe };
5250
+ return {
5251
+ connect,
5252
+ disconnect,
5253
+ getStatus,
5254
+ onMessage,
5255
+ onStatusChange,
5256
+ subscribe
5257
+ };
5218
5258
  }
5219
- return { connect, disconnect, onMessage };
5259
+ return { connect, disconnect, getStatus, onMessage, onStatusChange };
5220
5260
  }
5221
5261
 
5222
5262
  // src/index.ts