@cloudparse/up-miniapps-sdk 0.8.0 → 0.10.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.browser.min.js +478 -460
- package/dist/index.browser.min.js.map +1 -1
- package/dist/index.cjs +60 -8
- package/dist/index.cjs.map +1 -1
- package/dist/index.css +1 -1
- package/dist/index.css.map +1 -1
- package/dist/index.d.cts +107 -2
- package/dist/index.d.ts +107 -2
- package/dist/index.js +60 -8
- package/dist/index.js.map +1 -1
- package/dist/style.css +9 -0
- package/package.json +3 -3
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)(
|
|
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.
|
|
3668
|
+
var version = "0.10.0";
|
|
3631
3669
|
|
|
3632
3670
|
// src/sdk.ts
|
|
3633
3671
|
function deepFreeze(obj) {
|
|
@@ -3821,9 +3859,22 @@ var MiniAppSDK = class {
|
|
|
3821
3859
|
/**
|
|
3822
3860
|
* Performs a network request via the host shell.
|
|
3823
3861
|
* @param options Request method, URL, headers, and body.
|
|
3862
|
+
*
|
|
3863
|
+
* Real bug, caught by reviewer-strict: `options.timeoutMs` only ever
|
|
3864
|
+
* reached the shell's own `fetchWithTimeout` call — this `bridge.send`
|
|
3865
|
+
* has an entirely separate client-side promise timeout (its own
|
|
3866
|
+
* `timeoutMs` param, default 30000ms) waiting for the native reply,
|
|
3867
|
+
* previously left at that default regardless of what `options.timeoutMs`
|
|
3868
|
+
* said. A slow-but-legitimate call given a longer `options.timeoutMs`
|
|
3869
|
+
* (e.g. 50000ms for an LLM-backed endpoint) would still get this
|
|
3870
|
+
* bridge-level promise rejected ("Bridge request timeout") at 30s,
|
|
3871
|
+
* reintroducing the exact same "aborted before it could finish" bug
|
|
3872
|
+
* this field exists to fix, one layer up. Forwarding it here means both
|
|
3873
|
+
* ceilings move together; omitted (`undefined`, every other caller)
|
|
3874
|
+
* falls through to `send`'s own unchanged 30000ms default.
|
|
3824
3875
|
*/
|
|
3825
3876
|
request: async (options) => {
|
|
3826
|
-
return this.bridge.send("NETWORK_REQUEST", options);
|
|
3877
|
+
return this.bridge.send("NETWORK_REQUEST", options, options.timeoutMs);
|
|
3827
3878
|
}
|
|
3828
3879
|
});
|
|
3829
3880
|
/**
|
|
@@ -5652,10 +5703,11 @@ function createApiService(options) {
|
|
|
5652
5703
|
method: "PATCH",
|
|
5653
5704
|
url: buildUrl(getBaseUrl(), path)
|
|
5654
5705
|
}),
|
|
5655
|
-
post: (path, body) => sdk.network.request({
|
|
5706
|
+
post: (path, body, timeoutMs) => sdk.network.request({
|
|
5656
5707
|
body,
|
|
5657
5708
|
headers: { "Content-Type": "application/json" },
|
|
5658
5709
|
method: "POST",
|
|
5710
|
+
timeoutMs,
|
|
5659
5711
|
url: buildUrl(getBaseUrl(), path)
|
|
5660
5712
|
}),
|
|
5661
5713
|
get wsUrl() {
|