// Post-login gate, shown once when a signed-in player has no actor.rpg.sprite/self record yet. They // pick how to get one: build their own at rpg.actor (links out, then re-check), or clone the default // actor into their repo (POST /api/sprite/default — uses the sprite-write scope login granted because // they had no sprite). Either way, once a sprite exists the app falls through to the mode picker. import { useState } from 'react' import { hasActorSprite } from './sprite-import' export function SpriteSetup({ did, onReady, onSignOut, }: { did: string /** A sprite now exists for this player — proceed into the game. */ onReady: () => void onSignOut: () => void }) { const [busy, setBusy] = useState(null) const [error, setError] = useState(null) async function useDefault() { setBusy('default') setError(null) try { const res = await fetch('/api/sprite/default', { method: 'POST', credentials: 'include' }) const data = (await res.json().catch(() => ({}))) as { error?: string } if (!res.ok) { setError(`couldn’t set the default actor: ${data.error ?? res.status}`) return } onReady() } catch (e) { setError(e instanceof Error ? e.message : String(e)) } finally { setBusy(null) } } async function recheck() { setBusy('recheck') setError(null) try { if (await hasActorSprite(did)) onReady() else setError('still no actor.rpg.sprite/self — publish it, then re-check.') } finally { setBusy(null) } } return (

choose your actor

You need a sprite before you can play. Build your own, or start with the default actor.

or

Create your own at rpg.actor, then re-check.

Create at rpg.actor ↗
{error &&

{error}

}
) }