init with react+axum+spacetimedb
Some checks failed
CI / verify (push) Has been cancelled

This commit is contained in:
2026-04-26 18:06:23 +08:00
commit cbc27bad4a
20199 changed files with 883714 additions and 0 deletions

45
src/RpgRuntimeApp.tsx Normal file
View File

@@ -0,0 +1,45 @@
import { useEffect, useRef } from 'react';
import { RpgRuntimeShell } from './components/rpg-runtime-shell/RpgRuntimeShell';
import { useRpgRuntimeSession } from './hooks/rpg-session/useRpgRuntimeSession';
import type { HydratedSavedGameSnapshot } from './persistence/runtimeSnapshotTypes';
import type { CustomWorldProfile } from './types';
export type RpgRuntimeAppIntent =
| {
token: number;
kind: 'custom-world';
profile: CustomWorldProfile;
}
| {
token: number;
kind: 'snapshot';
snapshot: HydratedSavedGameSnapshot | null;
};
export function RpgRuntimeApp({
initialIntent,
}: {
initialIntent: RpgRuntimeAppIntent | null;
}) {
const gameShellProps = useRpgRuntimeSession();
const handledIntentTokenRef = useRef<number | null>(null);
useEffect(() => {
if (!initialIntent || handledIntentTokenRef.current === initialIntent.token) {
return;
}
handledIntentTokenRef.current = initialIntent.token;
if (initialIntent.kind === 'custom-world') {
gameShellProps.entry.handleCustomWorldSelect(initialIntent.profile);
return;
}
gameShellProps.entry.handleContinueGame(initialIntent.snapshot);
}, [gameShellProps.entry, initialIntent]);
return <RpgRuntimeShell {...gameShellProps} />;
}
export default RpgRuntimeApp;