chadtmiller.com/group-host
atmosphere group host
0
0
just dev redraws the console as its source changes
docs/development.md+2−1
| @@ -16,7 +16,8 @@ just web-dev # the console alone, asking that host | ||
`just dev` starts a world of its own (`harness/dev.mjs`): the reference | ||
PDS and a PLC directory with alice, bob and harbor on them, the host over | ||
them, and the console at https://group-host.localtest.me, with a group of | ||
alice's. It prints each one's password, where the codes the PDS emails | ||
alice's. The console is the dev server's, so a change to a page shows at | ||
once; a change to the host means starting it again. It prints each one's password, where the codes the PDS emails | ||
are read, and how to run the command against it. ctrl-c stops it all, and | ||
each start is empty again. | ||
| ||
harness/dev.mjs+3−1
| @@ -1,6 +1,7 @@ | ||
// `just dev`: a world to use the console in (world.mjs), for a person to | ||
// look at: the reference PDS with alice, bob and harbor on it, the host, the | ||
// console at https://group-host.localtest.me, and a group of alice's. | ||
// console at https://group-host.localtest.me, served by the dev server so a | ||
// change to it shows at once, and a group of alice's. | ||
// Stops on ctrl-c, and forgets everything: the PDS, the directory and the | ||
// host start empty each time. | ||
// | ||
| @@ -49,6 +50,7 @@ const w = await start({ | ||
accounts: ['alice', 'bob', 'harbor'], | ||
front, | ||
pdsEnv: { NODE_EXTRA_CA_CERTS: join(state, 'ca.pem') }, | ||
live: true, | ||
}) | ||
| ||
const stop = () => { | ||
harness/world.mjs+6−4
| @@ -53,9 +53,10 @@ const serviceAuth = async (pds, account, aud, lxm) => { | ||
| ||
/// Starts a world with `accounts` on the reference PDS, its console | ||
/// served at the port `front` is given and reached at the https address | ||
/// `front` answers with (`front(consolePort, net, children)`). `pdsEnv` is | ||
/// the PDS's environment beyond this one's. Its parts, and `stop`. | ||
export async function start({ accounts, front, pdsEnv = {} }) { | ||
/// `front` answers with (`front(consolePort, net, children)`): built, or | ||
/// with `live`, by the dev server, redrawn as its source changes. `pdsEnv` | ||
/// is the PDS's environment beyond this one's. Its parts, and `stop`. | ||
export async function start({ accounts, front, pdsEnv = {}, live = false }) { | ||
const children = [] | ||
const stop = () => children.reverse().forEach((c) => c.kill('SIGTERM')) | ||
try { | ||
| @@ -88,7 +89,8 @@ export async function start({ accounts, front, pdsEnv = {} }) { | ||
children.push(server) | ||
await line(server, (l) => l.startsWith('listening on')) | ||
| ||
const web = spawn('node', ['build'], { | ||
const serve = live ? ['npx', ['vite', 'dev', '--port', String(consolePort), '--strictPort', '--host', '127.0.0.1']] : ['node', ['build']] | ||
const web = spawn(serve[0], serve[1], { | ||
cwd: join(root, 'web'), | ||
stdio: ['ignore', 'inherit', 'inherit'], | ||
// A body as large as the host takes, past the Node adapter's 512K. | ||
web/src/lib/organisms/SignInDialog.svelte+0−1
| @@ -17,7 +17,6 @@ | ||
Your handle | ||
<input name="handle" required autocomplete="username" autocapitalize="none" spellcheck="false" placeholder="you.bsky.social" /> | ||
</label> | ||
<p class="mute small">Your server asks you to approve it, then sends you back here.</p> | ||
<div class="actions"> | ||
<button class="quiet" type="button" popovertarget={SIGN_IN} popovertargetaction="hide">Cancel</button> | ||
<button type="submit">Continue</button> | ||
web/vite.config.ts+10−0
| @@ -4,15 +4,25 @@ import { defineConfig } from 'vite'; | ||
| ||
/** The group host, which `vite dev` hands what it answers itself. */ | ||
const host = process.env.GROUP_HOST ?? 'http://127.0.0.1:2600'; | ||
/** | ||
* Where people reach the console when not at the dev server itself, as | ||
* the built console reads it too: `just dev` serves it behind portless at | ||
* https://group-host.localtest.me. The dev server answers that name, takes | ||
* a form's post from it, and has the page find its updates through it. | ||
*/ | ||
const origin = process.env.ORIGIN ? new URL(process.env.ORIGIN) : null; | ||
| ||
export default defineConfig({ | ||
server: { | ||
allowedHosts: origin ? [origin.hostname] : [], | ||
hmr: origin ? { clientPort: Number(origin.port || (origin.protocol === 'https:' ? 443 : 80)) } : undefined, | ||
proxy: { '^/xrpc/': host, '^/oauth/': host, '^/\\.well-known/': host, '^/img/': host } | ||
}, | ||
plugins: [ | ||
sveltekit({ | ||
compilerOptions: { runes: true }, | ||
adapter: adapter(), | ||
csrf: { trustedOrigins: origin ? [origin.origin] : [] }, | ||
// One stylesheet, small enough to come with each page. | ||
inlineStyleThreshold: Infinity, | ||
csp: { | ||
Justfile+4−2
| @@ -53,8 +53,10 @@ web-dev: | ||
| ||
# The console to use yourself, over a world of its own (harness/dev.mjs): | ||
# the reference PDS with alice, bob and harbor, the host, and the console | ||
# at https://group-host.localtest.me, behind portless. Empty each time. | ||
dev: web | ||
# at https://group-host.localtest.me, behind portless, redrawn as its | ||
# source changes. Empty each time; the host is built again first. | ||
dev: | ||
cd web && npm run lex | ||
{{cargo}} build -p group-host | ||
node harness/dev.mjs | ||
| ||