import { Hash, MutableSet, Resources, Store, WordCode } from '@hyper-hyper-space/core'; import { PeerComponent, ObjectState, useObjectState } from '@hyper-hyper-space/react'; import { AppBar, Button, Container, Link, Stack, TextField, Toolbar, Typography } from '@mui/material'; import { Box } from '@mui/system'; import { Fragment, useRef, useState, useEffect } from 'react'; import { useNavigate, Outlet } from 'react-router'; import { Link as RouterLink } from 'react-router-dom'; import { HyperBrowserConfig } from '../../model/HyperBrowserConfig'; function StartPage(props: {homes: MutableSet, config: Store}) { const navigate = useNavigate(); const [starterResources, setStarterResources] = useState(undefined); useEffect(() => { HyperBrowserConfig.initStarterResources().then((r: Resources) => { setStarterResources(r); }); }, []); const word1Input = useRef(null); const word2Input = useRef(null); const word3Input = useRef(null); const [currentWord1, setCurrentWord1] = useState(''); const [currentWord2, setCurrentWord2] = useState(''); const [currentWord3, setCurrentWord3] = useState(''); const [word1Error, setWord1Error] = useState(false); const [word2Error, setWord2Error] = useState(false); const [word3Error, setWord3Error] = useState(false); /*useEffect(() => { if (!showLookupDialog) { word1Input.current?.focus(); } if (showLookupDialog) { setShowLookupDialog(false); navigate('/start/lookup/' + currentWord1 + '-' + currentWord2 + '-' + currentWord3) } }, [showLookupDialog, currentWord1, currentWord2, currentWord3]);*/ const showLookupDialog = () => { const words = currentWord1 + '-' + currentWord2 + '-' + currentWord3; setCurrentWord1(''); setCurrentWord2(''); setCurrentWord3(''); word1Input.current?.focus(); navigate('/start/lookup/' + words); }; const showCreateHomeDialog = () => { word1Input.current?.focus(); navigate('/start/create-home'); }; const showLinkDeviceDialog = () => { word1Input.current?.focus(); navigate('/start/link-device'); } const handleWord1Change = (event: React.ChangeEvent) => { setCurrentWord1(event.target.value); }; const checkWord1Change = () => { if (currentWord1 !== '') { setWord1Error(!WordCode.english.check(currentWord1)); } } const handleWord1KeyPress = (e: React.KeyboardEvent) => { if (e.key === 'Enter') { e.preventDefault(); word2Input.current?.focus(); } } const handleWord2Change = (event: React.ChangeEvent) => { setCurrentWord2(event.target.value); }; const checkWord2Change = () => { if (currentWord2 !== '') { setWord2Error(!WordCode.english.check(currentWord2)); } } const handleWord2KeyPress = (e: React.KeyboardEvent) => { if (e.key === 'Enter') { e.preventDefault(); word3Input.current?.focus(); } } const handleWord3Change = (event: React.ChangeEvent) => { setCurrentWord3(event.target.value); }; const checkWord3Change = () => { if (currentWord3 !== '') { setWord3Error(!WordCode.english.check(currentWord3)); } } const handleWord3KeyPress = (e: React.KeyboardEvent) => { if (e.key === 'Enter') { e.preventDefault(); handleLookup(); } } const handleLookup = () => { const e1 = !WordCode.english.check(currentWord1); const e2 = !WordCode.english.check(currentWord2); const e3 = !WordCode.english.check(currentWord3); setWord1Error(e1); setWord2Error(e2); setWord3Error(e3); if (!(e1 || e2 || e3)) { showLookupDialog(); } }; const homes = useObjectState(props.homes) as ObjectState>; return ( { starterResources === undefined &&

Initializing starter page...

} { starterResources !== undefined && { /* */} { ((homes.value?.size() || 0) > 0) && } { ((homes.value?.size() || 0) === 0) && {/* Home Space: */} }

Spaces can hold blogs, chats, wikis, etc. They are are stored on your own computer, like files, and are synchronized over the network.
Lookup space using 3-word code: Spaces are looked up using 3-word codes, that you can enter above. Lost? Start here: {[{icon:'📗', iconTitle: 'feed', iconColor: 'lightblue', text:'About Hyper Hyper Space', title: 'tandem sticker bag'}, {icon:'💬', iconTitle: 'feed', iconColor: 'green', text:'Welcome chat and Q&A', title: 'ambar lemon tack'}, {icon:'🗒', iconTitle: 'feed', iconColor: 'yellow', text:'New spaces', title: 'puma kicker backlog'}].map((e) => {e.icon} {e.text} )} { ((homes.value?.size() || 0) === 0) && }
}
); } export default StartPage;