@cloudparse/up-miniapps-sdk 0.7.3 → 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
@@ -147,8 +147,7 @@ var MOCK_ACHIEVEMENTS = [
147
147
  slug: "first-journey",
148
148
  title: "First Steps",
149
149
  totalActionCount: 1,
150
- upReward: 20,
151
- xpReward: 40
150
+ pointsReward: 10
152
151
  },
153
152
  {
154
153
  completed: false,
@@ -158,8 +157,7 @@ var MOCK_ACHIEVEMENTS = [
158
157
  slug: "explore-5-pois",
159
158
  title: "Explorer",
160
159
  totalActionCount: 5,
161
- upReward: 50,
162
- xpReward: 100
160
+ pointsReward: 15
163
161
  },
164
162
  {
165
163
  completed: false,
@@ -169,8 +167,7 @@ var MOCK_ACHIEVEMENTS = [
169
167
  slug: "scan-10-qrcodes",
170
168
  title: "Code Breaker",
171
169
  totalActionCount: 10,
172
- upReward: 80,
173
- xpReward: 150
170
+ pointsReward: 20
174
171
  }
175
172
  ];
176
173
  function mockAchievement(slug) {
@@ -184,8 +181,7 @@ function mockAchievement(slug) {
184
181
  slug: slug || "unknown-achievement",
185
182
  title: slug || "Unknown Achievement",
186
183
  totalActionCount: 1,
187
- upReward: 0,
188
- xpReward: 0
184
+ pointsReward: 0
189
185
  };
190
186
  }
191
187
  function mockAchievements() {
@@ -2065,13 +2061,15 @@ var useUserLocation = () => {
2065
2061
 
2066
2062
  // src/components/Map/hooks/useLiveRouting.ts
2067
2063
  var import_react9 = require("react");
2064
+ var DEFAULT_ARRIVAL_THRESHOLD_METERS = 15;
2068
2065
  var useLiveRouting = ({
2069
2066
  origin: manualOrigin,
2070
2067
  destination,
2071
2068
  profile = "driving",
2072
2069
  recalculateThreshold = 50,
2073
2070
  enabled = true,
2074
- initialMode = "preview"
2071
+ initialMode = "preview",
2072
+ arrivalThresholdMeters = DEFAULT_ARRIVAL_THRESHOLD_METERS
2075
2073
  }) => {
2076
2074
  const [route, setRoute] = (0, import_react9.useState)(null);
2077
2075
  const [totalDistance, setTotalDistance] = (0, import_react9.useState)(null);
@@ -2125,6 +2123,7 @@ var useLiveRouting = ({
2125
2123
  }
2126
2124
  return dist;
2127
2125
  }, [trackingLocation, route, destination, getDistance]);
2126
+ const hasArrived = currentDistanceMeters !== null && currentDistanceMeters <= arrivalThresholdMeters;
2128
2127
  const calculate = (0, import_react9.useCallback)(
2129
2128
  async (origin, dest, isNewDest) => {
2130
2129
  if (isRequestInProgress.current) return;
@@ -2182,6 +2181,8 @@ var useLiveRouting = ({
2182
2181
  if (lastResetDestKey.current !== destKey) {
2183
2182
  lastResetDestKey.current = destKey;
2184
2183
  setMode(initialMode);
2184
+ setRoute(null);
2185
+ setTotalDistance(null);
2185
2186
  }
2186
2187
  if (destChanged) {
2187
2188
  calculate(calculationOrigin, destination, true);
@@ -2207,6 +2208,7 @@ var useLiveRouting = ({
2207
2208
  return {
2208
2209
  currentDistanceMeters,
2209
2210
  error,
2211
+ hasArrived,
2210
2212
  isCalculating,
2211
2213
  mode,
2212
2214
  recalculate: () => calculationOrigin && destination && calculate(calculationOrigin, destination, false),
@@ -2272,6 +2274,7 @@ var useJourney = (options = {}) => {
2272
2274
  }, []);
2273
2275
  const effectiveOptions = progNav || navigation;
2274
2276
  const internalNav = useLiveRouting({
2277
+ arrivalThresholdMeters: effectiveOptions?.arrivalThresholdMeters,
2275
2278
  destination: effectiveOptions?.destination || null,
2276
2279
  enabled: !isAborted && !!effectiveOptions?.destination,
2277
2280
  initialMode: effectiveOptions?.mode || "preview",
@@ -2327,6 +2330,7 @@ var useJourney = (options = {}) => {
2327
2330
  distanceRemainingMeters,
2328
2331
  error: isActive ? internalNav.error : null,
2329
2332
  etaMinutes,
2333
+ hasArrived: isActive ? internalNav.hasArrived : false,
2330
2334
  isActive,
2331
2335
  isCalculating: isActive ? internalNav.isCalculating : false,
2332
2336
  mode: isActive ? internalNav.mode : "preview",
@@ -2371,7 +2375,8 @@ var RouteLayer = ({
2371
2375
  geometry,
2372
2376
  color = "#3b82f6",
2373
2377
  width = 5,
2374
- opacity = 0.8
2378
+ opacity = 0.8,
2379
+ dashArray
2375
2380
  }) => {
2376
2381
  if (!geometry) return null;
2377
2382
  const data = {
@@ -2404,7 +2409,8 @@ var RouteLayer = ({
2404
2409
  paint: {
2405
2410
  "line-color": color,
2406
2411
  "line-opacity": opacity,
2407
- "line-width": width
2412
+ "line-width": width,
2413
+ ...dashArray ? { "line-dasharray": dashArray } : {}
2408
2414
  },
2409
2415
  type: "line"
2410
2416
  }
@@ -2831,6 +2837,7 @@ var MapInternal = ({
2831
2837
  pois = [],
2832
2838
  onPoiClick,
2833
2839
  route: externalRoute,
2840
+ routeStyle,
2834
2841
  showNavigationUI: externalShowNavigationUI,
2835
2842
  navigationData: externalNavigationData,
2836
2843
  onNavigationAbort,
@@ -2855,6 +2862,7 @@ var MapInternal = ({
2855
2862
  const hasIntegratedNav = journey.isActive;
2856
2863
  const navigationData = hasIntegratedNav ? {
2857
2864
  currentDistanceMeters: journey.distanceRemainingMeters,
2865
+ hasArrived: journey.hasArrived,
2858
2866
  mode: journey.mode,
2859
2867
  route: journey.route,
2860
2868
  start: journey.start,
@@ -3015,6 +3023,7 @@ var MapInternal = ({
3015
3023
  const showEtaData = showNavigationUI && navigationData && route ? {
3016
3024
  distanceRemainingKm: kmRemaining,
3017
3025
  etaMins,
3026
+ hasArrived: navigationData.hasArrived ?? false,
3018
3027
  label: mode === "navigation" ? "Walking Guidance Active" : "Route Preview",
3019
3028
  mode,
3020
3029
  onAbort: () => {
@@ -3189,7 +3198,23 @@ var MapInternal = ({
3189
3198
  initialViewState,
3190
3199
  interactiveLayerIds: mergedInteractiveLayerIds,
3191
3200
  mapStyle,
3192
- 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
+ ),
3193
3218
  onClick: handleMapClick,
3194
3219
  onContextMenu,
3195
3220
  onDragStart: handleUserInteraction,
@@ -3226,7 +3251,16 @@ var MapInternal = ({
3226
3251
  radiusMeters: mockLocation.radiusMeters
3227
3252
  }
3228
3253
  ),
3229
- 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
+ ),
3230
3264
  pois.length > 0 && /* @__PURE__ */ (0, import_jsx_runtime16.jsxs)(import_jsx_runtime16.Fragment, { children: [
3231
3265
  /* @__PURE__ */ (0, import_jsx_runtime16.jsx)(POILayers, { pois }),
3232
3266
  /* @__PURE__ */ (0, import_jsx_runtime16.jsx)(POIMarkers, { onClick: onPoiClick, pois })
@@ -3631,7 +3665,7 @@ var RoutingService = {
3631
3665
  };
3632
3666
 
3633
3667
  // package.json
3634
- var version = "0.7.3";
3668
+ var version = "0.9.0";
3635
3669
 
3636
3670
  // src/sdk.ts
3637
3671
  function deepFreeze(obj) {
@@ -4068,8 +4102,7 @@ var MOCK_ACHIEVEMENTS2 = [
4068
4102
  slug: "first-journey",
4069
4103
  title: "First Steps",
4070
4104
  totalActionCount: 1,
4071
- upReward: 20,
4072
- xpReward: 40
4105
+ pointsReward: 10
4073
4106
  },
4074
4107
  {
4075
4108
  completed: false,
@@ -4079,8 +4112,7 @@ var MOCK_ACHIEVEMENTS2 = [
4079
4112
  slug: "explore-5-pois",
4080
4113
  title: "Explorer",
4081
4114
  totalActionCount: 5,
4082
- upReward: 50,
4083
- xpReward: 100
4115
+ pointsReward: 15
4084
4116
  },
4085
4117
  {
4086
4118
  completed: false,
@@ -4090,8 +4122,7 @@ var MOCK_ACHIEVEMENTS2 = [
4090
4122
  slug: "scan-10-qrcodes",
4091
4123
  title: "Code Breaker",
4092
4124
  totalActionCount: 10,
4093
- upReward: 80,
4094
- xpReward: 150
4125
+ pointsReward: 20
4095
4126
  }
4096
4127
  ];
4097
4128
  var AVATAR_MOUTH_VARIANTS = [
@@ -4156,10 +4187,8 @@ function buildMockProfile(mockJWTToken) {
4156
4187
  fullName,
4157
4188
  lastName: lastNameParts.join(" ") || "Caveman",
4158
4189
  localNumber: "0600000000",
4159
- ups: 100,
4160
4190
  username,
4161
- uuid,
4162
- xp: 500
4191
+ uuid
4163
4192
  };
4164
4193
  }
4165
4194
  var getBearing = (p1, p2) => {
@@ -4464,8 +4493,7 @@ var BridgeMocker = ({
4464
4493
  slug: slug || "unknown-achievement",
4465
4494
  title: slug || "Unknown Achievement",
4466
4495
  totalActionCount: 1,
4467
- upReward: 0,
4468
- xpReward: 0
4496
+ pointsReward: 0
4469
4497
  }
4470
4498
  );
4471
4499
  }