@cloudparse/up-miniapps-sdk 0.6.8 → 0.7.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
@@ -1,5 +1,5 @@
1
1
  import * as React from 'react';
2
- import React__default, { ReactNode } from 'react';
2
+ import React__default, { ReactNode, TouchEvent } 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
5
  import { ViewState, StyleSpecification, ImmutableLike } from '@vis.gl/react-maplibre';
@@ -211,6 +211,45 @@ interface IFidelityTransaction {
211
211
  /** Type of transaction */
212
212
  type: FidelityTransactionTypeType;
213
213
  }
214
+ /**
215
+ * Achievement Types
216
+ */
217
+ /**
218
+ * A player's progress towards a single named Achievement. The Hub tracks a
219
+ * raw in-app action count per Achievement `slug` (reported server-to-server
220
+ * by each mini-app's own backend — never by this SDK, see `sdk.achievement`/
221
+ * `sdk.achievements` doc comments in `sdk.ts`) and auto-credits UP+XP once
222
+ * `playerActionCount` reaches `totalActionCount`. This is a read-only view
223
+ * for rendering progress (e.g. a progress bar) — there is no "claim" step.
224
+ */
225
+ interface IAchievement {
226
+ /** Unique slug identifying the Achievement (e.g. "explore-5-pois"). */
227
+ slug: string;
228
+ /** Display title. */
229
+ title: string;
230
+ /** Display description. */
231
+ description: string;
232
+ /** The player's current raw in-app action count towards this Achievement. */
233
+ playerActionCount: number;
234
+ /** The action count required to complete this Achievement. */
235
+ totalActionCount: number;
236
+ /** UP points credited automatically once completed. */
237
+ upReward: number;
238
+ /** XP credited automatically once completed. */
239
+ xpReward: number;
240
+ /** Whether `playerActionCount` has reached `totalActionCount`. */
241
+ completed: boolean;
242
+ /** Optional illustration/icon URL. */
243
+ imageUrl?: string;
244
+ /**
245
+ * Progression order among this mini-app's own Achievements — lower comes
246
+ * first (1 = first Achievement a player should complete). Achievements
247
+ * unlock sequentially: only the lowest-`priority` not-yet-`completed`
248
+ * Achievement is actionable, every higher-`priority` one stays locked
249
+ * until it completes. Ties are allowed (no uniqueness enforced).
250
+ */
251
+ priority: number;
252
+ }
214
253
  /**
215
254
  * The initialization options required to set up the Mini-App SDK.
216
255
  */
@@ -553,6 +592,16 @@ type BridgeMessageType = {
553
592
  type: "GET_FIDELITY_HISTORY";
554
593
  payload: IFidelityHistoryParams;
555
594
  callbackId: string;
595
+ } | {
596
+ type: "GET_ACHIEVEMENT";
597
+ payload: {
598
+ slug: string;
599
+ };
600
+ callbackId: string;
601
+ } | {
602
+ type: "GET_ACHIEVEMENTS";
603
+ payload?: unknown;
604
+ callbackId: string;
556
605
  } | {
557
606
  type: "EXIT";
558
607
  payload?: unknown;
@@ -1259,6 +1308,12 @@ interface SwipeCarouselProps {
1259
1308
  }
1260
1309
  declare const SwipeCarousel: ({ items, activeId, onActiveChange, peek, gap, className, itemClassName, axisPriority, verticalDrag, overscan, visibleOverscan, }: SwipeCarouselProps) => React.JSX.Element;
1261
1310
 
1311
+ declare const useTapAction: (action: () => void) => {
1312
+ onClick: () => void;
1313
+ onTouchEnd: (e: TouchEvent<HTMLElement>) => void;
1314
+ onTouchStart: (e: TouchEvent<HTMLElement>) => void;
1315
+ };
1316
+
1262
1317
  declare class MiniAppSDK {
1263
1318
  /**
1264
1319
  * Map services.
@@ -1470,7 +1525,7 @@ declare class MiniAppSDK {
1470
1525
  start: () => void;
1471
1526
  }>;
1472
1527
  /**
1473
- * Fidelity & Rewards program integration.
1528
+ * Fidelity & Points program integration.
1474
1529
  */
1475
1530
  readonly fidelity: Readonly<{
1476
1531
  /** Returns current fidelity balance. */
@@ -1565,6 +1620,19 @@ declare class MiniAppSDK {
1565
1620
  * Returns `null` before the first successful `initialize()`/context push.
1566
1621
  */
1567
1622
  getEnv<T extends Record<string, unknown> = Record<string, unknown>>(): T | null;
1623
+ /**
1624
+ * Fetches a single Achievement's current progress by slug — read-only, for
1625
+ * rendering things like a progress bar. Progress is reported server-side
1626
+ * by the mini-app's own backend calling the Hub's M2M endpoint directly;
1627
+ * there is no corresponding "report progress" method on this SDK.
1628
+ * @param slug Unique slug identifying the Achievement.
1629
+ */
1630
+ achievement(slug: string): Promise<IAchievement>;
1631
+ /**
1632
+ * Fetches every Achievement (with current progress) visible to this
1633
+ * mini-app — read-only, same boundary as {@link MiniAppSDK.achievement}.
1634
+ */
1635
+ achievements(): Promise<IAchievement[]>;
1568
1636
  /**
1569
1637
  * Registers a callback for a specific event from the native shell.
1570
1638
  * @param event The name of the event to listen for.
@@ -1825,4 +1893,4 @@ interface BroadcastWsServiceClient<TMessage extends WsMessage = WsMessage> {
1825
1893
  declare function createWsService<TMessage extends WsMessage = WsMessage>(options: CreateChannelWsServiceOptions<TMessage>): WsServiceClient<TMessage>;
1826
1894
  declare function createWsService<TMessage extends WsMessage = WsMessage>(options: CreateBroadcastWsServiceOptions<TMessage>): BroadcastWsServiceClient<TMessage>;
1827
1895
 
1828
- 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, PullToRefresh, type PullToRefreshIndicatorState, type PullToRefreshProps, 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 };
1896
+ 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 IAchievement, 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, PullToRefresh, type PullToRefreshIndicatorState, type PullToRefreshProps, 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, useTapAction, useTrimmedRoute, useUserLocation };
package/dist/index.d.ts CHANGED
@@ -1,5 +1,5 @@
1
1
  import * as React from 'react';
2
- import React__default, { ReactNode } from 'react';
2
+ import React__default, { ReactNode, TouchEvent } 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
5
  import { ViewState, StyleSpecification, ImmutableLike } from '@vis.gl/react-maplibre';
@@ -211,6 +211,45 @@ interface IFidelityTransaction {
211
211
  /** Type of transaction */
212
212
  type: FidelityTransactionTypeType;
213
213
  }
214
+ /**
215
+ * Achievement Types
216
+ */
217
+ /**
218
+ * A player's progress towards a single named Achievement. The Hub tracks a
219
+ * raw in-app action count per Achievement `slug` (reported server-to-server
220
+ * by each mini-app's own backend — never by this SDK, see `sdk.achievement`/
221
+ * `sdk.achievements` doc comments in `sdk.ts`) and auto-credits UP+XP once
222
+ * `playerActionCount` reaches `totalActionCount`. This is a read-only view
223
+ * for rendering progress (e.g. a progress bar) — there is no "claim" step.
224
+ */
225
+ interface IAchievement {
226
+ /** Unique slug identifying the Achievement (e.g. "explore-5-pois"). */
227
+ slug: string;
228
+ /** Display title. */
229
+ title: string;
230
+ /** Display description. */
231
+ description: string;
232
+ /** The player's current raw in-app action count towards this Achievement. */
233
+ playerActionCount: number;
234
+ /** The action count required to complete this Achievement. */
235
+ totalActionCount: number;
236
+ /** UP points credited automatically once completed. */
237
+ upReward: number;
238
+ /** XP credited automatically once completed. */
239
+ xpReward: number;
240
+ /** Whether `playerActionCount` has reached `totalActionCount`. */
241
+ completed: boolean;
242
+ /** Optional illustration/icon URL. */
243
+ imageUrl?: string;
244
+ /**
245
+ * Progression order among this mini-app's own Achievements — lower comes
246
+ * first (1 = first Achievement a player should complete). Achievements
247
+ * unlock sequentially: only the lowest-`priority` not-yet-`completed`
248
+ * Achievement is actionable, every higher-`priority` one stays locked
249
+ * until it completes. Ties are allowed (no uniqueness enforced).
250
+ */
251
+ priority: number;
252
+ }
214
253
  /**
215
254
  * The initialization options required to set up the Mini-App SDK.
216
255
  */
@@ -553,6 +592,16 @@ type BridgeMessageType = {
553
592
  type: "GET_FIDELITY_HISTORY";
554
593
  payload: IFidelityHistoryParams;
555
594
  callbackId: string;
595
+ } | {
596
+ type: "GET_ACHIEVEMENT";
597
+ payload: {
598
+ slug: string;
599
+ };
600
+ callbackId: string;
601
+ } | {
602
+ type: "GET_ACHIEVEMENTS";
603
+ payload?: unknown;
604
+ callbackId: string;
556
605
  } | {
557
606
  type: "EXIT";
558
607
  payload?: unknown;
@@ -1259,6 +1308,12 @@ interface SwipeCarouselProps {
1259
1308
  }
1260
1309
  declare const SwipeCarousel: ({ items, activeId, onActiveChange, peek, gap, className, itemClassName, axisPriority, verticalDrag, overscan, visibleOverscan, }: SwipeCarouselProps) => React.JSX.Element;
1261
1310
 
1311
+ declare const useTapAction: (action: () => void) => {
1312
+ onClick: () => void;
1313
+ onTouchEnd: (e: TouchEvent<HTMLElement>) => void;
1314
+ onTouchStart: (e: TouchEvent<HTMLElement>) => void;
1315
+ };
1316
+
1262
1317
  declare class MiniAppSDK {
1263
1318
  /**
1264
1319
  * Map services.
@@ -1470,7 +1525,7 @@ declare class MiniAppSDK {
1470
1525
  start: () => void;
1471
1526
  }>;
1472
1527
  /**
1473
- * Fidelity & Rewards program integration.
1528
+ * Fidelity & Points program integration.
1474
1529
  */
1475
1530
  readonly fidelity: Readonly<{
1476
1531
  /** Returns current fidelity balance. */
@@ -1565,6 +1620,19 @@ declare class MiniAppSDK {
1565
1620
  * Returns `null` before the first successful `initialize()`/context push.
1566
1621
  */
1567
1622
  getEnv<T extends Record<string, unknown> = Record<string, unknown>>(): T | null;
1623
+ /**
1624
+ * Fetches a single Achievement's current progress by slug — read-only, for
1625
+ * rendering things like a progress bar. Progress is reported server-side
1626
+ * by the mini-app's own backend calling the Hub's M2M endpoint directly;
1627
+ * there is no corresponding "report progress" method on this SDK.
1628
+ * @param slug Unique slug identifying the Achievement.
1629
+ */
1630
+ achievement(slug: string): Promise<IAchievement>;
1631
+ /**
1632
+ * Fetches every Achievement (with current progress) visible to this
1633
+ * mini-app — read-only, same boundary as {@link MiniAppSDK.achievement}.
1634
+ */
1635
+ achievements(): Promise<IAchievement[]>;
1568
1636
  /**
1569
1637
  * Registers a callback for a specific event from the native shell.
1570
1638
  * @param event The name of the event to listen for.
@@ -1825,4 +1893,4 @@ interface BroadcastWsServiceClient<TMessage extends WsMessage = WsMessage> {
1825
1893
  declare function createWsService<TMessage extends WsMessage = WsMessage>(options: CreateChannelWsServiceOptions<TMessage>): WsServiceClient<TMessage>;
1826
1894
  declare function createWsService<TMessage extends WsMessage = WsMessage>(options: CreateBroadcastWsServiceOptions<TMessage>): BroadcastWsServiceClient<TMessage>;
1827
1895
 
1828
- 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, PullToRefresh, type PullToRefreshIndicatorState, type PullToRefreshProps, 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 };
1896
+ 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 IAchievement, 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, PullToRefresh, type PullToRefreshIndicatorState, type PullToRefreshProps, 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, useTapAction, useTrimmedRoute, useUserLocation };