@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.d.ts
CHANGED
|
@@ -157,6 +157,27 @@ interface INetworkOptions {
|
|
|
157
157
|
body?: unknown;
|
|
158
158
|
/** Custom HTTP headers. */
|
|
159
159
|
headers?: Record<string, string>;
|
|
160
|
+
/**
|
|
161
|
+
* Real production bug, found live: the shell's NETWORK_REQUEST handler
|
|
162
|
+
* (`up/shell`'s `use-miniapp-bridge.ts`) hard-caps every proxied request
|
|
163
|
+
* at a fixed 5s timeout (`fetch-with-timeout.ts`'s `DEFAULT_TIMEOUT_MS`)
|
|
164
|
+
* with no way for a mini-app to ask for more — a genuinely slow-but-legit
|
|
165
|
+
* backend call (e.g. an LLM chat turn routinely taking 3-7s+) gets
|
|
166
|
+
* silently aborted mid-flight ("context canceled" server-side) well
|
|
167
|
+
* before its own, longer server-side timeout would ever fire. Optional
|
|
168
|
+
* override, in milliseconds — omit for the shell's existing 5s default.
|
|
169
|
+
* Only meaningful for `sdk.network.request()`/host-proxied calls; has no
|
|
170
|
+
* effect on any other bridge message type. Governs TWO independent
|
|
171
|
+
* ceilings that must move together, not just the shell's own fetch: the
|
|
172
|
+
* shell's `fetchWithTimeout` call (the actual HTTP request) AND this
|
|
173
|
+
* bridge's own client-side promise wait for the native reply
|
|
174
|
+
* (`Bridge.send`'s own `timeoutMs`, default 30s — see `sdk.ts`'s
|
|
175
|
+
* `network.request`, which forwards this same value there too). Setting
|
|
176
|
+
* this only high enough for the first would still let the second time out
|
|
177
|
+
* first on anything over ~30s and silently reject with a generic "Bridge
|
|
178
|
+
* request timeout" instead of ever reaching the real HTTP response.
|
|
179
|
+
*/
|
|
180
|
+
timeoutMs?: number;
|
|
160
181
|
}
|
|
161
182
|
/**
|
|
162
183
|
* Response from a network proxy request.
|
|
@@ -788,6 +809,19 @@ interface MapProps {
|
|
|
788
809
|
onPoiClick?: (poi: POI) => void;
|
|
789
810
|
/** Route geometry to display on the map. */
|
|
790
811
|
route?: GeoJSON.LineString;
|
|
812
|
+
/**
|
|
813
|
+
* Visual style for the route line the Map draws internally (both for
|
|
814
|
+
* `route` and for an active `navigation`/`navigationData` journey) —
|
|
815
|
+
* see `RouteLayerProps`. Defaults to `RouteLayer`'s own defaults
|
|
816
|
+
* (`#3b82f6` blue, solid) when omitted, so existing consumers are
|
|
817
|
+
* unaffected.
|
|
818
|
+
*/
|
|
819
|
+
routeStyle?: {
|
|
820
|
+
color?: string;
|
|
821
|
+
width?: number;
|
|
822
|
+
opacity?: number;
|
|
823
|
+
dashArray?: number[];
|
|
824
|
+
};
|
|
791
825
|
/** Whether to show the out-of-the-box navigation UI. */
|
|
792
826
|
showNavigationUI?: boolean;
|
|
793
827
|
/** Callback triggered when the user aborts/closes the navigation UI. */
|
|
@@ -814,6 +848,12 @@ interface MapProps {
|
|
|
814
848
|
* Defaults to 'preview'.
|
|
815
849
|
*/
|
|
816
850
|
mode?: "preview" | "navigation";
|
|
851
|
+
/**
|
|
852
|
+
* Distance in meters from the destination at which the journey
|
|
853
|
+
* counts as arrived. GPS accuracy means the live remaining distance
|
|
854
|
+
* rarely reaches exactly 0. Defaults to 15m.
|
|
855
|
+
*/
|
|
856
|
+
arrivalThresholdMeters?: number;
|
|
817
857
|
};
|
|
818
858
|
/** Callback triggered when the navigation mode changes (e.g. from preview to navigation). */
|
|
819
859
|
onNavigationModeChange?: (mode: "preview" | "navigation") => void;
|
|
@@ -832,6 +872,8 @@ interface MapProps {
|
|
|
832
872
|
mode?: "preview" | "navigation";
|
|
833
873
|
/** Function to transition to active navigation mode */
|
|
834
874
|
start?: () => void;
|
|
875
|
+
/** True once the live remaining distance drops to/below `navigation.arrivalThresholdMeters`. */
|
|
876
|
+
hasArrived?: boolean;
|
|
835
877
|
};
|
|
836
878
|
/** Whether to show the vertical drawer and floating right controls. Defaults to true. */
|
|
837
879
|
showControls?: boolean;
|
|
@@ -874,6 +916,8 @@ interface EtaData {
|
|
|
874
916
|
onStart?: () => void;
|
|
875
917
|
isCalculating?: boolean;
|
|
876
918
|
error?: string | null;
|
|
919
|
+
/** True once the live remaining distance drops to/below `navigation.arrivalThresholdMeters`. */
|
|
920
|
+
hasArrived?: boolean;
|
|
877
921
|
}
|
|
878
922
|
|
|
879
923
|
interface MapInsets {
|
|
@@ -1030,6 +1074,12 @@ interface LiveRoutingOptions {
|
|
|
1030
1074
|
enabled?: boolean;
|
|
1031
1075
|
/** Initial mode: 'preview' or 'navigation'. Defaults to 'preview'. */
|
|
1032
1076
|
initialMode?: "preview" | "navigation";
|
|
1077
|
+
/**
|
|
1078
|
+
* Distance in meters from the destination at which the journey counts
|
|
1079
|
+
* as arrived (`hasArrived` becomes true). GPS accuracy means the live
|
|
1080
|
+
* `currentDistanceMeters` rarely reaches exactly 0. Defaults to 15m.
|
|
1081
|
+
*/
|
|
1082
|
+
arrivalThresholdMeters?: number;
|
|
1033
1083
|
}
|
|
1034
1084
|
interface LiveRoutingResult {
|
|
1035
1085
|
/** The calculated route data from the last API call */
|
|
@@ -1048,8 +1098,15 @@ interface LiveRoutingResult {
|
|
|
1048
1098
|
mode: "preview" | "navigation";
|
|
1049
1099
|
/** Start active navigation (switch mode to 'navigation') */
|
|
1050
1100
|
start: () => void;
|
|
1101
|
+
/**
|
|
1102
|
+
* True once `currentDistanceMeters` drops to/below
|
|
1103
|
+
* `arrivalThresholdMeters`. Use this instead of checking
|
|
1104
|
+
* `currentDistanceMeters <= 0` — the point never reaches exactly 0 with
|
|
1105
|
+
* live GPS.
|
|
1106
|
+
*/
|
|
1107
|
+
hasArrived: boolean;
|
|
1051
1108
|
}
|
|
1052
|
-
declare const useLiveRouting: ({ origin: manualOrigin, destination, profile, recalculateThreshold, enabled, initialMode, }: LiveRoutingOptions) => LiveRoutingResult;
|
|
1109
|
+
declare const useLiveRouting: ({ origin: manualOrigin, destination, profile, recalculateThreshold, enabled, initialMode, arrivalThresholdMeters, }: LiveRoutingOptions) => LiveRoutingResult;
|
|
1053
1110
|
/**
|
|
1054
1111
|
* A simple hook to fetch a route once between two points.
|
|
1055
1112
|
* Does not automatically recalculate or track user location.
|
|
@@ -1077,6 +1134,12 @@ interface DeclarativeJourneyOptions {
|
|
|
1077
1134
|
origin?: [number, number] | null;
|
|
1078
1135
|
/** Initial mode. 'preview' shows the route overview, 'navigation' starts active guidance. Defaults to 'preview'. */
|
|
1079
1136
|
mode?: NavMode;
|
|
1137
|
+
/**
|
|
1138
|
+
* Distance in meters from the destination at which the journey counts
|
|
1139
|
+
* as arrived (`hasArrived` becomes true). GPS accuracy means the live
|
|
1140
|
+
* `distanceRemainingMeters` rarely reaches exactly 0. Defaults to 15m.
|
|
1141
|
+
*/
|
|
1142
|
+
arrivalThresholdMeters?: number;
|
|
1080
1143
|
}
|
|
1081
1144
|
interface UseJourneyOptions {
|
|
1082
1145
|
/**
|
|
@@ -1112,6 +1175,13 @@ interface UseJourneyResult {
|
|
|
1112
1175
|
etaMinutes: number;
|
|
1113
1176
|
/** Journey completion progress, 0-100. */
|
|
1114
1177
|
progress: number;
|
|
1178
|
+
/**
|
|
1179
|
+
* True once the live remaining distance drops to/below
|
|
1180
|
+
* `arrivalThresholdMeters`. Check this instead of
|
|
1181
|
+
* `distanceRemainingMeters <= 0` — it usually never reaches exactly 0
|
|
1182
|
+
* with live GPS, so a UI that waits for that may never show "arrived".
|
|
1183
|
+
*/
|
|
1184
|
+
hasArrived: boolean;
|
|
1115
1185
|
/** Switch from 'preview' to active 'navigation' guidance. */
|
|
1116
1186
|
start: () => void;
|
|
1117
1187
|
/** Cancel the journey entirely. Always returns to 'preview' the next time a journey starts. */
|
|
@@ -1153,6 +1223,14 @@ interface RouteLayerProps {
|
|
|
1153
1223
|
width?: number;
|
|
1154
1224
|
/** Opacity of the route line. Defaults to 0.8. */
|
|
1155
1225
|
opacity?: number;
|
|
1226
|
+
/**
|
|
1227
|
+
* MapLibre `line-dasharray` for the colored line (the white casing
|
|
1228
|
+
* underneath always stays solid, for legibility against any basemap).
|
|
1229
|
+
* Units are multiples of `width`. E.g. `[0, 2]` with the layer's own
|
|
1230
|
+
* `line-cap: round` (always on) renders as a dotted trail instead of a
|
|
1231
|
+
* continuous line. Omit for a solid line (default).
|
|
1232
|
+
*/
|
|
1233
|
+
dashArray?: number[];
|
|
1156
1234
|
}
|
|
1157
1235
|
declare const RouteLayer: React__default.FC<RouteLayerProps>;
|
|
1158
1236
|
|
|
@@ -1493,6 +1571,19 @@ declare class MiniAppSDK {
|
|
|
1493
1571
|
/**
|
|
1494
1572
|
* Performs a network request via the host shell.
|
|
1495
1573
|
* @param options Request method, URL, headers, and body.
|
|
1574
|
+
*
|
|
1575
|
+
* Real bug, caught by reviewer-strict: `options.timeoutMs` only ever
|
|
1576
|
+
* reached the shell's own `fetchWithTimeout` call — this `bridge.send`
|
|
1577
|
+
* has an entirely separate client-side promise timeout (its own
|
|
1578
|
+
* `timeoutMs` param, default 30000ms) waiting for the native reply,
|
|
1579
|
+
* previously left at that default regardless of what `options.timeoutMs`
|
|
1580
|
+
* said. A slow-but-legitimate call given a longer `options.timeoutMs`
|
|
1581
|
+
* (e.g. 50000ms for an LLM-backed endpoint) would still get this
|
|
1582
|
+
* bridge-level promise rejected ("Bridge request timeout") at 30s,
|
|
1583
|
+
* reintroducing the exact same "aborted before it could finish" bug
|
|
1584
|
+
* this field exists to fix, one layer up. Forwarding it here means both
|
|
1585
|
+
* ceilings move together; omitted (`undefined`, every other caller)
|
|
1586
|
+
* falls through to `send`'s own unchanged 30000ms default.
|
|
1496
1587
|
*/
|
|
1497
1588
|
request: <T = unknown>(options: INetworkOptions) => Promise<INetworkResponse<T>>;
|
|
1498
1589
|
}>;
|
|
@@ -1513,6 +1604,14 @@ declare class MiniAppSDK {
|
|
|
1513
1604
|
destination: [number, number];
|
|
1514
1605
|
origin?: [number, number];
|
|
1515
1606
|
profile?: "driving" | "cycling" | "walking";
|
|
1607
|
+
/**
|
|
1608
|
+
* Distance in meters from the destination at which the journey
|
|
1609
|
+
* counts as arrived (`useJourney().hasArrived` becomes true). GPS
|
|
1610
|
+
* accuracy means the live remaining distance rarely reaches
|
|
1611
|
+
* exactly 0 — this is the threshold a consumer's own UI should
|
|
1612
|
+
* treat as "done" instead of waiting for that. Defaults to 15m.
|
|
1613
|
+
*/
|
|
1614
|
+
arrivalThresholdMeters?: number;
|
|
1516
1615
|
}) => void;
|
|
1517
1616
|
/**
|
|
1518
1617
|
* Starts the active navigation (active guidance).
|
|
@@ -1667,7 +1766,13 @@ interface ApiServiceClient {
|
|
|
1667
1766
|
/** Current WebSocket backend URL, same resolution order as `baseUrl` but reading the dedicated ws fields instead. `undefined` if neither the shell nor `defaultWsBackendUrl` ever supplied one. */
|
|
1668
1767
|
readonly wsUrl: string | undefined;
|
|
1669
1768
|
get<T = unknown>(path: string): Promise<INetworkResponse<T>>;
|
|
1670
|
-
|
|
1769
|
+
/**
|
|
1770
|
+
* `timeoutMs` overrides the shell's default NETWORK_REQUEST timeout (5s,
|
|
1771
|
+
* see `INetworkOptions.timeoutMs`'s own doc comment) — pass it for a call
|
|
1772
|
+
* to a backend route that's legitimately slower than a typical REST call
|
|
1773
|
+
* (e.g. an LLM-backed endpoint), never as a blanket "just in case" bump.
|
|
1774
|
+
*/
|
|
1775
|
+
post<T = unknown>(path: string, body?: unknown, timeoutMs?: number): Promise<INetworkResponse<T>>;
|
|
1671
1776
|
patch<T = unknown>(path: string, body?: unknown): Promise<INetworkResponse<T>>;
|
|
1672
1777
|
delete(path: string): Promise<INetworkResponse<void>>;
|
|
1673
1778
|
graphqlQuery<T = unknown>(query: string, variables?: Record<string, unknown>): Promise<INetworkResponse<{
|
package/dist/index.js
CHANGED
|
@@ -2010,13 +2010,15 @@ var useUserLocation = () => {
|
|
|
2010
2010
|
|
|
2011
2011
|
// src/components/Map/hooks/useLiveRouting.ts
|
|
2012
2012
|
import { useCallback as useCallback4, useEffect as useEffect4, useMemo as useMemo3, useRef as useRef5, useState as useState6 } from "react";
|
|
2013
|
+
var DEFAULT_ARRIVAL_THRESHOLD_METERS = 15;
|
|
2013
2014
|
var useLiveRouting = ({
|
|
2014
2015
|
origin: manualOrigin,
|
|
2015
2016
|
destination,
|
|
2016
2017
|
profile = "driving",
|
|
2017
2018
|
recalculateThreshold = 50,
|
|
2018
2019
|
enabled = true,
|
|
2019
|
-
initialMode = "preview"
|
|
2020
|
+
initialMode = "preview",
|
|
2021
|
+
arrivalThresholdMeters = DEFAULT_ARRIVAL_THRESHOLD_METERS
|
|
2020
2022
|
}) => {
|
|
2021
2023
|
const [route, setRoute] = useState6(null);
|
|
2022
2024
|
const [totalDistance, setTotalDistance] = useState6(null);
|
|
@@ -2070,6 +2072,7 @@ var useLiveRouting = ({
|
|
|
2070
2072
|
}
|
|
2071
2073
|
return dist;
|
|
2072
2074
|
}, [trackingLocation, route, destination, getDistance]);
|
|
2075
|
+
const hasArrived = currentDistanceMeters !== null && currentDistanceMeters <= arrivalThresholdMeters;
|
|
2073
2076
|
const calculate = useCallback4(
|
|
2074
2077
|
async (origin, dest, isNewDest) => {
|
|
2075
2078
|
if (isRequestInProgress.current) return;
|
|
@@ -2127,6 +2130,8 @@ var useLiveRouting = ({
|
|
|
2127
2130
|
if (lastResetDestKey.current !== destKey) {
|
|
2128
2131
|
lastResetDestKey.current = destKey;
|
|
2129
2132
|
setMode(initialMode);
|
|
2133
|
+
setRoute(null);
|
|
2134
|
+
setTotalDistance(null);
|
|
2130
2135
|
}
|
|
2131
2136
|
if (destChanged) {
|
|
2132
2137
|
calculate(calculationOrigin, destination, true);
|
|
@@ -2152,6 +2157,7 @@ var useLiveRouting = ({
|
|
|
2152
2157
|
return {
|
|
2153
2158
|
currentDistanceMeters,
|
|
2154
2159
|
error,
|
|
2160
|
+
hasArrived,
|
|
2155
2161
|
isCalculating,
|
|
2156
2162
|
mode,
|
|
2157
2163
|
recalculate: () => calculationOrigin && destination && calculate(calculationOrigin, destination, false),
|
|
@@ -2217,6 +2223,7 @@ var useJourney = (options = {}) => {
|
|
|
2217
2223
|
}, []);
|
|
2218
2224
|
const effectiveOptions = progNav || navigation;
|
|
2219
2225
|
const internalNav = useLiveRouting({
|
|
2226
|
+
arrivalThresholdMeters: effectiveOptions?.arrivalThresholdMeters,
|
|
2220
2227
|
destination: effectiveOptions?.destination || null,
|
|
2221
2228
|
enabled: !isAborted && !!effectiveOptions?.destination,
|
|
2222
2229
|
initialMode: effectiveOptions?.mode || "preview",
|
|
@@ -2272,6 +2279,7 @@ var useJourney = (options = {}) => {
|
|
|
2272
2279
|
distanceRemainingMeters,
|
|
2273
2280
|
error: isActive ? internalNav.error : null,
|
|
2274
2281
|
etaMinutes,
|
|
2282
|
+
hasArrived: isActive ? internalNav.hasArrived : false,
|
|
2275
2283
|
isActive,
|
|
2276
2284
|
isCalculating: isActive ? internalNav.isCalculating : false,
|
|
2277
2285
|
mode: isActive ? internalNav.mode : "preview",
|
|
@@ -2316,7 +2324,8 @@ var RouteLayer = ({
|
|
|
2316
2324
|
geometry,
|
|
2317
2325
|
color = "#3b82f6",
|
|
2318
2326
|
width = 5,
|
|
2319
|
-
opacity = 0.8
|
|
2327
|
+
opacity = 0.8,
|
|
2328
|
+
dashArray
|
|
2320
2329
|
}) => {
|
|
2321
2330
|
if (!geometry) return null;
|
|
2322
2331
|
const data = {
|
|
@@ -2349,7 +2358,8 @@ var RouteLayer = ({
|
|
|
2349
2358
|
paint: {
|
|
2350
2359
|
"line-color": color,
|
|
2351
2360
|
"line-opacity": opacity,
|
|
2352
|
-
"line-width": width
|
|
2361
|
+
"line-width": width,
|
|
2362
|
+
...dashArray ? { "line-dasharray": dashArray } : {}
|
|
2353
2363
|
},
|
|
2354
2364
|
type: "line"
|
|
2355
2365
|
}
|
|
@@ -2783,6 +2793,7 @@ var MapInternal = ({
|
|
|
2783
2793
|
pois = [],
|
|
2784
2794
|
onPoiClick,
|
|
2785
2795
|
route: externalRoute,
|
|
2796
|
+
routeStyle,
|
|
2786
2797
|
showNavigationUI: externalShowNavigationUI,
|
|
2787
2798
|
navigationData: externalNavigationData,
|
|
2788
2799
|
onNavigationAbort,
|
|
@@ -2807,6 +2818,7 @@ var MapInternal = ({
|
|
|
2807
2818
|
const hasIntegratedNav = journey.isActive;
|
|
2808
2819
|
const navigationData = hasIntegratedNav ? {
|
|
2809
2820
|
currentDistanceMeters: journey.distanceRemainingMeters,
|
|
2821
|
+
hasArrived: journey.hasArrived,
|
|
2810
2822
|
mode: journey.mode,
|
|
2811
2823
|
route: journey.route,
|
|
2812
2824
|
start: journey.start,
|
|
@@ -2967,6 +2979,7 @@ var MapInternal = ({
|
|
|
2967
2979
|
const showEtaData = showNavigationUI && navigationData && route ? {
|
|
2968
2980
|
distanceRemainingKm: kmRemaining,
|
|
2969
2981
|
etaMins,
|
|
2982
|
+
hasArrived: navigationData.hasArrived ?? false,
|
|
2970
2983
|
label: mode === "navigation" ? "Walking Guidance Active" : "Route Preview",
|
|
2971
2984
|
mode,
|
|
2972
2985
|
onAbort: () => {
|
|
@@ -3141,7 +3154,23 @@ var MapInternal = ({
|
|
|
3141
3154
|
initialViewState,
|
|
3142
3155
|
interactiveLayerIds: mergedInteractiveLayerIds,
|
|
3143
3156
|
mapStyle,
|
|
3144
|
-
maxBounds
|
|
3157
|
+
maxBounds: (
|
|
3158
|
+
// @vis.gl/react-maplibre's own <Map> component (aliased MapLibre
|
|
3159
|
+
// here) types maxBounds as a flat [west, south, east, north]
|
|
3160
|
+
// tuple — raw maplibre-gl's LngLatBoundsLike still accepts a
|
|
3161
|
+
// pair-of-corners shape, this narrowing is the wrapper's own.
|
|
3162
|
+
// This SDK's public MapProps.maxBounds keeps the
|
|
3163
|
+
// [[lng, lat], [lng, lat]] pair-of-corners shape (matches every
|
|
3164
|
+
// other coordinate prop in this SDK, e.g. flyTo), so it's
|
|
3165
|
+
// flattened here at the point of use rather than changing the
|
|
3166
|
+
// public API.
|
|
3167
|
+
maxBounds ? [
|
|
3168
|
+
maxBounds[0][0],
|
|
3169
|
+
maxBounds[0][1],
|
|
3170
|
+
maxBounds[1][0],
|
|
3171
|
+
maxBounds[1][1]
|
|
3172
|
+
] : void 0
|
|
3173
|
+
),
|
|
3145
3174
|
onClick: handleMapClick,
|
|
3146
3175
|
onContextMenu,
|
|
3147
3176
|
onDragStart: handleUserInteraction,
|
|
@@ -3178,7 +3207,16 @@ var MapInternal = ({
|
|
|
3178
3207
|
radiusMeters: mockLocation.radiusMeters
|
|
3179
3208
|
}
|
|
3180
3209
|
),
|
|
3181
|
-
displayRoute && /* @__PURE__ */ jsx16(
|
|
3210
|
+
displayRoute && /* @__PURE__ */ jsx16(
|
|
3211
|
+
RouteLayer,
|
|
3212
|
+
{
|
|
3213
|
+
color: routeStyle?.color,
|
|
3214
|
+
dashArray: routeStyle?.dashArray,
|
|
3215
|
+
geometry: displayRoute,
|
|
3216
|
+
opacity: routeStyle?.opacity,
|
|
3217
|
+
width: routeStyle?.width
|
|
3218
|
+
}
|
|
3219
|
+
),
|
|
3182
3220
|
pois.length > 0 && /* @__PURE__ */ jsxs12(Fragment5, { children: [
|
|
3183
3221
|
/* @__PURE__ */ jsx16(POILayers, { pois }),
|
|
3184
3222
|
/* @__PURE__ */ jsx16(POIMarkers, { onClick: onPoiClick, pois })
|
|
@@ -3403,7 +3441,7 @@ var loadImage2 = (src) => new Promise((resolve, reject) => {
|
|
|
3403
3441
|
});
|
|
3404
3442
|
|
|
3405
3443
|
// package.json
|
|
3406
|
-
var version = "0.
|
|
3444
|
+
var version = "0.10.0";
|
|
3407
3445
|
|
|
3408
3446
|
// src/sdk.ts
|
|
3409
3447
|
function deepFreeze(obj) {
|
|
@@ -3597,9 +3635,22 @@ var MiniAppSDK = class {
|
|
|
3597
3635
|
/**
|
|
3598
3636
|
* Performs a network request via the host shell.
|
|
3599
3637
|
* @param options Request method, URL, headers, and body.
|
|
3638
|
+
*
|
|
3639
|
+
* Real bug, caught by reviewer-strict: `options.timeoutMs` only ever
|
|
3640
|
+
* reached the shell's own `fetchWithTimeout` call — this `bridge.send`
|
|
3641
|
+
* has an entirely separate client-side promise timeout (its own
|
|
3642
|
+
* `timeoutMs` param, default 30000ms) waiting for the native reply,
|
|
3643
|
+
* previously left at that default regardless of what `options.timeoutMs`
|
|
3644
|
+
* said. A slow-but-legitimate call given a longer `options.timeoutMs`
|
|
3645
|
+
* (e.g. 50000ms for an LLM-backed endpoint) would still get this
|
|
3646
|
+
* bridge-level promise rejected ("Bridge request timeout") at 30s,
|
|
3647
|
+
* reintroducing the exact same "aborted before it could finish" bug
|
|
3648
|
+
* this field exists to fix, one layer up. Forwarding it here means both
|
|
3649
|
+
* ceilings move together; omitted (`undefined`, every other caller)
|
|
3650
|
+
* falls through to `send`'s own unchanged 30000ms default.
|
|
3600
3651
|
*/
|
|
3601
3652
|
request: async (options) => {
|
|
3602
|
-
return this.bridge.send("NETWORK_REQUEST", options);
|
|
3653
|
+
return this.bridge.send("NETWORK_REQUEST", options, options.timeoutMs);
|
|
3603
3654
|
}
|
|
3604
3655
|
});
|
|
3605
3656
|
/**
|
|
@@ -5368,10 +5419,11 @@ function createApiService(options) {
|
|
|
5368
5419
|
method: "PATCH",
|
|
5369
5420
|
url: buildUrl(getBaseUrl(), path)
|
|
5370
5421
|
}),
|
|
5371
|
-
post: (path, body) => sdk.network.request({
|
|
5422
|
+
post: (path, body, timeoutMs) => sdk.network.request({
|
|
5372
5423
|
body,
|
|
5373
5424
|
headers: { "Content-Type": "application/json" },
|
|
5374
5425
|
method: "POST",
|
|
5426
|
+
timeoutMs,
|
|
5375
5427
|
url: buildUrl(getBaseUrl(), path)
|
|
5376
5428
|
}),
|
|
5377
5429
|
get wsUrl() {
|