Skip to content

Commit

Permalink
v0.0.0-alpha
Browse files Browse the repository at this point in the history
  • Loading branch information
shuji-koike committed Jan 26, 2024
1 parent 50c00d9 commit 8c38fcf
Show file tree
Hide file tree
Showing 52 changed files with 5,489 additions and 10,202 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ jobs:
if: steps.cache_node_modules.outputs.cache-hit != 'true'
- uses: actions/setup-go@v2
with:
go-version: "1.17"
go-version: "1.21"
- uses: actions/cache@v2
id: cache_go_mod
with:
Expand Down
1 change: 1 addition & 0 deletions .github/workflows/lint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,3 +17,4 @@ jobs:
if: steps.cache_node_modules.outputs.cache-hit != 'true'
- run: yarn prettier -c .
- run: yarn eslint .
- run: yarn tsc --noEmit
11 changes: 6 additions & 5 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -3,17 +3,18 @@ module github.com/shuji-koike/csgo
go 1.17

require (
github.com/golang/geo v0.0.0-20210211234256-740aa86cb551
github.com/markus-wa/demoinfocs-golang/v2 v2.12.1
github.com/golang/geo v0.0.0-20230421003525-6adc56603217
github.com/markus-wa/demoinfocs-golang/v2 v2.13.3
github.com/shuji-koike/goutil v1.0.0
golang.org/x/sync v0.0.0-20210220032951-036812b2e83c
golang.org/x/sync v0.3.0
)

require (
github.com/gogo/protobuf v1.3.2 // indirect
github.com/markus-wa/go-unassert v0.1.2 // indirect
github.com/markus-wa/go-unassert v0.1.3 // indirect
github.com/markus-wa/gobitread v0.2.3 // indirect
github.com/markus-wa/godispatch v1.4.1 // indirect
github.com/markus-wa/quickhull-go/v2 v2.1.0 // indirect
github.com/markus-wa/ice-cipher-go v0.0.0-20230901094113-348096939ba7 // indirect
github.com/markus-wa/quickhull-go/v2 v2.2.0 // indirect
github.com/pkg/errors v0.9.1 // indirect
)
15 changes: 15 additions & 0 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@ github.com/golang/freetype v0.0.0-20170609003504-e2365dfdc4a0/go.mod h1:E/TSTwGw
github.com/golang/geo v0.0.0-20180826223333-635502111454/go.mod h1:vgWZ7cu0fq0KY3PpEHsocXOWJpRtkcbKemU4IUw0M60=
github.com/golang/geo v0.0.0-20210211234256-740aa86cb551 h1:gtexQ/VGyN+VVFRXSFiguSNcXmS6rkKT+X7FdIrTtfo=
github.com/golang/geo v0.0.0-20210211234256-740aa86cb551/go.mod h1:QZ0nwyI2jOfgRAoBvP+ab5aRr7c9x7lhGEJrKvBwjWI=
github.com/golang/geo v0.0.0-20230421003525-6adc56603217 h1:HKlyj6in2JV6wVkmQ4XmG/EIm+SCYlPZ+V4GWit7Z+I=
github.com/golang/geo v0.0.0-20230421003525-6adc56603217/go.mod h1:8wI0hitZ3a1IxZfeH3/5I97CI8i5cLGsYe7xNhQGs9U=
github.com/jung-kurt/gofpdf v1.0.0/go.mod h1:7Id9E/uU8ce6rXgefFLlgrJj/GYY22cpxn+r32jIOes=
github.com/kisielk/errcheck v1.5.0/go.mod h1:pFxgyoBC7bSaBwPgfKdkLd5X25qrDl4LWUI2bnpBCr8=
github.com/kisielk/gotool v1.0.0/go.mod h1:XhKaO+MFFWcvkIS/tQcRk01m1F5IRFswLeQ+oQHNcck=
Expand All @@ -19,14 +21,23 @@ github.com/markus-wa/demoinfocs-golang/v2 v2.12.0 h1:XdUZ/SUgZdPNarerbErDuM1n7Bl
github.com/markus-wa/demoinfocs-golang/v2 v2.12.0/go.mod h1:BPIElNIVtyVzzc2AD3w/yMbiHiaq91o6L873PdZJobo=
github.com/markus-wa/demoinfocs-golang/v2 v2.12.1 h1:DjQg4jtWuuJiOlckDe+wEoUcxGLoxrIoIHqVBf046vs=
github.com/markus-wa/demoinfocs-golang/v2 v2.12.1/go.mod h1:BPIElNIVtyVzzc2AD3w/yMbiHiaq91o6L873PdZJobo=
github.com/markus-wa/demoinfocs-golang/v2 v2.13.3 h1:Wi15Iq0y66PuiGNHfAle3zhCVwwCoksWHCfgTEQSPgw=
github.com/markus-wa/demoinfocs-golang/v2 v2.13.3/go.mod h1:2mL3quPmFnXa8WkrsQTEFUm/iDBuzq5I3AeJ6SsMIn4=
github.com/markus-wa/go-unassert v0.1.2 h1:uXWlMDa8JVtc4RgNq4XJIjyRejv9MOVuy/E0VECPxxo=
github.com/markus-wa/go-unassert v0.1.2/go.mod h1:XEvrxR+trvZeMDfXcZPvzqGo6eumEtdk5VjNRuvvzxQ=
github.com/markus-wa/go-unassert v0.1.3 h1:4N2fPLUS3929Rmkv94jbWskjsLiyNT2yQpCulTFFWfM=
github.com/markus-wa/go-unassert v0.1.3/go.mod h1:/pqt7a0LRmdsRNYQ2nU3SGrXfw3bLXrvIkakY/6jpPY=
github.com/markus-wa/gobitread v0.2.3 h1:COx7dtYQ7Q+77hgUmD+O4MvOcqG7y17RP3Z7BbjRvPs=
github.com/markus-wa/gobitread v0.2.3/go.mod h1:PcWXMH4gx7o2CKslbkFkLyJB/aHW7JVRG3MRZe3PINg=
github.com/markus-wa/godispatch v1.4.1 h1:Cdff5x33ShuX3sDmUbYWejk7tOuoHErFYMhUc2h7sLc=
github.com/markus-wa/godispatch v1.4.1/go.mod h1:tk8L0yzLO4oAcFwM2sABMge0HRDJMdE8E7xm4gK/+xM=
github.com/markus-wa/ice-cipher-go v0.0.0-20220126215401-a6adadccc817/go.mod h1:JIsht5Oa9P50VnGJTvH2a6nkOqDFJbUeU1YRZYvdplw=
github.com/markus-wa/ice-cipher-go v0.0.0-20230901094113-348096939ba7 h1:aR9pvnlnBxifXBmzidpAiq2prLSGlkhE904qnk2sCz4=
github.com/markus-wa/ice-cipher-go v0.0.0-20230901094113-348096939ba7/go.mod h1:JIsht5Oa9P50VnGJTvH2a6nkOqDFJbUeU1YRZYvdplw=
github.com/markus-wa/quickhull-go/v2 v2.1.0 h1:DA2pzEzH0k5CEnlUsouRqNdD+jzNFb4DBhrX4Hpa5So=
github.com/markus-wa/quickhull-go/v2 v2.1.0/go.mod h1:bOlBUpIzGSMMhHX0f9N8CQs0VZD4nnPeta0OocH7m4o=
github.com/markus-wa/quickhull-go/v2 v2.2.0 h1:rB99NLYeUHoZQ/aNRcGOGqjNBGmrOaRxdtqTnsTUPTA=
github.com/markus-wa/quickhull-go/v2 v2.2.0/go.mod h1:EuLMucfr4B+62eipXm335hOs23LTnO62W7Psn3qvU2k=
github.com/pkg/errors v0.9.1 h1:FEBLx1zS214owpjy7qsBeixbURkuhQAwrK5UwLGTwt4=
github.com/pkg/errors v0.9.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0=
github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=
Expand All @@ -38,6 +49,8 @@ github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+
github.com/stretchr/testify v1.4.0/go.mod h1:j7eGeouHqKxXV5pUuKE4zz7dFj8WfuZ+81PSLYec5m4=
github.com/stretchr/testify v1.6.1 h1:hDPOHmpOpP40lSULcqw7IrRb/u7w6RpDC9399XyoNd0=
github.com/stretchr/testify v1.6.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg=
github.com/stretchr/testify v1.7.0 h1:nwc3DEeHmmLAfoZucVR881uASk0Mfjw8xYJ99tb5CcY=
github.com/stretchr/testify v1.7.0/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg=
github.com/yuin/goldmark v1.1.27/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74=
github.com/yuin/goldmark v1.2.1/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74=
golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w=
Expand All @@ -55,6 +68,8 @@ golang.org/x/sync v0.0.0-20190911185100-cd5d95a43a6e/go.mod h1:RxMgew5VJxzue5/jJ
golang.org/x/sync v0.0.0-20201020160332-67f06af15bc9/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
golang.org/x/sync v0.0.0-20210220032951-036812b2e83c h1:5KslGYwFpkhGh+Q16bwMP3cOontH8FOep7tGV86Y7SQ=
golang.org/x/sync v0.0.0-20210220032951-036812b2e83c/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
golang.org/x/sync v0.3.0 h1:ftCYgMx6zT/asHUrPw8BLLscYtGznsLAnjq5RH9P66E=
golang.org/x/sync v0.3.0/go.mod h1:FU7BRWz2tNW+3quACPkgCx/L+uEAv1htQ0V83Z9Rj+Y=
golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
golang.org/x/sys v0.0.0-20190412213103-97732733099d/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20200930185726-fdedc70b468f/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
Expand Down
2 changes: 1 addition & 1 deletion index.html
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
<!DOCTYPE html>
<!doctype html>
<script type="module" src="/packages/app/index.tsx"></script>
<div id="root"></div>
4 changes: 2 additions & 2 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import (
"bytes"
"errors"
"flag"
"io/ioutil"
"io"
"log"
"os"
"runtime"
Expand Down Expand Up @@ -37,7 +37,7 @@ func main() {
if *server {
new(Server).Listen(*port)
} else if *stdin {
buf, err := ioutil.ReadAll(os.Stdin)
buf, err := io.ReadAll(os.Stdin)
if err != nil {
log.Printf("main: error reading stdin %s", err.Error())
} else {
Expand Down
3 changes: 1 addition & 2 deletions model.go
Original file line number Diff line number Diff line change
Expand Up @@ -113,8 +113,7 @@ type KillEvent struct {
// Bomb ...
type Bomb struct {
r2.Point
Planted bool
State BombState
State BombState
}

// BombState ...
Expand Down
15 changes: 6 additions & 9 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,14 +15,11 @@
"packages/*"
],
"devDependencies": {
"@babel/core": "^7.16.5",
"@emotion/babel-plugin": "^11.7.1",
"@firebase/app-compat": "^0.1.5",
"@shuji-koike/boilerplate": "^1.8.0",
"@shuji-koike/eslint-config": "^1.8.0",
"@shuji-koike/storybook": "^1.8.0",
"@shuji-koike/vite-react": "^1.8.0",
"firebase-tools": "^10.1.0",
"webpack": "^4.46.0"
"@firebase/app-compat": "^0.2.19",
"@shuji-koike/boilerplate": "^1.13.0",
"@shuji-koike/eslint-config": "^1.13.0",
"@shuji-koike/storybook": "^1.13.0",
"@shuji-koike/vite-react": "^1.13.0",
"firebase-tools": "^12.6.1"
}
}
2 changes: 1 addition & 1 deletion packages/app/app.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ export const AppContext = React.createContext<AppState>({
setMatch() {},
})

export const AppContextProvider: React.VFC<{
export const AppContextProvider: React.FC<{
children: React.ReactNode
}> = ({ children }) => {
const [match, setMatch] = React.useState<AppState["match"]>()
Expand Down
4 changes: 2 additions & 2 deletions packages/app/components/AuthAvatar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import React from "react"

import { useAuth } from "../hooks"

export const AuthAvatar: React.VFC<{
export const AuthAvatar: React.FC<{
diameter?: number
}> = ({ diameter = 32 }) => {
const user = useAuth()
Expand Down Expand Up @@ -49,7 +49,7 @@ export const AuthAvatar: React.VFC<{
<MenuItem
onClick={() =>
signInWithPopup(getAuth(), new OAuthProvider("steam")).then(
close
close,
)
}
>
Expand Down
6 changes: 3 additions & 3 deletions packages/app/components/layout.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ const layoutState = Object.freeze<LayoutState>({
export const LayoutContext = React.createContext<LayoutState>(layoutState)

// https://git.io/JvUzq
export const Layout: React.VFC<{
export const Layout: React.FC<{
title?: string
nav?: React.ReactNode
menu?: React.ReactNode
Expand Down Expand Up @@ -89,7 +89,7 @@ export const Layout: React.VFC<{
)
}

const MenuButton: React.VFC = () => {
const MenuButton: React.FC = () => {
const { showDrawer, setLayout } = React.useContext(LayoutContext)
return (
<IconButton
Expand All @@ -102,7 +102,7 @@ const MenuButton: React.VFC = () => {
)
}

export const HeaderSlot: React.VFC<{
export const HeaderSlot: React.FC<{
children?: React.ReactNode
}> = ({ children = logo }) => {
const container = document.getElementById("header-portal")
Expand Down
8 changes: 4 additions & 4 deletions packages/app/components/menu.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,12 @@ import {
import React, { useContext } from "react"
import { NavLink, Route, Routes } from "react-router-dom"

import { LayoutContext } from "./layout"
import { AppContext } from "../app"
import { DemoTabView } from "../demo/DemoTabView"
import { useToggle } from "../hooks"
import { LayoutContext } from "./layout"

const MatchMenu: React.VFC = () => {
const MatchMenu: React.FC = () => {
const { match } = useContext(AppContext)
const open = useToggle()
return (
Expand All @@ -30,7 +30,7 @@ const MatchMenu: React.VFC = () => {
)
}

const MenuLink: React.VFC<{
const MenuLink: React.FC<{
icon: IconProp
label?: string
divider?: boolean
Expand All @@ -47,7 +47,7 @@ const MenuLink: React.VFC<{
)
}

const MenuButton: React.VFC<
const MenuButton: React.FC<
React.ComponentProps<typeof ListItemButton> & {
icon: IconProp
label?: string
Expand Down
4 changes: 2 additions & 2 deletions packages/app/demo/DebugNav.tsx
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import React from "react"

import { useAuth } from "../hooks"
import { storagePut } from "./io"
import { useAuth } from "../hooks"

export const DebugNav: React.VFC<{
export const DebugNav: React.FC<{
match: Match
round: Round | undefined
frame: Frame | undefined
Expand Down
2 changes: 1 addition & 1 deletion packages/app/demo/DebugView.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import React from "react"

export const DebugView: React.VFC<{ match: Match }> = ({ match }) => {
export const DebugView: React.FC<{ match: Match }> = ({ match }) => {
return (
<section>
<pre>
Expand Down
12 changes: 8 additions & 4 deletions packages/app/demo/DemoFilePicker.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,20 +2,24 @@ import React from "react"

import { openDemo, isValidFile } from "./io"

export const DemoFilePicker: React.VFC<{
export const DemoFilePicker: React.FC<{
setMatch?: (match: Match | null) => void
onLoad?: (match: Match, name: string) => void
}> = ({ setMatch, onLoad }) => {
const [output, setOutput] = React.useState<string[]>([])
const [files, setFiles] = React.useState<File[]>()
const mounted = React.useRef(true)
React.useEffect(() => {
const file = files && files[0]
const file = files?.at(0)
if (!file) return
if (!isValidFile(file)) return console.error("invalid file")
openDemo(file, setOutput, setMatch).then((match) => {
setMatch?.(match)
if (match) onLoad?.(match, file.name)
if (mounted.current) {
setMatch?.(match)
if (match) onLoad?.(match, file.name)
}
})
return () => void (mounted.current = false)
}, [files])
return (
<>
Expand Down
9 changes: 5 additions & 4 deletions packages/app/demo/DemoMenu.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,12 @@ import { Box, Tab, Tabs } from "@mui/material"
import React from "react"

import { findPlayer, icon } from "."
import { useSteamUsers } from "../hooks"
import { Filter } from "./DemoPlayer"
import { PlayerCard } from "./PlayerCard"
import { PlayerLabel } from "./PlayerLabel"
import { useSteamUsers } from "../hooks"

export const DemoMenu: React.VFC<{
export const DemoMenu: React.FC<{
match: Match
round?: Round
frame?: Frame
Expand Down Expand Up @@ -60,8 +60,9 @@ export const DemoMenu: React.VFC<{
>
<PlayerLabel player={findPlayer(match, e.Killer)} />
<img height={16} src={icon(e.Weapon)} />
{!!e.Penetrated && <span>(P)</span>}
{e.IsHeadshot && <span>(H)</span>}
{/* TODO: add icon */}
{!!e.Penetrated && <span>(-x-)</span>}
{e.IsHeadshot && <span>(HS)</span>}
<PlayerLabel player={findPlayer(match, e.Victim)} />
</Box>
))}
Expand Down
6 changes: 3 additions & 3 deletions packages/app/demo/DemoNav.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import React from "react"

import { teamColor } from "."

export const DemoNav: React.VFC<{
export const DemoNav: React.FC<{
match: Pick<Match, "Rounds" | "Ended">
round?: Round
onChange?: (round: Round) => void
Expand All @@ -32,15 +32,15 @@ export const DemoNav: React.VFC<{
<DemoNavItem key={i}>
<FontAwesomeIcon icon={faSyncAlt} size="xs" color="#333" />
</DemoNavItem>
)
),
)}
</>
)}
</>
)
}

const DemoNavItem: React.VFC<{
const DemoNavItem: React.FC<{
active?: boolean
size?: number
color?: string
Expand Down
18 changes: 9 additions & 9 deletions packages/app/demo/DemoPlayer.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,16 @@ import { css } from "@emotion/react"
import React from "react"

import { findRound, findFrame } from "."
import { HeaderSlot } from "../components/layout"
import { DebugNav } from "./DebugNav"
import { DemoMenu } from "./DemoMenu"
import { DemoNav } from "./DemoNav"
import { DemoSlider } from "./DemoSlider"
import { FrameView, TrailView } from "./FrameView"
import { MapEventView } from "./MapEventView"
import { MapView } from "./MapView"
import { HeaderSlot } from "../components/layout"

export const DemoPlayer: React.VFC<{
export const DemoPlayer: React.FC<{
match: Match
tick?: number
setTick?: (tick: number | undefined) => void
Expand All @@ -27,19 +27,19 @@ export const DemoPlayer: React.VFC<{
if (frame && !round?.Frames.includes(frame)) setFrame(round?.Frames[0])
}, [round])
React.useEffect(() => ref.current?.focus(), [ref.current])
React.useEffect(() =>
clearInterval.bind(
React.useEffect(() => {
return clearTimeout.bind(
window,
setTimeout(
() => !state.paused && setCurrentFrame(currentFrame + 1),
1000 / 8
)
1000 / 8,
),
)
)
}, [])
React.useEffect(() => {
document.body.style.overscrollBehavior = "none"
return () => void (document.body.style.overscrollBehavior = "auto")
})
}, [])
function setCurrentFrame(n: number) {
const frame = round?.Frames[n]
if (frame) setFrame(frame)
Expand All @@ -57,7 +57,7 @@ export const DemoPlayer: React.VFC<{
setFrame(findFrame(match, Tick))
setTick?.(Tick)
},
[match, setTick]
[match, setTick],
)
function onKeyDown(e: React.KeyboardEvent) {
const dict: { [key: string]: () => void } = {
Expand Down
Loading

0 comments on commit 8c38fcf

Please sign in to comment.