-
Notifications
You must be signed in to change notification settings - Fork 74
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
docs(changeset): experimental websocket support (doesn't work yet, wa…
…iting on dependencies)
- Loading branch information
Showing
22 changed files
with
352 additions
and
139 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
--- | ||
"vinxi": patch | ||
--- | ||
|
||
experimental websocket support (doesn't work yet, waiting on dependencies) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
.vercel |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
# example-vanilla | ||
|
||
## null | ||
|
||
### Patch Changes | ||
|
||
- Updated dependencies [fd06048] | ||
- Updated dependencies [0f14555] | ||
- Updated dependencies [82267c5] | ||
- vinxi@0.0.30 | ||
- @vinxi/plugin-references@0.0.20 | ||
|
||
## null | ||
|
||
### Patch Changes | ||
|
||
- Updated dependencies [8058084] | ||
- vinxi@0.0.29 | ||
- @vinxi/plugin-references@0.0.19 | ||
|
||
## null | ||
|
||
### Patch Changes | ||
|
||
- Updated dependencies [b934e84] | ||
- Updated dependencies [17693dc] | ||
- Updated dependencies [d6305b8] | ||
- Updated dependencies [cb91c48] | ||
- Updated dependencies [085116d] | ||
- Updated dependencies [f1ee5b8] | ||
- vinxi@0.0.28 | ||
- @vinxi/plugin-references@0.0.18 | ||
|
||
## null | ||
|
||
### Patch Changes | ||
|
||
- Updated dependencies [7803042] | ||
- vinxi@0.0.27 | ||
- @vinxi/plugin-references@0.0.17 | ||
|
||
## null | ||
|
||
### Patch Changes | ||
|
||
- Updated dependencies [2b17e0d] | ||
- vinxi@0.0.26 | ||
- @vinxi/plugin-references@0.0.16 | ||
|
||
## null | ||
|
||
### Patch Changes | ||
|
||
- Updated dependencies [552d8ca] | ||
- vinxi@0.0.25 | ||
- @vinxi/plugin-references@0.0.15 | ||
|
||
## null | ||
|
||
### Patch Changes | ||
|
||
- Updated dependencies [47abc3c] | ||
- @vinxi/plugin-references@0.0.14 | ||
- vinxi@0.0.24 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
import { references } from "@vinxi/plugin-references"; | ||
import { createApp } from "vinxi"; | ||
|
||
export default createApp({ | ||
server: { | ||
plugins: [references.serverPlugin], | ||
virtual: { | ||
[references.serverPlugin]: references.serverPluginModule(), | ||
}, | ||
}, | ||
routers: [ | ||
{ | ||
name: "public", | ||
mode: "static", | ||
dir: "./public", | ||
}, | ||
{ | ||
name: "client", | ||
mode: "spa", | ||
handler: "./index.html", | ||
target: "browser", | ||
plugins: () => [references.clientRouterPlugin()], | ||
}, | ||
{ | ||
name: "party", | ||
base: "/party", | ||
mode: "handler", | ||
handler: "./app/party.ts", | ||
target: "server", | ||
}, | ||
references.serverRouter({ | ||
middleware: "./app/middleware.tsx", | ||
}), | ||
], | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
"use server"; | ||
|
||
let store = { count: 0 }; | ||
export function sayHello() { | ||
console.log("Hello World"); | ||
store.count++; | ||
return store.count; | ||
} | ||
|
||
export function getStore() { | ||
return store.count; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
import { sayHello } from "./actions"; | ||
import "./style.css"; | ||
|
||
console.log(await sayHello()); | ||
console.log("Hello world!"); | ||
|
||
const ws = new WebSocket(`ws://${window.location.host}/party`); | ||
|
||
await new Promise((resolve) => { | ||
ws.addEventListener("open", resolve); | ||
}); | ||
|
||
ws.addEventListener("message", (event) => { | ||
document.getElementById("app").innerHTML += `<p>${event.data}</p>`; | ||
}); | ||
|
||
document.getElementById("form").onsubmit = (event) => { | ||
event.preventDefault(); | ||
const input = document.getElementById("input") as HTMLInputElement; | ||
ws.send(input.value); | ||
input.value = ""; | ||
}; | ||
|
||
ws.send("Hello world!"); | ||
|
||
console.log(await fetch("/party").then((res) => res.text())); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
import { defineMiddleware, getContext, setContext } from "vinxi/runtime/server"; | ||
|
||
export default defineMiddleware({ | ||
onRequest: (event) => { | ||
setContext(event, "help", { foo: "bar" }); | ||
}, | ||
onBeforeResponse: (event) => { | ||
console.log(getContext(event, "help")); | ||
}, | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
import { partyHandler } from "vinxi/runtime/party"; | ||
|
||
export default partyHandler({ | ||
onMessage(party, message, connection) { | ||
// Broadcast message to all other members | ||
party.broadcast(new TextDecoder().decode(message), [connection.id]); | ||
}, | ||
|
||
onConnect(party, connection) { | ||
party.broadcast( | ||
JSON.stringify({ | ||
type: "members", | ||
conns: [...party.getConnections()].map((conn) => conn.id), | ||
}), | ||
); | ||
}, | ||
|
||
onClose(party, connection) { | ||
party.broadcast( | ||
JSON.stringify({ | ||
type: "members", | ||
conns: [...party.getConnections()].map((conn) => conn.id), | ||
}), | ||
[connection.id], | ||
); | ||
}, | ||
onRequest(party, req) { | ||
return new Response("Not found", { status: 501 }); | ||
}, | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
@tailwind base; | ||
@tailwind components; | ||
@tailwind utilities; | ||
|
||
* { | ||
color: red; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
<!DOCTYPE html> | ||
<html lang="en"> | ||
<head> | ||
<meta charset="UTF-8" /> | ||
<meta name="viewport" content="width=device-width, initial-scale=1.0" /> | ||
<title>Document</title> | ||
<link rel="icon" href="/favicon.ico" /> | ||
</head> | ||
<body> | ||
<form id="form"><input id="input" /><button>Submit</button></form> | ||
<div id="app"></div> | ||
<script src="./app/client.tsx" type="module"></script> | ||
</body> | ||
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
{ | ||
"name": "example-vanilla-partyroom", | ||
"type": "module", | ||
"private": true, | ||
"version": null, | ||
"scripts": { | ||
"dev": "vinxi dev", | ||
"build": "vinxi build", | ||
"start": "vinxi start" | ||
}, | ||
"dependencies": { | ||
"@picocss/pico": "^1.5.10", | ||
"@vinxi/plugin-references": "0.0.20", | ||
"autoprefixer": "^10.4.15", | ||
"tailwindcss": "^3.3.3", | ||
"vinxi": "0.0.30" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
module.exports = { | ||
plugins: { | ||
tailwindcss: {}, | ||
autoprefixer: {}, | ||
}, | ||
} |
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
/** @type {import('tailwindcss').Config} */ | ||
module.exports = { | ||
content: ["./app/**/*.tsx", "./app/**/*.ts", "./app/**/*.js"], | ||
theme: { | ||
extend: {}, | ||
}, | ||
plugins: [], | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.