From 041c3fab4b32480ef0de9f11e4e88a3fa40e80f5 Mon Sep 17 00:00:00 2001 From: Hermes Date: Tue, 14 Jul 2026 10:13:51 -0300 Subject: [PATCH] feat: implement Havenllo single-board kanban (Go+SQLite backend, Preact/Vite frontend) - Single fixed 'Haven' board: lists (To do/In progress/Done) + cards, no multi-board - Go 1.24 backend, CGO-free modernc.org/sqlite, embedded SPA, REST /api - Preact + Vite + TS frontend, native HTML5 drag-and-drop, optimistic UI, dark Haven theme - PVC (nfs-client) for SQLite, root container on NFS, simple nginx ingress havenllo.haven - Dockerfile multi-arch build, Gitea CI via pipeline-actions@main --- .dockerignore | 15 + .gitattributes | 5 + .gitea/workflows/main.yaml | 59 + .gitignore | 13 + Dockerfile | 24 + PLAN.md | 540 +++++++ README.md | 52 + cmd/havenllo/main.go | 57 + deploy/havenllo.yaml | 120 ++ go.mod | 18 + go.sum | 49 + internal/api/handlers.go | 224 +++ internal/api/handlers_test.go | 86 ++ internal/api/http.go | 95 ++ internal/api/types.go | 72 + internal/app/service.go | 351 +++++ internal/app/service_test.go | 97 ++ internal/database/database.go | 37 + internal/database/database_test.go | 69 + internal/database/migrations.go | 87 ++ internal/domain/models.go | 42 + internal/store/sqlite.go | 146 ++ internal/store/sqlite_test.go | 29 + web/dist/.gitkeep | 1 + web/embed.go | 20 + web/index.html | 15 + web/package-lock.json | 2120 ++++++++++++++++++++++++++ web/package.json | 22 + web/src/App.tsx | 169 ++ web/src/api.ts | 63 + web/src/board-state.ts | 108 ++ web/src/components/BoardCanvas.tsx | 95 ++ web/src/components/CardEditor.tsx | 51 + web/src/components/CardItem.tsx | 113 ++ web/src/components/ConfirmDialog.tsx | 50 + web/src/components/Header.tsx | 30 + web/src/components/ListColumn.tsx | 196 +++ web/src/components/Toast.tsx | 25 + web/src/drag.ts | 50 + web/src/main.tsx | 12 + web/src/styles.css | 425 ++++++ web/src/types.ts | 46 + web/tsconfig.json | 22 + web/vite.config.ts | 11 + 44 files changed, 5931 insertions(+) create mode 100644 .dockerignore create mode 100644 .gitattributes create mode 100644 .gitea/workflows/main.yaml create mode 100644 .gitignore create mode 100644 Dockerfile create mode 100644 PLAN.md create mode 100644 README.md create mode 100644 cmd/havenllo/main.go create mode 100644 deploy/havenllo.yaml create mode 100644 go.mod create mode 100644 go.sum create mode 100644 internal/api/handlers.go create mode 100644 internal/api/handlers_test.go create mode 100644 internal/api/http.go create mode 100644 internal/api/types.go create mode 100644 internal/app/service.go create mode 100644 internal/app/service_test.go create mode 100644 internal/database/database.go create mode 100644 internal/database/database_test.go create mode 100644 internal/database/migrations.go create mode 100644 internal/domain/models.go create mode 100644 internal/store/sqlite.go create mode 100644 internal/store/sqlite_test.go create mode 100644 web/dist/.gitkeep create mode 100644 web/embed.go create mode 100644 web/index.html create mode 100644 web/package-lock.json create mode 100644 web/package.json create mode 100644 web/src/App.tsx create mode 100644 web/src/api.ts create mode 100644 web/src/board-state.ts create mode 100644 web/src/components/BoardCanvas.tsx create mode 100644 web/src/components/CardEditor.tsx create mode 100644 web/src/components/CardItem.tsx create mode 100644 web/src/components/ConfirmDialog.tsx create mode 100644 web/src/components/Header.tsx create mode 100644 web/src/components/ListColumn.tsx create mode 100644 web/src/components/Toast.tsx create mode 100644 web/src/drag.ts create mode 100644 web/src/main.tsx create mode 100644 web/src/styles.css create mode 100644 web/src/types.ts create mode 100644 web/tsconfig.json create mode 100644 web/vite.config.ts diff --git a/.dockerignore b/.dockerignore new file mode 100644 index 0000000..b8a2199 --- /dev/null +++ b/.dockerignore @@ -0,0 +1,15 @@ +.git +.gitea +.codex-* +.code-prompt.md +PLAN.md +README.md +havenllo +*.exe +*.db +*.db-shm +*.db-wal +coverage.out +web/node_modules +web/dist + diff --git a/.gitattributes b/.gitattributes new file mode 100644 index 0000000..b617354 --- /dev/null +++ b/.gitattributes @@ -0,0 +1,5 @@ +Dockerfile text eol=lf +*.yaml text eol=lf +*.yml text eol=lf +*.sh text eol=lf + diff --git a/.gitea/workflows/main.yaml b/.gitea/workflows/main.yaml new file mode 100644 index 0000000..289a789 --- /dev/null +++ b/.gitea/workflows/main.yaml @@ -0,0 +1,59 @@ +name: Build and deploy Havenllo + +on: + push: + branches: [main] + workflow_dispatch: + +jobs: + verify: + name: Verify Go and frontend + runs-on: runner-slim-amd64 + steps: + - name: Check out source + uses: actions/checkout@v4 + - name: Test Go + run: go test ./... + - name: Install frontend dependencies + working-directory: web + run: npm ci + - name: Build frontend + working-directory: web + run: npm run build + - name: Validate Kubernetes manifest + run: | + if command -v kubectl >/dev/null 2>&1; then + kubectl apply --dry-run=client -f deploy/havenllo.yaml + fi + build: + name: Build and push image + needs: verify + runs-on: runner-slim-amd64 + steps: + - name: Check out source + uses: actions/checkout@v4 + - name: Build and push multi-architecture image + uses: https://git.ivanch.me/ivanch/pipeline-actions/build-and-push@main + with: + image: git.ivanch.me/ivanch/havenllo + image_tag: latest + registry_password: ${{ secrets.REGISTRY_PASSWORD }} + ssh_key: ${{ secrets.SSH_KEY_DOCKERBUILD }} + deploy: + name: Apply and restart Havenllo + needs: build + runs-on: runner-slim-amd64 + steps: + - name: Check out source + uses: actions/checkout@v4 + - name: Apply Kubernetes manifest + uses: https://git.ivanch.me/ivanch/pipeline-actions/kubectl-apply@main + with: + manifest: deploy/havenllo.yaml + kube_config: ${{ secrets.KUBE_CONFIG }} + - name: Restart deployment + uses: https://git.ivanch.me/ivanch/pipeline-actions/deploy-restart@main + with: + deployment_name: havenllo + namespace: default + kube_config: ${{ secrets.KUBE_CONFIG }} diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..4d909e2 --- /dev/null +++ b/.gitignore @@ -0,0 +1,13 @@ +/havenllo +/havenllo.exe +*.exe +*-test.exe +*.db +*.db-shm +*.db-wal +coverage.out +web/node_modules/ +web/dist/* +!web/dist/.gitkeep +.codex-* +.code-prompt.md diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..9725899 --- /dev/null +++ b/Dockerfile @@ -0,0 +1,24 @@ +# syntax=docker/dockerfile:1 +FROM --platform=$BUILDPLATFORM node:22-alpine AS frontend +WORKDIR /src/web +COPY web/package.json web/package-lock.json ./ +RUN npm ci +COPY web/ ./ +RUN npm run build + +FROM --platform=$BUILDPLATFORM golang:1.24-alpine AS build +ARG TARGETOS +ARG TARGETARCH +WORKDIR /src +COPY go.mod go.sum ./ +RUN go mod download +COPY . . +COPY --from=frontend /src/web/dist ./web/dist +RUN CGO_ENABLED=0 GOOS=$TARGETOS GOARCH=$TARGETARCH go build -trimpath -ldflags="-s -w" -o /out/havenllo ./cmd/havenllo + +FROM gcr.io/distroless/static-debian12 +USER 0 +COPY --from=build /out/havenllo /havenllo +EXPOSE 8080 +ENTRYPOINT ["/havenllo"] + diff --git a/PLAN.md b/PLAN.md new file mode 100644 index 0000000..89a25f7 --- /dev/null +++ b/PLAN.md @@ -0,0 +1,540 @@ +# Havenllo implementation plan + +## 1. Overview and goals + +Havenllo will be a single-user kanban application for the Haven homelab. It will +provide multiple boards, ordered lists, and ordered task cards without accounts, +authentication, or external services. One Go HTTP server will expose a +same-origin JSON API and serve the compiled Preact SPA from one container. Its +only durable state will be a SQLite database stored on a 1Gi PVC. + +The implementation will favour a polished day-to-day board: fast board loading, +native card drag-and-drop, useful empty/loading states, keyboard-friendly inline +editing, and a responsive horizontally scrolling kanban layout. It will not add +an ORM, WebSockets, a separate frontend server, or a separate database service. + +## 2. Proposed repository tree + +```text +. +├── .dockerignore # Excludes Git data, node_modules, local DBs, and build artefacts from Docker context. +├── .gitattributes # Enforces LF for Docker/YAML/workflow files edited from Windows. +├── .gitea/ +│ └── workflows/ +│ └── main.yaml # Gitea Actions: verify, multi-arch build/push, apply, and restart. +├── .gitignore # Ignores database, binaries, coverage, node_modules, and web/dist output. +├── Dockerfile # Three-stage Node + Go + distroless build for the one production image. +├── README.md # Local development, test, build, and Kubernetes deployment instructions. +├── go.mod # Module definition; direct dependency only on modernc.org/sqlite. +├── go.sum # Checksums generated by go mod tidy and committed. +├── cmd/ +│ └── havenllo/ +│ └── main.go # Configuration, database setup, and HTTP server lifecycle. +├── internal/ +│ ├── api/ +│ │ ├── handlers.go # Go 1.22 ServeMux routes and endpoint handlers. +│ │ ├── http.go # JSON, errors, ID parsing, and validation helpers. +│ │ ├── types.go # API DTOs and domain-to-response conversion. +│ │ └── handlers_test.go # HTTP contract tests against temporary SQLite. +│ ├── app/ +│ │ ├── service.go # Transactional validation, ordering, moves, and board seeding. +│ │ └── service_test.go # Ordering, move, delete, and default-board tests. +│ ├── database/ +│ │ ├── database.go # SQLite options, migrations, and initial seed data. +│ │ ├── migrations.go # Versioned schema migrations. +│ │ └── database_test.go # Migration/idempotency and foreign-key tests. +│ ├── domain/ +│ │ └── models.go # Board, List, Card, snapshot, and domain errors. +│ └── store/ +│ ├── sqlite.go # Parameterized SQL repository methods; no ORM. +│ └── sqlite_test.go # Persistence and ordering-query tests. +├── web/ +│ ├── embed.go # Embeds dist/ into the Go binary and exposes an fs.FS. +│ ├── index.html # Vite HTML shell, title, theme-color, and root element. +│ ├── package.json # Preact runtime; Vite/TS/Preact preset development tools. +│ ├── package-lock.json # Generated locked npm dependency graph, committed. +│ ├── tsconfig.json # Strict TypeScript configuration. +│ ├── vite.config.ts # Preact plugin and deterministic web/dist output. +│ ├── dist/ +│ │ └── .gitkeep # Placeholder for pre-build Go embedding; replaced in image builds. +│ └── src/ +│ ├── main.tsx # Preact bootstrap and global error boundary. +│ ├── App.tsx # Board selection, fetch, optimistic state hook, and shell. +│ ├── api.ts # Typed fetch client, endpoint methods, and API error parsing. +│ ├── types.ts # TypeScript representations of resources and errors. +│ ├── board-state.ts # Reducer/selectors, pending mutations, rollback, and toast state. +│ ├── drag.ts # Native drag payload, drop-index, and position helpers. +│ ├── styles.css # Design tokens and responsive component styling. +│ └── components/ +│ ├── Header.tsx # Wordmark, board picker, create board, and status indicator. +│ ├── BoardCanvas.tsx # List rail, empty state, and add-list affordance. +│ ├── ListColumn.tsx # List editing, count, drop zones, and inline card creation. +│ ├── CardItem.tsx # Draggable card, inline title edit, done control, actions. +│ ├── CardEditor.tsx # Description editor and destructive card action. +│ ├── ConfirmDialog.tsx # Accessible confirmation dialog for deletes. +│ └── Toast.tsx # Non-blocking mutation feedback. +└── deploy/ + └── havenllo.yaml # PVC, Deployment, Service, and Ingress multi-document manifest. +``` + +No application source files will be created during this planning step. The +`web/dist` directory is ignored except for its tracked placeholder; the Docker +build replaces it with Vite output before Go evaluates the embed directive. + +## 3. Data model and SQLite schema + +IDs are SQLite `INTEGER PRIMARY KEY` values. `position` is a floating-point +sort key; records are ordered by `(position, id)`. A new sibling receives the +current maximum plus `1024`; a drag chooses a value between its new neighbours. +The service renumbers a sibling group to `1024` increments inside the same +transaction whenever positions become too close or invalid. + +Timestamps are UTC RFC 3339 strings written by Go. SQLite foreign keys are +enabled for every connection, and migrations run transactionally before the +server accepts traffic. + +```sql +CREATE TABLE IF NOT EXISTS schema_migrations ( + version INTEGER PRIMARY KEY, + applied_at TEXT NOT NULL +); + +CREATE TABLE IF NOT EXISTS boards ( + id INTEGER PRIMARY KEY, + name TEXT NOT NULL CHECK (length(trim(name)) BETWEEN 1 AND 120), + created_at TEXT NOT NULL, + position REAL NOT NULL +); + +CREATE TABLE IF NOT EXISTS lists ( + id INTEGER PRIMARY KEY, + board_id INTEGER NOT NULL, + name TEXT NOT NULL CHECK (length(trim(name)) BETWEEN 1 AND 120), + position REAL NOT NULL, + FOREIGN KEY (board_id) REFERENCES boards(id) ON DELETE CASCADE +); + +CREATE TABLE IF NOT EXISTS cards ( + id INTEGER PRIMARY KEY, + list_id INTEGER NOT NULL, + title TEXT NOT NULL CHECK (length(trim(title)) BETWEEN 1 AND 240), + description TEXT NOT NULL DEFAULT '', + position REAL NOT NULL, + done INTEGER NOT NULL DEFAULT 0 CHECK (done IN (0, 1)), + created_at TEXT NOT NULL, + updated_at TEXT NOT NULL, + FOREIGN KEY (list_id) REFERENCES lists(id) ON DELETE CASCADE +); + +CREATE INDEX IF NOT EXISTS idx_boards_position ON boards(position, id); +CREATE INDEX IF NOT EXISTS idx_lists_board_position ON lists(board_id, position, id); +CREATE INDEX IF NOT EXISTS idx_cards_list_position ON cards(list_id, position, id); +``` + +Migration 1 atomically seeds a `Haven` board with `To do`, `In progress`, and +`Done` lists. Creating later boards seeds the same three lists. Deleting a board +cascades its lists and cards, but the API rejects deletion of the final board +with `409 Conflict` so the app remains usable. + +The database comes from `HAVENLLO_DATABASE_PATH` (default `/data/havenllo.db`). +Connection setup uses WAL, a 5-second busy timeout, `foreign_keys=ON`, and one +open connection. This single-replica deployment intentionally keeps SQLite a +safe, simple single-writer database on the NFS-backed PVC. + +## 4. REST API contract + +All endpoints are same-origin under `/api`, accept and return JSON, and use +integer resource IDs. Mutation requests require `Content-Type: application/json`. +Unknown fields are rejected; names and titles are trimmed; descriptions allow up +to 10,000 characters. PATCH DTOs use pointer fields so `done: false` is distinct +from an omitted field. + +Every error has this shape: + +```json +{ + "error": { + "code": "validation_error", + "message": "title is required" + } +} +``` + +Success statuses are `200`, `201`, and `204`. The API returns `400` for malformed +JSON/IDs, `404` for absent records, `409` for final-board deletion, `415` for an +incorrect media type, and `422` for business validation. Unexpected database +errors are logged server-side and produce a non-sensitive `500` response. + +### Resource shapes + +A board is `{ "id": 1, "name": "Haven", "position": 1024, +"created_at": "2026-07-14T12:00:00Z" }`. + +A list is `{ "id": 10, "board_id": 1, "name": "To do", "position": 1024, +"card_count": 2 }`. `card_count` is included only in list collection responses. + +A card is: + +```json +{ + "id": 101, + "list_id": 10, + "title": "Back up the router config", + "description": "Export it after the firmware update.", + "position": 1024, + "done": false, + "created_at": "2026-07-14T12:00:00Z", + "updated_at": "2026-07-14T12:00:00Z" +} +``` + +The primary board-load response is a snapshot: + +```json +{ + "board": { "id": 1, "name": "Haven", "position": 1024, "created_at": "2026-07-14T12:00:00Z" }, + "lists": [ + { "id": 10, "board_id": 1, "name": "To do", "position": 1024, "cards": [] } + ] +} +``` + +### Health + +| Method | Path | Behaviour and response | +| --- | --- | --- | +| `GET` | `/api/health` | Pings SQLite and returns `200 {"status":"ok"}`; used by Kubernetes probes. | + +### Boards + +| Method | Path | Request body | Success response | +| --- | --- | --- | --- | +| `GET` | `/api/boards` | — | `200 {"boards":[Board...]}`, ordered by position. | +| `POST` | `/api/boards` | `{"name":"Homelab"}` | `201` BoardSnapshot with three starter lists. | +| `GET` | `/api/boards/{boardID}` | — | `200` BoardSnapshot with lists and cards in render order. | +| `PATCH` | `/api/boards/{boardID}` | `{"name":"…","position":2048}`; either field optional | `200 {"board":Board}`. | +| `DELETE` | `/api/boards/{boardID}` | — | `204`, unless it is the final board (`409`). | + +### Lists + +| Method | Path | Request body | Success response | +| --- | --- | --- | --- | +| `GET` | `/api/boards/{boardID}/lists` | — | `200 {"lists":[List...]}`, with card counts but not card bodies. | +| `POST` | `/api/boards/{boardID}/lists` | `{"name":"Waiting","position":4096}`; position optional | `201 {"list":List}`. | +| `GET` | `/api/lists/{listID}` | — | `200 {"list":List,"cards":[Card...]}`. | +| `PATCH` | `/api/lists/{listID}` | `{"name":"…","board_id":2,"position":1024}`; all optional | `200 {"list":List}`. | +| `DELETE` | `/api/lists/{listID}` | — | `204`; its cards are cascade-deleted after UI confirmation. | + +### Cards + +| Method | Path | Request body | Success response | +| --- | --- | --- | --- | +| `GET` | `/api/lists/{listID}/cards` | — | `200 {"cards":[Card...]}`, ordered by position. | +| `POST` | `/api/lists/{listID}/cards` | `{"title":"Replace UPS battery","description":"…","position":4096}`; description/position optional | `201 {"card":Card}`. | +| `GET` | `/api/cards/{cardID}` | — | `200 {"card":Card}`. | +| `PATCH` | `/api/cards/{cardID}` | `{"title":"…","description":"…","done":true,"list_id":11,"position":1536}`; all optional | `200 {"card":Card}`. | +| `DELETE` | `/api/cards/{cardID}` | — | `204`. | + +The browser calculates target position from adjacent cards at the drop location. +The service independently validates it, normalizes sibling positions when +needed, and returns the authoritative resource. A card list move and position +update happen in one transaction. + +## 5. Frontend architecture and interaction design + +The frontend uses Preact, TypeScript, and Vite with only Preact and the Preact +Vite preset as dependencies. It uses no component, state, icon, or drag library. +`web/embed.go` exposes the completed Vite output as an embedded `fs.FS`, so the +SPA and API are always same-origin and need no CORS configuration. + +`App` loads boards, restores the selected board from `localStorage` when it is +still valid (otherwise picks the first), and fetches one BoardSnapshot. Its +`useReducer`-based board state owns the snapshot, selection, pending mutation +IDs, rollback snapshots, and toast/error state. Every create/edit/move action +first performs an immutable optimistic update, calls `api.ts`, reconciles with +the canonical response, and restores state with an error toast if it fails. +Controls disable only for their pending resource, rather than freezing the board. + +`Header` contains the Havenllo wordmark, board picker, create-board action, and +small connection/status feedback. `BoardCanvas` maps lists to columns and ends +with an inline Add list affordance. `ListColumn` provides list-name inline edit, +card count, card drop zones, and inline add-card input. `CardItem` provides +click-to-edit title, a done control, and a small actions control; `CardEditor` +edits descriptions and hosts destructive actions. `ConfirmDialog` is required +before deleting a card, list, or board, and `Toast` gives non-blocking feedback. + +Cards use native HTML5 drag-and-drop. The drag payload holds card and source-list +IDs. Drop zones before every card plus one at the end provide an unambiguous +target index. Drag-over uses an accent outline and local preview; drop calculates +the new fractional position, updates optimistically, and sends one PATCH. A +failed call restores the pre-drag snapshot. The usual add/edit/done controls stay +fully usable on phones, while the board uses a horizontally scrolling rail, +280px minimum columns, and 44px touch targets; this remains useful on mobile +browsers with limited native DnD support. + +Plain CSS in `styles.css` will use variables and deliberately named component +classes. The visual system is deep slate/navy with restrained teal/indigo accents, +12–16px rounded surfaces, subtle borders, layered soft shadows, system font +stacks, clear focus rings, and reduced-motion support. Done cards, skeletons, +empty states, inline save/cancel affordances, and error states will feel designed +rather than like bare CRUD. + +## 6. Backend architecture + +`cmd/havenllo/main.go` reads `HAVENLLO_LISTEN_ADDR` (default `:8080`) and +`HAVENLLO_DATABASE_PATH` (default `/data/havenllo.db`), configures standard +library logging, opens/migrates SQLite, constructs the service and HTTP handler, +and gracefully shuts down on SIGINT/SIGTERM. + +`database` owns parent-directory creation, SQLite connection options, and ordered +migrations. `store` contains parameterized SQL and record scanning, with no ORM. +`app.Service` owns cross-record validation, default list creation, ordering and +renumbering, and final-board rules. This keeps every state-changing operation +transactional and independently testable. + +`api` uses Go 1.22 `http.ServeMux` method/path patterns and `PathValue`. It +decodes bounded JSON bodies with `DisallowUnknownFields`, maps typed domain errors +to the documented JSON shape, and never exposes SQL errors. It registers `/api/` +before static files: hashed Vite assets are served directly, and embedded +`index.html` is a fallback only for non-API SPA routes. An unknown API route +always produces JSON 404, never the SPA HTML. CORS headers are intentionally not +set because all browser traffic is same-origin. + +Tests cover migration/seed behaviour, cascade effects, position normalization, +invalid moves, final-board protection, JSON validation, and essential status/ +response shapes. Temporary SQLite files and an injectable static filesystem keep +tests independent of the PVC and production frontend bundle. + +## 7. Dockerfile strategy + +The Dockerfile has three stages: + +1. A `node:22-alpine` frontend stage copies package manifests first, runs + `npm ci`, then builds `web/` with `npm run build` into `web/dist`. +2. A `golang:1.24-alpine` stage copies `go.mod`/`go.sum`, runs `go mod download`, + copies source and the frontend stage's `web/dist`, then runs + `CGO_ENABLED=0 go build`. Buildx arguments `TARGETOS` and `TARGETARCH` are + passed to the build so the pure-Go `modernc.org/sqlite` binary targets each + requested architecture without CGO. +3. `gcr.io/distroless/static-debian12:nonroot` receives only the statically + linked `havenllo` binary, exposes 8080, and runs as its non-root user. + +The Dockerfile declares `BUILDPLATFORM`, `TARGETOS`, and `TARGETARCH` for clean +`linux/amd64,linux/arm64` remote Buildx builds. `.dockerignore` excludes local +`web/node_modules`, existing `web/dist`, Git metadata, test output, and `*.db`. +The stage-to-stage copy supplies the actual bundle, so ignoring any local dist +cannot break embedding. The final image contains no Node runtime, Go toolchain, +shell, npm cache, source tree, or database. + +## 8. Exact Kubernetes manifest + +`deploy/havenllo.yaml` will contain the following four documents. Each resource +explicitly targets the existing `default` namespace. One replica and a `Recreate` +strategy prevent concurrent SQLite writers or a conflicting RWO attachment during +an update. `fsGroup` matches the non-root distroless user so the provisioned NFS +volume remains writable. + +```yaml +apiVersion: v1 +kind: PersistentVolumeClaim +metadata: + name: havenllo-data + namespace: default + annotations: + nfs.io/storage-path: havenllo-data +spec: + accessModes: + - ReadWriteOnce + storageClassName: nfs-client + resources: + requests: + storage: 1Gi +--- +apiVersion: apps/v1 +kind: Deployment +metadata: + name: havenllo + namespace: default + labels: + app.kubernetes.io/name: havenllo +spec: + replicas: 1 + strategy: + type: Recreate + selector: + matchLabels: + app.kubernetes.io/name: havenllo + template: + metadata: + labels: + app.kubernetes.io/name: havenllo + spec: + securityContext: + runAsNonRoot: true + runAsUser: 65532 + runAsGroup: 65532 + fsGroup: 65532 + fsGroupChangePolicy: OnRootMismatch + containers: + - name: havenllo + image: git.ivanch.me/ivanch/havenllo:latest + imagePullPolicy: Always + ports: + - name: http + containerPort: 8080 + protocol: TCP + env: + - name: HAVENLLO_DATABASE_PATH + value: /data/havenllo.db + - name: HAVENLLO_LISTEN_ADDR + value: :8080 + volumeMounts: + - name: data + mountPath: /data + resources: + requests: + cpu: 50m + memory: 64Mi + limits: + cpu: 500m + memory: 256Mi + readinessProbe: + httpGet: + path: /api/health + port: http + initialDelaySeconds: 2 + periodSeconds: 5 + timeoutSeconds: 2 + failureThreshold: 3 + livenessProbe: + httpGet: + path: /api/health + port: http + initialDelaySeconds: 10 + periodSeconds: 10 + timeoutSeconds: 2 + failureThreshold: 3 + securityContext: + allowPrivilegeEscalation: false + readOnlyRootFilesystem: true + capabilities: + drop: + - ALL + volumes: + - name: data + persistentVolumeClaim: + claimName: havenllo-data +--- +apiVersion: v1 +kind: Service +metadata: + name: havenllo + namespace: default + labels: + app.kubernetes.io/name: havenllo +spec: + type: ClusterIP + selector: + app.kubernetes.io/name: havenllo + ports: + - name: http + port: 8080 + targetPort: http + protocol: TCP +--- +apiVersion: networking.k8s.io/v1 +kind: Ingress +metadata: + name: havenllo + namespace: default + annotations: + cert-manager.io/cluster-issuer: internal-ca + nginx.ingress.kubernetes.io/force-ssl-redirect: "true" +spec: + ingressClassName: nginx + tls: + - hosts: + - havenllo.haven + secretName: havenllo-tls + rules: + - host: havenllo.haven + http: + paths: + - path: / + pathType: Prefix + backend: + service: + name: havenllo + port: + number: 8080 +``` + +There is no ConfigMap or Secret: the only environment values are non-sensitive, +and all durable state is the mounted SQLite file. The image needs no pull secret +when the cluster is already configured for `git.ivanch.me`; if that is not true, +the implementation will reference an existing pull-secret by name rather than +commit registry credentials. + +## 9. Build and deploy flow + +`.gitea/workflows/main.yaml` will run on pushes to `main` and manual dispatch. +It will keep YAML files LF-only via `.gitattributes` and use descriptive `name:` +values for every Gitea job. + +1. A `verify` job on `runner-slim-amd64` checks out the repository, runs Go + tests, runs `npm ci` and the TypeScript/Vite production build, and performs a + client-side `kubectl apply --dry-run=client` validation of the manifest when + kubectl is available. +2. A `build` job uses + `https://git.ivanch.me/ivanch/pipeline-actions/build-and-push@main` with + `image: git.ivanch.me/ivanch/havenllo`, `image_tag: latest`, registry-password + and remote-builder SSH-key secrets. It retains the action's default + `linux/amd64,linux/arm64` platforms, builds on `docker-build.haven`, and pushes + `git.ivanch.me/ivanch/havenllo:latest`. +3. A dependent `deploy` job uses + `https://git.ivanch.me/ivanch/pipeline-actions/kubectl-apply@main` with + `manifest: deploy/havenllo.yaml` and `${{ secrets.KUBE_CONFIG }}`. It then uses + `https://git.ivanch.me/ivanch/pipeline-actions/deploy-restart@main` with + `deployment_name: havenllo`, `namespace: default`, and the same kubeconfig. + Applying before restart reconciles PVC/Service/Ingress changes before the + `latest` image is restarted. +4. Deployment verification is `kubectl -n default rollout status deployment/havenllo`, + followed by `kubectl -n default get certificate,ingress havenllo` and opening + `https://havenllo.haven`. cert-manager creates `havenllo-tls` through the + existing `internal-ca` ClusterIssuer. + +The Gitea repository requires `REGISTRY_PASSWORD`, `SSH_KEY_DOCKERBUILD`, and +`KUBE_CONFIG` secrets. No secret values are committed. + +## 10. Ordered implementation checklist + +1. Add `.gitignore`, `.dockerignore`, `.gitattributes`, and README. Confirm no + local database or generated frontend build is tracked and workflow YAML will + remain LF-only on Windows. +2. Add `go.mod` with only `modernc.org/sqlite`, run `go mod tidy`, and define the + domain models and errors. +3. Implement SQLite connection options, migration tracking, the schema above, + and one-time `Haven`/starter-list seeding. Add migration and foreign-key tests. +4. Implement parameterized SQLite store methods and the transactional service: + validation, float ordering/normalization, list/card moves, board starter lists, + cascade-aware deletion, and final-board protection. Add store/service tests. +5. Implement the standard-library API router, JSON/error helpers, health check, + all documented handlers, and graceful process entry point. Add HTTP contract + tests for normal, invalid, missing, and conflict cases. +6. Scaffold Vite/Preact, the typed client, reducer-based optimistic board state, + board selector persistence, and loading/error states. +7. Implement the visual components and CSS system: header, list rail, inline + creation/editing, count badges, done state, descriptions, confirmations, + toasts, empty states, and responsive interaction styling. +8. Add native card drag/drop previews and drop zones for same-list and cross-list + moves. Manually test error rollback, keyboard controls, and mobile-sized views. +9. Add `web/embed.go` and Go static-file/SPA fallback routing. Verify a production + frontend build is embedded and API misses return JSON rather than HTML. +10. Add the multi-stage Dockerfile; build locally for the host platform and verify + the container creates/uses `/data/havenllo.db`, serves `/`, and passes + `/api/health` with a read-only root filesystem. +11. Add the exact deployment manifest and Gitea workflow using the documented + pipeline-actions URLs. Validate YAML, a client-side apply, and LF-only files. +12. Push `main`; allow the multi-architecture image to build and deploy; verify + rollout, certificate, and ingress; then smoke-test create, edit, complete, + drag, refresh persistence, and deletion confirmation at `havenllo.haven`. diff --git a/README.md b/README.md new file mode 100644 index 0000000..e0e0ccd --- /dev/null +++ b/README.md @@ -0,0 +1,52 @@ +# Havenllo + +Havenllo is a small, single-board kanban app for the Haven homelab. It serves a +Preact SPA and a same-origin Go/SQLite API from one binary. On first start it +creates the fixed **To do**, **In progress**, and **Done** columns. + +## Local development + +Use a writable database path outside the default container location: + +```powershell +$env:HAVENLLO_DATABASE_PATH = "$PWD\havenllo.db" +go run ./cmd/havenllo +``` + +In another terminal, run the frontend development server: + +```powershell +Set-Location web +npm ci +npm run dev +``` + +For the embedded production bundle, run `npm run build` in `web/` before +`go build ./...`. + +## Verification + +```powershell +go test ./... +Set-Location web; npm ci; npm run build +Set-Location ..; go build ./... +``` + +## Container and deployment + +Build and push the multi-architecture image on `docker-build.haven`: + +```sh +docker buildx build --platform linux/amd64,linux/arm64 -t git.ivanch.me/ivanch/havenllo:latest --push . +``` + +Or push `main` / dispatch the Gitea workflow. Apply the manifest and restart +the deployment: + +```sh +kubectl apply -f deploy/havenllo.yaml -n default +kubectl -n default rollout restart deployment/havenllo +``` + +The app is available internally at `http://havenllo.haven`. + diff --git a/cmd/havenllo/main.go b/cmd/havenllo/main.go new file mode 100644 index 0000000..5e41eb6 --- /dev/null +++ b/cmd/havenllo/main.go @@ -0,0 +1,57 @@ +package main + +import ( + "context" + "errors" + "log" + "net/http" + "os" + "os/signal" + "syscall" + "time" + + "havenllo/internal/api" + "havenllo/internal/app" + "havenllo/internal/database" + "havenllo/web" +) + +func main() { + listenAddr := env("HAVENLLO_LISTEN_ADDR", ":8080") + databasePath := env("HAVENLLO_DATABASE_PATH", "/data/havenllo.db") + + ctx := context.Background() + db, err := database.Open(ctx, databasePath) + if err != nil { + log.Fatalf("database setup failed: %v", err) + } + defer db.Close() + + server := &http.Server{ + Addr: listenAddr, + Handler: api.NewHandler(app.New(db), web.Files), + ReadHeaderTimeout: 10 * time.Second, + } + go func() { + log.Printf("Havenllo listening on %s", listenAddr) + if err := server.ListenAndServe(); err != nil && !errors.Is(err, http.ErrServerClosed) { + log.Fatalf("server failed: %v", err) + } + }() + + stop := make(chan os.Signal, 1) + signal.Notify(stop, os.Interrupt, syscall.SIGTERM) + <-stop + shutdownCtx, cancel := context.WithTimeout(context.Background(), 10*time.Second) + defer cancel() + if err := server.Shutdown(shutdownCtx); err != nil { + log.Printf("graceful shutdown failed: %v", err) + } +} + +func env(key, fallback string) string { + if value := os.Getenv(key); value != "" { + return value + } + return fallback +} diff --git a/deploy/havenllo.yaml b/deploy/havenllo.yaml new file mode 100644 index 0000000..8977822 --- /dev/null +++ b/deploy/havenllo.yaml @@ -0,0 +1,120 @@ +apiVersion: v1 +kind: PersistentVolumeClaim +metadata: + name: havenllo-data + namespace: default + annotations: + nfs.io/storage-path: havenllo-data +spec: + accessModes: + - ReadWriteOnce + storageClassName: nfs-client + resources: + requests: + storage: 1Gi +--- +apiVersion: apps/v1 +kind: Deployment +metadata: + name: havenllo + namespace: default + labels: + app.kubernetes.io/name: havenllo +spec: + replicas: 1 + strategy: + type: Recreate + selector: + matchLabels: + app.kubernetes.io/name: havenllo + template: + metadata: + labels: + app.kubernetes.io/name: havenllo + spec: + containers: + - name: havenllo + image: git.ivanch.me/ivanch/havenllo:latest + imagePullPolicy: Always + ports: + - name: http + containerPort: 8080 + protocol: TCP + env: + - name: HAVENLLO_DATABASE_PATH + value: /data/havenllo.db + - name: HAVENLLO_LISTEN_ADDR + value: :8080 + volumeMounts: + - name: data + mountPath: /data + resources: + requests: + cpu: 50m + memory: 64Mi + limits: + cpu: 500m + memory: 256Mi + readinessProbe: + httpGet: + path: /api/health + port: http + initialDelaySeconds: 2 + periodSeconds: 5 + timeoutSeconds: 2 + failureThreshold: 3 + livenessProbe: + httpGet: + path: /api/health + port: http + initialDelaySeconds: 10 + periodSeconds: 10 + timeoutSeconds: 2 + failureThreshold: 3 + securityContext: + runAsUser: 0 + allowPrivilegeEscalation: false + readOnlyRootFilesystem: true + capabilities: + drop: + - ALL + volumes: + - name: data + persistentVolumeClaim: + claimName: havenllo-data +--- +apiVersion: v1 +kind: Service +metadata: + name: havenllo + namespace: default + labels: + app.kubernetes.io/name: havenllo +spec: + type: ClusterIP + selector: + app.kubernetes.io/name: havenllo + ports: + - name: http + port: 8080 + targetPort: 8080 + protocol: TCP +--- +apiVersion: networking.k8s.io/v1 +kind: Ingress +metadata: + name: havenllo + namespace: default +spec: + ingressClassName: nginx + rules: + - host: havenllo.haven + http: + paths: + - path: / + pathType: Prefix + backend: + service: + name: havenllo + port: + number: 8080 diff --git a/go.mod b/go.mod new file mode 100644 index 0000000..b21bb60 --- /dev/null +++ b/go.mod @@ -0,0 +1,18 @@ +module havenllo + +go 1.24 + +require modernc.org/sqlite v1.38.2 + +require ( + github.com/dustin/go-humanize v1.0.1 // indirect + github.com/google/uuid v1.6.0 // indirect + github.com/mattn/go-isatty v0.0.20 // indirect + github.com/ncruces/go-strftime v0.1.9 // indirect + github.com/remyoudompheng/bigfft v0.0.0-20230129092748-24d4a6f8daec // indirect + golang.org/x/exp v0.0.0-20250620022241-b7579e27df2b // indirect + golang.org/x/sys v0.34.0 // indirect + modernc.org/libc v1.66.3 // indirect + modernc.org/mathutil v1.7.1 // indirect + modernc.org/memory v1.11.0 // indirect +) diff --git a/go.sum b/go.sum new file mode 100644 index 0000000..aac187a --- /dev/null +++ b/go.sum @@ -0,0 +1,49 @@ +github.com/dustin/go-humanize v1.0.1 h1:GzkhY7T5VNhEkwH0PVJgjz+fX1rhBrR7pRT3mDkpeCY= +github.com/dustin/go-humanize v1.0.1/go.mod h1:Mu1zIs6XwVuF/gI1OepvI0qD18qycQx+mFykh5fBlto= +github.com/google/pprof v0.0.0-20250317173921-a4b03ec1a45e h1:ijClszYn+mADRFY17kjQEVQ1XRhq2/JR1M3sGqeJoxs= +github.com/google/pprof v0.0.0-20250317173921-a4b03ec1a45e/go.mod h1:boTsfXsheKC2y+lKOCMpSfarhxDeIzfZG1jqGcPl3cA= +github.com/google/uuid v1.6.0 h1:NIvaJDMOsjHA8n1jAhLSgzrAzy1Hgr+hNrb57e+94F0= +github.com/google/uuid v1.6.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= +github.com/mattn/go-isatty v0.0.20 h1:xfD0iDuEKnDkl03q4limB+vH+GxLEtL/jb4xVJSWWEY= +github.com/mattn/go-isatty v0.0.20/go.mod h1:W+V8PltTTMOvKvAeJH7IuucS94S2C6jfK/D7dTCTo3Y= +github.com/ncruces/go-strftime v0.1.9 h1:bY0MQC28UADQmHmaF5dgpLmImcShSi2kHU9XLdhx/f4= +github.com/ncruces/go-strftime v0.1.9/go.mod h1:Fwc5htZGVVkseilnfgOVb9mKy6w1naJmn9CehxcKcls= +github.com/remyoudompheng/bigfft v0.0.0-20230129092748-24d4a6f8daec h1:W09IVJc94icq4NjY3clb7Lk8O1qJ8BdBEF8z0ibU0rE= +github.com/remyoudompheng/bigfft v0.0.0-20230129092748-24d4a6f8daec/go.mod h1:qqbHyh8v60DhA7CoWK5oRCqLrMHRGoxYCSS9EjAz6Eo= +golang.org/x/exp v0.0.0-20250620022241-b7579e27df2b h1:M2rDM6z3Fhozi9O7NWsxAkg/yqS/lQJ6PmkyIV3YP+o= +golang.org/x/exp v0.0.0-20250620022241-b7579e27df2b/go.mod h1:3//PLf8L/X+8b4vuAfHzxeRUl04Adcb341+IGKfnqS8= +golang.org/x/mod v0.25.0 h1:n7a+ZbQKQA/Ysbyb0/6IbB1H/X41mKgbhfv7AfG/44w= +golang.org/x/mod v0.25.0/go.mod h1:IXM97Txy2VM4PJ3gI61r1YEk/gAj6zAHN3AdZt6S9Ww= +golang.org/x/sync v0.15.0 h1:KWH3jNZsfyT6xfAfKiz6MRNmd46ByHDYaZ7KSkCtdW8= +golang.org/x/sync v0.15.0/go.mod h1:1dzgHSNfp02xaA81J2MS99Qcpr2w7fw1gpm99rleRqA= +golang.org/x/sys v0.6.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/sys v0.34.0 h1:H5Y5sJ2L2JRdyv7ROF1he/lPdvFsd0mJHFw2ThKHxLA= +golang.org/x/sys v0.34.0/go.mod h1:BJP2sWEmIv4KK5OTEluFJCKSidICx8ciO85XgH3Ak8k= +golang.org/x/tools v0.34.0 h1:qIpSLOxeCYGg9TrcJokLBG4KFA6d795g0xkBkiESGlo= +golang.org/x/tools v0.34.0/go.mod h1:pAP9OwEaY1CAW3HOmg3hLZC5Z0CCmzjAF2UQMSqNARg= +modernc.org/cc/v4 v4.26.2 h1:991HMkLjJzYBIfha6ECZdjrIYz2/1ayr+FL8GN+CNzM= +modernc.org/cc/v4 v4.26.2/go.mod h1:uVtb5OGqUKpoLWhqwNQo/8LwvoiEBLvZXIQ/SmO6mL0= +modernc.org/ccgo/v4 v4.28.0 h1:rjznn6WWehKq7dG4JtLRKxb52Ecv8OUGah8+Z/SfpNU= +modernc.org/ccgo/v4 v4.28.0/go.mod h1:JygV3+9AV6SmPhDasu4JgquwU81XAKLd3OKTUDNOiKE= +modernc.org/fileutil v1.3.8 h1:qtzNm7ED75pd1C7WgAGcK4edm4fvhtBsEiI/0NQ54YM= +modernc.org/fileutil v1.3.8/go.mod h1:HxmghZSZVAz/LXcMNwZPA/DRrQZEVP9VX0V4LQGQFOc= +modernc.org/gc/v2 v2.6.5 h1:nyqdV8q46KvTpZlsw66kWqwXRHdjIlJOhG6kxiV/9xI= +modernc.org/gc/v2 v2.6.5/go.mod h1:YgIahr1ypgfe7chRuJi2gD7DBQiKSLMPgBQe9oIiito= +modernc.org/goabi0 v0.2.0 h1:HvEowk7LxcPd0eq6mVOAEMai46V+i7Jrj13t4AzuNks= +modernc.org/goabi0 v0.2.0/go.mod h1:CEFRnnJhKvWT1c1JTI3Avm+tgOWbkOu5oPA8eH8LnMI= +modernc.org/libc v1.66.3 h1:cfCbjTUcdsKyyZZfEUKfoHcP3S0Wkvz3jgSzByEWVCQ= +modernc.org/libc v1.66.3/go.mod h1:XD9zO8kt59cANKvHPXpx7yS2ELPheAey0vjIuZOhOU8= +modernc.org/mathutil v1.7.1 h1:GCZVGXdaN8gTqB1Mf/usp1Y/hSqgI2vAGGP4jZMCxOU= +modernc.org/mathutil v1.7.1/go.mod h1:4p5IwJITfppl0G4sUEDtCr4DthTaT47/N3aT6MhfgJg= +modernc.org/memory v1.11.0 h1:o4QC8aMQzmcwCK3t3Ux/ZHmwFPzE6hf2Y5LbkRs+hbI= +modernc.org/memory v1.11.0/go.mod h1:/JP4VbVC+K5sU2wZi9bHoq2MAkCnrt2r98UGeSK7Mjw= +modernc.org/opt v0.1.4 h1:2kNGMRiUjrp4LcaPuLY2PzUfqM/w9N23quVwhKt5Qm8= +modernc.org/opt v0.1.4/go.mod h1:03fq9lsNfvkYSfxrfUhZCWPk1lm4cq4N+Bh//bEtgns= +modernc.org/sortutil v1.2.1 h1:+xyoGf15mM3NMlPDnFqrteY07klSFxLElE2PVuWIJ7w= +modernc.org/sortutil v1.2.1/go.mod h1:7ZI3a3REbai7gzCLcotuw9AC4VZVpYMjDzETGsSMqJE= +modernc.org/sqlite v1.38.2 h1:Aclu7+tgjgcQVShZqim41Bbw9Cho0y/7WzYptXqkEek= +modernc.org/sqlite v1.38.2/go.mod h1:cPTJYSlgg3Sfg046yBShXENNtPrWrDX8bsbAQBzgQ5E= +modernc.org/strutil v1.2.1 h1:UneZBkQA+DX2Rp35KcM69cSsNES9ly8mQWD71HKlOA0= +modernc.org/strutil v1.2.1/go.mod h1:EHkiggD70koQxjVdSBM3JKM7k6L0FbGE5eymy9i3B9A= +modernc.org/token v1.1.0 h1:Xl7Ap9dKaEs5kLoOQeQmPWevfnk/DM5qcLcYlA8ys6Y= +modernc.org/token v1.1.0/go.mod h1:UGzOrNV1mAFSEB63lOFHIpNRUVMvYTc6yu1SMY/XTDM= diff --git a/internal/api/handlers.go b/internal/api/handlers.go new file mode 100644 index 0000000..06456f5 --- /dev/null +++ b/internal/api/handlers.go @@ -0,0 +1,224 @@ +// Package api exposes Havenllo's same-origin JSON API and embedded SPA handler. +package api + +import ( + "io/fs" + "net/http" + "path" + "strings" + + "havenllo/internal/app" +) + +type Handler struct { + service *app.Service + static fs.FS +} + +func NewHandler(service *app.Service, static fs.FS) http.Handler { + h := &Handler{service: service, static: static} + mux := http.NewServeMux() + mux.HandleFunc("GET /api/health", h.health) + mux.HandleFunc("GET /api/board", h.board) + mux.HandleFunc("GET /api/lists", h.lists) + mux.HandleFunc("POST /api/lists", h.createList) + mux.HandleFunc("GET /api/lists/{id}", h.list) + mux.HandleFunc("PATCH /api/lists/{id}", h.updateList) + mux.HandleFunc("DELETE /api/lists/{id}", h.deleteList) + mux.HandleFunc("GET /api/lists/{id}/cards", h.cards) + mux.HandleFunc("POST /api/lists/{id}/cards", h.createCard) + mux.HandleFunc("GET /api/cards/{id}", h.card) + mux.HandleFunc("PATCH /api/cards/{id}", h.updateCard) + mux.HandleFunc("DELETE /api/cards/{id}", h.deleteCard) + mux.HandleFunc("/api/", h.apiNotFound) + mux.HandleFunc("/", h.serveApp) + return mux +} + +func (h *Handler) health(w http.ResponseWriter, r *http.Request) { + if err := h.service.Health(r.Context()); err != nil { + writeError(w, http.StatusServiceUnavailable, "unavailable", "database is unavailable") + return + } + writeJSON(w, http.StatusOK, map[string]string{"status": "ok"}) +} + +func (h *Handler) board(w http.ResponseWriter, r *http.Request) { + snapshot, err := h.service.Board(r.Context()) + if err != nil { + writeDomainError(w, err) + return + } + writeJSON(w, http.StatusOK, snapshot) +} + +func (h *Handler) lists(w http.ResponseWriter, r *http.Request) { + lists, err := h.service.Lists(r.Context()) + if err != nil { + writeDomainError(w, err) + return + } + writeJSON(w, http.StatusOK, listsResponse{Lists: listSummaries(lists)}) +} + +func (h *Handler) createList(w http.ResponseWriter, r *http.Request) { + if !requireJSON(w, r) { + return + } + var request createListRequest + if !decodeJSON(w, r, &request) { + return + } + list, err := h.service.CreateList(r.Context(), request.Name, request.Position) + if err != nil { + writeDomainError(w, err) + return + } + writeJSON(w, http.StatusCreated, listResponse{List: list}) +} + +func (h *Handler) list(w http.ResponseWriter, r *http.Request) { + id, ok := pathID(w, r, "id") + if !ok { + return + } + list, err := h.service.List(r.Context(), id) + if err != nil { + writeDomainError(w, err) + return + } + cards, err := h.service.Cards(r.Context(), id) + if err != nil { + writeDomainError(w, err) + return + } + writeJSON(w, http.StatusOK, listDetailsResponse{List: list, Cards: cards}) +} + +func (h *Handler) updateList(w http.ResponseWriter, r *http.Request) { + id, ok := pathID(w, r, "id") + if !ok || !requireJSON(w, r) { + return + } + var request updateListRequest + if !decodeJSON(w, r, &request) { + return + } + list, err := h.service.UpdateList(r.Context(), id, request.Name, request.Position) + if err != nil { + writeDomainError(w, err) + return + } + writeJSON(w, http.StatusOK, listResponse{List: list}) +} + +func (h *Handler) deleteList(w http.ResponseWriter, r *http.Request) { + id, ok := pathID(w, r, "id") + if !ok { + return + } + if err := h.service.DeleteList(r.Context(), id); err != nil { + writeDomainError(w, err) + return + } + w.WriteHeader(http.StatusNoContent) +} + +func (h *Handler) cards(w http.ResponseWriter, r *http.Request) { + listID, ok := pathID(w, r, "id") + if !ok { + return + } + cards, err := h.service.Cards(r.Context(), listID) + if err != nil { + writeDomainError(w, err) + return + } + writeJSON(w, http.StatusOK, cardsResponse{Cards: cards}) +} + +func (h *Handler) createCard(w http.ResponseWriter, r *http.Request) { + listID, ok := pathID(w, r, "id") + if !ok || !requireJSON(w, r) { + return + } + var request createCardRequest + if !decodeJSON(w, r, &request) { + return + } + card, err := h.service.CreateCard(r.Context(), listID, request.Title, request.Description, request.Position) + if err != nil { + writeDomainError(w, err) + return + } + writeJSON(w, http.StatusCreated, cardResponse{Card: card}) +} + +func (h *Handler) card(w http.ResponseWriter, r *http.Request) { + id, ok := pathID(w, r, "id") + if !ok { + return + } + card, err := h.service.Card(r.Context(), id) + if err != nil { + writeDomainError(w, err) + return + } + writeJSON(w, http.StatusOK, cardResponse{Card: card}) +} + +func (h *Handler) updateCard(w http.ResponseWriter, r *http.Request) { + id, ok := pathID(w, r, "id") + if !ok || !requireJSON(w, r) { + return + } + var request updateCardRequest + if !decodeJSON(w, r, &request) { + return + } + card, err := h.service.UpdateCard(r.Context(), id, app.CardPatch{ + Title: request.Title, Description: request.Description, Done: request.Done, ListID: request.ListID, Position: request.Position, + }) + if err != nil { + writeDomainError(w, err) + return + } + writeJSON(w, http.StatusOK, cardResponse{Card: card}) +} + +func (h *Handler) deleteCard(w http.ResponseWriter, r *http.Request) { + id, ok := pathID(w, r, "id") + if !ok { + return + } + if err := h.service.DeleteCard(r.Context(), id); err != nil { + writeDomainError(w, err) + return + } + w.WriteHeader(http.StatusNoContent) +} + +func (h *Handler) apiNotFound(w http.ResponseWriter, r *http.Request) { + writeError(w, http.StatusNotFound, "not_found", "API endpoint not found") +} + +func (h *Handler) serveApp(w http.ResponseWriter, r *http.Request) { + if h.static == nil { + writeError(w, http.StatusNotFound, "not_found", "application bundle not found") + return + } + requested := strings.TrimPrefix(path.Clean(r.URL.Path), "/") + if requested != "" { + if _, err := fs.Stat(h.static, requested); err == nil { + http.FileServer(http.FS(h.static)).ServeHTTP(w, r) + return + } + } + index, err := fs.ReadFile(h.static, "index.html") + if err != nil { + writeError(w, http.StatusNotFound, "not_found", "application bundle not found") + return + } + w.Header().Set("Content-Type", "text/html; charset=utf-8") + _, _ = w.Write(index) +} diff --git a/internal/api/handlers_test.go b/internal/api/handlers_test.go new file mode 100644 index 0000000..580f91a --- /dev/null +++ b/internal/api/handlers_test.go @@ -0,0 +1,86 @@ +package api_test + +import ( + "bytes" + "context" + "encoding/json" + "net/http" + "net/http/httptest" + "path/filepath" + "strconv" + "testing" + "testing/fstest" + + "havenllo/internal/api" + "havenllo/internal/app" + "havenllo/internal/database" +) + +func newHandler(t *testing.T) http.Handler { + t.Helper() + db, err := database.Open(context.Background(), filepath.Join(t.TempDir(), "havenllo.db")) + if err != nil { + t.Fatal(err) + } + t.Cleanup(func() { _ = db.Close() }) + return api.NewHandler(app.New(db), fstest.MapFS{"index.html": {Data: []byte("")}}) +} + +func request(t *testing.T, handler http.Handler, method, path, body string, jsonBody bool) *httptest.ResponseRecorder { + t.Helper() + r := httptest.NewRequest(method, path, bytes.NewBufferString(body)) + if jsonBody { + r.Header.Set("Content-Type", "application/json") + } + w := httptest.NewRecorder() + handler.ServeHTTP(w, r) + return w +} + +func TestBoardAndHealth(t *testing.T) { + t.Parallel() + handler := newHandler(t) + for _, path := range []string{"/api/health", "/api/board"} { + response := request(t, handler, http.MethodGet, path, "", false) + if response.Code != http.StatusOK { + t.Fatalf("%s status = %d, body %s", path, response.Code, response.Body) + } + } + var snapshot struct { + Lists []json.RawMessage `json:"lists"` + } + if err := json.Unmarshal(request(t, handler, http.MethodGet, "/api/board", "", false).Body.Bytes(), &snapshot); err != nil { + t.Fatal(err) + } + if len(snapshot.Lists) != 3 { + t.Fatalf("snapshot lists = %d, want 3", len(snapshot.Lists)) + } +} + +func TestJSONValidationAndLastListConflict(t *testing.T) { + t.Parallel() + handler := newHandler(t) + if got := request(t, handler, http.MethodPost, "/api/lists", `{"name":"later","unknown":true}`, true); got.Code != http.StatusBadRequest { + t.Fatalf("unknown field status = %d", got.Code) + } + if got := request(t, handler, http.MethodPost, "/api/lists", `{"name":"later"}`, false); got.Code != http.StatusUnsupportedMediaType { + t.Fatalf("content type status = %d", got.Code) + } + response := request(t, handler, http.MethodGet, "/api/lists", "", false) + var lists struct { + Lists []struct { + ID int64 `json:"id"` + } `json:"lists"` + } + if err := json.Unmarshal(response.Body.Bytes(), &lists); err != nil { + t.Fatal(err) + } + for _, list := range lists.Lists[:2] { + if got := request(t, handler, http.MethodDelete, "/api/lists/"+strconv.FormatInt(list.ID, 10), "", false); got.Code != http.StatusNoContent { + t.Fatalf("delete list status = %d", got.Code) + } + } + if got := request(t, handler, http.MethodDelete, "/api/lists/"+strconv.FormatInt(lists.Lists[2].ID, 10), "", false); got.Code != http.StatusConflict { + t.Fatalf("last list status = %d", got.Code) + } +} diff --git a/internal/api/http.go b/internal/api/http.go new file mode 100644 index 0000000..3024aa4 --- /dev/null +++ b/internal/api/http.go @@ -0,0 +1,95 @@ +package api + +import ( + "encoding/json" + "errors" + "fmt" + "io" + "mime" + "net/http" + "strconv" + "strings" + + "havenllo/internal/domain" +) + +const maxJSONBody = 1 << 20 + +func writeJSON(w http.ResponseWriter, status int, value any) { + w.Header().Set("Content-Type", "application/json; charset=utf-8") + w.WriteHeader(status) + _ = json.NewEncoder(w).Encode(value) +} + +func writeError(w http.ResponseWriter, status int, code, message string) { + writeJSON(w, status, errorResponse{Error: apiError{Code: code, Message: message}}) +} + +func writeDomainError(w http.ResponseWriter, err error) { + var validation domain.ValidationError + switch { + case errors.Is(err, domain.ErrNotFound): + writeError(w, http.StatusNotFound, "not_found", "resource not found") + case errors.Is(err, domain.ErrLastList): + writeError(w, http.StatusConflict, "last_list", err.Error()) + case errors.As(err, &validation): + writeError(w, http.StatusUnprocessableEntity, "validation_error", validation.Message) + default: + writeError(w, http.StatusInternalServerError, "internal_error", "an unexpected error occurred") + } +} + +func requireJSON(w http.ResponseWriter, r *http.Request) bool { + contentType := r.Header.Get("Content-Type") + mediaType, _, err := mime.ParseMediaType(contentType) + if err != nil || mediaType != "application/json" { + writeError(w, http.StatusUnsupportedMediaType, "unsupported_media_type", "Content-Type must be application/json") + return false + } + return true +} + +func decodeJSON(w http.ResponseWriter, r *http.Request, target any) bool { + r.Body = http.MaxBytesReader(w, r.Body, maxJSONBody) + decoder := json.NewDecoder(r.Body) + decoder.DisallowUnknownFields() + if err := decoder.Decode(target); err != nil { + writeDecodeError(w, err) + return false + } + if err := decoder.Decode(&struct{}{}); err != io.EOF { + writeError(w, http.StatusBadRequest, "invalid_json", "request body must contain one JSON value") + return false + } + return true +} + +func writeDecodeError(w http.ResponseWriter, err error) { + var syntaxError *json.SyntaxError + var typeError *json.UnmarshalTypeError + switch { + case errors.As(err, &syntaxError): + writeError(w, http.StatusBadRequest, "invalid_json", "request body contains malformed JSON") + case errors.Is(err, io.ErrUnexpectedEOF): + writeError(w, http.StatusBadRequest, "invalid_json", "request body contains malformed JSON") + case errors.As(err, &typeError): + writeError(w, http.StatusBadRequest, "invalid_json", fmt.Sprintf("invalid value for %s", typeError.Field)) + case strings.HasPrefix(err.Error(), "json: unknown field "): + writeError(w, http.StatusBadRequest, "invalid_json", "request body contains an unknown field") + case errors.Is(err, io.EOF): + writeError(w, http.StatusBadRequest, "invalid_json", "request body must not be empty") + case strings.Contains(err.Error(), "http: request body too large"): + writeError(w, http.StatusBadRequest, "invalid_json", "request body is too large") + default: + writeError(w, http.StatusBadRequest, "invalid_json", "request body is invalid") + } +} + +func pathID(w http.ResponseWriter, r *http.Request, key string) (int64, bool) { + id, err := strconv.ParseInt(r.PathValue(key), 10, 64) + if err != nil || id < 1 { + writeError(w, http.StatusBadRequest, "invalid_id", "resource ID must be a positive integer") + return 0, false + } + return id, true +} diff --git a/internal/api/types.go b/internal/api/types.go new file mode 100644 index 0000000..807db5d --- /dev/null +++ b/internal/api/types.go @@ -0,0 +1,72 @@ +package api + +import "havenllo/internal/domain" + +type createListRequest struct { + Name string `json:"name"` + Position *float64 `json:"position,omitempty"` +} + +type updateListRequest struct { + Name *string `json:"name,omitempty"` + Position *float64 `json:"position,omitempty"` +} + +type createCardRequest struct { + Title string `json:"title"` + Description string `json:"description"` + Position *float64 `json:"position,omitempty"` +} + +type updateCardRequest struct { + Title *string `json:"title,omitempty"` + Description *string `json:"description,omitempty"` + Done *bool `json:"done,omitempty"` + ListID *int64 `json:"list_id,omitempty"` + Position *float64 `json:"position,omitempty"` +} + +type errorResponse struct { + Error apiError `json:"error"` +} + +type apiError struct { + Code string `json:"code"` + Message string `json:"message"` +} + +type listResponse struct { + List domain.List `json:"list"` +} + +type listDetailsResponse struct { + List domain.List `json:"list"` + Cards []domain.Card `json:"cards"` +} + +type listSummary struct { + ID int64 `json:"id"` + Name string `json:"name"` + Position float64 `json:"position"` + CardCount int `json:"card_count"` +} + +type listsResponse struct { + Lists []listSummary `json:"lists"` +} +type cardResponse struct { + Card domain.Card `json:"card"` +} +type cardsResponse struct { + Cards []domain.Card `json:"cards"` +} + +func listSummaries(lists []domain.List) []listSummary { + summaries := make([]listSummary, 0, len(lists)) + for _, list := range lists { + summaries = append(summaries, listSummary{ + ID: list.ID, Name: list.Name, Position: list.Position, CardCount: list.CardCount, + }) + } + return summaries +} diff --git a/internal/app/service.go b/internal/app/service.go new file mode 100644 index 0000000..fc85cd1 --- /dev/null +++ b/internal/app/service.go @@ -0,0 +1,351 @@ +// Package app contains the transactional business rules for the fixed Haven board. +package app + +import ( + "context" + "database/sql" + "fmt" + "math" + "strings" + "time" + + "havenllo/internal/domain" + "havenllo/internal/store" +) + +const positionStep = 1024.0 +const minimumPositionGap = 0.0001 + +type Service struct{ db *sql.DB } + +func New(db *sql.DB) *Service { return &Service{db: db} } + +func (s *Service) Health(ctx context.Context) error { return s.db.PingContext(ctx) } + +func (s *Service) Board(ctx context.Context) (domain.Snapshot, error) { + return store.Snapshot(ctx, s.db) +} + +func (s *Service) Lists(ctx context.Context) ([]domain.List, error) { + return store.Lists(ctx, s.db, true) +} + +func (s *Service) List(ctx context.Context, id int64) (domain.List, error) { + return store.List(ctx, s.db, id) +} + +func (s *Service) Cards(ctx context.Context, listID int64) ([]domain.Card, error) { + if _, err := store.List(ctx, s.db, listID); err != nil { + return nil, err + } + return store.Cards(ctx, s.db, listID) +} + +func (s *Service) Card(ctx context.Context, id int64) (domain.Card, error) { + return store.Card(ctx, s.db, id) +} + +func (s *Service) CreateList(ctx context.Context, name string, position *float64) (domain.List, error) { + name, err := validName(name) + if err != nil { + return domain.List{}, err + } + return withTx(ctx, s.db, func(tx *sql.Tx) (domain.List, error) { + pos, err := positionForNewList(ctx, tx, position) + if err != nil { + return domain.List{}, err + } + result, err := tx.ExecContext(ctx, "INSERT INTO lists (name, position) VALUES (?, ?)", name, pos) + if err != nil { + return domain.List{}, err + } + id, err := result.LastInsertId() + if err != nil { + return domain.List{}, err + } + if err := normalizeLists(ctx, tx); err != nil { + return domain.List{}, err + } + return store.List(ctx, tx, id) + }) +} + +func (s *Service) UpdateList(ctx context.Context, id int64, name *string, position *float64) (domain.List, error) { + if name != nil { + var err error + if *name, err = validName(*name); err != nil { + return domain.List{}, err + } + } + if position != nil && !validPosition(*position) { + return domain.List{}, domain.ValidationError{Message: "position must be a finite number"} + } + return withTx(ctx, s.db, func(tx *sql.Tx) (domain.List, error) { + list, err := store.List(ctx, tx, id) + if err != nil { + return domain.List{}, err + } + if name != nil { + list.Name = *name + } + if position != nil { + list.Position = *position + } + if _, err := tx.ExecContext(ctx, "UPDATE lists SET name = ?, position = ? WHERE id = ?", list.Name, list.Position, id); err != nil { + return domain.List{}, err + } + if err := normalizeLists(ctx, tx); err != nil { + return domain.List{}, err + } + return store.List(ctx, tx, id) + }) +} + +func (s *Service) DeleteList(ctx context.Context, id int64) error { + return withTxVoid(ctx, s.db, func(tx *sql.Tx) error { + if _, err := store.List(ctx, tx, id); err != nil { + return err + } + count, err := store.CountLists(ctx, tx) + if err != nil { + return err + } + if count <= 1 { + return domain.ErrLastList + } + _, err = tx.ExecContext(ctx, "DELETE FROM lists WHERE id = ?", id) + return err + }) +} + +func (s *Service) CreateCard(ctx context.Context, listID int64, title, description string, position *float64) (domain.Card, error) { + title, err := validTitle(title) + if err != nil { + return domain.Card{}, err + } + if err := validDescription(description); err != nil { + return domain.Card{}, err + } + return withTx(ctx, s.db, func(tx *sql.Tx) (domain.Card, error) { + if _, err := store.List(ctx, tx, listID); err != nil { + return domain.Card{}, err + } + pos, err := positionForNewCard(ctx, tx, listID, position) + if err != nil { + return domain.Card{}, err + } + now := timestamp() + result, err := tx.ExecContext(ctx, `INSERT INTO cards (list_id, title, description, position, done, created_at, updated_at) + VALUES (?, ?, ?, ?, 0, ?, ?)`, listID, title, description, pos, now, now) + if err != nil { + return domain.Card{}, err + } + id, err := result.LastInsertId() + if err != nil { + return domain.Card{}, err + } + if err := normalizeCards(ctx, tx, listID); err != nil { + return domain.Card{}, err + } + return store.Card(ctx, tx, id) + }) +} + +type CardPatch struct { + Title *string + Description *string + Done *bool + ListID *int64 + Position *float64 +} + +func (s *Service) UpdateCard(ctx context.Context, id int64, patch CardPatch) (domain.Card, error) { + if patch.Title != nil { + var err error + if *patch.Title, err = validTitle(*patch.Title); err != nil { + return domain.Card{}, err + } + } + if patch.Description != nil { + if err := validDescription(*patch.Description); err != nil { + return domain.Card{}, err + } + } + if patch.Position != nil && !validPosition(*patch.Position) { + return domain.Card{}, domain.ValidationError{Message: "position must be a finite number"} + } + if patch.ListID != nil && *patch.ListID < 1 { + return domain.Card{}, domain.ValidationError{Message: "list_id must be a positive integer"} + } + return withTx(ctx, s.db, func(tx *sql.Tx) (domain.Card, error) { + card, err := store.Card(ctx, tx, id) + if err != nil { + return domain.Card{}, err + } + sourceListID := card.ListID + if patch.Title != nil { + card.Title = *patch.Title + } + if patch.Description != nil { + card.Description = *patch.Description + } + if patch.Done != nil { + card.Done = *patch.Done + } + if patch.ListID != nil { + if _, err := store.List(ctx, tx, *patch.ListID); err != nil { + return domain.Card{}, err + } + card.ListID = *patch.ListID + } + if patch.Position != nil { + card.Position = *patch.Position + } else if card.ListID != sourceListID { + pos, err := store.MaxCardPosition(ctx, tx, card.ListID) + if err != nil { + return domain.Card{}, err + } + card.Position = pos + positionStep + } + done := 0 + if card.Done { + done = 1 + } + if _, err := tx.ExecContext(ctx, `UPDATE cards SET list_id = ?, title = ?, description = ?, position = ?, done = ?, updated_at = ? WHERE id = ?`, + card.ListID, card.Title, card.Description, card.Position, done, timestamp(), id); err != nil { + return domain.Card{}, err + } + if err := normalizeCards(ctx, tx, sourceListID); err != nil { + return domain.Card{}, err + } + if card.ListID != sourceListID { + if err := normalizeCards(ctx, tx, card.ListID); err != nil { + return domain.Card{}, err + } + } + return store.Card(ctx, tx, id) + }) +} + +func (s *Service) DeleteCard(ctx context.Context, id int64) error { + result, err := s.db.ExecContext(ctx, "DELETE FROM cards WHERE id = ?", id) + return store.MustRows(result, err) +} + +func positionForNewList(ctx context.Context, q store.DBTX, requested *float64) (float64, error) { + if requested != nil { + if !validPosition(*requested) { + return 0, domain.ValidationError{Message: "position must be a finite number"} + } + return *requested, nil + } + max, err := store.MaxListPosition(ctx, q) + return max + positionStep, err +} + +func positionForNewCard(ctx context.Context, q store.DBTX, listID int64, requested *float64) (float64, error) { + if requested != nil { + if !validPosition(*requested) { + return 0, domain.ValidationError{Message: "position must be a finite number"} + } + return *requested, nil + } + max, err := store.MaxCardPosition(ctx, q, listID) + return max + positionStep, err +} + +func normalizeLists(ctx context.Context, tx *sql.Tx) error { + lists, err := store.Lists(ctx, tx, false) + if err != nil { + return err + } + if !needsNormalizationList(lists) { + return nil + } + for i, list := range lists { + if _, err := tx.ExecContext(ctx, "UPDATE lists SET position = ? WHERE id = ?", float64(i+1)*positionStep, list.ID); err != nil { + return err + } + } + return nil +} + +func normalizeCards(ctx context.Context, tx *sql.Tx, listID int64) error { + cards, err := store.Cards(ctx, tx, listID) + if err != nil { + return err + } + if !needsNormalizationCards(cards) { + return nil + } + for i, card := range cards { + if _, err := tx.ExecContext(ctx, "UPDATE cards SET position = ? WHERE id = ?", float64(i+1)*positionStep, card.ID); err != nil { + return err + } + } + return nil +} + +func needsNormalizationList(lists []domain.List) bool { + for i, list := range lists { + if !validPosition(list.Position) || (i > 0 && list.Position-lists[i-1].Position < minimumPositionGap) { + return true + } + } + return false +} + +func needsNormalizationCards(cards []domain.Card) bool { + for i, card := range cards { + if !validPosition(card.Position) || (i > 0 && card.Position-cards[i-1].Position < minimumPositionGap) { + return true + } + } + return false +} + +func validName(name string) (string, error) { return validTrimmed(name, 120, "name") } +func validTitle(title string) (string, error) { return validTrimmed(title, 240, "title") } + +func validTrimmed(value string, max int, field string) (string, error) { + value = strings.TrimSpace(value) + if value == "" { + return "", domain.ValidationError{Message: field + " is required"} + } + if len([]rune(value)) > max { + return "", domain.ValidationError{Message: fmt.Sprintf("%s must be at most %d characters", field, max)} + } + return value, nil +} + +func validDescription(description string) error { + if len([]rune(description)) > 10000 { + return domain.ValidationError{Message: "description must be at most 10000 characters"} + } + return nil +} + +func validPosition(position float64) bool { return !math.IsNaN(position) && !math.IsInf(position, 0) } +func timestamp() string { return time.Now().UTC().Format(time.RFC3339Nano) } + +func withTx[T any](ctx context.Context, db *sql.DB, run func(*sql.Tx) (T, error)) (T, error) { + var zero T + tx, err := db.BeginTx(ctx, nil) + if err != nil { + return zero, err + } + value, err := run(tx) + if err != nil { + _ = tx.Rollback() + return zero, err + } + if err := tx.Commit(); err != nil { + return zero, err + } + return value, nil +} + +func withTxVoid(ctx context.Context, db *sql.DB, run func(*sql.Tx) error) error { + _, err := withTx(ctx, db, func(tx *sql.Tx) (struct{}, error) { return struct{}{}, run(tx) }) + return err +} diff --git a/internal/app/service_test.go b/internal/app/service_test.go new file mode 100644 index 0000000..6bb987a --- /dev/null +++ b/internal/app/service_test.go @@ -0,0 +1,97 @@ +package app_test + +import ( + "context" + "errors" + "path/filepath" + "testing" + + "havenllo/internal/app" + "havenllo/internal/database" + "havenllo/internal/domain" +) + +func newService(t *testing.T) (*app.Service, func()) { + t.Helper() + db, err := database.Open(context.Background(), filepath.Join(t.TempDir(), "havenllo.db")) + if err != nil { + t.Fatal(err) + } + return app.New(db), func() { _ = db.Close() } +} + +func TestLastListProtection(t *testing.T) { + t.Parallel() + service, closeDB := newService(t) + defer closeDB() + ctx := context.Background() + lists, err := service.Lists(ctx) + if err != nil { + t.Fatal(err) + } + for _, list := range lists[:2] { + if err := service.DeleteList(ctx, list.ID); err != nil { + t.Fatal(err) + } + } + if err := service.DeleteList(ctx, lists[2].ID); !errors.Is(err, domain.ErrLastList) { + t.Fatalf("DeleteList error = %v, want ErrLastList", err) + } +} + +func TestCardMoveNormalizesCrowdedPositions(t *testing.T) { + t.Parallel() + service, closeDB := newService(t) + defer closeDB() + ctx := context.Background() + lists, err := service.Lists(ctx) + if err != nil { + t.Fatal(err) + } + first := lists[0] + a, err := service.CreateCard(ctx, first.ID, "a", "", nil) + if err != nil { + t.Fatal(err) + } + b, err := service.CreateCard(ctx, first.ID, "b", "", nil) + if err != nil { + t.Fatal(err) + } + position := a.Position + 0.00001 + if _, err := service.UpdateCard(ctx, b.ID, app.CardPatch{Position: &position}); err != nil { + t.Fatal(err) + } + cards, err := service.Cards(ctx, first.ID) + if err != nil { + t.Fatal(err) + } + if len(cards) != 2 || cards[1].Position-cards[0].Position < 0.0001 { + t.Fatalf("cards were not normalized: %#v", cards) + } +} + +func TestCardMoveAndCascade(t *testing.T) { + t.Parallel() + service, closeDB := newService(t) + defer closeDB() + ctx := context.Background() + lists, _ := service.Lists(ctx) + card, err := service.CreateCard(ctx, lists[0].ID, "move me", "", nil) + if err != nil { + t.Fatal(err) + } + target := lists[1].ID + moved, err := service.UpdateCard(ctx, card.ID, app.CardPatch{ListID: &target}) + if err != nil { + t.Fatal(err) + } + if moved.ListID != target { + t.Fatalf("card list = %d, want %d", moved.ListID, target) + } + if err := service.DeleteList(ctx, target); err != nil { + t.Fatal(err) + } + if _, err := service.Card(ctx, card.ID); !errors.Is(err, domain.ErrNotFound) { + t.Fatalf("card after list deletion = %v, want not found", err) + } +} diff --git a/internal/database/database.go b/internal/database/database.go new file mode 100644 index 0000000..ddfdded --- /dev/null +++ b/internal/database/database.go @@ -0,0 +1,37 @@ +package database + +import ( + "context" + "database/sql" + "fmt" + "os" + "path/filepath" + + _ "modernc.org/sqlite" +) + +// Open configures the one SQLite connection used by the single-replica app and +// migrates it before returning it to callers. +func Open(ctx context.Context, path string) (*sql.DB, error) { + dir := filepath.Dir(path) + if dir != "." && dir != "" { + if err := os.MkdirAll(dir, 0o755); err != nil { + return nil, fmt.Errorf("create database directory: %w", err) + } + } + db, err := sql.Open("sqlite", path) + if err != nil { + return nil, fmt.Errorf("open database: %w", err) + } + db.SetMaxOpenConns(1) + db.SetMaxIdleConns(1) + if _, err := db.ExecContext(ctx, "PRAGMA foreign_keys = ON; PRAGMA busy_timeout = 5000; PRAGMA journal_mode = WAL;"); err != nil { + _ = db.Close() + return nil, fmt.Errorf("configure database: %w", err) + } + if err := migrate(ctx, db); err != nil { + _ = db.Close() + return nil, err + } + return db, nil +} diff --git a/internal/database/database_test.go b/internal/database/database_test.go new file mode 100644 index 0000000..7ac5d84 --- /dev/null +++ b/internal/database/database_test.go @@ -0,0 +1,69 @@ +package database_test + +import ( + "context" + "database/sql" + "path/filepath" + "testing" + + "havenllo/internal/database" +) + +func TestOpenMigratesSeedsAndEnforcesCascade(t *testing.T) { + t.Parallel() + ctx := context.Background() + path := filepath.Join(t.TempDir(), "havenllo.db") + db, err := database.Open(ctx, path) + if err != nil { + t.Fatalf("Open: %v", err) + } + defer db.Close() + + var count int + if err := db.QueryRowContext(ctx, "SELECT COUNT(*) FROM lists").Scan(&count); err != nil { + t.Fatal(err) + } + if count != 3 { + t.Fatalf("seeded lists = %d, want 3", count) + } + var listID int64 + if err := db.QueryRowContext(ctx, "SELECT id FROM lists ORDER BY position LIMIT 1").Scan(&listID); err != nil { + t.Fatal(err) + } + if _, err := db.ExecContext(ctx, `INSERT INTO cards (list_id, title, description, position, done, created_at, updated_at) + VALUES (?, 'test', '', 1024, 0, '2026-01-01T00:00:00Z', '2026-01-01T00:00:00Z')`, listID); err != nil { + t.Fatal(err) + } + if _, err := db.ExecContext(ctx, "DELETE FROM lists WHERE id = ?", listID); err != nil { + t.Fatal(err) + } + if err := db.QueryRowContext(ctx, "SELECT COUNT(*) FROM cards").Scan(&count); err != nil { + t.Fatal(err) + } + if count != 0 { + t.Fatalf("cascade left %d cards", count) + } +} + +func TestOpenIsIdempotent(t *testing.T) { + t.Parallel() + ctx := context.Background() + path := filepath.Join(t.TempDir(), "havenllo.db") + db, err := database.Open(ctx, path) + if err != nil { + t.Fatal(err) + } + _ = db.Close() + db, err = database.Open(ctx, path) + if err != nil { + t.Fatal(err) + } + defer db.Close() + var count int + if err := db.QueryRowContext(ctx, "SELECT COUNT(*) FROM schema_migrations").Scan(&count); err != nil && err != sql.ErrNoRows { + t.Fatal(err) + } + if count != 1 { + t.Fatalf("migrations = %d, want 1", count) + } +} diff --git a/internal/database/migrations.go b/internal/database/migrations.go new file mode 100644 index 0000000..cd14ca1 --- /dev/null +++ b/internal/database/migrations.go @@ -0,0 +1,87 @@ +package database + +import ( + "context" + "database/sql" + "fmt" + "time" +) + +type migration struct { + version int + apply func(context.Context, *sql.Tx) error +} + +var migrations = []migration{ + {version: 1, apply: migrationOne}, +} + +func migrate(ctx context.Context, db *sql.DB) error { + if _, err := db.ExecContext(ctx, `CREATE TABLE IF NOT EXISTS schema_migrations ( + version INTEGER PRIMARY KEY, + applied_at TEXT NOT NULL + )`); err != nil { + return fmt.Errorf("create migrations table: %w", err) + } + + for _, m := range migrations { + var exists int + if err := db.QueryRowContext(ctx, "SELECT COUNT(*) FROM schema_migrations WHERE version = ?", m.version).Scan(&exists); err != nil { + return fmt.Errorf("read migration %d: %w", m.version, err) + } + if exists != 0 { + continue + } + + tx, err := db.BeginTx(ctx, nil) + if err != nil { + return fmt.Errorf("begin migration %d: %w", m.version, err) + } + if err := m.apply(ctx, tx); err != nil { + _ = tx.Rollback() + return fmt.Errorf("apply migration %d: %w", m.version, err) + } + if _, err := tx.ExecContext(ctx, "INSERT INTO schema_migrations (version, applied_at) VALUES (?, ?)", m.version, time.Now().UTC().Format(time.RFC3339Nano)); err != nil { + _ = tx.Rollback() + return fmt.Errorf("record migration %d: %w", m.version, err) + } + if err := tx.Commit(); err != nil { + return fmt.Errorf("commit migration %d: %w", m.version, err) + } + } + return nil +} + +func migrationOne(ctx context.Context, tx *sql.Tx) error { + statements := []string{ + `CREATE TABLE lists ( + id INTEGER PRIMARY KEY, + name TEXT NOT NULL CHECK (length(trim(name)) BETWEEN 1 AND 120), + position REAL NOT NULL + )`, + `CREATE TABLE cards ( + id INTEGER PRIMARY KEY, + list_id INTEGER NOT NULL, + title TEXT NOT NULL CHECK (length(trim(title)) BETWEEN 1 AND 240), + description TEXT NOT NULL DEFAULT '', + position REAL NOT NULL, + done INTEGER NOT NULL DEFAULT 0 CHECK (done IN (0, 1)), + created_at TEXT NOT NULL, + updated_at TEXT NOT NULL, + FOREIGN KEY (list_id) REFERENCES lists(id) ON DELETE CASCADE + )`, + `CREATE INDEX idx_lists_position ON lists(position, id)`, + `CREATE INDEX idx_cards_list_position ON cards(list_id, position, id)`, + } + for _, statement := range statements { + if _, err := tx.ExecContext(ctx, statement); err != nil { + return err + } + } + for i, name := range []string{"To do", "In progress", "Done"} { + if _, err := tx.ExecContext(ctx, "INSERT INTO lists (name, position) VALUES (?, ?)", name, float64(i+1)*1024); err != nil { + return err + } + } + return nil +} diff --git a/internal/domain/models.go b/internal/domain/models.go new file mode 100644 index 0000000..08585fa --- /dev/null +++ b/internal/domain/models.go @@ -0,0 +1,42 @@ +package domain + +import "errors" + +var ( + ErrNotFound = errors.New("resource not found") + ErrLastList = errors.New("the last remaining list cannot be deleted") +) + +// ValidationError represents a user-correctable domain validation failure. +type ValidationError struct{ Message string } + +func (e ValidationError) Error() string { return e.Message } + +type List struct { + ID int64 `json:"id"` + Name string `json:"name"` + Position float64 `json:"position"` + CardCount int `json:"card_count,omitempty"` +} + +type Card struct { + ID int64 `json:"id"` + ListID int64 `json:"list_id"` + Title string `json:"title"` + Description string `json:"description"` + Position float64 `json:"position"` + Done bool `json:"done"` + CreatedAt string `json:"created_at"` + UpdatedAt string `json:"updated_at"` +} + +type ListWithCards struct { + ID int64 `json:"id"` + Name string `json:"name"` + Position float64 `json:"position"` + Cards []Card `json:"cards"` +} + +type Snapshot struct { + Lists []ListWithCards `json:"lists"` +} diff --git a/internal/store/sqlite.go b/internal/store/sqlite.go new file mode 100644 index 0000000..04a0660 --- /dev/null +++ b/internal/store/sqlite.go @@ -0,0 +1,146 @@ +// Package store contains small, parameterized SQLite queries used by the service. +package store + +import ( + "context" + "database/sql" + "fmt" + + "havenllo/internal/domain" +) + +type DBTX interface { + ExecContext(context.Context, string, ...any) (sql.Result, error) + QueryContext(context.Context, string, ...any) (*sql.Rows, error) + QueryRowContext(context.Context, string, ...any) *sql.Row +} + +func Lists(ctx context.Context, q DBTX, counts bool) ([]domain.List, error) { + query := `SELECT l.id, l.name, l.position` + if counts { + query += `, COUNT(c.id) FROM lists l LEFT JOIN cards c ON c.list_id = l.id GROUP BY l.id, l.name, l.position ORDER BY l.position, l.id` + } else { + query += ` FROM lists l ORDER BY l.position, l.id` + } + rows, err := q.QueryContext(ctx, query) + if err != nil { + return nil, err + } + defer rows.Close() + lists := make([]domain.List, 0) + for rows.Next() { + var list domain.List + if counts { + err = rows.Scan(&list.ID, &list.Name, &list.Position, &list.CardCount) + } else { + err = rows.Scan(&list.ID, &list.Name, &list.Position) + } + if err != nil { + return nil, err + } + lists = append(lists, list) + } + return lists, rows.Err() +} + +func List(ctx context.Context, q DBTX, id int64) (domain.List, error) { + var list domain.List + err := q.QueryRowContext(ctx, "SELECT id, name, position FROM lists WHERE id = ?", id).Scan(&list.ID, &list.Name, &list.Position) + if err == sql.ErrNoRows { + return domain.List{}, domain.ErrNotFound + } + return list, err +} + +func Cards(ctx context.Context, q DBTX, listID int64) ([]domain.Card, error) { + rows, err := q.QueryContext(ctx, `SELECT id, list_id, title, description, position, done, created_at, updated_at + FROM cards WHERE list_id = ? ORDER BY position, id`, listID) + if err != nil { + return nil, err + } + defer rows.Close() + cards := make([]domain.Card, 0) + for rows.Next() { + card, err := scanCard(rows) + if err != nil { + return nil, err + } + cards = append(cards, card) + } + return cards, rows.Err() +} + +func Card(ctx context.Context, q DBTX, id int64) (domain.Card, error) { + row := q.QueryRowContext(ctx, `SELECT id, list_id, title, description, position, done, created_at, updated_at + FROM cards WHERE id = ?`, id) + card, err := scanCard(row) + if err == sql.ErrNoRows { + return domain.Card{}, domain.ErrNotFound + } + return card, err +} + +type scanner interface{ Scan(...any) error } + +func scanCard(row scanner) (domain.Card, error) { + var card domain.Card + var done int + err := row.Scan(&card.ID, &card.ListID, &card.Title, &card.Description, &card.Position, &done, &card.CreatedAt, &card.UpdatedAt) + card.Done = done != 0 + return card, err +} + +func Snapshot(ctx context.Context, q DBTX) (domain.Snapshot, error) { + lists, err := Lists(ctx, q, false) + if err != nil { + return domain.Snapshot{}, err + } + snapshot := domain.Snapshot{Lists: make([]domain.ListWithCards, 0, len(lists))} + for _, list := range lists { + cards, err := Cards(ctx, q, list.ID) + if err != nil { + return domain.Snapshot{}, err + } + snapshot.Lists = append(snapshot.Lists, domain.ListWithCards{ID: list.ID, Name: list.Name, Position: list.Position, Cards: cards}) + } + return snapshot, nil +} + +func MaxListPosition(ctx context.Context, q DBTX) (float64, error) { + var position float64 + err := q.QueryRowContext(ctx, "SELECT COALESCE(MAX(position), 0) FROM lists").Scan(&position) + return position, err +} + +func MaxCardPosition(ctx context.Context, q DBTX, listID int64) (float64, error) { + var position float64 + err := q.QueryRowContext(ctx, "SELECT COALESCE(MAX(position), 0) FROM cards WHERE list_id = ?", listID).Scan(&position) + return position, err +} + +func CountLists(ctx context.Context, q DBTX) (int, error) { + var count int + err := q.QueryRowContext(ctx, "SELECT COUNT(*) FROM lists").Scan(&count) + return count, err +} + +func MustRows(result sql.Result, err error) error { + if err != nil { + return err + } + n, err := result.RowsAffected() + if err != nil { + return err + } + if n == 0 { + return domain.ErrNotFound + } + return nil +} + +func Wrap(action string, err error) error { + if err == nil || err == domain.ErrNotFound { + return err + } + return fmt.Errorf("%s: %w", action, err) +} diff --git a/internal/store/sqlite_test.go b/internal/store/sqlite_test.go new file mode 100644 index 0000000..ca2342a --- /dev/null +++ b/internal/store/sqlite_test.go @@ -0,0 +1,29 @@ +package store_test + +import ( + "context" + "path/filepath" + "testing" + + "havenllo/internal/database" + "havenllo/internal/store" +) + +func TestSnapshotUsesPositionOrder(t *testing.T) { + t.Parallel() + db, err := database.Open(context.Background(), filepath.Join(t.TempDir(), "havenllo.db")) + if err != nil { + t.Fatal(err) + } + defer db.Close() + if _, err := db.Exec("INSERT INTO lists (name, position) VALUES ('First', 1), ('Last', 9999)"); err != nil { + t.Fatal(err) + } + snapshot, err := store.Snapshot(context.Background(), db) + if err != nil { + t.Fatal(err) + } + if len(snapshot.Lists) != 5 || snapshot.Lists[0].Name != "First" || snapshot.Lists[len(snapshot.Lists)-1].Name != "Last" { + t.Fatalf("unexpected order: %#v", snapshot.Lists) + } +} diff --git a/web/dist/.gitkeep b/web/dist/.gitkeep new file mode 100644 index 0000000..8b13789 --- /dev/null +++ b/web/dist/.gitkeep @@ -0,0 +1 @@ + diff --git a/web/embed.go b/web/embed.go new file mode 100644 index 0000000..7e94883 --- /dev/null +++ b/web/embed.go @@ -0,0 +1,20 @@ +package web + +import ( + "embed" + "io/fs" +) + +//go:embed all:dist +var embedded embed.FS + +// Files contains the compiled Vite bundle without its dist path prefix. +var Files = mustSub(embedded, "dist") + +func mustSub(source fs.FS, directory string) fs.FS { + files, err := fs.Sub(source, directory) + if err != nil { + panic(err) + } + return files +} diff --git a/web/index.html b/web/index.html new file mode 100644 index 0000000..0541824 --- /dev/null +++ b/web/index.html @@ -0,0 +1,15 @@ + + + + + + + + Havenllo + + +
+ + + + diff --git a/web/package-lock.json b/web/package-lock.json new file mode 100644 index 0000000..8561e10 --- /dev/null +++ b/web/package-lock.json @@ -0,0 +1,2120 @@ +{ + "name": "havenllo-web", + "version": "0.1.0", + "lockfileVersion": 3, + "requires": true, + "packages": { + "": { + "name": "havenllo-web", + "version": "0.1.0", + "dependencies": { + "preact": "^10.26.4" + }, + "devDependencies": { + "@preact/preset-vite": "^2.10.1", + "typescript": "^5.8.3", + "vite": "^6.3.5" + } + }, + "node_modules/@babel/code-frame": { + "version": "7.29.7", + "resolved": "https://registry.npmjs.org/@babel/code-frame/-/code-frame-7.29.7.tgz", + "integrity": "sha512-Aup7aUOfpbAUg2ROOJN6Iw5f9DMBlzu0mIkm/malLQFN/YQgO48wCj0Kxa3sEHJvPVFg7siR+qRInwXd2qhQKw==", + "dev": true, + "license": "MIT", + "dependencies": { + "@babel/helper-validator-identifier": "^7.29.7", + "js-tokens": "^4.0.0", + "picocolors": "^1.1.1" + }, + "engines": { + "node": ">=6.9.0" + } + }, + "node_modules/@babel/compat-data": { + "version": "7.29.7", + "resolved": "https://registry.npmjs.org/@babel/compat-data/-/compat-data-7.29.7.tgz", + "integrity": "sha512-locTkQyKvwIEgBzVrn8693ebc97F2U8ZHjbXwDXJ5Fn2TCpNwTlKcaKLkdHop5c/icOFE7qt7Q9JC5hnKNa6Gg==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=6.9.0" + } + }, + "node_modules/@babel/core": { + "version": "7.29.7", + "resolved": "https://registry.npmjs.org/@babel/core/-/core-7.29.7.tgz", + "integrity": "sha512-RgHBCvtjbOK2gXSNBNIkNoEc9qoVEtau3hj8gEqKQuL3HZAibKarWFEI3Lfm6EYKkLalOh8eSrj9b+ch9H/VBA==", + "dev": true, + "license": "MIT", + "dependencies": { + "@babel/code-frame": "^7.29.7", + "@babel/generator": "^7.29.7", + "@babel/helper-compilation-targets": "^7.29.7", + "@babel/helper-module-transforms": "^7.29.7", + "@babel/helpers": "^7.29.7", + "@babel/parser": "^7.29.7", + "@babel/template": "^7.29.7", + "@babel/traverse": "^7.29.7", + "@babel/types": "^7.29.7", + "@jridgewell/remapping": "^2.3.5", + "convert-source-map": "^2.0.0", + "debug": "^4.1.0", + "gensync": "^1.0.0-beta.2", + "json5": "^2.2.3", + "semver": "^6.3.1" + }, + "engines": { + "node": ">=6.9.0" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/babel" + } + }, + "node_modules/@babel/generator": { + "version": "7.29.7", + "resolved": "https://registry.npmjs.org/@babel/generator/-/generator-7.29.7.tgz", + "integrity": "sha512-DkXD5OJQaAQIdZ1bt3UZdEnHAn9Imd3IVBdX03UFe+ony9Ojw5pzr9YVKGDY1jt+Gcn/FnGkNf8r+Vj5NOJWtQ==", + "dev": true, + "license": "MIT", + "dependencies": { + "@babel/parser": "^7.29.7", + "@babel/types": "^7.29.7", + "@jridgewell/gen-mapping": "^0.3.12", + "@jridgewell/trace-mapping": "^0.3.28", + "jsesc": "^3.0.2" + }, + "engines": { + "node": ">=6.9.0" + } + }, + "node_modules/@babel/helper-annotate-as-pure": { + "version": "7.29.7", + "resolved": "https://registry.npmjs.org/@babel/helper-annotate-as-pure/-/helper-annotate-as-pure-7.29.7.tgz", + "integrity": "sha512-OoK6239jHPuSQOoS0kfTVKn0b/rVTk0seKq4Gd2UMLtmOVLjDC0ki3e+c90Trqv2gMfvJFqkiljrr568+qddiw==", + "dev": true, + "license": "MIT", + "dependencies": { + "@babel/types": "^7.29.7" + }, + "engines": { + "node": ">=6.9.0" + } + }, + "node_modules/@babel/helper-compilation-targets": { + "version": "7.29.7", + "resolved": "https://registry.npmjs.org/@babel/helper-compilation-targets/-/helper-compilation-targets-7.29.7.tgz", + "integrity": "sha512-wem6WaBj4NaVYVdNhLPPVacES6ZJ+KBBfSkTMD3YZxbP3rm3Di85tJU5ljaUNhaOynt+Aj0xruhYuzQBt8n71g==", + "dev": true, + "license": "MIT", + "dependencies": { + "@babel/compat-data": "^7.29.7", + "@babel/helper-validator-option": "^7.29.7", + "browserslist": "^4.24.0", + "lru-cache": "^5.1.1", + "semver": "^6.3.1" + }, + "engines": { + "node": ">=6.9.0" + } + }, + "node_modules/@babel/helper-globals": { + "version": "7.29.7", + "resolved": "https://registry.npmjs.org/@babel/helper-globals/-/helper-globals-7.29.7.tgz", + "integrity": "sha512-3nQVUAtvkKH9zahfWgw96Jc/uFOmjACE1kQz82E2lqWmHBgjzbNlsC22nuQTfahmWeQtTq5nQ/4Nnd2A1wj4zA==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=6.9.0" + } + }, + "node_modules/@babel/helper-module-imports": { + "version": "7.29.7", + "resolved": "https://registry.npmjs.org/@babel/helper-module-imports/-/helper-module-imports-7.29.7.tgz", + "integrity": "sha512-ejHwrQQYcm9xnTivShn2IDOlIzInN34AXskvq9QicvCtEzq1Vzclu/tKF8Jq1Cg8JG2GL6/EmjgsCT7lXepE3g==", + "dev": true, + "license": "MIT", + "dependencies": { + "@babel/traverse": "^7.29.7", + "@babel/types": "^7.29.7" + }, + "engines": { + "node": ">=6.9.0" + } + }, + "node_modules/@babel/helper-module-transforms": { + "version": "7.29.7", + "resolved": "https://registry.npmjs.org/@babel/helper-module-transforms/-/helper-module-transforms-7.29.7.tgz", + "integrity": "sha512-UPUVSyXbOh627KiCIGQSgwWzGeBKLkaJ9PJEdrngIwMSzxLR4jS4+f1f1jb7VzBbg8nFLaYotvVPFCTqdrmTAg==", + "dev": true, + "license": "MIT", + "dependencies": { + "@babel/helper-module-imports": "^7.29.7", + "@babel/helper-validator-identifier": "^7.29.7", + "@babel/traverse": "^7.29.7" + }, + "engines": { + "node": ">=6.9.0" + }, + "peerDependencies": { + "@babel/core": "^7.0.0" + } + }, + "node_modules/@babel/helper-plugin-utils": { + "version": "7.29.7", + "resolved": "https://registry.npmjs.org/@babel/helper-plugin-utils/-/helper-plugin-utils-7.29.7.tgz", + "integrity": "sha512-G7sHYigPY17oO5SYWnfD/0MTBwVR781S/JI643e/JhUYgVgWE/61SoW3NH9KWUKyKq5LVh3npif99Wkt6j86Jw==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=6.9.0" + } + }, + "node_modules/@babel/helper-string-parser": { + "version": "7.29.7", + "resolved": "https://registry.npmjs.org/@babel/helper-string-parser/-/helper-string-parser-7.29.7.tgz", + "integrity": "sha512-Pb5ijPrZ89GDH8223L4UP8i6QApWxs04RbPQJTeWDV0/keR2E36MeKnyr6LYmUUvqRRI+Iv87SuF1W6ErINzYw==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=6.9.0" + } + }, + "node_modules/@babel/helper-validator-identifier": { + "version": "7.29.7", + "resolved": "https://registry.npmjs.org/@babel/helper-validator-identifier/-/helper-validator-identifier-7.29.7.tgz", + "integrity": "sha512-qehxGkRj55h/ff8EMaJ+cYhyaKlHIxqYDn682wQD7RNp9UujOQsHog2uS0r2vzr4pW+sXf90NeeayjcNaX3fFg==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=6.9.0" + } + }, + "node_modules/@babel/helper-validator-option": { + "version": "7.29.7", + "resolved": "https://registry.npmjs.org/@babel/helper-validator-option/-/helper-validator-option-7.29.7.tgz", + "integrity": "sha512-N9ZErrD+yW5geCDtBqnOoxmR8+tNKiGuxKlDpuJxfsqpa2dFcexaziGAE/qoHLiDDreVNMupxGmSoNlyvsA3gw==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=6.9.0" + } + }, + "node_modules/@babel/helpers": { + "version": "7.29.7", + "resolved": "https://registry.npmjs.org/@babel/helpers/-/helpers-7.29.7.tgz", + "integrity": "sha512-1k2lAGRMfHTcwuNYcCNUmaUffmQv8KWMfh2iJUUeRlwlwH4FdNG7mfPI10NPfLHJFThE4Tyr4mv7kTNZOiPuBg==", + "dev": true, + "license": "MIT", + "dependencies": { + "@babel/template": "^7.29.7", + "@babel/types": "^7.29.7" + }, + "engines": { + "node": ">=6.9.0" + } + }, + "node_modules/@babel/parser": { + "version": "7.29.7", + "resolved": "https://registry.npmjs.org/@babel/parser/-/parser-7.29.7.tgz", + "integrity": "sha512-hnORnjP/1P/zFEndoeX+n+t1RwWRJiJpM/jO7FW32Kn9r5+sJB2JWOdYo4L6k78j15eCwY3Gm/7364B1EMwtNg==", + "dev": true, + "license": "MIT", + "dependencies": { + "@babel/types": "^7.29.7" + }, + "bin": { + "parser": "bin/babel-parser.js" + }, + "engines": { + "node": ">=6.0.0" + } + }, + "node_modules/@babel/plugin-syntax-jsx": { + "version": "7.29.7", + "resolved": "https://registry.npmjs.org/@babel/plugin-syntax-jsx/-/plugin-syntax-jsx-7.29.7.tgz", + "integrity": "sha512-TSu8+mHCoEaaCDEZ0I3+6mvTBYR4PCxQwf2z9/r5Tbztv6NaLR3B9thGTTxX2WGuGHJqRiAbKPeGTJ5XWXVg6A==", + "dev": true, + "license": "MIT", + "dependencies": { + "@babel/helper-plugin-utils": "^7.29.7" + }, + "engines": { + "node": ">=6.9.0" + }, + "peerDependencies": { + "@babel/core": "^7.0.0-0" + } + }, + "node_modules/@babel/plugin-transform-react-jsx": { + "version": "7.29.7", + "resolved": "https://registry.npmjs.org/@babel/plugin-transform-react-jsx/-/plugin-transform-react-jsx-7.29.7.tgz", + "integrity": "sha512-WsZulLVBUHXVj2cUcPVx6UE21TpalB6bHbSFErKT0Ib++ax24jjXe73FqlWvdylFOjiuPHYi6VCcgRad1ItN+A==", + "dev": true, + "license": "MIT", + "dependencies": { + "@babel/helper-annotate-as-pure": "^7.29.7", + "@babel/helper-module-imports": "^7.29.7", + "@babel/helper-plugin-utils": "^7.29.7", + "@babel/plugin-syntax-jsx": "^7.29.7", + "@babel/types": "^7.29.7" + }, + "engines": { + "node": ">=6.9.0" + }, + "peerDependencies": { + "@babel/core": "^7.0.0-0" + } + }, + "node_modules/@babel/plugin-transform-react-jsx-development": { + "version": "7.29.7", + "resolved": "https://registry.npmjs.org/@babel/plugin-transform-react-jsx-development/-/plugin-transform-react-jsx-development-7.29.7.tgz", + "integrity": "sha512-Xfy3UVMF04+ypnFbkhvfqtmvwfe92qwQdbGZVonhE+6v35GzlofmOnA1szaZqzb9xYWr0nl1e5EMmzi0DNON1g==", + "dev": true, + "license": "MIT", + "dependencies": { + "@babel/plugin-transform-react-jsx": "^7.29.7" + }, + "engines": { + "node": ">=6.9.0" + }, + "peerDependencies": { + "@babel/core": "^7.0.0-0" + } + }, + "node_modules/@babel/template": { + "version": "7.29.7", + "resolved": "https://registry.npmjs.org/@babel/template/-/template-7.29.7.tgz", + "integrity": "sha512-puq+Gf35oI24FeN11LkoUQFqv9uwNeWpxXZi/Ji3rRIoKAzKnxRaZ+Gkj0vKS9ZCiTESfng1N9LyOyXvo+m+Gg==", + "dev": true, + "license": "MIT", + "dependencies": { + "@babel/code-frame": "^7.29.7", + "@babel/parser": "^7.29.7", + "@babel/types": "^7.29.7" + }, + "engines": { + "node": ">=6.9.0" + } + }, + "node_modules/@babel/traverse": { + "version": "7.29.7", + "resolved": "https://registry.npmjs.org/@babel/traverse/-/traverse-7.29.7.tgz", + "integrity": "sha512-EhlfNQtZ+NK22w5BM61ciuiq1m58ed33Wr1Xan//ZRTy6hgjnwyCffRYwzsGXdASJSUJ1guZILsErh1eQcl+zw==", + "dev": true, + "license": "MIT", + "dependencies": { + "@babel/code-frame": "^7.29.7", + "@babel/generator": "^7.29.7", + "@babel/helper-globals": "^7.29.7", + "@babel/parser": "^7.29.7", + "@babel/template": "^7.29.7", + "@babel/types": "^7.29.7", + "debug": "^4.3.1" + }, + "engines": { + "node": ">=6.9.0" + } + }, + "node_modules/@babel/types": { + "version": "7.29.7", + "resolved": "https://registry.npmjs.org/@babel/types/-/types-7.29.7.tgz", + "integrity": "sha512-4zBIxpPzowiZpusoFkyGVwakdRJUyuH5PxQ/PrqghfdFWWasvnCdPfQXHrenDai+gyLARulZjZowCOj6fjT4pA==", + "dev": true, + "license": "MIT", + "dependencies": { + "@babel/helper-string-parser": "^7.29.7", + "@babel/helper-validator-identifier": "^7.29.7" + }, + "engines": { + "node": ">=6.9.0" + } + }, + "node_modules/@esbuild/aix-ppc64": { + "version": "0.25.12", + "resolved": "https://registry.npmjs.org/@esbuild/aix-ppc64/-/aix-ppc64-0.25.12.tgz", + "integrity": "sha512-Hhmwd6CInZ3dwpuGTF8fJG6yoWmsToE+vYgD4nytZVxcu1ulHpUQRAB1UJ8+N1Am3Mz4+xOByoQoSZf4D+CpkA==", + "cpu": [ + "ppc64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "aix" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/@esbuild/android-arm": { + "version": "0.25.12", + "resolved": "https://registry.npmjs.org/@esbuild/android-arm/-/android-arm-0.25.12.tgz", + "integrity": "sha512-VJ+sKvNA/GE7Ccacc9Cha7bpS8nyzVv0jdVgwNDaR4gDMC/2TTRc33Ip8qrNYUcpkOHUT5OZ0bUcNNVZQ9RLlg==", + "cpu": [ + "arm" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "android" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/@esbuild/android-arm64": { + "version": "0.25.12", + "resolved": "https://registry.npmjs.org/@esbuild/android-arm64/-/android-arm64-0.25.12.tgz", + "integrity": "sha512-6AAmLG7zwD1Z159jCKPvAxZd4y/VTO0VkprYy+3N2FtJ8+BQWFXU+OxARIwA46c5tdD9SsKGZ/1ocqBS/gAKHg==", + "cpu": [ + "arm64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "android" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/@esbuild/android-x64": { + "version": "0.25.12", + "resolved": "https://registry.npmjs.org/@esbuild/android-x64/-/android-x64-0.25.12.tgz", + "integrity": "sha512-5jbb+2hhDHx5phYR2By8GTWEzn6I9UqR11Kwf22iKbNpYrsmRB18aX/9ivc5cabcUiAT/wM+YIZ6SG9QO6a8kg==", + "cpu": [ + "x64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "android" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/@esbuild/darwin-arm64": { + "version": "0.25.12", + "resolved": "https://registry.npmjs.org/@esbuild/darwin-arm64/-/darwin-arm64-0.25.12.tgz", + "integrity": "sha512-N3zl+lxHCifgIlcMUP5016ESkeQjLj/959RxxNYIthIg+CQHInujFuXeWbWMgnTo4cp5XVHqFPmpyu9J65C1Yg==", + "cpu": [ + "arm64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "darwin" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/@esbuild/darwin-x64": { + "version": "0.25.12", + "resolved": "https://registry.npmjs.org/@esbuild/darwin-x64/-/darwin-x64-0.25.12.tgz", + "integrity": "sha512-HQ9ka4Kx21qHXwtlTUVbKJOAnmG1ipXhdWTmNXiPzPfWKpXqASVcWdnf2bnL73wgjNrFXAa3yYvBSd9pzfEIpA==", + "cpu": [ + "x64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "darwin" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/@esbuild/freebsd-arm64": { + "version": "0.25.12", + "resolved": "https://registry.npmjs.org/@esbuild/freebsd-arm64/-/freebsd-arm64-0.25.12.tgz", + "integrity": "sha512-gA0Bx759+7Jve03K1S0vkOu5Lg/85dou3EseOGUes8flVOGxbhDDh/iZaoek11Y8mtyKPGF3vP8XhnkDEAmzeg==", + "cpu": [ + "arm64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "freebsd" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/@esbuild/freebsd-x64": { + "version": "0.25.12", + "resolved": "https://registry.npmjs.org/@esbuild/freebsd-x64/-/freebsd-x64-0.25.12.tgz", + "integrity": "sha512-TGbO26Yw2xsHzxtbVFGEXBFH0FRAP7gtcPE7P5yP7wGy7cXK2oO7RyOhL5NLiqTlBh47XhmIUXuGciXEqYFfBQ==", + "cpu": [ + "x64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "freebsd" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/@esbuild/linux-arm": { + "version": "0.25.12", + "resolved": "https://registry.npmjs.org/@esbuild/linux-arm/-/linux-arm-0.25.12.tgz", + "integrity": "sha512-lPDGyC1JPDou8kGcywY0YILzWlhhnRjdof3UlcoqYmS9El818LLfJJc3PXXgZHrHCAKs/Z2SeZtDJr5MrkxtOw==", + "cpu": [ + "arm" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/@esbuild/linux-arm64": { + "version": "0.25.12", + "resolved": "https://registry.npmjs.org/@esbuild/linux-arm64/-/linux-arm64-0.25.12.tgz", + "integrity": "sha512-8bwX7a8FghIgrupcxb4aUmYDLp8pX06rGh5HqDT7bB+8Rdells6mHvrFHHW2JAOPZUbnjUpKTLg6ECyzvas2AQ==", + "cpu": [ + "arm64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/@esbuild/linux-ia32": { + "version": "0.25.12", + "resolved": "https://registry.npmjs.org/@esbuild/linux-ia32/-/linux-ia32-0.25.12.tgz", + "integrity": "sha512-0y9KrdVnbMM2/vG8KfU0byhUN+EFCny9+8g202gYqSSVMonbsCfLjUO+rCci7pM0WBEtz+oK/PIwHkzxkyharA==", + "cpu": [ + "ia32" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/@esbuild/linux-loong64": { + "version": "0.25.12", + "resolved": "https://registry.npmjs.org/@esbuild/linux-loong64/-/linux-loong64-0.25.12.tgz", + "integrity": "sha512-h///Lr5a9rib/v1GGqXVGzjL4TMvVTv+s1DPoxQdz7l/AYv6LDSxdIwzxkrPW438oUXiDtwM10o9PmwS/6Z0Ng==", + "cpu": [ + "loong64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/@esbuild/linux-mips64el": { + "version": "0.25.12", + "resolved": "https://registry.npmjs.org/@esbuild/linux-mips64el/-/linux-mips64el-0.25.12.tgz", + "integrity": "sha512-iyRrM1Pzy9GFMDLsXn1iHUm18nhKnNMWscjmp4+hpafcZjrr2WbT//d20xaGljXDBYHqRcl8HnxbX6uaA/eGVw==", + "cpu": [ + "mips64el" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/@esbuild/linux-ppc64": { + "version": "0.25.12", + "resolved": "https://registry.npmjs.org/@esbuild/linux-ppc64/-/linux-ppc64-0.25.12.tgz", + "integrity": "sha512-9meM/lRXxMi5PSUqEXRCtVjEZBGwB7P/D4yT8UG/mwIdze2aV4Vo6U5gD3+RsoHXKkHCfSxZKzmDssVlRj1QQA==", + "cpu": [ + "ppc64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/@esbuild/linux-riscv64": { + "version": "0.25.12", + "resolved": "https://registry.npmjs.org/@esbuild/linux-riscv64/-/linux-riscv64-0.25.12.tgz", + "integrity": "sha512-Zr7KR4hgKUpWAwb1f3o5ygT04MzqVrGEGXGLnj15YQDJErYu/BGg+wmFlIDOdJp0PmB0lLvxFIOXZgFRrdjR0w==", + "cpu": [ + "riscv64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/@esbuild/linux-s390x": { + "version": "0.25.12", + "resolved": "https://registry.npmjs.org/@esbuild/linux-s390x/-/linux-s390x-0.25.12.tgz", + "integrity": "sha512-MsKncOcgTNvdtiISc/jZs/Zf8d0cl/t3gYWX8J9ubBnVOwlk65UIEEvgBORTiljloIWnBzLs4qhzPkJcitIzIg==", + "cpu": [ + "s390x" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/@esbuild/linux-x64": { + "version": "0.25.12", + "resolved": "https://registry.npmjs.org/@esbuild/linux-x64/-/linux-x64-0.25.12.tgz", + "integrity": "sha512-uqZMTLr/zR/ed4jIGnwSLkaHmPjOjJvnm6TVVitAa08SLS9Z0VM8wIRx7gWbJB5/J54YuIMInDquWyYvQLZkgw==", + "cpu": [ + "x64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/@esbuild/netbsd-arm64": { + "version": "0.25.12", + "resolved": "https://registry.npmjs.org/@esbuild/netbsd-arm64/-/netbsd-arm64-0.25.12.tgz", + "integrity": "sha512-xXwcTq4GhRM7J9A8Gv5boanHhRa/Q9KLVmcyXHCTaM4wKfIpWkdXiMog/KsnxzJ0A1+nD+zoecuzqPmCRyBGjg==", + "cpu": [ + "arm64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "netbsd" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/@esbuild/netbsd-x64": { + "version": "0.25.12", + "resolved": "https://registry.npmjs.org/@esbuild/netbsd-x64/-/netbsd-x64-0.25.12.tgz", + "integrity": "sha512-Ld5pTlzPy3YwGec4OuHh1aCVCRvOXdH8DgRjfDy/oumVovmuSzWfnSJg+VtakB9Cm0gxNO9BzWkj6mtO1FMXkQ==", + "cpu": [ + "x64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "netbsd" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/@esbuild/openbsd-arm64": { + "version": "0.25.12", + "resolved": "https://registry.npmjs.org/@esbuild/openbsd-arm64/-/openbsd-arm64-0.25.12.tgz", + "integrity": "sha512-fF96T6KsBo/pkQI950FARU9apGNTSlZGsv1jZBAlcLL1MLjLNIWPBkj5NlSz8aAzYKg+eNqknrUJ24QBybeR5A==", + "cpu": [ + "arm64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "openbsd" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/@esbuild/openbsd-x64": { + "version": "0.25.12", + "resolved": "https://registry.npmjs.org/@esbuild/openbsd-x64/-/openbsd-x64-0.25.12.tgz", + "integrity": "sha512-MZyXUkZHjQxUvzK7rN8DJ3SRmrVrke8ZyRusHlP+kuwqTcfWLyqMOE3sScPPyeIXN/mDJIfGXvcMqCgYKekoQw==", + "cpu": [ + "x64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "openbsd" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/@esbuild/openharmony-arm64": { + "version": "0.25.12", + "resolved": "https://registry.npmjs.org/@esbuild/openharmony-arm64/-/openharmony-arm64-0.25.12.tgz", + "integrity": "sha512-rm0YWsqUSRrjncSXGA7Zv78Nbnw4XL6/dzr20cyrQf7ZmRcsovpcRBdhD43Nuk3y7XIoW2OxMVvwuRvk9XdASg==", + "cpu": [ + "arm64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "openharmony" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/@esbuild/sunos-x64": { + "version": "0.25.12", + "resolved": "https://registry.npmjs.org/@esbuild/sunos-x64/-/sunos-x64-0.25.12.tgz", + "integrity": "sha512-3wGSCDyuTHQUzt0nV7bocDy72r2lI33QL3gkDNGkod22EsYl04sMf0qLb8luNKTOmgF/eDEDP5BFNwoBKH441w==", + "cpu": [ + "x64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "sunos" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/@esbuild/win32-arm64": { + "version": "0.25.12", + "resolved": "https://registry.npmjs.org/@esbuild/win32-arm64/-/win32-arm64-0.25.12.tgz", + "integrity": "sha512-rMmLrur64A7+DKlnSuwqUdRKyd3UE7oPJZmnljqEptesKM8wx9J8gx5u0+9Pq0fQQW8vqeKebwNXdfOyP+8Bsg==", + "cpu": [ + "arm64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "win32" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/@esbuild/win32-ia32": { + "version": "0.25.12", + "resolved": "https://registry.npmjs.org/@esbuild/win32-ia32/-/win32-ia32-0.25.12.tgz", + "integrity": "sha512-HkqnmmBoCbCwxUKKNPBixiWDGCpQGVsrQfJoVGYLPT41XWF8lHuE5N6WhVia2n4o5QK5M4tYr21827fNhi4byQ==", + "cpu": [ + "ia32" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "win32" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/@esbuild/win32-x64": { + "version": "0.25.12", + "resolved": "https://registry.npmjs.org/@esbuild/win32-x64/-/win32-x64-0.25.12.tgz", + "integrity": "sha512-alJC0uCZpTFrSL0CCDjcgleBXPnCrEAhTBILpeAp7M/OFgoqtAetfBzX0xM00MUsVVPpVjlPuMbREqnZCXaTnA==", + "cpu": [ + "x64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "win32" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/@jridgewell/gen-mapping": { + "version": "0.3.13", + "resolved": "https://registry.npmjs.org/@jridgewell/gen-mapping/-/gen-mapping-0.3.13.tgz", + "integrity": "sha512-2kkt/7niJ6MgEPxF0bYdQ6etZaA+fQvDcLKckhy1yIQOzaoKjBBjSj63/aLVjYE3qhRt5dvM+uUyfCg6UKCBbA==", + "dev": true, + "license": "MIT", + "dependencies": { + "@jridgewell/sourcemap-codec": "^1.5.0", + "@jridgewell/trace-mapping": "^0.3.24" + } + }, + "node_modules/@jridgewell/remapping": { + "version": "2.3.5", + "resolved": "https://registry.npmjs.org/@jridgewell/remapping/-/remapping-2.3.5.tgz", + "integrity": "sha512-LI9u/+laYG4Ds1TDKSJW2YPrIlcVYOwi2fUC6xB43lueCjgxV4lffOCZCtYFiH6TNOX+tQKXx97T4IKHbhyHEQ==", + "dev": true, + "license": "MIT", + "dependencies": { + "@jridgewell/gen-mapping": "^0.3.5", + "@jridgewell/trace-mapping": "^0.3.24" + } + }, + "node_modules/@jridgewell/resolve-uri": { + "version": "3.1.2", + "resolved": "https://registry.npmjs.org/@jridgewell/resolve-uri/-/resolve-uri-3.1.2.tgz", + "integrity": "sha512-bRISgCIjP20/tbWSPWMEi54QVPRZExkuD9lJL+UIxUKtwVJA8wW1Trb1jMs1RFXo1CBTNZ/5hpC9QvmKWdopKw==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=6.0.0" + } + }, + "node_modules/@jridgewell/sourcemap-codec": { + "version": "1.5.5", + "resolved": "https://registry.npmjs.org/@jridgewell/sourcemap-codec/-/sourcemap-codec-1.5.5.tgz", + "integrity": "sha512-cYQ9310grqxueWbl+WuIUIaiUaDcj7WOq5fVhEljNVgRfOUhY9fy2zTvfoqWsnebh8Sl70VScFbICvJnLKB0Og==", + "dev": true, + "license": "MIT" + }, + "node_modules/@jridgewell/trace-mapping": { + "version": "0.3.31", + "resolved": "https://registry.npmjs.org/@jridgewell/trace-mapping/-/trace-mapping-0.3.31.tgz", + "integrity": "sha512-zzNR+SdQSDJzc8joaeP8QQoCQr8NuYx2dIIytl1QeBEZHJ9uW6hebsrYgbz8hJwUQao3TWCMtmfV8Nu1twOLAw==", + "dev": true, + "license": "MIT", + "dependencies": { + "@jridgewell/resolve-uri": "^3.1.0", + "@jridgewell/sourcemap-codec": "^1.4.14" + } + }, + "node_modules/@preact/preset-vite": { + "version": "2.10.5", + "resolved": "https://registry.npmjs.org/@preact/preset-vite/-/preset-vite-2.10.5.tgz", + "integrity": "sha512-p0vJpxiVO7KWWazWny3LUZ+saXyZKWv6Ju0bYMWNJRp2YveufRPgSUB1C4MTqGJfz07EehMgfN+AJNwQy+w6Iw==", + "dev": true, + "license": "MIT", + "dependencies": { + "@babel/plugin-transform-react-jsx": "^7.27.1", + "@babel/plugin-transform-react-jsx-development": "^7.27.1", + "@prefresh/vite": "^2.4.11", + "@rollup/pluginutils": "^5.0.0", + "babel-plugin-transform-hook-names": "^1.0.2", + "debug": "^4.4.3", + "magic-string": "^0.30.21", + "picocolors": "^1.1.1", + "vite-prerender-plugin": "^0.5.8", + "zimmerframe": "^1.1.4" + }, + "peerDependencies": { + "@babel/core": "7.x", + "vite": "2.x || 3.x || 4.x || 5.x || 6.x || 7.x || 8.x" + } + }, + "node_modules/@prefresh/babel-plugin": { + "version": "0.5.3", + "resolved": "https://registry.npmjs.org/@prefresh/babel-plugin/-/babel-plugin-0.5.3.tgz", + "integrity": "sha512-57LX2SHs4BX2s1IwCjNzTE2OJeEepRCNf1VTEpbNcUyHfMO68eeOWGDIt4ob9aYlW6PEWZ1SuwNikuoIXANDtQ==", + "dev": true, + "license": "MIT" + }, + "node_modules/@prefresh/core": { + "version": "1.5.10", + "resolved": "https://registry.npmjs.org/@prefresh/core/-/core-1.5.10.tgz", + "integrity": "sha512-7yPTFbG56sutaFu8krp3B4a200KOFUvrtlllKWRuLjsYXo9UUucHOZRcer+gtgMkFTpv6ob8TGcTwA32bSwa1w==", + "dev": true, + "license": "MIT", + "peerDependencies": { + "preact": "^10.0.0 || ^11.0.0-0" + } + }, + "node_modules/@prefresh/utils": { + "version": "1.2.1", + "resolved": "https://registry.npmjs.org/@prefresh/utils/-/utils-1.2.1.tgz", + "integrity": "sha512-vq/sIuN5nYfYzvyayXI4C2QkprfNaHUQ9ZX+3xLD8nL3rWyzpxOm1+K7RtMbhd+66QcaISViK7amjnheQ/4WZw==", + "dev": true, + "license": "MIT" + }, + "node_modules/@prefresh/vite": { + "version": "2.4.12", + "resolved": "https://registry.npmjs.org/@prefresh/vite/-/vite-2.4.12.tgz", + "integrity": "sha512-FY1fzXpUjiuosznMV0YM7XAOPZjB5FIdWS0W24+XnlxYkt9hNAwwsiKYn+cuTEoMtD/ZVazS5QVssBr9YhpCQA==", + "dev": true, + "license": "MIT", + "dependencies": { + "@babel/core": "^7.22.1", + "@prefresh/babel-plugin": "^0.5.2", + "@prefresh/core": "^1.5.0", + "@prefresh/utils": "^1.2.0", + "@rollup/pluginutils": "^4.2.1" + }, + "peerDependencies": { + "preact": "^10.4.0 || ^11.0.0-0", + "vite": ">=2.0.0" + } + }, + "node_modules/@prefresh/vite/node_modules/@rollup/pluginutils": { + "version": "4.2.1", + "resolved": "https://registry.npmjs.org/@rollup/pluginutils/-/pluginutils-4.2.1.tgz", + "integrity": "sha512-iKnFXr7NkdZAIHiIWE+BX5ULi/ucVFYWD6TbAV+rZctiRTY2PL6tsIKhoIOaoskiWAkgu+VsbXgUVDNLHf+InQ==", + "dev": true, + "license": "MIT", + "dependencies": { + "estree-walker": "^2.0.1", + "picomatch": "^2.2.2" + }, + "engines": { + "node": ">= 8.0.0" + } + }, + "node_modules/@prefresh/vite/node_modules/picomatch": { + "version": "2.3.2", + "resolved": "https://registry.npmjs.org/picomatch/-/picomatch-2.3.2.tgz", + "integrity": "sha512-V7+vQEJ06Z+c5tSye8S+nHUfI51xoXIXjHQ99cQtKUkQqqO1kO/KCJUfZXuB47h/YBlDhah2H3hdUGXn8ie0oA==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=8.6" + }, + "funding": { + "url": "https://github.com/sponsors/jonschlinkert" + } + }, + "node_modules/@rollup/pluginutils": { + "version": "5.4.0", + "resolved": "https://registry.npmjs.org/@rollup/pluginutils/-/pluginutils-5.4.0.tgz", + "integrity": "sha512-MfPp06CjRLfXQ3wY0R8vJDYBy/MvVcc9OulEfR0B8Iv9ko+GCNaRZ+EpJYFl27LhKsZK0o420sYCRHCjfCgeUg==", + "dev": true, + "license": "MIT", + "dependencies": { + "@types/estree": "^1.0.0", + "estree-walker": "^2.0.2", + "picomatch": "^4.0.2" + }, + "engines": { + "node": ">=14.0.0" + }, + "peerDependencies": { + "rollup": "^1.20.0||^2.0.0||^3.0.0||^4.0.0" + }, + "peerDependenciesMeta": { + "rollup": { + "optional": true + } + } + }, + "node_modules/@rollup/rollup-android-arm-eabi": { + "version": "4.62.2", + "resolved": "https://registry.npmjs.org/@rollup/rollup-android-arm-eabi/-/rollup-android-arm-eabi-4.62.2.tgz", + "integrity": "sha512-6o7ZLZK+BeenkZCFNDXqpbjw9bD6nuWonvS/lwQJp7NoVVxm6p3qE7qQ5jGuBjiFsgvqjD8mZAU5oWxTmbOeOg==", + "cpu": [ + "arm" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "android" + ] + }, + "node_modules/@rollup/rollup-android-arm64": { + "version": "4.62.2", + "resolved": "https://registry.npmjs.org/@rollup/rollup-android-arm64/-/rollup-android-arm64-4.62.2.tgz", + "integrity": "sha512-BaH7BllCACHoH1LguOU56UItGfUWjujlO65kS9LAodViaN4bwIKd7oeW/ZHJ/4ljr/7MIiENnNy3HJ0zXv8Zkw==", + "cpu": [ + "arm64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "android" + ] + }, + "node_modules/@rollup/rollup-darwin-arm64": { + "version": "4.62.2", + "resolved": "https://registry.npmjs.org/@rollup/rollup-darwin-arm64/-/rollup-darwin-arm64-4.62.2.tgz", + "integrity": "sha512-v39RCCvj4He82I9sFmk+M1VZ0PLM9sfsLVikjfx2hYBNALhrrOR2D3JjQA6AhlaSOgcR+RzrKY7e1+bT6SUO/A==", + "cpu": [ + "arm64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "darwin" + ] + }, + "node_modules/@rollup/rollup-darwin-x64": { + "version": "4.62.2", + "resolved": "https://registry.npmjs.org/@rollup/rollup-darwin-x64/-/rollup-darwin-x64-4.62.2.tgz", + "integrity": "sha512-yl0y2vq3S3lHeuXhEdss6TWfKW8vkujImO12tn4ZkG/4oghr09LvdYm2RElVjokTQiUvDUGXLGsYeLqUMCKpGA==", + "cpu": [ + "x64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "darwin" + ] + }, + "node_modules/@rollup/rollup-freebsd-arm64": { + "version": "4.62.2", + "resolved": "https://registry.npmjs.org/@rollup/rollup-freebsd-arm64/-/rollup-freebsd-arm64-4.62.2.tgz", + "integrity": "sha512-tT4pvt4qXD+vEoezupCWi+a1F0vvDiksiHc+PxRlYTOH1I6/X4id9jPxTP+Fg+545euaFT1jJVs4CEdHZAU1vw==", + "cpu": [ + "arm64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "freebsd" + ] + }, + "node_modules/@rollup/rollup-freebsd-x64": { + "version": "4.62.2", + "resolved": "https://registry.npmjs.org/@rollup/rollup-freebsd-x64/-/rollup-freebsd-x64-4.62.2.tgz", + "integrity": "sha512-6nU5F2wCW+qvCBhTn1pdIU3bzsIoF7EUwsCDRxilWGprQR6yd508YnH9+OKFCwpfS8pjZqDUmnCAr7exax0XCg==", + "cpu": [ + "x64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "freebsd" + ] + }, + "node_modules/@rollup/rollup-linux-arm-gnueabihf": { + "version": "4.62.2", + "resolved": "https://registry.npmjs.org/@rollup/rollup-linux-arm-gnueabihf/-/rollup-linux-arm-gnueabihf-4.62.2.tgz", + "integrity": "sha512-n1GJHPOvpIfhi3TmrCeh6S6URt9BFCt0KQE3qvexyGCTAKpR4Lg+eWvNZEqu7epxwus/8ElT3hacYEucm49SZg==", + "cpu": [ + "arm" + ], + "dev": true, + "libc": [ + "glibc" + ], + "license": "MIT", + "optional": true, + "os": [ + "linux" + ] + }, + "node_modules/@rollup/rollup-linux-arm-musleabihf": { + "version": "4.62.2", + "resolved": "https://registry.npmjs.org/@rollup/rollup-linux-arm-musleabihf/-/rollup-linux-arm-musleabihf-4.62.2.tgz", + "integrity": "sha512-JqgflS8wEB+UXV/vS1RpRbifGBeN4D5lz8D8oOFbFZw4vedvdOgCFAjfBmIMdW3yL10XpQQ0Ambepw6MXrhOnA==", + "cpu": [ + "arm" + ], + "dev": true, + "libc": [ + "musl" + ], + "license": "MIT", + "optional": true, + "os": [ + "linux" + ] + }, + "node_modules/@rollup/rollup-linux-arm64-gnu": { + "version": "4.62.2", + "resolved": "https://registry.npmjs.org/@rollup/rollup-linux-arm64-gnu/-/rollup-linux-arm64-gnu-4.62.2.tgz", + "integrity": "sha512-wnFJkogWvN4jm/hQRF2UBaeUmk20j5+DmHvoyWii2b8HJDyvz1MF2OU/6ynXt2KR63rbZLWkFpoytpdc/yBuSA==", + "cpu": [ + "arm64" + ], + "dev": true, + "libc": [ + "glibc" + ], + "license": "MIT", + "optional": true, + "os": [ + "linux" + ] + }, + "node_modules/@rollup/rollup-linux-arm64-musl": { + "version": "4.62.2", + "resolved": "https://registry.npmjs.org/@rollup/rollup-linux-arm64-musl/-/rollup-linux-arm64-musl-4.62.2.tgz", + "integrity": "sha512-HVu2bp0zhvJ8xHEV9+UUs7S90VadmBSY3LcIMvozbPo4AuMGDWlz3ymHLHZPX4hR67TKTt8Qp5PJ5RBg/i+RMQ==", + "cpu": [ + "arm64" + ], + "dev": true, + "libc": [ + "musl" + ], + "license": "MIT", + "optional": true, + "os": [ + "linux" + ] + }, + "node_modules/@rollup/rollup-linux-loong64-gnu": { + "version": "4.62.2", + "resolved": "https://registry.npmjs.org/@rollup/rollup-linux-loong64-gnu/-/rollup-linux-loong64-gnu-4.62.2.tgz", + "integrity": "sha512-mQqqAV8QaoSgr9I2fKDLY2BAVvmKjWoGiu/cSYQonsLvtqwEn1E4QYfnCOcp5zoEqNhsDYin1s6jx/VJmrxlZg==", + "cpu": [ + "loong64" + ], + "dev": true, + "libc": [ + "glibc" + ], + "license": "MIT", + "optional": true, + "os": [ + "linux" + ] + }, + "node_modules/@rollup/rollup-linux-loong64-musl": { + "version": "4.62.2", + "resolved": "https://registry.npmjs.org/@rollup/rollup-linux-loong64-musl/-/rollup-linux-loong64-musl-4.62.2.tgz", + "integrity": "sha512-IxKLoxCQ2IWi6bT2akyDUBGsOImDKB+sPp4EsTmwFQ/fMwpCKm8uLSSgP/Kx/QYUgKis6SEZ5/Nlhup0DIA0PQ==", + "cpu": [ + "loong64" + ], + "dev": true, + "libc": [ + "musl" + ], + "license": "MIT", + "optional": true, + "os": [ + "linux" + ] + }, + "node_modules/@rollup/rollup-linux-ppc64-gnu": { + "version": "4.62.2", + "resolved": "https://registry.npmjs.org/@rollup/rollup-linux-ppc64-gnu/-/rollup-linux-ppc64-gnu-4.62.2.tgz", + "integrity": "sha512-Mk5ha2RQSgyFfmYYLkBpPnUk8D8FriBxesO1u9O75X0mHgXL1UQcH5Itl2lurWL2tj0RxV9b9tJgipac0hRY9A==", + "cpu": [ + "ppc64" + ], + "dev": true, + "libc": [ + "glibc" + ], + "license": "MIT", + "optional": true, + "os": [ + "linux" + ] + }, + "node_modules/@rollup/rollup-linux-ppc64-musl": { + "version": "4.62.2", + "resolved": "https://registry.npmjs.org/@rollup/rollup-linux-ppc64-musl/-/rollup-linux-ppc64-musl-4.62.2.tgz", + "integrity": "sha512-CjvEnqJL/0/TQ3TXX3OPIJ/kmBellrWd4heXUmHeJlTnmwjKpSJzoehLaL6Xk0ZnMHBu9dZuFADNOrtjF4v+2w==", + "cpu": [ + "ppc64" + ], + "dev": true, + "libc": [ + "musl" + ], + "license": "MIT", + "optional": true, + "os": [ + "linux" + ] + }, + "node_modules/@rollup/rollup-linux-riscv64-gnu": { + "version": "4.62.2", + "resolved": "https://registry.npmjs.org/@rollup/rollup-linux-riscv64-gnu/-/rollup-linux-riscv64-gnu-4.62.2.tgz", + "integrity": "sha512-1SiZbzwdkaDURsew/tSOrooKiYy7EQGT6m8ufavAi9NEyQb/6VuIxFXAL1fqa4iZe3g4NbNk4P7J32z2tw5Mgg==", + "cpu": [ + "riscv64" + ], + "dev": true, + "libc": [ + "glibc" + ], + "license": "MIT", + "optional": true, + "os": [ + "linux" + ] + }, + "node_modules/@rollup/rollup-linux-riscv64-musl": { + "version": "4.62.2", + "resolved": "https://registry.npmjs.org/@rollup/rollup-linux-riscv64-musl/-/rollup-linux-riscv64-musl-4.62.2.tgz", + "integrity": "sha512-nQts12zJ3NQRoE6uYljOH89v7szzLDvG2JD/vsX+vGXU8w/At1GowTZ5/7qeFQ8m7L55rpR8Okugnuo5bgjy2Q==", + "cpu": [ + "riscv64" + ], + "dev": true, + "libc": [ + "musl" + ], + "license": "MIT", + "optional": true, + "os": [ + "linux" + ] + }, + "node_modules/@rollup/rollup-linux-s390x-gnu": { + "version": "4.62.2", + "resolved": "https://registry.npmjs.org/@rollup/rollup-linux-s390x-gnu/-/rollup-linux-s390x-gnu-4.62.2.tgz", + "integrity": "sha512-E9/ll019jhPIJgpzfZoIkBGhcz+kKNgVWYRY0zr9srBdPPFVpvOKW8VaJKUbeK+eZXyQF9ltME+Kk6affeaPgg==", + "cpu": [ + "s390x" + ], + "dev": true, + "libc": [ + "glibc" + ], + "license": "MIT", + "optional": true, + "os": [ + "linux" + ] + }, + "node_modules/@rollup/rollup-linux-x64-gnu": { + "version": "4.62.2", + "resolved": "https://registry.npmjs.org/@rollup/rollup-linux-x64-gnu/-/rollup-linux-x64-gnu-4.62.2.tgz", + "integrity": "sha512-5BqxR/pshjey51iliyzTD5Xi3EN0aLmQ2lZ3lvefVV9c82BvrLo2/6OT55iifpWBufs6kdwWbuOKS841DrmK9A==", + "cpu": [ + "x64" + ], + "dev": true, + "libc": [ + "glibc" + ], + "license": "MIT", + "optional": true, + "os": [ + "linux" + ] + }, + "node_modules/@rollup/rollup-linux-x64-musl": { + "version": "4.62.2", + "resolved": "https://registry.npmjs.org/@rollup/rollup-linux-x64-musl/-/rollup-linux-x64-musl-4.62.2.tgz", + "integrity": "sha512-uNN83XxQrRAh/w0/pmAfibcwyb6YWt4gP+dpnQKPVJshAloQ785ii8CT8ZCIxkGg9opVsvAlGhFitSm6D1Jjpg==", + "cpu": [ + "x64" + ], + "dev": true, + "libc": [ + "musl" + ], + "license": "MIT", + "optional": true, + "os": [ + "linux" + ] + }, + "node_modules/@rollup/rollup-openbsd-x64": { + "version": "4.62.2", + "resolved": "https://registry.npmjs.org/@rollup/rollup-openbsd-x64/-/rollup-openbsd-x64-4.62.2.tgz", + "integrity": "sha512-srjEIxSH3LRnJN6THczDHWQplqEMFiAJrTab0msUryh9kwNpkICf3Ea6q6MN/2cZwRFUNx5w+h6Hpi4QuHS6Zg==", + "cpu": [ + "x64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "openbsd" + ] + }, + "node_modules/@rollup/rollup-openharmony-arm64": { + "version": "4.62.2", + "resolved": "https://registry.npmjs.org/@rollup/rollup-openharmony-arm64/-/rollup-openharmony-arm64-4.62.2.tgz", + "integrity": "sha512-8hOJnxgbyObnCm5AlRA3A931xX19xq80RjVTKgJOvEKWqJruP/Uf12IbAOaDjjEXYRewwHLfmF0YRIdK3OwKWA==", + "cpu": [ + "arm64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "openharmony" + ] + }, + "node_modules/@rollup/rollup-win32-arm64-msvc": { + "version": "4.62.2", + "resolved": "https://registry.npmjs.org/@rollup/rollup-win32-arm64-msvc/-/rollup-win32-arm64-msvc-4.62.2.tgz", + "integrity": "sha512-mmF4AY1i0hG/bLWUctUq59gtmgaSIRa3cu/A3JFRp/sCNEme2bgDEiDS22P9FbnJB8NJNF4jPJiSP5RHQpUTDg==", + "cpu": [ + "arm64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "win32" + ] + }, + "node_modules/@rollup/rollup-win32-ia32-msvc": { + "version": "4.62.2", + "resolved": "https://registry.npmjs.org/@rollup/rollup-win32-ia32-msvc/-/rollup-win32-ia32-msvc-4.62.2.tgz", + "integrity": "sha512-DZgkknc6jhHrk46V25vbAM0zZkyP0nSDkJB8/dRkLTxv470dOmWDqGoEJl/9A0dFfS7yE3REOwNDxpHwSLSt0Q==", + "cpu": [ + "ia32" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "win32" + ] + }, + "node_modules/@rollup/rollup-win32-x64-gnu": { + "version": "4.62.2", + "resolved": "https://registry.npmjs.org/@rollup/rollup-win32-x64-gnu/-/rollup-win32-x64-gnu-4.62.2.tgz", + "integrity": "sha512-T6xr6ucWSFto+VGajA8YH26LdpHRuP4YLHEKAtCWvJDOlnmWcDZVCI2Jmjr+IFHDlt2zRaTAKE4tfjTaWLgJBg==", + "cpu": [ + "x64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "win32" + ] + }, + "node_modules/@rollup/rollup-win32-x64-msvc": { + "version": "4.62.2", + "resolved": "https://registry.npmjs.org/@rollup/rollup-win32-x64-msvc/-/rollup-win32-x64-msvc-4.62.2.tgz", + "integrity": "sha512-BfzEnDJOt9T8M989/lA37EcJgat01wLRnoi5dQf3QzOH7jzpqTAzdDbVfRljVr5r+jzKqpbHeyOfAaXxAd0PAA==", + "cpu": [ + "x64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "win32" + ] + }, + "node_modules/@types/estree": { + "version": "1.0.9", + "resolved": "https://registry.npmjs.org/@types/estree/-/estree-1.0.9.tgz", + "integrity": "sha512-GhdPgy1el4/ImP05X05Uw4cw2/M93BCUmnEvWZNStlCzEKME4Fkk+YpoA5OiHNQmoS7Cafb8Xa3Pya8m1Qrzeg==", + "dev": true, + "license": "MIT" + }, + "node_modules/babel-plugin-transform-hook-names": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/babel-plugin-transform-hook-names/-/babel-plugin-transform-hook-names-1.0.2.tgz", + "integrity": "sha512-5gafyjyyBTTdX/tQQ0hRgu4AhNHG/hqWi0ZZmg2xvs2FgRkJXzDNKBZCyoYqgFkovfDrgM8OoKg8karoUvWeCw==", + "dev": true, + "license": "MIT", + "peerDependencies": { + "@babel/core": "^7.12.10" + } + }, + "node_modules/baseline-browser-mapping": { + "version": "2.10.43", + "resolved": "https://registry.npmjs.org/baseline-browser-mapping/-/baseline-browser-mapping-2.10.43.tgz", + "integrity": "sha512-AjYpR78kDWAY3Efj+cDTFH9t9SCoL7OoTp1BOb0mQV7S+6CiLwnWM3FyxhJtdPufDFKzmCSFoUncKjWgJEZTCQ==", + "dev": true, + "license": "Apache-2.0", + "bin": { + "baseline-browser-mapping": "dist/cli.cjs" + }, + "engines": { + "node": ">=6.0.0" + } + }, + "node_modules/boolbase": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/boolbase/-/boolbase-1.0.0.tgz", + "integrity": "sha512-JZOSA7Mo9sNGB8+UjSgzdLtokWAky1zbztM3WRLCbZ70/3cTANmQmOdR7y2g+J0e2WXywy1yS468tY+IruqEww==", + "dev": true, + "license": "ISC" + }, + "node_modules/browserslist": { + "version": "4.28.6", + "resolved": "https://registry.npmjs.org/browserslist/-/browserslist-4.28.6.tgz", + "integrity": "sha512-FQBYNK15VMslhLHpA7+n+n1GOlF1kId2xcCg7/j95f24AOF6VDYMNH4mFxF7KuaTdv627faazpOAjFzMrfJOUw==", + "dev": true, + "funding": [ + { + "type": "opencollective", + "url": "https://opencollective.com/browserslist" + }, + { + "type": "tidelift", + "url": "https://tidelift.com/funding/github/npm/browserslist" + }, + { + "type": "github", + "url": "https://github.com/sponsors/ai" + } + ], + "license": "MIT", + "dependencies": { + "baseline-browser-mapping": "^2.10.42", + "caniuse-lite": "^1.0.30001803", + "electron-to-chromium": "^1.5.389", + "node-releases": "^2.0.51", + "update-browserslist-db": "^1.2.3" + }, + "bin": { + "browserslist": "cli.js" + }, + "engines": { + "node": "^6 || ^7 || ^8 || ^9 || ^10 || ^11 || ^12 || >=13.7" + } + }, + "node_modules/caniuse-lite": { + "version": "1.0.30001805", + "resolved": "https://registry.npmjs.org/caniuse-lite/-/caniuse-lite-1.0.30001805.tgz", + "integrity": "sha512-52noaS3DubycKSXaU30TwPGIp+POyQSUVa5jBEq3vkRkY0kjyb3LQgvhU6WGyCcyXqVLWO0Cw0Q6BSdD0kUfVA==", + "dev": true, + "funding": [ + { + "type": "opencollective", + "url": "https://opencollective.com/browserslist" + }, + { + "type": "tidelift", + "url": "https://tidelift.com/funding/github/npm/caniuse-lite" + }, + { + "type": "github", + "url": "https://github.com/sponsors/ai" + } + ], + "license": "CC-BY-4.0" + }, + "node_modules/convert-source-map": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/convert-source-map/-/convert-source-map-2.0.0.tgz", + "integrity": "sha512-Kvp459HrV2FEJ1CAsi1Ku+MY3kasH19TFykTz2xWmMeq6bk2NU3XXvfJ+Q61m0xktWwt+1HSYf3JZsTms3aRJg==", + "dev": true, + "license": "MIT" + }, + "node_modules/css-select": { + "version": "5.2.2", + "resolved": "https://registry.npmjs.org/css-select/-/css-select-5.2.2.tgz", + "integrity": "sha512-TizTzUddG/xYLA3NXodFM0fSbNizXjOKhqiQQwvhlspadZokn1KDy0NZFS0wuEubIYAV5/c1/lAr0TaaFXEXzw==", + "dev": true, + "license": "BSD-2-Clause", + "dependencies": { + "boolbase": "^1.0.0", + "css-what": "^6.1.0", + "domhandler": "^5.0.2", + "domutils": "^3.0.1", + "nth-check": "^2.0.1" + }, + "funding": { + "url": "https://github.com/sponsors/fb55" + } + }, + "node_modules/css-what": { + "version": "6.2.2", + "resolved": "https://registry.npmjs.org/css-what/-/css-what-6.2.2.tgz", + "integrity": "sha512-u/O3vwbptzhMs3L1fQE82ZSLHQQfto5gyZzwteVIEyeaY5Fc7R4dapF/BvRoSYFeqfBk4m0V1Vafq5Pjv25wvA==", + "dev": true, + "license": "BSD-2-Clause", + "engines": { + "node": ">= 6" + }, + "funding": { + "url": "https://github.com/sponsors/fb55" + } + }, + "node_modules/debug": { + "version": "4.4.3", + "resolved": "https://registry.npmjs.org/debug/-/debug-4.4.3.tgz", + "integrity": "sha512-RGwwWnwQvkVfavKVt22FGLw+xYSdzARwm0ru6DhTVA3umU5hZc28V3kO4stgYryrTlLpuvgI9GiijltAjNbcqA==", + "dev": true, + "license": "MIT", + "dependencies": { + "ms": "^2.1.3" + }, + "engines": { + "node": ">=6.0" + }, + "peerDependenciesMeta": { + "supports-color": { + "optional": true + } + } + }, + "node_modules/dom-serializer": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/dom-serializer/-/dom-serializer-2.0.0.tgz", + "integrity": "sha512-wIkAryiqt/nV5EQKqQpo3SToSOV9J0DnbJqwK7Wv/Trc92zIAYZ4FlMu+JPFW1DfGFt81ZTCGgDEabffXeLyJg==", + "dev": true, + "license": "MIT", + "dependencies": { + "domelementtype": "^2.3.0", + "domhandler": "^5.0.2", + "entities": "^4.2.0" + }, + "funding": { + "url": "https://github.com/cheeriojs/dom-serializer?sponsor=1" + } + }, + "node_modules/domelementtype": { + "version": "2.3.0", + "resolved": "https://registry.npmjs.org/domelementtype/-/domelementtype-2.3.0.tgz", + "integrity": "sha512-OLETBj6w0OsagBwdXnPdN0cnMfF9opN69co+7ZrbfPGrdpPVNBUj02spi6B1N7wChLQiPn4CSH/zJvXw56gmHw==", + "dev": true, + "funding": [ + { + "type": "github", + "url": "https://github.com/sponsors/fb55" + } + ], + "license": "BSD-2-Clause" + }, + "node_modules/domhandler": { + "version": "5.0.3", + "resolved": "https://registry.npmjs.org/domhandler/-/domhandler-5.0.3.tgz", + "integrity": "sha512-cgwlv/1iFQiFnU96XXgROh8xTeetsnJiDsTc7TYCLFd9+/WNkIqPTxiM/8pSd8VIrhXGTf1Ny1q1hquVqDJB5w==", + "dev": true, + "license": "BSD-2-Clause", + "dependencies": { + "domelementtype": "^2.3.0" + }, + "engines": { + "node": ">= 4" + }, + "funding": { + "url": "https://github.com/fb55/domhandler?sponsor=1" + } + }, + "node_modules/domutils": { + "version": "3.2.2", + "resolved": "https://registry.npmjs.org/domutils/-/domutils-3.2.2.tgz", + "integrity": "sha512-6kZKyUajlDuqlHKVX1w7gyslj9MPIXzIFiz/rGu35uC1wMi+kMhQwGhl4lt9unC9Vb9INnY9Z3/ZA3+FhASLaw==", + "dev": true, + "license": "BSD-2-Clause", + "dependencies": { + "dom-serializer": "^2.0.0", + "domelementtype": "^2.3.0", + "domhandler": "^5.0.3" + }, + "funding": { + "url": "https://github.com/fb55/domutils?sponsor=1" + } + }, + "node_modules/electron-to-chromium": { + "version": "1.5.389", + "resolved": "https://registry.npmjs.org/electron-to-chromium/-/electron-to-chromium-1.5.389.tgz", + "integrity": "sha512-cEto7aeOqBfU1D+c5py5pE+ooscKE75JifxLBdFUZsqAxRS6y7kebtxAZvICszSl05gPjYHDTjY+lXpyGvpJbg==", + "dev": true, + "license": "ISC" + }, + "node_modules/entities": { + "version": "4.5.0", + "resolved": "https://registry.npmjs.org/entities/-/entities-4.5.0.tgz", + "integrity": "sha512-V0hjH4dGPh9Ao5p0MoRY6BVqtwCjhz6vI5LT8AJ55H+4g9/4vbHx1I54fS0XuclLhDHArPQCiMjDxjaL8fPxhw==", + "dev": true, + "license": "BSD-2-Clause", + "engines": { + "node": ">=0.12" + }, + "funding": { + "url": "https://github.com/fb55/entities?sponsor=1" + } + }, + "node_modules/esbuild": { + "version": "0.25.12", + "resolved": "https://registry.npmjs.org/esbuild/-/esbuild-0.25.12.tgz", + "integrity": "sha512-bbPBYYrtZbkt6Os6FiTLCTFxvq4tt3JKall1vRwshA3fdVztsLAatFaZobhkBC8/BrPetoa0oksYoKXoG4ryJg==", + "dev": true, + "hasInstallScript": true, + "license": "MIT", + "bin": { + "esbuild": "bin/esbuild" + }, + "engines": { + "node": ">=18" + }, + "optionalDependencies": { + "@esbuild/aix-ppc64": "0.25.12", + "@esbuild/android-arm": "0.25.12", + "@esbuild/android-arm64": "0.25.12", + "@esbuild/android-x64": "0.25.12", + "@esbuild/darwin-arm64": "0.25.12", + "@esbuild/darwin-x64": "0.25.12", + "@esbuild/freebsd-arm64": "0.25.12", + "@esbuild/freebsd-x64": "0.25.12", + "@esbuild/linux-arm": "0.25.12", + "@esbuild/linux-arm64": "0.25.12", + "@esbuild/linux-ia32": "0.25.12", + "@esbuild/linux-loong64": "0.25.12", + "@esbuild/linux-mips64el": "0.25.12", + "@esbuild/linux-ppc64": "0.25.12", + "@esbuild/linux-riscv64": "0.25.12", + "@esbuild/linux-s390x": "0.25.12", + "@esbuild/linux-x64": "0.25.12", + "@esbuild/netbsd-arm64": "0.25.12", + "@esbuild/netbsd-x64": "0.25.12", + "@esbuild/openbsd-arm64": "0.25.12", + "@esbuild/openbsd-x64": "0.25.12", + "@esbuild/openharmony-arm64": "0.25.12", + "@esbuild/sunos-x64": "0.25.12", + "@esbuild/win32-arm64": "0.25.12", + "@esbuild/win32-ia32": "0.25.12", + "@esbuild/win32-x64": "0.25.12" + } + }, + "node_modules/escalade": { + "version": "3.2.0", + "resolved": "https://registry.npmjs.org/escalade/-/escalade-3.2.0.tgz", + "integrity": "sha512-WUj2qlxaQtO4g6Pq5c29GTcWGDyd8itL8zTlipgECz3JesAiiOKotd8JU6otB3PACgG6xkJUyVhboMS+bje/jA==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=6" + } + }, + "node_modules/estree-walker": { + "version": "2.0.2", + "resolved": "https://registry.npmjs.org/estree-walker/-/estree-walker-2.0.2.tgz", + "integrity": "sha512-Rfkk/Mp/DL7JVje3u18FxFujQlTNR2q6QfMSMB7AvCBx91NGj/ba3kCfza0f6dVDbw7YlRf/nDrn7pQrCCyQ/w==", + "dev": true, + "license": "MIT" + }, + "node_modules/fdir": { + "version": "6.5.0", + "resolved": "https://registry.npmjs.org/fdir/-/fdir-6.5.0.tgz", + "integrity": "sha512-tIbYtZbucOs0BRGqPJkshJUYdL+SDH7dVM8gjy+ERp3WAUjLEFJE+02kanyHtwjWOnwrKYBiwAmM0p4kLJAnXg==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=12.0.0" + }, + "peerDependencies": { + "picomatch": "^3 || ^4" + }, + "peerDependenciesMeta": { + "picomatch": { + "optional": true + } + } + }, + "node_modules/fsevents": { + "version": "2.3.3", + "resolved": "https://registry.npmjs.org/fsevents/-/fsevents-2.3.3.tgz", + "integrity": "sha512-5xoDfX+fL7faATnagmWPpbFtwh/R77WmMMqqHGS65C3vvB0YHrgF+B1YmZ3441tMj5n63k0212XNoJwzlhffQw==", + "dev": true, + "hasInstallScript": true, + "license": "MIT", + "optional": true, + "os": [ + "darwin" + ], + "engines": { + "node": "^8.16.0 || ^10.6.0 || >=11.0.0" + } + }, + "node_modules/gensync": { + "version": "1.0.0-beta.2", + "resolved": "https://registry.npmjs.org/gensync/-/gensync-1.0.0-beta.2.tgz", + "integrity": "sha512-3hN7NaskYvMDLQY55gnW3NQ+mesEAepTqlg+VEbj7zzqEMBVNhzcGYYeqFo/TlYz6eQiFcp1HcsCZO+nGgS8zg==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=6.9.0" + } + }, + "node_modules/he": { + "version": "1.2.0", + "resolved": "https://registry.npmjs.org/he/-/he-1.2.0.tgz", + "integrity": "sha512-F/1DnUGPopORZi0ni+CvrCgHQ5FyEAHRLSApuYWMmrbSwoN2Mn/7k+Gl38gJnR7yyDZk6WLXwiGod1JOWNDKGw==", + "dev": true, + "license": "MIT", + "bin": { + "he": "bin/he" + } + }, + "node_modules/js-tokens": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/js-tokens/-/js-tokens-4.0.0.tgz", + "integrity": "sha512-RdJUflcE3cUzKiMqQgsCu06FPu9UdIJO0beYbPhHN4k6apgJtifcoCtT9bcxOpYBtpD2kCM6Sbzg4CausW/PKQ==", + "dev": true, + "license": "MIT" + }, + "node_modules/jsesc": { + "version": "3.1.0", + "resolved": "https://registry.npmjs.org/jsesc/-/jsesc-3.1.0.tgz", + "integrity": "sha512-/sM3dO2FOzXjKQhJuo0Q173wf2KOo8t4I8vHy6lF9poUp7bKT0/NHE8fPX23PwfhnykfqnC2xRxOnVw5XuGIaA==", + "dev": true, + "license": "MIT", + "bin": { + "jsesc": "bin/jsesc" + }, + "engines": { + "node": ">=6" + } + }, + "node_modules/json5": { + "version": "2.2.3", + "resolved": "https://registry.npmjs.org/json5/-/json5-2.2.3.tgz", + "integrity": "sha512-XmOWe7eyHYH14cLdVPoyg+GOH3rYX++KpzrylJwSW98t3Nk+U8XOl8FWKOgwtzdb8lXGf6zYwDUzeHMWfxasyg==", + "dev": true, + "license": "MIT", + "bin": { + "json5": "lib/cli.js" + }, + "engines": { + "node": ">=6" + } + }, + "node_modules/kolorist": { + "version": "1.8.0", + "resolved": "https://registry.npmjs.org/kolorist/-/kolorist-1.8.0.tgz", + "integrity": "sha512-Y+60/zizpJ3HRH8DCss+q95yr6145JXZo46OTpFvDZWLfRCE4qChOyk1b26nMaNpfHHgxagk9dXT5OP0Tfe+dQ==", + "dev": true, + "license": "MIT" + }, + "node_modules/lru-cache": { + "version": "5.1.1", + "resolved": "https://registry.npmjs.org/lru-cache/-/lru-cache-5.1.1.tgz", + "integrity": "sha512-KpNARQA3Iwv+jTA0utUVVbrh+Jlrr1Fv0e56GGzAFOXN7dk/FviaDW8LHmK52DlcH4WP2n6gI8vN1aesBFgo9w==", + "dev": true, + "license": "ISC", + "dependencies": { + "yallist": "^3.0.2" + } + }, + "node_modules/magic-string": { + "version": "0.30.21", + "resolved": "https://registry.npmjs.org/magic-string/-/magic-string-0.30.21.tgz", + "integrity": "sha512-vd2F4YUyEXKGcLHoq+TEyCjxueSeHnFxyyjNp80yg0XV4vUhnDer/lvvlqM/arB5bXQN5K2/3oinyCRyx8T2CQ==", + "dev": true, + "license": "MIT", + "dependencies": { + "@jridgewell/sourcemap-codec": "^1.5.5" + } + }, + "node_modules/ms": { + "version": "2.1.3", + "resolved": "https://registry.npmjs.org/ms/-/ms-2.1.3.tgz", + "integrity": "sha512-6FlzubTLZG3J2a/NVCAleEhjzq5oxgHyaCU9yYXvcLsvoVaHJq/s5xXI6/XXP6tz7R9xAOtHnSO/tXtF3WRTlA==", + "dev": true, + "license": "MIT" + }, + "node_modules/nanoid": { + "version": "3.3.16", + "resolved": "https://registry.npmjs.org/nanoid/-/nanoid-3.3.16.tgz", + "integrity": "sha512-bzlKTyNJ7+LdGIIwy8ijFpIqEQIvafahV7eYykJ8Cvh42EdJeODoJ6gUJXpQJvej1BddH8OqTXZNE/KfbWAu8Q==", + "dev": true, + "funding": [ + { + "type": "github", + "url": "https://github.com/sponsors/ai" + } + ], + "license": "MIT", + "bin": { + "nanoid": "bin/nanoid.cjs" + }, + "engines": { + "node": "^10 || ^12 || ^13.7 || ^14 || >=15.0.1" + } + }, + "node_modules/node-html-parser": { + "version": "6.1.13", + "resolved": "https://registry.npmjs.org/node-html-parser/-/node-html-parser-6.1.13.tgz", + "integrity": "sha512-qIsTMOY4C/dAa5Q5vsobRpOOvPfC4pB61UVW2uSwZNUp0QU/jCekTal1vMmbO0DgdHeLUJpv/ARmDqErVxA3Sg==", + "dev": true, + "license": "MIT", + "dependencies": { + "css-select": "^5.1.0", + "he": "1.2.0" + } + }, + "node_modules/node-releases": { + "version": "2.0.51", + "resolved": "https://registry.npmjs.org/node-releases/-/node-releases-2.0.51.tgz", + "integrity": "sha512-wRNIrw4DmVLKQlbgOMdkMx27Wrpzes2hh5Jtbi2bjPd+4wJstWIqP5A+lscnqbm0xxmT5Bpg8Lec5ItEBwx6BQ==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=18" + } + }, + "node_modules/nth-check": { + "version": "2.1.1", + "resolved": "https://registry.npmjs.org/nth-check/-/nth-check-2.1.1.tgz", + "integrity": "sha512-lqjrjmaOoAnWfMmBPL+XNnynZh2+swxiX3WUE0s4yEHI6m+AwrK2UZOimIRl3X/4QctVqS8AiZjFqyOGrMXb/w==", + "dev": true, + "license": "BSD-2-Clause", + "dependencies": { + "boolbase": "^1.0.0" + }, + "funding": { + "url": "https://github.com/fb55/nth-check?sponsor=1" + } + }, + "node_modules/picocolors": { + "version": "1.1.1", + "resolved": "https://registry.npmjs.org/picocolors/-/picocolors-1.1.1.tgz", + "integrity": "sha512-xceH2snhtb5M9liqDsmEw56le376mTZkEX/jEb/RxNFyegNul7eNslCXP9FDj/Lcu0X8KEyMceP2ntpaHrDEVA==", + "dev": true, + "license": "ISC" + }, + "node_modules/picomatch": { + "version": "4.0.5", + "resolved": "https://registry.npmjs.org/picomatch/-/picomatch-4.0.5.tgz", + "integrity": "sha512-RvwwcruNjI1ncT5xRakeyS9Lf8lcItv34KD+aif+VH9kduAyfYBipGh12274xtenIPZ119/R9BdTBa8gAwSh0A==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=12" + }, + "funding": { + "url": "https://github.com/sponsors/jonschlinkert" + } + }, + "node_modules/postcss": { + "version": "8.5.19", + "resolved": "https://registry.npmjs.org/postcss/-/postcss-8.5.19.tgz", + "integrity": "sha512-Mz8SaolMd8nB+G13WkORcxQKHZ/NE4xXevtkJHVuG+guo9/wYKlIMTKAqGdEmYOXR2ijPjTYNHssizdaVSUNdQ==", + "dev": true, + "funding": [ + { + "type": "opencollective", + "url": "https://opencollective.com/postcss/" + }, + { + "type": "tidelift", + "url": "https://tidelift.com/funding/github/npm/postcss" + }, + { + "type": "github", + "url": "https://github.com/sponsors/ai" + } + ], + "license": "MIT", + "dependencies": { + "nanoid": "^3.3.12", + "picocolors": "^1.1.1", + "source-map-js": "^1.2.1" + }, + "engines": { + "node": "^10 || ^12 || >=14" + } + }, + "node_modules/preact": { + "version": "10.29.7", + "resolved": "https://registry.npmjs.org/preact/-/preact-10.29.7.tgz", + "integrity": "sha512-DCHYrK/B10yUD3ZjLfhZ3WIE/9Vf9VFUODcRE2dRomTYDpJk6z6L9wecSfhfE6M9ZTHUdyQkoC46arIDhEV84Q==", + "license": "MIT", + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/preact" + }, + "peerDependencies": { + "preact-render-to-string": ">=5" + }, + "peerDependenciesMeta": { + "preact-render-to-string": { + "optional": true + } + } + }, + "node_modules/rollup": { + "version": "4.62.2", + "resolved": "https://registry.npmjs.org/rollup/-/rollup-4.62.2.tgz", + "integrity": "sha512-RFnrW4lhXA3s3eqHDZvN654g8OTjzRfqpIRJYczCGB6HzphckVAi/Qh4tbPUbRuDi7s1Llv8g/NspLkttY3gTA==", + "dev": true, + "license": "MIT", + "dependencies": { + "@types/estree": "1.0.9" + }, + "bin": { + "rollup": "dist/bin/rollup" + }, + "engines": { + "node": ">=18.0.0", + "npm": ">=8.0.0" + }, + "optionalDependencies": { + "@rollup/rollup-android-arm-eabi": "4.62.2", + "@rollup/rollup-android-arm64": "4.62.2", + "@rollup/rollup-darwin-arm64": "4.62.2", + "@rollup/rollup-darwin-x64": "4.62.2", + "@rollup/rollup-freebsd-arm64": "4.62.2", + "@rollup/rollup-freebsd-x64": "4.62.2", + "@rollup/rollup-linux-arm-gnueabihf": "4.62.2", + "@rollup/rollup-linux-arm-musleabihf": "4.62.2", + "@rollup/rollup-linux-arm64-gnu": "4.62.2", + "@rollup/rollup-linux-arm64-musl": "4.62.2", + "@rollup/rollup-linux-loong64-gnu": "4.62.2", + "@rollup/rollup-linux-loong64-musl": "4.62.2", + "@rollup/rollup-linux-ppc64-gnu": "4.62.2", + "@rollup/rollup-linux-ppc64-musl": "4.62.2", + "@rollup/rollup-linux-riscv64-gnu": "4.62.2", + "@rollup/rollup-linux-riscv64-musl": "4.62.2", + "@rollup/rollup-linux-s390x-gnu": "4.62.2", + "@rollup/rollup-linux-x64-gnu": "4.62.2", + "@rollup/rollup-linux-x64-musl": "4.62.2", + "@rollup/rollup-openbsd-x64": "4.62.2", + "@rollup/rollup-openharmony-arm64": "4.62.2", + "@rollup/rollup-win32-arm64-msvc": "4.62.2", + "@rollup/rollup-win32-ia32-msvc": "4.62.2", + "@rollup/rollup-win32-x64-gnu": "4.62.2", + "@rollup/rollup-win32-x64-msvc": "4.62.2", + "fsevents": "~2.3.2" + } + }, + "node_modules/semver": { + "version": "6.3.1", + "resolved": "https://registry.npmjs.org/semver/-/semver-6.3.1.tgz", + "integrity": "sha512-BR7VvDCVHO+q2xBEWskxS6DJE1qRnb7DxzUrogb71CWoSficBxYsiAGd+Kl0mmq/MprG9yArRkyrQxTO6XjMzA==", + "dev": true, + "license": "ISC", + "bin": { + "semver": "bin/semver.js" + } + }, + "node_modules/simple-code-frame": { + "version": "1.3.0", + "resolved": "https://registry.npmjs.org/simple-code-frame/-/simple-code-frame-1.3.0.tgz", + "integrity": "sha512-MB4pQmETUBlNs62BBeRjIFGeuy/x6gGKh7+eRUemn1rCFhqo7K+4slPqsyizCbcbYLnaYqaoZ2FWsZ/jN06D8w==", + "dev": true, + "license": "MIT", + "dependencies": { + "kolorist": "^1.6.0" + } + }, + "node_modules/source-map": { + "version": "0.7.6", + "resolved": "https://registry.npmjs.org/source-map/-/source-map-0.7.6.tgz", + "integrity": "sha512-i5uvt8C3ikiWeNZSVZNWcfZPItFQOsYTUAOkcUPGd8DqDy1uOUikjt5dG+uRlwyvR108Fb9DOd4GvXfT0N2/uQ==", + "dev": true, + "license": "BSD-3-Clause", + "engines": { + "node": ">= 12" + } + }, + "node_modules/source-map-js": { + "version": "1.2.1", + "resolved": "https://registry.npmjs.org/source-map-js/-/source-map-js-1.2.1.tgz", + "integrity": "sha512-UXWMKhLOwVKb728IUtQPXxfYU+usdybtUrK/8uGE8CQMvrhOpwvzDBwj0QhSL7MQc7vIsISBG8VQ8+IDQxpfQA==", + "dev": true, + "license": "BSD-3-Clause", + "engines": { + "node": ">=0.10.0" + } + }, + "node_modules/stack-trace": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/stack-trace/-/stack-trace-1.0.0.tgz", + "integrity": "sha512-H6D7134xi6qONvh7ZHKgviXf+rd3vhGBSvebPZCaUkd8zvQ+7PtDw6CljPTe4cXWNf2IKZGNqw6VJXSb9IgBpA==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=20.0.0" + } + }, + "node_modules/tinyglobby": { + "version": "0.2.17", + "resolved": "https://registry.npmjs.org/tinyglobby/-/tinyglobby-0.2.17.tgz", + "integrity": "sha512-wXR/dYpcqKmfWpEdZjiKJOwCNFndD0DMnrW/cYjVGttEkBfVgcLFHoNrlj47mjOVic9yyNu65alsgF4NQyTa2g==", + "dev": true, + "license": "MIT", + "dependencies": { + "fdir": "^6.5.0", + "picomatch": "^4.0.4" + }, + "engines": { + "node": ">=12.0.0" + }, + "funding": { + "url": "https://github.com/sponsors/SuperchupuDev" + } + }, + "node_modules/typescript": { + "version": "5.9.3", + "resolved": "https://registry.npmjs.org/typescript/-/typescript-5.9.3.tgz", + "integrity": "sha512-jl1vZzPDinLr9eUt3J/t7V6FgNEw9QjvBPdysz9KfQDD41fQrC2Y4vKQdiaUpFT4bXlb1RHhLpp8wtm6M5TgSw==", + "dev": true, + "license": "Apache-2.0", + "bin": { + "tsc": "bin/tsc", + "tsserver": "bin/tsserver" + }, + "engines": { + "node": ">=14.17" + } + }, + "node_modules/update-browserslist-db": { + "version": "1.2.3", + "resolved": "https://registry.npmjs.org/update-browserslist-db/-/update-browserslist-db-1.2.3.tgz", + "integrity": "sha512-Js0m9cx+qOgDxo0eMiFGEueWztz+d4+M3rGlmKPT+T4IS/jP4ylw3Nwpu6cpTTP8R1MAC1kF4VbdLt3ARf209w==", + "dev": true, + "funding": [ + { + "type": "opencollective", + "url": "https://opencollective.com/browserslist" + }, + { + "type": "tidelift", + "url": "https://tidelift.com/funding/github/npm/browserslist" + }, + { + "type": "github", + "url": "https://github.com/sponsors/ai" + } + ], + "license": "MIT", + "dependencies": { + "escalade": "^3.2.0", + "picocolors": "^1.1.1" + }, + "bin": { + "update-browserslist-db": "cli.js" + }, + "peerDependencies": { + "browserslist": ">= 4.21.0" + } + }, + "node_modules/vite": { + "version": "6.4.3", + "resolved": "https://registry.npmjs.org/vite/-/vite-6.4.3.tgz", + "integrity": "sha512-NTKlcQjlAK7MlQoyb6LgaqHc8sso/pVyUJYWMws3jg21uTJw/LddqIFPcPqP6PzpgbIcZyKI85sFE4HBrQDA8A==", + "dev": true, + "license": "MIT", + "dependencies": { + "esbuild": "^0.25.0", + "fdir": "^6.4.4", + "picomatch": "^4.0.2", + "postcss": "^8.5.3", + "rollup": "^4.34.9", + "tinyglobby": "^0.2.13" + }, + "bin": { + "vite": "bin/vite.js" + }, + "engines": { + "node": "^18.0.0 || ^20.0.0 || >=22.0.0" + }, + "funding": { + "url": "https://github.com/vitejs/vite?sponsor=1" + }, + "optionalDependencies": { + "fsevents": "~2.3.3" + }, + "peerDependencies": { + "@types/node": "^18.0.0 || ^20.0.0 || >=22.0.0", + "jiti": ">=1.21.0", + "less": "*", + "lightningcss": "^1.21.0", + "sass": "*", + "sass-embedded": "*", + "stylus": "*", + "sugarss": "*", + "terser": "^5.16.0", + "tsx": "^4.8.1", + "yaml": "^2.4.2" + }, + "peerDependenciesMeta": { + "@types/node": { + "optional": true + }, + "jiti": { + "optional": true + }, + "less": { + "optional": true + }, + "lightningcss": { + "optional": true + }, + "sass": { + "optional": true + }, + "sass-embedded": { + "optional": true + }, + "stylus": { + "optional": true + }, + "sugarss": { + "optional": true + }, + "terser": { + "optional": true + }, + "tsx": { + "optional": true + }, + "yaml": { + "optional": true + } + } + }, + "node_modules/vite-prerender-plugin": { + "version": "0.5.13", + "resolved": "https://registry.npmjs.org/vite-prerender-plugin/-/vite-prerender-plugin-0.5.13.tgz", + "integrity": "sha512-IKSpYkzDBsKAxa05naRbj7GvNVMSdww/Z/E89oO3xndz+gWnOBOKOAbEXv7qDhktY/j3vHgJmoV1pPzqU2tx9g==", + "dev": true, + "license": "MIT", + "dependencies": { + "kolorist": "^1.8.0", + "magic-string": "0.x >= 0.26.0", + "node-html-parser": "^6.1.12", + "simple-code-frame": "^1.3.0", + "source-map": "^0.7.4", + "stack-trace": "^1.0.0-pre2" + }, + "peerDependencies": { + "vite": "5.x || 6.x || 7.x || 8.x" + } + }, + "node_modules/yallist": { + "version": "3.1.1", + "resolved": "https://registry.npmjs.org/yallist/-/yallist-3.1.1.tgz", + "integrity": "sha512-a4UGQaWPH59mOXUYnAG2ewncQS4i4F43Tv3JoAM+s2VDAmS9NsK8GpDMLrCHPksFT7h3K6TOoUNn2pb7RoXx4g==", + "dev": true, + "license": "ISC" + }, + "node_modules/zimmerframe": { + "version": "1.1.4", + "resolved": "https://registry.npmjs.org/zimmerframe/-/zimmerframe-1.1.4.tgz", + "integrity": "sha512-B58NGBEoc8Y9MWWCQGl/gq9xBCe4IiKM0a2x7GZdQKOW5Exr8S1W24J6OgM1njK8xCRGvAJIL/MxXHf6SkmQKQ==", + "dev": true, + "license": "MIT" + } + } +} diff --git a/web/package.json b/web/package.json new file mode 100644 index 0000000..dec4e89 --- /dev/null +++ b/web/package.json @@ -0,0 +1,22 @@ +{ + "name": "havenllo-web", + "private": true, + "version": "0.1.0", + "type": "module", + "scripts": { + "dev": "vite", + "build": "tsc --noEmit && vite build", + "preview": "vite preview" + }, + "dependencies": { + "preact": "^10.26.4" + }, + "devDependencies": { + "@preact/preset-vite": "^2.10.1", + "typescript": "^5.8.3", + "vite": "^6.3.5" + }, + "allowScripts": { + "esbuild@0.25.12": true + } +} diff --git a/web/src/App.tsx b/web/src/App.tsx new file mode 100644 index 0000000..c68fa10 --- /dev/null +++ b/web/src/App.tsx @@ -0,0 +1,169 @@ +import { useCallback, useEffect, useReducer, useRef } from "preact/hooks"; +import { api, APIError } from "./api"; +import { + addCard, + addList, + boardReducer, + cloneBoard, + initialBoardState, + removeCard, + removeList, + updateCard, + updateList +} from "./board-state"; +import { movePosition } from "./drag"; +import type { CardPatch, ListPatch } from "./types"; +import { BoardCanvas } from "./components/BoardCanvas"; +import { Header } from "./components/Header"; +import { Toasts } from "./components/Toast"; + +let toastID = 0; + +function friendlyError(error: unknown): string { + if (error instanceof APIError) return error.message; + if (error instanceof Error) return error.message; + return "Could not save that change. Please try again."; +} + +export function App() { + const [state, dispatch] = useReducer(boardReducer, initialBoardState); + const boardRef = useRef(state.board); + boardRef.current = state.board; + + const toast = useCallback((message: string, tone: "success" | "error" | "info" = "info") => { + const id = ++toastID; + dispatch({ type: "toast", toast: { id, message, tone } }); + window.setTimeout(() => dispatch({ type: "dismiss", id }), 4200); + }, []); + + const load = useCallback(async () => { + dispatch({ type: "loading" }); + try { + dispatch({ type: "loaded", board: await api.board() }); + } catch (error) { + dispatch({ type: "error", error: friendlyError(error) }); + } + }, []); + + useEffect(() => { void load(); }, [load]); + + const mutate = useCallback(async ( + makeOptimistic: (current: NonNullable) => NonNullable, + request: () => Promise, + success?: string + ) => { + const before = boardRef.current; + if (!before) return; + dispatch({ type: "replace", board: makeOptimistic(cloneBoard(before)) }); + try { + await request(); + if (success) toast(success, "success"); + } catch (error) { + dispatch({ type: "replace", board: before }); + toast(friendlyError(error), "error"); + throw error; + } + }, [toast]); + + const createList = async (name: string) => { + const current = boardRef.current; + if (!current) return; + const position = Math.max(0, ...current.lists.map((list) => list.position)) + 1024; + try { + const { list } = await api.createList(name, position); + const board = boardRef.current; + if (board) dispatch({ type: "replace", board: addList(board, list) }); + toast("List added", "success"); + } catch (error) { + toast(friendlyError(error), "error"); + throw error; + } + }; + + const editList = async (id: number, patch: ListPatch) => { + const old = boardRef.current?.lists.find((list) => list.id === id); + if (!old) return; + await mutate( + (board) => updateList(board, { ...old, ...patch }), + async () => { + const { list } = await api.patchList(id, patch); + const current = boardRef.current; + if (current) dispatch({ type: "replace", board: updateList(current, list) }); + } + ); + }; + + const deleteList = async (id: number) => { + await mutate((board) => removeList(board, id), () => api.deleteList(id), "List deleted"); + }; + + const createCard = async (listID: number, title: string) => { + const current = boardRef.current; + const list = current?.lists.find((item) => item.id === listID); + if (!list) return; + const position = Math.max(0, ...list.cards.map((card) => card.position)) + 1024; + try { + const { card } = await api.createCard(listID, title, "", position); + const board = boardRef.current; + if (board) dispatch({ type: "replace", board: addCard(board, card) }); + toast("Card added", "success"); + } catch (error) { + toast(friendlyError(error), "error"); + throw error; + } + }; + + const editCard = async (id: number, patch: CardPatch) => { + const old = boardRef.current?.lists.flatMap((list) => list.cards).find((card) => card.id === id); + if (!old) return; + const optimistic = { ...old, ...patch, list_id: patch.list_id ?? old.list_id }; + await mutate( + (board) => updateCard(board, optimistic), + async () => { + const { card } = await api.patchCard(id, patch); + const current = boardRef.current; + if (current) dispatch({ type: "replace", board: updateCard(current, card) }); + } + ); + }; + + const deleteCard = async (id: number) => { + await mutate((board) => removeCard(board, id), () => api.deleteCard(id), "Card deleted"); + }; + + const moveCard = async (cardID: number, sourceListID: number, targetListID: number, dropIndex: number) => { + const current = boardRef.current; + const card = current?.lists.flatMap((list) => list.cards).find((item) => item.id === cardID); + if (!current || !card) return; + const position = movePosition(current.lists, cardID, sourceListID, targetListID, dropIndex); + await editCard(cardID, { list_id: targetListID, position }); + }; + + return ( +
+
+ {state.loading && !state.board ?
Loading your Haven board…
: null} + {state.error ? ( +
+

Havenllo could not reach its board

+

{state.error}

+ +
+ ) : null} + {state.board ? ( + + ) : null} + dispatch({ type: "dismiss", id })} /> +
+ ); +} + diff --git a/web/src/api.ts b/web/src/api.ts new file mode 100644 index 0000000..f9a0d17 --- /dev/null +++ b/web/src/api.ts @@ -0,0 +1,63 @@ +import type { Board, Card, CardPatch, List, ListPatch } from "./types"; + +export class APIError extends Error { + constructor( + message: string, + readonly status: number, + readonly code: string + ) { + super(message); + } +} + +async function request(path: string, init?: RequestInit): Promise { + const response = await fetch("/api" + path, { + ...init, + headers: { + ...(init?.body ? { "Content-Type": "application/json" } : {}), + ...init?.headers + } + }); + if (!response.ok) { + let message = "Something went wrong"; + let code = "request_failed"; + try { + const payload = (await response.json()) as { error?: { message?: string; code?: string } }; + message = payload.error?.message || message; + code = payload.error?.code || code; + } catch { + // The server's JSON error body is preferred, but network intermediaries may not have one. + } + throw new APIError(message, response.status, code); + } + if (response.status === 204) { + return undefined as T; + } + return response.json() as Promise; +} + +const json = (body: object): RequestInit => ({ + method: "POST", + body: JSON.stringify(body) +}); + +export const api = { + board: () => request("/board"), + lists: () => request<{ lists: List[] }>("/lists"), + createList: (name: string, position?: number) => + request<{ list: List }>("/lists", json({ name, ...(position === undefined ? {} : { position }) })), + patchList: (id: number, patch: ListPatch) => + request<{ list: List }>("/lists/" + id, { method: "PATCH", body: JSON.stringify(patch) }), + deleteList: (id: number) => request("/lists/" + id, { method: "DELETE" }), + listCards: (id: number) => request<{ cards: Card[] }>("/lists/" + id + "/cards"), + createCard: (listID: number, title: string, description = "", position?: number) => + request<{ card: Card }>("/lists/" + listID + "/cards", json({ + title, + description, + ...(position === undefined ? {} : { position }) + })), + patchCard: (id: number, patch: CardPatch) => + request<{ card: Card }>("/cards/" + id, { method: "PATCH", body: JSON.stringify(patch) }), + deleteCard: (id: number) => request("/cards/" + id, { method: "DELETE" }) +}; + diff --git a/web/src/board-state.ts b/web/src/board-state.ts new file mode 100644 index 0000000..858fbf1 --- /dev/null +++ b/web/src/board-state.ts @@ -0,0 +1,108 @@ +import type { Board, Card, List, ListWithCards } from "./types"; + +export type ToastTone = "success" | "error" | "info"; + +export interface ToastMessage { + id: number; + tone: ToastTone; + message: string; +} + +export interface BoardState { + board: Board | null; + loading: boolean; + error: string | null; + toasts: ToastMessage[]; +} + +export type BoardAction = + | { type: "loading" } + | { type: "loaded"; board: Board } + | { type: "replace"; board: Board } + | { type: "error"; error: string } + | { type: "toast"; toast: ToastMessage } + | { type: "dismiss"; id: number }; + +export const initialBoardState: BoardState = { + board: null, + loading: true, + error: null, + toasts: [] +}; + +export function boardReducer(state: BoardState, action: BoardAction): BoardState { + switch (action.type) { + case "loading": + return { ...state, loading: true, error: null }; + case "loaded": + return { ...state, board: action.board, loading: false, error: null }; + case "replace": + return { ...state, board: action.board }; + case "error": + return { ...state, loading: false, error: action.error }; + case "toast": + return { ...state, toasts: [...state.toasts, action.toast] }; + case "dismiss": + return { ...state, toasts: state.toasts.filter((toast) => toast.id !== action.id) }; + } +} + +export function cloneBoard(board: Board): Board { + return { + lists: board.lists.map((list) => ({ ...list, cards: list.cards.map((card) => ({ ...card })) })) + }; +} + +export function orderedLists(lists: ListWithCards[]): ListWithCards[] { + return [...lists].sort((a, b) => a.position - b.position || a.id - b.id); +} + +export function orderedCards(cards: Card[]): Card[] { + return [...cards].sort((a, b) => a.position - b.position || a.id - b.id); +} + +export function addList(board: Board, list: List): Board { + return { lists: orderedLists([...board.lists, { ...list, cards: [] }]) }; +} + +export function updateList(board: Board, list: List): Board { + return { + lists: orderedLists(board.lists.map((current) => current.id === list.id + ? { ...current, ...list } + : current)) + }; +} + +export function removeList(board: Board, listID: number): Board { + return { lists: board.lists.filter((list) => list.id !== listID) }; +} + +export function addCard(board: Board, card: Card): Board { + return { + lists: board.lists.map((list) => list.id === card.list_id + ? { ...list, cards: orderedCards([...list.cards, card]) } + : list) + }; +} + +export function updateCard(board: Board, card: Card): Board { + const without = board.lists.map((list) => ({ + ...list, + cards: list.cards.filter((current) => current.id !== card.id) + })); + return { + lists: without.map((list) => list.id === card.list_id + ? { ...list, cards: orderedCards([...list.cards, card]) } + : list) + }; +} + +export function removeCard(board: Board, cardID: number): Board { + return { + lists: board.lists.map((list) => ({ + ...list, + cards: list.cards.filter((card) => card.id !== cardID) + })) + }; +} + diff --git a/web/src/components/BoardCanvas.tsx b/web/src/components/BoardCanvas.tsx new file mode 100644 index 0000000..c3930c5 --- /dev/null +++ b/web/src/components/BoardCanvas.tsx @@ -0,0 +1,95 @@ +import { useState } from "preact/hooks"; +import type { ListWithCards } from "../types"; +import { ListColumn } from "./ListColumn"; + +interface BoardCanvasProps { + lists: ListWithCards[]; + onCreateList: (name: string) => Promise; + onEditList: (id: number, patch: { name?: string; position?: number }) => Promise; + onDeleteList: (id: number) => Promise; + onCreateCard: (listID: number, title: string) => Promise; + onEditCard: (id: number, patch: { title?: string; description?: string; done?: boolean }) => Promise; + onDeleteCard: (id: number) => Promise; + onMoveCard: (cardID: number, sourceListID: number, targetListID: number, index: number) => Promise; +} + +export function BoardCanvas(props: BoardCanvasProps) { + const [adding, setAdding] = useState(false); + const [name, setName] = useState(""); + const [saving, setSaving] = useState(false); + + const addList = async () => { + if (!name.trim()) return; + setSaving(true); + try { + await props.onCreateList(name); + setName(""); + setAdding(false); + } catch { + // App has shown an error toast. + } finally { + setSaving(false); + } + }; + + return ( +
+
+
+

One calm place for your homelab work

+

Haven board

+
+

Drag tasks between lists, or click a title to edit.

+
+
+ {props.lists.map((list) => ( + props.onEditList(list.id, patch)} + onDeleteList={() => props.onDeleteList(list.id)} + onCreateCard={(title) => props.onCreateCard(list.id, title)} + onEditCard={props.onEditCard} + onDeleteCard={props.onDeleteCard} + onMoveCard={props.onMoveCard} + /> + ))} +
+ {adding ? ( +
{ + event.preventDefault(); + void addList(); + }} + > + + setName(event.currentTarget.value)} + onKeyDown={(event) => { + if (event.key === "Escape") { + setAdding(false); + setName(""); + } + }} + /> +
+ + +
+
+ ) : ( + + )} +
+
+
+ ); +} diff --git a/web/src/components/CardEditor.tsx b/web/src/components/CardEditor.tsx new file mode 100644 index 0000000..6e516a4 --- /dev/null +++ b/web/src/components/CardEditor.tsx @@ -0,0 +1,51 @@ +import { useEffect, useState } from "preact/hooks"; +import type { Card } from "../types"; + +interface CardEditorProps { + card: Card; + onSave: (description: string) => Promise; + onClose: () => void; + onDelete: () => void; +} + +export function CardEditor({ card, onSave, onClose, onDelete }: CardEditorProps) { + const [description, setDescription] = useState(card.description); + const [saving, setSaving] = useState(false); + + useEffect(() => setDescription(card.description), [card.id, card.description]); + + const save = async () => { + setSaving(true); + try { + await onSave(description); + onClose(); + } catch { + // App already surfaced an actionable toast and has rolled the state back. + } finally { + setSaving(false); + } + }; + + return ( +
+