From 500ae01ba33a5d83100304497af0da43ff9275e6 Mon Sep 17 00:00:00 2001 From: Brandon <137568790+Brandondiaz19@users.noreply.github.com> Date: Sat, 24 Oct 2026 16:33:11 -0300 Subject: [PATCH 1/6] feat: crear perfil web privado de solo lectura --- src/PlayerHub.tsx | 132 ++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 132 insertions(+) create mode 100644 src/PlayerHub.tsx diff --git a/src/PlayerHub.tsx b/src/PlayerHub.tsx new file mode 100644 index 0000000..8eb363a --- /dev/null +++ b/src/PlayerHub.tsx @@ -0,0 +1,132 @@ +import { useEffect, useState, type FormEvent } from 'react' +import type { User } from '@supabase/supabase-js' +import { supabase } from './lib/supabase' +import './PlayerHub.css' + +type Progress = { + current_mission_id: string | null + completed_missions: unknown + unlocked_knowledge: unknown + minerals_ship: number | null + minerals_spid: number | null + map_tier: number | null + updated_at: string | null +} +const safeList = (value: unknown): string[] => Array.isArray(value) ? value.filter((item): item is string => typeof item === 'string') : [] +const readable = (id: string) => id.replaceAll('_', ' ') + +export default function PlayerHub() { + const [user, setUser] = useState(null) + const [checking, setChecking] = useState(true) + const [email, setEmail] = useState('') + const [password, setPassword] = useState('') + const [authBusy, setAuthBusy] = useState(false) + const [notice, setNotice] = useState('') + const [progress, setProgress] = useState(null) + const [loadingProgress, setLoadingProgress] = useState(false) + const [progressError, setProgressError] = useState('') + + useEffect(() => { + if (!supabase) { setChecking(false); return } + const client = supabase + let active = true + void client.auth.getUser().then(({ data, error }) => { + if (active) { setUser(error ? null : data.user); setChecking(false) } + }).catch(() => { if (active) { setUser(null); setChecking(false) } }) + const { data } = client.auth.onAuthStateChange((_event, session) => { + if (active) setUser(session?.user ?? null) + }) + return () => { active = false; data.subscription.unsubscribe() } + }, []) + + useEffect(() => { + if (!supabase || !user) { setProgress(null); setProgressError(''); return } + const client = supabase + let active = true + const userId = user.id + setLoadingProgress(true) + setProgress(null) + setProgressError('') + // Sólo consulta la fila del usuario autenticado, además de las restricciones RLS del servidor. + void client.from('player_progress') + .select('current_mission_id,completed_missions,unlocked_knowledge,minerals_ship,minerals_spid,map_tier,updated_at') + .eq('user_id', userId) + .maybeSingle() + .then(({ data, error }) => { + if (!active) return + setLoadingProgress(false) + if (error) { + setProgressError('No fue posible consultar el progreso. Verifica que esta web use el mismo proyecto Supabase que el juego y que RLS permita leer solo los datos propios.') + } else setProgress(data as Progress | null) + }) + return () => { active = false } + }, [user?.id]) + + async function signIn(event: FormEvent) { + event.preventDefault() + if (!supabase || authBusy) return + setAuthBusy(true); setNotice('') + try { + const { error } = await supabase.auth.signInWithPassword({ email: email.trim(), password }) + setPassword('') + if (error) setNotice('No se pudo iniciar sesión. Revisa tus credenciales.') + } catch { setNotice('No se pudo conectar con el servicio de autenticación.') } + finally { setAuthBusy(false) } + } + + async function signOut() { + if (!supabase || authBusy) return + setAuthBusy(true) + const { error } = await supabase.auth.signOut() + setAuthBusy(false) + if (error) setNotice('No se pudo cerrar sesión. Inténtalo nuevamente.') + else { setUser(null); setProgress(null); setNotice('Sesión cerrada.') } + } + + return
+ Saltar al contenido +
+
+

CENTRO DE CONTROL // PERFIL DEL JUGADOR

+

Tu aventura, tu progreso.

+

Consulta los datos guardados de tu partida de SpidoCode. Este panel no modifica misiones, minerales ni inventario.

+ {!supabase ?

Configuración pendiente

El portal aún no tiene configuradas sus variables públicas de Supabase. No se puede acceder al perfil.

+ : checking ?

Comprobando sesión…

+ : !user ?
+

Inicia sesión

Usa la misma cuenta que utilizas en el videojuego.

+
+ + + +
+

Las credenciales se procesan mediante Supabase Auth. Nunca aparecen en la URL ni se registran en esta página.

+
+ :
+
CUENTA CONECTADA{user.email ?? 'Cuenta de jugador'}
+ {loadingProgress ?

Cargando progreso…

+ : progressError ?

Progreso no disponible

{progressError}

+ : !progress ?

Sin partida sincronizada

Esta cuenta todavía no tiene una partida remota registrada. Abre SpidoCode con esa cuenta para generar progreso.

+ : <> +
+
MISIÓN ACTUAL{progress.current_mission_id ? readable(progress.current_mission_id) : 'Sin datos'}
+
MISIONES COMPLETADAS{safeList(progress.completed_missions).length}
+
MINERALES EN NAVE{progress.minerals_ship ?? 'Sin datos'}
+
MINERALES DE SPID{progress.minerals_spid ?? 'Sin datos'}
+
NIVEL DEL MAPA{progress.map_tier ?? 'Sin datos'}
+
CONOCIMIENTOS{safeList(progress.unlocked_knowledge).length}
+
+
+

Conocimientos desbloqueados

+
{safeList(progress.unlocked_knowledge).length ? safeList(progress.unlocked_knowledge).map((id) => {readable(id)} ↗) :

Sin conocimientos registrados.

}
+
+

Última sincronización registrada: {progress.updated_at ? new Date(progress.updated_at).toLocaleString('es-CL') : 'Sin datos'}. Solo lectura.

+ } +
} + {notice &&

{notice}

} +
+ +
+} From 9f244cecf4ca619895aa78b613c7526938b87c46 Mon Sep 17 00:00:00 2001 From: Brandon <137568790+Brandondiaz19@users.noreply.github.com> Date: Sat, 24 Oct 2026 16:33:14 -0300 Subject: [PATCH 2/6] feat: crear perfil web privado de solo lectura --- src/PlayerHub.css | 1 + 1 file changed, 1 insertion(+) create mode 100644 src/PlayerHub.css diff --git a/src/PlayerHub.css b/src/PlayerHub.css new file mode 100644 index 0000000..36ad7e8 --- /dev/null +++ b/src/PlayerHub.css @@ -0,0 +1 @@ +.spido-hub{min-height:100vh;background:radial-gradient(ellipse at 75% 3%,#183150,transparent 42%),#070e1c;color:#f1f8f9;font-family:Inter,sans-serif}.spido-hub-container{width:min(1100px,calc(100% - 42px));margin:auto}.spido-hub :is(a,button,input):focus-visible{outline:2px solid #b1f878;outline-offset:4px}.spido-hub-skip{position:absolute;top:-90px;left:12px;background:#b1f878;color:#07111f;padding:12px}.spido-hub-skip:focus{top:10px;z-index:99}.spido-hub-header{border-bottom:1px solid #2e3b4f;background:#081224}.spido-hub-nav{min-height:76px;display:flex;align-items:center;justify-content:space-between;gap:22px}.spido-hub-nav nav{display:flex;gap:20px}.spido-hub-nav nav a{color:#c7d7df;font-size:13px;text-decoration:none}.spido-hub-logo{font:700 27px 'Spido Pixel',monospace;color:#ecffe2;text-shadow:2px 2px #59418b;text-decoration:none}.spido-hub-logo span{color:#b1f878}.spido-hub-main{padding:70px 0 100px}.spido-hub-kicker,.spido-hub-panel small{font:11px 'JetBrains Mono',monospace;color:#b1f878;letter-spacing:.12em}.spido-hub h1{font:700 clamp(2.3rem,5vw,4rem) 'Space Grotesk',sans-serif;line-height:1.15;margin:16px 0}.spido-hub h1 span{color:#b1f878}.spido-hub-lead{max-width:690px;color:#b9c8d8;line-height:1.8;margin-bottom:38px}.spido-hub-panel{background:#0d1c30;border:1px solid #2d4d58;border-radius:11px;padding:27px;margin:22px 0}.spido-hub-panel h2{font:650 24px 'Space Grotesk',sans-serif;margin-top:0}.spido-hub-panel p{color:#bdcad8;line-height:1.7}.spido-hub-auth{max-width:500px}.spido-hub-auth form{display:grid;gap:16px}.spido-hub-auth label{display:grid;gap:8px;font-size:13px;color:#cbd6e4}.spido-hub-auth input{background:#071322;color:#fff;border:1px solid #4b6170;border-radius:5px;padding:13px}.spido-hub button{cursor:pointer;border:1px solid #9ed76d;border-radius:5px;padding:11px 17px;background:#b1f878;color:#07111f;font-weight:700}.spido-hub button:disabled{opacity:.65;cursor:wait}.spido-hub-account{display:flex;align-items:center;justify-content:space-between;gap:18px;flex-wrap:wrap;background:#102337;border:1px solid #2e4b51;padding:19px;border-radius:10px}.spido-hub-account div{display:grid;gap:6px}.spido-hub-account small,.spido-hub-stats small{font:11px 'JetBrains Mono',monospace;color:#84dece}.spido-hub-account strong{overflow-wrap:anywhere}.spido-hub-stats{display:grid;grid-template-columns:repeat(3,minmax(0,1fr));gap:14px;margin-top:20px}.spido-hub-stats article{background:#102034;border:1px solid #344d56;border-radius:9px;padding:21px;display:grid;gap:12px}.spido-hub-stats strong{font-size:23px;color:#b1f878;overflow-wrap:anywhere;text-transform:capitalize}.spido-hub-knowledge{display:flex;flex-wrap:wrap;gap:10px}.spido-hub-knowledge a{display:inline-block;padding:10px 14px;background:#143134;border:1px solid #42786f;border-radius:5px;color:#c9fff2;font-size:13px;text-decoration:none}.spido-hub-note{font-size:12px;color:#aabccb;line-height:1.7}.spido-hub-notice{padding:14px;color:#ffcfa2}.spido-hub-footer{border-top:1px solid #2d3a52;padding:28px 0;font:11px 'JetBrains Mono',monospace;color:#b8c7d6}.spido-hub-footer>div{display:flex;justify-content:space-between;gap:14px}.spido-hub-footer a{color:#b1f878}@media(max-width:760px){.spido-hub-stats{grid-template-columns:repeat(2,minmax(0,1fr))}}@media(max-width:460px){.spido-hub-nav{flex-wrap:wrap;padding:12px 0}.spido-hub-nav nav{gap:12px}.spido-hub-main{padding:45px 0 60px}.spido-hub-stats{grid-template-columns:1fr}} \ No newline at end of file From d832a51b22a5d3cac2a610e952b7c3573f3c9c23 Mon Sep 17 00:00:00 2001 From: Brandon <137568790+Brandondiaz19@users.noreply.github.com> Date: Sat, 24 Oct 2026 16:33:29 -0300 Subject: [PATCH 3/6] =?UTF-8?q?feat:=20enlazar=20perfil=20de=20jugador=20a?= =?UTF-8?q?=20la=20navegaci=C3=B3n?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/App.tsx | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/App.tsx b/src/App.tsx index 50d4cf5..e6df4e0 100644 --- a/src/App.tsx +++ b/src/App.tsx @@ -1,6 +1,7 @@ import { FormEvent, useEffect, useMemo, useState } from 'react' import { supabase } from './lib/supabase' import DocsPage from './docs/DocsPage' +import PlayerHub from './PlayerHub' const brand = { bg: '#07111F', @@ -75,6 +76,7 @@ function Nav() { ['Cómo se juega', '#como-jugar'], ['Misiones', '#misiones'], ['Documentación', '/docs'], + ['Mi progreso', '/perfil'], ['Equipo', '#equipo'], ] return ( @@ -1463,5 +1465,6 @@ export default function App() { const pathname = window.location.pathname.replace(/\/+$/, '') || '/' if (pathname === '/reset-password') return if (pathname === '/docs') return + if (pathname === '/perfil') return return } From 4cd657ca12f4fc2a33f431519029fc61af085f60 Mon Sep 17 00:00:00 2001 From: Brandon <137568790+Brandondiaz19@users.noreply.github.com> Date: Sat, 24 Oct 2026 16:33:34 -0300 Subject: [PATCH 4/6] fix: servir ruta /perfil directamente en Vercel --- vercel.json | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/vercel.json b/vercel.json index 8336730..9de8dc0 100644 --- a/vercel.json +++ b/vercel.json @@ -8,6 +8,10 @@ "source": "/docs", "destination": "/index.html" }, + { + "source": "/perfil", + "destination": "/index.html" + }, { "source": "/", "destination": "/index.html" From 2b81edb9c14bc35c5ae161c6a3bef1c21d19414e Mon Sep 17 00:00:00 2001 From: Brandon <137568790+Brandondiaz19@users.noreply.github.com> Date: Sat, 24 Oct 2026 16:35:46 -0300 Subject: [PATCH 5/6] =?UTF-8?q?ci:=20comprobar=20TypeScript=20y=20compilac?= =?UTF-8?q?i=C3=B3n=20de=20la=20web?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .github/workflows/web-checks.yml | 40 ++++++++++++++++++++++++++++++++ 1 file changed, 40 insertions(+) create mode 100644 .github/workflows/web-checks.yml diff --git a/.github/workflows/web-checks.yml b/.github/workflows/web-checks.yml new file mode 100644 index 0000000..1f0bda8 --- /dev/null +++ b/.github/workflows/web-checks.yml @@ -0,0 +1,40 @@ +name: Verificar web SpidoCode + +on: + push: + branches: + - feat/spidocode-player-hub + pull_request: + paths: + - 'src/**' + - 'package.json' + - 'pnpm-lock.yaml' + - 'vercel.json' + - '.github/workflows/web-checks.yml' + workflow_dispatch: + +permissions: + contents: read + +jobs: + verify: + runs-on: ubuntu-latest + timeout-minutes: 15 + steps: + - name: Obtener código + uses: actions/checkout@v4 + - name: Preparar pnpm + uses: pnpm/action-setup@v4 + with: + version: 10.34.3 + - name: Preparar Node + uses: actions/setup-node@v4 + with: + node-version: '22' + cache: pnpm + - name: Instalar dependencias + run: pnpm install --frozen-lockfile + - name: Verificar TypeScript + run: pnpm exec tsc --noEmit + - name: Compilar + run: pnpm run build From 8e95943ee7d1a1dfb52f4006c4f4463411bbd0e5 Mon Sep 17 00:00:00 2001 From: Brandon <137568790+Brandondiaz19@users.noreply.github.com> Date: Thu, 29 Oct 2026 01:14:59 -0300 Subject: [PATCH 6/6] fix: compatibilidad TypeScript en etiquetas del perfil --- src/PlayerHub.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/PlayerHub.tsx b/src/PlayerHub.tsx index 8eb363a..c573594 100644 --- a/src/PlayerHub.tsx +++ b/src/PlayerHub.tsx @@ -13,7 +13,7 @@ type Progress = { updated_at: string | null } const safeList = (value: unknown): string[] => Array.isArray(value) ? value.filter((item): item is string => typeof item === 'string') : [] -const readable = (id: string) => id.replaceAll('_', ' ') +const readable = (id: string) => id.replace(/_/g, ' ') export default function PlayerHub() { const [user, setUser] = useState(null)