@cloudparse/up-miniapps-sdk 0.6.7 → 0.6.8
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 +38 -38
- package/dist/index.browser.min.js.map +1 -1
- package/dist/index.cjs +139 -113
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +203 -177
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -726,7 +726,7 @@ var MapDrawer = forwardRef3(
|
|
|
726
726
|
const dragDelta = touchEndY - dragStartY;
|
|
727
727
|
const drawerHeightFromBottom = dragBaseHeightPxRef.current - dragDelta;
|
|
728
728
|
const distToClosed = Math.abs(drawerHeightFromBottom - closedPx);
|
|
729
|
-
let
|
|
729
|
+
let targetState2;
|
|
730
730
|
if (currentState === "auto") {
|
|
731
731
|
const autoMaxPx2 = resolveHeightToPixels(
|
|
732
732
|
drawerAutoMaxHeight || "100%",
|
|
@@ -734,22 +734,22 @@ var MapDrawer = forwardRef3(
|
|
|
734
734
|
);
|
|
735
735
|
const autoPx2 = Math.min(autoMaxPx2, autoContentPx);
|
|
736
736
|
const distToAuto = Math.abs(drawerHeightFromBottom - autoPx2);
|
|
737
|
-
|
|
737
|
+
targetState2 = distToAuto <= distToClosed ? "auto" : "closed";
|
|
738
738
|
} else {
|
|
739
739
|
const distToFull = Math.abs(drawerHeightFromBottom - fullPx2);
|
|
740
740
|
const distToPeek = Math.abs(drawerHeightFromBottom - peekPx2);
|
|
741
741
|
const minDist = Math.min(distToFull, distToPeek, distToClosed);
|
|
742
742
|
if (minDist === distToFull) {
|
|
743
|
-
|
|
743
|
+
targetState2 = "full";
|
|
744
744
|
} else if (minDist === distToPeek) {
|
|
745
|
-
|
|
745
|
+
targetState2 = "peek";
|
|
746
746
|
} else {
|
|
747
|
-
|
|
747
|
+
targetState2 = "closed";
|
|
748
748
|
}
|
|
749
749
|
}
|
|
750
750
|
setTouchStartY(null);
|
|
751
751
|
setCurrentTouchY(null);
|
|
752
|
-
onChangeState(
|
|
752
|
+
onChangeState(targetState2);
|
|
753
753
|
requestAnimationFrame(() => {
|
|
754
754
|
if (parentContainer) {
|
|
755
755
|
parentContainer.style.setProperty("--drag-offset", "0px");
|
|
@@ -2031,122 +2031,149 @@ var GlobalEvent = /* @__PURE__ */ ((GlobalEvent2) => {
|
|
|
2031
2031
|
})(GlobalEvent || {});
|
|
2032
2032
|
|
|
2033
2033
|
// src/components/Map/hooks/useUserLocation.ts
|
|
2034
|
-
import {
|
|
2034
|
+
import { useEffect as useEffect3, useState as useState4 } from "react";
|
|
2035
2035
|
var LERP_FACTOR = 0.12;
|
|
2036
|
-
var
|
|
2037
|
-
|
|
2038
|
-
|
|
2039
|
-
|
|
2040
|
-
|
|
2041
|
-
|
|
2042
|
-
const
|
|
2043
|
-
|
|
2044
|
-
|
|
2045
|
-
|
|
2046
|
-
|
|
2047
|
-
|
|
2048
|
-
|
|
2049
|
-
|
|
2050
|
-
|
|
2051
|
-
|
|
2052
|
-
|
|
2053
|
-
|
|
2054
|
-
|
|
2055
|
-
|
|
2056
|
-
|
|
2057
|
-
|
|
2058
|
-
|
|
2059
|
-
|
|
2060
|
-
|
|
2061
|
-
|
|
2062
|
-
|
|
2063
|
-
|
|
2064
|
-
|
|
2065
|
-
|
|
2066
|
-
|
|
2067
|
-
|
|
2068
|
-
|
|
2069
|
-
|
|
2070
|
-
|
|
2071
|
-
|
|
2072
|
-
|
|
2073
|
-
|
|
2074
|
-
|
|
2075
|
-
|
|
2076
|
-
|
|
2077
|
-
|
|
2078
|
-
|
|
2079
|
-
|
|
2080
|
-
|
|
2081
|
-
|
|
2082
|
-
|
|
2083
|
-
|
|
2084
|
-
|
|
2085
|
-
|
|
2086
|
-
|
|
2087
|
-
|
|
2088
|
-
|
|
2089
|
-
if (
|
|
2090
|
-
|
|
2091
|
-
|
|
2092
|
-
changed = true;
|
|
2093
|
-
} else {
|
|
2094
|
-
const target = targetRef.current.heading;
|
|
2095
|
-
const current = currentRef.current.heading;
|
|
2096
|
-
let delta = target - current;
|
|
2097
|
-
if (delta > 180) delta -= 360;
|
|
2098
|
-
if (delta < -180) delta += 360;
|
|
2099
|
-
const nHeading = current + delta * LERP_FACTOR;
|
|
2100
|
-
const normalized = (nHeading % 360 + 360) % 360;
|
|
2101
|
-
if (Math.abs(delta) > 0.1) {
|
|
2102
|
-
currentRef.current.heading = normalized;
|
|
2103
|
-
changed = true;
|
|
2104
|
-
}
|
|
2105
|
-
}
|
|
2106
|
-
}
|
|
2107
|
-
if (changed) {
|
|
2108
|
-
setLocationState({
|
|
2109
|
-
accuracy: targetRef.current.accuracy,
|
|
2110
|
-
coords: currentRef.current.coords ? [...currentRef.current.coords] : null,
|
|
2111
|
-
heading: currentRef.current.heading
|
|
2112
|
-
});
|
|
2113
|
-
}
|
|
2114
|
-
rafId = requestAnimationFrame(animate);
|
|
2115
|
-
};
|
|
2116
|
-
rafId = requestAnimationFrame(animate);
|
|
2117
|
-
sdk.location.getCurrentPosition().then((data) => {
|
|
2118
|
-
const payload = mapPayload(data);
|
|
2119
|
-
targetRef.current = payload;
|
|
2120
|
-
}).catch((e) => console.warn("Initial location fetch failed", e));
|
|
2121
|
-
const unsubscribeStream = sdk.on(
|
|
2122
|
-
"LOCATION_STREAM_UPDATE" /* LOCATION_STREAM_UPDATE */,
|
|
2123
|
-
(payload) => {
|
|
2124
|
-
targetRef.current = mapPayload(payload);
|
|
2036
|
+
var EMPTY_STATE = {
|
|
2037
|
+
accuracy: null,
|
|
2038
|
+
coords: null,
|
|
2039
|
+
heading: null
|
|
2040
|
+
};
|
|
2041
|
+
function mapPayload(payload) {
|
|
2042
|
+
const coords = payload.location?.coords || payload.coords;
|
|
2043
|
+
const headingData = payload.heading;
|
|
2044
|
+
const newCoords = coords ? [coords.longitude, coords.latitude] : null;
|
|
2045
|
+
let heading = null;
|
|
2046
|
+
if (headingData?.trueHeading !== void 0 && headingData.trueHeading >= 0) {
|
|
2047
|
+
heading = headingData.trueHeading;
|
|
2048
|
+
} else if (headingData?.magneticHeading !== void 0 && headingData.magneticHeading >= 0) {
|
|
2049
|
+
heading = headingData.magneticHeading;
|
|
2050
|
+
} else if (headingData?.heading !== null && headingData?.heading >= 0) {
|
|
2051
|
+
heading = headingData.heading;
|
|
2052
|
+
}
|
|
2053
|
+
return {
|
|
2054
|
+
accuracy: coords?.accuracy || null,
|
|
2055
|
+
coords: newCoords,
|
|
2056
|
+
heading
|
|
2057
|
+
};
|
|
2058
|
+
}
|
|
2059
|
+
var refCount = 0;
|
|
2060
|
+
var generation = 0;
|
|
2061
|
+
var subscribers = /* @__PURE__ */ new Set();
|
|
2062
|
+
var targetState = { ...EMPTY_STATE };
|
|
2063
|
+
var currentInterpolated = { coords: null, heading: null };
|
|
2064
|
+
var rafId = null;
|
|
2065
|
+
var unsubscribeStream = null;
|
|
2066
|
+
var unsubscribeLegacy = null;
|
|
2067
|
+
function getSnapshot() {
|
|
2068
|
+
return {
|
|
2069
|
+
accuracy: targetState.accuracy,
|
|
2070
|
+
coords: currentInterpolated.coords ? [...currentInterpolated.coords] : null,
|
|
2071
|
+
heading: currentInterpolated.heading
|
|
2072
|
+
};
|
|
2073
|
+
}
|
|
2074
|
+
function notify() {
|
|
2075
|
+
const snapshot = getSnapshot();
|
|
2076
|
+
for (const callback of subscribers) callback(snapshot);
|
|
2077
|
+
}
|
|
2078
|
+
function animate() {
|
|
2079
|
+
let changed = false;
|
|
2080
|
+
if (targetState.coords) {
|
|
2081
|
+
if (!currentInterpolated.coords) {
|
|
2082
|
+
currentInterpolated.coords = [...targetState.coords];
|
|
2083
|
+
changed = true;
|
|
2084
|
+
} else {
|
|
2085
|
+
const [tLng, tLat] = targetState.coords;
|
|
2086
|
+
const [cLng, cLat] = currentInterpolated.coords;
|
|
2087
|
+
const nLng = cLng + (tLng - cLng) * LERP_FACTOR;
|
|
2088
|
+
const nLat = cLat + (tLat - cLat) * LERP_FACTOR;
|
|
2089
|
+
if (Math.abs(nLng - cLng) > 1e-7 || Math.abs(nLat - cLat) > 1e-7) {
|
|
2090
|
+
currentInterpolated.coords = [nLng, nLat];
|
|
2091
|
+
changed = true;
|
|
2125
2092
|
}
|
|
2126
|
-
|
|
2127
|
-
|
|
2128
|
-
|
|
2129
|
-
|
|
2130
|
-
|
|
2093
|
+
}
|
|
2094
|
+
}
|
|
2095
|
+
if (targetState.heading !== null) {
|
|
2096
|
+
if (currentInterpolated.heading === null) {
|
|
2097
|
+
currentInterpolated.heading = targetState.heading;
|
|
2098
|
+
changed = true;
|
|
2099
|
+
} else {
|
|
2100
|
+
const target = targetState.heading;
|
|
2101
|
+
const current = currentInterpolated.heading;
|
|
2102
|
+
let delta = target - current;
|
|
2103
|
+
if (delta > 180) delta -= 360;
|
|
2104
|
+
if (delta < -180) delta += 360;
|
|
2105
|
+
const nHeading = current + delta * LERP_FACTOR;
|
|
2106
|
+
const normalized = (nHeading % 360 + 360) % 360;
|
|
2107
|
+
if (Math.abs(delta) > 0.1) {
|
|
2108
|
+
currentInterpolated.heading = normalized;
|
|
2109
|
+
changed = true;
|
|
2131
2110
|
}
|
|
2132
|
-
|
|
2133
|
-
|
|
2134
|
-
|
|
2135
|
-
|
|
2136
|
-
|
|
2111
|
+
}
|
|
2112
|
+
}
|
|
2113
|
+
if (changed) notify();
|
|
2114
|
+
rafId = requestAnimationFrame(animate);
|
|
2115
|
+
}
|
|
2116
|
+
function startSharedStream() {
|
|
2117
|
+
rafId = requestAnimationFrame(animate);
|
|
2118
|
+
generation++;
|
|
2119
|
+
const thisGeneration = generation;
|
|
2120
|
+
sdk.location.getCurrentPosition().then((data) => {
|
|
2121
|
+
if (thisGeneration !== generation) return;
|
|
2122
|
+
targetState = mapPayload(data);
|
|
2123
|
+
}).catch((e) => console.warn("Initial location fetch failed", e));
|
|
2124
|
+
unsubscribeStream = sdk.on(
|
|
2125
|
+
"LOCATION_STREAM_UPDATE" /* LOCATION_STREAM_UPDATE */,
|
|
2126
|
+
(payload) => {
|
|
2127
|
+
targetState = mapPayload(payload);
|
|
2128
|
+
}
|
|
2129
|
+
);
|
|
2130
|
+
unsubscribeLegacy = sdk.on(
|
|
2131
|
+
"LOCATION_UPDATE" /* LOCATION_UPDATE */,
|
|
2132
|
+
(payload) => {
|
|
2133
|
+
targetState = mapPayload(payload);
|
|
2134
|
+
}
|
|
2135
|
+
);
|
|
2136
|
+
sdk.location.startStream({
|
|
2137
|
+
distanceFilter: 1,
|
|
2138
|
+
headingThreshold: 2
|
|
2139
|
+
}).catch((e) => console.warn("Failed to start location stream", e));
|
|
2140
|
+
}
|
|
2141
|
+
function stopSharedStream() {
|
|
2142
|
+
generation++;
|
|
2143
|
+
if (rafId !== null) cancelAnimationFrame(rafId);
|
|
2144
|
+
rafId = null;
|
|
2145
|
+
unsubscribeStream?.();
|
|
2146
|
+
unsubscribeLegacy?.();
|
|
2147
|
+
unsubscribeStream = null;
|
|
2148
|
+
unsubscribeLegacy = null;
|
|
2149
|
+
sdk.location.stopStream().catch(() => {
|
|
2150
|
+
});
|
|
2151
|
+
targetState = { ...EMPTY_STATE };
|
|
2152
|
+
currentInterpolated = { coords: null, heading: null };
|
|
2153
|
+
}
|
|
2154
|
+
var useUserLocation = () => {
|
|
2155
|
+
const [locationState, setLocationState] = useState4(getSnapshot);
|
|
2156
|
+
useEffect3(() => {
|
|
2157
|
+
refCount++;
|
|
2158
|
+
if (refCount === 1) {
|
|
2159
|
+
startSharedStream();
|
|
2160
|
+
} else {
|
|
2161
|
+
setLocationState(getSnapshot());
|
|
2162
|
+
}
|
|
2163
|
+
subscribers.add(setLocationState);
|
|
2137
2164
|
return () => {
|
|
2138
|
-
|
|
2139
|
-
|
|
2140
|
-
|
|
2141
|
-
|
|
2142
|
-
}
|
|
2165
|
+
subscribers.delete(setLocationState);
|
|
2166
|
+
refCount--;
|
|
2167
|
+
if (refCount === 0) {
|
|
2168
|
+
stopSharedStream();
|
|
2169
|
+
}
|
|
2143
2170
|
};
|
|
2144
|
-
}, [
|
|
2171
|
+
}, []);
|
|
2145
2172
|
return locationState;
|
|
2146
2173
|
};
|
|
2147
2174
|
|
|
2148
2175
|
// src/components/Map/hooks/useLiveRouting.ts
|
|
2149
|
-
import { useCallback as
|
|
2176
|
+
import { useCallback as useCallback3, useEffect as useEffect4, useMemo as useMemo2, useRef as useRef4, useState as useState5 } from "react";
|
|
2150
2177
|
var useLiveRouting = ({
|
|
2151
2178
|
origin: manualOrigin,
|
|
2152
2179
|
destination,
|
|
@@ -2163,11 +2190,11 @@ var useLiveRouting = ({
|
|
|
2163
2190
|
const userLocationState = useUserLocation();
|
|
2164
2191
|
const calculationOrigin = manualOrigin || userLocationState.coords;
|
|
2165
2192
|
const trackingLocation = userLocationState.coords || manualOrigin;
|
|
2166
|
-
const lastCalcOrigin =
|
|
2167
|
-
const lastCalcDest =
|
|
2168
|
-
const isRequestInProgress =
|
|
2169
|
-
const lastResetDestKey =
|
|
2170
|
-
const getDistance =
|
|
2193
|
+
const lastCalcOrigin = useRef4(null);
|
|
2194
|
+
const lastCalcDest = useRef4(null);
|
|
2195
|
+
const isRequestInProgress = useRef4(false);
|
|
2196
|
+
const lastResetDestKey = useRef4(null);
|
|
2197
|
+
const getDistance = useCallback3(
|
|
2171
2198
|
(p1, p2) => {
|
|
2172
2199
|
const R = 6371e3;
|
|
2173
2200
|
const \u03C61 = p1[1] * Math.PI / 180;
|
|
@@ -2207,7 +2234,7 @@ var useLiveRouting = ({
|
|
|
2207
2234
|
}
|
|
2208
2235
|
return dist;
|
|
2209
2236
|
}, [trackingLocation, route, destination, getDistance]);
|
|
2210
|
-
const calculate =
|
|
2237
|
+
const calculate = useCallback3(
|
|
2211
2238
|
async (origin, dest, isNewDest) => {
|
|
2212
2239
|
if (isRequestInProgress.current) return;
|
|
2213
2240
|
isRequestInProgress.current = true;
|
|
@@ -2328,7 +2355,7 @@ var useRoute = (origin, destination, profile = "driving") => {
|
|
|
2328
2355
|
};
|
|
2329
2356
|
|
|
2330
2357
|
// src/components/Map/hooks/useJourney.ts
|
|
2331
|
-
import { useCallback as
|
|
2358
|
+
import { useCallback as useCallback4, useEffect as useEffect5, useRef as useRef5, useState as useState6 } from "react";
|
|
2332
2359
|
var useJourney = (options = {}) => {
|
|
2333
2360
|
const { navigation, onAbort, onModeChange } = options;
|
|
2334
2361
|
const [progNav, setProgNav] = useState6(null);
|
|
@@ -2361,7 +2388,7 @@ var useJourney = (options = {}) => {
|
|
|
2361
2388
|
profile: effectiveOptions?.profile || "driving",
|
|
2362
2389
|
recalculateThreshold: effectiveOptions?.recalculateThreshold || 50
|
|
2363
2390
|
});
|
|
2364
|
-
const prevDest =
|
|
2391
|
+
const prevDest = useRef5(null);
|
|
2365
2392
|
const currentDest = effectiveOptions?.destination;
|
|
2366
2393
|
useEffect5(() => {
|
|
2367
2394
|
if (currentDest && (!prevDest.current || prevDest.current[0] !== currentDest[0] || prevDest.current[1] !== currentDest[1])) {
|
|
@@ -2369,7 +2396,7 @@ var useJourney = (options = {}) => {
|
|
|
2369
2396
|
}
|
|
2370
2397
|
prevDest.current = currentDest;
|
|
2371
2398
|
}, [currentDest]);
|
|
2372
|
-
const onModeChangeRef =
|
|
2399
|
+
const onModeChangeRef = useRef5(onModeChange);
|
|
2373
2400
|
onModeChangeRef.current = onModeChange;
|
|
2374
2401
|
useEffect5(() => {
|
|
2375
2402
|
onModeChangeRef.current?.(internalNav.mode);
|
|
@@ -2393,13 +2420,13 @@ var useJourney = (options = {}) => {
|
|
|
2393
2420
|
(totalDistanceMeters - remainingMeters) / totalDistanceMeters * 100
|
|
2394
2421
|
)
|
|
2395
2422
|
) : 0;
|
|
2396
|
-
const cancel =
|
|
2423
|
+
const cancel = useCallback4(() => {
|
|
2397
2424
|
setIsAborted(true);
|
|
2398
2425
|
setProgNav(null);
|
|
2399
2426
|
sdk.navigation.abort();
|
|
2400
2427
|
if (onAbort) onAbort();
|
|
2401
2428
|
}, [onAbort]);
|
|
2402
|
-
const start =
|
|
2429
|
+
const start = useCallback4(() => {
|
|
2403
2430
|
sdk.navigation.start();
|
|
2404
2431
|
internalNav.start();
|
|
2405
2432
|
}, [internalNav.start]);
|
|
@@ -2887,11 +2914,11 @@ var UserLocationLayer = ({
|
|
|
2887
2914
|
// src/components/Map/Map.tsx
|
|
2888
2915
|
import { Map as MapLibre, MapProvider } from "@vis.gl/react-maplibre";
|
|
2889
2916
|
import React4, {
|
|
2890
|
-
useCallback as
|
|
2917
|
+
useCallback as useCallback5,
|
|
2891
2918
|
useContext as useContext5,
|
|
2892
2919
|
useEffect as useEffect7,
|
|
2893
2920
|
useMemo as useMemo6,
|
|
2894
|
-
useRef as
|
|
2921
|
+
useRef as useRef6,
|
|
2895
2922
|
useState as useState8
|
|
2896
2923
|
} from "react";
|
|
2897
2924
|
import "maplibre-gl/dist/maplibre-gl.css";
|
|
@@ -2935,7 +2962,7 @@ var MapInternal = ({
|
|
|
2935
2962
|
}) => {
|
|
2936
2963
|
const mapControls = useContext5(MapControlsContext);
|
|
2937
2964
|
const mockLocation = useContext5(MockLocationContext);
|
|
2938
|
-
const mapRef =
|
|
2965
|
+
const mapRef = useRef6(null);
|
|
2939
2966
|
const userLocationState = useUserLocation();
|
|
2940
2967
|
const journey = useJourney({
|
|
2941
2968
|
navigation,
|
|
@@ -2953,14 +2980,14 @@ var MapInternal = ({
|
|
|
2953
2980
|
const showNavigationUI = hasIntegratedNav ? externalShowNavigationUI !== false && navigation?.showUI !== false : externalShowNavigationUI;
|
|
2954
2981
|
const mode = navigationData?.mode || "preview";
|
|
2955
2982
|
const resolvedInitialFollow = mapControls ? mapControls.isFollowing : initialFollowUser;
|
|
2956
|
-
const isFollowingRef =
|
|
2957
|
-
const isFlyingRef =
|
|
2958
|
-
const flyingGenerationRef =
|
|
2959
|
-
const lockFlying =
|
|
2983
|
+
const isFollowingRef = useRef6(resolvedInitialFollow);
|
|
2984
|
+
const isFlyingRef = useRef6(false);
|
|
2985
|
+
const flyingGenerationRef = useRef6(0);
|
|
2986
|
+
const lockFlying = useCallback5(() => {
|
|
2960
2987
|
isFlyingRef.current = true;
|
|
2961
2988
|
return ++flyingGenerationRef.current;
|
|
2962
2989
|
}, []);
|
|
2963
|
-
const releaseFlyingIfCurrent =
|
|
2990
|
+
const releaseFlyingIfCurrent = useCallback5((flightId) => {
|
|
2964
2991
|
if (flyingGenerationRef.current === flightId) {
|
|
2965
2992
|
isFlyingRef.current = false;
|
|
2966
2993
|
}
|
|
@@ -2970,7 +2997,7 @@ var MapInternal = ({
|
|
|
2970
2997
|
);
|
|
2971
2998
|
const isFollowingUI = mapControls ? mapControls.isFollowing : localIsFollowingUI;
|
|
2972
2999
|
const setIsFollowingCtx = mapControls?.setIsFollowing;
|
|
2973
|
-
const setFollowMode =
|
|
3000
|
+
const setFollowMode = useCallback5(
|
|
2974
3001
|
(follow) => {
|
|
2975
3002
|
isFollowingRef.current = follow;
|
|
2976
3003
|
setLocalIsFollowingUI(follow);
|
|
@@ -2989,7 +3016,7 @@ var MapInternal = ({
|
|
|
2989
3016
|
if (pois.length > 0 && !mergedInteractiveLayerIds.includes("sdk-poi-layer")) {
|
|
2990
3017
|
mergedInteractiveLayerIds.push("sdk-poi-layer");
|
|
2991
3018
|
}
|
|
2992
|
-
const prevInitialFollow =
|
|
3019
|
+
const prevInitialFollow = useRef6(initialFollowUser);
|
|
2993
3020
|
useEffect7(() => {
|
|
2994
3021
|
if (initialFollowUser !== prevInitialFollow.current) {
|
|
2995
3022
|
setFollowMode(initialFollowUser);
|
|
@@ -3014,8 +3041,8 @@ var MapInternal = ({
|
|
|
3014
3041
|
lockFlying,
|
|
3015
3042
|
releaseFlyingIfCurrent
|
|
3016
3043
|
]);
|
|
3017
|
-
const lastAutoLockedRouteRef =
|
|
3018
|
-
const lastModeRef =
|
|
3044
|
+
const lastAutoLockedRouteRef = useRef6(null);
|
|
3045
|
+
const lastModeRef = useRef6(null);
|
|
3019
3046
|
useEffect7(() => {
|
|
3020
3047
|
if (!route || !mapRef.current) {
|
|
3021
3048
|
if (!route) lastAutoLockedRouteRef.current = null;
|
|
@@ -3188,7 +3215,7 @@ var MapInternal = ({
|
|
|
3188
3215
|
}
|
|
3189
3216
|
if (onClick) onClick(e);
|
|
3190
3217
|
};
|
|
3191
|
-
const handleCenterOnUser =
|
|
3218
|
+
const handleCenterOnUser = useCallback5(
|
|
3192
3219
|
(payload) => {
|
|
3193
3220
|
if (userLocationState.coords && mapRef.current) {
|
|
3194
3221
|
setFollowMode(true);
|
|
@@ -3213,7 +3240,7 @@ var MapInternal = ({
|
|
|
3213
3240
|
releaseFlyingIfCurrent
|
|
3214
3241
|
]
|
|
3215
3242
|
);
|
|
3216
|
-
const handleFlyTo =
|
|
3243
|
+
const handleFlyTo = useCallback5(
|
|
3217
3244
|
(coords, params) => {
|
|
3218
3245
|
const map = mapRef.current;
|
|
3219
3246
|
if (!map) return;
|
|
@@ -3233,7 +3260,7 @@ var MapInternal = ({
|
|
|
3233
3260
|
},
|
|
3234
3261
|
[setFollowMode, lockFlying, releaseFlyingIfCurrent]
|
|
3235
3262
|
);
|
|
3236
|
-
const handleResetBearing =
|
|
3263
|
+
const handleResetBearing = useCallback5((params) => {
|
|
3237
3264
|
if (mapRef.current) {
|
|
3238
3265
|
mapRef.current.easeTo({
|
|
3239
3266
|
bearing: 0,
|
|
@@ -3250,7 +3277,7 @@ var MapInternal = ({
|
|
|
3250
3277
|
mapControls._registerFlyToCallback(handleFlyTo);
|
|
3251
3278
|
}
|
|
3252
3279
|
}, [mapControls, handleCenterOnUser, handleResetBearing, handleFlyTo]);
|
|
3253
|
-
const handleMove =
|
|
3280
|
+
const handleMove = useCallback5(() => {
|
|
3254
3281
|
if (mapRef.current && mapControls) {
|
|
3255
3282
|
mapControls.setBearing(mapRef.current.getBearing());
|
|
3256
3283
|
mapControls.setPitch(mapRef.current.getPitch());
|
|
@@ -3540,7 +3567,7 @@ var loadImage2 = (src) => new Promise((resolve, reject) => {
|
|
|
3540
3567
|
});
|
|
3541
3568
|
|
|
3542
3569
|
// package.json
|
|
3543
|
-
var version = "0.6.
|
|
3570
|
+
var version = "0.6.8";
|
|
3544
3571
|
|
|
3545
3572
|
// src/sdk.ts
|
|
3546
3573
|
function deepFreeze(obj) {
|
|
@@ -3947,11 +3974,10 @@ var MiniAppSDK = class {
|
|
|
3947
3974
|
var sdk = deepFreeze(new MiniAppSDK());
|
|
3948
3975
|
|
|
3949
3976
|
// src/components/BridgeMocker.tsx
|
|
3950
|
-
import { useCallback as
|
|
3977
|
+
import { useCallback as useCallback6, useEffect as useEffect8, useMemo as useMemo7, useRef as useRef7, useState as useState9 } from "react";
|
|
3951
3978
|
import { jsx as jsx16, jsxs as jsxs12 } from "react/jsx-runtime";
|
|
3952
3979
|
var AVATAR_MOUTH_VARIANTS = [
|
|
3953
3980
|
"variant03",
|
|
3954
|
-
"variant06",
|
|
3955
3981
|
"variant07",
|
|
3956
3982
|
"variant08",
|
|
3957
3983
|
"variant09",
|
|
@@ -4045,10 +4071,10 @@ var BridgeMocker = ({
|
|
|
4045
4071
|
const [radiusMeters, setRadiusMeters] = useState9(0);
|
|
4046
4072
|
const [radiusUnit, setRadiusUnit] = useState9("m");
|
|
4047
4073
|
const [isPlacingLocation, setIsPlacingLocation] = useState9(false);
|
|
4048
|
-
const streamIntervalRef =
|
|
4049
|
-
const pathIndexRef =
|
|
4050
|
-
const activeConfigRef =
|
|
4051
|
-
const stateRef =
|
|
4074
|
+
const streamIntervalRef = useRef7(null);
|
|
4075
|
+
const pathIndexRef = useRef7(0);
|
|
4076
|
+
const activeConfigRef = useRef7(null);
|
|
4077
|
+
const stateRef = useRef7({
|
|
4052
4078
|
autoMove,
|
|
4053
4079
|
heading,
|
|
4054
4080
|
location,
|
|
@@ -4060,7 +4086,7 @@ var BridgeMocker = ({
|
|
|
4060
4086
|
simulationPath,
|
|
4061
4087
|
speedMultiplier
|
|
4062
4088
|
});
|
|
4063
|
-
const pushLocationUpdateFor =
|
|
4089
|
+
const pushLocationUpdateFor = useCallback6(
|
|
4064
4090
|
(coords, headingDeg) => {
|
|
4065
4091
|
const currentState = stateRef.current;
|
|
4066
4092
|
const payload = {
|
|
@@ -4092,11 +4118,11 @@ var BridgeMocker = ({
|
|
|
4092
4118
|
},
|
|
4093
4119
|
[]
|
|
4094
4120
|
);
|
|
4095
|
-
const pushLocationUpdate =
|
|
4121
|
+
const pushLocationUpdate = useCallback6(() => {
|
|
4096
4122
|
const currentState = stateRef.current;
|
|
4097
4123
|
pushLocationUpdateFor(currentState.location, currentState.heading);
|
|
4098
4124
|
}, [pushLocationUpdateFor]);
|
|
4099
|
-
const placeLocation =
|
|
4125
|
+
const placeLocation = useCallback6(
|
|
4100
4126
|
(coords) => {
|
|
4101
4127
|
setLocation(coords);
|
|
4102
4128
|
setIsPlacingLocation(false);
|
|
@@ -4546,7 +4572,7 @@ var BridgeMocker = ({
|
|
|
4546
4572
|
};
|
|
4547
4573
|
|
|
4548
4574
|
// src/components/DebugConsole.tsx
|
|
4549
|
-
import { useCallback as
|
|
4575
|
+
import { useCallback as useCallback7, useEffect as useEffect9, useRef as useRef8, useState as useState10 } from "react";
|
|
4550
4576
|
import { jsx as jsx17, jsxs as jsxs13 } from "react/jsx-runtime";
|
|
4551
4577
|
var DebugConsole = ({
|
|
4552
4578
|
isOpen: initialOpen = false,
|
|
@@ -4554,12 +4580,12 @@ var DebugConsole = ({
|
|
|
4554
4580
|
}) => {
|
|
4555
4581
|
const [showConsole, setShowConsole] = useState10(initialOpen);
|
|
4556
4582
|
const [logs, setLogs] = useState10([]);
|
|
4557
|
-
const scrollRef =
|
|
4583
|
+
const scrollRef = useRef8(null);
|
|
4558
4584
|
useEffect9(() => {
|
|
4559
4585
|
setShowConsole(initialOpen);
|
|
4560
4586
|
}, [initialOpen]);
|
|
4561
4587
|
const clearLogs = () => setLogs([]);
|
|
4562
|
-
const addLog =
|
|
4588
|
+
const addLog = useCallback7((label, data) => {
|
|
4563
4589
|
if (label.includes("LOCATION_STREAM_UPDATE" /* LOCATION_STREAM_UPDATE */)) return;
|
|
4564
4590
|
const entry = {
|
|
4565
4591
|
content: typeof data === "string" ? data : JSON.stringify(data, null, 2),
|
|
@@ -4687,7 +4713,7 @@ var DebugConsole = ({
|
|
|
4687
4713
|
};
|
|
4688
4714
|
|
|
4689
4715
|
// src/components/PullToRefresh.tsx
|
|
4690
|
-
import { useEffect as useEffect10, useRef as
|
|
4716
|
+
import { useEffect as useEffect10, useRef as useRef9, useState as useState11 } from "react";
|
|
4691
4717
|
import { jsx as jsx18, jsxs as jsxs14 } from "react/jsx-runtime";
|
|
4692
4718
|
var DEFAULT_PULL_THRESHOLD = 64;
|
|
4693
4719
|
var DEFAULT_MAX_PULL = 96;
|
|
@@ -4754,25 +4780,25 @@ var PullToRefresh = ({
|
|
|
4754
4780
|
maxPull = DEFAULT_MAX_PULL,
|
|
4755
4781
|
renderIndicator
|
|
4756
4782
|
}) => {
|
|
4757
|
-
const containerRef =
|
|
4758
|
-
const startYRef =
|
|
4759
|
-
const lastYRef =
|
|
4760
|
-
const lastMoveTimeRef =
|
|
4761
|
-
const velocityRef =
|
|
4762
|
-
const pointerIdRef =
|
|
4763
|
-
const isPullingRef =
|
|
4764
|
-
const pullDistanceRef =
|
|
4765
|
-
const flingRafRef =
|
|
4783
|
+
const containerRef = useRef9(null);
|
|
4784
|
+
const startYRef = useRef9(null);
|
|
4785
|
+
const lastYRef = useRef9(0);
|
|
4786
|
+
const lastMoveTimeRef = useRef9(0);
|
|
4787
|
+
const velocityRef = useRef9(0);
|
|
4788
|
+
const pointerIdRef = useRef9(null);
|
|
4789
|
+
const isPullingRef = useRef9(false);
|
|
4790
|
+
const pullDistanceRef = useRef9(0);
|
|
4791
|
+
const flingRafRef = useRef9(null);
|
|
4766
4792
|
const [pullDistance, setPullDistance] = useState11(0);
|
|
4767
4793
|
const [isRefreshing, setIsRefreshing] = useState11(false);
|
|
4768
4794
|
const [isTracking, setIsTracking] = useState11(false);
|
|
4769
|
-
const disabledRef =
|
|
4795
|
+
const disabledRef = useRef9(disabled);
|
|
4770
4796
|
disabledRef.current = disabled;
|
|
4771
|
-
const onRefreshRef =
|
|
4797
|
+
const onRefreshRef = useRef9(onRefresh);
|
|
4772
4798
|
onRefreshRef.current = onRefresh;
|
|
4773
|
-
const pullThresholdRef =
|
|
4799
|
+
const pullThresholdRef = useRef9(pullThreshold);
|
|
4774
4800
|
pullThresholdRef.current = pullThreshold;
|
|
4775
|
-
const maxPullRef =
|
|
4801
|
+
const maxPullRef = useRef9(maxPull);
|
|
4776
4802
|
maxPullRef.current = maxPull;
|
|
4777
4803
|
useEffect10(() => {
|
|
4778
4804
|
const el = containerRef.current;
|
|
@@ -4941,14 +4967,14 @@ var PullToRefresh = ({
|
|
|
4941
4967
|
|
|
4942
4968
|
// src/components/QRScanner.tsx
|
|
4943
4969
|
import jsQR2 from "jsqr";
|
|
4944
|
-
import { useEffect as useEffect11, useRef as
|
|
4970
|
+
import { useEffect as useEffect11, useRef as useRef10, useState as useState12 } from "react";
|
|
4945
4971
|
import { jsx as jsx19, jsxs as jsxs15 } from "react/jsx-runtime";
|
|
4946
4972
|
function QRScanner({ onScan, onError, className = "" }) {
|
|
4947
|
-
const videoRef =
|
|
4948
|
-
const canvasRef =
|
|
4949
|
-
const streamRef =
|
|
4950
|
-
const tickRequestRef =
|
|
4951
|
-
const hasScannedRef =
|
|
4973
|
+
const videoRef = useRef10(null);
|
|
4974
|
+
const canvasRef = useRef10(null);
|
|
4975
|
+
const streamRef = useRef10(null);
|
|
4976
|
+
const tickRequestRef = useRef10(null);
|
|
4977
|
+
const hasScannedRef = useRef10(false);
|
|
4952
4978
|
const [isReady, setIsReady] = useState12(false);
|
|
4953
4979
|
useEffect11(() => {
|
|
4954
4980
|
let cancelled = false;
|
|
@@ -5100,7 +5126,7 @@ var SDKProvider = ({
|
|
|
5100
5126
|
import {
|
|
5101
5127
|
useEffect as useEffect12,
|
|
5102
5128
|
useLayoutEffect,
|
|
5103
|
-
useRef as
|
|
5129
|
+
useRef as useRef11,
|
|
5104
5130
|
useState as useState13
|
|
5105
5131
|
} from "react";
|
|
5106
5132
|
import { jsx as jsx21 } from "react/jsx-runtime";
|
|
@@ -5130,20 +5156,20 @@ var SwipeCarousel = ({
|
|
|
5130
5156
|
overscan = DEFAULT_OVERSCAN,
|
|
5131
5157
|
visibleOverscan = DEFAULT_VISIBLE_OVERSCAN
|
|
5132
5158
|
}) => {
|
|
5133
|
-
const containerRef =
|
|
5159
|
+
const containerRef = useRef11(null);
|
|
5134
5160
|
const [containerWidth, setContainerWidth] = useState13(0);
|
|
5135
5161
|
const [dragX, setDragX] = useState13(0);
|
|
5136
5162
|
const [dragY, setDragY] = useState13(0);
|
|
5137
5163
|
const [isDraggingX, setIsDraggingX] = useState13(false);
|
|
5138
5164
|
const [isDraggingY, setIsDraggingY] = useState13(false);
|
|
5139
|
-
const touchStateRef =
|
|
5165
|
+
const touchStateRef = useRef11(null);
|
|
5140
5166
|
const [internalIndex, setInternalIndex] = useState13(
|
|
5141
5167
|
() => Math.max(
|
|
5142
5168
|
0,
|
|
5143
5169
|
items.findIndex((item) => item.id === activeId)
|
|
5144
5170
|
)
|
|
5145
5171
|
);
|
|
5146
|
-
const prevActiveIdRef =
|
|
5172
|
+
const prevActiveIdRef = useRef11(activeId);
|
|
5147
5173
|
const [timingWaiting, setTimingWaiting] = useState13(true);
|
|
5148
5174
|
useEffect12(() => {
|
|
5149
5175
|
const timer = setTimeout(() => {
|