Compare commits
No commits in common. "08f04e09d439f2a2e9829f6bbcc87b78025e2bbe" and "1557a148794b1751a7d7efc99ab391461655768f" have entirely different histories.
08f04e09d4
...
1557a14879
3
.gitignore
vendored
3
.gitignore
vendored
|
|
@ -1,2 +1 @@
|
||||||
node_modules/
|
node_modules/
|
||||||
.claude/
|
|
||||||
|
|
@ -25,7 +25,7 @@
|
||||||
|
|
||||||
"kleur": ["kleur@4.1.5", "", {}, "sha512-o+NO+8WrRiQEE4/7nwRJhN1HWpVmJm511pBHUxPLtp0BUISzlBplORYSmTclCnJvQq2tKu/sgl3xVpkc7ZWuQQ=="],
|
"kleur": ["kleur@4.1.5", "", {}, "sha512-o+NO+8WrRiQEE4/7nwRJhN1HWpVmJm511pBHUxPLtp0BUISzlBplORYSmTclCnJvQq2tKu/sgl3xVpkc7ZWuQQ=="],
|
||||||
|
|
||||||
"pyre": ["pyre@file:..", { "dependencies": { "hype": "git+https://git.nose.space/defunkt/hype" }, "devDependencies": { "@types/bun": "latest" }, "peerDependencies": { "typescript": "^5" } }],
|
"pyre": ["pyre@file:..", { "dependencies": { "hype": "git+https://git.nose.space/defunkt/hype" }, "devDependencies": { "@types/bun": "latest" }, "peerDependencies": { "hono": "*", "typescript": "^5" } }],
|
||||||
|
|
||||||
"typescript": ["typescript@5.9.3", "", { "bin": { "tsc": "bin/tsc", "tsserver": "bin/tsserver" } }, "sha512-jl1vZzPDinLr9eUt3J/t7V6FgNEw9QjvBPdysz9KfQDD41fQrC2Y4vKQdiaUpFT4bXlb1RHhLpp8wtm6M5TgSw=="],
|
"typescript": ["typescript@5.9.3", "", { "bin": { "tsc": "bin/tsc", "tsserver": "bin/tsserver" } }, "sha512-jl1vZzPDinLr9eUt3J/t7V6FgNEw9QjvBPdysz9KfQDD41fQrC2Y4vKQdiaUpFT4bXlb1RHhLpp8wtm6M5TgSw=="],
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,10 @@
|
||||||
import { render } from 'hono/jsx/dom' // needed to use the same hono/jsx as the frontend
|
import { render } from 'hono/jsx/dom'
|
||||||
import { setup } from 'pyre/client'
|
import { setup } from 'pyre/client'
|
||||||
import type { Game } from '../types'
|
import type { Game } from '../types'
|
||||||
import Board from './board'
|
import Board from './board'
|
||||||
|
|
||||||
setup<Game>(render, game => <Board game={game} />)
|
const root = document.getElementById('root')!
|
||||||
|
|
||||||
|
setup<Game>(game => {
|
||||||
|
render(game ? <Board game={game} /> : <h1>Loading...</h1>, root)
|
||||||
|
})
|
||||||
|
|
|
||||||
|
|
@ -3,7 +3,7 @@
|
||||||
"module": "src/index.ts",
|
"module": "src/index.ts",
|
||||||
"type": "module",
|
"type": "module",
|
||||||
"exports": {
|
"exports": {
|
||||||
"./client": "./src/client/index.ts",
|
"./client": "./src/client.ts",
|
||||||
"./server": "./src/server/index.tsx"
|
"./server": "./src/server/index.tsx"
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
|
|
@ -16,6 +16,7 @@
|
||||||
"hype": "git+https://git.nose.space/defunkt/hype"
|
"hype": "git+https://git.nose.space/defunkt/hype"
|
||||||
},
|
},
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"check": "bunx tsc --noEmit"
|
"start": "bun run src/server/index.tsx",
|
||||||
|
"dev": "bun run --hot src/server/index.tsx"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
3
src/client.ts
Normal file
3
src/client.ts
Normal file
|
|
@ -0,0 +1,3 @@
|
||||||
|
export { setup } from '#setup'
|
||||||
|
export { send, gameId } from '#websocket'
|
||||||
|
export { sessionId } from '#session'
|
||||||
|
|
@ -1,3 +0,0 @@
|
||||||
export { setup } from './setup'
|
|
||||||
export { send, gameId } from './websocket'
|
|
||||||
export { sessionId } from './session'
|
|
||||||
13
src/client/setup.ts
Normal file
13
src/client/setup.ts
Normal file
|
|
@ -0,0 +1,13 @@
|
||||||
|
import { initWebsocket, onUpdate } from '#websocket'
|
||||||
|
|
||||||
|
export function setup<G>(onRender: (game: G | undefined) => void) {
|
||||||
|
let game: G | undefined = undefined
|
||||||
|
|
||||||
|
onUpdate((newGame: G) => {
|
||||||
|
game = newGame
|
||||||
|
onRender(game)
|
||||||
|
})
|
||||||
|
|
||||||
|
initWebsocket()
|
||||||
|
onRender(game)
|
||||||
|
}
|
||||||
|
|
@ -1,18 +0,0 @@
|
||||||
import { type Child, render as renderJsx } from 'hono/jsx/dom'
|
|
||||||
import { initWebsocket, onUpdate } from './websocket'
|
|
||||||
|
|
||||||
const root = document.getElementById('root')!
|
|
||||||
|
|
||||||
export function setup<G>(render: typeof renderJsx, onRender: (game: G) => Child) {
|
|
||||||
let game: G | undefined = undefined
|
|
||||||
|
|
||||||
onUpdate((newGame: G) => {
|
|
||||||
game = newGame
|
|
||||||
render(game ? onRender(game) : <Loading />, root)
|
|
||||||
})
|
|
||||||
|
|
||||||
initWebsocket()
|
|
||||||
render(game ? onRender(game) : <Loading />, root)
|
|
||||||
}
|
|
||||||
|
|
||||||
const Loading = () => <h1>Loading...</h1>
|
|
||||||
|
|
@ -1,5 +1,5 @@
|
||||||
import type { Message } from '../shared/types'
|
import type { Message } from '@types'
|
||||||
import { sessionId } from './session'
|
import { sessionId } from '#session'
|
||||||
|
|
||||||
const MAX_RETRIES = 5
|
const MAX_RETRIES = 5
|
||||||
let retries = 0
|
let retries = 0
|
||||||
|
|
|
||||||
|
|
@ -6,7 +6,7 @@ const GIT_HASH = process.env.RENDER_GIT_COMMIT?.slice(0, 7)
|
||||||
export default () => <>
|
export default () => <>
|
||||||
<html lang="en">
|
<html lang="en">
|
||||||
<head>
|
<head>
|
||||||
<title>🔥 pyre</title>
|
<title>hype</title>
|
||||||
<meta charset="utf-8" />
|
<meta charset="utf-8" />
|
||||||
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
||||||
<meta name="color-scheme" content="light dark" />
|
<meta name="color-scheme" content="light dark" />
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,5 @@
|
||||||
import type { Message } from '../shared/types'
|
import type { Message } from '@types'
|
||||||
import { send, sendTo } from './websocket'
|
import { send, sendTo } from '$websocket'
|
||||||
|
|
||||||
// set by setup, called by server
|
// set by setup, called by server
|
||||||
export let dispatch = (ws: any, msg: Message) => { }
|
export let dispatch = (ws: any, msg: Message) => { }
|
||||||
|
|
|
||||||
|
|
@ -1,8 +1,8 @@
|
||||||
import { writeFileSync as writeFile, readFileSync as readFile, existsSync as exists } from 'fs'
|
import { writeFileSync as writeFile, readFileSync as readFile, existsSync as exists } from 'fs'
|
||||||
import { watch } from 'fs'
|
import { watch } from 'fs'
|
||||||
import { join } from 'path'
|
import { join } from 'path'
|
||||||
import { parseActions } from './actionParser'
|
import { parseActions } from '$actionParser'
|
||||||
import { normalize } from './action'
|
import { normalize } from '$action'
|
||||||
|
|
||||||
const srcDir = join(process.cwd(), 'src')
|
const srcDir = join(process.cwd(), 'src')
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,14 +1,14 @@
|
||||||
import { upgradeWebSocket, websocket } from 'hono/bun'
|
import { upgradeWebSocket, websocket } from 'hono/bun'
|
||||||
import { Hype } from 'hype'
|
import { Hype } from 'hype'
|
||||||
import type { Message } from '../shared/types'
|
import type { Message } from '@types'
|
||||||
import { send, addWebsocket, removeWebsocket, closeWebsockets } from './websocket'
|
import { send, addWebsocket, removeWebsocket, closeWebsockets } from '$websocket'
|
||||||
import { dispatch, onPart } from './action'
|
import { dispatch, onPart } from '$action'
|
||||||
import IndexPage from '../pages/index'
|
import IndexPage from '../pages/index'
|
||||||
|
|
||||||
export { setup } from './action'
|
export { setup } from '$action'
|
||||||
export type { Context } from './action'
|
export type { Context } from '$action'
|
||||||
|
|
||||||
import './actionCodegen'
|
import '$actionCodegen'
|
||||||
|
|
||||||
const app = new Hype({ layout: false })
|
const app = new Hype({ layout: false })
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,4 @@
|
||||||
import type { Message } from '../shared/types'
|
import type { Message } from '@types'
|
||||||
|
|
||||||
const wsConnections = new Map<string, any>()
|
const wsConnections = new Map<string, any>()
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -19,6 +19,11 @@
|
||||||
"noUnusedLocals": false,
|
"noUnusedLocals": false,
|
||||||
"noUnusedParameters": false,
|
"noUnusedParameters": false,
|
||||||
"noPropertyAccessFromIndexSignature": false,
|
"noPropertyAccessFromIndexSignature": false,
|
||||||
"baseUrl": "."
|
"baseUrl": ".",
|
||||||
|
"paths": {
|
||||||
|
"$*": ["src/server/*"],
|
||||||
|
"#*": ["src/client/*"],
|
||||||
|
"@*": ["src/shared/*"]
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue
Block a user