Skip to content

Commit a45af6c

Browse files
committed
feat(frontend): add static SvelteKit tooling and CI
1 parent 18092e0 commit a45af6c

36 files changed

Lines changed: 3578 additions & 977 deletions

.github/workflows/test.yaml

Lines changed: 36 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -103,4 +103,39 @@ jobs:
103103
with:
104104
only-dev: true
105105
- run: |-
106-
uv run deptry ./src
106+
uv run deptry ./src
107+
108+
frontend:
109+
runs-on: ubuntu-latest
110+
steps:
111+
- uses: actions/checkout@v5
112+
- name: Setup Node
113+
uses: actions/setup-node@v5
114+
with:
115+
node-version: '22'
116+
cache: npm
117+
cache-dependency-path: frontend/package-lock.json
118+
- name: Install frontend dependencies
119+
working-directory: frontend
120+
run: npm ci
121+
- name: Check frontend types
122+
working-directory: frontend
123+
run: npm run check
124+
- name: Check frontend formatting
125+
working-directory: frontend
126+
run: npm run format:check
127+
- name: Lint frontend
128+
working-directory: frontend
129+
run: npm run lint
130+
- name: Run frontend unit tests
131+
working-directory: frontend
132+
run: npm run test:unit -- --run
133+
- name: Install Playwright browser
134+
working-directory: frontend
135+
run: npx playwright install --with-deps chromium
136+
- name: Run frontend E2E tests
137+
working-directory: frontend
138+
run: npm run test:e2e
139+
- name: Build frontend static assets
140+
working-directory: frontend
141+
run: npm run build

frontend/.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,8 @@ node_modules
77
.wrangler
88
/.svelte-kit
99
/build
10+
/playwright-report
11+
/test-results
1012

1113
# OS
1214
.DS_Store

frontend/.oxlintrc.json

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
{
2+
"$schema": "./node_modules/oxlint/configuration_schema.json",
3+
"plugins": ["unicorn", "typescript", "oxc"],
4+
"categories": {
5+
"correctness": "error",
6+
"suspicious": "warn",
7+
"pedantic": "off",
8+
"style": "off"
9+
},
10+
"rules": {
11+
"unicorn/require-module-specifiers": "off"
12+
}
13+
}

frontend/.prettierignore

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
.svelte-kit
2+
node_modules
3+
playwright-report
4+
test-results
5+
../src/MoBI_View/web/static

frontend/.prettierrc

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
{
2+
"plugins": ["prettier-plugin-svelte"],
3+
"overrides": [
4+
{
5+
"files": "*.svelte",
6+
"options": {
7+
"parser": "svelte"
8+
}
9+
}
10+
]
11+
}

frontend/.vscode/extensions.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
{
2-
"recommendations": ["svelte.svelte-vscode"]
2+
"recommendations": ["svelte.svelte-vscode"]
33
}

frontend/README.md

Lines changed: 22 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -1,42 +1,38 @@
1-
# sv
1+
# MoBI-View Frontend
22

3-
Everything you need to build a Svelte project, powered by [`sv`](https://github.com/sveltejs/cli).
3+
SvelteKit frontend for the MoBI-View browser UI.
44

5-
## Creating a project
5+
The app is built as static HTML, JavaScript, and CSS with `@sveltejs/adapter-static`.
6+
Production assets are emitted directly to `../src/MoBI_View/web/static`, which is
7+
the directory served by the Python WebSocket/HTTP server.
68

7-
If you're seeing this, you've probably already done this step. Congrats!
9+
## Commands
810

911
```sh
10-
# create a new project
11-
npx sv create my-app
12+
npm run dev
13+
npm run check
14+
npm run format:check
15+
npm run test:unit -- --run
16+
npm run test:e2e
17+
npm run build
1218
```
1319

14-
To recreate this project with the same configuration:
20+
## Backend Contract
1521

16-
```sh
17-
# recreate this project
18-
npx sv@0.15.2 create --template minimal --types ts --install npm frontend
19-
```
22+
During local development, the frontend expects the Python server to be available at
23+
`ws://localhost:8765`.
2024

21-
## Developing
25+
The current backend message contract is:
2226

23-
Once you've created a project and installed dependencies with `npm install` (or `pnpm install` or `yarn`), start a development server:
27+
- Send discovery command: `{"command":"discover"}`
28+
- Receive discovery response: `{"type":"discover_result","streams":[...]}`
29+
- Receive broadcast frame: `{"streams":[{"stream_name":"...","data":[...],"channel_labels":[...]}]}`
2430

25-
```sh
26-
npm run dev
27-
28-
# or start the server and open the app in a new browser tab
29-
npm run dev -- --open
30-
```
31-
32-
## Building
33-
34-
To create a production version of your app:
31+
## Static Build
3532

3633
```sh
3734
npm run build
3835
```
3936

40-
You can preview the production build with `npm run preview`.
41-
42-
> To deploy your app, you may need to install an [adapter](https://svelte.dev/docs/kit/adapters) for your target environment.
37+
After building, run `uv run mobi-view` from the repository root and open
38+
`http://localhost:8765` to view the static frontend served by Python.

0 commit comments

Comments
 (0)