Skip to content

Commit 1656c0b

Browse files
committed
useWsState
1 parent 9bd88fa commit 1656c0b

17 files changed

+2405
-50
lines changed

Makefile

+8-3
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,10 @@
11
npm=pnpm
22

3-
.PHONY: dev
4-
dev:
5-
cd ./test/ && nodemon -e go --watch './**/*.go' --watch '../handler/**/*.go' --signal SIGTERM --exec 'go' run .
3+
.PHONY: devVanilla
4+
devVanilla:
5+
cd ./example/vanilla && nodemon -e go --watch './**/*.go' --watch '../handler/**/*.go' --signal SIGTERM --exec 'go' run .
6+
7+
.PHONY: devReact
8+
devReact:
9+
tmux split-window -h 'cd example/react && npm run dev'
10+
cd ./example/react && nodemon -e go --watch './**/*.go' --watch '../handler/**/*.go' --signal SIGTERM --exec 'go' run .

example/react/.eslintrc.cjs

+20
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
module.exports = {
2+
root: true,
3+
env: { browser: true, es2020: true },
4+
extends: [
5+
'eslint:recommended',
6+
'plugin:react/recommended',
7+
'plugin:react/jsx-runtime',
8+
'plugin:react-hooks/recommended',
9+
],
10+
ignorePatterns: ['dist', '.eslintrc.cjs'],
11+
parserOptions: { ecmaVersion: 'latest', sourceType: 'module' },
12+
settings: { react: { version: '18.2' } },
13+
plugins: ['react-refresh'],
14+
rules: {
15+
'react-refresh/only-export-components': [
16+
'warn',
17+
{ allowConstantExport: true },
18+
],
19+
},
20+
}

example/react/.gitignore

+24
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
# Logs
2+
logs
3+
*.log
4+
npm-debug.log*
5+
yarn-debug.log*
6+
yarn-error.log*
7+
pnpm-debug.log*
8+
lerna-debug.log*
9+
10+
node_modules
11+
dist
12+
dist-ssr
13+
*.local
14+
15+
# Editor directories and files
16+
.vscode/*
17+
!.vscode/extensions.json
18+
.idea
19+
.DS_Store
20+
*.suo
21+
*.ntvs*
22+
*.njsproj
23+
*.sln
24+
*.sw?

example/react/README.md

+8
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
# React + Vite
2+
3+
This template provides a minimal setup to get React working in Vite with HMR and some ESLint rules.
4+
5+
Currently, two official plugins are available:
6+
7+
- [@vitejs/plugin-react](https://github.com/vitejs/vite-plugin-react/blob/main/packages/plugin-react/README.md) uses [Babel](https://babeljs.io/) for Fast Refresh
8+
- [@vitejs/plugin-react-swc](https://github.com/vitejs/vite-plugin-react-swc) uses [SWC](https://swc.rs/) for Fast Refresh

example/react/index.html

+15
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
<!doctype html>
2+
<html lang="en">
3+
4+
<head>
5+
<meta charset="UTF-8" />
6+
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
7+
<title>Vite + React</title>
8+
</head>
9+
10+
<body>
11+
<div id="root"></div>
12+
<script type="module" src="/src/main.jsx"></script>
13+
</body>
14+
15+
</html>

example/react/main.go

+17
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
package main
2+
3+
import (
4+
"log"
5+
"net/http"
6+
7+
wsync "github.com/simbafs/wsync/handler"
8+
mapstorage "github.com/simbafs/wsync/handler/mapStorage"
9+
)
10+
11+
func main() {
12+
ws := wsync.New(mapstorage.New())
13+
http.Handle("/ws", ws)
14+
http.Handle("/all", ws.All)
15+
16+
log.Fatal(http.ListenAndServe(":3000", nil))
17+
}

example/react/package.json

+26
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
{
2+
"name": "react",
3+
"private": true,
4+
"version": "0.0.0",
5+
"type": "module",
6+
"scripts": {
7+
"dev": "vite",
8+
"build": "vite build",
9+
"lint": "eslint . --ext js,jsx --report-unused-disable-directives --max-warnings 0",
10+
"preview": "vite preview"
11+
},
12+
"dependencies": {
13+
"react": "^18.2.0",
14+
"react-dom": "^18.2.0"
15+
},
16+
"devDependencies": {
17+
"@types/react": "^18.2.15",
18+
"@types/react-dom": "^18.2.7",
19+
"@vitejs/plugin-react": "^4.0.3",
20+
"eslint": "^8.45.0",
21+
"eslint-plugin-react": "^7.32.2",
22+
"eslint-plugin-react-hooks": "^4.6.0",
23+
"eslint-plugin-react-refresh": "^0.4.3",
24+
"vite": "^4.4.5"
25+
}
26+
}

0 commit comments

Comments
 (0)