Compare commits
33 Commits
76643fcc62
...
main
Author | SHA1 | Date | |
---|---|---|---|
105d2aad88
|
|||
1f2bee0b08
|
|||
86d07570c6
|
|||
906dbeca22
|
|||
60bbe418a6
|
|||
650d77bbfd
|
|||
7f06ac94e8
|
|||
ced5259272
|
|||
d1cdf8cf6d
|
|||
4246266f9f
|
|||
956e9b6ffd
|
|||
590539a979
|
|||
abb5c3c584
|
|||
5e61cabcdc
|
|||
8ba47fe2f0
|
|||
834b1643de
|
|||
55aff5f900
|
|||
afcb5427af
|
|||
0b9df38139
|
|||
20f8fd515f
|
|||
256f0b7684
|
|||
409e13277e
|
|||
0433e4695e
|
|||
29c0a234d1
|
|||
a8182befe5
|
|||
ed019a3ed4
|
|||
b726305a44
|
|||
71b7df0008
|
|||
5143bdc446
|
|||
0a3fe8c243
|
|||
1fbd8ee5c3
|
|||
986649a070
|
|||
39312adc2a
|
@ -1,5 +1,6 @@
|
||||
# Public variables
|
||||
EXPO_PUBLIC_TRAINTRAPE_MOI_SERVER=https://traintrapemoi.luemy.eu/api
|
||||
EXPO_PUBLIC_TRAINTRAPE_MOI_SOCKET=https://traintrapemoi.luemy.eu/
|
||||
|
||||
# Build variables
|
||||
ANDROID_HOME=/opt/android-sdk
|
@ -1 +1,2 @@
|
||||
EXPO_PUBLIC_TRAINTRAPE_MOI_SERVER=http://localhost:3000/
|
||||
EXPO_PUBLIC_TRAINTRAPE_MOI_SOCKET=http://localhost:3000/
|
||||
|
5
client/.gitignore
vendored
@ -9,6 +9,11 @@ dist/
|
||||
web-build/
|
||||
expo-env.d.ts
|
||||
|
||||
# Android output
|
||||
*.aab
|
||||
*.apk
|
||||
*.apks
|
||||
|
||||
# Native
|
||||
*.orig.*
|
||||
*.jks
|
||||
|
@ -2,10 +2,10 @@
|
||||
"expo": {
|
||||
"name": "Traintrape-moi",
|
||||
"slug": "traintrape-moi-client",
|
||||
"version": "1.0.0",
|
||||
"version": "1.1.1",
|
||||
"orientation": "portrait",
|
||||
"icon": "./assets/images/icon.png",
|
||||
"scheme": "myapp",
|
||||
"scheme": "traintrapemoi",
|
||||
"userInterfaceStyle": "automatic",
|
||||
"newArchEnabled": true,
|
||||
"ios": {
|
||||
@ -15,17 +15,10 @@
|
||||
"android": {
|
||||
"adaptiveIcon": {
|
||||
"foregroundImage": "./assets/images/adaptive-icon.png",
|
||||
"backgroundColor": "#ffffff"
|
||||
"backgroundColor": "#0033fe"
|
||||
},
|
||||
"package": "eu.luemy.traintrapemoi",
|
||||
"permissions": [
|
||||
"android.permission.ACCESS_COARSE_LOCATION",
|
||||
"android.permission.ACCESS_FINE_LOCATION",
|
||||
"android.permission.ACCESS_BACKGROUND_LOCATION",
|
||||
"android.permission.FOREGROUND_SERVICE",
|
||||
"android.permission.FOREGROUND_SERVICE_LOCATION",
|
||||
"android.permission.RECEIVE_BOOT_COMPLETED",
|
||||
"android.permission.WAKE_LOCK",
|
||||
"android.permission.ACCESS_COARSE_LOCATION",
|
||||
"android.permission.ACCESS_FINE_LOCATION",
|
||||
"android.permission.ACCESS_BACKGROUND_LOCATION",
|
||||
@ -49,17 +42,16 @@
|
||||
"locationAlwaysAndWhenInUsePermission": "Allow $(PRODUCT_NAME) to use your location."
|
||||
}
|
||||
],
|
||||
"expo-notifications",
|
||||
"expo-router",
|
||||
"expo-secure-store",
|
||||
"expo-share-extension",
|
||||
"expo-share-intent",
|
||||
[
|
||||
"expo-splash-screen",
|
||||
{
|
||||
"image": "./assets/images/splash-icon.png",
|
||||
"imageWidth": 200,
|
||||
"imageWidth": 128,
|
||||
"resizeMode": "contain",
|
||||
"backgroundColor": "#ffffff"
|
||||
"backgroundColor": "#0033fe"
|
||||
}
|
||||
],
|
||||
"expo-task-manager",
|
||||
|
@ -1,10 +1,12 @@
|
||||
import { useGameRepairMutation, useGameResetMutation, useGameStartMutation, useGameStopMutation, useGameSwitchPlayerMutation } from '@/hooks/mutations/useGameMutation'
|
||||
import { useAuth } from '@/hooks/useAuth'
|
||||
import { useGame, useUpdateGameState } from '@/hooks/useGame'
|
||||
import { useGame, useSetLocationAccuracy, useUpdateGameState } from '@/hooks/useGame'
|
||||
import { useQueryClient } from '@tanstack/react-query'
|
||||
import { useRouter } from 'expo-router'
|
||||
import { useState } from 'react'
|
||||
import { Button, Dialog, FAB, List, MD3Colors, Portal, Snackbar, Surface, Text } from 'react-native-paper'
|
||||
import { Button, Dialog, List, MD3Colors, Portal, Snackbar, Surface, Text } from 'react-native-paper'
|
||||
import { Dropdown } from 'react-native-paper-dropdown'
|
||||
import { Accuracy } from 'expo-location'
|
||||
|
||||
export default function HistoryScreen() {
|
||||
const [successVisible, setSuccessVisible] = useState(false)
|
||||
@ -17,6 +19,17 @@ export default function HistoryScreen() {
|
||||
const auth = useAuth()
|
||||
const game = useGame()
|
||||
const updateGameState = useUpdateGameState()
|
||||
const setLocationAccuracy = useSetLocationAccuracy()
|
||||
|
||||
const accuracyArrayList = [
|
||||
{ value: Accuracy.BestForNavigation.toString(), label: "Navigation" },
|
||||
{ value: Accuracy.Highest.toString(), label: "Plus haute" },
|
||||
{ value: Accuracy.High.toString(), label: "Haute" },
|
||||
{ value: Accuracy.Balanced.toString(), label: "Équilibrée" },
|
||||
{ value: Accuracy.Low.toString(), label: "Basse" },
|
||||
{ value: Accuracy.Lowest.toString(), label: "Plus basse" },
|
||||
{ value: 'null', label: "Désactivée" },
|
||||
]
|
||||
|
||||
const gameStartMutation = useGameStartMutation({
|
||||
auth,
|
||||
@ -112,6 +125,11 @@ export default function HistoryScreen() {
|
||||
description={auth.loggedIn ? "Vous êtes déjà connecté⋅e" : "Vous n'êtes pas connecté⋅e"}
|
||||
right={() => <List.Icon icon="login" />}
|
||||
onPress={() => router.navigate('/login')} />
|
||||
<List.Item
|
||||
key={"location-accuracy"}
|
||||
title="Précision de la géolocalisation"
|
||||
description="Réglez le niveau de précision de la géolocalisation. Une valeur élevée indique une consommation de batterie accrue."
|
||||
right={() => <Dropdown label={"Géolocalisation"} hideMenuHeader={true} options={accuracyArrayList} value={game.settings.locationAccuracy?.toString() ?? 'null'} onSelect={(value) => setLocationAccuracy(!value || value == 'null' ? null : +value)} />} />
|
||||
</List.Section>
|
||||
<List.Section title={"Gestion du jeu"}>
|
||||
<List.Item
|
||||
|
@ -5,7 +5,8 @@ import { useTrain } from '@/hooks/useTrain'
|
||||
import { TrainTrip } from '@/utils/features/train/trainSlice'
|
||||
import { FontAwesome6 } from '@expo/vector-icons'
|
||||
import { useQueryClient } from '@tanstack/react-query'
|
||||
import { useMemo, useState } from 'react'
|
||||
import { useShareIntentContext } from 'expo-share-intent'
|
||||
import { useEffect, useMemo, useState } from 'react'
|
||||
import { FlatList, StyleSheet } from 'react-native'
|
||||
import { Button, Dialog, Divider, FAB, HelperText, List, MD3Colors, Portal, Snackbar, Surface, Text, TextInput } from 'react-native-paper'
|
||||
|
||||
@ -38,6 +39,23 @@ export default function TrainScreen() {
|
||||
|
||||
const trains = useTrain()
|
||||
|
||||
|
||||
const { hasShareIntent, shareIntent, resetShareIntent } = useShareIntentContext()
|
||||
useEffect(() => {
|
||||
if (hasShareIntent) {
|
||||
resetShareIntent()
|
||||
if (!shareIntent.text || !shareIntent.text.includes("eurailapp.com/share"))
|
||||
return
|
||||
const parsedTrainId = /[0-9A-F]{8}-[0-9A-F]{4}-[0-9A-F]{4}-[0-9A-F]{4}-[0-9A-F]{12}/.exec(shareIntent.text)?.[0]
|
||||
if (parsedTrainId)
|
||||
addTrainMutation.mutate(parsedTrainId)
|
||||
else {
|
||||
setErrorVisible(true)
|
||||
setError([400, "Impossible de récupérer l'identifiant du train à ajouter"])
|
||||
}
|
||||
}
|
||||
}, [hasShareIntent])
|
||||
|
||||
return (
|
||||
<Surface style={{ flex: 1 }}>
|
||||
<PenaltyBanner />
|
||||
|
@ -1,19 +1,20 @@
|
||||
import { DarkTheme, DefaultTheme, ThemeProvider } from '@react-navigation/native'
|
||||
import { Stack, useNavigationContainerRef } from 'expo-router'
|
||||
import { StatusBar } from 'expo-status-bar'
|
||||
import { Provider as StoreProvider } from 'react-redux'
|
||||
import { MD3DarkTheme, MD3LightTheme, PaperProvider } from 'react-native-paper'
|
||||
import AsyncStorage from '@react-native-async-storage/async-storage'
|
||||
import { QueryClient } from '@tanstack/react-query'
|
||||
import { PersistQueryClientProvider } from '@tanstack/react-query-persist-client'
|
||||
import { createAsyncStoragePersister } from '@tanstack/query-async-storage-persister'
|
||||
import { useReactNavigationDevTools } from '@dev-plugins/react-navigation'
|
||||
import { useReactQueryDevTools } from '@dev-plugins/react-query'
|
||||
import AsyncStorage from '@react-native-async-storage/async-storage'
|
||||
import { DarkTheme, DefaultTheme, ThemeProvider } from '@react-navigation/native'
|
||||
import { QueryClient } from '@tanstack/react-query'
|
||||
import { createAsyncStoragePersister } from '@tanstack/query-async-storage-persister'
|
||||
import { PersistQueryClientProvider } from '@tanstack/react-query-persist-client'
|
||||
import { Stack, useNavigationContainerRef } from 'expo-router'
|
||||
import { ShareIntentProvider } from 'expo-share-intent'
|
||||
import { StatusBar } from 'expo-status-bar'
|
||||
import { MD3DarkTheme, MD3LightTheme, PaperProvider } from 'react-native-paper'
|
||||
import { Provider as StoreProvider } from 'react-redux'
|
||||
import GameProvider from '@/components/providers/GameProvider'
|
||||
import GeolocationProvider from '@/components/providers/GeolocationProvider'
|
||||
import LoginProvider from '@/components/providers/LoginProvider'
|
||||
import { useColorScheme } from '@/hooks/useColorScheme'
|
||||
import store from '@/utils/store'
|
||||
import LoginProvider from '@/components/LoginProvider'
|
||||
import GeolocationProvider from '@/components/GeolocationProvider'
|
||||
import GameProvider from '@/components/GameProvider'
|
||||
|
||||
const queryClient = new QueryClient({
|
||||
defaultOptions: {
|
||||
@ -42,24 +43,26 @@ export default function RootLayout() {
|
||||
client={queryClient}
|
||||
persistOptions={{ persister: asyncStoragePersister }}
|
||||
onSuccess={() => queryClient.resumePausedMutations().then(() => queryClient.invalidateQueries())}>
|
||||
<LoginProvider loginRedirect={'/login'}>
|
||||
<GeolocationProvider>
|
||||
<GameProvider>
|
||||
<PaperProvider
|
||||
theme={colorScheme === 'dark' ? MD3DarkTheme : MD3LightTheme} >
|
||||
<ThemeProvider value={colorScheme === 'dark' ? DarkTheme : DefaultTheme}>
|
||||
<Stack>
|
||||
<Stack.Screen name="(tabs)" options={{ headerShown: false }} />
|
||||
<Stack.Screen name="login" options={{ headerShown: false }} />
|
||||
<Stack.Screen name="challenges-list" options={{ headerShown: false }} />
|
||||
<Stack.Screen name="+not-found" />
|
||||
</Stack>
|
||||
<StatusBar style="auto" />
|
||||
</ThemeProvider>
|
||||
</PaperProvider>
|
||||
</GameProvider>
|
||||
</GeolocationProvider>
|
||||
</LoginProvider>
|
||||
<ShareIntentProvider>
|
||||
<LoginProvider loginRedirect={'/login'}>
|
||||
<GeolocationProvider>
|
||||
<GameProvider>
|
||||
<PaperProvider
|
||||
theme={colorScheme === 'dark' ? MD3DarkTheme : MD3LightTheme} >
|
||||
<ThemeProvider value={colorScheme === 'dark' ? DarkTheme : DefaultTheme}>
|
||||
<Stack>
|
||||
<Stack.Screen name="(tabs)" options={{ headerShown: false }} />
|
||||
<Stack.Screen name="login" options={{ headerShown: false }} />
|
||||
<Stack.Screen name="challenges-list" options={{ headerShown: false }} />
|
||||
<Stack.Screen name="+not-found" />
|
||||
</Stack>
|
||||
<StatusBar style="auto" />
|
||||
</ThemeProvider>
|
||||
</PaperProvider>
|
||||
</GameProvider>
|
||||
</GeolocationProvider>
|
||||
</LoginProvider>
|
||||
</ShareIntentProvider>
|
||||
</PersistQueryClientProvider>
|
||||
</StoreProvider>
|
||||
)
|
||||
|
Before Width: | Height: | Size: 17 KiB After Width: | Height: | Size: 17 KiB |
Before Width: | Height: | Size: 1.4 KiB After Width: | Height: | Size: 13 KiB |
Before Width: | Height: | Size: 22 KiB After Width: | Height: | Size: 17 KiB |
Before Width: | Height: | Size: 5.0 KiB |
Before Width: | Height: | Size: 6.2 KiB |
Before Width: | Height: | Size: 14 KiB |
Before Width: | Height: | Size: 21 KiB |
Before Width: | Height: | Size: 17 KiB After Width: | Height: | Size: 17 KiB |
@ -2,10 +2,5 @@ module.exports = function(api) {
|
||||
api.cache(true);
|
||||
return {
|
||||
presets: ['babel-preset-expo'],
|
||||
env: {
|
||||
production: {
|
||||
plugins: ['react-native-paper/babel'],
|
||||
},
|
||||
},
|
||||
}
|
||||
}
|
||||
|
@ -7,13 +7,13 @@ import { Banner, MD3Colors, ProgressBar, Text } from "react-native-paper"
|
||||
export default function FreeChaseBanner() {
|
||||
const game = useGame()
|
||||
const chaseFreeTime = game.chaseFreeTime
|
||||
const chaser = !game.gameStarted && !game.currentRunner && chaseFreeTime !== null
|
||||
const chaser = game.gameStarted && !game.currentRunner && chaseFreeTime !== null
|
||||
const chaseFreeDate = useMemo(() => new Date(chaseFreeTime || 0), [chaseFreeTime])
|
||||
const chaseFreePretty = chaseFreeDate.toLocaleTimeString(undefined, { hour: '2-digit', minute: '2-digit' })
|
||||
const [remainingTime, setRemainingTime] = useState(0)
|
||||
const prettyRemainingTime = useMemo(() => `${Math.floor(remainingTime / 60).toString().padStart(2, '0')}:${Math.floor(remainingTime % 60).toString().padStart(2, '0')}`, [remainingTime])
|
||||
const iconName = useMemo(() => {
|
||||
switch (Math.abs(remainingTime % 4)) {
|
||||
switch (Math.abs(Math.floor(remainingTime) % 4)) {
|
||||
case 0: return 'hourglass-empty'
|
||||
case 1: return 'hourglass-end'
|
||||
case 2: return 'hourglass-half'
|
||||
@ -25,7 +25,7 @@ export default function FreeChaseBanner() {
|
||||
const now = new Date().getTime()
|
||||
if (!chaser || (chaseFreeTime < now && remainingTime < 0))
|
||||
return
|
||||
const interval = setInterval(() => setRemainingTime(Math.floor(chaseFreeTime - now) / 1000), 1000)
|
||||
const interval = setInterval(() => setRemainingTime(Math.floor(chaseFreeTime - new Date().getTime()) / 1000), 1000)
|
||||
return () => clearInterval(interval)
|
||||
}, [game.gameStarted, game.currentRunner, chaseFreeDate])
|
||||
|
||||
|
@ -1,44 +1,91 @@
|
||||
import { StyleSheet } from 'react-native'
|
||||
import MapLibreGL, { Camera, FillLayer, LineLayer, MapView, PointAnnotation, RasterLayer, RasterSource, ShapeSource, UserLocation } from '@maplibre/maplibre-react-native'
|
||||
import { FontAwesome5 } from '@expo/vector-icons'
|
||||
import { FontAwesome5, MaterialIcons } from '@expo/vector-icons'
|
||||
import MapLibreGL, { Camera, FillLayer, LineLayer, MapView, PointAnnotation, RasterLayer, RasterSource, ShapeSource, UserLocation, UserTrackingMode } from '@maplibre/maplibre-react-native'
|
||||
import { useQuery } from '@tanstack/react-query'
|
||||
import { circle } from '@turf/circle'
|
||||
import { useLastOwnLocation, useLastPlayerLocations } from '@/hooks/useLocation'
|
||||
import { useMemo } from 'react'
|
||||
import { PlayerLocation } from '@/utils/features/location/locationSlice'
|
||||
import { reverseGeocodeAsync } from 'expo-location'
|
||||
import React, { useEffect, useMemo, useState } from 'react'
|
||||
import { StyleSheet } from 'react-native'
|
||||
import { Button, Dialog, FAB, Portal, Text } from 'react-native-paper'
|
||||
import { useAuth } from '@/hooks/useAuth'
|
||||
import { useGame } from '@/hooks/useGame'
|
||||
import { useLastOwnLocation, useLastPlayerLocations } from '@/hooks/useLocation'
|
||||
import { isAuthValid } from '@/utils/features/auth/authSlice'
|
||||
import { Player } from '@/utils/features/game/gameSlice'
|
||||
import { PlayerLocation } from '@/utils/features/location/locationSlice'
|
||||
|
||||
export default function Map() {
|
||||
const userLocation = useLastOwnLocation()
|
||||
const [followUser, setFollowUser] = useState(true)
|
||||
|
||||
return (
|
||||
<>
|
||||
<MapWrapper followUser={followUser} setFollowUser={setFollowUser} />
|
||||
<FollowUserButton key={'follow-userr-btn-component'} followUser={followUser} setFollowUser={setFollowUser} />
|
||||
</>
|
||||
)
|
||||
}
|
||||
|
||||
type FollowUserProps = {
|
||||
followUser: boolean,
|
||||
setFollowUser: React.Dispatch<React.SetStateAction<boolean>>,
|
||||
}
|
||||
|
||||
function MapWrapper({ followUser, setFollowUser }: FollowUserProps) {
|
||||
const [displayedPlayerId, setDisplayedPlayerId] = useState<number | null>(null)
|
||||
return (
|
||||
<>
|
||||
<MapComponent followUser={followUser} setFollowUser={setFollowUser} setDisplayedPlayerId={setDisplayedPlayerId} />
|
||||
<Portal>
|
||||
<PlayerLocationDialog displayedPlayerId={displayedPlayerId} onDismiss={() => setDisplayedPlayerId(null)} />
|
||||
</Portal>
|
||||
</>
|
||||
)
|
||||
}
|
||||
|
||||
type MapComponentProps = {
|
||||
followUser?: boolean,
|
||||
setFollowUser: React.Dispatch<React.SetStateAction<boolean>>,
|
||||
setDisplayedPlayerId: React.Dispatch<React.SetStateAction<number | null>>
|
||||
}
|
||||
|
||||
function MapComponent({ followUser, setFollowUser, setDisplayedPlayerId }: MapComponentProps) {
|
||||
MapLibreGL.setAccessToken(null)
|
||||
const userLocation = useLastOwnLocation()
|
||||
return (
|
||||
<MapView
|
||||
logoEnabled={false}
|
||||
compassViewPosition={2}
|
||||
style={styles.map}
|
||||
styleURL="https://openmaptiles.geo.data.gouv.fr/styles/osm-bright/style.json">
|
||||
{/* FIXME Il faudra pouvoir avoir un bouton de suivi pour activer le suivi de la caméro */}
|
||||
{userLocation && <Camera
|
||||
defaultSettings={{centerCoordinate: [userLocation?.coords.longitude, userLocation?.coords.latitude], zoomLevel: 15}} />}
|
||||
defaultSettings={{centerCoordinate: [userLocation?.coords.longitude, userLocation?.coords.latitude], zoomLevel: 15}}
|
||||
followUserLocation={followUser}
|
||||
followUserMode={UserTrackingMode.Follow}
|
||||
followZoomLevel={16}
|
||||
onUserTrackingModeChange={(event) => {
|
||||
if (followUser && !event.nativeEvent.payload.followUserLocation)
|
||||
setFollowUser(false)
|
||||
}} />}
|
||||
|
||||
<RasterSource id="railwaymap-source" tileUrlTemplates={["https://a.tiles.openrailwaymap.org/standard/{z}/{x}/{y}.png"]}></RasterSource>
|
||||
<RasterLayer id="railwaymap-layer" sourceID="railwaymap-source" style={{rasterOpacity: 0.7}} />
|
||||
|
||||
<UserLocation animated={true} renderMode="native" androidRenderMode="compass" showsUserHeadingIndicator={true} />
|
||||
<PlayerLocationsMarkers />
|
||||
<PlayerLocationsMarkers setDisplayedPlayerId={setDisplayedPlayerId} />
|
||||
</MapView>
|
||||
)
|
||||
}
|
||||
|
||||
|
||||
function PlayerLocationsMarkers() {
|
||||
function PlayerLocationsMarkers({ setDisplayedPlayerId }: { setDisplayedPlayerId: React.Dispatch<React.SetStateAction<number | null>> }) {
|
||||
const game = useGame()
|
||||
const lastPlayerLocations = useLastPlayerLocations()
|
||||
return lastPlayerLocations ? lastPlayerLocations
|
||||
.filter(() => !game.currentRunner || !game.gameStarted)
|
||||
.filter(playerLoc => playerLoc.playerId !== game.playerId)
|
||||
.map(playerLoc => <PlayerLocationMarker key={`player-${playerLoc.playerId}-loc`} playerLocation={playerLoc} />) : <></>
|
||||
.map(playerLoc => <PlayerLocationMarker key={`player-${playerLoc.playerId}-loc`} playerLocation={playerLoc} setDisplayedPlayerId={setDisplayedPlayerId} />) : <></>
|
||||
}
|
||||
|
||||
function PlayerLocationMarker({ playerLocation }: { playerLocation: PlayerLocation }) {
|
||||
function PlayerLocationMarker({ playerLocation, setDisplayedPlayerId }: { playerLocation: PlayerLocation, setDisplayedPlayerId: React.Dispatch<React.SetStateAction<number | null>> }) {
|
||||
const accuracyCircle = useMemo(() => circle([playerLocation.longitude, playerLocation.latitude], playerLocation.accuracy, {steps: 64, units: 'meters'}), [playerLocation])
|
||||
return <>
|
||||
<ShapeSource
|
||||
@ -55,7 +102,8 @@ function PlayerLocationMarker({ playerLocation }: { playerLocation: PlayerLocati
|
||||
style={{lineOpacity: 0.4, lineColor: 'red'}}
|
||||
aboveLayerID={`accuracy-radius-fill-${playerLocation.playerId}`} />
|
||||
<PointAnnotation id={`player-location-marker-${playerLocation.playerId}`}
|
||||
coordinate={[playerLocation.longitude, playerLocation.latitude]}>
|
||||
coordinate={[playerLocation.longitude, playerLocation.latitude]}
|
||||
onSelected={() => { setDisplayedPlayerId(playerLocation.playerId) }}>
|
||||
<FontAwesome5 name="map-marker-alt" size={24} color="red" />
|
||||
</PointAnnotation>
|
||||
</>
|
||||
@ -67,3 +115,68 @@ const styles = StyleSheet.create({
|
||||
alignSelf: 'stretch',
|
||||
}
|
||||
})
|
||||
|
||||
function FollowUserButton({ followUser, setFollowUser }: FollowUserProps) {
|
||||
return (
|
||||
<FAB
|
||||
key={'follow-user-btn'}
|
||||
style={{ position: 'absolute', right: 25, bottom: 25 }}
|
||||
icon={(props) => <MaterialIcons name={followUser ? 'my-location' : 'location-searching'} {...props} />}
|
||||
onPress={() => setFollowUser(followUser => !followUser)} />
|
||||
)
|
||||
}
|
||||
|
||||
function PlayerLocationDialog({ displayedPlayerId, onDismiss }: { displayedPlayerId: number | null, onDismiss: () => void }) {
|
||||
const auth = useAuth()
|
||||
const lastPlayerLocations = useLastPlayerLocations()
|
||||
const playersQuery = useQuery({
|
||||
queryKey: ['get-players', auth.token],
|
||||
queryFn: () => fetch(`${process.env.EXPO_PUBLIC_TRAINTRAPE_MOI_SERVER}/players/`, {
|
||||
headers: { "Authorization": `Bearer ${auth.token}` }}
|
||||
).then(resp => resp.json()),
|
||||
enabled: isAuthValid(auth),
|
||||
initialData: { data: [], meta: { currentPage: 0, lastPage: 0, nextPage: 0, prevPage: 0, total: 0, totalPerPage: 0 } },
|
||||
})
|
||||
|
||||
const displayedPlayerLoc = useMemo(() => {
|
||||
return lastPlayerLocations.find(loc => loc.playerId === displayedPlayerId)
|
||||
}, [displayedPlayerId, lastPlayerLocations])
|
||||
|
||||
const displayedPlayerName = useMemo(() => {
|
||||
if (!playersQuery.isSuccess || !displayedPlayerId)
|
||||
return "Chargement…"
|
||||
const player: Player | undefined = playersQuery.data.data.find((player: Player) => player.id === displayedPlayerId)
|
||||
if (!player)
|
||||
return "Chargement…"
|
||||
return player.name
|
||||
}, [displayedPlayerId, playersQuery])
|
||||
|
||||
const [address, setAddress] = useState("Adresse inconnue")
|
||||
useEffect(() => {
|
||||
if (!displayedPlayerLoc)
|
||||
return setAddress("Adresse inconnue")
|
||||
reverseGeocodeAsync(displayedPlayerLoc).then(addresses => setAddress(addresses[0].formattedAddress ?? "Adresse inconnue"))
|
||||
}, [displayedPlayerLoc])
|
||||
|
||||
return (
|
||||
<Dialog visible={displayedPlayerId !== null} onDismiss={onDismiss}>
|
||||
<Dialog.Title>{displayedPlayerName}</Dialog.Title>
|
||||
<Dialog.Content>
|
||||
<Text>
|
||||
Dernière position : {new Date(displayedPlayerLoc?.timestamp ?? 0).toLocaleString()}
|
||||
</Text>
|
||||
<Text>
|
||||
Précision : {displayedPlayerLoc?.accuracy.toPrecision(3)} m
|
||||
</Text>
|
||||
<Text>
|
||||
Adresse estimée : {address}
|
||||
</Text>
|
||||
</Dialog.Content>
|
||||
<Dialog.Actions>
|
||||
<Button onPress={onDismiss}>
|
||||
Fermer
|
||||
</Button>
|
||||
</Dialog.Actions>
|
||||
</Dialog>
|
||||
)
|
||||
}
|
||||
|
@ -1,3 +1,4 @@
|
||||
import { Constants } from '@/constants/Constants'
|
||||
import { useAuth } from '@/hooks/useAuth'
|
||||
import { useChallengeActions, useDownloadChallengeActions } from '@/hooks/useChallengeActions'
|
||||
import { useDownloadChallenges } from '@/hooks/useChallenges'
|
||||
@ -8,7 +9,9 @@ import { isAuthValid } from '@/utils/features/auth/authSlice'
|
||||
import { ChallengeAction, ChallengeActionPayload } from '@/utils/features/challengeActions/challengeActionsSlice'
|
||||
import { Challenge } from '@/utils/features/challenges/challengesSlice'
|
||||
import { useQuery } from '@tanstack/react-query'
|
||||
import { ReactNode, useEffect } from 'react'
|
||||
import { router } from 'expo-router'
|
||||
import { useShareIntentContext } from 'expo-share-intent'
|
||||
import React, { ReactNode, useEffect } from 'react'
|
||||
|
||||
export default function GameProvider({ children }: { children: ReactNode }) {
|
||||
const auth = useAuth()
|
||||
@ -29,7 +32,7 @@ export default function GameProvider({ children }: { children: ReactNode }) {
|
||||
headers: { "Authorization": `Bearer ${auth.token}` }}
|
||||
).then(resp => resp.json()),
|
||||
enabled: isAuthValid(auth),
|
||||
refetchInterval: 5000,
|
||||
refetchInterval: Constants.QUERY_REFETCH_INTERVAL * 1000,
|
||||
})
|
||||
useEffect(() => {
|
||||
if (gameQuery.isSuccess && gameQuery.data)
|
||||
@ -42,7 +45,7 @@ export default function GameProvider({ children }: { children: ReactNode }) {
|
||||
headers: { "Authorization": `Bearer ${auth.token}` }}
|
||||
).then(resp => resp.json()),
|
||||
enabled: isAuthValid(auth) && !!game.playerId,
|
||||
refetchInterval: 5000,
|
||||
refetchInterval: Constants.QUERY_REFETCH_INTERVAL * 1000,
|
||||
})
|
||||
useEffect(() => {
|
||||
if (playerQuery.isSuccess && playerQuery.data) {
|
||||
@ -58,7 +61,7 @@ export default function GameProvider({ children }: { children: ReactNode }) {
|
||||
).then(resp => resp.json()),
|
||||
enabled: isAuthValid(auth) && !!game.playerId,
|
||||
initialData: { data: [], meta: { currentPage: 0, lastPage: 0, nextPage: 0, prevPage: 0, total: 0, totalPerPage: 0 } },
|
||||
refetchInterval: 5000,
|
||||
refetchInterval: Constants.QUERY_REFETCH_INTERVAL * 1000,
|
||||
})
|
||||
useEffect(() => {
|
||||
if (trainsQuery.isSuccess && trainsQuery.data)
|
||||
@ -72,7 +75,7 @@ export default function GameProvider({ children }: { children: ReactNode }) {
|
||||
).then(resp => resp.json()),
|
||||
enabled: isAuthValid(auth),
|
||||
initialData: { data: [], meta: { currentPage: 0, lastPage: 0, nextPage: 0, prevPage: 0, total: 0, totalPerPage: 0 } },
|
||||
refetchInterval: 5000,
|
||||
refetchInterval: Constants.QUERY_REFETCH_INTERVAL * 1000,
|
||||
})
|
||||
useEffect(() => {
|
||||
if (challengesQuery.isSuccess && challengesQuery.data) {
|
||||
@ -89,7 +92,7 @@ export default function GameProvider({ children }: { children: ReactNode }) {
|
||||
headers: { "Authorization": `Bearer ${auth.token}` }}
|
||||
).then(resp => resp.json()),
|
||||
enabled: isAuthValid(auth) && !!game.playerId,
|
||||
refetchInterval: 5000,
|
||||
refetchInterval: Constants.QUERY_REFETCH_INTERVAL * 1000,
|
||||
})
|
||||
useEffect(() => {
|
||||
if (moneyUpdatesQuery.isSuccess && moneyUpdatesQuery.data)
|
||||
@ -108,6 +111,15 @@ export default function GameProvider({ children }: { children: ReactNode }) {
|
||||
}
|
||||
}, [game.currentRunner, challengeActions])
|
||||
|
||||
const { hasShareIntent, shareIntent, resetShareIntent } = useShareIntentContext()
|
||||
useEffect(() => {
|
||||
if (hasShareIntent) {
|
||||
if (!shareIntent.text || !shareIntent.text.includes("eurailapp.com/share"))
|
||||
return resetShareIntent()
|
||||
router.replace('/train')
|
||||
}
|
||||
}, [hasShareIntent])
|
||||
|
||||
return <>
|
||||
{children}
|
||||
</>
|
@ -1,31 +1,50 @@
|
||||
import { ReactNode, useEffect } from 'react'
|
||||
import { useAuth } from '@/hooks/useAuth'
|
||||
import { useQueuedLocations, useSetLastPlayerLocations, useUnqueueLocation } from '@/hooks/useLocation'
|
||||
import { useGeolocationMutation } from '@/hooks/mutations/useGeolocationMutation'
|
||||
import { useStartGeolocationServiceEffect } from '@/utils/geolocation'
|
||||
import { Platform } from 'react-native'
|
||||
import { useQuery } from '@tanstack/react-query'
|
||||
import React, { ReactNode, useEffect } from 'react'
|
||||
import { Platform } from 'react-native'
|
||||
import { Constants } from '@/constants/Constants'
|
||||
import { useAuth } from '@/hooks/useAuth'
|
||||
import { useSetLocationAccuracy } from '@/hooks/useGame'
|
||||
import { useGeolocationMutation } from '@/hooks/mutations/useGeolocationMutation'
|
||||
import { useQueuedLocations, useSetLastPlayerLocation, useSetLastPlayerLocations, useUnqueueLocation } from '@/hooks/useLocation'
|
||||
import { isAuthValid } from '@/utils/features/auth/authSlice'
|
||||
import { PlayerLocation } from '@/utils/features/location/locationSlice'
|
||||
import { useStartGeolocationServiceEffect } from '@/utils/geolocation'
|
||||
import * as SecureStore from '@/utils/SecureStore'
|
||||
import { socket } from '@/utils/socket'
|
||||
import { Accuracy } from 'expo-location'
|
||||
|
||||
export default function GeolocationProvider({ children }: { children: ReactNode }) {
|
||||
useStartGeolocationServiceEffect()
|
||||
|
||||
const auth = useAuth()
|
||||
const setLocationAccuracy = useSetLocationAccuracy()
|
||||
const geolocationsQueue = useQueuedLocations()
|
||||
const unqueueLocation = useUnqueueLocation()
|
||||
const setLastPlayerLocations = useSetLastPlayerLocations()
|
||||
const setLastPlayerLocation = useSetLastPlayerLocation()
|
||||
const geolocationMutation = useGeolocationMutation({
|
||||
auth,
|
||||
onPostSuccess: (data) => unqueueLocation(data),
|
||||
onError: ({ response, error }) => { console.error(response, error) }
|
||||
onPostSuccess: (data, variables) => unqueueLocation(variables),
|
||||
onError: ({ response, error }) => console.error(response, error),
|
||||
})
|
||||
|
||||
useEffect(() => {
|
||||
SecureStore.getItemAsync('locationAccuracy').then(locationAccuracyString => {
|
||||
if (!locationAccuracyString)
|
||||
setLocationAccuracy(Accuracy.Balanced)
|
||||
else if (locationAccuracyString === 'null')
|
||||
setLocationAccuracy(null)
|
||||
else
|
||||
setLocationAccuracy(+locationAccuracyString)
|
||||
})
|
||||
}, [])
|
||||
|
||||
if (Platform.OS !== "web") {
|
||||
useEffect(() => {
|
||||
if (geolocationsQueue.length === 0 || geolocationMutation.isPending || isAuthValid(auth))
|
||||
if (geolocationsQueue.length === 0 || geolocationMutation.isPending || !isAuthValid(auth))
|
||||
return
|
||||
const locToSend = geolocationsQueue[0]
|
||||
geolocationMutation.mutate(locToSend)
|
||||
const locToSend = geolocationsQueue[0]
|
||||
geolocationMutation.mutate(locToSend)
|
||||
}, [auth, geolocationMutation.status, geolocationsQueue])
|
||||
}
|
||||
|
||||
@ -40,13 +59,22 @@ export default function GeolocationProvider({ children }: { children: ReactNode
|
||||
}).then(resp => resp.json()),
|
||||
initialData: [],
|
||||
enabled: isAuthValid(auth),
|
||||
refetchInterval: 5000,
|
||||
refetchInterval: Constants.QUERY_REFETCH_INTERVAL * 1000,
|
||||
})
|
||||
useEffect(() => {
|
||||
if (lastLocationsQuery.isSuccess && lastLocationsQuery.data)
|
||||
setLastPlayerLocations(lastLocationsQuery.data)
|
||||
}, [lastLocationsQuery.status, lastLocationsQuery.dataUpdatedAt])
|
||||
|
||||
useEffect(() => {
|
||||
const locationListener = async (data: PlayerLocation) => {
|
||||
if (data.playerId)
|
||||
setLastPlayerLocation(data)
|
||||
}
|
||||
socket.on('last-location', locationListener)
|
||||
return () => { socket.off('last-location', locationListener) }
|
||||
}, [])
|
||||
|
||||
return <>
|
||||
{children}
|
||||
</>
|
@ -1,6 +1,6 @@
|
||||
import { Href, useRouter } from 'expo-router'
|
||||
import { useRouteInfo } from 'expo-router/build/hooks'
|
||||
import { ReactNode, useEffect } from 'react'
|
||||
import React, { ReactNode, useEffect } from 'react'
|
||||
import { useAuth, useAuthLogin } from '@/hooks/useAuth'
|
||||
import * as SecureStore from '@/utils/SecureStore'
|
||||
import { useLoginMutation } from '@/hooks/mutations/useLoginMutation'
|
||||
@ -47,7 +47,7 @@ export default function LoginProvider({ loginRedirect, children }: Props) {
|
||||
// Renouvellement auto du jeton d'authentification
|
||||
const { name, token } = auth
|
||||
const password = SecureStore.getItem('apiPassword')
|
||||
if (name === null || (password === null && token === null))
|
||||
if (name === null || (password === null && token === null) || loginMutation.isPending)
|
||||
return
|
||||
let waitTime = 0
|
||||
if (token !== null && token !== undefined) {
|
||||
@ -69,7 +69,7 @@ export default function LoginProvider({ loginRedirect, children }: Props) {
|
||||
authLogin({ name: name, token: null })
|
||||
}, waitTime)
|
||||
return () => clearTimeout(timeout)
|
||||
}, [auth, authLogin, game, setPlayerId])
|
||||
}, [auth, authLogin, loginMutation.status, game, setPlayerId])
|
||||
|
||||
return <>
|
||||
{children}
|
@ -1,3 +1,6 @@
|
||||
import { Accuracy } from 'expo-location'
|
||||
|
||||
export const Constants = {
|
||||
MIN_DELAY_LOCATION_SENT: 20
|
||||
MIN_DELAY_LOCATION_SENT: 20,
|
||||
QUERY_REFETCH_INTERVAL: 15,
|
||||
}
|
||||
|
@ -1,7 +1,9 @@
|
||||
import { Accuracy } from "expo-location"
|
||||
import { useAppDispatch, useAppSelector } from "./useStore"
|
||||
import { GamePayload, PenaltyPayload, setPlayerId, updateActiveChallengeId, updateGameState, updateMoney, updatePenalty } from "@/utils/features/game/gameSlice"
|
||||
import { GamePayload, PenaltyPayload, setLocationAccuracy, setPlayerId, updateActiveChallengeId, updateGameState, updateMoney, updatePenalty } from "@/utils/features/game/gameSlice"
|
||||
|
||||
export const useGame = () => useAppSelector((state) => state.game)
|
||||
export const useSettings = () => useAppSelector((state) => state.game.settings)
|
||||
export const useSetPlayerId = () => {
|
||||
const dispath = useAppDispatch()
|
||||
return (playerId: number) => dispath(setPlayerId(playerId))
|
||||
@ -22,3 +24,7 @@ export const useUpdatePenalty = () => {
|
||||
const dispatch = useAppDispatch()
|
||||
return (penalty: PenaltyPayload) => dispatch(updatePenalty(penalty))
|
||||
}
|
||||
export const useSetLocationAccuracy = () => {
|
||||
const dispatch = useAppDispatch()
|
||||
return (accuracy: Accuracy | null) => dispatch(setLocationAccuracy(accuracy))
|
||||
}
|
||||
|
@ -1,6 +1,6 @@
|
||||
import { LocationObject } from "expo-location"
|
||||
import { useAppDispatch, useAppSelector } from "./useStore"
|
||||
import { PlayerLocation, setLastLocation, setLastPlayerLocations, unqueueLocation } from "@/utils/features/location/locationSlice"
|
||||
import { PlayerLocation, setLastLocation, setLastPlayerLocation, setLastPlayerLocations, unqueueLocation } from "@/utils/features/location/locationSlice"
|
||||
|
||||
export const useLastOwnLocation = () => useAppSelector((state) => state.location.lastOwnLocation)
|
||||
export const useQueuedLocations = () => useAppSelector((state) => state.location.queuedLocations)
|
||||
@ -18,3 +18,7 @@ export const useSetLastPlayerLocations = () => {
|
||||
const dispatch = useAppDispatch()
|
||||
return (playerLocations: PlayerLocation[]) => dispatch(setLastPlayerLocations(playerLocations))
|
||||
}
|
||||
export const useSetLastPlayerLocation = () => {
|
||||
const dispatch = useAppDispatch()
|
||||
return (playerLocation: PlayerLocation) => dispatch(setLastPlayerLocation(playerLocation))
|
||||
}
|
||||
|
367
client/package-lock.json
generated
@ -1,12 +1,12 @@
|
||||
{
|
||||
"name": "traintrape-moi-client",
|
||||
"version": "1.0.0",
|
||||
"version": "1.0.1",
|
||||
"lockfileVersion": 3,
|
||||
"requires": true,
|
||||
"packages": {
|
||||
"": {
|
||||
"name": "traintrape-moi-client",
|
||||
"version": "1.0.0",
|
||||
"version": "1.0.1",
|
||||
"dependencies": {
|
||||
"@dev-plugins/react-navigation": "^0.1.0",
|
||||
"@dev-plugins/react-query": "^0.1.0",
|
||||
@ -25,20 +25,17 @@
|
||||
"expo-constants": "~17.0.3",
|
||||
"expo-dev-client": "~5.0.4",
|
||||
"expo-font": "~13.0.1",
|
||||
"expo-haptics": "~14.0.0",
|
||||
"expo-linking": "~7.0.3",
|
||||
"expo-location": "^18.0.2",
|
||||
"expo-notifications": "~0.29.11",
|
||||
"expo-router": "~4.0.9",
|
||||
"expo-secure-store": "~14.0.0",
|
||||
"expo-share-extension": "^2.0.1",
|
||||
"expo-share-intent": "^3.1.1",
|
||||
"expo-splash-screen": "~0.29.13",
|
||||
"expo-status-bar": "~2.0.0",
|
||||
"expo-symbols": "~0.2.0",
|
||||
"expo-system-ui": "~4.0.4",
|
||||
"expo-task-manager": "^12.0.3",
|
||||
"expo-updates": "~0.26.10",
|
||||
"expo-web-browser": "~14.0.1",
|
||||
"maplibre-gl": "^4.7.1",
|
||||
"maplibre-react-components": "^0.1.9",
|
||||
"react": "18.3.1",
|
||||
@ -47,12 +44,12 @@
|
||||
"react-native": "0.76.3",
|
||||
"react-native-gesture-handler": "~2.20.2",
|
||||
"react-native-paper": "^5.12.5",
|
||||
"react-native-reanimated": "~3.16.1",
|
||||
"react-native-paper-dropdown": "^2.3.1",
|
||||
"react-native-safe-area-context": "~4.12.0",
|
||||
"react-native-screens": "~4.1.0",
|
||||
"react-native-web": "~0.19.13",
|
||||
"react-native-webview": "13.12.2",
|
||||
"react-redux": "^9.1.2"
|
||||
"react-redux": "^9.1.2",
|
||||
"socket.io-client": "^4.8.1"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@babel/core": "^7.25.2",
|
||||
@ -1849,6 +1846,7 @@
|
||||
"resolved": "https://registry.npmjs.org/@babel/plugin-transform-template-literals/-/plugin-transform-template-literals-7.25.9.tgz",
|
||||
"integrity": "sha512-o97AE4syN71M/lxrCtQByzphAdlYluKPDBzDVzMmfCobUjjhAryZV0AIpRPrxN0eAkxXO6ZLEScmt+PNhj2OTw==",
|
||||
"license": "MIT",
|
||||
"peer": true,
|
||||
"dependencies": {
|
||||
"@babel/helper-plugin-utils": "^7.25.9"
|
||||
},
|
||||
@ -2955,12 +2953,6 @@
|
||||
"js-yaml": "bin/js-yaml.js"
|
||||
}
|
||||
},
|
||||
"node_modules/@ide/backoff": {
|
||||
"version": "1.0.0",
|
||||
"resolved": "https://registry.npmjs.org/@ide/backoff/-/backoff-1.0.0.tgz",
|
||||
"integrity": "sha512-F0YfUDjvT+Mtt/R4xdl2X0EYCHMMiJqNLdxHD++jDT5ydEFIyqbCHh51Qx2E211dgZprPKhV7sHmnXKpLuvc5g==",
|
||||
"license": "MIT"
|
||||
},
|
||||
"node_modules/@isaacs/cliui": {
|
||||
"version": "8.0.2",
|
||||
"resolved": "https://registry.npmjs.org/@isaacs/cliui/-/cliui-8.0.2.tgz",
|
||||
@ -4654,6 +4646,12 @@
|
||||
"@sinonjs/commons": "^3.0.0"
|
||||
}
|
||||
},
|
||||
"node_modules/@socket.io/component-emitter": {
|
||||
"version": "3.1.2",
|
||||
"resolved": "https://registry.npmjs.org/@socket.io/component-emitter/-/component-emitter-3.1.2.tgz",
|
||||
"integrity": "sha512-9BCxFwvbGg/RsZK9tjXd8s4UcwR0MWeFQ1XEKIQVVvAGJyINdrqKMcTRyLoK8Rse1GjzLV9cwjWV1olXRWEXVA==",
|
||||
"license": "MIT"
|
||||
},
|
||||
"node_modules/@tanstack/query-async-storage-persister": {
|
||||
"version": "5.62.7",
|
||||
"resolved": "https://registry.npmjs.org/@tanstack/query-async-storage-persister/-/query-async-storage-persister-5.62.7.tgz",
|
||||
@ -5679,19 +5677,6 @@
|
||||
"integrity": "sha512-BSHWgDSAiKs50o2Re8ppvp3seVHXSRM44cdSsT9FfNEUUZLOGWVCsiWaRPWM1Znn+mqZ1OfVZ3z3DWEzSp7hRA==",
|
||||
"license": "MIT"
|
||||
},
|
||||
"node_modules/assert": {
|
||||
"version": "2.1.0",
|
||||
"resolved": "https://registry.npmjs.org/assert/-/assert-2.1.0.tgz",
|
||||
"integrity": "sha512-eLHpSK/Y4nhMJ07gDaAzoX/XAKS8PSaojml3M0DM4JpV1LAi5JOJ/p6H/XWrl8L+DzVEvVCW1z3vWAaB9oTsQw==",
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"call-bind": "^1.0.2",
|
||||
"is-nan": "^1.3.2",
|
||||
"object-is": "^1.1.5",
|
||||
"object.assign": "^4.1.4",
|
||||
"util": "^0.12.5"
|
||||
}
|
||||
},
|
||||
"node_modules/assign-symbols": {
|
||||
"version": "1.0.0",
|
||||
"resolved": "https://registry.npmjs.org/assign-symbols/-/assign-symbols-1.0.0.tgz",
|
||||
@ -5975,12 +5960,6 @@
|
||||
"@babel/core": "^7.0.0"
|
||||
}
|
||||
},
|
||||
"node_modules/badgin": {
|
||||
"version": "1.2.3",
|
||||
"resolved": "https://registry.npmjs.org/badgin/-/badgin-1.2.3.tgz",
|
||||
"integrity": "sha512-NQGA7LcfCpSzIbGRbkgjgdWkjy7HI+Th5VLxTJfW5EeaAf3fnS+xWQaQOCYiny+q6QSvxqoSO04vCx+4u++EJw==",
|
||||
"license": "MIT"
|
||||
},
|
||||
"node_modules/balanced-match": {
|
||||
"version": "1.0.2",
|
||||
"resolved": "https://registry.npmjs.org/balanced-match/-/balanced-match-1.0.2.tgz",
|
||||
@ -7116,23 +7095,6 @@
|
||||
"node": ">=8"
|
||||
}
|
||||
},
|
||||
"node_modules/define-properties": {
|
||||
"version": "1.2.1",
|
||||
"resolved": "https://registry.npmjs.org/define-properties/-/define-properties-1.2.1.tgz",
|
||||
"integrity": "sha512-8QmQKqEASLd5nx0U1B1okLElbUuuttJ/AnYmRXbbbGDWh6uS208EjD4Xqq/I9wK7u0v6O08XhTWnt5XtEbR6Dg==",
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"define-data-property": "^1.0.1",
|
||||
"has-property-descriptors": "^1.0.0",
|
||||
"object-keys": "^1.1.1"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">= 0.4"
|
||||
},
|
||||
"funding": {
|
||||
"url": "https://github.com/sponsors/ljharb"
|
||||
}
|
||||
},
|
||||
"node_modules/del": {
|
||||
"version": "6.1.1",
|
||||
"resolved": "https://registry.npmjs.org/del/-/del-6.1.1.tgz",
|
||||
@ -7349,6 +7311,66 @@
|
||||
"once": "^1.4.0"
|
||||
}
|
||||
},
|
||||
"node_modules/engine.io-client": {
|
||||
"version": "6.6.2",
|
||||
"resolved": "https://registry.npmjs.org/engine.io-client/-/engine.io-client-6.6.2.tgz",
|
||||
"integrity": "sha512-TAr+NKeoVTjEVW8P3iHguO1LO6RlUz9O5Y8o7EY0fU+gY1NYqas7NN3slpFtbXEsLMHk0h90fJMfKjRkQ0qUIw==",
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"@socket.io/component-emitter": "~3.1.0",
|
||||
"debug": "~4.3.1",
|
||||
"engine.io-parser": "~5.2.1",
|
||||
"ws": "~8.17.1",
|
||||
"xmlhttprequest-ssl": "~2.1.1"
|
||||
}
|
||||
},
|
||||
"node_modules/engine.io-client/node_modules/debug": {
|
||||
"version": "4.3.7",
|
||||
"resolved": "https://registry.npmjs.org/debug/-/debug-4.3.7.tgz",
|
||||
"integrity": "sha512-Er2nc/H7RrMXZBFCEim6TCmMk02Z8vLC2Rbi1KEBggpo0fS6l0S1nnapwmIi3yW/+GOJap1Krg4w0Hg80oCqgQ==",
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"ms": "^2.1.3"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">=6.0"
|
||||
},
|
||||
"peerDependenciesMeta": {
|
||||
"supports-color": {
|
||||
"optional": true
|
||||
}
|
||||
}
|
||||
},
|
||||
"node_modules/engine.io-client/node_modules/ws": {
|
||||
"version": "8.17.1",
|
||||
"resolved": "https://registry.npmjs.org/ws/-/ws-8.17.1.tgz",
|
||||
"integrity": "sha512-6XQFvXTkbfUOZOKKILFG1PDK2NDQs4azKQl26T0YS5CxqWLgXajbPZ+h4gZekJyRqFU8pvnbAbbs/3TgRPy+GQ==",
|
||||
"license": "MIT",
|
||||
"engines": {
|
||||
"node": ">=10.0.0"
|
||||
},
|
||||
"peerDependencies": {
|
||||
"bufferutil": "^4.0.1",
|
||||
"utf-8-validate": ">=5.0.2"
|
||||
},
|
||||
"peerDependenciesMeta": {
|
||||
"bufferutil": {
|
||||
"optional": true
|
||||
},
|
||||
"utf-8-validate": {
|
||||
"optional": true
|
||||
}
|
||||
}
|
||||
},
|
||||
"node_modules/engine.io-parser": {
|
||||
"version": "5.2.3",
|
||||
"resolved": "https://registry.npmjs.org/engine.io-parser/-/engine.io-parser-5.2.3.tgz",
|
||||
"integrity": "sha512-HqD3yTBfnBxIrbnM1DoD6Pcq8NECnh8d4As1Qgh0z5Gg3jRRIqijury0CL3ghu/edArpUYiYqQiDUQBIs4np3Q==",
|
||||
"license": "MIT",
|
||||
"engines": {
|
||||
"node": ">=10.0.0"
|
||||
}
|
||||
},
|
||||
"node_modules/enhanced-resolve": {
|
||||
"version": "5.17.1",
|
||||
"resolved": "https://registry.npmjs.org/enhanced-resolve/-/enhanced-resolve-5.17.1.tgz",
|
||||
@ -7779,15 +7801,6 @@
|
||||
}
|
||||
}
|
||||
},
|
||||
"node_modules/expo-application": {
|
||||
"version": "6.0.1",
|
||||
"resolved": "https://registry.npmjs.org/expo-application/-/expo-application-6.0.1.tgz",
|
||||
"integrity": "sha512-w+1quSmKp8SYKT+GAFHSN5c6u+PqoVRIfpsLyRQrQdOnBA9dA8Hw6JT9sHNFmA30A2v1b/sdYZE3qKuRJFNSWQ==",
|
||||
"license": "MIT",
|
||||
"peerDependencies": {
|
||||
"expo": "*"
|
||||
}
|
||||
},
|
||||
"node_modules/expo-asset": {
|
||||
"version": "11.0.1",
|
||||
"resolved": "https://registry.npmjs.org/expo-asset/-/expo-asset-11.0.1.tgz",
|
||||
@ -7914,15 +7927,6 @@
|
||||
"react": "*"
|
||||
}
|
||||
},
|
||||
"node_modules/expo-haptics": {
|
||||
"version": "14.0.0",
|
||||
"resolved": "https://registry.npmjs.org/expo-haptics/-/expo-haptics-14.0.0.tgz",
|
||||
"integrity": "sha512-5tYJN+2axYF22BtG1elBQAV1aZPUOCtr9sItClfm4jDoekGiPCxZG/nylcA3DVh2bUHMSll4Y98qjFFFhwZ1Cw==",
|
||||
"license": "MIT",
|
||||
"peerDependencies": {
|
||||
"expo": "*"
|
||||
}
|
||||
},
|
||||
"node_modules/expo-json-utils": {
|
||||
"version": "0.14.0",
|
||||
"resolved": "https://registry.npmjs.org/expo-json-utils/-/expo-json-utils-0.14.0.tgz",
|
||||
@ -8039,26 +8043,6 @@
|
||||
"invariant": "^2.2.4"
|
||||
}
|
||||
},
|
||||
"node_modules/expo-notifications": {
|
||||
"version": "0.29.11",
|
||||
"resolved": "https://registry.npmjs.org/expo-notifications/-/expo-notifications-0.29.11.tgz",
|
||||
"integrity": "sha512-u/Csc3YNOPjjuyjAeyj5ne7XR/Z0ABYVquhSnyjEj2Fp8mSldOPCMvaEA01pTFj+8HTlkjX5RZDvQ7cR62ngOA==",
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"@expo/image-utils": "^0.6.0",
|
||||
"@ide/backoff": "^1.0.0",
|
||||
"abort-controller": "^3.0.0",
|
||||
"assert": "^2.0.0",
|
||||
"badgin": "^1.1.5",
|
||||
"expo-application": "~6.0.0",
|
||||
"expo-constants": "~17.0.0"
|
||||
},
|
||||
"peerDependencies": {
|
||||
"expo": "*",
|
||||
"react": "*",
|
||||
"react-native": "*"
|
||||
}
|
||||
},
|
||||
"node_modules/expo-router": {
|
||||
"version": "4.0.11",
|
||||
"resolved": "https://registry.npmjs.org/expo-router/-/expo-router-4.0.11.tgz",
|
||||
@ -8121,33 +8105,31 @@
|
||||
"expo": "*"
|
||||
}
|
||||
},
|
||||
"node_modules/expo-share-extension": {
|
||||
"version": "2.0.1",
|
||||
"resolved": "https://registry.npmjs.org/expo-share-extension/-/expo-share-extension-2.0.1.tgz",
|
||||
"integrity": "sha512-MFjzN8xapBAz3f8lZCTmgVYjVeVa8gUC0NLuTTMgeIwNlua3HW/ySbkYxyRsSX48q7MtVV/OwxqkOfnw6Bpj/w==",
|
||||
"node_modules/expo-share-intent": {
|
||||
"version": "3.1.1",
|
||||
"resolved": "https://registry.npmjs.org/expo-share-intent/-/expo-share-intent-3.1.1.tgz",
|
||||
"integrity": "sha512-YoO7arEP8oRRevQ3digP7Fu1r1Nk6Zo2LfPndWfLXota1O8BLlAkl15W5dOLqRrYIAuRfQpcmmtXu/pUA0pvQg==",
|
||||
"funding": [
|
||||
{
|
||||
"type": "github",
|
||||
"url": "https://github.com/sponsors/achorein"
|
||||
},
|
||||
"https://www.buymeacoffee.com/achorein"
|
||||
],
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"semver": "^7.6.3",
|
||||
"zod": "^3.23.8"
|
||||
"@expo/config-plugins": "^9.0.9",
|
||||
"expo-constants": "^17.0.2",
|
||||
"expo-linking": "~7.0.2"
|
||||
},
|
||||
"peerDependencies": {
|
||||
"expo": "*",
|
||||
"expo": "^52",
|
||||
"expo-constants": ">=17.0.2",
|
||||
"expo-linking": ">=7.0.2",
|
||||
"react": "*",
|
||||
"react-native": "*"
|
||||
}
|
||||
},
|
||||
"node_modules/expo-share-extension/node_modules/semver": {
|
||||
"version": "7.6.3",
|
||||
"resolved": "https://registry.npmjs.org/semver/-/semver-7.6.3.tgz",
|
||||
"integrity": "sha512-oVekP1cKtI+CTDvHWYFUcMtsK/00wmAEfyqKfNdARm8u1wNVhSgaX7A8d4UuIlUI5e84iEwOhs7ZPYRmzU9U6A==",
|
||||
"license": "ISC",
|
||||
"bin": {
|
||||
"semver": "bin/semver.js"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">=10"
|
||||
}
|
||||
},
|
||||
"node_modules/expo-splash-screen": {
|
||||
"version": "0.29.18",
|
||||
"resolved": "https://registry.npmjs.org/expo-splash-screen/-/expo-splash-screen-0.29.18.tgz",
|
||||
@ -8265,16 +8247,6 @@
|
||||
"integrity": "sha512-ZWc51jO3qegGkVh8Hwpv636EkbesNV5ZNQPCtRa+0qytRYPEs9IYT9qITY9buezqUH5uqyzlWLcufrzU2rffdg==",
|
||||
"license": "MIT"
|
||||
},
|
||||
"node_modules/expo-web-browser": {
|
||||
"version": "14.0.1",
|
||||
"resolved": "https://registry.npmjs.org/expo-web-browser/-/expo-web-browser-14.0.1.tgz",
|
||||
"integrity": "sha512-QM9F3ie+UyIOoBvqFmT6CZojb1vMc2H+7ZlMT5dEu1PL2jtYyOeK2hLfbt/EMt7CBm/w+P29H9W9Y9gdebOkuQ==",
|
||||
"license": "MIT",
|
||||
"peerDependencies": {
|
||||
"expo": "*",
|
||||
"react-native": "*"
|
||||
}
|
||||
},
|
||||
"node_modules/exponential-backoff": {
|
||||
"version": "3.1.1",
|
||||
"resolved": "https://registry.npmjs.org/exponential-backoff/-/exponential-backoff-3.1.1.tgz",
|
||||
@ -9493,22 +9465,6 @@
|
||||
"node": ">=0.10.0"
|
||||
}
|
||||
},
|
||||
"node_modules/is-nan": {
|
||||
"version": "1.3.2",
|
||||
"resolved": "https://registry.npmjs.org/is-nan/-/is-nan-1.3.2.tgz",
|
||||
"integrity": "sha512-E+zBKpQ2t6MEo1VsonYmluk9NxGrbzpeeLC2xIViuO2EjU2xsXsBPwTr3Ykv9l08UYEVEdWeRZNouaZqF6RN0w==",
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"call-bind": "^1.0.0",
|
||||
"define-properties": "^1.1.3"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">= 0.4"
|
||||
},
|
||||
"funding": {
|
||||
"url": "https://github.com/sponsors/ljharb"
|
||||
}
|
||||
},
|
||||
"node_modules/is-number": {
|
||||
"version": "7.0.0",
|
||||
"resolved": "https://registry.npmjs.org/is-number/-/is-number-7.0.0.tgz",
|
||||
@ -12387,49 +12343,6 @@
|
||||
"node": ">=0.10.0"
|
||||
}
|
||||
},
|
||||
"node_modules/object-is": {
|
||||
"version": "1.1.6",
|
||||
"resolved": "https://registry.npmjs.org/object-is/-/object-is-1.1.6.tgz",
|
||||
"integrity": "sha512-F8cZ+KfGlSGi09lJT7/Nd6KJZ9ygtvYC0/UYYLI9nmQKLMnydpB9yvbv9K1uSkEu7FU9vYPmVwLg328tX+ot3Q==",
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"call-bind": "^1.0.7",
|
||||
"define-properties": "^1.2.1"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">= 0.4"
|
||||
},
|
||||
"funding": {
|
||||
"url": "https://github.com/sponsors/ljharb"
|
||||
}
|
||||
},
|
||||
"node_modules/object-keys": {
|
||||
"version": "1.1.1",
|
||||
"resolved": "https://registry.npmjs.org/object-keys/-/object-keys-1.1.1.tgz",
|
||||
"integrity": "sha512-NuAESUOUMrlIXOfHKzD6bpPu3tYt3xvjNdRIQ+FeT0lNb4K8WR70CaDxhuNguS2XG+GjkyMwOzsN5ZktImfhLA==",
|
||||
"license": "MIT",
|
||||
"engines": {
|
||||
"node": ">= 0.4"
|
||||
}
|
||||
},
|
||||
"node_modules/object.assign": {
|
||||
"version": "4.1.5",
|
||||
"resolved": "https://registry.npmjs.org/object.assign/-/object.assign-4.1.5.tgz",
|
||||
"integrity": "sha512-byy+U7gp+FVwmyzKPYhW2h5l3crpmGsxl7X2s8y43IgxvG4g3QZ6CffDtsNQy1WsmZpQbO+ybo0AlW7TY6DcBQ==",
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"call-bind": "^1.0.5",
|
||||
"define-properties": "^1.2.1",
|
||||
"has-symbols": "^1.0.3",
|
||||
"object-keys": "^1.1.1"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">= 0.4"
|
||||
},
|
||||
"funding": {
|
||||
"url": "https://github.com/sponsors/ljharb"
|
||||
}
|
||||
},
|
||||
"node_modules/on-finished": {
|
||||
"version": "2.3.0",
|
||||
"resolved": "https://registry.npmjs.org/on-finished/-/on-finished-2.3.0.tgz",
|
||||
@ -13566,6 +13479,23 @@
|
||||
"react-native-vector-icons": "*"
|
||||
}
|
||||
},
|
||||
"node_modules/react-native-paper-dropdown": {
|
||||
"version": "2.3.1",
|
||||
"resolved": "https://registry.npmjs.org/react-native-paper-dropdown/-/react-native-paper-dropdown-2.3.1.tgz",
|
||||
"integrity": "sha512-IvcHTucAV5+fiX2IVMiVdBDKT6KHxycW0o9QzZe7bpmeZWmuCajHDnwG3OSBGlXhUxrrM3TC0/HJZHwORWGgQg==",
|
||||
"license": "MIT",
|
||||
"workspaces": [
|
||||
"example"
|
||||
],
|
||||
"dependencies": {
|
||||
"react-native-paper": "^5.12.3"
|
||||
},
|
||||
"peerDependencies": {
|
||||
"react": "*",
|
||||
"react-native": "*",
|
||||
"react-native-paper": "*"
|
||||
}
|
||||
},
|
||||
"node_modules/react-native-paper/node_modules/color": {
|
||||
"version": "3.2.1",
|
||||
"resolved": "https://registry.npmjs.org/color/-/color-3.2.1.tgz",
|
||||
@ -13605,6 +13535,8 @@
|
||||
"resolved": "https://registry.npmjs.org/react-native-reanimated/-/react-native-reanimated-3.16.5.tgz",
|
||||
"integrity": "sha512-mq/5k14pimkhCeP9XwFJkEr8XufaHqIekum8fqpsn0fcBzbLvyiqfM2LEuBvi0+DTv5Bd2dHmUHkYqGYfkj3Jw==",
|
||||
"license": "MIT",
|
||||
"optional": true,
|
||||
"peer": true,
|
||||
"dependencies": {
|
||||
"@babel/plugin-transform-arrow-functions": "^7.0.0-0",
|
||||
"@babel/plugin-transform-class-properties": "^7.0.0-0",
|
||||
@ -13778,6 +13710,8 @@
|
||||
"resolved": "https://registry.npmjs.org/react-native-webview/-/react-native-webview-13.12.2.tgz",
|
||||
"integrity": "sha512-OpRcEhf1IEushREax6rrKTeqGrHZ9OmryhZLBLQQU4PwjqVsq55iC8OdYSD61/F628f9rURn9THyxEZjrknpQQ==",
|
||||
"license": "MIT",
|
||||
"optional": true,
|
||||
"peer": true,
|
||||
"dependencies": {
|
||||
"escape-string-regexp": "^4.0.0",
|
||||
"invariant": "2.2.4"
|
||||
@ -14800,6 +14734,68 @@
|
||||
"node": ">=8.0.0"
|
||||
}
|
||||
},
|
||||
"node_modules/socket.io-client": {
|
||||
"version": "4.8.1",
|
||||
"resolved": "https://registry.npmjs.org/socket.io-client/-/socket.io-client-4.8.1.tgz",
|
||||
"integrity": "sha512-hJVXfu3E28NmzGk8o1sHhN3om52tRvwYeidbj7xKy2eIIse5IoKX3USlS6Tqt3BHAtflLIkCQBkzVrEEfWUyYQ==",
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"@socket.io/component-emitter": "~3.1.0",
|
||||
"debug": "~4.3.2",
|
||||
"engine.io-client": "~6.6.1",
|
||||
"socket.io-parser": "~4.2.4"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">=10.0.0"
|
||||
}
|
||||
},
|
||||
"node_modules/socket.io-client/node_modules/debug": {
|
||||
"version": "4.3.7",
|
||||
"resolved": "https://registry.npmjs.org/debug/-/debug-4.3.7.tgz",
|
||||
"integrity": "sha512-Er2nc/H7RrMXZBFCEim6TCmMk02Z8vLC2Rbi1KEBggpo0fS6l0S1nnapwmIi3yW/+GOJap1Krg4w0Hg80oCqgQ==",
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"ms": "^2.1.3"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">=6.0"
|
||||
},
|
||||
"peerDependenciesMeta": {
|
||||
"supports-color": {
|
||||
"optional": true
|
||||
}
|
||||
}
|
||||
},
|
||||
"node_modules/socket.io-parser": {
|
||||
"version": "4.2.4",
|
||||
"resolved": "https://registry.npmjs.org/socket.io-parser/-/socket.io-parser-4.2.4.tgz",
|
||||
"integrity": "sha512-/GbIKmo8ioc+NIWIhwdecY0ge+qVBSMdgxGygevmdHj24bsfgtCmcUUcQ5ZzcylGFHsN3k4HB4Cgkl96KVnuew==",
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"@socket.io/component-emitter": "~3.1.0",
|
||||
"debug": "~4.3.1"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">=10.0.0"
|
||||
}
|
||||
},
|
||||
"node_modules/socket.io-parser/node_modules/debug": {
|
||||
"version": "4.3.7",
|
||||
"resolved": "https://registry.npmjs.org/debug/-/debug-4.3.7.tgz",
|
||||
"integrity": "sha512-Er2nc/H7RrMXZBFCEim6TCmMk02Z8vLC2Rbi1KEBggpo0fS6l0S1nnapwmIi3yW/+GOJap1Krg4w0Hg80oCqgQ==",
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"ms": "^2.1.3"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">=6.0"
|
||||
},
|
||||
"peerDependenciesMeta": {
|
||||
"supports-color": {
|
||||
"optional": true
|
||||
}
|
||||
}
|
||||
},
|
||||
"node_modules/sort-asc": {
|
||||
"version": "0.2.0",
|
||||
"resolved": "https://registry.npmjs.org/sort-asc/-/sort-asc-0.2.0.tgz",
|
||||
@ -16707,6 +16703,14 @@
|
||||
"dev": true,
|
||||
"license": "MIT"
|
||||
},
|
||||
"node_modules/xmlhttprequest-ssl": {
|
||||
"version": "2.1.2",
|
||||
"resolved": "https://registry.npmjs.org/xmlhttprequest-ssl/-/xmlhttprequest-ssl-2.1.2.tgz",
|
||||
"integrity": "sha512-TEU+nJVUUnA4CYJFLvK5X9AOeH4KvDvhIfm0vV1GaQRtchnG0hgK5p8hw/xjv8cunWYCsiPCSDzObPyhEwq3KQ==",
|
||||
"engines": {
|
||||
"node": ">=0.4.0"
|
||||
}
|
||||
},
|
||||
"node_modules/xtend": {
|
||||
"version": "4.0.2",
|
||||
"resolved": "https://registry.npmjs.org/xtend/-/xtend-4.0.2.tgz",
|
||||
@ -16801,15 +16805,6 @@
|
||||
"funding": {
|
||||
"url": "https://github.com/sponsors/sindresorhus"
|
||||
}
|
||||
},
|
||||
"node_modules/zod": {
|
||||
"version": "3.24.1",
|
||||
"resolved": "https://registry.npmjs.org/zod/-/zod-3.24.1.tgz",
|
||||
"integrity": "sha512-muH7gBL9sI1nciMZV67X5fTKKBLtwpZ5VBp1vsOQzj1MhrBZ4wlVCm3gedKZWLp0Oyel8sIGfeiz54Su+OVT+A==",
|
||||
"license": "MIT",
|
||||
"funding": {
|
||||
"url": "https://github.com/sponsors/colinhacks"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1,7 +1,7 @@
|
||||
{
|
||||
"name": "traintrape-moi-client",
|
||||
"main": "expo-router/entry",
|
||||
"version": "1.0.0",
|
||||
"version": "1.1.1",
|
||||
"scripts": {
|
||||
"start": "expo start",
|
||||
"android": "expo run:android",
|
||||
@ -31,20 +31,17 @@
|
||||
"expo-constants": "~17.0.3",
|
||||
"expo-dev-client": "~5.0.4",
|
||||
"expo-font": "~13.0.1",
|
||||
"expo-haptics": "~14.0.0",
|
||||
"expo-linking": "~7.0.3",
|
||||
"expo-location": "^18.0.2",
|
||||
"expo-notifications": "~0.29.11",
|
||||
"expo-router": "~4.0.9",
|
||||
"expo-secure-store": "~14.0.0",
|
||||
"expo-share-extension": "^2.0.1",
|
||||
"expo-share-intent": "^3.1.1",
|
||||
"expo-splash-screen": "~0.29.13",
|
||||
"expo-status-bar": "~2.0.0",
|
||||
"expo-symbols": "~0.2.0",
|
||||
"expo-system-ui": "~4.0.4",
|
||||
"expo-task-manager": "^12.0.3",
|
||||
"expo-updates": "~0.26.10",
|
||||
"expo-web-browser": "~14.0.1",
|
||||
"maplibre-gl": "^4.7.1",
|
||||
"maplibre-react-components": "^0.1.9",
|
||||
"react": "18.3.1",
|
||||
@ -53,12 +50,12 @@
|
||||
"react-native": "0.76.3",
|
||||
"react-native-gesture-handler": "~2.20.2",
|
||||
"react-native-paper": "^5.12.5",
|
||||
"react-native-reanimated": "~3.16.1",
|
||||
"react-native-paper-dropdown": "^2.3.1",
|
||||
"react-native-safe-area-context": "~4.12.0",
|
||||
"react-native-screens": "~4.1.0",
|
||||
"react-native-web": "~0.19.13",
|
||||
"react-native-webview": "13.12.2",
|
||||
"react-redux": "^9.1.2"
|
||||
"react-redux": "^9.1.2",
|
||||
"socket.io-client": "^4.8.1"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@babel/core": "^7.25.2",
|
||||
|
@ -1,4 +1,6 @@
|
||||
import { createSlice, PayloadAction } from '@reduxjs/toolkit'
|
||||
import { Accuracy } from 'expo-location'
|
||||
import * as SecureStore from '@/utils/SecureStore'
|
||||
|
||||
export interface RunPayload {
|
||||
id: number
|
||||
@ -20,6 +22,13 @@ export interface PenaltyPayload {
|
||||
penaltyEnd: number | null
|
||||
}
|
||||
|
||||
export interface Player {
|
||||
id: number
|
||||
name: string
|
||||
money: number
|
||||
activeChallengeId: number | null
|
||||
}
|
||||
|
||||
export interface GameState {
|
||||
playerId: number | null
|
||||
runId: number | null
|
||||
@ -30,6 +39,11 @@ export interface GameState {
|
||||
chaseFreeTime: number | null // date
|
||||
penaltyStart: number | null // date
|
||||
penaltyEnd: number | null //date
|
||||
settings: Settings
|
||||
}
|
||||
|
||||
export interface Settings {
|
||||
locationAccuracy: Accuracy | null
|
||||
}
|
||||
|
||||
const initialState: GameState = {
|
||||
@ -42,6 +56,9 @@ const initialState: GameState = {
|
||||
chaseFreeTime: null,
|
||||
penaltyStart: null,
|
||||
penaltyEnd: null,
|
||||
settings: {
|
||||
locationAccuracy: Accuracy.Highest,
|
||||
}
|
||||
}
|
||||
|
||||
export const gameSlice = createSlice({
|
||||
@ -70,10 +87,14 @@ export const gameSlice = createSlice({
|
||||
updatePenalty: (state, action: PayloadAction<PenaltyPayload>) => {
|
||||
state.penaltyStart = action.payload.penaltyStart
|
||||
state.penaltyEnd = action.payload.penaltyEnd
|
||||
},
|
||||
setLocationAccuracy: (state, action: PayloadAction<Accuracy | null>) => {
|
||||
state.settings.locationAccuracy = action.payload
|
||||
SecureStore.setItem('locationAccuracy', action.payload?.toString() ?? 'null')
|
||||
}
|
||||
},
|
||||
})
|
||||
|
||||
export const { setPlayerId, updateMoney, updateActiveChallengeId, updateGameState, updatePenalty } = gameSlice.actions
|
||||
export const { setLocationAccuracy, setPlayerId, updateMoney, updateActiveChallengeId, updateGameState, updatePenalty } = gameSlice.actions
|
||||
|
||||
export default gameSlice.reducer
|
||||
|
@ -1,9 +1,10 @@
|
||||
import { Constants } from '@/constants/Constants'
|
||||
import { createSlice, PayloadAction } from '@reduxjs/toolkit'
|
||||
import { LocationObject } from 'expo-location'
|
||||
import { Constants } from '@/constants/Constants'
|
||||
|
||||
|
||||
export type PlayerLocation = {
|
||||
id: number
|
||||
id?: number
|
||||
playerId: number
|
||||
longitude: number
|
||||
latitude: number
|
||||
@ -44,15 +45,19 @@ export const locationSlice = createSlice({
|
||||
const sentLoc = action.payload
|
||||
state.queuedLocations = state.queuedLocations
|
||||
.filter(loc => new Date(loc.timestamp).getTime() !== sentLoc.timestamp
|
||||
|| loc.coords.latitude !== sentLoc.coords.latitude
|
||||
|| loc.coords.longitude !== sentLoc.coords.latitude)
|
||||
&& loc.coords.latitude !== sentLoc.coords.latitude
|
||||
&& loc.coords.longitude !== sentLoc.coords.longitude)
|
||||
},
|
||||
setLastPlayerLocations: (state, action: PayloadAction<PlayerLocation[]>) => {
|
||||
state.lastPlayerLocations = action.payload
|
||||
},
|
||||
setLastPlayerLocation: (state, action: PayloadAction<PlayerLocation>) => {
|
||||
state.lastPlayerLocations = state.lastPlayerLocations.filter(playerLoc => playerLoc.playerId !== action.payload.playerId)
|
||||
state.lastPlayerLocations.push(action.payload)
|
||||
}
|
||||
},
|
||||
})
|
||||
|
||||
export const { setLastLocation, unqueueLocation, setLastPlayerLocations } = locationSlice.actions
|
||||
export const { setLastLocation, unqueueLocation, setLastPlayerLocation, setLastPlayerLocations } = locationSlice.actions
|
||||
|
||||
export default locationSlice.reducer
|
||||
|
@ -1,11 +1,15 @@
|
||||
import * as Location from 'expo-location'
|
||||
import * as TaskManager from 'expo-task-manager'
|
||||
import { Platform } from 'react-native'
|
||||
import { setLastLocation } from './features/location/locationSlice'
|
||||
import { PlayerLocation, setLastLocation } from './features/location/locationSlice'
|
||||
import store from './store'
|
||||
import { useEffect } from 'react'
|
||||
import { socket } from './socket'
|
||||
import { useSettings } from '@/hooks/useGame'
|
||||
import { useAuth } from '@/hooks/useAuth'
|
||||
import { isAuthValid } from './features/auth/authSlice'
|
||||
|
||||
const LOCATION_TASK = "fetch-geolocation"
|
||||
const LOCATION_TASK = "TRAINTRAPE_MOI_GEOLOCATION"
|
||||
|
||||
TaskManager.defineTask(LOCATION_TASK, async ({ data, error }: any) => {
|
||||
if (error) {
|
||||
@ -13,12 +17,32 @@ TaskManager.defineTask(LOCATION_TASK, async ({ data, error }: any) => {
|
||||
return
|
||||
}
|
||||
const { locations } = data
|
||||
store.dispatch(setLastLocation(locations.at(-1)))
|
||||
const lastLoc: Location.LocationObject = locations.at(-1)
|
||||
if (__DEV__)
|
||||
console.log("Localisation reçue :", lastLoc)
|
||||
store.dispatch(setLastLocation(lastLoc))
|
||||
const playerId = store.getState().game.playerId
|
||||
if (socket.active && playerId) {
|
||||
const lastLocToSend: PlayerLocation = {
|
||||
playerId: playerId,
|
||||
longitude: lastLoc.coords.longitude,
|
||||
latitude: lastLoc.coords.latitude,
|
||||
speed: lastLoc.coords.speed ?? 0,
|
||||
accuracy: lastLoc.coords.accuracy ?? 0,
|
||||
altitude: lastLoc.coords.altitude ?? 0,
|
||||
altitudeAccuracy: lastLoc.coords.altitudeAccuracy ?? 0,
|
||||
timestamp: new Date(lastLoc.timestamp).toISOString(),
|
||||
}
|
||||
socket.emit('last-location', lastLocToSend)
|
||||
}
|
||||
})
|
||||
|
||||
export async function startGeolocationService(): Promise<void | (() => void)> {
|
||||
export async function startGeolocationService(locationAccuracy: Location.Accuracy | null): Promise<void | (() => void)> {
|
||||
if (Platform.OS !== "web" && await Location.hasStartedLocationUpdatesAsync(LOCATION_TASK))
|
||||
return async () => await Location.stopLocationUpdatesAsync(LOCATION_TASK)
|
||||
await Location.stopLocationUpdatesAsync(LOCATION_TASK)
|
||||
|
||||
if (locationAccuracy === null)
|
||||
return
|
||||
|
||||
await Location.enableNetworkProviderAsync().catch(error => alert(error))
|
||||
|
||||
@ -32,10 +56,10 @@ export async function startGeolocationService(): Promise<void | (() => void)> {
|
||||
|
||||
if (Platform.OS !== "web") {
|
||||
await Location.startLocationUpdatesAsync(LOCATION_TASK, {
|
||||
accuracy: Location.Accuracy.BestForNavigation,
|
||||
accuracy: locationAccuracy,
|
||||
activityType: Location.ActivityType.OtherNavigation,
|
||||
deferredUpdatesInterval: 100,
|
||||
timeInterval: 100,
|
||||
distanceInterval: 10,
|
||||
timeInterval: 1000,
|
||||
foregroundService: {
|
||||
killServiceOnDestroy: false,
|
||||
notificationBody: "Géolocalisation activée pour « Traintrape-moi »",
|
||||
@ -46,13 +70,19 @@ export async function startGeolocationService(): Promise<void | (() => void)> {
|
||||
return async () => await Location.stopLocationUpdatesAsync(LOCATION_TASK)
|
||||
}
|
||||
else {
|
||||
const locationSubscription = await Location.watchPositionAsync({accuracy: Location.Accuracy.BestForNavigation}, location_nouveau => store.dispatch(setLastLocation(location_nouveau)))
|
||||
const locationSubscription = await Location.watchPositionAsync({ accuracy: locationAccuracy }, location_nouveau => store.dispatch(setLastLocation(location_nouveau)))
|
||||
return locationSubscription.remove
|
||||
}
|
||||
}
|
||||
|
||||
export const useStartGeolocationServiceEffect = () => useEffect(() => {
|
||||
let cleanup: void | (() => void) = () => {}
|
||||
startGeolocationService().then(result => cleanup = result)
|
||||
return cleanup
|
||||
}, [])
|
||||
export const useStartGeolocationServiceEffect = () => {
|
||||
const auth = useAuth()
|
||||
const settings = useSettings()
|
||||
return useEffect(() => {
|
||||
if (!isAuthValid(auth))
|
||||
return
|
||||
let cleanup: void | (() => void) = () => {}
|
||||
startGeolocationService(settings.locationAccuracy).then(result => cleanup = result)
|
||||
return cleanup
|
||||
}, [auth, settings.locationAccuracy])
|
||||
}
|
||||
|
3
client/utils/socket.ts
Normal file
@ -0,0 +1,3 @@
|
||||
import { io } from 'socket.io-client'
|
||||
|
||||
export const socket = io(process.env.EXPO_PUBLIC_TRAINTRAPE_MOI_SOCKET)
|
@ -1,2 +1,4 @@
|
||||
DATABASE_URL="postgres://username:password@localhost:5432/traintrape-moi"
|
||||
JWT_SECRET="CHANGE_ME"
|
||||
API_GLOBAL_PREFIX="api"
|
||||
API_HOSTNAME="traintrape-moi.luemy.eu"
|
||||
|
225
server/package-lock.json
generated
@ -14,7 +14,10 @@
|
||||
"@nestjs/jwt": "^10.2.0",
|
||||
"@nestjs/passport": "^10.0.3",
|
||||
"@nestjs/platform-express": "^10.0.0",
|
||||
"@nestjs/platform-socket.io": "^10.4.15",
|
||||
"@nestjs/platform-ws": "^10.4.15",
|
||||
"@nestjs/swagger": "^8.1.0",
|
||||
"@nestjs/websockets": "^10.4.15",
|
||||
"@prisma/client": "^6.0.1",
|
||||
"bcrypt": "^5.1.1",
|
||||
"class-transformer": "^0.5.1",
|
||||
@ -1815,6 +1818,65 @@
|
||||
"@nestjs/core": "^10.0.0"
|
||||
}
|
||||
},
|
||||
"node_modules/@nestjs/platform-socket.io": {
|
||||
"version": "10.4.15",
|
||||
"resolved": "https://registry.npmjs.org/@nestjs/platform-socket.io/-/platform-socket.io-10.4.15.tgz",
|
||||
"integrity": "sha512-KZAxNEADPwoORixh3NJgGYWMVGORVPKeTqjD7hbF8TPDLKWWxru9yasBQwEz2/wXH/WgpkQbbaYwx4nUjCIVpw==",
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"socket.io": "4.8.1",
|
||||
"tslib": "2.8.1"
|
||||
},
|
||||
"funding": {
|
||||
"type": "opencollective",
|
||||
"url": "https://opencollective.com/nest"
|
||||
},
|
||||
"peerDependencies": {
|
||||
"@nestjs/common": "^10.0.0",
|
||||
"@nestjs/websockets": "^10.0.0",
|
||||
"rxjs": "^7.1.0"
|
||||
}
|
||||
},
|
||||
"node_modules/@nestjs/platform-ws": {
|
||||
"version": "10.4.15",
|
||||
"resolved": "https://registry.npmjs.org/@nestjs/platform-ws/-/platform-ws-10.4.15.tgz",
|
||||
"integrity": "sha512-EvioQ4zq5LcaL+wdCfcxWgX/R65f4/VN/qFN18cfoVAxWRRa/JfHtWDT+b1lacAU8jPnYjLNAtWPKXc/mcZ1eQ==",
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"tslib": "2.8.1",
|
||||
"ws": "8.18.0"
|
||||
},
|
||||
"funding": {
|
||||
"type": "opencollective",
|
||||
"url": "https://opencollective.com/nest"
|
||||
},
|
||||
"peerDependencies": {
|
||||
"@nestjs/common": "^10.0.0",
|
||||
"@nestjs/websockets": "^10.0.0",
|
||||
"rxjs": "^7.1.0"
|
||||
}
|
||||
},
|
||||
"node_modules/@nestjs/platform-ws/node_modules/ws": {
|
||||
"version": "8.18.0",
|
||||
"resolved": "https://registry.npmjs.org/ws/-/ws-8.18.0.tgz",
|
||||
"integrity": "sha512-8VbfWfHLbbwu3+N6OKsOMpBdT4kXPDDB9cJk2bJ6mh9ucxdlnNvH1e+roYkKmN9Nxw2yjz7VzeO9oOz2zJ04Pw==",
|
||||
"license": "MIT",
|
||||
"engines": {
|
||||
"node": ">=10.0.0"
|
||||
},
|
||||
"peerDependencies": {
|
||||
"bufferutil": "^4.0.1",
|
||||
"utf-8-validate": ">=5.0.2"
|
||||
},
|
||||
"peerDependenciesMeta": {
|
||||
"bufferutil": {
|
||||
"optional": true
|
||||
},
|
||||
"utf-8-validate": {
|
||||
"optional": true
|
||||
}
|
||||
}
|
||||
},
|
||||
"node_modules/@nestjs/schematics": {
|
||||
"version": "10.2.3",
|
||||
"resolved": "https://registry.npmjs.org/@nestjs/schematics/-/schematics-10.2.3.tgz",
|
||||
@ -1900,6 +1962,29 @@
|
||||
}
|
||||
}
|
||||
},
|
||||
"node_modules/@nestjs/websockets": {
|
||||
"version": "10.4.15",
|
||||
"resolved": "https://registry.npmjs.org/@nestjs/websockets/-/websockets-10.4.15.tgz",
|
||||
"integrity": "sha512-OmCUJwvtagzXfMVko595O98UI3M9zg+URL+/HV7vd3QPMCZ3uGCKSq15YYJ99LHJn9NyK4e4Szm2KnHtUg2QzA==",
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"iterare": "1.2.1",
|
||||
"object-hash": "3.0.0",
|
||||
"tslib": "2.8.1"
|
||||
},
|
||||
"peerDependencies": {
|
||||
"@nestjs/common": "^10.0.0",
|
||||
"@nestjs/core": "^10.0.0",
|
||||
"@nestjs/platform-socket.io": "^10.0.0",
|
||||
"reflect-metadata": "^0.1.12 || ^0.2.0",
|
||||
"rxjs": "^7.1.0"
|
||||
},
|
||||
"peerDependenciesMeta": {
|
||||
"@nestjs/platform-socket.io": {
|
||||
"optional": true
|
||||
}
|
||||
}
|
||||
},
|
||||
"node_modules/@nodelib/fs.scandir": {
|
||||
"version": "2.1.5",
|
||||
"resolved": "https://registry.npmjs.org/@nodelib/fs.scandir/-/fs.scandir-2.1.5.tgz",
|
||||
@ -2077,6 +2162,12 @@
|
||||
"@sinonjs/commons": "^3.0.0"
|
||||
}
|
||||
},
|
||||
"node_modules/@socket.io/component-emitter": {
|
||||
"version": "3.1.2",
|
||||
"resolved": "https://registry.npmjs.org/@socket.io/component-emitter/-/component-emitter-3.1.2.tgz",
|
||||
"integrity": "sha512-9BCxFwvbGg/RsZK9tjXd8s4UcwR0MWeFQ1XEKIQVVvAGJyINdrqKMcTRyLoK8Rse1GjzLV9cwjWV1olXRWEXVA==",
|
||||
"license": "MIT"
|
||||
},
|
||||
"node_modules/@tsconfig/node10": {
|
||||
"version": "1.0.11",
|
||||
"resolved": "https://registry.npmjs.org/@tsconfig/node10/-/node10-1.0.11.tgz",
|
||||
@ -2181,6 +2272,12 @@
|
||||
"@types/node": "*"
|
||||
}
|
||||
},
|
||||
"node_modules/@types/cookie": {
|
||||
"version": "0.4.1",
|
||||
"resolved": "https://registry.npmjs.org/@types/cookie/-/cookie-0.4.1.tgz",
|
||||
"integrity": "sha512-XW/Aa8APYr6jSVVA1y/DEIZX0/GMKLEVekNG727R8cs56ahETkRAy/3DR7+fJyh7oUgGwNQaRfXCun0+KbWY7Q==",
|
||||
"license": "MIT"
|
||||
},
|
||||
"node_modules/@types/cookiejar": {
|
||||
"version": "2.1.5",
|
||||
"resolved": "https://registry.npmjs.org/@types/cookiejar/-/cookiejar-2.1.5.tgz",
|
||||
@ -2188,6 +2285,15 @@
|
||||
"dev": true,
|
||||
"license": "MIT"
|
||||
},
|
||||
"node_modules/@types/cors": {
|
||||
"version": "2.8.17",
|
||||
"resolved": "https://registry.npmjs.org/@types/cors/-/cors-2.8.17.tgz",
|
||||
"integrity": "sha512-8CGDvrBj1zgo2qE+oS3pOCyYNqCPryMWY2bGfwA0dcfopWGgxs+78df0Rs3rc9THP4JkOhLsAa+15VdpAqkcUA==",
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"@types/node": "*"
|
||||
}
|
||||
},
|
||||
"node_modules/@types/eslint": {
|
||||
"version": "9.6.1",
|
||||
"resolved": "https://registry.npmjs.org/@types/eslint/-/eslint-9.6.1.tgz",
|
||||
@ -3285,6 +3391,15 @@
|
||||
],
|
||||
"license": "MIT"
|
||||
},
|
||||
"node_modules/base64id": {
|
||||
"version": "2.0.0",
|
||||
"resolved": "https://registry.npmjs.org/base64id/-/base64id-2.0.0.tgz",
|
||||
"integrity": "sha512-lGe34o6EHj9y3Kts9R4ZYs/Gr+6N7MCaMlIFA3F1R2O5/m7K06AxfSeO5530PEERE6/WyEg3lsuyw4GHlPZHog==",
|
||||
"license": "MIT",
|
||||
"engines": {
|
||||
"node": "^4.5.0 || >= 5.9"
|
||||
}
|
||||
},
|
||||
"node_modules/bcrypt": {
|
||||
"version": "5.1.1",
|
||||
"resolved": "https://registry.npmjs.org/bcrypt/-/bcrypt-5.1.1.tgz",
|
||||
@ -4304,6 +4419,45 @@
|
||||
"node": ">= 0.8"
|
||||
}
|
||||
},
|
||||
"node_modules/engine.io": {
|
||||
"version": "6.6.2",
|
||||
"resolved": "https://registry.npmjs.org/engine.io/-/engine.io-6.6.2.tgz",
|
||||
"integrity": "sha512-gmNvsYi9C8iErnZdVcJnvCpSKbWTt1E8+JZo8b+daLninywUWi5NQ5STSHZ9rFjFO7imNcvb8Pc5pe/wMR5xEw==",
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"@types/cookie": "^0.4.1",
|
||||
"@types/cors": "^2.8.12",
|
||||
"@types/node": ">=10.0.0",
|
||||
"accepts": "~1.3.4",
|
||||
"base64id": "2.0.0",
|
||||
"cookie": "~0.7.2",
|
||||
"cors": "~2.8.5",
|
||||
"debug": "~4.3.1",
|
||||
"engine.io-parser": "~5.2.1",
|
||||
"ws": "~8.17.1"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">=10.2.0"
|
||||
}
|
||||
},
|
||||
"node_modules/engine.io-parser": {
|
||||
"version": "5.2.3",
|
||||
"resolved": "https://registry.npmjs.org/engine.io-parser/-/engine.io-parser-5.2.3.tgz",
|
||||
"integrity": "sha512-HqD3yTBfnBxIrbnM1DoD6Pcq8NECnh8d4As1Qgh0z5Gg3jRRIqijury0CL3ghu/edArpUYiYqQiDUQBIs4np3Q==",
|
||||
"license": "MIT",
|
||||
"engines": {
|
||||
"node": ">=10.0.0"
|
||||
}
|
||||
},
|
||||
"node_modules/engine.io/node_modules/cookie": {
|
||||
"version": "0.7.2",
|
||||
"resolved": "https://registry.npmjs.org/cookie/-/cookie-0.7.2.tgz",
|
||||
"integrity": "sha512-yki5XnKuf750l50uGTllt6kKILY4nQ1eNIQatoXEByZ5dWgnKqbnqmTrBE5B4N7lrMJKQ2ytWMiTO2o0v6Ew/w==",
|
||||
"license": "MIT",
|
||||
"engines": {
|
||||
"node": ">= 0.6"
|
||||
}
|
||||
},
|
||||
"node_modules/enhanced-resolve": {
|
||||
"version": "5.17.1",
|
||||
"resolved": "https://registry.npmjs.org/enhanced-resolve/-/enhanced-resolve-5.17.1.tgz",
|
||||
@ -7408,6 +7562,15 @@
|
||||
"node": ">=0.10.0"
|
||||
}
|
||||
},
|
||||
"node_modules/object-hash": {
|
||||
"version": "3.0.0",
|
||||
"resolved": "https://registry.npmjs.org/object-hash/-/object-hash-3.0.0.tgz",
|
||||
"integrity": "sha512-RSn9F68PjH9HqtltsSnqYC1XXoWe9Bju5+213R98cNGttag9q9yAOTzdbsqvIa7aNm5WffBZFpWYr2aWrklWAw==",
|
||||
"license": "MIT",
|
||||
"engines": {
|
||||
"node": ">= 6"
|
||||
}
|
||||
},
|
||||
"node_modules/object-inspect": {
|
||||
"version": "1.13.3",
|
||||
"resolved": "https://registry.npmjs.org/object-inspect/-/object-inspect-1.13.3.tgz",
|
||||
@ -8590,6 +8753,47 @@
|
||||
"node": ">=8"
|
||||
}
|
||||
},
|
||||
"node_modules/socket.io": {
|
||||
"version": "4.8.1",
|
||||
"resolved": "https://registry.npmjs.org/socket.io/-/socket.io-4.8.1.tgz",
|
||||
"integrity": "sha512-oZ7iUCxph8WYRHHcjBEc9unw3adt5CmSNlppj/5Q4k2RIrhl8Z5yY2Xr4j9zj0+wzVZ0bxmYoGSzKJnRl6A4yg==",
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"accepts": "~1.3.4",
|
||||
"base64id": "~2.0.0",
|
||||
"cors": "~2.8.5",
|
||||
"debug": "~4.3.2",
|
||||
"engine.io": "~6.6.0",
|
||||
"socket.io-adapter": "~2.5.2",
|
||||
"socket.io-parser": "~4.2.4"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">=10.2.0"
|
||||
}
|
||||
},
|
||||
"node_modules/socket.io-adapter": {
|
||||
"version": "2.5.5",
|
||||
"resolved": "https://registry.npmjs.org/socket.io-adapter/-/socket.io-adapter-2.5.5.tgz",
|
||||
"integrity": "sha512-eLDQas5dzPgOWCk9GuuJC2lBqItuhKI4uxGgo9aIV7MYbk2h9Q6uULEh8WBzThoI7l+qU9Ast9fVUmkqPP9wYg==",
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"debug": "~4.3.4",
|
||||
"ws": "~8.17.1"
|
||||
}
|
||||
},
|
||||
"node_modules/socket.io-parser": {
|
||||
"version": "4.2.4",
|
||||
"resolved": "https://registry.npmjs.org/socket.io-parser/-/socket.io-parser-4.2.4.tgz",
|
||||
"integrity": "sha512-/GbIKmo8ioc+NIWIhwdecY0ge+qVBSMdgxGygevmdHj24bsfgtCmcUUcQ5ZzcylGFHsN3k4HB4Cgkl96KVnuew==",
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"@socket.io/component-emitter": "~3.1.0",
|
||||
"debug": "~4.3.1"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">=10.0.0"
|
||||
}
|
||||
},
|
||||
"node_modules/source-map": {
|
||||
"version": "0.7.4",
|
||||
"resolved": "https://registry.npmjs.org/source-map/-/source-map-0.7.4.tgz",
|
||||
@ -9802,6 +10006,27 @@
|
||||
"dev": true,
|
||||
"license": "ISC"
|
||||
},
|
||||
"node_modules/ws": {
|
||||
"version": "8.17.1",
|
||||
"resolved": "https://registry.npmjs.org/ws/-/ws-8.17.1.tgz",
|
||||
"integrity": "sha512-6XQFvXTkbfUOZOKKILFG1PDK2NDQs4azKQl26T0YS5CxqWLgXajbPZ+h4gZekJyRqFU8pvnbAbbs/3TgRPy+GQ==",
|
||||
"license": "MIT",
|
||||
"engines": {
|
||||
"node": ">=10.0.0"
|
||||
},
|
||||
"peerDependencies": {
|
||||
"bufferutil": "^4.0.1",
|
||||
"utf-8-validate": ">=5.0.2"
|
||||
},
|
||||
"peerDependenciesMeta": {
|
||||
"bufferutil": {
|
||||
"optional": true
|
||||
},
|
||||
"utf-8-validate": {
|
||||
"optional": true
|
||||
}
|
||||
}
|
||||
},
|
||||
"node_modules/xtend": {
|
||||
"version": "4.0.2",
|
||||
"resolved": "https://registry.npmjs.org/xtend/-/xtend-4.0.2.tgz",
|
||||
|
@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "traintrape-moi-server",
|
||||
"version": "0.0.1",
|
||||
"version": "1.1.1",
|
||||
"description": "",
|
||||
"author": "",
|
||||
"private": true,
|
||||
@ -25,7 +25,10 @@
|
||||
"@nestjs/jwt": "^10.2.0",
|
||||
"@nestjs/passport": "^10.0.3",
|
||||
"@nestjs/platform-express": "^10.0.0",
|
||||
"@nestjs/platform-socket.io": "^10.4.15",
|
||||
"@nestjs/platform-ws": "^10.4.15",
|
||||
"@nestjs/swagger": "^8.1.0",
|
||||
"@nestjs/websockets": "^10.4.15",
|
||||
"@prisma/client": "^6.0.1",
|
||||
"bcrypt": "^5.1.1",
|
||||
"class-transformer": "^0.5.1",
|
||||
|
@ -1,8 +1,13 @@
|
||||
export const Constants = {
|
||||
/**
|
||||
* Nombre de points attribués au début de la partie
|
||||
* Nombre de points attribués au début de la partie pour la première joueuse
|
||||
*/
|
||||
INITIAL_MONEY: 2000,
|
||||
INITIAL_MONEY_1ST_PLAYER: 1500,
|
||||
|
||||
/**
|
||||
* Nombre de points attribués au début de la partie pour la première joueuse
|
||||
*/
|
||||
INITIAL_MONEY_2ND_PLAYER: 1000,
|
||||
|
||||
/**
|
||||
* Nombre de points attribués lors d'une nouvelle tentative
|
||||
|
@ -20,16 +20,16 @@ export class GameService {
|
||||
const alreadyStarted = game.currentRunId !== null
|
||||
let run
|
||||
if (!alreadyStarted) {
|
||||
const runnerId = players[Math.floor(players.length * Math.random())].id
|
||||
for (const player of players) {
|
||||
await this.prisma.moneyUpdate.create({
|
||||
data: {
|
||||
playerId: player.id,
|
||||
amount: Constants.INITIAL_MONEY,
|
||||
amount: player.id === runnerId ? Constants.INITIAL_MONEY_1ST_PLAYER : Constants.INITIAL_MONEY_2ND_PLAYER,
|
||||
reason: MoneyUpdateType.START,
|
||||
}
|
||||
})
|
||||
}
|
||||
const runnerId = players[Math.floor(players.length * Math.random())].id
|
||||
run = await this.prisma.playerRun.create({
|
||||
data: {
|
||||
gameId: game.id,
|
||||
|
18
server/src/geolocations/geolocations.gateway.spec.ts
Normal file
@ -0,0 +1,18 @@
|
||||
import { Test, TestingModule } from '@nestjs/testing'
|
||||
import { GeolocationsGateway } from './geolocations.gateway'
|
||||
|
||||
describe('GeolocationsGateway', () => {
|
||||
let gateway: GeolocationsGateway
|
||||
|
||||
beforeEach(async () => {
|
||||
const module: TestingModule = await Test.createTestingModule({
|
||||
providers: [GeolocationsGateway],
|
||||
}).compile();
|
||||
|
||||
gateway = module.get<GeolocationsGateway>(GeolocationsGateway)
|
||||
});
|
||||
|
||||
it('should be defined', () => {
|
||||
expect(gateway).toBeDefined()
|
||||
})
|
||||
})
|
15
server/src/geolocations/geolocations.gateway.ts
Normal file
@ -0,0 +1,15 @@
|
||||
import { SubscribeMessage, WebSocketGateway, WebSocketServer } from '@nestjs/websockets'
|
||||
import { Server, Socket } from 'socket.io'
|
||||
|
||||
@WebSocketGateway({
|
||||
cors: { allowedHeaders: process.env.API_HOSTNAME },
|
||||
})
|
||||
export class GeolocationsGateway {
|
||||
@WebSocketServer()
|
||||
server: Server
|
||||
|
||||
@SubscribeMessage('last-location')
|
||||
handleLastLocation(client: Socket, payload: any) {
|
||||
return this.server.emit('last-location', payload)
|
||||
}
|
||||
}
|
@ -1,11 +1,12 @@
|
||||
import { Module } from '@nestjs/common'
|
||||
import { GeolocationsService } from './geolocations.service'
|
||||
import { GeolocationsController } from './geolocations.controller'
|
||||
import { PrismaModule } from 'src/prisma/prisma.module'
|
||||
import { GeolocationsController } from './geolocations.controller'
|
||||
import { GeolocationsService } from './geolocations.service'
|
||||
import { GeolocationsGateway } from './geolocations.gateway'
|
||||
|
||||
@Module({
|
||||
controllers: [GeolocationsController],
|
||||
providers: [GeolocationsService],
|
||||
providers: [GeolocationsService, GeolocationsGateway],
|
||||
imports: [PrismaModule],
|
||||
})
|
||||
export class GeolocationsModule {}
|
||||
|
@ -6,18 +6,20 @@ import { ClassSerializerInterceptor, ValidationPipe } from '@nestjs/common'
|
||||
async function bootstrap() {
|
||||
const app = await NestFactory.create(AppModule, { cors: true })
|
||||
|
||||
app.setGlobalPrefix(process.env.API_GLOBAL_PREFIX ?? '')
|
||||
app.useGlobalPipes(new ValidationPipe({ transform: true }))
|
||||
app.useGlobalInterceptors(new ClassSerializerInterceptor(app.get(Reflector)))
|
||||
|
||||
const { version } = require('../../package.json')
|
||||
const config = new DocumentBuilder()
|
||||
.setTitle('Traintrape-moi')
|
||||
.setDescription('API permettant de stocker les données de Traintrape-moi')
|
||||
.setVersion('1.0')
|
||||
.setVersion(version)
|
||||
.addBearerAuth()
|
||||
.build()
|
||||
const document = SwaggerModule.createDocument(app, config)
|
||||
|
||||
SwaggerModule.setup('', app, document)
|
||||
SwaggerModule.setup(process.env.API_GLOBAL_PREFIX ?? '', app, document)
|
||||
await app.listen(process.env.PORT ?? 3000)
|
||||
}
|
||||
bootstrap()
|
||||
|