@cloudparse/up-miniapps-sdk 0.5.3 → 0.5.5

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
@@ -331,6 +331,13 @@ interface ScrollConfig {
331
331
  loadingMore?: boolean;
332
332
  };
333
333
  }
334
+ /**
335
+ * Result of a `sdk.media.saveImage` call.
336
+ */
337
+ interface ISaveImageResult {
338
+ /** Whether the image was saved successfully. */
339
+ success: boolean;
340
+ }
334
341
  /**
335
342
  * Edge insets representing padding or margins around a component, typically used for layout purposes.
336
343
  */
@@ -535,6 +542,13 @@ type BridgeMessageType = {
535
542
  type: "STOP_LOCATION_STREAM";
536
543
  payload?: never;
537
544
  callbackId: string;
545
+ } | {
546
+ type: "SAVE_IMAGE";
547
+ payload: {
548
+ base64: string;
549
+ filename?: string;
550
+ };
551
+ callbackId: string;
538
552
  } | {
539
553
  type: string;
540
554
  payload: unknown;
@@ -1206,6 +1220,20 @@ declare class MiniAppSDK {
1206
1220
  (type: "profile", fields: (keyof IUserProfile)[]): Promise<boolean>;
1207
1221
  };
1208
1222
  }>;
1223
+ /**
1224
+ * Media & Gallery integration.
1225
+ */
1226
+ readonly media: Readonly<{
1227
+ /**
1228
+ * Saves a base64-encoded image to the device's photo gallery via the Host Shell.
1229
+ * A plain browser `<a download>` does not work inside the native WebView (no
1230
+ * download manager is wired up) — this is the only way to persist an image
1231
+ * generated inside a Mini-App (e.g. a QR code) to the device.
1232
+ * @param base64 Base64-encoded image data, with or without the `data:image/...;base64,` prefix.
1233
+ * @param filename Suggested filename (without extension).
1234
+ */
1235
+ saveImage: (base64: string, filename?: string) => Promise<ISaveImageResult>;
1236
+ }>;
1209
1237
  /**
1210
1238
  * Payments integration.
1211
1239
  */
@@ -1385,4 +1413,4 @@ declare class MiniAppSDK {
1385
1413
  */
1386
1414
  declare const sdk: MiniAppSDK;
1387
1415
 
1388
- 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 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 };
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 };
package/dist/index.d.ts CHANGED
@@ -331,6 +331,13 @@ interface ScrollConfig {
331
331
  loadingMore?: boolean;
332
332
  };
333
333
  }
334
+ /**
335
+ * Result of a `sdk.media.saveImage` call.
336
+ */
337
+ interface ISaveImageResult {
338
+ /** Whether the image was saved successfully. */
339
+ success: boolean;
340
+ }
334
341
  /**
335
342
  * Edge insets representing padding or margins around a component, typically used for layout purposes.
336
343
  */
@@ -535,6 +542,13 @@ type BridgeMessageType = {
535
542
  type: "STOP_LOCATION_STREAM";
536
543
  payload?: never;
537
544
  callbackId: string;
545
+ } | {
546
+ type: "SAVE_IMAGE";
547
+ payload: {
548
+ base64: string;
549
+ filename?: string;
550
+ };
551
+ callbackId: string;
538
552
  } | {
539
553
  type: string;
540
554
  payload: unknown;
@@ -1206,6 +1220,20 @@ declare class MiniAppSDK {
1206
1220
  (type: "profile", fields: (keyof IUserProfile)[]): Promise<boolean>;
1207
1221
  };
1208
1222
  }>;
1223
+ /**
1224
+ * Media & Gallery integration.
1225
+ */
1226
+ readonly media: Readonly<{
1227
+ /**
1228
+ * Saves a base64-encoded image to the device's photo gallery via the Host Shell.
1229
+ * A plain browser `<a download>` does not work inside the native WebView (no
1230
+ * download manager is wired up) — this is the only way to persist an image
1231
+ * generated inside a Mini-App (e.g. a QR code) to the device.
1232
+ * @param base64 Base64-encoded image data, with or without the `data:image/...;base64,` prefix.
1233
+ * @param filename Suggested filename (without extension).
1234
+ */
1235
+ saveImage: (base64: string, filename?: string) => Promise<ISaveImageResult>;
1236
+ }>;
1209
1237
  /**
1210
1238
  * Payments integration.
1211
1239
  */
@@ -1385,4 +1413,4 @@ declare class MiniAppSDK {
1385
1413
  */
1386
1414
  declare const sdk: MiniAppSDK;
1387
1415
 
1388
- 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 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 };
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 };
package/dist/index.js CHANGED
@@ -355,6 +355,7 @@ var resolveHeightToPixels = (height, containerHeight) => {
355
355
  };
356
356
  var CONTENT_EDGE_PULL_THRESHOLD_PX = 24;
357
357
  var HANDLE_BAR_HEIGHT_PX = 32;
358
+ var HANDLE_TAP_CLICK_SUPPRESSION_MS = 400;
358
359
  var MapDrawer = forwardRef3(
359
360
  ({
360
361
  menuItems,
@@ -619,7 +620,7 @@ var MapDrawer = forwardRef3(
619
620
  suppressNextClickRef.current = true;
620
621
  setTimeout(() => {
621
622
  suppressNextClickRef.current = false;
622
- }, 500);
623
+ }, HANDLE_TAP_CLICK_SUPPRESSION_MS);
623
624
  }
624
625
  setTouchStartY(null);
625
626
  setCurrentTouchY(null);
@@ -683,6 +684,12 @@ var MapDrawer = forwardRef3(
683
684
  }
684
685
  });
685
686
  };
687
+ const handleNativeClickCapture = (e) => {
688
+ if (!suppressNextClickRef.current) return;
689
+ suppressNextClickRef.current = false;
690
+ e.preventDefault();
691
+ e.stopPropagation();
692
+ };
686
693
  container.addEventListener("touchstart", handleNativeTouchStart, {
687
694
  passive: true
688
695
  });
@@ -692,10 +699,16 @@ var MapDrawer = forwardRef3(
692
699
  container.addEventListener("touchend", handleNativeTouchEnd, {
693
700
  passive: true
694
701
  });
702
+ container.addEventListener("click", handleNativeClickCapture, {
703
+ capture: true
704
+ });
695
705
  return () => {
696
706
  container.removeEventListener("touchstart", handleNativeTouchStart);
697
707
  container.removeEventListener("touchmove", handleNativeTouchMove);
698
708
  container.removeEventListener("touchend", handleNativeTouchEnd);
709
+ container.removeEventListener("click", handleNativeClickCapture, {
710
+ capture: true
711
+ });
699
712
  };
700
713
  }, [
701
714
  side,
@@ -3278,7 +3291,7 @@ function renderMap(containerId, props = {}) {
3278
3291
  }
3279
3292
 
3280
3293
  // package.json
3281
- var version = "0.5.3";
3294
+ var version = "0.5.5";
3282
3295
 
3283
3296
  // src/sdk.ts
3284
3297
  function deepFreeze(obj) {
@@ -3387,6 +3400,20 @@ var MiniAppSDK = class {
3387
3400
  return this.bridge.send("REQUEST_PERMISSION", { fields, type });
3388
3401
  })
3389
3402
  });
3403
+ /**
3404
+ * Media & Gallery integration.
3405
+ */
3406
+ media = Object.freeze({
3407
+ /**
3408
+ * Saves a base64-encoded image to the device's photo gallery via the Host Shell.
3409
+ * A plain browser `<a download>` does not work inside the native WebView (no
3410
+ * download manager is wired up) — this is the only way to persist an image
3411
+ * generated inside a Mini-App (e.g. a QR code) to the device.
3412
+ * @param base64 Base64-encoded image data, with or without the `data:image/...;base64,` prefix.
3413
+ * @param filename Suggested filename (without extension).
3414
+ */
3415
+ saveImage: (base64, filename) => this.bridge.send("SAVE_IMAGE", { base64, filename })
3416
+ });
3390
3417
  /**
3391
3418
  * Payments integration.
3392
3419
  */