@cloudparse/up-miniapps-sdk 0.6.8 → 0.7.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/README.md +12 -0
- package/dist/index.browser.min.js +104 -101
- package/dist/index.browser.min.js.map +1 -1
- package/dist/index.cjs +952 -988
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +62 -2
- package/dist/index.d.ts +62 -2
- package/dist/index.js +919 -954
- package/dist/index.js.map +1 -1
- package/dist/style.css +96 -18
- package/package.json +3 -1
package/dist/index.js
CHANGED
|
@@ -72,6 +72,58 @@ function isRunningInsideNativeShell() {
|
|
|
72
72
|
// src/bridge.ts
|
|
73
73
|
var BridgeTimeoutError = class extends Error {
|
|
74
74
|
};
|
|
75
|
+
var MOCK_ACHIEVEMENTS = [
|
|
76
|
+
{
|
|
77
|
+
completed: false,
|
|
78
|
+
description: "Discover 5 points of interest around Annecy.",
|
|
79
|
+
imageUrl: "https://api.dicebear.com/9.x/icons/svg?seed=explore",
|
|
80
|
+
playerActionCount: 3,
|
|
81
|
+
slug: "explore-5-pois",
|
|
82
|
+
title: "Explorer",
|
|
83
|
+
totalActionCount: 5,
|
|
84
|
+
upReward: 50,
|
|
85
|
+
xpReward: 100
|
|
86
|
+
},
|
|
87
|
+
{
|
|
88
|
+
completed: true,
|
|
89
|
+
description: "Complete your first navigation journey.",
|
|
90
|
+
imageUrl: "https://api.dicebear.com/9.x/icons/svg?seed=journey",
|
|
91
|
+
playerActionCount: 1,
|
|
92
|
+
slug: "first-journey",
|
|
93
|
+
title: "First Steps",
|
|
94
|
+
totalActionCount: 1,
|
|
95
|
+
upReward: 20,
|
|
96
|
+
xpReward: 40
|
|
97
|
+
},
|
|
98
|
+
{
|
|
99
|
+
completed: false,
|
|
100
|
+
description: "Scan 10 QR codes at partner venues.",
|
|
101
|
+
imageUrl: "https://api.dicebear.com/9.x/icons/svg?seed=scan",
|
|
102
|
+
playerActionCount: 4,
|
|
103
|
+
slug: "scan-10-qrcodes",
|
|
104
|
+
title: "Code Breaker",
|
|
105
|
+
totalActionCount: 10,
|
|
106
|
+
upReward: 80,
|
|
107
|
+
xpReward: 150
|
|
108
|
+
}
|
|
109
|
+
];
|
|
110
|
+
function mockAchievement(slug) {
|
|
111
|
+
const found = MOCK_ACHIEVEMENTS.find((a) => a.slug === slug);
|
|
112
|
+
if (found) return found;
|
|
113
|
+
return {
|
|
114
|
+
completed: false,
|
|
115
|
+
description: "Mocked achievement (no native shell attached).",
|
|
116
|
+
playerActionCount: 0,
|
|
117
|
+
slug: slug || "unknown-achievement",
|
|
118
|
+
title: slug || "Unknown Achievement",
|
|
119
|
+
totalActionCount: 1,
|
|
120
|
+
upReward: 0,
|
|
121
|
+
xpReward: 0
|
|
122
|
+
};
|
|
123
|
+
}
|
|
124
|
+
function mockAchievements() {
|
|
125
|
+
return MOCK_ACHIEVEMENTS;
|
|
126
|
+
}
|
|
75
127
|
var Bridge = class {
|
|
76
128
|
callbacks = /* @__PURE__ */ new Map();
|
|
77
129
|
eventListeners = /* @__PURE__ */ new Map();
|
|
@@ -222,6 +274,12 @@ var Bridge = class {
|
|
|
222
274
|
return this.mockSaveImage(
|
|
223
275
|
payload
|
|
224
276
|
);
|
|
277
|
+
case "GET_ACHIEVEMENT":
|
|
278
|
+
return Promise.resolve(
|
|
279
|
+
mockAchievement(payload?.slug)
|
|
280
|
+
);
|
|
281
|
+
case "GET_ACHIEVEMENTS":
|
|
282
|
+
return Promise.resolve(mockAchievements());
|
|
225
283
|
default:
|
|
226
284
|
console.warn(
|
|
227
285
|
`[Bridge] Mock mode active: Unhandled message type ${type}`
|
|
@@ -408,420 +466,29 @@ var SheetDescription = React2.forwardRef(({ className, ...props }, ref) => /* @_
|
|
|
408
466
|
SheetDescription.displayName = SheetPrimitive.Description.displayName;
|
|
409
467
|
|
|
410
468
|
// src/components/Map/components/MapDrawer.tsx
|
|
411
|
-
import {
|
|
412
|
-
forwardRef as forwardRef3,
|
|
413
|
-
useEffect,
|
|
414
|
-
useImperativeHandle,
|
|
415
|
-
useRef,
|
|
416
|
-
useState
|
|
417
|
-
} from "react";
|
|
469
|
+
import { forwardRef as forwardRef3, useImperativeHandle, useRef, useState } from "react";
|
|
418
470
|
import { Fragment, jsx as jsx3, jsxs as jsxs2 } from "react/jsx-runtime";
|
|
419
|
-
var resolveHeightToPixels = (height, containerHeight) => {
|
|
420
|
-
if (typeof height === "number") {
|
|
421
|
-
return height;
|
|
422
|
-
}
|
|
423
|
-
if (height.endsWith("%")) {
|
|
424
|
-
return parseFloat(height) / 100 * containerHeight;
|
|
425
|
-
}
|
|
426
|
-
return parseFloat(height);
|
|
427
|
-
};
|
|
428
|
-
var CONTENT_EDGE_PULL_THRESHOLD_PX = 24;
|
|
429
|
-
var HANDLE_BAR_HEIGHT_PX = 32;
|
|
430
|
-
var HANDLE_TAP_CLICK_SUPPRESSION_MS = 400;
|
|
431
471
|
var MapDrawer = forwardRef3(
|
|
432
472
|
({
|
|
433
473
|
menuItems,
|
|
434
474
|
state,
|
|
435
475
|
onChangeState,
|
|
436
|
-
side,
|
|
437
|
-
etaBarHeight = 0,
|
|
438
|
-
etaData,
|
|
439
|
-
touchStartY,
|
|
440
|
-
setTouchStartY,
|
|
441
|
-
currentTouchY,
|
|
442
|
-
setCurrentTouchY,
|
|
443
|
-
isDragging,
|
|
444
|
-
clampedDragOffset,
|
|
445
|
-
drawerPeekHeight,
|
|
446
|
-
drawerFullHeight,
|
|
447
|
-
drawerAutoMaxHeight,
|
|
448
|
-
containerHeight,
|
|
449
476
|
menuContent,
|
|
450
|
-
enableTouchDrag = false,
|
|
451
|
-
handleVisible = true,
|
|
452
|
-
onAutoContentHeightChange,
|
|
453
477
|
showScrollToTopButton = true,
|
|
454
|
-
scrollToTopThreshold = 300
|
|
455
|
-
safeAreaInsets = { bottom: 0, left: 0, right: 0, top: 0 }
|
|
478
|
+
scrollToTopThreshold = 300
|
|
456
479
|
}, ref) => {
|
|
457
480
|
const scrollContainerRef = useRef(null);
|
|
458
|
-
const containerRef = useRef(null);
|
|
459
|
-
const handleBarRef = useRef(null);
|
|
460
|
-
const contentAreaRef = useRef(null);
|
|
461
481
|
useImperativeHandle(
|
|
462
482
|
ref,
|
|
463
483
|
() => scrollContainerRef.current
|
|
464
484
|
);
|
|
465
|
-
const handleHandleClick = () => {
|
|
466
|
-
if (side === "left") {
|
|
467
|
-
onChangeState(state === "closed" ? "full" : "closed");
|
|
468
|
-
} else {
|
|
469
|
-
if (state === "closed") {
|
|
470
|
-
onChangeState("peek");
|
|
471
|
-
} else if (state === "peek") {
|
|
472
|
-
onChangeState("full");
|
|
473
|
-
} else if (state === "auto") {
|
|
474
|
-
onChangeState("closed");
|
|
475
|
-
} else {
|
|
476
|
-
onChangeState("peek");
|
|
477
|
-
}
|
|
478
|
-
}
|
|
479
|
-
};
|
|
480
|
-
const handleHandleClickRef = useRef(handleHandleClick);
|
|
481
|
-
handleHandleClickRef.current = handleHandleClick;
|
|
482
|
-
const [autoContentPx, setAutoContentPx] = useState(0);
|
|
483
|
-
useEffect(() => {
|
|
484
|
-
if (state !== "auto") return;
|
|
485
|
-
const scrollEl = scrollContainerRef.current;
|
|
486
|
-
const contentAreaEl = contentAreaRef.current;
|
|
487
|
-
if (!scrollEl || !contentAreaEl) return;
|
|
488
|
-
const handleHeight = handleVisible ? handleBarRef.current?.offsetHeight ?? 0 : 0;
|
|
489
|
-
const contentEl = scrollEl.firstElementChild;
|
|
490
|
-
const measure = () => {
|
|
491
|
-
const contentAreaStyle = window.getComputedStyle(contentAreaEl);
|
|
492
|
-
const verticalPadding = parseFloat(contentAreaStyle.paddingTop || "0") + parseFloat(contentAreaStyle.paddingBottom || "0");
|
|
493
|
-
const contentHeight = contentEl?.scrollHeight ?? scrollEl.scrollHeight;
|
|
494
|
-
const px = handleHeight + verticalPadding + contentHeight;
|
|
495
|
-
setAutoContentPx(px);
|
|
496
|
-
onAutoContentHeightChange?.(px);
|
|
497
|
-
};
|
|
498
|
-
measure();
|
|
499
|
-
const ro = new ResizeObserver(measure);
|
|
500
|
-
ro.observe(contentEl ?? scrollEl);
|
|
501
|
-
return () => ro.disconnect();
|
|
502
|
-
}, [state, handleVisible, onAutoContentHeightChange]);
|
|
503
485
|
const [showScrollTop, setShowScrollTop] = useState(false);
|
|
504
486
|
const handleScroll = (e) => {
|
|
505
487
|
const scrollTop = e.currentTarget.scrollTop;
|
|
506
488
|
setShowScrollTop(state !== "closed" && scrollTop > scrollToTopThreshold);
|
|
507
489
|
};
|
|
508
|
-
|
|
509
|
-
if (state === "closed") {
|
|
510
|
-
setShowScrollTop(false);
|
|
511
|
-
} else {
|
|
512
|
-
const scrollTop = scrollContainerRef.current?.scrollTop || 0;
|
|
513
|
-
setShowScrollTop(scrollTop > scrollToTopThreshold);
|
|
514
|
-
}
|
|
515
|
-
}, [state, scrollToTopThreshold]);
|
|
516
|
-
const isDraggingSheet = useRef(false);
|
|
517
|
-
const hasDeterminedDirection = useRef(false);
|
|
518
|
-
const isTouchOnContent = useRef(false);
|
|
519
|
-
const isTouchOnHandle = useRef(false);
|
|
520
|
-
const suppressNextClickRef = useRef(false);
|
|
521
|
-
const contentAtTopSinceY = useRef(null);
|
|
522
|
-
const contentAtBottomSinceY = useRef(null);
|
|
523
|
-
const dragStartYRef = useRef(null);
|
|
524
|
-
const dragBaseHeightPxRef = useRef(0);
|
|
525
|
-
const stateRef = useRef(state);
|
|
526
|
-
const touchStartYRef = useRef(touchStartY);
|
|
527
|
-
const currentTouchYRef = useRef(currentTouchY);
|
|
528
|
-
useEffect(() => {
|
|
529
|
-
stateRef.current = state;
|
|
530
|
-
}, [state]);
|
|
531
|
-
useEffect(() => {
|
|
532
|
-
touchStartYRef.current = touchStartY;
|
|
533
|
-
}, [touchStartY]);
|
|
534
|
-
useEffect(() => {
|
|
535
|
-
currentTouchYRef.current = currentTouchY;
|
|
536
|
-
}, [currentTouchY]);
|
|
537
|
-
useEffect(() => {
|
|
538
|
-
const container = containerRef.current;
|
|
539
|
-
if (!container || side !== "bottom" || !enableTouchDrag) return;
|
|
540
|
-
const handleNativeTouchStart = (e) => {
|
|
541
|
-
const clientY = e.targetTouches[0].clientY;
|
|
542
|
-
setTouchStartY(clientY);
|
|
543
|
-
setCurrentTouchY(clientY);
|
|
544
|
-
isDraggingSheet.current = false;
|
|
545
|
-
hasDeterminedDirection.current = false;
|
|
546
|
-
contentAtTopSinceY.current = null;
|
|
547
|
-
contentAtBottomSinceY.current = null;
|
|
548
|
-
dragStartYRef.current = null;
|
|
549
|
-
const target = e.target;
|
|
550
|
-
isTouchOnContent.current = scrollContainerRef.current ? scrollContainerRef.current.contains(target) : false;
|
|
551
|
-
isTouchOnHandle.current = handleBarRef.current ? handleBarRef.current.contains(target) : false;
|
|
552
|
-
};
|
|
553
|
-
const handleNativeTouchMove = (e) => {
|
|
554
|
-
const startY = touchStartYRef.current;
|
|
555
|
-
if (startY === null) return;
|
|
556
|
-
const currentY = e.targetTouches[0].clientY;
|
|
557
|
-
const deltaY = startY - currentY;
|
|
558
|
-
const scrollTop = scrollContainerRef.current ? scrollContainerRef.current.scrollTop : 0;
|
|
559
|
-
const clientHeight = scrollContainerRef.current ? scrollContainerRef.current.clientHeight : 0;
|
|
560
|
-
const scrollHeight = scrollContainerRef.current ? scrollContainerRef.current.scrollHeight : 0;
|
|
561
|
-
const isAtBottom = scrollTop + clientHeight >= scrollHeight - 1;
|
|
562
|
-
const currentState = stateRef.current;
|
|
563
|
-
const containerHForHeights = containerHeight || container.parentElement?.getBoundingClientRect().height || window.innerHeight;
|
|
564
|
-
const fullPxNow = resolveHeightToPixels(
|
|
565
|
-
drawerFullHeight || "85%",
|
|
566
|
-
containerHForHeights
|
|
567
|
-
);
|
|
568
|
-
const peekPxNow = resolveHeightToPixels(
|
|
569
|
-
drawerPeekHeight || "15%",
|
|
570
|
-
containerHForHeights
|
|
571
|
-
);
|
|
572
|
-
const closedPxNow = (handleVisible ? HANDLE_BAR_HEIGHT_PX : 0) + (currentState === "closed" ? safeAreaInsets.bottom : 0);
|
|
573
|
-
const autoMaxPxNow = resolveHeightToPixels(
|
|
574
|
-
drawerAutoMaxHeight || "100%",
|
|
575
|
-
containerHForHeights
|
|
576
|
-
);
|
|
577
|
-
const autoPxNow = Math.min(autoMaxPxNow, autoContentPx);
|
|
578
|
-
const baselineHeightPxForState = (s) => {
|
|
579
|
-
if (s === "full") return fullPxNow;
|
|
580
|
-
if (s === "peek") return peekPxNow;
|
|
581
|
-
if (s === "auto") return autoPxNow;
|
|
582
|
-
return closedPxNow;
|
|
583
|
-
};
|
|
584
|
-
const commitDrag = () => {
|
|
585
|
-
isDraggingSheet.current = true;
|
|
586
|
-
dragStartYRef.current = currentY;
|
|
587
|
-
dragBaseHeightPxRef.current = baselineHeightPxForState(currentState);
|
|
588
|
-
};
|
|
589
|
-
if (scrollTop <= 0) {
|
|
590
|
-
if (contentAtTopSinceY.current === null) {
|
|
591
|
-
contentAtTopSinceY.current = currentY;
|
|
592
|
-
}
|
|
593
|
-
} else {
|
|
594
|
-
contentAtTopSinceY.current = null;
|
|
595
|
-
}
|
|
596
|
-
if (isAtBottom) {
|
|
597
|
-
if (contentAtBottomSinceY.current === null) {
|
|
598
|
-
contentAtBottomSinceY.current = currentY;
|
|
599
|
-
}
|
|
600
|
-
} else {
|
|
601
|
-
contentAtBottomSinceY.current = null;
|
|
602
|
-
}
|
|
603
|
-
const pullPastTop = contentAtTopSinceY.current !== null ? currentY - contentAtTopSinceY.current : 0;
|
|
604
|
-
const pullPastBottom = contentAtBottomSinceY.current !== null ? contentAtBottomSinceY.current - currentY : 0;
|
|
605
|
-
if (!hasDeterminedDirection.current) {
|
|
606
|
-
if (!isTouchOnContent.current) {
|
|
607
|
-
if (Math.abs(deltaY) < CONTENT_EDGE_PULL_THRESHOLD_PX) {
|
|
608
|
-
return;
|
|
609
|
-
}
|
|
610
|
-
commitDrag();
|
|
611
|
-
hasDeterminedDirection.current = true;
|
|
612
|
-
} else if (currentState !== "full") {
|
|
613
|
-
if (deltaY > 0 && isAtBottom && pullPastBottom >= CONTENT_EDGE_PULL_THRESHOLD_PX) {
|
|
614
|
-
commitDrag();
|
|
615
|
-
hasDeterminedDirection.current = true;
|
|
616
|
-
} else if (deltaY < 0 && scrollTop <= 0 && pullPastTop >= CONTENT_EDGE_PULL_THRESHOLD_PX) {
|
|
617
|
-
commitDrag();
|
|
618
|
-
hasDeterminedDirection.current = true;
|
|
619
|
-
} else if (deltaY > 0 && isAtBottom || deltaY < 0 && scrollTop <= 0) {
|
|
620
|
-
return;
|
|
621
|
-
} else {
|
|
622
|
-
isDraggingSheet.current = false;
|
|
623
|
-
hasDeterminedDirection.current = true;
|
|
624
|
-
}
|
|
625
|
-
} else {
|
|
626
|
-
if (deltaY < 0 && scrollTop <= 0 && pullPastTop >= CONTENT_EDGE_PULL_THRESHOLD_PX) {
|
|
627
|
-
commitDrag();
|
|
628
|
-
hasDeterminedDirection.current = true;
|
|
629
|
-
} else if (deltaY < 0 && scrollTop <= 0) {
|
|
630
|
-
return;
|
|
631
|
-
} else {
|
|
632
|
-
isDraggingSheet.current = false;
|
|
633
|
-
hasDeterminedDirection.current = true;
|
|
634
|
-
}
|
|
635
|
-
}
|
|
636
|
-
} else if (!isDraggingSheet.current && isTouchOnContent.current) {
|
|
637
|
-
if (deltaY < 0 && scrollTop <= 0 && pullPastTop >= CONTENT_EDGE_PULL_THRESHOLD_PX) {
|
|
638
|
-
commitDrag();
|
|
639
|
-
return;
|
|
640
|
-
}
|
|
641
|
-
if (deltaY > 0 && isAtBottom && currentState !== "full" && pullPastBottom >= CONTENT_EDGE_PULL_THRESHOLD_PX) {
|
|
642
|
-
commitDrag();
|
|
643
|
-
return;
|
|
644
|
-
}
|
|
645
|
-
}
|
|
646
|
-
if (isDraggingSheet.current) {
|
|
647
|
-
if (e.cancelable) {
|
|
648
|
-
e.preventDefault();
|
|
649
|
-
}
|
|
650
|
-
const parentContainer = container.parentElement;
|
|
651
|
-
if (parentContainer) {
|
|
652
|
-
const dragOffset = currentY - (dragStartYRef.current ?? currentY);
|
|
653
|
-
let localClamped = dragOffset;
|
|
654
|
-
if (currentState === "full") {
|
|
655
|
-
localClamped = Math.max(
|
|
656
|
-
0,
|
|
657
|
-
Math.min(fullPxNow - closedPxNow, dragOffset)
|
|
658
|
-
);
|
|
659
|
-
} else if (currentState === "peek") {
|
|
660
|
-
localClamped = Math.max(
|
|
661
|
-
-(fullPxNow - peekPxNow),
|
|
662
|
-
Math.min(peekPxNow - closedPxNow, dragOffset)
|
|
663
|
-
);
|
|
664
|
-
} else if (currentState === "closed") {
|
|
665
|
-
localClamped = Math.min(
|
|
666
|
-
0,
|
|
667
|
-
Math.max(-(fullPxNow - closedPxNow), dragOffset)
|
|
668
|
-
);
|
|
669
|
-
} else if (currentState === "auto") {
|
|
670
|
-
localClamped = Math.max(0, dragOffset);
|
|
671
|
-
}
|
|
672
|
-
parentContainer.style.setProperty(
|
|
673
|
-
"--drag-offset",
|
|
674
|
-
`${localClamped}px`
|
|
675
|
-
);
|
|
676
|
-
}
|
|
677
|
-
}
|
|
678
|
-
};
|
|
679
|
-
const handleNativeTouchEnd = (e) => {
|
|
680
|
-
const startY = touchStartYRef.current;
|
|
681
|
-
const currentY = currentTouchYRef.current;
|
|
682
|
-
const parentContainer = container.parentElement;
|
|
683
|
-
if (startY === null || currentY === null) {
|
|
684
|
-
if (parentContainer) {
|
|
685
|
-
parentContainer.style.setProperty("--drag-offset", "0px");
|
|
686
|
-
}
|
|
687
|
-
return;
|
|
688
|
-
}
|
|
689
|
-
if (!isDraggingSheet.current) {
|
|
690
|
-
if (isTouchOnHandle.current) {
|
|
691
|
-
handleHandleClickRef.current();
|
|
692
|
-
suppressNextClickRef.current = true;
|
|
693
|
-
setTimeout(() => {
|
|
694
|
-
suppressNextClickRef.current = false;
|
|
695
|
-
}, HANDLE_TAP_CLICK_SUPPRESSION_MS);
|
|
696
|
-
}
|
|
697
|
-
setTouchStartY(null);
|
|
698
|
-
setCurrentTouchY(null);
|
|
699
|
-
if (parentContainer) {
|
|
700
|
-
parentContainer.style.setProperty("--drag-offset", "0px");
|
|
701
|
-
}
|
|
702
|
-
return;
|
|
703
|
-
}
|
|
704
|
-
const touchEndY = e.changedTouches[0].clientY;
|
|
705
|
-
const dragStartY = dragStartYRef.current ?? startY;
|
|
706
|
-
const dragDistance = Math.abs(touchEndY - dragStartY);
|
|
707
|
-
if (dragDistance < 10) {
|
|
708
|
-
setTouchStartY(null);
|
|
709
|
-
setCurrentTouchY(null);
|
|
710
|
-
if (parentContainer) {
|
|
711
|
-
parentContainer.style.setProperty("--drag-offset", "0px");
|
|
712
|
-
}
|
|
713
|
-
return;
|
|
714
|
-
}
|
|
715
|
-
const containerH2 = containerHeight || (parentContainer ? parentContainer.getBoundingClientRect().height : window.innerHeight);
|
|
716
|
-
const fullPx2 = resolveHeightToPixels(
|
|
717
|
-
drawerFullHeight || "85%",
|
|
718
|
-
containerH2
|
|
719
|
-
);
|
|
720
|
-
const peekPx2 = resolveHeightToPixels(
|
|
721
|
-
drawerPeekHeight || "15%",
|
|
722
|
-
containerH2
|
|
723
|
-
);
|
|
724
|
-
const currentState = stateRef.current;
|
|
725
|
-
const closedPx = (handleVisible ? HANDLE_BAR_HEIGHT_PX : 0) + (currentState === "closed" ? safeAreaInsets.bottom : 0);
|
|
726
|
-
const dragDelta = touchEndY - dragStartY;
|
|
727
|
-
const drawerHeightFromBottom = dragBaseHeightPxRef.current - dragDelta;
|
|
728
|
-
const distToClosed = Math.abs(drawerHeightFromBottom - closedPx);
|
|
729
|
-
let targetState2;
|
|
730
|
-
if (currentState === "auto") {
|
|
731
|
-
const autoMaxPx2 = resolveHeightToPixels(
|
|
732
|
-
drawerAutoMaxHeight || "100%",
|
|
733
|
-
containerH2
|
|
734
|
-
);
|
|
735
|
-
const autoPx2 = Math.min(autoMaxPx2, autoContentPx);
|
|
736
|
-
const distToAuto = Math.abs(drawerHeightFromBottom - autoPx2);
|
|
737
|
-
targetState2 = distToAuto <= distToClosed ? "auto" : "closed";
|
|
738
|
-
} else {
|
|
739
|
-
const distToFull = Math.abs(drawerHeightFromBottom - fullPx2);
|
|
740
|
-
const distToPeek = Math.abs(drawerHeightFromBottom - peekPx2);
|
|
741
|
-
const minDist = Math.min(distToFull, distToPeek, distToClosed);
|
|
742
|
-
if (minDist === distToFull) {
|
|
743
|
-
targetState2 = "full";
|
|
744
|
-
} else if (minDist === distToPeek) {
|
|
745
|
-
targetState2 = "peek";
|
|
746
|
-
} else {
|
|
747
|
-
targetState2 = "closed";
|
|
748
|
-
}
|
|
749
|
-
}
|
|
750
|
-
setTouchStartY(null);
|
|
751
|
-
setCurrentTouchY(null);
|
|
752
|
-
onChangeState(targetState2);
|
|
753
|
-
requestAnimationFrame(() => {
|
|
754
|
-
if (parentContainer) {
|
|
755
|
-
parentContainer.style.setProperty("--drag-offset", "0px");
|
|
756
|
-
}
|
|
757
|
-
});
|
|
758
|
-
};
|
|
759
|
-
const handleNativeClickCapture = (e) => {
|
|
760
|
-
if (!suppressNextClickRef.current) return;
|
|
761
|
-
suppressNextClickRef.current = false;
|
|
762
|
-
e.preventDefault();
|
|
763
|
-
e.stopPropagation();
|
|
764
|
-
};
|
|
765
|
-
container.addEventListener("touchstart", handleNativeTouchStart, {
|
|
766
|
-
passive: true
|
|
767
|
-
});
|
|
768
|
-
container.addEventListener("touchmove", handleNativeTouchMove, {
|
|
769
|
-
passive: false
|
|
770
|
-
});
|
|
771
|
-
container.addEventListener("touchend", handleNativeTouchEnd, {
|
|
772
|
-
passive: true
|
|
773
|
-
});
|
|
774
|
-
container.addEventListener("click", handleNativeClickCapture, {
|
|
775
|
-
capture: true
|
|
776
|
-
});
|
|
777
|
-
return () => {
|
|
778
|
-
container.removeEventListener("touchstart", handleNativeTouchStart);
|
|
779
|
-
container.removeEventListener("touchmove", handleNativeTouchMove);
|
|
780
|
-
container.removeEventListener("touchend", handleNativeTouchEnd);
|
|
781
|
-
container.removeEventListener("click", handleNativeClickCapture, {
|
|
782
|
-
capture: true
|
|
783
|
-
});
|
|
784
|
-
};
|
|
785
|
-
}, [
|
|
786
|
-
side,
|
|
787
|
-
enableTouchDrag,
|
|
788
|
-
containerHeight,
|
|
789
|
-
drawerFullHeight,
|
|
790
|
-
drawerPeekHeight,
|
|
791
|
-
drawerAutoMaxHeight,
|
|
792
|
-
safeAreaInsets,
|
|
793
|
-
onChangeState,
|
|
794
|
-
setTouchStartY,
|
|
795
|
-
setCurrentTouchY,
|
|
796
|
-
autoContentPx,
|
|
797
|
-
handleVisible
|
|
798
|
-
]);
|
|
799
|
-
const isBackdropActive = state === "full" || state === "auto";
|
|
490
|
+
const isBackdropActive = state !== "closed";
|
|
800
491
|
const backdropStyles = isBackdropActive ? "opacity-100 pointer-events-auto" : "opacity-0 pointer-events-none";
|
|
801
|
-
const containerH = containerHeight || window.innerHeight;
|
|
802
|
-
const fullPx = resolveHeightToPixels(drawerFullHeight || "85%", containerH);
|
|
803
|
-
const peekPx = resolveHeightToPixels(drawerPeekHeight || "15%", containerH);
|
|
804
|
-
const autoMaxPx = resolveHeightToPixels(
|
|
805
|
-
drawerAutoMaxHeight || "100%",
|
|
806
|
-
containerH
|
|
807
|
-
);
|
|
808
|
-
const shiftPx = fullPx - peekPx;
|
|
809
|
-
const autoPx = Math.min(autoMaxPx, autoContentPx);
|
|
810
|
-
const autoShiftPx = Math.max(fullPx - autoPx, 0);
|
|
811
|
-
const getBottomDrawerTransform = () => {
|
|
812
|
-
if (state === "full") {
|
|
813
|
-
return "translateY(var(--drag-offset, 0px))";
|
|
814
|
-
}
|
|
815
|
-
if (state === "peek") {
|
|
816
|
-
return `translateY(calc(${shiftPx}px + var(--drag-offset, 0px)))`;
|
|
817
|
-
}
|
|
818
|
-
if (state === "auto") {
|
|
819
|
-
return `translateY(calc(${autoShiftPx}px + var(--drag-offset, 0px)))`;
|
|
820
|
-
}
|
|
821
|
-
const closedVisibleHeight = handleVisible ? HANDLE_BAR_HEIGHT_PX : 0;
|
|
822
|
-
const closedShiftPx = fullPx - closedVisibleHeight;
|
|
823
|
-
return `translateY(calc(${closedShiftPx}px + var(--drag-offset, 0px)))`;
|
|
824
|
-
};
|
|
825
492
|
return /* @__PURE__ */ jsxs2(Fragment, { children: [
|
|
826
493
|
/* @__PURE__ */ jsx3("style", { children: `
|
|
827
494
|
.no-scrollbar {
|
|
@@ -839,233 +506,113 @@ var MapDrawer = forwardRef3(
|
|
|
839
506
|
onClick: () => onChangeState("closed")
|
|
840
507
|
}
|
|
841
508
|
),
|
|
842
|
-
|
|
843
|
-
|
|
844
|
-
|
|
845
|
-
|
|
846
|
-
|
|
847
|
-
|
|
848
|
-
|
|
849
|
-
|
|
850
|
-
|
|
851
|
-
|
|
852
|
-
|
|
853
|
-
|
|
854
|
-
|
|
855
|
-
|
|
856
|
-
|
|
857
|
-
|
|
858
|
-
|
|
859
|
-
|
|
860
|
-
|
|
861
|
-
|
|
862
|
-
|
|
863
|
-
|
|
864
|
-
|
|
865
|
-
|
|
866
|
-
|
|
867
|
-
|
|
868
|
-
|
|
869
|
-
|
|
870
|
-
|
|
871
|
-
|
|
872
|
-
|
|
873
|
-
|
|
874
|
-
|
|
875
|
-
|
|
876
|
-
|
|
877
|
-
|
|
878
|
-
|
|
879
|
-
|
|
880
|
-
|
|
881
|
-
children:
|
|
882
|
-
|
|
883
|
-
|
|
884
|
-
|
|
885
|
-
|
|
886
|
-
|
|
887
|
-
|
|
888
|
-
|
|
889
|
-
children: menuContent ? menuContent : /* @__PURE__ */ jsx3("div", { className: "flex flex-col gap-1.5", children: menuItems.map((item) => /* @__PURE__ */ jsxs2(
|
|
890
|
-
Button,
|
|
891
|
-
{
|
|
892
|
-
className: `flex items-center gap-3 w-full py-3 px-3.5 rounded-xl text-left cursor-pointer transition-all duration-150 justify-start hover:bg-white/5 hover:text-white active:bg-white/10 text-white ${item.disabled ? "opacity-45 cursor-not-allowed pointer-events-none" : ""}`,
|
|
893
|
-
disabled: item.disabled,
|
|
894
|
-
onClick: () => {
|
|
895
|
-
if (!item.disabled) {
|
|
896
|
-
item.onPress();
|
|
897
|
-
onChangeState("closed");
|
|
898
|
-
}
|
|
899
|
-
},
|
|
900
|
-
variant: "ghost",
|
|
901
|
-
children: [
|
|
902
|
-
/* @__PURE__ */ jsxs2("div", { className: "relative flex items-center justify-center w-8 h-8 rounded-lg bg-white/5 text-zinc-300", children: [
|
|
903
|
-
item.icon,
|
|
904
|
-
item.badge !== void 0 && /* @__PURE__ */ jsx3("span", { className: "absolute -top-1 -right-1 bg-cyan-500 text-black text-[9px] font-extrabold min-w-[15px] h-3.5 rounded-full flex items-center justify-center px-1 border border-zinc-950 shadow", children: item.badge })
|
|
905
|
-
] }),
|
|
906
|
-
/* @__PURE__ */ jsx3("span", { className: "text-sm font-medium tracking-wide flex-1", children: item.label })
|
|
907
|
-
]
|
|
908
|
-
},
|
|
909
|
-
item.id
|
|
910
|
-
)) })
|
|
911
|
-
}
|
|
912
|
-
),
|
|
913
|
-
showScrollToTopButton && showScrollTop && /* @__PURE__ */ jsx3(
|
|
914
|
-
Button,
|
|
915
|
-
{
|
|
916
|
-
className: "absolute bottom-6 right-6 z-50 flex items-center justify-center w-10 h-10 rounded-full bg-cyan-500 hover:bg-cyan-400 active:scale-95 text-black hover:text-black shadow-lg shadow-cyan-500/25 transition-all duration-200 cursor-pointer p-0!",
|
|
917
|
-
onClick: () => {
|
|
918
|
-
scrollContainerRef.current?.scrollTo({
|
|
919
|
-
behavior: "smooth",
|
|
920
|
-
top: 0
|
|
921
|
-
});
|
|
922
|
-
},
|
|
923
|
-
variant: "ghost",
|
|
924
|
-
children: /* @__PURE__ */ jsx3(
|
|
925
|
-
"svg",
|
|
926
|
-
{
|
|
927
|
-
fill: "none",
|
|
928
|
-
height: "20",
|
|
929
|
-
stroke: "currentColor",
|
|
930
|
-
strokeLinecap: "round",
|
|
931
|
-
strokeLinejoin: "round",
|
|
932
|
-
strokeWidth: "2.5",
|
|
933
|
-
viewBox: "0 0 24 24",
|
|
934
|
-
width: "20",
|
|
935
|
-
xmlns: "http://www.w3.org/2000/svg",
|
|
936
|
-
children: /* @__PURE__ */ jsx3("polyline", { points: "18 15 12 9 6 15" })
|
|
937
|
-
}
|
|
938
|
-
)
|
|
939
|
-
}
|
|
940
|
-
)
|
|
941
|
-
]
|
|
942
|
-
}
|
|
943
|
-
)
|
|
944
|
-
}
|
|
945
|
-
)
|
|
946
|
-
] }) : (
|
|
947
|
-
/* Bottom Sheet Panel - Hardware accelerated translateY transitions */
|
|
948
|
-
/* @__PURE__ */ jsxs2(
|
|
949
|
-
"div",
|
|
950
|
-
{
|
|
951
|
-
className: `absolute w-full bg-zinc-950/85 backdrop-blur-md border border-white/10 rounded-t-2xl shadow-2xl flex flex-col z-40 select-none ${isDragging ? "transition-none" : "transition-transform duration-300 ease-out"}`,
|
|
952
|
-
ref: containerRef,
|
|
953
|
-
style: {
|
|
954
|
-
bottom: "0px",
|
|
955
|
-
// Box height must stay exactly fullPx for "closed"/"peek"/
|
|
956
|
-
// "full" — every other transform calc in this component
|
|
957
|
-
// assumes the box IS fullPx tall. Only "auto" grows it (up to
|
|
958
|
-
// autoMaxPx) when content needs more room than fullPx offers;
|
|
959
|
-
// getBottomDrawerTransform()'s auto branch is derived to match
|
|
960
|
-
// (shift = max(fullPx - autoPx, 0), so a taller box needs zero
|
|
961
|
-
// extra shift to fully reveal itself).
|
|
962
|
-
height: `${state === "auto" ? Math.max(fullPx, autoPx) : fullPx}px`,
|
|
963
|
-
marginBottom: state === "closed" ? `${safeAreaInsets.bottom}px` : "0px",
|
|
964
|
-
transform: getBottomDrawerTransform(),
|
|
965
|
-
// `height` is animated too (not just transform/margin-bottom):
|
|
966
|
-
// entering/leaving "auto" with content taller than fullPx
|
|
967
|
-
// changes the box's actual CSS height, and without this it
|
|
968
|
-
// would snap instantly while transform eases in over 300ms —
|
|
969
|
-
// a visible pop of content before the slide animation catches
|
|
970
|
-
// up.
|
|
971
|
-
transition: isDragging ? "none" : "transform 300ms ease-out, height 300ms ease-out, margin-bottom 250ms ease-in-out"
|
|
972
|
-
},
|
|
973
|
-
children: [
|
|
974
|
-
handleVisible && /* @__PURE__ */ jsx3(
|
|
975
|
-
"div",
|
|
976
|
-
{
|
|
977
|
-
className: "w-full h-8 flex flex-col items-center justify-center cursor-pointer hover:bg-white/5 rounded-t-2xl transition-colors border-b border-white/5",
|
|
978
|
-
onClick: () => {
|
|
979
|
-
if (suppressNextClickRef.current) return;
|
|
980
|
-
handleHandleClick();
|
|
981
|
-
},
|
|
982
|
-
ref: handleBarRef,
|
|
983
|
-
children: /* @__PURE__ */ jsx3("div", { className: "w-12 h-1 bg-white/25 rounded-full" })
|
|
984
|
-
}
|
|
985
|
-
),
|
|
986
|
-
/* @__PURE__ */ jsxs2(
|
|
987
|
-
"div",
|
|
988
|
-
{
|
|
989
|
-
className: "flex-1 flex flex-col overflow-hidden px-4 pb-4 pt-2 transition-[margin-top] duration-250 ease-in-out relative",
|
|
990
|
-
ref: contentAreaRef,
|
|
991
|
-
style: {
|
|
992
|
-
marginTop: state === "closed" ? `${safeAreaInsets.bottom}px` : "0px"
|
|
993
|
-
},
|
|
994
|
-
children: [
|
|
995
|
-
/* @__PURE__ */ jsx3(
|
|
996
|
-
"div",
|
|
997
|
-
{
|
|
998
|
-
className: "flex-1 overflow-y-auto no-scrollbar",
|
|
999
|
-
onScroll: handleScroll,
|
|
1000
|
-
ref: scrollContainerRef,
|
|
1001
|
-
style: {
|
|
1002
|
-
paddingBottom: state === "peek" ? `${shiftPx}px` : "0px"
|
|
1003
|
-
},
|
|
1004
|
-
children: menuContent ? menuContent : /* @__PURE__ */ jsx3("div", { className: "flex flex-col gap-1", children: menuItems.map((item) => /* @__PURE__ */ jsxs2(
|
|
1005
|
-
Button,
|
|
1006
|
-
{
|
|
1007
|
-
className: `flex items-center gap-3 w-full py-3 px-3.5 rounded-xl text-left cursor-pointer transition-all duration-150 justify-start hover:bg-white/5 hover:text-white active:bg-white/10 text-white ${item.disabled ? "opacity-45 cursor-not-allowed pointer-events-none" : ""}`,
|
|
1008
|
-
disabled: item.disabled,
|
|
1009
|
-
onClick: () => {
|
|
1010
|
-
if (!item.disabled) {
|
|
1011
|
-
item.onPress();
|
|
1012
|
-
onChangeState("closed");
|
|
1013
|
-
}
|
|
1014
|
-
},
|
|
1015
|
-
variant: "ghost",
|
|
1016
|
-
children: [
|
|
1017
|
-
/* @__PURE__ */ jsxs2("div", { className: "relative flex items-center justify-center w-8 h-8 rounded-lg bg-white/5 text-zinc-300", children: [
|
|
1018
|
-
item.icon,
|
|
1019
|
-
item.badge !== void 0 && /* @__PURE__ */ jsx3("span", { className: "absolute -top-1 -right-1 bg-cyan-500 text-black text-[9px] font-extrabold min-w-[15px] h-3.5 rounded-full flex items-center justify-center px-1 border border-zinc-950 shadow", children: item.badge })
|
|
1020
|
-
] }),
|
|
1021
|
-
/* @__PURE__ */ jsx3("span", { className: "text-sm font-medium tracking-wide", children: item.label })
|
|
1022
|
-
]
|
|
1023
|
-
},
|
|
1024
|
-
item.id
|
|
1025
|
-
)) })
|
|
1026
|
-
}
|
|
1027
|
-
),
|
|
1028
|
-
showScrollToTopButton && showScrollTop && /* @__PURE__ */ jsx3(
|
|
509
|
+
state === "closed" && /* @__PURE__ */ jsx3(
|
|
510
|
+
Button,
|
|
511
|
+
{
|
|
512
|
+
className: "absolute top-4 left-4 z-40 w-12 h-12 rounded-full bg-zinc-950/80 backdrop-blur-md border border-white/10 shadow-lg flex items-center justify-center text-white active:scale-95 transition-all cursor-pointer hover:bg-zinc-900 hover:text-white p-0!",
|
|
513
|
+
onClick: () => onChangeState("full"),
|
|
514
|
+
variant: "ghost",
|
|
515
|
+
children: /* @__PURE__ */ jsxs2(
|
|
516
|
+
"svg",
|
|
517
|
+
{
|
|
518
|
+
fill: "none",
|
|
519
|
+
height: "24",
|
|
520
|
+
stroke: "currentColor",
|
|
521
|
+
strokeLinecap: "round",
|
|
522
|
+
strokeLinejoin: "round",
|
|
523
|
+
strokeWidth: "2",
|
|
524
|
+
viewBox: "0 0 24 24",
|
|
525
|
+
width: "24",
|
|
526
|
+
xmlns: "http://www.w3.org/2000/svg",
|
|
527
|
+
children: [
|
|
528
|
+
/* @__PURE__ */ jsx3("line", { x1: "4", x2: "20", y1: "12", y2: "12" }),
|
|
529
|
+
/* @__PURE__ */ jsx3("line", { x1: "4", x2: "20", y1: "6", y2: "6" }),
|
|
530
|
+
/* @__PURE__ */ jsx3("line", { x1: "4", x2: "20", y1: "18", y2: "18" })
|
|
531
|
+
]
|
|
532
|
+
}
|
|
533
|
+
)
|
|
534
|
+
}
|
|
535
|
+
),
|
|
536
|
+
/* @__PURE__ */ jsx3(
|
|
537
|
+
Sheet,
|
|
538
|
+
{
|
|
539
|
+
onOpenChange: (open) => onChangeState(open ? "full" : "closed"),
|
|
540
|
+
open: state !== "closed",
|
|
541
|
+
children: /* @__PURE__ */ jsxs2(
|
|
542
|
+
SheetContent,
|
|
543
|
+
{
|
|
544
|
+
className: "w-80 bg-zinc-950/85 backdrop-blur-md border-r border-y border-white/10 rounded-r-2xl shadow-2xl p-4 text-white flex flex-col h-full overflow-hidden",
|
|
545
|
+
portal: false,
|
|
546
|
+
side: "left",
|
|
547
|
+
children: [
|
|
548
|
+
/* @__PURE__ */ jsx3(SheetHeader, { className: "pb-3 border-b border-white/10 mb-2 text-left", children: /* @__PURE__ */ jsx3(SheetTitle, { className: "text-sm font-bold tracking-wider text-zinc-400 uppercase", children: "Menu" }) }),
|
|
549
|
+
/* @__PURE__ */ jsx3(
|
|
550
|
+
"div",
|
|
551
|
+
{
|
|
552
|
+
className: "flex-1 overflow-y-auto no-scrollbar pr-2",
|
|
553
|
+
onScroll: handleScroll,
|
|
554
|
+
ref: scrollContainerRef,
|
|
555
|
+
children: menuContent ? menuContent : /* @__PURE__ */ jsx3("div", { className: "flex flex-col gap-1.5", children: menuItems.map((item) => /* @__PURE__ */ jsxs2(
|
|
1029
556
|
Button,
|
|
1030
557
|
{
|
|
1031
|
-
className:
|
|
558
|
+
className: `flex items-center gap-3 w-full py-3 px-3.5 rounded-xl text-left cursor-pointer transition-all duration-150 justify-start hover:bg-white/5 hover:text-white active:bg-white/10 text-white ${item.disabled ? "opacity-45 cursor-not-allowed pointer-events-none" : ""}`,
|
|
559
|
+
disabled: item.disabled,
|
|
1032
560
|
onClick: () => {
|
|
1033
|
-
|
|
1034
|
-
|
|
1035
|
-
|
|
1036
|
-
}
|
|
1037
|
-
},
|
|
1038
|
-
style: {
|
|
1039
|
-
bottom: state === "peek" ? `calc(${24 + shiftPx}px + var(--drag-offset, 0px))` : `calc(24px + var(--drag-offset, 0px))`
|
|
561
|
+
if (!item.disabled) {
|
|
562
|
+
item.onPress();
|
|
563
|
+
onChangeState("closed");
|
|
564
|
+
}
|
|
1040
565
|
},
|
|
1041
566
|
variant: "ghost",
|
|
1042
|
-
children:
|
|
1043
|
-
"
|
|
1044
|
-
|
|
1045
|
-
|
|
1046
|
-
|
|
1047
|
-
|
|
1048
|
-
|
|
1049
|
-
|
|
1050
|
-
|
|
1051
|
-
|
|
1052
|
-
|
|
1053
|
-
|
|
1054
|
-
|
|
1055
|
-
|
|
1056
|
-
|
|
567
|
+
children: [
|
|
568
|
+
/* @__PURE__ */ jsxs2("div", { className: "relative flex items-center justify-center w-8 h-8 rounded-lg bg-white/5 text-zinc-300", children: [
|
|
569
|
+
item.icon,
|
|
570
|
+
item.badge !== void 0 && /* @__PURE__ */ jsx3("span", { className: "absolute -top-1 -right-1 bg-cyan-500 text-black text-[9px] font-extrabold min-w-[15px] h-3.5 rounded-full flex items-center justify-center px-1 border border-zinc-950 shadow", children: item.badge })
|
|
571
|
+
] }),
|
|
572
|
+
/* @__PURE__ */ jsx3("span", { className: "text-sm font-medium tracking-wide flex-1", children: item.label })
|
|
573
|
+
]
|
|
574
|
+
},
|
|
575
|
+
item.id
|
|
576
|
+
)) })
|
|
577
|
+
}
|
|
578
|
+
),
|
|
579
|
+
showScrollToTopButton && showScrollTop && /* @__PURE__ */ jsx3(
|
|
580
|
+
Button,
|
|
581
|
+
{
|
|
582
|
+
className: "absolute bottom-6 right-6 z-50 flex items-center justify-center w-10 h-10 rounded-full bg-cyan-500 hover:bg-cyan-400 active:scale-95 text-black hover:text-black shadow-lg shadow-cyan-500/25 transition-all duration-200 cursor-pointer p-0!",
|
|
583
|
+
onClick: () => {
|
|
584
|
+
scrollContainerRef.current?.scrollTo({
|
|
585
|
+
behavior: "smooth",
|
|
586
|
+
top: 0
|
|
587
|
+
});
|
|
588
|
+
},
|
|
589
|
+
variant: "ghost",
|
|
590
|
+
children: /* @__PURE__ */ jsx3(
|
|
591
|
+
"svg",
|
|
592
|
+
{
|
|
593
|
+
fill: "none",
|
|
594
|
+
height: "20",
|
|
595
|
+
stroke: "currentColor",
|
|
596
|
+
strokeLinecap: "round",
|
|
597
|
+
strokeLinejoin: "round",
|
|
598
|
+
strokeWidth: "2.5",
|
|
599
|
+
viewBox: "0 0 24 24",
|
|
600
|
+
width: "20",
|
|
601
|
+
xmlns: "http://www.w3.org/2000/svg",
|
|
602
|
+
children: /* @__PURE__ */ jsx3("polyline", { points: "18 15 12 9 6 15" })
|
|
1057
603
|
}
|
|
1058
604
|
)
|
|
1059
|
-
|
|
1060
|
-
|
|
1061
|
-
|
|
1062
|
-
|
|
1063
|
-
|
|
1064
|
-
|
|
605
|
+
}
|
|
606
|
+
)
|
|
607
|
+
]
|
|
608
|
+
}
|
|
609
|
+
)
|
|
610
|
+
}
|
|
1065
611
|
)
|
|
1066
612
|
] });
|
|
1067
613
|
}
|
|
1068
614
|
);
|
|
615
|
+
MapDrawer.displayName = "MapDrawer";
|
|
1069
616
|
|
|
1070
617
|
// src/components/ui/card.tsx
|
|
1071
618
|
import * as React3 from "react";
|
|
@@ -1516,40 +1063,348 @@ var MapRightControls = ({
|
|
|
1516
1063
|
);
|
|
1517
1064
|
};
|
|
1518
1065
|
|
|
1519
|
-
// src/components/Map/
|
|
1066
|
+
// src/components/Map/components/MobileBottomDrawer.tsx
|
|
1067
|
+
import { interpolate, useTransform } from "motion/react";
|
|
1520
1068
|
import {
|
|
1521
|
-
|
|
1069
|
+
forwardRef as forwardRef5,
|
|
1522
1070
|
useCallback,
|
|
1523
|
-
|
|
1071
|
+
useEffect,
|
|
1072
|
+
useImperativeHandle as useImperativeHandle2,
|
|
1524
1073
|
useMemo,
|
|
1525
1074
|
useRef as useRef2,
|
|
1526
1075
|
useState as useState2
|
|
1527
1076
|
} from "react";
|
|
1528
|
-
import {
|
|
1077
|
+
import { Sheet as Sheet2 } from "react-modal-sheet";
|
|
1078
|
+
import { Fragment as Fragment2, jsx as jsx7, jsxs as jsxs5 } from "react/jsx-runtime";
|
|
1079
|
+
var resolveHeightToPixels = (height, containerHeight) => {
|
|
1080
|
+
if (typeof height === "number") {
|
|
1081
|
+
return height;
|
|
1082
|
+
}
|
|
1083
|
+
if (height.endsWith("%")) {
|
|
1084
|
+
return parseFloat(height) / 100 * containerHeight;
|
|
1085
|
+
}
|
|
1086
|
+
return parseFloat(height);
|
|
1087
|
+
};
|
|
1088
|
+
var HANDLE_HEIGHT_PX = 32;
|
|
1089
|
+
var SHEET_TWEEN_CONFIG = {
|
|
1090
|
+
duration: 0.4,
|
|
1091
|
+
ease: [0.32, 0.72, 0, 1]
|
|
1092
|
+
};
|
|
1093
|
+
var SHEET_DRAG_VELOCITY_THRESHOLD = 1700;
|
|
1094
|
+
var MobileBottomDrawer = forwardRef5(
|
|
1095
|
+
({
|
|
1096
|
+
menuItems,
|
|
1097
|
+
state,
|
|
1098
|
+
onChangeState,
|
|
1099
|
+
drawerPeekHeight,
|
|
1100
|
+
drawerFullHeight,
|
|
1101
|
+
drawerAutoMaxHeight,
|
|
1102
|
+
containerHeight,
|
|
1103
|
+
menuContent,
|
|
1104
|
+
enableTouchDrag = true,
|
|
1105
|
+
handleVisible = true,
|
|
1106
|
+
onAutoContentHeightChange,
|
|
1107
|
+
showScrollToTopButton = true,
|
|
1108
|
+
scrollToTopThreshold = 300,
|
|
1109
|
+
safeAreaInsets = { bottom: 0, left: 0, right: 0, top: 0 }
|
|
1110
|
+
}, ref) => {
|
|
1111
|
+
const scrollRef = useRef2(null);
|
|
1112
|
+
useImperativeHandle2(ref, () => scrollRef.current);
|
|
1113
|
+
const headerRef = useRef2(null);
|
|
1114
|
+
const contentWrapperRef = useRef2(null);
|
|
1115
|
+
const [viewportHeight, setViewportHeight] = useState2(
|
|
1116
|
+
() => containerHeight ?? (typeof window !== "undefined" ? window.innerHeight : 800)
|
|
1117
|
+
);
|
|
1118
|
+
useEffect(() => {
|
|
1119
|
+
if (containerHeight) {
|
|
1120
|
+
setViewportHeight(containerHeight);
|
|
1121
|
+
return;
|
|
1122
|
+
}
|
|
1123
|
+
if (typeof window === "undefined") return;
|
|
1124
|
+
const update = () => setViewportHeight(window.innerHeight);
|
|
1125
|
+
update();
|
|
1126
|
+
window.addEventListener("resize", update);
|
|
1127
|
+
return () => window.removeEventListener("resize", update);
|
|
1128
|
+
}, [containerHeight]);
|
|
1129
|
+
const [autoContentPx, setAutoContentPx] = useState2(0);
|
|
1130
|
+
useEffect(() => {
|
|
1131
|
+
const contentEl = contentWrapperRef.current;
|
|
1132
|
+
if (!contentEl) return;
|
|
1133
|
+
const measure = () => {
|
|
1134
|
+
const headerHeight = handleVisible ? headerRef.current?.offsetHeight ?? 0 : 0;
|
|
1135
|
+
const px = headerHeight + contentEl.scrollHeight;
|
|
1136
|
+
setAutoContentPx(px);
|
|
1137
|
+
onAutoContentHeightChange?.(px);
|
|
1138
|
+
};
|
|
1139
|
+
measure();
|
|
1140
|
+
const ro = new ResizeObserver(measure);
|
|
1141
|
+
ro.observe(contentEl);
|
|
1142
|
+
return () => ro.disconnect();
|
|
1143
|
+
}, [handleVisible, onAutoContentHeightChange]);
|
|
1144
|
+
const closedPx = (handleVisible ? HANDLE_HEIGHT_PX : 0) + safeAreaInsets.bottom;
|
|
1145
|
+
const peekPx = resolveHeightToPixels(
|
|
1146
|
+
drawerPeekHeight ?? "15%",
|
|
1147
|
+
viewportHeight
|
|
1148
|
+
);
|
|
1149
|
+
const autoMaxPx = resolveHeightToPixels(
|
|
1150
|
+
drawerAutoMaxHeight ?? "100%",
|
|
1151
|
+
viewportHeight
|
|
1152
|
+
);
|
|
1153
|
+
const autoPx = Math.min(autoMaxPx, Math.max(autoContentPx, closedPx + 1));
|
|
1154
|
+
const { snapPoints, snapLabels, backdropOutput } = useMemo(() => {
|
|
1155
|
+
const normalize = (raw) => raw > 0 && raw <= 1 ? raw * viewportHeight : raw;
|
|
1156
|
+
const unsorted = [
|
|
1157
|
+
{ label: "closed", raw: 0 },
|
|
1158
|
+
{ label: "closed", raw: closedPx },
|
|
1159
|
+
{ label: "peek", raw: peekPx },
|
|
1160
|
+
{ label: "auto", raw: autoPx },
|
|
1161
|
+
{ label: "full", raw: 1 }
|
|
1162
|
+
];
|
|
1163
|
+
const entries = unsorted.sort(
|
|
1164
|
+
(a, b) => normalize(a.raw) - normalize(b.raw)
|
|
1165
|
+
);
|
|
1166
|
+
const deduped = [];
|
|
1167
|
+
for (const entry of entries) {
|
|
1168
|
+
const prev = deduped[deduped.length - 1];
|
|
1169
|
+
if (prev && Math.abs(normalize(prev.raw) - normalize(entry.raw)) < 0.5) {
|
|
1170
|
+
deduped[deduped.length - 1] = entry;
|
|
1171
|
+
continue;
|
|
1172
|
+
}
|
|
1173
|
+
deduped.push(entry);
|
|
1174
|
+
}
|
|
1175
|
+
return {
|
|
1176
|
+
backdropOutput: deduped.map(
|
|
1177
|
+
(d) => d.label === "full" || d.label === "auto" ? 1 : 0
|
|
1178
|
+
),
|
|
1179
|
+
snapLabels: deduped.map((d) => d.label),
|
|
1180
|
+
snapPoints: deduped.map((d) => d.raw)
|
|
1181
|
+
};
|
|
1182
|
+
}, [closedPx, peekPx, autoPx, viewportHeight]);
|
|
1183
|
+
const currentIndex = Math.max(0, snapLabels.lastIndexOf(state));
|
|
1184
|
+
const sheetRef = useRef2(null);
|
|
1185
|
+
useEffect(() => {
|
|
1186
|
+
let cancelled = false;
|
|
1187
|
+
let attempts = 0;
|
|
1188
|
+
const trySnap = () => {
|
|
1189
|
+
if (cancelled) return;
|
|
1190
|
+
const ref2 = sheetRef.current;
|
|
1191
|
+
if (ref2 && ref2.snapPoints.length > 0) {
|
|
1192
|
+
ref2.snapTo(currentIndex);
|
|
1193
|
+
return;
|
|
1194
|
+
}
|
|
1195
|
+
attempts += 1;
|
|
1196
|
+
if (attempts > 60) return;
|
|
1197
|
+
requestAnimationFrame(trySnap);
|
|
1198
|
+
};
|
|
1199
|
+
trySnap();
|
|
1200
|
+
return () => {
|
|
1201
|
+
cancelled = true;
|
|
1202
|
+
};
|
|
1203
|
+
}, [currentIndex]);
|
|
1204
|
+
const handleSnap = useCallback(
|
|
1205
|
+
(index) => {
|
|
1206
|
+
const label = snapLabels[index] ?? "closed";
|
|
1207
|
+
if (label !== state) onChangeState(label);
|
|
1208
|
+
},
|
|
1209
|
+
[snapLabels, state, onChangeState]
|
|
1210
|
+
);
|
|
1211
|
+
const handleHandleClick = () => {
|
|
1212
|
+
if (state === "closed") {
|
|
1213
|
+
onChangeState("peek");
|
|
1214
|
+
} else if (state === "peek") {
|
|
1215
|
+
onChangeState("full");
|
|
1216
|
+
} else if (state === "auto") {
|
|
1217
|
+
onChangeState("closed");
|
|
1218
|
+
} else {
|
|
1219
|
+
onChangeState("peek");
|
|
1220
|
+
}
|
|
1221
|
+
};
|
|
1222
|
+
const [showScrollTop, setShowScrollTop] = useState2(false);
|
|
1223
|
+
useEffect(() => {
|
|
1224
|
+
const el = scrollRef.current;
|
|
1225
|
+
if (!el) return;
|
|
1226
|
+
const onScroll = () => {
|
|
1227
|
+
setShowScrollTop(
|
|
1228
|
+
state !== "closed" && el.scrollTop > scrollToTopThreshold
|
|
1229
|
+
);
|
|
1230
|
+
};
|
|
1231
|
+
el.addEventListener("scroll", onScroll);
|
|
1232
|
+
return () => el.removeEventListener("scroll", onScroll);
|
|
1233
|
+
}, [state, scrollToTopThreshold]);
|
|
1234
|
+
useEffect(() => {
|
|
1235
|
+
if (state === "closed") setShowScrollTop(false);
|
|
1236
|
+
}, [state]);
|
|
1237
|
+
const dragDisabled = !enableTouchDrag;
|
|
1238
|
+
return /* @__PURE__ */ jsxs5(Fragment2, { children: [
|
|
1239
|
+
/* @__PURE__ */ jsx7("style", { children: `
|
|
1240
|
+
.no-scrollbar { -ms-overflow-style: none; scrollbar-width: none; }
|
|
1241
|
+
.no-scrollbar::-webkit-scrollbar { display: none; }
|
|
1242
|
+
` }),
|
|
1243
|
+
/* @__PURE__ */ jsxs5(
|
|
1244
|
+
Sheet2,
|
|
1245
|
+
{
|
|
1246
|
+
disableDismiss: true,
|
|
1247
|
+
disableDrag: dragDisabled,
|
|
1248
|
+
dragVelocityThreshold: SHEET_DRAG_VELOCITY_THRESHOLD,
|
|
1249
|
+
initialSnap: currentIndex,
|
|
1250
|
+
isOpen: true,
|
|
1251
|
+
onClose: () => onChangeState("closed"),
|
|
1252
|
+
onSnap: handleSnap,
|
|
1253
|
+
ref: sheetRef,
|
|
1254
|
+
snapPoints,
|
|
1255
|
+
tweenConfig: SHEET_TWEEN_CONFIG,
|
|
1256
|
+
children: [
|
|
1257
|
+
/* @__PURE__ */ jsxs5(
|
|
1258
|
+
Sheet2.Container,
|
|
1259
|
+
{
|
|
1260
|
+
className: "!bg-zinc-950/85 !backdrop-blur-md !border !border-white/10 !border-b-0 !rounded-t-2xl !shadow-2xl ",
|
|
1261
|
+
style: { paddingBottom: safeAreaInsets.bottom },
|
|
1262
|
+
children: [
|
|
1263
|
+
handleVisible && /* @__PURE__ */ jsx7(
|
|
1264
|
+
Sheet2.Header,
|
|
1265
|
+
{
|
|
1266
|
+
className: "!bg-transparent cursor-pointer hover:!bg-white/5 transition-colors",
|
|
1267
|
+
onClick: handleHandleClick,
|
|
1268
|
+
ref: headerRef
|
|
1269
|
+
}
|
|
1270
|
+
),
|
|
1271
|
+
/* @__PURE__ */ jsxs5(
|
|
1272
|
+
Sheet2.Content,
|
|
1273
|
+
{
|
|
1274
|
+
className: "!bg-transparent",
|
|
1275
|
+
disableDrag: (info) => dragDisabled || info.scrollPosition === "middle",
|
|
1276
|
+
disableScroll: (info) => !dragDisabled && info.currentSnap !== snapPoints.length - 1,
|
|
1277
|
+
scrollClassName: "no-scrollbar",
|
|
1278
|
+
scrollRef,
|
|
1279
|
+
children: [
|
|
1280
|
+
/* @__PURE__ */ jsx7("div", { className: "px-4 pb-4 pt-2 relative", ref: contentWrapperRef, children: menuContent ? menuContent : /* @__PURE__ */ jsx7("div", { className: "flex flex-col gap-1", children: menuItems.map((item) => /* @__PURE__ */ jsxs5(
|
|
1281
|
+
Button,
|
|
1282
|
+
{
|
|
1283
|
+
className: `flex items-center gap-3 w-full py-3 px-3.5 rounded-xl text-left cursor-pointer transition-all duration-150 justify-start hover:bg-white/5 hover:text-white active:bg-white/10 text-white ${item.disabled ? "opacity-45 cursor-not-allowed pointer-events-none" : ""}`,
|
|
1284
|
+
disabled: item.disabled,
|
|
1285
|
+
onClick: () => {
|
|
1286
|
+
if (!item.disabled) {
|
|
1287
|
+
item.onPress();
|
|
1288
|
+
onChangeState("closed");
|
|
1289
|
+
}
|
|
1290
|
+
},
|
|
1291
|
+
variant: "ghost",
|
|
1292
|
+
children: [
|
|
1293
|
+
/* @__PURE__ */ jsxs5("div", { className: "relative flex items-center justify-center w-8 h-8 rounded-lg bg-white/5 text-zinc-300", children: [
|
|
1294
|
+
item.icon,
|
|
1295
|
+
item.badge !== void 0 && /* @__PURE__ */ jsx7("span", { className: "absolute -top-1 -right-1 bg-cyan-500 text-black text-[9px] font-extrabold min-w-[15px] h-3.5 rounded-full flex items-center justify-center px-1 border border-zinc-950 shadow", children: item.badge })
|
|
1296
|
+
] }),
|
|
1297
|
+
/* @__PURE__ */ jsx7("span", { className: "text-sm font-medium tracking-wide", children: item.label })
|
|
1298
|
+
]
|
|
1299
|
+
},
|
|
1300
|
+
item.id
|
|
1301
|
+
)) }) }),
|
|
1302
|
+
showScrollToTopButton && showScrollTop && /* @__PURE__ */ jsx7(
|
|
1303
|
+
Button,
|
|
1304
|
+
{
|
|
1305
|
+
className: "absolute bottom-4 right-6 z-50 flex items-center justify-center w-10 h-10 rounded-full bg-cyan-500 hover:bg-cyan-400 active:scale-95 text-black hover:text-black shadow-lg shadow-cyan-500/25 transition-all duration-200 cursor-pointer p-0!",
|
|
1306
|
+
onClick: () => {
|
|
1307
|
+
scrollRef.current?.scrollTo({ behavior: "smooth", top: 0 });
|
|
1308
|
+
},
|
|
1309
|
+
variant: "ghost",
|
|
1310
|
+
children: /* @__PURE__ */ jsx7(
|
|
1311
|
+
"svg",
|
|
1312
|
+
{
|
|
1313
|
+
fill: "none",
|
|
1314
|
+
height: "20",
|
|
1315
|
+
stroke: "currentColor",
|
|
1316
|
+
strokeLinecap: "round",
|
|
1317
|
+
strokeLinejoin: "round",
|
|
1318
|
+
strokeWidth: "2.5",
|
|
1319
|
+
viewBox: "0 0 24 24",
|
|
1320
|
+
width: "20",
|
|
1321
|
+
xmlns: "http://www.w3.org/2000/svg",
|
|
1322
|
+
children: /* @__PURE__ */ jsx7("polyline", { points: "18 15 12 9 6 15" })
|
|
1323
|
+
}
|
|
1324
|
+
)
|
|
1325
|
+
}
|
|
1326
|
+
)
|
|
1327
|
+
]
|
|
1328
|
+
}
|
|
1329
|
+
)
|
|
1330
|
+
]
|
|
1331
|
+
}
|
|
1332
|
+
),
|
|
1333
|
+
/* @__PURE__ */ jsx7(
|
|
1334
|
+
DrawerBackdrop,
|
|
1335
|
+
{
|
|
1336
|
+
active: state === "full" || state === "auto",
|
|
1337
|
+
onTap: () => onChangeState("closed"),
|
|
1338
|
+
output: backdropOutput
|
|
1339
|
+
}
|
|
1340
|
+
)
|
|
1341
|
+
]
|
|
1342
|
+
}
|
|
1343
|
+
)
|
|
1344
|
+
] });
|
|
1345
|
+
}
|
|
1346
|
+
);
|
|
1347
|
+
MobileBottomDrawer.displayName = "MobileBottomDrawer";
|
|
1348
|
+
function DrawerBackdrop({
|
|
1349
|
+
active,
|
|
1350
|
+
output,
|
|
1351
|
+
onTap
|
|
1352
|
+
}) {
|
|
1353
|
+
const { y, snapPoints } = Sheet2.useContext();
|
|
1354
|
+
const opacity = useTransform(y, (value) => {
|
|
1355
|
+
if (snapPoints.length === 0 || output.length !== snapPoints.length) {
|
|
1356
|
+
return 0;
|
|
1357
|
+
}
|
|
1358
|
+
const mix = interpolate(
|
|
1359
|
+
snapPoints.map((point) => point.snapValueY),
|
|
1360
|
+
output
|
|
1361
|
+
);
|
|
1362
|
+
return mix(value) * 0.45;
|
|
1363
|
+
});
|
|
1364
|
+
return /* @__PURE__ */ jsx7(
|
|
1365
|
+
Sheet2.Backdrop,
|
|
1366
|
+
{
|
|
1367
|
+
className: "!bg-black !backdrop-blur-[1px]",
|
|
1368
|
+
onTap: active ? onTap : void 0,
|
|
1369
|
+
style: { opacity }
|
|
1370
|
+
}
|
|
1371
|
+
);
|
|
1372
|
+
}
|
|
1373
|
+
|
|
1374
|
+
// src/components/Map/MapContext.tsx
|
|
1375
|
+
import {
|
|
1376
|
+
createContext as createContext2,
|
|
1377
|
+
useCallback as useCallback2,
|
|
1378
|
+
useContext as useContext2,
|
|
1379
|
+
useMemo as useMemo2,
|
|
1380
|
+
useRef as useRef3,
|
|
1381
|
+
useState as useState3
|
|
1382
|
+
} from "react";
|
|
1383
|
+
import { jsx as jsx8 } from "react/jsx-runtime";
|
|
1529
1384
|
var MapControlsContext = createContext2(
|
|
1530
1385
|
null
|
|
1531
1386
|
);
|
|
1532
1387
|
var SDKMapProvider = ({
|
|
1533
1388
|
children
|
|
1534
1389
|
}) => {
|
|
1535
|
-
const [isFollowing, setIsFollowing] =
|
|
1536
|
-
const [bearing, setBearingState] =
|
|
1537
|
-
const [pitch, setPitchState] =
|
|
1538
|
-
const [drawerState, setDrawerStateInternal] =
|
|
1539
|
-
const drawerContentRef =
|
|
1540
|
-
const setDrawerState =
|
|
1390
|
+
const [isFollowing, setIsFollowing] = useState3(true);
|
|
1391
|
+
const [bearing, setBearingState] = useState3(0);
|
|
1392
|
+
const [pitch, setPitchState] = useState3(0);
|
|
1393
|
+
const [drawerState, setDrawerStateInternal] = useState3("closed");
|
|
1394
|
+
const drawerContentRef = useRef3(null);
|
|
1395
|
+
const setDrawerState = useCallback2((val) => {
|
|
1541
1396
|
setDrawerStateInternal(val);
|
|
1542
1397
|
}, []);
|
|
1543
|
-
const [drawerHandleVisible, setDrawerHandleVisibleState] =
|
|
1544
|
-
const setDrawerHandleVisible =
|
|
1398
|
+
const [drawerHandleVisible, setDrawerHandleVisibleState] = useState3(true);
|
|
1399
|
+
const setDrawerHandleVisible = useCallback2((val) => {
|
|
1545
1400
|
setDrawerHandleVisibleState((prev) => prev === val ? prev : val);
|
|
1546
1401
|
}, []);
|
|
1547
|
-
const [hasControls, setHasControlsState] =
|
|
1548
|
-
const setHasControls =
|
|
1402
|
+
const [hasControls, setHasControlsState] = useState3(false);
|
|
1403
|
+
const setHasControls = useCallback2((val) => {
|
|
1549
1404
|
setHasControlsState((prev) => prev === val ? prev : val);
|
|
1550
1405
|
}, []);
|
|
1551
|
-
const [etaData, setEtaDataState] =
|
|
1552
|
-
const setEtaData =
|
|
1406
|
+
const [etaData, setEtaDataState] = useState3(void 0);
|
|
1407
|
+
const setEtaData = useCallback2((newData) => {
|
|
1553
1408
|
setEtaDataState((prev) => {
|
|
1554
1409
|
if (!prev && !newData) return prev;
|
|
1555
1410
|
if (!prev || !newData) return newData;
|
|
@@ -1559,29 +1414,29 @@ var SDKMapProvider = ({
|
|
|
1559
1414
|
return newData;
|
|
1560
1415
|
});
|
|
1561
1416
|
}, []);
|
|
1562
|
-
const [insets, setInsetsState] =
|
|
1417
|
+
const [insets, setInsetsState] = useState3({
|
|
1563
1418
|
bottom: 0,
|
|
1564
1419
|
left: 0,
|
|
1565
1420
|
right: 0,
|
|
1566
1421
|
top: 0
|
|
1567
1422
|
});
|
|
1568
|
-
const setInsets =
|
|
1423
|
+
const setInsets = useCallback2((newInsets) => {
|
|
1569
1424
|
setInsetsState((prev) => ({ ...prev, ...newInsets }));
|
|
1570
1425
|
}, []);
|
|
1571
|
-
const centerCallbackRef =
|
|
1572
|
-
const resetBearingCallbackRef =
|
|
1573
|
-
const flyToCallbackRef =
|
|
1574
|
-
const centerOnUser =
|
|
1426
|
+
const centerCallbackRef = useRef3(null);
|
|
1427
|
+
const resetBearingCallbackRef = useRef3(null);
|
|
1428
|
+
const flyToCallbackRef = useRef3(null);
|
|
1429
|
+
const centerOnUser = useCallback2((params) => {
|
|
1575
1430
|
if (centerCallbackRef.current) {
|
|
1576
1431
|
centerCallbackRef.current(params);
|
|
1577
1432
|
}
|
|
1578
1433
|
}, []);
|
|
1579
|
-
const resetBearing =
|
|
1434
|
+
const resetBearing = useCallback2((params) => {
|
|
1580
1435
|
if (resetBearingCallbackRef.current) {
|
|
1581
1436
|
resetBearingCallbackRef.current(params);
|
|
1582
1437
|
}
|
|
1583
1438
|
}, []);
|
|
1584
|
-
const flyTo =
|
|
1439
|
+
const flyTo = useCallback2(
|
|
1585
1440
|
(coords, params) => {
|
|
1586
1441
|
if (flyToCallbackRef.current) {
|
|
1587
1442
|
flyToCallbackRef.current(coords, params);
|
|
@@ -1589,31 +1444,31 @@ var SDKMapProvider = ({
|
|
|
1589
1444
|
},
|
|
1590
1445
|
[]
|
|
1591
1446
|
);
|
|
1592
|
-
const _registerCenterCallback =
|
|
1447
|
+
const _registerCenterCallback = useCallback2(
|
|
1593
1448
|
(cb) => {
|
|
1594
1449
|
centerCallbackRef.current = cb;
|
|
1595
1450
|
},
|
|
1596
1451
|
[]
|
|
1597
1452
|
);
|
|
1598
|
-
const _registerResetBearingCallback =
|
|
1453
|
+
const _registerResetBearingCallback = useCallback2(
|
|
1599
1454
|
(cb) => {
|
|
1600
1455
|
resetBearingCallbackRef.current = cb;
|
|
1601
1456
|
},
|
|
1602
1457
|
[]
|
|
1603
1458
|
);
|
|
1604
|
-
const _registerFlyToCallback =
|
|
1459
|
+
const _registerFlyToCallback = useCallback2(
|
|
1605
1460
|
(cb) => {
|
|
1606
1461
|
flyToCallbackRef.current = cb;
|
|
1607
1462
|
},
|
|
1608
1463
|
[]
|
|
1609
1464
|
);
|
|
1610
|
-
const setBearing =
|
|
1465
|
+
const setBearing = useCallback2((b) => {
|
|
1611
1466
|
setBearingState(b);
|
|
1612
1467
|
}, []);
|
|
1613
|
-
const setPitch =
|
|
1468
|
+
const setPitch = useCallback2((p) => {
|
|
1614
1469
|
setPitchState(p);
|
|
1615
1470
|
}, []);
|
|
1616
|
-
const contextValue =
|
|
1471
|
+
const contextValue = useMemo2(
|
|
1617
1472
|
() => ({
|
|
1618
1473
|
_registerCenterCallback,
|
|
1619
1474
|
_registerFlyToCallback,
|
|
@@ -1663,7 +1518,7 @@ var SDKMapProvider = ({
|
|
|
1663
1518
|
setInsets
|
|
1664
1519
|
]
|
|
1665
1520
|
);
|
|
1666
|
-
return /* @__PURE__ */
|
|
1521
|
+
return /* @__PURE__ */ jsx8(MapControlsContext.Provider, { value: contextValue, children });
|
|
1667
1522
|
};
|
|
1668
1523
|
var useMapControls = () => {
|
|
1669
1524
|
const context = useContext2(MapControlsContext);
|
|
@@ -1674,8 +1529,8 @@ var useMapControls = () => {
|
|
|
1674
1529
|
};
|
|
1675
1530
|
|
|
1676
1531
|
// src/components/Map/components/MapControls.tsx
|
|
1677
|
-
import { useCallback as
|
|
1678
|
-
import { Fragment as
|
|
1532
|
+
import { useCallback as useCallback3, useContext as useContext3, useEffect as useEffect2, useRef as useRef4, useState as useState4 } from "react";
|
|
1533
|
+
import { Fragment as Fragment3, jsx as jsx9, jsxs as jsxs6 } from "react/jsx-runtime";
|
|
1679
1534
|
var resolveHeightToPixels2 = (height, containerHeight) => {
|
|
1680
1535
|
if (typeof height === "number") {
|
|
1681
1536
|
return height;
|
|
@@ -1713,7 +1568,7 @@ var MapControls = ({
|
|
|
1713
1568
|
}) => {
|
|
1714
1569
|
const mapContext = useContext3(MapControlsContext);
|
|
1715
1570
|
const contextRef = mapContext?.drawerContentRef;
|
|
1716
|
-
const mergedRef =
|
|
1571
|
+
const mergedRef = useCallback3(
|
|
1717
1572
|
(node) => {
|
|
1718
1573
|
if (drawerContentRef) {
|
|
1719
1574
|
if (typeof drawerContentRef === "function") {
|
|
@@ -1728,11 +1583,11 @@ var MapControls = ({
|
|
|
1728
1583
|
},
|
|
1729
1584
|
[drawerContentRef, contextRef]
|
|
1730
1585
|
);
|
|
1731
|
-
const [localDrawerState, setLocalDrawerState] =
|
|
1586
|
+
const [localDrawerState, setLocalDrawerState] = useState4(
|
|
1732
1587
|
defaultState ?? "closed"
|
|
1733
1588
|
);
|
|
1734
1589
|
const drawerState = mapContext ? mapContext.drawerState : localDrawerState;
|
|
1735
|
-
const setDrawerState =
|
|
1590
|
+
const setDrawerState = useCallback3(
|
|
1736
1591
|
(state) => {
|
|
1737
1592
|
if (mapContext) {
|
|
1738
1593
|
mapContext.setDrawerState(state);
|
|
@@ -1747,9 +1602,9 @@ var MapControls = ({
|
|
|
1747
1602
|
mapContext.setDrawerState(defaultState);
|
|
1748
1603
|
}
|
|
1749
1604
|
}, []);
|
|
1750
|
-
const [side, setSide] =
|
|
1751
|
-
const containerRef =
|
|
1752
|
-
const [mapHeight, setMapHeight] =
|
|
1605
|
+
const [side, setSide] = useState4("left");
|
|
1606
|
+
const containerRef = useRef4(null);
|
|
1607
|
+
const [mapHeight, setMapHeight] = useState4(600);
|
|
1753
1608
|
useEffect2(() => {
|
|
1754
1609
|
const parent = containerRef.current?.parentElement;
|
|
1755
1610
|
if (!parent) return;
|
|
@@ -1788,9 +1643,7 @@ var MapControls = ({
|
|
|
1788
1643
|
};
|
|
1789
1644
|
const mapPitch = mapContext ? mapContext.pitch : 0;
|
|
1790
1645
|
const resolvedEtaData = etaData !== void 0 ? etaData : mapContext?.etaData;
|
|
1791
|
-
const [
|
|
1792
|
-
const [currentTouchY, setCurrentTouchY] = useState3(null);
|
|
1793
|
-
const [autoContentPx, setAutoContentPx] = useState3(0);
|
|
1646
|
+
const [autoContentPx, setAutoContentPx] = useState4(0);
|
|
1794
1647
|
useEffect2(() => {
|
|
1795
1648
|
if (typeof window === "undefined") return;
|
|
1796
1649
|
const checkLayout = () => {
|
|
@@ -1808,8 +1661,8 @@ var MapControls = ({
|
|
|
1808
1661
|
window.addEventListener("resize", checkLayout);
|
|
1809
1662
|
return () => window.removeEventListener("resize", checkLayout);
|
|
1810
1663
|
}, [drawerSide]);
|
|
1811
|
-
const isDragging =
|
|
1812
|
-
const
|
|
1664
|
+
const isDragging = false;
|
|
1665
|
+
const clampedDragOffset = 0;
|
|
1813
1666
|
const fullPx = resolveHeightToPixels2(drawerFullHeight || "85%", mapHeight);
|
|
1814
1667
|
const peekPx = resolveHeightToPixels2(drawerPeekHeight || "15%", mapHeight);
|
|
1815
1668
|
const autoMaxPx = resolveHeightToPixels2(
|
|
@@ -1819,22 +1672,6 @@ var MapControls = ({
|
|
|
1819
1672
|
const autoPx = Math.min(autoMaxPx, autoContentPx);
|
|
1820
1673
|
const bottomInset = mapContext?.insets.bottom || 0;
|
|
1821
1674
|
const handleVisible = mapContext ? mapContext.drawerHandleVisible : true;
|
|
1822
|
-
const closedPx = (handleVisible ? 32 : 0) + (drawerState === "closed" ? bottomInset : 0);
|
|
1823
|
-
let clampedDragOffset = dragOffset;
|
|
1824
|
-
if (drawerState === "full") {
|
|
1825
|
-
clampedDragOffset = Math.max(0, Math.min(fullPx - closedPx, dragOffset));
|
|
1826
|
-
} else if (drawerState === "peek") {
|
|
1827
|
-
clampedDragOffset = Math.max(
|
|
1828
|
-
-(fullPx - peekPx),
|
|
1829
|
-
// up to full
|
|
1830
|
-
Math.min(peekPx - closedPx, dragOffset)
|
|
1831
|
-
// down to closed
|
|
1832
|
-
);
|
|
1833
|
-
} else if (drawerState === "closed") {
|
|
1834
|
-
clampedDragOffset = Math.min(0, Math.max(-(fullPx - closedPx), dragOffset));
|
|
1835
|
-
} else if (drawerState === "auto") {
|
|
1836
|
-
clampedDragOffset = Math.max(0, dragOffset);
|
|
1837
|
-
}
|
|
1838
1675
|
let baseHeight = handleVisible ? 32 : 0;
|
|
1839
1676
|
if (drawerState === "peek") {
|
|
1840
1677
|
baseHeight = peekPx;
|
|
@@ -1843,7 +1680,7 @@ var MapControls = ({
|
|
|
1843
1680
|
} else if (drawerState === "auto") {
|
|
1844
1681
|
baseHeight = autoPx;
|
|
1845
1682
|
}
|
|
1846
|
-
const currentDrawerHeight = baseHeight
|
|
1683
|
+
const currentDrawerHeight = baseHeight;
|
|
1847
1684
|
const startFadeHeight = peekPx + 20;
|
|
1848
1685
|
const endFadeHeight = peekPx + (fullPx - peekPx) * 0.35;
|
|
1849
1686
|
let etaOpacity = 1;
|
|
@@ -1863,22 +1700,17 @@ var MapControls = ({
|
|
|
1863
1700
|
etaOpacity = drawerState === "full" ? 0 : 1;
|
|
1864
1701
|
etaBottomStyle = `calc(1rem + ${bottomInset}px)`;
|
|
1865
1702
|
}
|
|
1866
|
-
return /* @__PURE__ */
|
|
1867
|
-
/* @__PURE__ */
|
|
1868
|
-
/* @__PURE__ */
|
|
1869
|
-
|
|
1703
|
+
return /* @__PURE__ */ jsxs6(Fragment3, { children: [
|
|
1704
|
+
/* @__PURE__ */ jsx9("div", { ref: containerRef, style: { display: "none" } }),
|
|
1705
|
+
side === "bottom" ? /* @__PURE__ */ jsx9(
|
|
1706
|
+
MobileBottomDrawer,
|
|
1870
1707
|
{
|
|
1871
|
-
clampedDragOffset,
|
|
1872
1708
|
containerHeight: mapHeight,
|
|
1873
|
-
currentTouchY,
|
|
1874
1709
|
drawerAutoMaxHeight,
|
|
1875
1710
|
drawerFullHeight,
|
|
1876
1711
|
drawerPeekHeight,
|
|
1877
1712
|
enableTouchDrag,
|
|
1878
|
-
etaBarHeight,
|
|
1879
|
-
etaData: resolvedEtaData,
|
|
1880
1713
|
handleVisible,
|
|
1881
|
-
isDragging,
|
|
1882
1714
|
menuContent: children || menuContent,
|
|
1883
1715
|
menuItems,
|
|
1884
1716
|
onAutoContentHeightChange: setAutoContentPx,
|
|
@@ -1886,15 +1718,22 @@ var MapControls = ({
|
|
|
1886
1718
|
ref: mergedRef,
|
|
1887
1719
|
safeAreaInsets: mapContext?.insets,
|
|
1888
1720
|
scrollToTopThreshold,
|
|
1889
|
-
setCurrentTouchY,
|
|
1890
|
-
setTouchStartY,
|
|
1891
1721
|
showScrollToTopButton,
|
|
1892
|
-
|
|
1893
|
-
|
|
1894
|
-
|
|
1722
|
+
state: drawerState
|
|
1723
|
+
}
|
|
1724
|
+
) : /* @__PURE__ */ jsx9(
|
|
1725
|
+
MapDrawer,
|
|
1726
|
+
{
|
|
1727
|
+
menuContent: children || menuContent,
|
|
1728
|
+
menuItems,
|
|
1729
|
+
onChangeState: setDrawerState,
|
|
1730
|
+
ref: mergedRef,
|
|
1731
|
+
scrollToTopThreshold,
|
|
1732
|
+
showScrollToTopButton,
|
|
1733
|
+
state: drawerState
|
|
1895
1734
|
}
|
|
1896
1735
|
),
|
|
1897
|
-
/* @__PURE__ */
|
|
1736
|
+
/* @__PURE__ */ jsx9(
|
|
1898
1737
|
MapRightControls,
|
|
1899
1738
|
{
|
|
1900
1739
|
bottomOffset: controlsBottomOffset,
|
|
@@ -1917,7 +1756,7 @@ var MapControls = ({
|
|
|
1917
1756
|
side
|
|
1918
1757
|
}
|
|
1919
1758
|
),
|
|
1920
|
-
resolvedEtaData && /* @__PURE__ */
|
|
1759
|
+
resolvedEtaData && /* @__PURE__ */ jsx9(
|
|
1921
1760
|
MapEtaPanel,
|
|
1922
1761
|
{
|
|
1923
1762
|
etaData: resolvedEtaData,
|
|
@@ -1936,9 +1775,9 @@ var MapControls = ({
|
|
|
1936
1775
|
|
|
1937
1776
|
// src/components/Map/components/MapMenu.tsx
|
|
1938
1777
|
import { useContext as useContext4 } from "react";
|
|
1939
|
-
import { jsx as
|
|
1778
|
+
import { jsx as jsx10, jsxs as jsxs7 } from "react/jsx-runtime";
|
|
1940
1779
|
var MapMenu = ({ children }) => {
|
|
1941
|
-
return /* @__PURE__ */
|
|
1780
|
+
return /* @__PURE__ */ jsx10("div", { className: "flex flex-col gap-1.5", children });
|
|
1942
1781
|
};
|
|
1943
1782
|
var MapMenuItem = ({
|
|
1944
1783
|
id,
|
|
@@ -1957,7 +1796,7 @@ var MapMenuItem = ({
|
|
|
1957
1796
|
context.setDrawerState("closed");
|
|
1958
1797
|
}
|
|
1959
1798
|
};
|
|
1960
|
-
return /* @__PURE__ */
|
|
1799
|
+
return /* @__PURE__ */ jsxs7(
|
|
1961
1800
|
"button",
|
|
1962
1801
|
{
|
|
1963
1802
|
className: `flex items-center gap-3 w-full py-3 px-3.5 rounded-xl text-left cursor-pointer transition-all duration-150 ${disabled ? "opacity-45 cursor-not-allowed pointer-events-none" : "hover:bg-white/5 active:bg-white/10 text-white"}`,
|
|
@@ -1965,12 +1804,12 @@ var MapMenuItem = ({
|
|
|
1965
1804
|
onClick: handleClick,
|
|
1966
1805
|
type: "button",
|
|
1967
1806
|
children: [
|
|
1968
|
-
icon && /* @__PURE__ */
|
|
1807
|
+
icon && /* @__PURE__ */ jsxs7("div", { className: "relative flex items-center justify-center w-8 h-8 rounded-lg bg-white/5 text-zinc-300", children: [
|
|
1969
1808
|
icon,
|
|
1970
|
-
badge !== void 0 && /* @__PURE__ */
|
|
1809
|
+
badge !== void 0 && /* @__PURE__ */ jsx10("span", { className: "absolute -top-1 -right-1 bg-cyan-500 text-black text-[9px] font-extrabold min-w-[15px] h-3.5 rounded-full flex items-center justify-center px-1 border border-zinc-950 shadow", children: badge })
|
|
1971
1810
|
] }),
|
|
1972
|
-
/* @__PURE__ */
|
|
1973
|
-
/* @__PURE__ */
|
|
1811
|
+
/* @__PURE__ */ jsxs7("div", { className: "flex-1 flex flex-col justify-center", children: [
|
|
1812
|
+
/* @__PURE__ */ jsx10("span", { className: "text-sm font-medium tracking-wide flex-1", children: label }),
|
|
1974
1813
|
children
|
|
1975
1814
|
] })
|
|
1976
1815
|
]
|
|
@@ -1984,7 +1823,7 @@ var MapMenuTitle = ({
|
|
|
1984
1823
|
showDivider = true,
|
|
1985
1824
|
className = ""
|
|
1986
1825
|
}) => {
|
|
1987
|
-
return /* @__PURE__ */
|
|
1826
|
+
return /* @__PURE__ */ jsx10(
|
|
1988
1827
|
"div",
|
|
1989
1828
|
{
|
|
1990
1829
|
className: `flex items-center justify-between pb-3 first:mt-0 px-3.5 ${className} ${showDivider ? "border-b border-white/10 mb-2 mt-4" : ""}`,
|
|
@@ -1996,14 +1835,14 @@ MapMenuTitle.displayName = "MapMenuTitle";
|
|
|
1996
1835
|
var MapMenuDivider = ({
|
|
1997
1836
|
className = ""
|
|
1998
1837
|
}) => {
|
|
1999
|
-
return /* @__PURE__ */
|
|
1838
|
+
return /* @__PURE__ */ jsx10("div", { className: `h-[1px] bg-white/10 my-3 mx-3.5 ${className}` });
|
|
2000
1839
|
};
|
|
2001
1840
|
MapMenuDivider.displayName = "MapMenuDivider";
|
|
2002
1841
|
var MapMenuFooter = ({
|
|
2003
1842
|
children,
|
|
2004
1843
|
className = ""
|
|
2005
1844
|
}) => {
|
|
2006
|
-
return /* @__PURE__ */
|
|
1845
|
+
return /* @__PURE__ */ jsx10(
|
|
2007
1846
|
"div",
|
|
2008
1847
|
{
|
|
2009
1848
|
className: `mt-auto pt-4 border-t border-white/10 px-3.5 text-xs text-zinc-500 font-medium ${className}`,
|
|
@@ -2031,7 +1870,7 @@ var GlobalEvent = /* @__PURE__ */ ((GlobalEvent2) => {
|
|
|
2031
1870
|
})(GlobalEvent || {});
|
|
2032
1871
|
|
|
2033
1872
|
// src/components/Map/hooks/useUserLocation.ts
|
|
2034
|
-
import { useEffect as useEffect3, useState as
|
|
1873
|
+
import { useEffect as useEffect3, useState as useState5 } from "react";
|
|
2035
1874
|
var LERP_FACTOR = 0.12;
|
|
2036
1875
|
var EMPTY_STATE = {
|
|
2037
1876
|
accuracy: null,
|
|
@@ -2152,7 +1991,7 @@ function stopSharedStream() {
|
|
|
2152
1991
|
currentInterpolated = { coords: null, heading: null };
|
|
2153
1992
|
}
|
|
2154
1993
|
var useUserLocation = () => {
|
|
2155
|
-
const [locationState, setLocationState] =
|
|
1994
|
+
const [locationState, setLocationState] = useState5(getSnapshot);
|
|
2156
1995
|
useEffect3(() => {
|
|
2157
1996
|
refCount++;
|
|
2158
1997
|
if (refCount === 1) {
|
|
@@ -2173,7 +2012,7 @@ var useUserLocation = () => {
|
|
|
2173
2012
|
};
|
|
2174
2013
|
|
|
2175
2014
|
// src/components/Map/hooks/useLiveRouting.ts
|
|
2176
|
-
import { useCallback as
|
|
2015
|
+
import { useCallback as useCallback4, useEffect as useEffect4, useMemo as useMemo3, useRef as useRef5, useState as useState6 } from "react";
|
|
2177
2016
|
var useLiveRouting = ({
|
|
2178
2017
|
origin: manualOrigin,
|
|
2179
2018
|
destination,
|
|
@@ -2182,19 +2021,19 @@ var useLiveRouting = ({
|
|
|
2182
2021
|
enabled = true,
|
|
2183
2022
|
initialMode = "preview"
|
|
2184
2023
|
}) => {
|
|
2185
|
-
const [route, setRoute] =
|
|
2186
|
-
const [totalDistance, setTotalDistance] =
|
|
2187
|
-
const [isCalculating, setIsCalculating] =
|
|
2188
|
-
const [error, setError] =
|
|
2189
|
-
const [mode, setMode] =
|
|
2024
|
+
const [route, setRoute] = useState6(null);
|
|
2025
|
+
const [totalDistance, setTotalDistance] = useState6(null);
|
|
2026
|
+
const [isCalculating, setIsCalculating] = useState6(false);
|
|
2027
|
+
const [error, setError] = useState6(null);
|
|
2028
|
+
const [mode, setMode] = useState6(initialMode);
|
|
2190
2029
|
const userLocationState = useUserLocation();
|
|
2191
2030
|
const calculationOrigin = manualOrigin || userLocationState.coords;
|
|
2192
2031
|
const trackingLocation = userLocationState.coords || manualOrigin;
|
|
2193
|
-
const lastCalcOrigin =
|
|
2194
|
-
const lastCalcDest =
|
|
2195
|
-
const isRequestInProgress =
|
|
2196
|
-
const lastResetDestKey =
|
|
2197
|
-
const getDistance =
|
|
2032
|
+
const lastCalcOrigin = useRef5(null);
|
|
2033
|
+
const lastCalcDest = useRef5(null);
|
|
2034
|
+
const isRequestInProgress = useRef5(false);
|
|
2035
|
+
const lastResetDestKey = useRef5(null);
|
|
2036
|
+
const getDistance = useCallback4(
|
|
2198
2037
|
(p1, p2) => {
|
|
2199
2038
|
const R = 6371e3;
|
|
2200
2039
|
const \u03C61 = p1[1] * Math.PI / 180;
|
|
@@ -2207,7 +2046,7 @@ var useLiveRouting = ({
|
|
|
2207
2046
|
},
|
|
2208
2047
|
[]
|
|
2209
2048
|
);
|
|
2210
|
-
const currentDistanceMeters =
|
|
2049
|
+
const currentDistanceMeters = useMemo3(() => {
|
|
2211
2050
|
if (!trackingLocation || !route || route.geometry.coordinates.length < 2) {
|
|
2212
2051
|
if (trackingLocation && destination) {
|
|
2213
2052
|
return getDistance(trackingLocation, destination);
|
|
@@ -2234,7 +2073,7 @@ var useLiveRouting = ({
|
|
|
2234
2073
|
}
|
|
2235
2074
|
return dist;
|
|
2236
2075
|
}, [trackingLocation, route, destination, getDistance]);
|
|
2237
|
-
const calculate =
|
|
2076
|
+
const calculate = useCallback4(
|
|
2238
2077
|
async (origin, dest, isNewDest) => {
|
|
2239
2078
|
if (isRequestInProgress.current) return;
|
|
2240
2079
|
isRequestInProgress.current = true;
|
|
@@ -2325,9 +2164,9 @@ var useLiveRouting = ({
|
|
|
2325
2164
|
};
|
|
2326
2165
|
};
|
|
2327
2166
|
var useRoute = (origin, destination, profile = "driving") => {
|
|
2328
|
-
const [route, setRoute] =
|
|
2329
|
-
const [isCalculating, setIsCalculating] =
|
|
2330
|
-
const [error, setError] =
|
|
2167
|
+
const [route, setRoute] = useState6(null);
|
|
2168
|
+
const [isCalculating, setIsCalculating] = useState6(false);
|
|
2169
|
+
const [error, setError] = useState6(null);
|
|
2331
2170
|
useEffect4(() => {
|
|
2332
2171
|
if (!origin || !destination) {
|
|
2333
2172
|
setRoute(null);
|
|
@@ -2355,11 +2194,11 @@ var useRoute = (origin, destination, profile = "driving") => {
|
|
|
2355
2194
|
};
|
|
2356
2195
|
|
|
2357
2196
|
// src/components/Map/hooks/useJourney.ts
|
|
2358
|
-
import { useCallback as
|
|
2197
|
+
import { useCallback as useCallback5, useEffect as useEffect5, useRef as useRef6, useState as useState7 } from "react";
|
|
2359
2198
|
var useJourney = (options = {}) => {
|
|
2360
2199
|
const { navigation, onAbort, onModeChange } = options;
|
|
2361
|
-
const [progNav, setProgNav] =
|
|
2362
|
-
const [isAborted, setIsAborted] =
|
|
2200
|
+
const [progNav, setProgNav] = useState7(null);
|
|
2201
|
+
const [isAborted, setIsAborted] = useState7(false);
|
|
2363
2202
|
useEffect5(() => {
|
|
2364
2203
|
const unsubCreate = sdk.on("SDK_NAVIGATION_CREATE", (payload) => {
|
|
2365
2204
|
setIsAborted(false);
|
|
@@ -2388,7 +2227,7 @@ var useJourney = (options = {}) => {
|
|
|
2388
2227
|
profile: effectiveOptions?.profile || "driving",
|
|
2389
2228
|
recalculateThreshold: effectiveOptions?.recalculateThreshold || 50
|
|
2390
2229
|
});
|
|
2391
|
-
const prevDest =
|
|
2230
|
+
const prevDest = useRef6(null);
|
|
2392
2231
|
const currentDest = effectiveOptions?.destination;
|
|
2393
2232
|
useEffect5(() => {
|
|
2394
2233
|
if (currentDest && (!prevDest.current || prevDest.current[0] !== currentDest[0] || prevDest.current[1] !== currentDest[1])) {
|
|
@@ -2396,7 +2235,7 @@ var useJourney = (options = {}) => {
|
|
|
2396
2235
|
}
|
|
2397
2236
|
prevDest.current = currentDest;
|
|
2398
2237
|
}, [currentDest]);
|
|
2399
|
-
const onModeChangeRef =
|
|
2238
|
+
const onModeChangeRef = useRef6(onModeChange);
|
|
2400
2239
|
onModeChangeRef.current = onModeChange;
|
|
2401
2240
|
useEffect5(() => {
|
|
2402
2241
|
onModeChangeRef.current?.(internalNav.mode);
|
|
@@ -2420,13 +2259,13 @@ var useJourney = (options = {}) => {
|
|
|
2420
2259
|
(totalDistanceMeters - remainingMeters) / totalDistanceMeters * 100
|
|
2421
2260
|
)
|
|
2422
2261
|
) : 0;
|
|
2423
|
-
const cancel =
|
|
2262
|
+
const cancel = useCallback5(() => {
|
|
2424
2263
|
setIsAborted(true);
|
|
2425
2264
|
setProgNav(null);
|
|
2426
2265
|
sdk.navigation.abort();
|
|
2427
2266
|
if (onAbort) onAbort();
|
|
2428
2267
|
}, [onAbort]);
|
|
2429
|
-
const start =
|
|
2268
|
+
const start = useCallback5(() => {
|
|
2430
2269
|
sdk.navigation.start();
|
|
2431
2270
|
internalNav.start();
|
|
2432
2271
|
}, [internalNav.start]);
|
|
@@ -2448,9 +2287,9 @@ var useJourney = (options = {}) => {
|
|
|
2448
2287
|
};
|
|
2449
2288
|
|
|
2450
2289
|
// src/components/Map/hooks/useTrimmedRoute.ts
|
|
2451
|
-
import { useMemo as
|
|
2290
|
+
import { useMemo as useMemo4 } from "react";
|
|
2452
2291
|
var useTrimmedRoute = (route, userLocation) => {
|
|
2453
|
-
return
|
|
2292
|
+
return useMemo4(() => {
|
|
2454
2293
|
if (!route || !userLocation || route.coordinates.length < 2) return route;
|
|
2455
2294
|
const coords = route.coordinates;
|
|
2456
2295
|
let minDistance = Infinity;
|
|
@@ -2475,7 +2314,7 @@ var useTrimmedRoute = (route, userLocation) => {
|
|
|
2475
2314
|
|
|
2476
2315
|
// src/components/Map/layers/RouteLayer.tsx
|
|
2477
2316
|
import { Layer, Source } from "@vis.gl/react-maplibre";
|
|
2478
|
-
import { jsx as
|
|
2317
|
+
import { jsx as jsx11, jsxs as jsxs8 } from "react/jsx-runtime";
|
|
2479
2318
|
var RouteLayer = ({
|
|
2480
2319
|
geometry,
|
|
2481
2320
|
color = "#3b82f6",
|
|
@@ -2488,8 +2327,8 @@ var RouteLayer = ({
|
|
|
2488
2327
|
properties: {},
|
|
2489
2328
|
type: "Feature"
|
|
2490
2329
|
};
|
|
2491
|
-
return /* @__PURE__ */
|
|
2492
|
-
/* @__PURE__ */
|
|
2330
|
+
return /* @__PURE__ */ jsxs8(Source, { data, id: "sdk-route-source", type: "geojson", children: [
|
|
2331
|
+
/* @__PURE__ */ jsx11(
|
|
2493
2332
|
Layer,
|
|
2494
2333
|
{
|
|
2495
2334
|
id: "sdk-route-layer-casing",
|
|
@@ -2502,7 +2341,7 @@ var RouteLayer = ({
|
|
|
2502
2341
|
type: "line"
|
|
2503
2342
|
}
|
|
2504
2343
|
),
|
|
2505
|
-
/* @__PURE__ */
|
|
2344
|
+
/* @__PURE__ */ jsx11(
|
|
2506
2345
|
Layer,
|
|
2507
2346
|
{
|
|
2508
2347
|
id: "sdk-route-layer",
|
|
@@ -2545,8 +2384,8 @@ var buildGeoCircle = (center, radiusMeters, points = 64) => {
|
|
|
2545
2384
|
|
|
2546
2385
|
// src/components/Map/layers/MockRadiusLayer.tsx
|
|
2547
2386
|
import { Layer as Layer2, Source as Source2 } from "@vis.gl/react-maplibre";
|
|
2548
|
-
import { useMemo as
|
|
2549
|
-
import { jsx as
|
|
2387
|
+
import { useMemo as useMemo5 } from "react";
|
|
2388
|
+
import { jsx as jsx12, jsxs as jsxs9 } from "react/jsx-runtime";
|
|
2550
2389
|
var MockRadiusLayer = ({
|
|
2551
2390
|
center,
|
|
2552
2391
|
radiusMeters,
|
|
@@ -2559,12 +2398,12 @@ var MockRadiusLayer = ({
|
|
|
2559
2398
|
// pastel palette with no neon accents at all).
|
|
2560
2399
|
color = "#e2e8f0"
|
|
2561
2400
|
}) => {
|
|
2562
|
-
const data =
|
|
2401
|
+
const data = useMemo5(
|
|
2563
2402
|
() => buildGeoCircle(center, radiusMeters),
|
|
2564
2403
|
[center, radiusMeters]
|
|
2565
2404
|
);
|
|
2566
|
-
return /* @__PURE__ */
|
|
2567
|
-
/* @__PURE__ */
|
|
2405
|
+
return /* @__PURE__ */ jsxs9(Source2, { data, id: "sdk-mock-radius-source", type: "geojson", children: [
|
|
2406
|
+
/* @__PURE__ */ jsx12(
|
|
2568
2407
|
Layer2,
|
|
2569
2408
|
{
|
|
2570
2409
|
id: "sdk-mock-radius-fill",
|
|
@@ -2575,7 +2414,7 @@ var MockRadiusLayer = ({
|
|
|
2575
2414
|
type: "fill"
|
|
2576
2415
|
}
|
|
2577
2416
|
),
|
|
2578
|
-
/* @__PURE__ */
|
|
2417
|
+
/* @__PURE__ */ jsx12(
|
|
2579
2418
|
Layer2,
|
|
2580
2419
|
{
|
|
2581
2420
|
id: "sdk-mock-radius-outline",
|
|
@@ -2592,8 +2431,8 @@ var MockRadiusLayer = ({
|
|
|
2592
2431
|
|
|
2593
2432
|
// src/components/Map/layers/POILayers.tsx
|
|
2594
2433
|
import { Layer as Layer3, Source as Source3, useMap } from "@vis.gl/react-maplibre";
|
|
2595
|
-
import { useEffect as useEffect6, useMemo as
|
|
2596
|
-
import { jsx as
|
|
2434
|
+
import { useEffect as useEffect6, useMemo as useMemo6, useState as useState8 } from "react";
|
|
2435
|
+
import { jsx as jsx13 } from "react/jsx-runtime";
|
|
2597
2436
|
function createEmojiIcon(emoji, size = 64) {
|
|
2598
2437
|
const canvas = document.createElement("canvas");
|
|
2599
2438
|
canvas.width = size;
|
|
@@ -2606,9 +2445,9 @@ function createEmojiIcon(emoji, size = 64) {
|
|
|
2606
2445
|
return ctx.getImageData(0, 0, size, size);
|
|
2607
2446
|
}
|
|
2608
2447
|
var POILayers = ({ pois }) => {
|
|
2609
|
-
const [loadedImages, setLoadedImages] =
|
|
2448
|
+
const [loadedImages, setLoadedImages] = useState8(0);
|
|
2610
2449
|
const { current: map } = useMap();
|
|
2611
|
-
const glPois =
|
|
2450
|
+
const glPois = useMemo6(
|
|
2612
2451
|
() => pois.filter((p) => !p.displayMode || p.displayMode === "gl"),
|
|
2613
2452
|
[pois]
|
|
2614
2453
|
);
|
|
@@ -2652,7 +2491,7 @@ var POILayers = ({ pois }) => {
|
|
|
2652
2491
|
setLoadedImages((prev) => prev + updates);
|
|
2653
2492
|
}
|
|
2654
2493
|
}, [map, glPois]);
|
|
2655
|
-
const geojson =
|
|
2494
|
+
const geojson = useMemo6(
|
|
2656
2495
|
() => ({
|
|
2657
2496
|
features: glPois.map((poi) => ({
|
|
2658
2497
|
geometry: {
|
|
@@ -2670,7 +2509,7 @@ var POILayers = ({ pois }) => {
|
|
|
2670
2509
|
}),
|
|
2671
2510
|
[glPois]
|
|
2672
2511
|
);
|
|
2673
|
-
return /* @__PURE__ */
|
|
2512
|
+
return /* @__PURE__ */ jsx13(Source3, { data: geojson, id: "sdk-pois", type: "geojson", children: /* @__PURE__ */ jsx13(
|
|
2674
2513
|
Layer3,
|
|
2675
2514
|
{
|
|
2676
2515
|
id: "sdk-poi-layer",
|
|
@@ -2707,11 +2546,11 @@ var POILayers = ({ pois }) => {
|
|
|
2707
2546
|
|
|
2708
2547
|
// src/components/Map/layers/POIMarkers.tsx
|
|
2709
2548
|
import { Marker } from "@vis.gl/react-maplibre";
|
|
2710
|
-
import { Fragment as
|
|
2549
|
+
import { Fragment as Fragment4, jsx as jsx14, jsxs as jsxs10 } from "react/jsx-runtime";
|
|
2711
2550
|
var POIMarkers = ({ pois, onClick }) => {
|
|
2712
2551
|
const markerPois = pois.filter((p) => p.displayMode === "marker");
|
|
2713
2552
|
if (markerPois.length === 0) return null;
|
|
2714
|
-
return /* @__PURE__ */
|
|
2553
|
+
return /* @__PURE__ */ jsx14(Fragment4, { children: markerPois.map((poi) => /* @__PURE__ */ jsx14(
|
|
2715
2554
|
Marker,
|
|
2716
2555
|
{
|
|
2717
2556
|
anchor: "bottom",
|
|
@@ -2721,7 +2560,7 @@ var POIMarkers = ({ pois, onClick }) => {
|
|
|
2721
2560
|
e.originalEvent.stopPropagation();
|
|
2722
2561
|
if (onClick) onClick(poi);
|
|
2723
2562
|
},
|
|
2724
|
-
children: poi.markerComponent ? poi.markerComponent : /* @__PURE__ */
|
|
2563
|
+
children: poi.markerComponent ? poi.markerComponent : /* @__PURE__ */ jsxs10(
|
|
2725
2564
|
"div",
|
|
2726
2565
|
{
|
|
2727
2566
|
style: {
|
|
@@ -2730,7 +2569,7 @@ var POIMarkers = ({ pois, onClick }) => {
|
|
|
2730
2569
|
transform: "transition-transform duration-200 hover:scale-110"
|
|
2731
2570
|
},
|
|
2732
2571
|
children: [
|
|
2733
|
-
/* @__PURE__ */
|
|
2572
|
+
/* @__PURE__ */ jsx14(
|
|
2734
2573
|
"div",
|
|
2735
2574
|
{
|
|
2736
2575
|
style: {
|
|
@@ -2743,7 +2582,7 @@ var POIMarkers = ({ pois, onClick }) => {
|
|
|
2743
2582
|
justifyContent: "center",
|
|
2744
2583
|
width: "32px"
|
|
2745
2584
|
},
|
|
2746
|
-
children: poi.emoji ? /* @__PURE__ */
|
|
2585
|
+
children: poi.emoji ? /* @__PURE__ */ jsx14("span", { style: { fontSize: "16px" }, children: poi.emoji }) : /* @__PURE__ */ jsx14(
|
|
2747
2586
|
"div",
|
|
2748
2587
|
{
|
|
2749
2588
|
style: {
|
|
@@ -2756,7 +2595,7 @@ var POIMarkers = ({ pois, onClick }) => {
|
|
|
2756
2595
|
)
|
|
2757
2596
|
}
|
|
2758
2597
|
),
|
|
2759
|
-
/* @__PURE__ */
|
|
2598
|
+
/* @__PURE__ */ jsx14(
|
|
2760
2599
|
"div",
|
|
2761
2600
|
{
|
|
2762
2601
|
style: {
|
|
@@ -2779,19 +2618,19 @@ var POIMarkers = ({ pois, onClick }) => {
|
|
|
2779
2618
|
|
|
2780
2619
|
// src/components/Map/layers/UserLocationLayer.tsx
|
|
2781
2620
|
import { Marker as Marker2 } from "@vis.gl/react-maplibre";
|
|
2782
|
-
import { jsx as
|
|
2621
|
+
import { jsx as jsx15, jsxs as jsxs11 } from "react/jsx-runtime";
|
|
2783
2622
|
var UserLocationLayer = ({
|
|
2784
2623
|
forcedLocation,
|
|
2785
2624
|
heading
|
|
2786
2625
|
}) => {
|
|
2787
2626
|
if (!forcedLocation) return null;
|
|
2788
|
-
return /* @__PURE__ */
|
|
2627
|
+
return /* @__PURE__ */ jsx15(
|
|
2789
2628
|
Marker2,
|
|
2790
2629
|
{
|
|
2791
2630
|
anchor: "center",
|
|
2792
2631
|
latitude: forcedLocation[1],
|
|
2793
2632
|
longitude: forcedLocation[0],
|
|
2794
|
-
children: /* @__PURE__ */
|
|
2633
|
+
children: /* @__PURE__ */ jsxs11(
|
|
2795
2634
|
"div",
|
|
2796
2635
|
{
|
|
2797
2636
|
style: {
|
|
@@ -2801,7 +2640,7 @@ var UserLocationLayer = ({
|
|
|
2801
2640
|
position: "relative"
|
|
2802
2641
|
},
|
|
2803
2642
|
children: [
|
|
2804
|
-
/* @__PURE__ */
|
|
2643
|
+
/* @__PURE__ */ jsx15(
|
|
2805
2644
|
"div",
|
|
2806
2645
|
{
|
|
2807
2646
|
style: {
|
|
@@ -2814,7 +2653,7 @@ var UserLocationLayer = ({
|
|
|
2814
2653
|
}
|
|
2815
2654
|
}
|
|
2816
2655
|
),
|
|
2817
|
-
heading !== void 0 && heading !== null && /* @__PURE__ */
|
|
2656
|
+
heading !== void 0 && heading !== null && /* @__PURE__ */ jsx15(
|
|
2818
2657
|
"div",
|
|
2819
2658
|
{
|
|
2820
2659
|
style: {
|
|
@@ -2824,13 +2663,13 @@ var UserLocationLayer = ({
|
|
|
2824
2663
|
width: "60px",
|
|
2825
2664
|
zIndex: 0
|
|
2826
2665
|
},
|
|
2827
|
-
children: /* @__PURE__ */
|
|
2666
|
+
children: /* @__PURE__ */ jsxs11(
|
|
2828
2667
|
"svg",
|
|
2829
2668
|
{
|
|
2830
2669
|
style: { height: "100%", width: "100%" },
|
|
2831
2670
|
viewBox: "0 0 100 100",
|
|
2832
2671
|
children: [
|
|
2833
|
-
/* @__PURE__ */
|
|
2672
|
+
/* @__PURE__ */ jsx15("defs", { children: /* @__PURE__ */ jsxs11(
|
|
2834
2673
|
"radialGradient",
|
|
2835
2674
|
{
|
|
2836
2675
|
cx: "50%",
|
|
@@ -2840,7 +2679,7 @@ var UserLocationLayer = ({
|
|
|
2840
2679
|
id: "grad1",
|
|
2841
2680
|
r: "50%",
|
|
2842
2681
|
children: [
|
|
2843
|
-
/* @__PURE__ */
|
|
2682
|
+
/* @__PURE__ */ jsx15(
|
|
2844
2683
|
"stop",
|
|
2845
2684
|
{
|
|
2846
2685
|
offset: "0%",
|
|
@@ -2850,7 +2689,7 @@ var UserLocationLayer = ({
|
|
|
2850
2689
|
}
|
|
2851
2690
|
}
|
|
2852
2691
|
),
|
|
2853
|
-
/* @__PURE__ */
|
|
2692
|
+
/* @__PURE__ */ jsx15(
|
|
2854
2693
|
"stop",
|
|
2855
2694
|
{
|
|
2856
2695
|
offset: "100%",
|
|
@@ -2863,7 +2702,7 @@ var UserLocationLayer = ({
|
|
|
2863
2702
|
]
|
|
2864
2703
|
}
|
|
2865
2704
|
) }),
|
|
2866
|
-
/* @__PURE__ */
|
|
2705
|
+
/* @__PURE__ */ jsx15(
|
|
2867
2706
|
"path",
|
|
2868
2707
|
{
|
|
2869
2708
|
d: "M 50 50 L 35 0 A 50 50 0 0 1 65 0 Z",
|
|
@@ -2875,7 +2714,7 @@ var UserLocationLayer = ({
|
|
|
2875
2714
|
)
|
|
2876
2715
|
}
|
|
2877
2716
|
),
|
|
2878
|
-
/* @__PURE__ */
|
|
2717
|
+
/* @__PURE__ */ jsx15(
|
|
2879
2718
|
"div",
|
|
2880
2719
|
{
|
|
2881
2720
|
style: {
|
|
@@ -2889,7 +2728,7 @@ var UserLocationLayer = ({
|
|
|
2889
2728
|
width: "20px",
|
|
2890
2729
|
zIndex: 1
|
|
2891
2730
|
},
|
|
2892
|
-
children: /* @__PURE__ */
|
|
2731
|
+
children: /* @__PURE__ */ jsx15(
|
|
2893
2732
|
"div",
|
|
2894
2733
|
{
|
|
2895
2734
|
style: {
|
|
@@ -2903,7 +2742,7 @@ var UserLocationLayer = ({
|
|
|
2903
2742
|
)
|
|
2904
2743
|
}
|
|
2905
2744
|
),
|
|
2906
|
-
/* @__PURE__ */
|
|
2745
|
+
/* @__PURE__ */ jsx15("style", { children: `@keyframes pulse { 0% { transform: scale(0.95); opacity: 0.7; } 70% { transform: scale(1.5); opacity: 0; } 100% { transform: scale(0.95); opacity: 0; } }` })
|
|
2907
2746
|
]
|
|
2908
2747
|
}
|
|
2909
2748
|
)
|
|
@@ -2914,15 +2753,15 @@ var UserLocationLayer = ({
|
|
|
2914
2753
|
// src/components/Map/Map.tsx
|
|
2915
2754
|
import { Map as MapLibre, MapProvider } from "@vis.gl/react-maplibre";
|
|
2916
2755
|
import React4, {
|
|
2917
|
-
useCallback as
|
|
2756
|
+
useCallback as useCallback6,
|
|
2918
2757
|
useContext as useContext5,
|
|
2919
2758
|
useEffect as useEffect7,
|
|
2920
|
-
useMemo as
|
|
2921
|
-
useRef as
|
|
2922
|
-
useState as
|
|
2759
|
+
useMemo as useMemo7,
|
|
2760
|
+
useRef as useRef7,
|
|
2761
|
+
useState as useState9
|
|
2923
2762
|
} from "react";
|
|
2924
2763
|
import "maplibre-gl/dist/maplibre-gl.css";
|
|
2925
|
-
import { Fragment as
|
|
2764
|
+
import { Fragment as Fragment5, jsx as jsx16, jsxs as jsxs12 } from "react/jsx-runtime";
|
|
2926
2765
|
var MapInternal = ({
|
|
2927
2766
|
initialViewState = {
|
|
2928
2767
|
latitude: 45.90583599233422,
|
|
@@ -2962,7 +2801,7 @@ var MapInternal = ({
|
|
|
2962
2801
|
}) => {
|
|
2963
2802
|
const mapControls = useContext5(MapControlsContext);
|
|
2964
2803
|
const mockLocation = useContext5(MockLocationContext);
|
|
2965
|
-
const mapRef =
|
|
2804
|
+
const mapRef = useRef7(null);
|
|
2966
2805
|
const userLocationState = useUserLocation();
|
|
2967
2806
|
const journey = useJourney({
|
|
2968
2807
|
navigation,
|
|
@@ -2980,24 +2819,24 @@ var MapInternal = ({
|
|
|
2980
2819
|
const showNavigationUI = hasIntegratedNav ? externalShowNavigationUI !== false && navigation?.showUI !== false : externalShowNavigationUI;
|
|
2981
2820
|
const mode = navigationData?.mode || "preview";
|
|
2982
2821
|
const resolvedInitialFollow = mapControls ? mapControls.isFollowing : initialFollowUser;
|
|
2983
|
-
const isFollowingRef =
|
|
2984
|
-
const isFlyingRef =
|
|
2985
|
-
const flyingGenerationRef =
|
|
2986
|
-
const lockFlying =
|
|
2822
|
+
const isFollowingRef = useRef7(resolvedInitialFollow);
|
|
2823
|
+
const isFlyingRef = useRef7(false);
|
|
2824
|
+
const flyingGenerationRef = useRef7(0);
|
|
2825
|
+
const lockFlying = useCallback6(() => {
|
|
2987
2826
|
isFlyingRef.current = true;
|
|
2988
2827
|
return ++flyingGenerationRef.current;
|
|
2989
2828
|
}, []);
|
|
2990
|
-
const releaseFlyingIfCurrent =
|
|
2829
|
+
const releaseFlyingIfCurrent = useCallback6((flightId) => {
|
|
2991
2830
|
if (flyingGenerationRef.current === flightId) {
|
|
2992
2831
|
isFlyingRef.current = false;
|
|
2993
2832
|
}
|
|
2994
2833
|
}, []);
|
|
2995
|
-
const [localIsFollowingUI, setLocalIsFollowingUI] =
|
|
2834
|
+
const [localIsFollowingUI, setLocalIsFollowingUI] = useState9(
|
|
2996
2835
|
resolvedInitialFollow
|
|
2997
2836
|
);
|
|
2998
2837
|
const isFollowingUI = mapControls ? mapControls.isFollowing : localIsFollowingUI;
|
|
2999
2838
|
const setIsFollowingCtx = mapControls?.setIsFollowing;
|
|
3000
|
-
const setFollowMode =
|
|
2839
|
+
const setFollowMode = useCallback6(
|
|
3001
2840
|
(follow) => {
|
|
3002
2841
|
isFollowingRef.current = follow;
|
|
3003
2842
|
setLocalIsFollowingUI(follow);
|
|
@@ -3016,7 +2855,7 @@ var MapInternal = ({
|
|
|
3016
2855
|
if (pois.length > 0 && !mergedInteractiveLayerIds.includes("sdk-poi-layer")) {
|
|
3017
2856
|
mergedInteractiveLayerIds.push("sdk-poi-layer");
|
|
3018
2857
|
}
|
|
3019
|
-
const prevInitialFollow =
|
|
2858
|
+
const prevInitialFollow = useRef7(initialFollowUser);
|
|
3020
2859
|
useEffect7(() => {
|
|
3021
2860
|
if (initialFollowUser !== prevInitialFollow.current) {
|
|
3022
2861
|
setFollowMode(initialFollowUser);
|
|
@@ -3041,8 +2880,8 @@ var MapInternal = ({
|
|
|
3041
2880
|
lockFlying,
|
|
3042
2881
|
releaseFlyingIfCurrent
|
|
3043
2882
|
]);
|
|
3044
|
-
const lastAutoLockedRouteRef =
|
|
3045
|
-
const lastModeRef =
|
|
2883
|
+
const lastAutoLockedRouteRef = useRef7(null);
|
|
2884
|
+
const lastModeRef = useRef7(null);
|
|
3046
2885
|
useEffect7(() => {
|
|
3047
2886
|
if (!route || !mapRef.current) {
|
|
3048
2887
|
if (!route) lastAutoLockedRouteRef.current = null;
|
|
@@ -3155,7 +2994,7 @@ var MapInternal = ({
|
|
|
3155
2994
|
}
|
|
3156
2995
|
}, [propDrawerState, setDrawerStateCtx]);
|
|
3157
2996
|
const resolvedMenuItems = menuItems ?? [];
|
|
3158
|
-
const { mapLibreChildren, menuContentFromChildren } =
|
|
2997
|
+
const { mapLibreChildren, menuContentFromChildren } = useMemo7(() => {
|
|
3159
2998
|
const mapLibreChildren2 = [];
|
|
3160
2999
|
const extractedMenuItems = [];
|
|
3161
3000
|
React4.Children.forEach(children, (child) => {
|
|
@@ -3187,7 +3026,7 @@ var MapInternal = ({
|
|
|
3187
3026
|
mapLibreChildren2.push(child);
|
|
3188
3027
|
}
|
|
3189
3028
|
});
|
|
3190
|
-
const menuContentFromChildren2 = extractedMenuItems.length > 0 ? /* @__PURE__ */
|
|
3029
|
+
const menuContentFromChildren2 = extractedMenuItems.length > 0 ? /* @__PURE__ */ jsx16(MapMenu, { children: extractedMenuItems }) : null;
|
|
3191
3030
|
return { mapLibreChildren: mapLibreChildren2, menuContentFromChildren: menuContentFromChildren2 };
|
|
3192
3031
|
}, [children]);
|
|
3193
3032
|
const handleMapClick = (e) => {
|
|
@@ -3215,7 +3054,7 @@ var MapInternal = ({
|
|
|
3215
3054
|
}
|
|
3216
3055
|
if (onClick) onClick(e);
|
|
3217
3056
|
};
|
|
3218
|
-
const handleCenterOnUser =
|
|
3057
|
+
const handleCenterOnUser = useCallback6(
|
|
3219
3058
|
(payload) => {
|
|
3220
3059
|
if (userLocationState.coords && mapRef.current) {
|
|
3221
3060
|
setFollowMode(true);
|
|
@@ -3240,7 +3079,7 @@ var MapInternal = ({
|
|
|
3240
3079
|
releaseFlyingIfCurrent
|
|
3241
3080
|
]
|
|
3242
3081
|
);
|
|
3243
|
-
const handleFlyTo =
|
|
3082
|
+
const handleFlyTo = useCallback6(
|
|
3244
3083
|
(coords, params) => {
|
|
3245
3084
|
const map = mapRef.current;
|
|
3246
3085
|
if (!map) return;
|
|
@@ -3260,7 +3099,7 @@ var MapInternal = ({
|
|
|
3260
3099
|
},
|
|
3261
3100
|
[setFollowMode, lockFlying, releaseFlyingIfCurrent]
|
|
3262
3101
|
);
|
|
3263
|
-
const handleResetBearing =
|
|
3102
|
+
const handleResetBearing = useCallback6((params) => {
|
|
3264
3103
|
if (mapRef.current) {
|
|
3265
3104
|
mapRef.current.easeTo({
|
|
3266
3105
|
bearing: 0,
|
|
@@ -3277,7 +3116,7 @@ var MapInternal = ({
|
|
|
3277
3116
|
mapControls._registerFlyToCallback(handleFlyTo);
|
|
3278
3117
|
}
|
|
3279
3118
|
}, [mapControls, handleCenterOnUser, handleResetBearing, handleFlyTo]);
|
|
3280
|
-
const handleMove =
|
|
3119
|
+
const handleMove = useCallback6(() => {
|
|
3281
3120
|
if (mapRef.current && mapControls) {
|
|
3282
3121
|
mapControls.setBearing(mapRef.current.getBearing());
|
|
3283
3122
|
mapControls.setPitch(mapRef.current.getPitch());
|
|
@@ -3292,13 +3131,13 @@ var MapInternal = ({
|
|
|
3292
3131
|
}
|
|
3293
3132
|
}
|
|
3294
3133
|
};
|
|
3295
|
-
return /* @__PURE__ */
|
|
3134
|
+
return /* @__PURE__ */ jsxs12(
|
|
3296
3135
|
"div",
|
|
3297
3136
|
{
|
|
3298
3137
|
className: `w-full h-full overflow-hidden relative ${mockLocation?.isPlacingLocation ? "cursor-crosshair" : ""} ${className}`,
|
|
3299
3138
|
style,
|
|
3300
3139
|
children: [
|
|
3301
|
-
/* @__PURE__ */
|
|
3140
|
+
/* @__PURE__ */ jsxs12(
|
|
3302
3141
|
MapLibre,
|
|
3303
3142
|
{
|
|
3304
3143
|
attributionControl: false,
|
|
@@ -3328,30 +3167,30 @@ var MapInternal = ({
|
|
|
3328
3167
|
showUserLocation && userLocationState.coords && (renderUserLocation ? renderUserLocation({
|
|
3329
3168
|
coords: userLocationState.coords,
|
|
3330
3169
|
heading: userLocationState.heading
|
|
3331
|
-
}) : /* @__PURE__ */
|
|
3170
|
+
}) : /* @__PURE__ */ jsx16(
|
|
3332
3171
|
UserLocationLayer,
|
|
3333
3172
|
{
|
|
3334
3173
|
forcedLocation: userLocationState.coords,
|
|
3335
3174
|
heading: userLocationState.heading
|
|
3336
3175
|
}
|
|
3337
3176
|
)),
|
|
3338
|
-
mockLocation && mockLocation.radiusMeters > 0 && userLocationState.coords && /* @__PURE__ */
|
|
3177
|
+
mockLocation && mockLocation.radiusMeters > 0 && userLocationState.coords && /* @__PURE__ */ jsx16(
|
|
3339
3178
|
MockRadiusLayer,
|
|
3340
3179
|
{
|
|
3341
3180
|
center: userLocationState.coords,
|
|
3342
3181
|
radiusMeters: mockLocation.radiusMeters
|
|
3343
3182
|
}
|
|
3344
3183
|
),
|
|
3345
|
-
displayRoute && /* @__PURE__ */
|
|
3346
|
-
pois.length > 0 && /* @__PURE__ */
|
|
3347
|
-
/* @__PURE__ */
|
|
3348
|
-
/* @__PURE__ */
|
|
3184
|
+
displayRoute && /* @__PURE__ */ jsx16(RouteLayer, { geometry: displayRoute }),
|
|
3185
|
+
pois.length > 0 && /* @__PURE__ */ jsxs12(Fragment5, { children: [
|
|
3186
|
+
/* @__PURE__ */ jsx16(POILayers, { pois }),
|
|
3187
|
+
/* @__PURE__ */ jsx16(POIMarkers, { onClick: onPoiClick, pois })
|
|
3349
3188
|
] }),
|
|
3350
3189
|
mapLibreChildren
|
|
3351
3190
|
]
|
|
3352
3191
|
}
|
|
3353
3192
|
),
|
|
3354
|
-
showControls && mapControls && !mapControls.hasControls && /* @__PURE__ */
|
|
3193
|
+
showControls && mapControls && !mapControls.hasControls && /* @__PURE__ */ jsx16(
|
|
3355
3194
|
MapControls,
|
|
3356
3195
|
{
|
|
3357
3196
|
drawerContentRef,
|
|
@@ -3373,12 +3212,12 @@ var SDKMapProviderWrapper = ({
|
|
|
3373
3212
|
}) => {
|
|
3374
3213
|
const context = useContext5(MapControlsContext);
|
|
3375
3214
|
if (context) {
|
|
3376
|
-
return /* @__PURE__ */
|
|
3215
|
+
return /* @__PURE__ */ jsx16(Fragment5, { children });
|
|
3377
3216
|
}
|
|
3378
|
-
return /* @__PURE__ */
|
|
3217
|
+
return /* @__PURE__ */ jsx16(SDKMapProvider, { children });
|
|
3379
3218
|
};
|
|
3380
3219
|
var Map2 = (props) => {
|
|
3381
|
-
return /* @__PURE__ */
|
|
3220
|
+
return /* @__PURE__ */ jsx16(SDKMapProviderWrapper, { children: /* @__PURE__ */ jsx16(MapProvider, { children: /* @__PURE__ */ jsx16(MapInternal, { ...props }) }) });
|
|
3382
3221
|
};
|
|
3383
3222
|
|
|
3384
3223
|
// src/components/MapWrapper.tsx
|
|
@@ -3567,7 +3406,7 @@ var loadImage2 = (src) => new Promise((resolve, reject) => {
|
|
|
3567
3406
|
});
|
|
3568
3407
|
|
|
3569
3408
|
// package.json
|
|
3570
|
-
var version = "0.
|
|
3409
|
+
var version = "0.7.0";
|
|
3571
3410
|
|
|
3572
3411
|
// src/sdk.ts
|
|
3573
3412
|
function deepFreeze(obj) {
|
|
@@ -3913,6 +3752,8 @@ var MiniAppSDK = class {
|
|
|
3913
3752
|
);
|
|
3914
3753
|
this.initialize = this.initialize.bind(this);
|
|
3915
3754
|
this.getEnv = this.getEnv.bind(this);
|
|
3755
|
+
this.achievement = this.achievement.bind(this);
|
|
3756
|
+
this.achievements = this.achievements.bind(this);
|
|
3916
3757
|
this.on = this.on.bind(this);
|
|
3917
3758
|
this.off = this.off.bind(this);
|
|
3918
3759
|
}
|
|
@@ -3953,6 +3794,23 @@ var MiniAppSDK = class {
|
|
|
3953
3794
|
getEnv() {
|
|
3954
3795
|
return lastKnownEnv;
|
|
3955
3796
|
}
|
|
3797
|
+
/**
|
|
3798
|
+
* Fetches a single Achievement's current progress by slug — read-only, for
|
|
3799
|
+
* rendering things like a progress bar. Progress is reported server-side
|
|
3800
|
+
* by the mini-app's own backend calling the Hub's M2M endpoint directly;
|
|
3801
|
+
* there is no corresponding "report progress" method on this SDK.
|
|
3802
|
+
* @param slug Unique slug identifying the Achievement.
|
|
3803
|
+
*/
|
|
3804
|
+
achievement(slug) {
|
|
3805
|
+
return this.bridge.send("GET_ACHIEVEMENT", { slug });
|
|
3806
|
+
}
|
|
3807
|
+
/**
|
|
3808
|
+
* Fetches every Achievement (with current progress) visible to this
|
|
3809
|
+
* mini-app — read-only, same boundary as {@link MiniAppSDK.achievement}.
|
|
3810
|
+
*/
|
|
3811
|
+
achievements() {
|
|
3812
|
+
return this.bridge.send("GET_ACHIEVEMENTS");
|
|
3813
|
+
}
|
|
3956
3814
|
/**
|
|
3957
3815
|
* Registers a callback for a specific event from the native shell.
|
|
3958
3816
|
* @param event The name of the event to listen for.
|
|
@@ -3974,8 +3832,43 @@ var MiniAppSDK = class {
|
|
|
3974
3832
|
var sdk = deepFreeze(new MiniAppSDK());
|
|
3975
3833
|
|
|
3976
3834
|
// src/components/BridgeMocker.tsx
|
|
3977
|
-
import { useCallback as
|
|
3978
|
-
import { jsx as
|
|
3835
|
+
import { useCallback as useCallback7, useEffect as useEffect8, useMemo as useMemo8, useRef as useRef8, useState as useState10 } from "react";
|
|
3836
|
+
import { jsx as jsx17, jsxs as jsxs13 } from "react/jsx-runtime";
|
|
3837
|
+
var MOCK_ACHIEVEMENTS2 = [
|
|
3838
|
+
{
|
|
3839
|
+
completed: false,
|
|
3840
|
+
description: "Discover 5 points of interest around Annecy.",
|
|
3841
|
+
imageUrl: "https://api.dicebear.com/9.x/icons/svg?seed=explore",
|
|
3842
|
+
playerActionCount: 3,
|
|
3843
|
+
slug: "explore-5-pois",
|
|
3844
|
+
title: "Explorer",
|
|
3845
|
+
totalActionCount: 5,
|
|
3846
|
+
upReward: 50,
|
|
3847
|
+
xpReward: 100
|
|
3848
|
+
},
|
|
3849
|
+
{
|
|
3850
|
+
completed: true,
|
|
3851
|
+
description: "Complete your first navigation journey.",
|
|
3852
|
+
imageUrl: "https://api.dicebear.com/9.x/icons/svg?seed=journey",
|
|
3853
|
+
playerActionCount: 1,
|
|
3854
|
+
slug: "first-journey",
|
|
3855
|
+
title: "First Steps",
|
|
3856
|
+
totalActionCount: 1,
|
|
3857
|
+
upReward: 20,
|
|
3858
|
+
xpReward: 40
|
|
3859
|
+
},
|
|
3860
|
+
{
|
|
3861
|
+
completed: false,
|
|
3862
|
+
description: "Scan 10 QR codes at partner venues.",
|
|
3863
|
+
imageUrl: "https://api.dicebear.com/9.x/icons/svg?seed=scan",
|
|
3864
|
+
playerActionCount: 4,
|
|
3865
|
+
slug: "scan-10-qrcodes",
|
|
3866
|
+
title: "Code Breaker",
|
|
3867
|
+
totalActionCount: 10,
|
|
3868
|
+
upReward: 80,
|
|
3869
|
+
xpReward: 150
|
|
3870
|
+
}
|
|
3871
|
+
];
|
|
3979
3872
|
var AVATAR_MOUTH_VARIANTS = [
|
|
3980
3873
|
"variant03",
|
|
3981
3874
|
"variant07",
|
|
@@ -4062,19 +3955,19 @@ var BridgeMocker = ({
|
|
|
4062
3955
|
mockJWTToken,
|
|
4063
3956
|
children
|
|
4064
3957
|
}) => {
|
|
4065
|
-
const [autoMove, setAutoMove] =
|
|
4066
|
-
const [location, setLocation] =
|
|
4067
|
-
const [heading, setHeading] =
|
|
4068
|
-
const [speedMultiplier, setSpeedMultiplier] =
|
|
4069
|
-
const [isReady, setIsReady] =
|
|
4070
|
-
const [isMinimized, setIsMinimized] =
|
|
4071
|
-
const [radiusMeters, setRadiusMeters] =
|
|
4072
|
-
const [radiusUnit, setRadiusUnit] =
|
|
4073
|
-
const [isPlacingLocation, setIsPlacingLocation] =
|
|
4074
|
-
const streamIntervalRef =
|
|
4075
|
-
const pathIndexRef =
|
|
4076
|
-
const activeConfigRef =
|
|
4077
|
-
const stateRef =
|
|
3958
|
+
const [autoMove, setAutoMove] = useState10(isMoving);
|
|
3959
|
+
const [location, setLocation] = useState10(initialLocation);
|
|
3960
|
+
const [heading, setHeading] = useState10(0);
|
|
3961
|
+
const [speedMultiplier, setSpeedMultiplier] = useState10(simulationSpeed);
|
|
3962
|
+
const [isReady, setIsReady] = useState10(false);
|
|
3963
|
+
const [isMinimized, setIsMinimized] = useState10(true);
|
|
3964
|
+
const [radiusMeters, setRadiusMeters] = useState10(0);
|
|
3965
|
+
const [radiusUnit, setRadiusUnit] = useState10("m");
|
|
3966
|
+
const [isPlacingLocation, setIsPlacingLocation] = useState10(false);
|
|
3967
|
+
const streamIntervalRef = useRef8(null);
|
|
3968
|
+
const pathIndexRef = useRef8(0);
|
|
3969
|
+
const activeConfigRef = useRef8(null);
|
|
3970
|
+
const stateRef = useRef8({
|
|
4078
3971
|
autoMove,
|
|
4079
3972
|
heading,
|
|
4080
3973
|
location,
|
|
@@ -4086,7 +3979,7 @@ var BridgeMocker = ({
|
|
|
4086
3979
|
simulationPath,
|
|
4087
3980
|
speedMultiplier
|
|
4088
3981
|
});
|
|
4089
|
-
const pushLocationUpdateFor =
|
|
3982
|
+
const pushLocationUpdateFor = useCallback7(
|
|
4090
3983
|
(coords, headingDeg) => {
|
|
4091
3984
|
const currentState = stateRef.current;
|
|
4092
3985
|
const payload = {
|
|
@@ -4118,11 +4011,11 @@ var BridgeMocker = ({
|
|
|
4118
4011
|
},
|
|
4119
4012
|
[]
|
|
4120
4013
|
);
|
|
4121
|
-
const pushLocationUpdate =
|
|
4014
|
+
const pushLocationUpdate = useCallback7(() => {
|
|
4122
4015
|
const currentState = stateRef.current;
|
|
4123
4016
|
pushLocationUpdateFor(currentState.location, currentState.heading);
|
|
4124
4017
|
}, [pushLocationUpdateFor]);
|
|
4125
|
-
const placeLocation =
|
|
4018
|
+
const placeLocation = useCallback7(
|
|
4126
4019
|
(coords) => {
|
|
4127
4020
|
setLocation(coords);
|
|
4128
4021
|
setIsPlacingLocation(false);
|
|
@@ -4332,6 +4225,24 @@ var BridgeMocker = ({
|
|
|
4332
4225
|
if (type === "GET_FIDELITY_BALANCE") {
|
|
4333
4226
|
return Promise.resolve({ balance: 1337, currency: "FPoints" });
|
|
4334
4227
|
}
|
|
4228
|
+
if (type === "GET_ACHIEVEMENTS") {
|
|
4229
|
+
return Promise.resolve(MOCK_ACHIEVEMENTS2);
|
|
4230
|
+
}
|
|
4231
|
+
if (type === "GET_ACHIEVEMENT") {
|
|
4232
|
+
const slug = payload?.slug;
|
|
4233
|
+
return Promise.resolve(
|
|
4234
|
+
MOCK_ACHIEVEMENTS2.find((a) => a.slug === slug) ?? {
|
|
4235
|
+
completed: false,
|
|
4236
|
+
description: "Mocked achievement (no native shell attached).",
|
|
4237
|
+
playerActionCount: 0,
|
|
4238
|
+
slug: slug || "unknown-achievement",
|
|
4239
|
+
title: slug || "Unknown Achievement",
|
|
4240
|
+
totalActionCount: 1,
|
|
4241
|
+
upReward: 0,
|
|
4242
|
+
xpReward: 0
|
|
4243
|
+
}
|
|
4244
|
+
);
|
|
4245
|
+
}
|
|
4335
4246
|
if (type === "PAYMENT_REQUEST") {
|
|
4336
4247
|
return Promise.resolve({
|
|
4337
4248
|
success: true,
|
|
@@ -4350,7 +4261,7 @@ var BridgeMocker = ({
|
|
|
4350
4261
|
};
|
|
4351
4262
|
}, [appId]);
|
|
4352
4263
|
const radiusInMeters = radiusUnit === "km" ? radiusMeters * 1e3 : radiusMeters;
|
|
4353
|
-
const mockLocationContextValue =
|
|
4264
|
+
const mockLocationContextValue = useMemo8(
|
|
4354
4265
|
() => ({
|
|
4355
4266
|
isPlacingLocation,
|
|
4356
4267
|
placeLocation,
|
|
@@ -4359,9 +4270,9 @@ var BridgeMocker = ({
|
|
|
4359
4270
|
[isPlacingLocation, placeLocation, radiusInMeters]
|
|
4360
4271
|
);
|
|
4361
4272
|
if (!isReady) return null;
|
|
4362
|
-
return /* @__PURE__ */
|
|
4363
|
-
/* @__PURE__ */
|
|
4364
|
-
isMinimized ? /* @__PURE__ */
|
|
4273
|
+
return /* @__PURE__ */ jsxs13("div", { className: "relative w-full h-full", children: [
|
|
4274
|
+
/* @__PURE__ */ jsx17("div", { className: "w-full h-full", children: /* @__PURE__ */ jsx17(MockLocationContext.Provider, { value: mockLocationContextValue, children }) }),
|
|
4275
|
+
isMinimized ? /* @__PURE__ */ jsx17(
|
|
4365
4276
|
Button,
|
|
4366
4277
|
{
|
|
4367
4278
|
className: "fixed bottom-4 right-4 w-8 h-8 rounded-full bg-slate-900/60 backdrop-blur-sm border border-slate-700/50 flex items-center justify-center text-slate-400 hover:text-blue-400 hover:bg-slate-900/80 z-[9999] transition-all shadow-lg group p-0!",
|
|
@@ -4369,7 +4280,7 @@ var BridgeMocker = ({
|
|
|
4369
4280
|
title: "Open Simulation Controls",
|
|
4370
4281
|
type: "button",
|
|
4371
4282
|
variant: "ghost",
|
|
4372
|
-
children: /* @__PURE__ */
|
|
4283
|
+
children: /* @__PURE__ */ jsxs13(
|
|
4373
4284
|
"svg",
|
|
4374
4285
|
{
|
|
4375
4286
|
className: "group-hover:scale-110 transition-transform",
|
|
@@ -4383,34 +4294,34 @@ var BridgeMocker = ({
|
|
|
4383
4294
|
width: "14",
|
|
4384
4295
|
xmlns: "http://www.w3.org/2000/svg",
|
|
4385
4296
|
children: [
|
|
4386
|
-
/* @__PURE__ */
|
|
4387
|
-
/* @__PURE__ */
|
|
4388
|
-
/* @__PURE__ */
|
|
4389
|
-
/* @__PURE__ */
|
|
4390
|
-
/* @__PURE__ */
|
|
4391
|
-
/* @__PURE__ */
|
|
4392
|
-
/* @__PURE__ */
|
|
4297
|
+
/* @__PURE__ */ jsx17("path", { d: "M21 4H3" }),
|
|
4298
|
+
/* @__PURE__ */ jsx17("path", { d: "M10 8H3" }),
|
|
4299
|
+
/* @__PURE__ */ jsx17("path", { d: "M21 12H3" }),
|
|
4300
|
+
/* @__PURE__ */ jsx17("path", { d: "M10 16H3" }),
|
|
4301
|
+
/* @__PURE__ */ jsx17("path", { d: "M21 20H3" }),
|
|
4302
|
+
/* @__PURE__ */ jsx17("circle", { cx: "14", cy: "8", r: "2" }),
|
|
4303
|
+
/* @__PURE__ */ jsx17("circle", { cx: "14", cy: "16", r: "2" })
|
|
4393
4304
|
]
|
|
4394
4305
|
}
|
|
4395
4306
|
)
|
|
4396
4307
|
}
|
|
4397
|
-
) : /* @__PURE__ */
|
|
4308
|
+
) : /* @__PURE__ */ jsxs13(
|
|
4398
4309
|
"div",
|
|
4399
4310
|
{
|
|
4400
4311
|
className: "fixed bottom-4 right-4 bg-slate-900 text-slate-300 font-mono text-xs rounded-xl shadow-2xl border border-slate-700 pointer-events-auto flex flex-col w-80 overflow-hidden animate-in slide-in-from-right duration-300",
|
|
4401
4312
|
style: { zIndex: 9998 },
|
|
4402
4313
|
children: [
|
|
4403
|
-
/* @__PURE__ */
|
|
4314
|
+
/* @__PURE__ */ jsxs13(
|
|
4404
4315
|
"div",
|
|
4405
4316
|
{
|
|
4406
4317
|
className: "flex justify-between items-center p-3 border-b border-slate-800 cursor-pointer bg-slate-800/50 hover:bg-slate-800 transition-colors",
|
|
4407
4318
|
onClick: () => setIsMinimized(true),
|
|
4408
4319
|
children: [
|
|
4409
|
-
/* @__PURE__ */
|
|
4410
|
-
/* @__PURE__ */
|
|
4320
|
+
/* @__PURE__ */ jsxs13("span", { className: "font-bold text-slate-100 flex items-center gap-2", children: [
|
|
4321
|
+
/* @__PURE__ */ jsx17("span", { className: "text-lg", children: "\u{1F6E0}\uFE0F" }),
|
|
4411
4322
|
" Simulation Controls"
|
|
4412
4323
|
] }),
|
|
4413
|
-
/* @__PURE__ */
|
|
4324
|
+
/* @__PURE__ */ jsx17(
|
|
4414
4325
|
Button,
|
|
4415
4326
|
{
|
|
4416
4327
|
className: "text-slate-500 hover:text-white p-0 h-auto hover:bg-transparent cursor-pointer",
|
|
@@ -4422,10 +4333,10 @@ var BridgeMocker = ({
|
|
|
4422
4333
|
]
|
|
4423
4334
|
}
|
|
4424
4335
|
),
|
|
4425
|
-
/* @__PURE__ */
|
|
4426
|
-
/* @__PURE__ */
|
|
4427
|
-
/* @__PURE__ */
|
|
4428
|
-
/* @__PURE__ */
|
|
4336
|
+
/* @__PURE__ */ jsxs13("div", { className: "p-4 flex flex-col gap-3", children: [
|
|
4337
|
+
/* @__PURE__ */ jsxs13("div", { className: "flex justify-between items-center", children: [
|
|
4338
|
+
/* @__PURE__ */ jsxs13("label", { className: "flex items-center gap-2 cursor-pointer", children: [
|
|
4339
|
+
/* @__PURE__ */ jsx17(
|
|
4429
4340
|
"input",
|
|
4430
4341
|
{
|
|
4431
4342
|
checked: autoMove,
|
|
@@ -4434,20 +4345,20 @@ var BridgeMocker = ({
|
|
|
4434
4345
|
type: "checkbox"
|
|
4435
4346
|
}
|
|
4436
4347
|
),
|
|
4437
|
-
/* @__PURE__ */
|
|
4348
|
+
/* @__PURE__ */ jsxs13("span", { className: "text-slate-200 font-bold", children: [
|
|
4438
4349
|
"Auto-Move ",
|
|
4439
4350
|
simulationPath ? "(Path)" : "(Random)"
|
|
4440
4351
|
] })
|
|
4441
4352
|
] }),
|
|
4442
|
-
/* @__PURE__ */
|
|
4443
|
-
/* @__PURE__ */
|
|
4444
|
-
/* @__PURE__ */
|
|
4353
|
+
/* @__PURE__ */ jsxs13("div", { className: "flex items-center gap-2", children: [
|
|
4354
|
+
/* @__PURE__ */ jsx17("span", { className: "text-[10px] text-slate-500", children: "Speed:" }),
|
|
4355
|
+
/* @__PURE__ */ jsx17(
|
|
4445
4356
|
"select",
|
|
4446
4357
|
{
|
|
4447
4358
|
className: "bg-slate-800 border border-slate-700 rounded px-1 py-0.5 text-white focus:outline-none focus:border-blue-500 text-[10px]",
|
|
4448
4359
|
onChange: (e) => setSpeedMultiplier(Number(e.target.value)),
|
|
4449
4360
|
value: speedMultiplier,
|
|
4450
|
-
children: [1, 2, 5, 10, 50, 100, 250].map((s) => /* @__PURE__ */
|
|
4361
|
+
children: [1, 2, 5, 10, 50, 100, 250].map((s) => /* @__PURE__ */ jsxs13("option", { value: s, children: [
|
|
4451
4362
|
s,
|
|
4452
4363
|
"x"
|
|
4453
4364
|
] }, s))
|
|
@@ -4455,10 +4366,10 @@ var BridgeMocker = ({
|
|
|
4455
4366
|
)
|
|
4456
4367
|
] })
|
|
4457
4368
|
] }),
|
|
4458
|
-
/* @__PURE__ */
|
|
4459
|
-
/* @__PURE__ */
|
|
4460
|
-
/* @__PURE__ */
|
|
4461
|
-
/* @__PURE__ */
|
|
4369
|
+
/* @__PURE__ */ jsxs13("div", { className: "grid grid-cols-2 gap-2", children: [
|
|
4370
|
+
/* @__PURE__ */ jsxs13("div", { className: "flex flex-col gap-1", children: [
|
|
4371
|
+
/* @__PURE__ */ jsx17("span", { className: "text-[10px] text-slate-500 text-left", children: "Lng" }),
|
|
4372
|
+
/* @__PURE__ */ jsx17(
|
|
4462
4373
|
"input",
|
|
4463
4374
|
{
|
|
4464
4375
|
className: "bg-slate-800 border border-slate-700 rounded px-2 py-1 text-white focus:outline-none focus:border-blue-500",
|
|
@@ -4473,9 +4384,9 @@ var BridgeMocker = ({
|
|
|
4473
4384
|
}
|
|
4474
4385
|
)
|
|
4475
4386
|
] }),
|
|
4476
|
-
/* @__PURE__ */
|
|
4477
|
-
/* @__PURE__ */
|
|
4478
|
-
/* @__PURE__ */
|
|
4387
|
+
/* @__PURE__ */ jsxs13("div", { className: "flex flex-col gap-1", children: [
|
|
4388
|
+
/* @__PURE__ */ jsx17("span", { className: "text-[10px] text-slate-500 text-left", children: "Lat" }),
|
|
4389
|
+
/* @__PURE__ */ jsx17(
|
|
4479
4390
|
"input",
|
|
4480
4391
|
{
|
|
4481
4392
|
className: "bg-slate-800 border border-slate-700 rounded px-2 py-1 text-white focus:outline-none focus:border-blue-500",
|
|
@@ -4490,9 +4401,9 @@ var BridgeMocker = ({
|
|
|
4490
4401
|
}
|
|
4491
4402
|
)
|
|
4492
4403
|
] }),
|
|
4493
|
-
/* @__PURE__ */
|
|
4494
|
-
/* @__PURE__ */
|
|
4495
|
-
/* @__PURE__ */
|
|
4404
|
+
/* @__PURE__ */ jsxs13("div", { className: "flex flex-col gap-1 col-span-2", children: [
|
|
4405
|
+
/* @__PURE__ */ jsx17("span", { className: "text-[10px] text-slate-500", children: "Heading (Degrees)" }),
|
|
4406
|
+
/* @__PURE__ */ jsx17(
|
|
4496
4407
|
"input",
|
|
4497
4408
|
{
|
|
4498
4409
|
className: "w-full accent-blue-500",
|
|
@@ -4506,13 +4417,13 @@ var BridgeMocker = ({
|
|
|
4506
4417
|
value: heading
|
|
4507
4418
|
}
|
|
4508
4419
|
),
|
|
4509
|
-
/* @__PURE__ */
|
|
4420
|
+
/* @__PURE__ */ jsxs13("div", { className: "text-right text-slate-400", children: [
|
|
4510
4421
|
heading,
|
|
4511
4422
|
"\xB0"
|
|
4512
4423
|
] })
|
|
4513
4424
|
] })
|
|
4514
4425
|
] }),
|
|
4515
|
-
/* @__PURE__ */
|
|
4426
|
+
/* @__PURE__ */ jsx17(
|
|
4516
4427
|
Button,
|
|
4517
4428
|
{
|
|
4518
4429
|
className: `w-full rounded px-2 py-1.5 text-[10px] font-bold border cursor-pointer ${isPlacingLocation ? "bg-blue-500/20 border-blue-500 text-blue-300" : "bg-slate-800 border-slate-700 text-slate-200 hover:bg-slate-700"}`,
|
|
@@ -4522,11 +4433,11 @@ var BridgeMocker = ({
|
|
|
4522
4433
|
children: isPlacingLocation ? "\u{1F4CD} Click the map to drop location\u2026" : "\u{1F4CD} Drop location on map"
|
|
4523
4434
|
}
|
|
4524
4435
|
),
|
|
4525
|
-
/* @__PURE__ */
|
|
4526
|
-
/* @__PURE__ */
|
|
4527
|
-
/* @__PURE__ */
|
|
4528
|
-
/* @__PURE__ */
|
|
4529
|
-
/* @__PURE__ */
|
|
4436
|
+
/* @__PURE__ */ jsxs13("div", { className: "flex flex-col gap-1 border-t border-slate-800 pt-3", children: [
|
|
4437
|
+
/* @__PURE__ */ jsxs13("div", { className: "flex justify-between items-center", children: [
|
|
4438
|
+
/* @__PURE__ */ jsx17("span", { className: "text-[10px] text-slate-500", children: "Scan Radius" }),
|
|
4439
|
+
/* @__PURE__ */ jsxs13("div", { className: "flex items-center gap-1", children: [
|
|
4440
|
+
/* @__PURE__ */ jsx17(
|
|
4530
4441
|
"input",
|
|
4531
4442
|
{
|
|
4532
4443
|
className: "w-16 bg-slate-800 border border-slate-700 rounded px-1.5 py-0.5 text-white text-[10px] focus:outline-none focus:border-blue-500",
|
|
@@ -4536,21 +4447,21 @@ var BridgeMocker = ({
|
|
|
4536
4447
|
value: radiusMeters
|
|
4537
4448
|
}
|
|
4538
4449
|
),
|
|
4539
|
-
/* @__PURE__ */
|
|
4450
|
+
/* @__PURE__ */ jsxs13(
|
|
4540
4451
|
"select",
|
|
4541
4452
|
{
|
|
4542
4453
|
className: "bg-slate-800 border border-slate-700 rounded px-1 py-0.5 text-white text-[10px] focus:outline-none focus:border-blue-500",
|
|
4543
4454
|
onChange: (e) => setRadiusUnit(e.target.value),
|
|
4544
4455
|
value: radiusUnit,
|
|
4545
4456
|
children: [
|
|
4546
|
-
/* @__PURE__ */
|
|
4547
|
-
/* @__PURE__ */
|
|
4457
|
+
/* @__PURE__ */ jsx17("option", { value: "m", children: "m" }),
|
|
4458
|
+
/* @__PURE__ */ jsx17("option", { value: "km", children: "km" })
|
|
4548
4459
|
]
|
|
4549
4460
|
}
|
|
4550
4461
|
)
|
|
4551
4462
|
] })
|
|
4552
4463
|
] }),
|
|
4553
|
-
/* @__PURE__ */
|
|
4464
|
+
/* @__PURE__ */ jsx17(
|
|
4554
4465
|
"input",
|
|
4555
4466
|
{
|
|
4556
4467
|
className: "w-full accent-blue-500",
|
|
@@ -4562,7 +4473,7 @@ var BridgeMocker = ({
|
|
|
4562
4473
|
value: radiusMeters
|
|
4563
4474
|
}
|
|
4564
4475
|
),
|
|
4565
|
-
/* @__PURE__ */
|
|
4476
|
+
/* @__PURE__ */ jsx17("div", { className: "text-right text-slate-400", children: radiusMeters === 0 ? "hidden" : `${radiusMeters}${radiusUnit} radius around user` })
|
|
4566
4477
|
] })
|
|
4567
4478
|
] })
|
|
4568
4479
|
]
|
|
@@ -4572,20 +4483,20 @@ var BridgeMocker = ({
|
|
|
4572
4483
|
};
|
|
4573
4484
|
|
|
4574
4485
|
// src/components/DebugConsole.tsx
|
|
4575
|
-
import { useCallback as
|
|
4576
|
-
import { jsx as
|
|
4486
|
+
import { useCallback as useCallback8, useEffect as useEffect9, useRef as useRef9, useState as useState11 } from "react";
|
|
4487
|
+
import { jsx as jsx18, jsxs as jsxs14 } from "react/jsx-runtime";
|
|
4577
4488
|
var DebugConsole = ({
|
|
4578
4489
|
isOpen: initialOpen = false,
|
|
4579
4490
|
onClose
|
|
4580
4491
|
}) => {
|
|
4581
|
-
const [showConsole, setShowConsole] =
|
|
4582
|
-
const [logs, setLogs] =
|
|
4583
|
-
const scrollRef =
|
|
4492
|
+
const [showConsole, setShowConsole] = useState11(initialOpen);
|
|
4493
|
+
const [logs, setLogs] = useState11([]);
|
|
4494
|
+
const scrollRef = useRef9(null);
|
|
4584
4495
|
useEffect9(() => {
|
|
4585
4496
|
setShowConsole(initialOpen);
|
|
4586
4497
|
}, [initialOpen]);
|
|
4587
4498
|
const clearLogs = () => setLogs([]);
|
|
4588
|
-
const addLog =
|
|
4499
|
+
const addLog = useCallback8((label, data) => {
|
|
4589
4500
|
if (label.includes("LOCATION_STREAM_UPDATE" /* LOCATION_STREAM_UPDATE */)) return;
|
|
4590
4501
|
const entry = {
|
|
4591
4502
|
content: typeof data === "string" ? data : JSON.stringify(data, null, 2),
|
|
@@ -4617,7 +4528,7 @@ var DebugConsole = ({
|
|
|
4617
4528
|
};
|
|
4618
4529
|
}, [addLog]);
|
|
4619
4530
|
if (!showConsole) {
|
|
4620
|
-
return /* @__PURE__ */
|
|
4531
|
+
return /* @__PURE__ */ jsx18(
|
|
4621
4532
|
Button,
|
|
4622
4533
|
{
|
|
4623
4534
|
className: "fixed bottom-4 left-4 w-8 h-8 rounded-full bg-slate-900/60 backdrop-blur-sm border border-slate-700/50 flex items-center justify-center text-slate-400 hover:text-emerald-400 hover:bg-slate-900/80 transition-all z-[9998] shadow-lg group p-0!",
|
|
@@ -4625,7 +4536,7 @@ var DebugConsole = ({
|
|
|
4625
4536
|
title: "Open Debug Console",
|
|
4626
4537
|
type: "button",
|
|
4627
4538
|
variant: "ghost",
|
|
4628
|
-
children: /* @__PURE__ */
|
|
4539
|
+
children: /* @__PURE__ */ jsxs14(
|
|
4629
4540
|
"svg",
|
|
4630
4541
|
{
|
|
4631
4542
|
className: "group-hover:scale-110 transition-transform",
|
|
@@ -4639,31 +4550,31 @@ var DebugConsole = ({
|
|
|
4639
4550
|
width: "14",
|
|
4640
4551
|
xmlns: "http://www.w3.org/2000/svg",
|
|
4641
4552
|
children: [
|
|
4642
|
-
/* @__PURE__ */
|
|
4643
|
-
/* @__PURE__ */
|
|
4644
|
-
/* @__PURE__ */
|
|
4645
|
-
/* @__PURE__ */
|
|
4646
|
-
/* @__PURE__ */
|
|
4647
|
-
/* @__PURE__ */
|
|
4648
|
-
/* @__PURE__ */
|
|
4649
|
-
/* @__PURE__ */
|
|
4650
|
-
/* @__PURE__ */
|
|
4651
|
-
/* @__PURE__ */
|
|
4652
|
-
/* @__PURE__ */
|
|
4553
|
+
/* @__PURE__ */ jsx18("path", { d: "m8 2 1.88 1.88" }),
|
|
4554
|
+
/* @__PURE__ */ jsx18("path", { d: "M14.12 3.88 16 2" }),
|
|
4555
|
+
/* @__PURE__ */ jsx18("path", { d: "M9 7.13v-1a3.003 3.003 0 1 1 6 0v1" }),
|
|
4556
|
+
/* @__PURE__ */ jsx18("path", { d: "M12 20c-3.3 0-6-2.7-6-6v-3a4 4 0 0 1 4-4h4a4 4 0 0 1 4 4v3c0 3.3-2.7 6-6 6" }),
|
|
4557
|
+
/* @__PURE__ */ jsx18("path", { d: "M12 20v-9" }),
|
|
4558
|
+
/* @__PURE__ */ jsx18("path", { d: "M6.53 9C4.6 8.8 3 7.1 3 5" }),
|
|
4559
|
+
/* @__PURE__ */ jsx18("path", { d: "M6 13H2" }),
|
|
4560
|
+
/* @__PURE__ */ jsx18("path", { d: "M3 21c0-2.1 1.7-3.9 3.8-4" }),
|
|
4561
|
+
/* @__PURE__ */ jsx18("path", { d: "M20.97 5c0 2.1-1.6 3.8-3.5 4" }),
|
|
4562
|
+
/* @__PURE__ */ jsx18("path", { d: "M22 13h-4" }),
|
|
4563
|
+
/* @__PURE__ */ jsx18("path", { d: "M17.2 17c2.1.1 3.8 1.9 3.8 4" })
|
|
4653
4564
|
]
|
|
4654
4565
|
}
|
|
4655
4566
|
)
|
|
4656
4567
|
}
|
|
4657
4568
|
);
|
|
4658
4569
|
}
|
|
4659
|
-
return /* @__PURE__ */
|
|
4660
|
-
/* @__PURE__ */
|
|
4661
|
-
/* @__PURE__ */
|
|
4662
|
-
/* @__PURE__ */
|
|
4570
|
+
return /* @__PURE__ */ jsxs14("div", { className: "fixed inset-x-0 bottom-0 w-full bg-[#0a080f] border-t border-slate-800 z-[9998] p-4 shadow-2xl flex flex-col animate-in slide-in-from-bottom duration-300", children: [
|
|
4571
|
+
/* @__PURE__ */ jsxs14("div", { className: "flex items-center justify-between mb-2", children: [
|
|
4572
|
+
/* @__PURE__ */ jsxs14("span", { className: "text-[10px] font-bold uppercase tracking-widest text-slate-400 flex items-center gap-2", children: [
|
|
4573
|
+
/* @__PURE__ */ jsx18("span", { className: "w-2 h-2 rounded-full bg-emerald-500 animate-pulse" }),
|
|
4663
4574
|
"UP SDK Debug Console"
|
|
4664
4575
|
] }),
|
|
4665
|
-
/* @__PURE__ */
|
|
4666
|
-
/* @__PURE__ */
|
|
4576
|
+
/* @__PURE__ */ jsxs14("div", { className: "flex gap-4", children: [
|
|
4577
|
+
/* @__PURE__ */ jsx18(
|
|
4667
4578
|
Button,
|
|
4668
4579
|
{
|
|
4669
4580
|
className: "text-[10px] text-slate-500 font-bold uppercase hover:text-slate-300 hover:bg-transparent transition-colors p-0 h-auto cursor-pointer",
|
|
@@ -4673,7 +4584,7 @@ var DebugConsole = ({
|
|
|
4673
4584
|
children: "Clear"
|
|
4674
4585
|
}
|
|
4675
4586
|
),
|
|
4676
|
-
/* @__PURE__ */
|
|
4587
|
+
/* @__PURE__ */ jsx18(
|
|
4677
4588
|
Button,
|
|
4678
4589
|
{
|
|
4679
4590
|
className: "text-[10px] text-pink-500 font-bold uppercase hover:text-pink-400 hover:bg-transparent transition-colors p-0 h-auto cursor-pointer",
|
|
@@ -4688,21 +4599,21 @@ var DebugConsole = ({
|
|
|
4688
4599
|
)
|
|
4689
4600
|
] })
|
|
4690
4601
|
] }),
|
|
4691
|
-
/* @__PURE__ */
|
|
4602
|
+
/* @__PURE__ */ jsx18(
|
|
4692
4603
|
"div",
|
|
4693
4604
|
{
|
|
4694
4605
|
className: "bg-black/80 rounded-xl p-3 font-mono text-[10px] text-emerald-400 min-h-[120px] max-h-[240px] overflow-y-auto border border-slate-900 custom-scrollbar",
|
|
4695
4606
|
ref: scrollRef,
|
|
4696
|
-
children: logs.length === 0 ? /* @__PURE__ */
|
|
4607
|
+
children: logs.length === 0 ? /* @__PURE__ */ jsx18("div", { className: "text-slate-600 italic text-center py-8", children: "No logs yet. Interacting with the SDK will show events here." }) : logs.map((log) => /* @__PURE__ */ jsxs14(
|
|
4697
4608
|
"div",
|
|
4698
4609
|
{
|
|
4699
4610
|
className: "mb-3 pb-3 border-b border-slate-900/50 last:border-0 last:mb-0 last:pb-0",
|
|
4700
4611
|
children: [
|
|
4701
|
-
/* @__PURE__ */
|
|
4702
|
-
/* @__PURE__ */
|
|
4703
|
-
/* @__PURE__ */
|
|
4612
|
+
/* @__PURE__ */ jsxs14("div", { className: "flex gap-2 text-slate-500 mb-1 items-center", children: [
|
|
4613
|
+
/* @__PURE__ */ jsx18("span", { className: "text-[8px]", children: log.time }),
|
|
4614
|
+
/* @__PURE__ */ jsx18("span", { className: "font-bold text-white uppercase text-[8px] bg-slate-800 px-1.5 py-0.5 rounded leading-none", children: log.label })
|
|
4704
4615
|
] }),
|
|
4705
|
-
/* @__PURE__ */
|
|
4616
|
+
/* @__PURE__ */ jsx18("pre", { className: "whitespace-pre-wrap break-all opacity-90", children: log.content })
|
|
4706
4617
|
]
|
|
4707
4618
|
},
|
|
4708
4619
|
log.id
|
|
@@ -4713,8 +4624,8 @@ var DebugConsole = ({
|
|
|
4713
4624
|
};
|
|
4714
4625
|
|
|
4715
4626
|
// src/components/PullToRefresh.tsx
|
|
4716
|
-
import { useEffect as useEffect10, useRef as
|
|
4717
|
-
import { jsx as
|
|
4627
|
+
import { useEffect as useEffect10, useRef as useRef10, useState as useState12 } from "react";
|
|
4628
|
+
import { jsx as jsx19, jsxs as jsxs15 } from "react/jsx-runtime";
|
|
4718
4629
|
var DEFAULT_PULL_THRESHOLD = 64;
|
|
4719
4630
|
var DEFAULT_MAX_PULL = 96;
|
|
4720
4631
|
var RESISTANCE = 0.5;
|
|
@@ -4725,7 +4636,7 @@ function DefaultIndicator({
|
|
|
4725
4636
|
progress,
|
|
4726
4637
|
isRefreshing
|
|
4727
4638
|
}) {
|
|
4728
|
-
return /* @__PURE__ */
|
|
4639
|
+
return /* @__PURE__ */ jsxs15(
|
|
4729
4640
|
"div",
|
|
4730
4641
|
{
|
|
4731
4642
|
style: {
|
|
@@ -4740,7 +4651,7 @@ function DefaultIndicator({
|
|
|
4740
4651
|
width: 28
|
|
4741
4652
|
},
|
|
4742
4653
|
children: [
|
|
4743
|
-
/* @__PURE__ */
|
|
4654
|
+
/* @__PURE__ */ jsxs15(
|
|
4744
4655
|
"svg",
|
|
4745
4656
|
{
|
|
4746
4657
|
height: 14,
|
|
@@ -4752,8 +4663,8 @@ function DefaultIndicator({
|
|
|
4752
4663
|
viewBox: "0 0 24 24",
|
|
4753
4664
|
width: 14,
|
|
4754
4665
|
children: [
|
|
4755
|
-
/* @__PURE__ */
|
|
4756
|
-
/* @__PURE__ */
|
|
4666
|
+
/* @__PURE__ */ jsx19("title", { children: "Refreshing" }),
|
|
4667
|
+
/* @__PURE__ */ jsx19(
|
|
4757
4668
|
"path",
|
|
4758
4669
|
{
|
|
4759
4670
|
d: "M21 12a9 9 0 1 1-2.64-6.36",
|
|
@@ -4766,7 +4677,7 @@ function DefaultIndicator({
|
|
|
4766
4677
|
]
|
|
4767
4678
|
}
|
|
4768
4679
|
),
|
|
4769
|
-
/* @__PURE__ */
|
|
4680
|
+
/* @__PURE__ */ jsx19("style", { children: "@keyframes up-sdk-ptr-spin { to { transform: rotate(360deg); } }" })
|
|
4770
4681
|
]
|
|
4771
4682
|
}
|
|
4772
4683
|
);
|
|
@@ -4780,26 +4691,45 @@ var PullToRefresh = ({
|
|
|
4780
4691
|
maxPull = DEFAULT_MAX_PULL,
|
|
4781
4692
|
renderIndicator
|
|
4782
4693
|
}) => {
|
|
4783
|
-
const containerRef =
|
|
4784
|
-
const startYRef =
|
|
4785
|
-
const lastYRef =
|
|
4786
|
-
const lastMoveTimeRef =
|
|
4787
|
-
const velocityRef =
|
|
4788
|
-
const pointerIdRef =
|
|
4789
|
-
const isPullingRef =
|
|
4790
|
-
const pullDistanceRef =
|
|
4791
|
-
const flingRafRef =
|
|
4792
|
-
const [pullDistance, setPullDistance] =
|
|
4793
|
-
const [isRefreshing, setIsRefreshing] =
|
|
4794
|
-
const [isTracking, setIsTracking] =
|
|
4795
|
-
const disabledRef =
|
|
4694
|
+
const containerRef = useRef10(null);
|
|
4695
|
+
const startYRef = useRef10(null);
|
|
4696
|
+
const lastYRef = useRef10(0);
|
|
4697
|
+
const lastMoveTimeRef = useRef10(0);
|
|
4698
|
+
const velocityRef = useRef10(0);
|
|
4699
|
+
const pointerIdRef = useRef10(null);
|
|
4700
|
+
const isPullingRef = useRef10(false);
|
|
4701
|
+
const pullDistanceRef = useRef10(0);
|
|
4702
|
+
const flingRafRef = useRef10(null);
|
|
4703
|
+
const [pullDistance, setPullDistance] = useState12(0);
|
|
4704
|
+
const [isRefreshing, setIsRefreshing] = useState12(false);
|
|
4705
|
+
const [isTracking, setIsTracking] = useState12(false);
|
|
4706
|
+
const disabledRef = useRef10(disabled);
|
|
4796
4707
|
disabledRef.current = disabled;
|
|
4797
|
-
const onRefreshRef =
|
|
4708
|
+
const onRefreshRef = useRef10(onRefresh);
|
|
4798
4709
|
onRefreshRef.current = onRefresh;
|
|
4799
|
-
const pullThresholdRef =
|
|
4710
|
+
const pullThresholdRef = useRef10(pullThreshold);
|
|
4800
4711
|
pullThresholdRef.current = pullThreshold;
|
|
4801
|
-
const maxPullRef =
|
|
4712
|
+
const maxPullRef = useRef10(maxPull);
|
|
4802
4713
|
maxPullRef.current = maxPull;
|
|
4714
|
+
useEffect10(() => {
|
|
4715
|
+
const el = containerRef.current;
|
|
4716
|
+
if (!el || typeof window === "undefined") return;
|
|
4717
|
+
const checkScrollChain = () => {
|
|
4718
|
+
const noInternalOverflow = el.scrollHeight <= el.clientHeight;
|
|
4719
|
+
const tallerThanViewport = el.clientHeight > window.innerHeight;
|
|
4720
|
+
if (noInternalOverflow && tallerThanViewport) {
|
|
4721
|
+
console.warn(
|
|
4722
|
+
"[PullToRefresh] This container is taller than the viewport but has no internal scroll (scrollHeight <= clientHeight). Because this component disables native touch scrolling entirely (touch-action: none), scrolling is now completely broken here. This almost always means either: (1) an ancestor's flex-1 item is missing `min-h-0` (a flex item defaults to min-height:auto and refuses to shrink below its content size), or (2) an ancestor uses `min-h-screen`/`min-h-full` (a floor, not a ceiling) instead of `h-full`/`h-screen`/`h-dvh`. See the vault skill js/pull-to-refresh-scroll-chain.md for the fix pattern."
|
|
4723
|
+
);
|
|
4724
|
+
}
|
|
4725
|
+
};
|
|
4726
|
+
const raf = requestAnimationFrame(checkScrollChain);
|
|
4727
|
+
window.addEventListener("resize", checkScrollChain);
|
|
4728
|
+
return () => {
|
|
4729
|
+
cancelAnimationFrame(raf);
|
|
4730
|
+
window.removeEventListener("resize", checkScrollChain);
|
|
4731
|
+
};
|
|
4732
|
+
}, []);
|
|
4803
4733
|
useEffect10(() => {
|
|
4804
4734
|
const el = containerRef.current;
|
|
4805
4735
|
if (!el) return;
|
|
@@ -4931,7 +4861,7 @@ var PullToRefresh = ({
|
|
|
4931
4861
|
const indicatorHeight = isRefreshing ? pullThreshold : pullDistance;
|
|
4932
4862
|
const progress = Math.min(indicatorHeight / pullThreshold, 1);
|
|
4933
4863
|
const isSettling = pullDistance === 0 && !isRefreshing && !isTracking;
|
|
4934
|
-
return /* @__PURE__ */
|
|
4864
|
+
return /* @__PURE__ */ jsxs15(
|
|
4935
4865
|
"div",
|
|
4936
4866
|
{
|
|
4937
4867
|
className: `up-sdk-pull-to-refresh ${className}`,
|
|
@@ -4942,8 +4872,8 @@ var PullToRefresh = ({
|
|
|
4942
4872
|
touchAction: "none"
|
|
4943
4873
|
},
|
|
4944
4874
|
children: [
|
|
4945
|
-
/* @__PURE__ */
|
|
4946
|
-
/* @__PURE__ */
|
|
4875
|
+
/* @__PURE__ */ jsx19("style", { children: ".up-sdk-pull-to-refresh::-webkit-scrollbar { display: none; } .up-sdk-pull-to-refresh { scrollbar-width: none; -ms-overflow-style: none; }" }),
|
|
4876
|
+
/* @__PURE__ */ jsx19(
|
|
4947
4877
|
"div",
|
|
4948
4878
|
{
|
|
4949
4879
|
style: {
|
|
@@ -4956,7 +4886,7 @@ var PullToRefresh = ({
|
|
|
4956
4886
|
userSelect: "none",
|
|
4957
4887
|
width: "100%"
|
|
4958
4888
|
},
|
|
4959
|
-
children: renderIndicator ? renderIndicator({ isRefreshing, progress }) : /* @__PURE__ */
|
|
4889
|
+
children: renderIndicator ? renderIndicator({ isRefreshing, progress }) : /* @__PURE__ */ jsx19(DefaultIndicator, { isRefreshing, progress })
|
|
4960
4890
|
}
|
|
4961
4891
|
),
|
|
4962
4892
|
children
|
|
@@ -4967,15 +4897,15 @@ var PullToRefresh = ({
|
|
|
4967
4897
|
|
|
4968
4898
|
// src/components/QRScanner.tsx
|
|
4969
4899
|
import jsQR2 from "jsqr";
|
|
4970
|
-
import { useEffect as useEffect11, useRef as
|
|
4971
|
-
import { jsx as
|
|
4900
|
+
import { useEffect as useEffect11, useRef as useRef11, useState as useState13 } from "react";
|
|
4901
|
+
import { jsx as jsx20, jsxs as jsxs16 } from "react/jsx-runtime";
|
|
4972
4902
|
function QRScanner({ onScan, onError, className = "" }) {
|
|
4973
|
-
const videoRef =
|
|
4974
|
-
const canvasRef =
|
|
4975
|
-
const streamRef =
|
|
4976
|
-
const tickRequestRef =
|
|
4977
|
-
const hasScannedRef =
|
|
4978
|
-
const [isReady, setIsReady] =
|
|
4903
|
+
const videoRef = useRef11(null);
|
|
4904
|
+
const canvasRef = useRef11(null);
|
|
4905
|
+
const streamRef = useRef11(null);
|
|
4906
|
+
const tickRequestRef = useRef11(null);
|
|
4907
|
+
const hasScannedRef = useRef11(false);
|
|
4908
|
+
const [isReady, setIsReady] = useState13(false);
|
|
4979
4909
|
useEffect11(() => {
|
|
4980
4910
|
let cancelled = false;
|
|
4981
4911
|
hasScannedRef.current = false;
|
|
@@ -5059,7 +4989,7 @@ function QRScanner({ onScan, onError, className = "" }) {
|
|
|
5059
4989
|
cleanup();
|
|
5060
4990
|
};
|
|
5061
4991
|
}, []);
|
|
5062
|
-
return /* @__PURE__ */
|
|
4992
|
+
return /* @__PURE__ */ jsxs16(
|
|
5063
4993
|
"div",
|
|
5064
4994
|
{
|
|
5065
4995
|
className,
|
|
@@ -5071,7 +5001,7 @@ function QRScanner({ onScan, onError, className = "" }) {
|
|
|
5071
5001
|
position: "relative"
|
|
5072
5002
|
},
|
|
5073
5003
|
children: [
|
|
5074
|
-
/* @__PURE__ */
|
|
5004
|
+
/* @__PURE__ */ jsx20(
|
|
5075
5005
|
"video",
|
|
5076
5006
|
{
|
|
5077
5007
|
playsInline: true,
|
|
@@ -5079,8 +5009,8 @@ function QRScanner({ onScan, onError, className = "" }) {
|
|
|
5079
5009
|
style: { height: "100%", objectFit: "cover", width: "100%" }
|
|
5080
5010
|
}
|
|
5081
5011
|
),
|
|
5082
|
-
/* @__PURE__ */
|
|
5083
|
-
isReady && /* @__PURE__ */
|
|
5012
|
+
/* @__PURE__ */ jsx20("canvas", { ref: canvasRef, style: { display: "none" } }),
|
|
5013
|
+
isReady && /* @__PURE__ */ jsx20(
|
|
5084
5014
|
"div",
|
|
5085
5015
|
{
|
|
5086
5016
|
style: {
|
|
@@ -5101,8 +5031,8 @@ function QRScanner({ onScan, onError, className = "" }) {
|
|
|
5101
5031
|
}
|
|
5102
5032
|
|
|
5103
5033
|
// src/components/SDKProvider.tsx
|
|
5104
|
-
import { createContext as createContext3, useContext as useContext6, useMemo as
|
|
5105
|
-
import { Fragment as
|
|
5034
|
+
import { createContext as createContext3, useContext as useContext6, useMemo as useMemo9 } from "react";
|
|
5035
|
+
import { Fragment as Fragment6, jsx as jsx21, jsxs as jsxs17 } from "react/jsx-runtime";
|
|
5106
5036
|
var SDKContext = createContext3({ isMocked: false });
|
|
5107
5037
|
var useIsMocked = () => useContext6(SDKContext).isMocked;
|
|
5108
5038
|
var SDKProvider = ({
|
|
@@ -5111,25 +5041,25 @@ var SDKProvider = ({
|
|
|
5111
5041
|
...mockerProps
|
|
5112
5042
|
}) => {
|
|
5113
5043
|
const isMocked = typeof window !== "undefined" && !(window.__UP_REACT_NATIVE_APP__ === true || !!window.ReactNativeWebView);
|
|
5114
|
-
const value =
|
|
5115
|
-
const content = /* @__PURE__ */
|
|
5044
|
+
const value = useMemo9(() => ({ isMocked }), [isMocked]);
|
|
5045
|
+
const content = /* @__PURE__ */ jsxs17(Fragment6, { children: [
|
|
5116
5046
|
children,
|
|
5117
|
-
(debug || isMocked) && /* @__PURE__ */
|
|
5047
|
+
(debug || isMocked) && /* @__PURE__ */ jsx21(DebugConsole, {})
|
|
5118
5048
|
] });
|
|
5119
5049
|
if (isMocked) {
|
|
5120
|
-
return /* @__PURE__ */
|
|
5050
|
+
return /* @__PURE__ */ jsx21(SDKContext.Provider, { value, children: /* @__PURE__ */ jsx21(BridgeMocker, { ...mockerProps, children: content }) });
|
|
5121
5051
|
}
|
|
5122
|
-
return /* @__PURE__ */
|
|
5052
|
+
return /* @__PURE__ */ jsx21(SDKContext.Provider, { value, children: content });
|
|
5123
5053
|
};
|
|
5124
5054
|
|
|
5125
5055
|
// src/components/SwipeCarousel.tsx
|
|
5126
5056
|
import {
|
|
5127
5057
|
useEffect as useEffect12,
|
|
5128
5058
|
useLayoutEffect,
|
|
5129
|
-
useRef as
|
|
5130
|
-
useState as
|
|
5059
|
+
useRef as useRef12,
|
|
5060
|
+
useState as useState14
|
|
5131
5061
|
} from "react";
|
|
5132
|
-
import { jsx as
|
|
5062
|
+
import { jsx as jsx22 } from "react/jsx-runtime";
|
|
5133
5063
|
var DIRECTION_LOCK_THRESHOLD_PX = 8;
|
|
5134
5064
|
var SWIPE_DISTANCE_THRESHOLD_PX = 40;
|
|
5135
5065
|
var SWIPE_VELOCITY_THRESHOLD = 0.4;
|
|
@@ -5156,21 +5086,21 @@ var SwipeCarousel = ({
|
|
|
5156
5086
|
overscan = DEFAULT_OVERSCAN,
|
|
5157
5087
|
visibleOverscan = DEFAULT_VISIBLE_OVERSCAN
|
|
5158
5088
|
}) => {
|
|
5159
|
-
const containerRef =
|
|
5160
|
-
const [containerWidth, setContainerWidth] =
|
|
5161
|
-
const [dragX, setDragX] =
|
|
5162
|
-
const [dragY, setDragY] =
|
|
5163
|
-
const [isDraggingX, setIsDraggingX] =
|
|
5164
|
-
const [isDraggingY, setIsDraggingY] =
|
|
5165
|
-
const touchStateRef =
|
|
5166
|
-
const [internalIndex, setInternalIndex] =
|
|
5089
|
+
const containerRef = useRef12(null);
|
|
5090
|
+
const [containerWidth, setContainerWidth] = useState14(0);
|
|
5091
|
+
const [dragX, setDragX] = useState14(0);
|
|
5092
|
+
const [dragY, setDragY] = useState14(0);
|
|
5093
|
+
const [isDraggingX, setIsDraggingX] = useState14(false);
|
|
5094
|
+
const [isDraggingY, setIsDraggingY] = useState14(false);
|
|
5095
|
+
const touchStateRef = useRef12(null);
|
|
5096
|
+
const [internalIndex, setInternalIndex] = useState14(
|
|
5167
5097
|
() => Math.max(
|
|
5168
5098
|
0,
|
|
5169
5099
|
items.findIndex((item) => item.id === activeId)
|
|
5170
5100
|
)
|
|
5171
5101
|
);
|
|
5172
|
-
const prevActiveIdRef =
|
|
5173
|
-
const [timingWaiting, setTimingWaiting] =
|
|
5102
|
+
const prevActiveIdRef = useRef12(activeId);
|
|
5103
|
+
const [timingWaiting, setTimingWaiting] = useState14(true);
|
|
5174
5104
|
useEffect12(() => {
|
|
5175
5105
|
const timer = setTimeout(() => {
|
|
5176
5106
|
setTimingWaiting(false);
|
|
@@ -5306,7 +5236,7 @@ var SwipeCarousel = ({
|
|
|
5306
5236
|
};
|
|
5307
5237
|
const windowStart = Math.max(0, activeIndex - overscan);
|
|
5308
5238
|
const windowEnd = Math.min(items.length - 1, activeIndex + overscan);
|
|
5309
|
-
return /* @__PURE__ */
|
|
5239
|
+
return /* @__PURE__ */ jsx22(
|
|
5310
5240
|
"div",
|
|
5311
5241
|
{
|
|
5312
5242
|
className: `relative overflow-hidden touch-pan-y ${className ?? ""}`,
|
|
@@ -5315,7 +5245,7 @@ var SwipeCarousel = ({
|
|
|
5315
5245
|
onTouchMove: handleTouchMove,
|
|
5316
5246
|
onTouchStart: handleTouchStart,
|
|
5317
5247
|
ref: containerRef,
|
|
5318
|
-
children: /* @__PURE__ */
|
|
5248
|
+
children: /* @__PURE__ */ jsx22(
|
|
5319
5249
|
"div",
|
|
5320
5250
|
{
|
|
5321
5251
|
className: "relative h-full",
|
|
@@ -5330,7 +5260,7 @@ var SwipeCarousel = ({
|
|
|
5330
5260
|
const verticalOffset = isActive ? dragY : 0;
|
|
5331
5261
|
const distance = Math.abs(index - activeIndex);
|
|
5332
5262
|
const isVisible = distance <= visibleOverscan;
|
|
5333
|
-
return /* @__PURE__ */
|
|
5263
|
+
return /* @__PURE__ */ jsx22(
|
|
5334
5264
|
"div",
|
|
5335
5265
|
{
|
|
5336
5266
|
className: `absolute top-0 left-0 h-full shrink-0 ${itemClassName ?? ""} ${item.className ?? ""}`,
|
|
@@ -5358,6 +5288,40 @@ var SwipeCarousel = ({
|
|
|
5358
5288
|
);
|
|
5359
5289
|
};
|
|
5360
5290
|
|
|
5291
|
+
// src/hooks/useTapAction.ts
|
|
5292
|
+
import { useRef as useRef13 } from "react";
|
|
5293
|
+
var TAP_MOVE_TOLERANCE_PX = 10;
|
|
5294
|
+
var CLICK_SUPPRESS_WINDOW_MS = 500;
|
|
5295
|
+
var useTapAction = (action) => {
|
|
5296
|
+
const startRef = useRef13(null);
|
|
5297
|
+
const handledByTouchRef = useRef13(false);
|
|
5298
|
+
const onTouchStart = (e) => {
|
|
5299
|
+
const touch = e.targetTouches[0];
|
|
5300
|
+
startRef.current = touch ? { x: touch.clientX, y: touch.clientY } : null;
|
|
5301
|
+
};
|
|
5302
|
+
const onTouchEnd = (e) => {
|
|
5303
|
+
const start = startRef.current;
|
|
5304
|
+
const touch = e.changedTouches[0];
|
|
5305
|
+
startRef.current = null;
|
|
5306
|
+
if (!start || !touch) return;
|
|
5307
|
+
const moved = Math.hypot(touch.clientX - start.x, touch.clientY - start.y);
|
|
5308
|
+
if (moved > TAP_MOVE_TOLERANCE_PX) return;
|
|
5309
|
+
handledByTouchRef.current = true;
|
|
5310
|
+
setTimeout(() => {
|
|
5311
|
+
handledByTouchRef.current = false;
|
|
5312
|
+
}, CLICK_SUPPRESS_WINDOW_MS);
|
|
5313
|
+
action();
|
|
5314
|
+
};
|
|
5315
|
+
const onClick = () => {
|
|
5316
|
+
if (handledByTouchRef.current) {
|
|
5317
|
+
handledByTouchRef.current = false;
|
|
5318
|
+
return;
|
|
5319
|
+
}
|
|
5320
|
+
action();
|
|
5321
|
+
};
|
|
5322
|
+
return { onClick, onTouchEnd, onTouchStart };
|
|
5323
|
+
};
|
|
5324
|
+
|
|
5361
5325
|
// src/services/apiService.ts
|
|
5362
5326
|
function buildUrl(baseUrl, path) {
|
|
5363
5327
|
if (path.startsWith("http://") || path.startsWith("https://")) {
|
|
@@ -5626,6 +5590,7 @@ export {
|
|
|
5626
5590
|
useMapControls,
|
|
5627
5591
|
useMockLocation,
|
|
5628
5592
|
useRoute,
|
|
5593
|
+
useTapAction,
|
|
5629
5594
|
useTrimmedRoute,
|
|
5630
5595
|
useUserLocation
|
|
5631
5596
|
};
|