From 080afd095c996498132becc7dba914053e6ee6a5 Mon Sep 17 00:00:00 2001 From: yoshikouki Date: Sat, 2 Mar 2024 22:13:50 +0900 Subject: [PATCH] WebSocket Sample --- sample/with-websocket/.gitignore | 175 +++++++++++++++++++++++++++ sample/with-websocket/README.md | 13 ++ sample/with-websocket/bun.lockb | Bin 0 -> 9946 bytes sample/with-websocket/package.json | 20 +++ sample/with-websocket/src/app.tsx | 15 +++ sample/with-websocket/src/client.tsx | 36 ++++++ sample/with-websocket/src/index.tsx | 49 ++++++++ sample/with-websocket/tsconfig.json | 35 ++++++ 8 files changed, 343 insertions(+) create mode 100644 sample/with-websocket/.gitignore create mode 100644 sample/with-websocket/README.md create mode 100755 sample/with-websocket/bun.lockb create mode 100644 sample/with-websocket/package.json create mode 100644 sample/with-websocket/src/app.tsx create mode 100644 sample/with-websocket/src/client.tsx create mode 100644 sample/with-websocket/src/index.tsx create mode 100644 sample/with-websocket/tsconfig.json diff --git a/sample/with-websocket/.gitignore b/sample/with-websocket/.gitignore new file mode 100644 index 0000000..9b1ee42 --- /dev/null +++ b/sample/with-websocket/.gitignore @@ -0,0 +1,175 @@ +# Based on https://raw.githubusercontent.com/github/gitignore/main/Node.gitignore + +# Logs + +logs +_.log +npm-debug.log_ +yarn-debug.log* +yarn-error.log* +lerna-debug.log* +.pnpm-debug.log* + +# Caches + +.cache + +# Diagnostic reports (https://nodejs.org/api/report.html) + +report.[0-9]_.[0-9]_.[0-9]_.[0-9]_.json + +# Runtime data + +pids +_.pid +_.seed +*.pid.lock + +# Directory for instrumented libs generated by jscoverage/JSCover + +lib-cov + +# Coverage directory used by tools like istanbul + +coverage +*.lcov + +# nyc test coverage + +.nyc_output + +# Grunt intermediate storage (https://gruntjs.com/creating-plugins#storing-task-files) + +.grunt + +# Bower dependency directory (https://bower.io/) + +bower_components + +# node-waf configuration + +.lock-wscript + +# Compiled binary addons (https://nodejs.org/api/addons.html) + +build/Release + +# Dependency directories + +node_modules/ +jspm_packages/ + +# Snowpack dependency directory (https://snowpack.dev/) + +web_modules/ + +# TypeScript cache + +*.tsbuildinfo + +# Optional npm cache directory + +.npm + +# Optional eslint cache + +.eslintcache + +# Optional stylelint cache + +.stylelintcache + +# Microbundle cache + +.rpt2_cache/ +.rts2_cache_cjs/ +.rts2_cache_es/ +.rts2_cache_umd/ + +# Optional REPL history + +.node_repl_history + +# Output of 'npm pack' + +*.tgz + +# Yarn Integrity file + +.yarn-integrity + +# dotenv environment variable files + +.env +.env.development.local +.env.test.local +.env.production.local +.env.local + +# parcel-bundler cache (https://parceljs.org/) + +.parcel-cache + +# Next.js build output + +.next +out + +# Nuxt.js build / generate output + +.nuxt +dist + +# Gatsby files + +# Comment in the public line in if your project uses Gatsby and not Next.js + +# https://nextjs.org/blog/next-9-1#public-directory-support + +# public + +# vuepress build output + +.vuepress/dist + +# vuepress v2.x temp and cache directory + +.temp + +# Docusaurus cache and generated files + +.docusaurus + +# Serverless directories + +.serverless/ + +# FuseBox cache + +.fusebox/ + +# DynamoDB Local files + +.dynamodb/ + +# TernJS port file + +.tern-port + +# Stores VSCode versions used for testing VSCode extensions + +.vscode-test + +# yarn v2 + +.yarn/cache +.yarn/unplugged +.yarn/build-state.yml +.yarn/install-state.gz +.pnp.* + +# IntelliJ based IDEs +.idea + +# Finder (MacOS) folder config +.DS_Store diff --git a/sample/with-websocket/README.md b/sample/with-websocket/README.md new file mode 100644 index 0000000..fc18a0c --- /dev/null +++ b/sample/with-websocket/README.md @@ -0,0 +1,13 @@ +# basic-hot-reload + +## Setup + +```bash +bun install +``` + +# To run + +```bash +bun dev +``` diff --git a/sample/with-websocket/bun.lockb b/sample/with-websocket/bun.lockb new file mode 100755 index 0000000000000000000000000000000000000000..1a53eeb701b2f47b92a82bbe7e3c8414af4954c2 GIT binary patch literal 9946 zcmeHM30PD|5+2}z1Qa~bh@yhTQGq$R1p!ebw{j@52#PQa!!<`BI3br@OELVW~PTx6M}KSFZ=Ch@eTD}cmID^*XyqC_sZCa zl^_ecwvmE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|6yK=#}5LfaKgr&WcizyMRWrawMzOSwr%6B=6N(Lo$0L zGuBx{a(^Uu)>%WcgCx7wStFn8il?orVgmj`A(=mtIqR$;xj~X!>#QN!Ly~<1UxTBW zTpEq!4N2ZjRpA4YK_nSCRh0!?Hj~3)nv)zO$@mSj-avW6;lrX+GiZFIU4X!TGt!#`2s>vQGQ^>jLpu_VB?j zzlnz|j>2^^cJM=b-OYYGzWU|;`g-{&oN-ZtK#YX-&iSq7PMaMf7KAb)gc62`7cC44 zbHXgI7`v2TNf(3iH6u(IBW)Ba62wWQ)mRiEk;I9|uvj77Nhf;Aq^gEri4EyS|}9r7?55Ugr|r@BY0s6(LB-b@hP}EdAfiocL7M{TLy<| z0do=Tkj_cA;ktzg>QM_nDEUyy)cL~WK^2mzcp-~hmSh^Vb`yBw20wy2UhkQyS{W$6m7&~3|5kzul zzC$K2`&i55kLOoL{VO$poLp|I66Z$_{M~8vF5O2B9S#$KhW`xd8RB>5_WL0Vpo%yo zi#;6aeDCVv$zq`trhv=OJkq5itB(^2;~3IQd7p~a+y%FMM+92=6~i2kCBL^|-|qn6 ziq0T(aIBa%-E&K)%|Ow4!{Aslt#Oa-I&R3#csG1Vd&XEIbww9LSG0ky71v4=RL&kN z4CBc!le&t)iZ(!(BxcA?0^J(`b^$0<4B6R&Yk|mw*f2q;;CBb2+ze=xZz24`;ldKh LWc%>{-v9pqM}N6h literal 0 HcmV?d00001 diff --git a/sample/with-websocket/package.json b/sample/with-websocket/package.json new file mode 100644 index 0000000..1e3edfe --- /dev/null +++ b/sample/with-websocket/package.json @@ -0,0 +1,20 @@ +{ + "name": "basic-hot-reload", + "module": "src/index.ts", + "type": "module", + "scripts": { + "dev": "bun --hot src/index.tsx" + }, + "devDependencies": { + "@types/bun": "latest", + "@types/react": "^18.2.61", + "@types/react-dom": "^18.2.19", + "add": "^2.0.6", + "bun": "^1.0.29", + "typescript": "^5" + }, + "dependencies": { + "react": "^18.2.0", + "react-dom": "^18.2.0" + } +} diff --git a/sample/with-websocket/src/app.tsx b/sample/with-websocket/src/app.tsx new file mode 100644 index 0000000..de274ab --- /dev/null +++ b/sample/with-websocket/src/app.tsx @@ -0,0 +1,15 @@ +export const App = () => { + return ( + + + + + Bun Hot Reload +