@flapsdk/vault-runtime 0.1.40-next.2 → 0.1.40-next.4
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/README.md +2 -2
- package/{chunk-2K4HG2TC.js → chunk-5DU4W4CK.js} +417 -58
- package/chunk-5DU4W4CK.js.map +1 -0
- package/{chunk-WTLF4JPJ.js → chunk-FNM6KION.js} +3 -3
- package/{chunk-WTLF4JPJ.js.map → chunk-FNM6KION.js.map} +1 -1
- package/host-client.js +2 -2
- package/{maplibre-gl-5HQYASCY.js → maplibre-gl-KTPWJHIW.js} +3 -3
- package/maplibre-gl-KTPWJHIW.js.map +1 -0
- package/{mpegts-6MFVUHRP.js → mpegts-536UQHCG.js} +6 -6
- package/{mpegts-6MFVUHRP.js.map → mpegts-536UQHCG.js.map} +1 -1
- package/package.json +2 -2
- package/runtime-contract.json +3 -2
- package/sdk.js +4 -4
- package/ui.d.mts +49 -5
- package/ui.js +1 -1
- package/chunk-2K4HG2TC.js.map +0 -1
- package/maplibre-gl-5HQYASCY.js.map +0 -1
|
@@ -2,7 +2,7 @@ import { shortenAddress, isValidAddress, ZERO_ADDRESS } from './chunk-B4WKI3EW.j
|
|
|
2
2
|
import { isIpfsImageCid, resolveIpfsImageUrls, getTaxVaultHostChainConfig, resolveIpfsImageUrl } from './chunk-GY7YY67I.js';
|
|
3
3
|
import * as React10 from 'react';
|
|
4
4
|
import { createContext, useContext, useState, useEffect, useMemo, createElement } from 'react';
|
|
5
|
-
import { Loader2, ExternalLink, AlertTriangle, CheckCircle2, Info, Check, AlertCircle, Copy, X, ShieldCheck, Play, Pause, VolumeX, Volume2, Maximize, SkipBack, ChevronLeft, ChevronRight, SkipForward } from 'lucide-react';
|
|
5
|
+
import { Loader2, ExternalLink, AlertTriangle, CheckCircle2, Info, Check, AlertCircle, Copy, X, ShieldCheck, Plus, Minus, Compass, Play, Pause, VolumeX, Volume2, Maximize, SkipBack, ChevronLeft, ChevronRight, SkipForward } from 'lucide-react';
|
|
6
6
|
import { jsx, jsxs, Fragment } from 'react/jsx-runtime';
|
|
7
7
|
import { clsx } from 'clsx';
|
|
8
8
|
import { twMerge } from 'tailwind-merge';
|
|
@@ -1656,7 +1656,7 @@ function ConsumerVideoSessionPlayer({ consumer, startClip = 0, label, fallback =
|
|
|
1656
1656
|
}, [reader, startClip]);
|
|
1657
1657
|
React10.useEffect(() => {
|
|
1658
1658
|
if (!videoRef.current) return;
|
|
1659
|
-
const controller = new VideoSessionController(videoRef.current, async () => (await import('./mpegts-
|
|
1659
|
+
const controller = new VideoSessionController(videoRef.current, async () => (await import('./mpegts-536UQHCG.js')).default, setMediaState);
|
|
1660
1660
|
controllerRef.current = controller;
|
|
1661
1661
|
return () => {
|
|
1662
1662
|
controller.dispose();
|
|
@@ -1916,7 +1916,7 @@ function VideoSessionPlayer(props) {
|
|
|
1916
1916
|
return "consumer" in props && props.consumer !== void 0 ? /* @__PURE__ */ jsx(ConsumerVideoSessionPlayer, { ...props }) : /* @__PURE__ */ jsx(VideoClipSessionPlayer, { ...props });
|
|
1917
1917
|
}
|
|
1918
1918
|
async function loadMpegts() {
|
|
1919
|
-
return (await import('./mpegts-
|
|
1919
|
+
return (await import('./mpegts-536UQHCG.js')).default;
|
|
1920
1920
|
}
|
|
1921
1921
|
function VideoClipSessionPlayer({ clips, label, fallback = null, className, autoPlay = false, muted = false }) {
|
|
1922
1922
|
const videoRef = React10.useRef(null);
|
|
@@ -1958,6 +1958,14 @@ function VideoClipSessionPlayer({ clips, label, fallback = null, className, auto
|
|
|
1958
1958
|
var STREET_MAP_WORKER_PATH = "/runtime-map/maplibre-6.15.0-worker.mjs";
|
|
1959
1959
|
var STREET_MAP_STYLE = "https://tiles.openfreemap.org/styles/dark";
|
|
1960
1960
|
var STREET_MAP_MAX_POINTS = 2e3;
|
|
1961
|
+
var STREET_MAP_MAX_RADIUS_METERS = 1e5;
|
|
1962
|
+
var STREET_MAP_RARITY_COLORS = Object.freeze({
|
|
1963
|
+
common: "#22c55e",
|
|
1964
|
+
rare: "#3b82f6",
|
|
1965
|
+
epic: "#a855f7",
|
|
1966
|
+
legendary: "#fbbf24"
|
|
1967
|
+
});
|
|
1968
|
+
var STREET_MAP_INACTIVE_COLOR = "#6b7280";
|
|
1961
1969
|
function validStreetMapCoordinate(value) {
|
|
1962
1970
|
if (!value || typeof value !== "object") return false;
|
|
1963
1971
|
const coordinate = value;
|
|
@@ -1970,10 +1978,23 @@ function validStreetMapPoints(value) {
|
|
|
1970
1978
|
if (!validStreetMapCoordinate(point)) return false;
|
|
1971
1979
|
const item = point;
|
|
1972
1980
|
if (typeof item.id !== "string" || !item.id.length || item.id.length > 128 || ids.has(item.id) || typeof item.title !== "string" || item.title.length > 256 || item.rarity !== void 0 && !["common", "rare", "epic", "legendary"].includes(item.rarity)) return false;
|
|
1981
|
+
if (!optionalText(item.symbol, 32) || !optionalText(item.place, 160) || !optionalText(item.city, 80)) return false;
|
|
1982
|
+
if (item.amount !== void 0 && !(typeof item.amount === "string" ? item.amount.length <= 128 && !/[\u0000-\u001f\u007f]/.test(item.amount) : typeof item.amount === "number" && Number.isFinite(item.amount) && item.amount >= 0 && item.amount <= Number.MAX_SAFE_INTEGER)) return false;
|
|
1983
|
+
if (!optionalTimestamp(item.expiresAt) || !optionalTimestamp(item.respawnAt)) return false;
|
|
1984
|
+
if (item.kind !== void 0 && item.kind !== "store" && item.kind !== "event") return false;
|
|
1973
1985
|
ids.add(item.id);
|
|
1974
1986
|
}
|
|
1975
1987
|
return true;
|
|
1976
1988
|
}
|
|
1989
|
+
function optionalText(value, length) {
|
|
1990
|
+
return value === void 0 || typeof value === "string" && value.length <= length && !/[\u0000-\u001f\u007f]/.test(value);
|
|
1991
|
+
}
|
|
1992
|
+
function optionalTimestamp(value) {
|
|
1993
|
+
return value === void 0 || typeof value === "number" && Number.isSafeInteger(value) && value >= 0 && value <= 864e13;
|
|
1994
|
+
}
|
|
1995
|
+
function validStreetMapRadius(value) {
|
|
1996
|
+
return typeof value === "number" && Number.isFinite(value) && value >= 0 && value <= STREET_MAP_MAX_RADIUS_METERS;
|
|
1997
|
+
}
|
|
1977
1998
|
function streetMapZoom(value) {
|
|
1978
1999
|
return value === void 0 ? 12 : Math.min(18, Math.max(3, value));
|
|
1979
2000
|
}
|
|
@@ -1986,62 +2007,264 @@ function streetMapRequest(url) {
|
|
|
1986
2007
|
if (!allowed) throw new Error("street-map/resource-blocked");
|
|
1987
2008
|
return { url: parsed.href, credentials: "omit", referrerPolicy: "no-referrer" };
|
|
1988
2009
|
}
|
|
1989
|
-
function
|
|
1990
|
-
|
|
2010
|
+
function streetMapPointState(point, nowMs = Date.now()) {
|
|
2011
|
+
const cooldownRemainingMs = Math.max(0, (point.respawnAt ?? nowMs) - nowMs);
|
|
2012
|
+
const eventRemainingMs = point.expiresAt === void 0 ? null : Math.max(0, point.expiresAt - nowMs);
|
|
2013
|
+
return { coolingDown: cooldownRemainingMs > 0, expired: eventRemainingMs === 0, cooldownRemainingMs, eventRemainingMs };
|
|
2014
|
+
}
|
|
2015
|
+
function streetMapPointLabel(point) {
|
|
2016
|
+
const symbol = point.symbol?.trim(), place = point.place?.trim();
|
|
2017
|
+
return symbol && place ? `${symbol} \xB7 ${place}` : place || symbol || point.title;
|
|
2018
|
+
}
|
|
2019
|
+
function streetMapPointData(points, { nowMs = Date.now(), selectedPointId } = {}) {
|
|
2020
|
+
return { type: "FeatureCollection", features: points.map((point) => {
|
|
2021
|
+
const rarity = point.rarity ?? "common";
|
|
2022
|
+
const state = streetMapPointState(point, nowMs);
|
|
2023
|
+
const city = point.city?.trim() ?? "";
|
|
2024
|
+
return {
|
|
2025
|
+
type: "Feature",
|
|
2026
|
+
geometry: { type: "Point", coordinates: [point.lng, point.lat] },
|
|
2027
|
+
// Fixed text-field/paint properties only. Labels are literal text, never
|
|
2028
|
+
// HTML. Business payloads, style expressions and resources stay outside.
|
|
2029
|
+
properties: { id: point.id, rarity, color: state.coolingDown || state.expired ? STREET_MAP_INACTIVE_COLOR : STREET_MAP_RARITY_COLORS[rarity], kind: point.kind ?? "store", city, hasCity: city.length > 0, label: streetMapPointLabel(point), coolingDown: state.coolingDown, expired: state.expired, selected: selectedPointId === point.id }
|
|
2030
|
+
};
|
|
2031
|
+
}) };
|
|
2032
|
+
}
|
|
2033
|
+
function streetMapCityData(points) {
|
|
2034
|
+
const cities = /* @__PURE__ */ new Map();
|
|
2035
|
+
for (const point of points) {
|
|
2036
|
+
const city = point.city?.trim();
|
|
2037
|
+
if (!city || point.kind === "event") continue;
|
|
2038
|
+
const group = cities.get(city) ?? { lat: 0, sin: 0, cos: 0, count: 0 };
|
|
2039
|
+
group.lat += point.lat;
|
|
2040
|
+
group.sin += Math.sin(point.lng * Math.PI / 180);
|
|
2041
|
+
group.cos += Math.cos(point.lng * Math.PI / 180);
|
|
2042
|
+
group.count += 1;
|
|
2043
|
+
cities.set(city, group);
|
|
2044
|
+
}
|
|
2045
|
+
return { type: "FeatureCollection", features: Array.from(cities, ([city, group]) => ({
|
|
1991
2046
|
type: "Feature",
|
|
1992
|
-
geometry: { type: "Point", coordinates: [
|
|
1993
|
-
|
|
1994
|
-
properties: { id: point.id, rarity: point.rarity ?? "common" }
|
|
2047
|
+
geometry: { type: "Point", coordinates: [Math.atan2(group.sin, group.cos) * 180 / Math.PI, group.lat / group.count] },
|
|
2048
|
+
properties: { city, count: group.count }
|
|
1995
2049
|
})) };
|
|
1996
2050
|
}
|
|
1997
2051
|
function streetMapLocationData(location) {
|
|
1998
2052
|
return { type: "FeatureCollection", features: location ? [{ type: "Feature", geometry: { type: "Point", coordinates: [location.lng, location.lat] }, properties: {} }] : [] };
|
|
1999
2053
|
}
|
|
2054
|
+
var EARTH_RADIUS_METERS = 63710088e-1;
|
|
2055
|
+
var MERCATOR_LATITUDE_LIMIT = 85.051129;
|
|
2056
|
+
function clipRing(input, axis, limit, keepGreater) {
|
|
2057
|
+
const result = [];
|
|
2058
|
+
let previous = input[input.length - 1];
|
|
2059
|
+
if (!previous) return result;
|
|
2060
|
+
let previousInside = keepGreater ? previous[axis] >= limit : previous[axis] <= limit;
|
|
2061
|
+
for (const current of input) {
|
|
2062
|
+
const inside = keepGreater ? current[axis] >= limit : current[axis] <= limit;
|
|
2063
|
+
if (inside !== previousInside) {
|
|
2064
|
+
const ratio = (limit - previous[axis]) / (current[axis] - previous[axis]);
|
|
2065
|
+
const intersection = [previous[0] + ratio * (current[0] - previous[0]), previous[1] + ratio * (current[1] - previous[1])];
|
|
2066
|
+
intersection[axis] = limit;
|
|
2067
|
+
result.push(intersection);
|
|
2068
|
+
}
|
|
2069
|
+
if (inside) result.push(current);
|
|
2070
|
+
previous = current;
|
|
2071
|
+
previousInside = inside;
|
|
2072
|
+
}
|
|
2073
|
+
return result;
|
|
2074
|
+
}
|
|
2075
|
+
function streetMapRadiusData(location, radiusMeters) {
|
|
2076
|
+
const features = [];
|
|
2077
|
+
if (!validStreetMapCoordinate(location) || !validStreetMapRadius(radiusMeters) || radiusMeters === 0) return { type: "FeatureCollection", features };
|
|
2078
|
+
const latitude = location.lat * Math.PI / 180, longitude = location.lng * Math.PI / 180;
|
|
2079
|
+
const angularRadius = radiusMeters / EARTH_RADIUS_METERS;
|
|
2080
|
+
const ring = [];
|
|
2081
|
+
for (let index = 0; index < 64; index += 1) {
|
|
2082
|
+
const bearing = -index * 2 * Math.PI / 64;
|
|
2083
|
+
const lat = Math.asin(Math.sin(latitude) * Math.cos(angularRadius) + Math.cos(latitude) * Math.sin(angularRadius) * Math.cos(bearing));
|
|
2084
|
+
const lng = longitude + Math.atan2(Math.sin(bearing) * Math.sin(angularRadius) * Math.cos(latitude), Math.cos(angularRadius) - Math.sin(latitude) * Math.sin(lat));
|
|
2085
|
+
ring.push([lng * 180 / Math.PI, lat * 180 / Math.PI]);
|
|
2086
|
+
}
|
|
2087
|
+
const polygons = [];
|
|
2088
|
+
for (const shift of [-360, 0, 360]) {
|
|
2089
|
+
let clipped = ring.map(([lng, lat]) => [lng + shift, lat]);
|
|
2090
|
+
clipped = clipRing(clipRing(clipped, 0, -180, true), 0, 180, false);
|
|
2091
|
+
clipped = clipRing(clipRing(clipped, 1, -MERCATOR_LATITUDE_LIMIT, true), 1, MERCATOR_LATITUDE_LIMIT, false);
|
|
2092
|
+
if (clipped.length >= 3) polygons.push([[...clipped, [...clipped[0]]]]);
|
|
2093
|
+
}
|
|
2094
|
+
if (polygons.length) features.push({ type: "Feature", geometry: polygons.length === 1 ? { type: "Polygon", coordinates: polygons[0] } : { type: "MultiPolygon", coordinates: polygons }, properties: { radiusMeters } });
|
|
2095
|
+
return { type: "FeatureCollection", features };
|
|
2096
|
+
}
|
|
2097
|
+
function streetMapDistanceMeters(a, b) {
|
|
2098
|
+
if (!validStreetMapCoordinate(a) || !validStreetMapCoordinate(b)) return null;
|
|
2099
|
+
const latA = a.lat * Math.PI / 180, latB = b.lat * Math.PI / 180;
|
|
2100
|
+
const deltaLat = latB - latA, deltaLng = (b.lng - a.lng) * Math.PI / 180;
|
|
2101
|
+
const haversine = Math.sin(deltaLat / 2) ** 2 + Math.cos(latA) * Math.cos(latB) * Math.sin(deltaLng / 2) ** 2;
|
|
2102
|
+
return 2 * EARTH_RADIUS_METERS * Math.asin(Math.sqrt(Math.max(0, Math.min(1, haversine))));
|
|
2103
|
+
}
|
|
2104
|
+
var STREET_MAP_PRESENTATION_V1 = 1;
|
|
2000
2105
|
var EMPTY_POINTS = [];
|
|
2001
2106
|
var DEFAULT_CENTER = { lat: 31.2304, lng: 121.4737 };
|
|
2002
|
-
var
|
|
2003
|
-
|
|
2107
|
+
var FONT = ["Noto Sans Regular", "Noto Sans CJK SC Regular"];
|
|
2108
|
+
var RARITIES = ["common", "rare", "epic", "legendary"];
|
|
2109
|
+
var LABEL_KEYS = ["zoomIn", "zoomOut", "resetBearing", "closeDetails"];
|
|
2110
|
+
var MAP_CSS = `
|
|
2111
|
+
.flap-street-map{position:relative;width:100%;min-height:400px;background:#070808;color:#f9fafb;overflow:hidden}
|
|
2112
|
+
.flap-street-map__canvas{position:absolute;inset:0}.flap-street-map .maplibregl-canvas{position:absolute;left:0;top:0}.flap-street-map .maplibregl-canvas-container{position:absolute;inset:0}
|
|
2113
|
+
.flap-street-map .maplibregl-interactive{cursor:grab;user-select:none;-webkit-user-select:none;touch-action:none}.flap-street-map .maplibregl-interactive:active{cursor:grabbing}
|
|
2114
|
+
.flap-street-map__fallback{position:relative;padding:16px}.flap-street-map__fallback button{display:block;text-align:left;color:inherit}
|
|
2115
|
+
.flap-street-map__attribution{position:absolute;bottom:0;right:0;z-index:2;padding:2px 5px;background:#070808;color:#9ca3af;font:10px/1.5 sans-serif}.flap-street-map__attribution a{color:inherit;text-decoration:underline}
|
|
2116
|
+
.flap-street-map__navigation{position:absolute;right:8px;top:8px;z-index:2;display:flex;flex-direction:column;border:1px solid #374151;border-radius:8px;background:#070808;overflow:hidden}
|
|
2117
|
+
.flap-street-map__navigation button,.flap-street-map__close{display:flex;align-items:center;justify-content:center;min-width:40px;min-height:40px;color:inherit;background:transparent;border:0;cursor:pointer}.flap-street-map__navigation button+button{border-top:1px solid #374151}
|
|
2118
|
+
.flap-street-map__navigation button:focus-visible,.flap-street-map__close:focus-visible{outline:2px solid #f9fafb;outline-offset:-3px}
|
|
2119
|
+
.flap-street-map__details{position:absolute;z-index:3;bottom:48px;left:8px;right:8px;max-height:55%;overflow:auto;border:1px solid #374151;border-radius:8px;background:#070808;padding:16px 48px 16px 16px;box-shadow:0 4px 12px #0003}
|
|
2120
|
+
.flap-street-map__close{position:absolute;right:0;top:0}.flap-street-map[data-map-state=unavailable] .flap-street-map__details{position:relative;inset:auto;margin:8px;max-height:none}
|
|
2121
|
+
.flap-street-map .maplibregl-ctrl-bottom-left{position:absolute;left:8px;bottom:18px;pointer-events:none}.flap-street-map .maplibregl-ctrl-scale{box-sizing:border-box;padding:0 4px;border:2px solid #f9fafb;border-top:0;background:#070808;color:inherit;text-align:center;font:11px/16px sans-serif}
|
|
2122
|
+
.flap-street-map .maplibregl-marker{position:absolute;top:0;left:0;will-change:transform}.flap-street-map__user-location{width:14px;height:14px;border:2px solid #fff;border-radius:50%;background:#38bdf8;pointer-events:none}
|
|
2123
|
+
.flap-street-map__user-location:after{content:"";position:absolute;inset:-6px;border:2px solid #38bdf8;border-radius:50%;animation:flap-location-pulse 2s ease-out infinite}
|
|
2124
|
+
@keyframes flap-location-pulse{from{transform:scale(.7);opacity:.8}to{transform:scale(1.8);opacity:0}}@media(prefers-reduced-motion:reduce){.flap-street-map__user-location:after{animation:none;opacity:.3}}
|
|
2125
|
+
`;
|
|
2126
|
+
function validOptions(colors, labels2) {
|
|
2127
|
+
return (colors === void 0 || !!colors && typeof colors === "object" && !Array.isArray(colors) && Object.entries(colors).every(([key, value]) => RARITIES.includes(key) && typeof value === "string" && /^#[0-9a-f]{6}$/i.test(value))) && (labels2 === void 0 || !!labels2 && typeof labels2 === "object" && !Array.isArray(labels2) && Object.entries(labels2).every(([key, value]) => LABEL_KEYS.includes(key) && typeof value === "string" && value.length > 0 && value.length <= 128));
|
|
2128
|
+
}
|
|
2129
|
+
function countdown(ms) {
|
|
2130
|
+
const seconds = Math.max(0, Math.ceil(ms / 1e3));
|
|
2131
|
+
return `${Math.floor(seconds / 3600).toString().padStart(2, "0")}:${Math.floor(seconds / 60 % 60).toString().padStart(2, "0")}:${(seconds % 60).toString().padStart(2, "0")}`;
|
|
2132
|
+
}
|
|
2133
|
+
function eventData(points, nowMs, selectedPointId, showCountdowns) {
|
|
2134
|
+
const events = points.filter((point) => point.kind === "event");
|
|
2135
|
+
const data = streetMapPointData(events, { nowMs, selectedPointId });
|
|
2136
|
+
return { ...data, features: data.features.map((feature, index) => {
|
|
2137
|
+
const remaining = streetMapPointState(events[index], nowMs).eventRemainingMs;
|
|
2138
|
+
return { ...feature, properties: { ...feature.properties, eventLabel: `${feature.properties.label}${showCountdowns && remaining !== null ? `
|
|
2139
|
+
${countdown(remaining)}` : ""}` } };
|
|
2140
|
+
}) };
|
|
2141
|
+
}
|
|
2142
|
+
function FlapStreetMap({
|
|
2143
|
+
points = EMPTY_POINTS,
|
|
2144
|
+
center,
|
|
2145
|
+
userLocation,
|
|
2146
|
+
zoom,
|
|
2147
|
+
selectedPointId,
|
|
2148
|
+
onSelectPoint,
|
|
2149
|
+
onSelectionChange,
|
|
2150
|
+
renderPointDetails,
|
|
2151
|
+
claimRadiusMeters,
|
|
2152
|
+
cityClusters = true,
|
|
2153
|
+
showPointLabels = true,
|
|
2154
|
+
showEventCountdowns = true,
|
|
2155
|
+
showNavigation = false,
|
|
2156
|
+
showScale = false,
|
|
2157
|
+
rarityColors,
|
|
2158
|
+
controlLabels,
|
|
2159
|
+
onStateChange,
|
|
2160
|
+
fallback,
|
|
2161
|
+
className
|
|
2162
|
+
}) {
|
|
2004
2163
|
const vault = React10.useContext(RuntimeContext), app = React10.useContext(MiniAppContext);
|
|
2005
2164
|
const declared = (app ?? vault)?.context.manifest.mapCapabilities?.includes("street-map-v1") === true;
|
|
2006
|
-
const valid = validStreetMapPoints(points) && (center === void 0 || validStreetMapCoordinate(center)) && (userLocation == null || validStreetMapCoordinate(userLocation)) && (zoom === void 0 || Number.isFinite(zoom));
|
|
2165
|
+
const valid = validStreetMapPoints(points) && (center === void 0 || validStreetMapCoordinate(center)) && (userLocation == null || validStreetMapCoordinate(userLocation)) && (zoom === void 0 || Number.isFinite(zoom)) && (claimRadiusMeters === void 0 || validStreetMapRadius(claimRadiusMeters)) && (selectedPointId == null || typeof selectedPointId === "string" && selectedPointId.length <= 128) && [cityClusters, showPointLabels, showEventCountdowns, showNavigation, showScale].every((value) => typeof value === "boolean") && validOptions(rarityColors, controlLabels);
|
|
2166
|
+
const [internalSelection, setInternalSelection] = React10.useState(null);
|
|
2167
|
+
const selectedId = selectedPointId === void 0 ? internalSelection : selectedPointId;
|
|
2168
|
+
const selectedPoint = valid ? points.find((point) => point.id === selectedId) ?? null : null;
|
|
2169
|
+
const previousSelection = React10.useRef(null);
|
|
2170
|
+
const [nowMs, setNowMs] = React10.useState(Date.now);
|
|
2171
|
+
const [state, setState] = React10.useState({ status: "loading" });
|
|
2007
2172
|
const containerRef = React10.useRef(null);
|
|
2008
2173
|
const mapRef = React10.useRef(null);
|
|
2174
|
+
const markerRef = React10.useRef(null);
|
|
2175
|
+
const scaleRef = React10.useRef(null);
|
|
2009
2176
|
const failRef = React10.useRef(null);
|
|
2010
|
-
const
|
|
2011
|
-
latest
|
|
2012
|
-
|
|
2177
|
+
const refreshRef = React10.useRef(null);
|
|
2178
|
+
const latest = React10.useRef({ points, center, userLocation, zoom, selectedId, selectedPointId, onSelectPoint, onSelectionChange, onStateChange, nowMs, claimRadiusMeters, cityClusters, showPointLabels, showEventCountdowns, showScale, rarityColors });
|
|
2179
|
+
latest.current = { points, center, userLocation, zoom, selectedId, selectedPointId, onSelectPoint, onSelectionChange, onStateChange, nowMs, claimRadiusMeters, cityClusters, showPointLabels, showEventCountdowns, showScale, rarityColors };
|
|
2180
|
+
const select = React10.useCallback((id) => {
|
|
2181
|
+
const current = latest.current;
|
|
2182
|
+
const point = id === null ? null : current.points.find((item) => item.id === id) ?? null;
|
|
2183
|
+
if (id !== null && !point) return;
|
|
2184
|
+
if (current.selectedPointId === void 0) setInternalSelection(point?.id ?? null);
|
|
2185
|
+
setNowMs(Date.now());
|
|
2186
|
+
try {
|
|
2187
|
+
if (point) current.onSelectPoint?.(point.id);
|
|
2188
|
+
current.onSelectionChange?.(point);
|
|
2189
|
+
} catch {
|
|
2190
|
+
console.error("FlapStreetMap selection callback failed.");
|
|
2191
|
+
}
|
|
2192
|
+
}, []);
|
|
2013
2193
|
React10.useEffect(() => {
|
|
2194
|
+
if (!valid) return;
|
|
2195
|
+
if (selectedId && previousSelection.current === selectedId && !points.some((point) => point.id === selectedId)) {
|
|
2196
|
+
if (latest.current.selectedPointId === void 0) setInternalSelection(null);
|
|
2197
|
+
try {
|
|
2198
|
+
latest.current.onSelectionChange?.(null);
|
|
2199
|
+
} catch {
|
|
2200
|
+
console.error("FlapStreetMap selection callback failed.");
|
|
2201
|
+
}
|
|
2202
|
+
}
|
|
2203
|
+
previousSelection.current = points.some((point) => point.id === selectedId) ? selectedId ?? null : null;
|
|
2204
|
+
}, [points, selectedId, valid]);
|
|
2205
|
+
React10.useEffect(() => {
|
|
2206
|
+
if (!declared || !valid) return;
|
|
2207
|
+
let timer;
|
|
2014
2208
|
let disposed = false;
|
|
2015
|
-
|
|
2209
|
+
const tick = () => {
|
|
2210
|
+
if (timer) clearTimeout(timer);
|
|
2211
|
+
if (disposed || document.visibilityState === "hidden") return;
|
|
2212
|
+
const now = Date.now();
|
|
2213
|
+
setNowMs(now);
|
|
2214
|
+
const deadlines = points.flatMap((point) => [point.respawnAt, point.expiresAt]).filter((time) => typeof time === "number" && time > now);
|
|
2215
|
+
if (deadlines.length) timer = setTimeout(tick, Math.max(16, Math.min(1e3, Math.min(...deadlines) - now + 1)));
|
|
2216
|
+
};
|
|
2217
|
+
const visibility = () => {
|
|
2218
|
+
if (timer) clearTimeout(timer);
|
|
2219
|
+
if (document.visibilityState !== "hidden") tick();
|
|
2220
|
+
};
|
|
2221
|
+
tick();
|
|
2222
|
+
document.addEventListener("visibilitychange", visibility);
|
|
2223
|
+
return () => {
|
|
2224
|
+
disposed = true;
|
|
2225
|
+
if (timer) clearTimeout(timer);
|
|
2226
|
+
document.removeEventListener("visibilitychange", visibility);
|
|
2227
|
+
};
|
|
2228
|
+
}, [declared, valid, points]);
|
|
2229
|
+
const temporalStateKey = valid ? points.map((point) => `${point.respawnAt !== void 0 && point.respawnAt > nowMs ? 1 : 0}${point.expiresAt !== void 0 && point.expiresAt <= nowMs ? 1 : 0}`).join("") : "";
|
|
2230
|
+
React10.useEffect(() => {
|
|
2231
|
+
let disposed = false, failed = false;
|
|
2016
2232
|
let map = null;
|
|
2017
2233
|
let resize;
|
|
2018
2234
|
let timeout;
|
|
2019
2235
|
let canvas;
|
|
2236
|
+
let layerKey = "", paletteKey = "", locationKey = "";
|
|
2020
2237
|
const emit = (next) => {
|
|
2021
|
-
if (disposed)
|
|
2022
|
-
|
|
2023
|
-
|
|
2024
|
-
|
|
2025
|
-
|
|
2026
|
-
|
|
2238
|
+
if (!disposed) {
|
|
2239
|
+
setState(next);
|
|
2240
|
+
try {
|
|
2241
|
+
latest.current.onStateChange?.(next);
|
|
2242
|
+
} catch {
|
|
2243
|
+
console.error("FlapStreetMap onStateChange failed.");
|
|
2244
|
+
}
|
|
2027
2245
|
}
|
|
2028
2246
|
};
|
|
2029
2247
|
const cleanMap = () => {
|
|
2030
2248
|
if (timeout) clearTimeout(timeout);
|
|
2031
2249
|
resize?.disconnect();
|
|
2032
2250
|
canvas?.removeEventListener("webglcontextlost", contextLost);
|
|
2251
|
+
markerRef.current?.remove();
|
|
2252
|
+
markerRef.current = null;
|
|
2253
|
+
scaleRef.current = null;
|
|
2033
2254
|
if (map) {
|
|
2034
2255
|
const previous = map;
|
|
2035
2256
|
map = null;
|
|
2036
2257
|
if (mapRef.current === previous) mapRef.current = null;
|
|
2037
2258
|
previous.remove();
|
|
2038
2259
|
}
|
|
2260
|
+
refreshRef.current = null;
|
|
2039
2261
|
};
|
|
2040
2262
|
const fail = (reason) => {
|
|
2041
|
-
if (disposed
|
|
2042
|
-
|
|
2043
|
-
|
|
2044
|
-
|
|
2263
|
+
if (!disposed && !failed) {
|
|
2264
|
+
failed = true;
|
|
2265
|
+
cleanMap();
|
|
2266
|
+
emit({ status: "unavailable", reason });
|
|
2267
|
+
}
|
|
2045
2268
|
};
|
|
2046
2269
|
const contextLost = () => fail("context-lost");
|
|
2047
2270
|
failRef.current = fail;
|
|
@@ -2066,50 +2289,123 @@ function FlapStreetMap({ points = EMPTY_POINTS, center, userLocation, zoom, onSe
|
|
|
2066
2289
|
if (!supported || !mount) fail("unsupported");
|
|
2067
2290
|
else {
|
|
2068
2291
|
timeout = setTimeout(() => fail("timeout"), 15e3);
|
|
2069
|
-
void import('./maplibre-gl-
|
|
2070
|
-
if (disposed || failed ||
|
|
2292
|
+
void import('./maplibre-gl-KTPWJHIW.js').then((engine) => {
|
|
2293
|
+
if (disposed || failed || containerRef.current !== mount) return;
|
|
2071
2294
|
engine.setWorkerUrl(STREET_MAP_WORKER_PATH);
|
|
2072
2295
|
engine.setWorkerCount(2);
|
|
2073
|
-
const
|
|
2074
|
-
const initial = current.center ?? current.userLocation ?? DEFAULT_CENTER;
|
|
2296
|
+
const initial = latest.current.center ?? latest.current.userLocation ?? DEFAULT_CENTER;
|
|
2075
2297
|
map = new engine.Map({
|
|
2076
2298
|
container: mount,
|
|
2077
2299
|
style: STREET_MAP_STYLE,
|
|
2078
2300
|
center: [initial.lng, initial.lat],
|
|
2079
|
-
zoom: streetMapZoom(current.zoom),
|
|
2301
|
+
zoom: streetMapZoom(latest.current.zoom),
|
|
2080
2302
|
minZoom: 3,
|
|
2081
2303
|
maxZoom: 18,
|
|
2082
2304
|
attributionControl: false,
|
|
2083
2305
|
maxTileCacheSize: 128,
|
|
2084
|
-
// MapLibre forwards this to fetch. Its public type currently omits the
|
|
2085
|
-
// valid Fetch credentials="omit" value; no cookie/header is provided.
|
|
2086
2306
|
transformRequest: (url) => streetMapRequest(url)
|
|
2087
2307
|
});
|
|
2088
2308
|
mapRef.current = map;
|
|
2089
2309
|
canvas = map.getCanvas();
|
|
2090
2310
|
canvas.addEventListener("webglcontextlost", contextLost);
|
|
2091
2311
|
map.on("error", () => fail("load-failed"));
|
|
2312
|
+
const refresh = () => {
|
|
2313
|
+
if (!map || !map.getLayer("flap-cities-label")) return;
|
|
2314
|
+
const current = latest.current;
|
|
2315
|
+
const grouped = current.cityClusters && map.getZoom() <= 7.2;
|
|
2316
|
+
const labels2 = current.showPointLabels && map.getZoom() > 10.5;
|
|
2317
|
+
const nextLayers = `${grouped}:${labels2}`;
|
|
2318
|
+
if (nextLayers !== layerKey) {
|
|
2319
|
+
layerKey = nextLayers;
|
|
2320
|
+
const individual = grouped ? ["!=", ["get", "hasCity"], true] : ["literal", true];
|
|
2321
|
+
const active = ["all", ["!", ["get", "coolingDown"]], ["!", ["get", "expired"]]];
|
|
2322
|
+
map.setFilter("flap-points-core", individual);
|
|
2323
|
+
map.setFilter("flap-points-glow", ["all", individual, active]);
|
|
2324
|
+
map.setFilter("flap-points-selected", ["all", individual, ["==", ["get", "selected"], true]]);
|
|
2325
|
+
map.setFilter("flap-points-label", individual);
|
|
2326
|
+
for (const id of ["flap-cities-bubble", "flap-cities-label"]) map.setLayoutProperty(id, "visibility", grouped ? "visible" : "none");
|
|
2327
|
+
map.setLayoutProperty("flap-points-label", "visibility", labels2 ? "visible" : "none");
|
|
2328
|
+
}
|
|
2329
|
+
if (current.showScale && !scaleRef.current) {
|
|
2330
|
+
scaleRef.current = new engine.ScaleControl({ maxWidth: 100, unit: "metric" });
|
|
2331
|
+
map.addControl(scaleRef.current, "bottom-left");
|
|
2332
|
+
} else if (!current.showScale && scaleRef.current) {
|
|
2333
|
+
map.removeControl(scaleRef.current);
|
|
2334
|
+
scaleRef.current = null;
|
|
2335
|
+
}
|
|
2336
|
+
const colors = { ...STREET_MAP_RARITY_COLORS, ...current.rarityColors };
|
|
2337
|
+
const nextPalette = RARITIES.map((rarity) => colors[rarity]).join(":");
|
|
2338
|
+
if (nextPalette !== paletteKey) {
|
|
2339
|
+
paletteKey = nextPalette;
|
|
2340
|
+
const color = ["case", ["any", ["get", "coolingDown"], ["get", "expired"]], STREET_MAP_INACTIVE_COLOR, ["match", ["get", "rarity"], "rare", colors.rare, "epic", colors.epic, "legendary", colors.legendary, colors.common]];
|
|
2341
|
+
for (const id of ["flap-points-core", "flap-points-glow", "flap-events-core", "flap-events-glow"]) map.setPaintProperty(id, "circle-color", color);
|
|
2342
|
+
}
|
|
2343
|
+
const nextLocation = current.userLocation ? `${current.userLocation.lat}:${current.userLocation.lng}` : "none";
|
|
2344
|
+
if (nextLocation !== locationKey) {
|
|
2345
|
+
locationKey = nextLocation;
|
|
2346
|
+
if (current.userLocation) {
|
|
2347
|
+
if (!markerRef.current) {
|
|
2348
|
+
const element = document.createElement("span");
|
|
2349
|
+
element.className = "flap-street-map__user-location";
|
|
2350
|
+
element.setAttribute("aria-hidden", "true");
|
|
2351
|
+
markerRef.current = new engine.Marker({ element }).setLngLat([current.userLocation.lng, current.userLocation.lat]).addTo(map);
|
|
2352
|
+
} else markerRef.current.setLngLat([current.userLocation.lng, current.userLocation.lat]);
|
|
2353
|
+
} else {
|
|
2354
|
+
markerRef.current?.remove();
|
|
2355
|
+
markerRef.current = null;
|
|
2356
|
+
}
|
|
2357
|
+
}
|
|
2358
|
+
};
|
|
2359
|
+
refreshRef.current = refresh;
|
|
2360
|
+
map.on("zoom", () => {
|
|
2361
|
+
try {
|
|
2362
|
+
refresh();
|
|
2363
|
+
} catch {
|
|
2364
|
+
fail("load-failed");
|
|
2365
|
+
}
|
|
2366
|
+
});
|
|
2092
2367
|
map.on("load", () => {
|
|
2093
2368
|
if (disposed || failed || !map) return;
|
|
2094
2369
|
try {
|
|
2095
|
-
|
|
2096
|
-
|
|
2097
|
-
map.
|
|
2098
|
-
map.addSource("flap-
|
|
2099
|
-
map.
|
|
2100
|
-
map.
|
|
2101
|
-
|
|
2102
|
-
|
|
2103
|
-
|
|
2104
|
-
|
|
2105
|
-
|
|
2106
|
-
|
|
2107
|
-
|
|
2108
|
-
}
|
|
2370
|
+
const current = latest.current;
|
|
2371
|
+
const data = streetMapPointData(current.points, { nowMs: current.nowMs, selectedPointId: current.selectedId });
|
|
2372
|
+
map.addSource("flap-points", { type: "geojson", data: { ...data, features: data.features.filter((point) => point.properties.kind === "store") } });
|
|
2373
|
+
map.addSource("flap-events", { type: "geojson", data: eventData(current.points, current.nowMs, current.selectedId, current.showEventCountdowns) });
|
|
2374
|
+
map.addSource("flap-cities", { type: "geojson", data: streetMapCityData(current.points) });
|
|
2375
|
+
map.addSource("flap-location", { type: "geojson", data: streetMapLocationData(current.userLocation) });
|
|
2376
|
+
map.addSource("flap-location-range", { type: "geojson", data: streetMapRadiusData(current.userLocation, current.claimRadiusMeters) });
|
|
2377
|
+
map.addLayer({ id: "flap-location-range-fill", type: "fill", source: "flap-location-range", paint: { "fill-color": "#38bdf8", "fill-opacity": 0.1 } });
|
|
2378
|
+
map.addLayer({ id: "flap-location-range-outline", type: "line", source: "flap-location-range", paint: { "line-color": "#38bdf8", "line-width": 1.5, "line-opacity": 0.7 } });
|
|
2379
|
+
map.addLayer({ id: "flap-cities-bubble", type: "circle", source: "flap-cities", paint: { "circle-radius": ["step", ["get", "count"], 18, 10, 22, 50, 26], "circle-color": "#fbbf24", "circle-opacity": 0.9, "circle-stroke-color": "#070808", "circle-stroke-width": 2 } });
|
|
2380
|
+
map.addLayer({ id: "flap-cities-label", type: "symbol", source: "flap-cities", layout: { "text-field": ["concat", ["get", "city"], "\n", ["to-string", ["get", "count"]]], "text-font": FONT, "text-size": 11, "text-allow-overlap": true }, paint: { "text-color": "#070808" } });
|
|
2381
|
+
const active = ["all", ["!", ["get", "coolingDown"]], ["!", ["get", "expired"]]];
|
|
2382
|
+
for (const [source, radius] of [["flap-points", 6], ["flap-events", 9]]) {
|
|
2383
|
+
map.addLayer({ id: `${source}-glow`, type: "circle", source, filter: active, paint: { "circle-radius": radius + 8, "circle-color": ["get", "color"], "circle-opacity": 0.25, "circle-blur": 0.6 } });
|
|
2384
|
+
map.addLayer({ id: `${source}-core`, type: "circle", source, paint: { "circle-radius": radius, "circle-color": ["get", "color"], "circle-stroke-width": source === "flap-events" ? 2 : 1.5, "circle-stroke-color": source === "flap-events" ? "#ffffff" : "#000000" } });
|
|
2385
|
+
map.addLayer({ id: `${source}-selected`, type: "circle", source, filter: ["==", ["get", "selected"], true], paint: { "circle-radius": radius + 5, "circle-opacity": 0, "circle-stroke-width": 2, "circle-stroke-color": "#ffffff" } });
|
|
2386
|
+
map.addLayer({ id: `${source}-label`, type: "symbol", source, layout: { "text-field": ["get", source === "flap-events" ? "eventLabel" : "label"], "text-font": FONT, "text-size": 11, "text-offset": [0, 1.4], "text-anchor": "top", "text-max-width": 18 }, paint: { "text-color": "#f9fafb", "text-halo-color": "#070808", "text-halo-width": 2 } });
|
|
2387
|
+
}
|
|
2388
|
+
map.addLayer({ id: "flap-events-symbol", type: "symbol", source: "flap-events", layout: { "text-field": "\u2605", "text-font": FONT, "text-size": 12, "text-allow-overlap": true, "text-ignore-placement": true }, paint: { "text-color": "#ffffff" } });
|
|
2389
|
+
const interactiveLayers = ["flap-cities-bubble", "flap-points-core", "flap-events-core"];
|
|
2390
|
+
map.on("click", interactiveLayers, (event) => {
|
|
2391
|
+
const feature = event.features?.[0];
|
|
2392
|
+
if (!map || !feature) return;
|
|
2393
|
+
if (feature.layer.id === "flap-cities-bubble" && feature.geometry.type === "Point") {
|
|
2394
|
+
const [lng, lat] = feature.geometry.coordinates;
|
|
2395
|
+
if (validStreetMapCoordinate({ lat, lng })) map.flyTo({ center: [lng, lat], zoom: 12, duration: 600, essential: false });
|
|
2396
|
+
} else if (typeof feature.properties?.id === "string") select(feature.properties.id);
|
|
2397
|
+
});
|
|
2398
|
+
map.on("mouseenter", interactiveLayers, () => {
|
|
2399
|
+
if (map) map.getCanvas().style.cursor = "pointer";
|
|
2109
2400
|
});
|
|
2401
|
+
map.on("mouseleave", interactiveLayers, () => {
|
|
2402
|
+
if (map) map.getCanvas().style.cursor = "";
|
|
2403
|
+
});
|
|
2404
|
+
map.addLayer({ id: "flap-location-dot", type: "circle", source: "flap-location", paint: { "circle-radius": 0, "circle-opacity": 0 } });
|
|
2405
|
+
if (current.center) map.jumpTo({ center: [current.center.lng, current.center.lat], zoom: streetMapZoom(current.zoom) });
|
|
2406
|
+
else if (current.zoom !== void 0) map.setZoom(streetMapZoom(current.zoom));
|
|
2407
|
+
refresh();
|
|
2110
2408
|
if (timeout) clearTimeout(timeout);
|
|
2111
|
-
if (latest.current.center) map.jumpTo({ center: [latest.current.center.lng, latest.current.center.lat], zoom: streetMapZoom(latest.current.zoom) });
|
|
2112
|
-
else if (latest.current.zoom !== void 0) map.setZoom(streetMapZoom(latest.current.zoom));
|
|
2113
2409
|
emit({ status: "ready" });
|
|
2114
2410
|
} catch {
|
|
2115
2411
|
fail("load-failed");
|
|
@@ -2126,24 +2422,87 @@ function FlapStreetMap({ points = EMPTY_POINTS, center, userLocation, zoom, onSe
|
|
|
2126
2422
|
if (failRef.current === fail) failRef.current = null;
|
|
2127
2423
|
cleanMap();
|
|
2128
2424
|
};
|
|
2129
|
-
}, [declared, valid]);
|
|
2425
|
+
}, [declared, valid, select]);
|
|
2426
|
+
React10.useEffect(() => {
|
|
2427
|
+
const map = mapRef.current;
|
|
2428
|
+
if (!valid || !map?.getSource("flap-points")) return;
|
|
2429
|
+
try {
|
|
2430
|
+
const data = streetMapPointData(points, { nowMs: latest.current.nowMs, selectedPointId: selectedId });
|
|
2431
|
+
map.getSource("flap-points").setData({ ...data, features: data.features.filter((point) => point.properties.kind === "store") });
|
|
2432
|
+
map.getSource("flap-cities").setData(streetMapCityData(points));
|
|
2433
|
+
refreshRef.current?.();
|
|
2434
|
+
} catch {
|
|
2435
|
+
failRef.current?.("load-failed");
|
|
2436
|
+
}
|
|
2437
|
+
}, [points, selectedId, temporalStateKey, valid]);
|
|
2130
2438
|
React10.useEffect(() => {
|
|
2131
2439
|
const map = mapRef.current;
|
|
2132
|
-
if (!valid || !map
|
|
2440
|
+
if (!valid || !map?.getSource("flap-events")) return;
|
|
2133
2441
|
try {
|
|
2134
|
-
map.getSource("flap-
|
|
2135
|
-
|
|
2136
|
-
|
|
2442
|
+
map.getSource("flap-events").setData(eventData(points, nowMs, selectedId, showEventCountdowns));
|
|
2443
|
+
} catch {
|
|
2444
|
+
failRef.current?.("load-failed");
|
|
2445
|
+
}
|
|
2446
|
+
}, [points, selectedId, nowMs, showEventCountdowns, valid]);
|
|
2447
|
+
React10.useEffect(() => {
|
|
2448
|
+
const map = mapRef.current;
|
|
2449
|
+
if (!valid || !map?.getSource("flap-location")) return;
|
|
2450
|
+
try {
|
|
2451
|
+
map.getSource("flap-location").setData(streetMapLocationData(userLocation));
|
|
2452
|
+
map.getSource("flap-location-range").setData(streetMapRadiusData(userLocation, claimRadiusMeters));
|
|
2453
|
+
refreshRef.current?.();
|
|
2454
|
+
} catch {
|
|
2455
|
+
failRef.current?.("load-failed");
|
|
2456
|
+
}
|
|
2457
|
+
}, [userLocation, claimRadiusMeters, valid]);
|
|
2458
|
+
const centerLat = center?.lat, centerLng = center?.lng;
|
|
2459
|
+
React10.useEffect(() => {
|
|
2460
|
+
const map = mapRef.current;
|
|
2461
|
+
if (!valid || !map?.getSource("flap-points")) return;
|
|
2462
|
+
try {
|
|
2463
|
+
if (centerLat !== void 0 && centerLng !== void 0) map.jumpTo({ center: [centerLng, centerLat], ...zoom === void 0 ? {} : { zoom: streetMapZoom(zoom) } });
|
|
2137
2464
|
else if (zoom !== void 0) map.setZoom(streetMapZoom(zoom));
|
|
2138
2465
|
} catch {
|
|
2139
2466
|
failRef.current?.("load-failed");
|
|
2140
2467
|
}
|
|
2141
|
-
}, [
|
|
2468
|
+
}, [centerLat, centerLng, zoom, valid]);
|
|
2469
|
+
React10.useEffect(() => {
|
|
2470
|
+
try {
|
|
2471
|
+
refreshRef.current?.();
|
|
2472
|
+
} catch {
|
|
2473
|
+
failRef.current?.("load-failed");
|
|
2474
|
+
}
|
|
2475
|
+
}, [cityClusters, showPointLabels, showScale, rarityColors]);
|
|
2142
2476
|
const visibleState = !declared ? { status: "unavailable", reason: "not-declared" } : !valid ? { status: "unavailable", reason: "invalid-input" } : state;
|
|
2477
|
+
const distance = selectedPoint && userLocation ? streetMapDistanceMeters(userLocation, selectedPoint) : null;
|
|
2478
|
+
const details = selectedPoint && renderPointDetails && visibleState.status !== "loading" ? renderPointDetails(selectedPoint, {
|
|
2479
|
+
...streetMapPointState(selectedPoint, nowMs),
|
|
2480
|
+
nowMs,
|
|
2481
|
+
distanceMeters: distance,
|
|
2482
|
+
claimRadiusMeters: claimRadiusMeters ?? null,
|
|
2483
|
+
withinDisplayRadius: distance !== null && claimRadiusMeters !== void 0 ? distance <= claimRadiusMeters : null,
|
|
2484
|
+
close: () => select(null)
|
|
2485
|
+
}) : null;
|
|
2486
|
+
const navigate = (action) => {
|
|
2487
|
+
const map = mapRef.current;
|
|
2488
|
+
if (!map) return;
|
|
2489
|
+
if (action === "in") map.zoomIn();
|
|
2490
|
+
else if (action === "out") map.zoomOut();
|
|
2491
|
+
else map.resetNorth();
|
|
2492
|
+
};
|
|
2143
2493
|
return /* @__PURE__ */ jsxs("div", { className: ["flap-street-map", className].filter(Boolean).join(" "), "data-flap-ui": "street-map", "data-map-state": visibleState.status, "data-map-reason": visibleState.reason, children: [
|
|
2144
2494
|
/* @__PURE__ */ jsx("style", { children: MAP_CSS }),
|
|
2145
2495
|
/* @__PURE__ */ jsx("div", { ref: containerRef, className: "flap-street-map__canvas", "aria-hidden": visibleState.status !== "ready", style: { visibility: visibleState.status === "ready" ? "visible" : "hidden" } }),
|
|
2146
|
-
visibleState.status !== "ready" && /* @__PURE__ */ jsx("div", { className: "flap-street-map__fallback", children: fallback ?? (validStreetMapPoints(points) ? points.map((point) => /* @__PURE__ */ jsx("button", { type: "button", onClick: () =>
|
|
2496
|
+
visibleState.status !== "ready" && /* @__PURE__ */ jsx("div", { className: "flap-street-map__fallback", children: fallback ?? (validStreetMapPoints(points) ? points.map((point) => /* @__PURE__ */ jsx("button", { type: "button", onClick: () => select(point.id), children: point.title }, point.id)) : null) }),
|
|
2497
|
+
showNavigation && visibleState.status === "ready" && /* @__PURE__ */ jsxs("div", { className: "flap-street-map__navigation", children: [
|
|
2498
|
+
/* @__PURE__ */ jsx("button", { type: "button", "aria-label": controlLabels?.zoomIn ?? "Zoom in", onClick: () => navigate("in"), children: /* @__PURE__ */ jsx(Plus, { size: 18, "aria-hidden": "true" }) }),
|
|
2499
|
+
/* @__PURE__ */ jsx("button", { type: "button", "aria-label": controlLabels?.zoomOut ?? "Zoom out", onClick: () => navigate("out"), children: /* @__PURE__ */ jsx(Minus, { size: 18, "aria-hidden": "true" }) }),
|
|
2500
|
+
/* @__PURE__ */ jsx("button", { type: "button", "aria-label": controlLabels?.resetBearing ?? "Reset bearing", onClick: () => navigate("north"), children: /* @__PURE__ */ jsx(Compass, { size: 18, "aria-hidden": "true" }) })
|
|
2501
|
+
] }),
|
|
2502
|
+
details != null && /* @__PURE__ */ jsxs("div", { className: "flap-street-map__details", "data-map-selected": selectedPoint?.id, children: [
|
|
2503
|
+
/* @__PURE__ */ jsx("button", { type: "button", className: "flap-street-map__close", "aria-label": controlLabels?.closeDetails ?? "Close details", onClick: () => select(null), children: /* @__PURE__ */ jsx(X, { size: 18, "aria-hidden": "true" }) }),
|
|
2504
|
+
details
|
|
2505
|
+
] }),
|
|
2147
2506
|
/* @__PURE__ */ jsxs("div", { className: "flap-street-map__attribution", children: [
|
|
2148
2507
|
/* @__PURE__ */ jsx("a", { href: "https://openfreemap.org/", target: "_blank", rel: "noopener noreferrer", children: "OpenFreeMap" }),
|
|
2149
2508
|
" \xB7 ",
|
|
@@ -2154,6 +2513,6 @@ function FlapStreetMap({ points = EMPTY_POINTS, center, userLocation, zoom, onSe
|
|
|
2154
2513
|
] });
|
|
2155
2514
|
}
|
|
2156
2515
|
|
|
2157
|
-
export { AddressLink, Alert, BinanceImage, Button, Card, CardContent, CardDescription, CardHeader, CardTitle, CopyButton, Countdown, DataRow, DetailTile, ExternalLink2 as ExternalLink, FlapStreetMap, Input, IpfsBackground, IpfsImage, IpfsText, Metric, MiniAppContext, MiniAppRoutingContext, NftMetadataImage, ReviewedFrame, RuntimeContext, StatusBadge, TxButton, VaultBanner, VideoSessionPlayer, VideoSessionReadError, buttonVariants, createConsumerVideoSessionReader, readVideoSessionLength, readVideoSessionSlice, useFlapI18n, useFlapNotify, useFlapSdk, useVaultContext };
|
|
2158
|
-
//# sourceMappingURL=chunk-
|
|
2159
|
-
//# sourceMappingURL=chunk-
|
|
2516
|
+
export { AddressLink, Alert, BinanceImage, Button, Card, CardContent, CardDescription, CardHeader, CardTitle, CopyButton, Countdown, DataRow, DetailTile, ExternalLink2 as ExternalLink, FlapStreetMap, Input, IpfsBackground, IpfsImage, IpfsText, Metric, MiniAppContext, MiniAppRoutingContext, NftMetadataImage, ReviewedFrame, RuntimeContext, STREET_MAP_PRESENTATION_V1, StatusBadge, TxButton, VaultBanner, VideoSessionPlayer, VideoSessionReadError, buttonVariants, createConsumerVideoSessionReader, readVideoSessionLength, readVideoSessionSlice, useFlapI18n, useFlapNotify, useFlapSdk, useVaultContext };
|
|
2517
|
+
//# sourceMappingURL=chunk-5DU4W4CK.js.map
|
|
2518
|
+
//# sourceMappingURL=chunk-5DU4W4CK.js.map
|