@cloudparse/up-miniapps-sdk 0.8.0 → 0.9.0

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.cjs CHANGED
@@ -2061,13 +2061,15 @@ var useUserLocation = () => {
2061
2061
 
2062
2062
  // src/components/Map/hooks/useLiveRouting.ts
2063
2063
  var import_react9 = require("react");
2064
+ var DEFAULT_ARRIVAL_THRESHOLD_METERS = 15;
2064
2065
  var useLiveRouting = ({
2065
2066
  origin: manualOrigin,
2066
2067
  destination,
2067
2068
  profile = "driving",
2068
2069
  recalculateThreshold = 50,
2069
2070
  enabled = true,
2070
- initialMode = "preview"
2071
+ initialMode = "preview",
2072
+ arrivalThresholdMeters = DEFAULT_ARRIVAL_THRESHOLD_METERS
2071
2073
  }) => {
2072
2074
  const [route, setRoute] = (0, import_react9.useState)(null);
2073
2075
  const [totalDistance, setTotalDistance] = (0, import_react9.useState)(null);
@@ -2121,6 +2123,7 @@ var useLiveRouting = ({
2121
2123
  }
2122
2124
  return dist;
2123
2125
  }, [trackingLocation, route, destination, getDistance]);
2126
+ const hasArrived = currentDistanceMeters !== null && currentDistanceMeters <= arrivalThresholdMeters;
2124
2127
  const calculate = (0, import_react9.useCallback)(
2125
2128
  async (origin, dest, isNewDest) => {
2126
2129
  if (isRequestInProgress.current) return;
@@ -2178,6 +2181,8 @@ var useLiveRouting = ({
2178
2181
  if (lastResetDestKey.current !== destKey) {
2179
2182
  lastResetDestKey.current = destKey;
2180
2183
  setMode(initialMode);
2184
+ setRoute(null);
2185
+ setTotalDistance(null);
2181
2186
  }
2182
2187
  if (destChanged) {
2183
2188
  calculate(calculationOrigin, destination, true);
@@ -2203,6 +2208,7 @@ var useLiveRouting = ({
2203
2208
  return {
2204
2209
  currentDistanceMeters,
2205
2210
  error,
2211
+ hasArrived,
2206
2212
  isCalculating,
2207
2213
  mode,
2208
2214
  recalculate: () => calculationOrigin && destination && calculate(calculationOrigin, destination, false),
@@ -2268,6 +2274,7 @@ var useJourney = (options = {}) => {
2268
2274
  }, []);
2269
2275
  const effectiveOptions = progNav || navigation;
2270
2276
  const internalNav = useLiveRouting({
2277
+ arrivalThresholdMeters: effectiveOptions?.arrivalThresholdMeters,
2271
2278
  destination: effectiveOptions?.destination || null,
2272
2279
  enabled: !isAborted && !!effectiveOptions?.destination,
2273
2280
  initialMode: effectiveOptions?.mode || "preview",
@@ -2323,6 +2330,7 @@ var useJourney = (options = {}) => {
2323
2330
  distanceRemainingMeters,
2324
2331
  error: isActive ? internalNav.error : null,
2325
2332
  etaMinutes,
2333
+ hasArrived: isActive ? internalNav.hasArrived : false,
2326
2334
  isActive,
2327
2335
  isCalculating: isActive ? internalNav.isCalculating : false,
2328
2336
  mode: isActive ? internalNav.mode : "preview",
@@ -2367,7 +2375,8 @@ var RouteLayer = ({
2367
2375
  geometry,
2368
2376
  color = "#3b82f6",
2369
2377
  width = 5,
2370
- opacity = 0.8
2378
+ opacity = 0.8,
2379
+ dashArray
2371
2380
  }) => {
2372
2381
  if (!geometry) return null;
2373
2382
  const data = {
@@ -2400,7 +2409,8 @@ var RouteLayer = ({
2400
2409
  paint: {
2401
2410
  "line-color": color,
2402
2411
  "line-opacity": opacity,
2403
- "line-width": width
2412
+ "line-width": width,
2413
+ ...dashArray ? { "line-dasharray": dashArray } : {}
2404
2414
  },
2405
2415
  type: "line"
2406
2416
  }
@@ -2827,6 +2837,7 @@ var MapInternal = ({
2827
2837
  pois = [],
2828
2838
  onPoiClick,
2829
2839
  route: externalRoute,
2840
+ routeStyle,
2830
2841
  showNavigationUI: externalShowNavigationUI,
2831
2842
  navigationData: externalNavigationData,
2832
2843
  onNavigationAbort,
@@ -2851,6 +2862,7 @@ var MapInternal = ({
2851
2862
  const hasIntegratedNav = journey.isActive;
2852
2863
  const navigationData = hasIntegratedNav ? {
2853
2864
  currentDistanceMeters: journey.distanceRemainingMeters,
2865
+ hasArrived: journey.hasArrived,
2854
2866
  mode: journey.mode,
2855
2867
  route: journey.route,
2856
2868
  start: journey.start,
@@ -3011,6 +3023,7 @@ var MapInternal = ({
3011
3023
  const showEtaData = showNavigationUI && navigationData && route ? {
3012
3024
  distanceRemainingKm: kmRemaining,
3013
3025
  etaMins,
3026
+ hasArrived: navigationData.hasArrived ?? false,
3014
3027
  label: mode === "navigation" ? "Walking Guidance Active" : "Route Preview",
3015
3028
  mode,
3016
3029
  onAbort: () => {
@@ -3185,7 +3198,23 @@ var MapInternal = ({
3185
3198
  initialViewState,
3186
3199
  interactiveLayerIds: mergedInteractiveLayerIds,
3187
3200
  mapStyle,
3188
- maxBounds,
3201
+ maxBounds: (
3202
+ // @vis.gl/react-maplibre's own <Map> component (aliased MapLibre
3203
+ // here) types maxBounds as a flat [west, south, east, north]
3204
+ // tuple — raw maplibre-gl's LngLatBoundsLike still accepts a
3205
+ // pair-of-corners shape, this narrowing is the wrapper's own.
3206
+ // This SDK's public MapProps.maxBounds keeps the
3207
+ // [[lng, lat], [lng, lat]] pair-of-corners shape (matches every
3208
+ // other coordinate prop in this SDK, e.g. flyTo), so it's
3209
+ // flattened here at the point of use rather than changing the
3210
+ // public API.
3211
+ maxBounds ? [
3212
+ maxBounds[0][0],
3213
+ maxBounds[0][1],
3214
+ maxBounds[1][0],
3215
+ maxBounds[1][1]
3216
+ ] : void 0
3217
+ ),
3189
3218
  onClick: handleMapClick,
3190
3219
  onContextMenu,
3191
3220
  onDragStart: handleUserInteraction,
@@ -3222,7 +3251,16 @@ var MapInternal = ({
3222
3251
  radiusMeters: mockLocation.radiusMeters
3223
3252
  }
3224
3253
  ),
3225
- displayRoute && /* @__PURE__ */ (0, import_jsx_runtime16.jsx)(RouteLayer, { geometry: displayRoute }),
3254
+ displayRoute && /* @__PURE__ */ (0, import_jsx_runtime16.jsx)(
3255
+ RouteLayer,
3256
+ {
3257
+ color: routeStyle?.color,
3258
+ dashArray: routeStyle?.dashArray,
3259
+ geometry: displayRoute,
3260
+ opacity: routeStyle?.opacity,
3261
+ width: routeStyle?.width
3262
+ }
3263
+ ),
3226
3264
  pois.length > 0 && /* @__PURE__ */ (0, import_jsx_runtime16.jsxs)(import_jsx_runtime16.Fragment, { children: [
3227
3265
  /* @__PURE__ */ (0, import_jsx_runtime16.jsx)(POILayers, { pois }),
3228
3266
  /* @__PURE__ */ (0, import_jsx_runtime16.jsx)(POIMarkers, { onClick: onPoiClick, pois })
@@ -3627,7 +3665,7 @@ var RoutingService = {
3627
3665
  };
3628
3666
 
3629
3667
  // package.json
3630
- var version = "0.8.0";
3668
+ var version = "0.9.0";
3631
3669
 
3632
3670
  // src/sdk.ts
3633
3671
  function deepFreeze(obj) {