Skip to content

Commit df52ea3

Browse files
committed
docs
1 parent cbeb6ae commit df52ea3

File tree

1 file changed

+71
-0
lines changed

1 file changed

+71
-0
lines changed

docs/App-server.md

Lines changed: 71 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,71 @@
1+
### Prerequisites
2+
3+
- Run your world with client dev features enabled: set env `PUBLIC_DEV_SERVER=true` when starting the client app.
4+
- You must be an admin in the world to access Dev Tools and link apps.
5+
6+
---
7+
8+
### Start the local app server
9+
10+
```bash
11+
npx @drama.haus/app-server # starts on http://localhost:8080 (WS on ws://localhost:8080/)
12+
```
13+
14+
Notes
15+
- Hot reload is ON by default. Disable with `--no-hot-reload` or `HOT_RELOAD=false`.
16+
- Health check: `GET http://localhost:8080/health`.
17+
18+
---
19+
20+
### Link an app from your world (one‑time per app)
21+
22+
1) In your running world, open the Sidebar → Dev Tools (gear icon). It should show Connected if the server is up on port 8080. You can change the port and reconnect from this pane.
23+
2) Select an app in the Apps pane, open its inspector, and click the Link (chain) icon. The client will:
24+
- Create `apps/<appName>/` locally on the dev server if missing
25+
- Upload current script and metadata
26+
- Save minimal overrides to `apps/<appName>/links.json`
27+
28+
After linking, the app is associated with your world URL and eligible for hot reload.
29+
30+
---
31+
32+
### Common workflow
33+
34+
1) Edit your local file on disk: `apps/<appName>/index.js`.
35+
2) The dev server detects changes and pushes an update to the connected world only for that linked app.
36+
3) The client receives the update, hashes and stages the script as `asset://<hash>.js`, uploads it if needed, updates the app blueprint, and applies the changes live.
37+
38+
Result: Changes appear in‑world in ~1–2 seconds without page refresh.
39+
40+
What’s watched by the server
41+
- `apps/<appName>/index.js` — script changes deploy to the linked world
42+
- `apps/<appName>/links.json` — blueprint/prop changes deploy to the linked world
43+
44+
Tips
45+
- You can still use the Dev Tools pane to manually Deploy or Unlink an app.
46+
- If you add model/prop assets referenced as `asset://<hash>.<ext>`, the server may request the file from the client; assets are saved under `apps/<appName>/assets/`.
47+
48+
---
49+
50+
### Minimal CLI you might use
51+
52+
```bash
53+
# Start server (hot reload on)
54+
npx @drama.haus/app-server
55+
56+
# (Optional) Create a scaffold if starting from scratch
57+
npx @drama.haus/app-server create myApp
58+
59+
# Manually deploy (rarely needed once hot reload is on)
60+
npx @drama.haus/app-server deploy myApp
61+
```
62+
63+
---
64+
65+
### Troubleshooting
66+
67+
- Dev Tools shows Disconnected: ensure the server is running and the port matches (default 8080). Use Refresh Status.
68+
- No Dev Tools in Sidebar: ensure `PUBLIC_DEV_SERVER=true` and you are admin.
69+
- Changes not appearing: confirm the app is linked (Link icon active) and that you are editing `apps/<appName>/index.js` on the dev server’s filesystem.
70+
71+

0 commit comments

Comments
 (0)