diff --git a/.forgejo/workflows/release.yml b/.forgejo/workflows/release.yml new file mode 100644 index 0000000..023f628 --- /dev/null +++ b/.forgejo/workflows/release.yml @@ -0,0 +1,138 @@ +# What happens at every merge into main: +# 1. semantic-release reads the commits since the last release (Conventional Commits), works out the next version, +# writes CHANGELOG.md, makes the release on the forge and tags it. A merge with nothing to release (docs, tests, ci) +# makes none. +# 2. When there is a release, the image is built from the tag, for amd64 and for arm64, and pushed to +# git.kmalloc.org/squid/sonda as X.Y.Z-ARCH; then X.Y.Z, X.Y and latest are made to point at both. +# The runner has no Docker and cannot emulate another architecture, so the images are built with kaniko, which needs no +# daemon, and the Dockerfile crosses to arm64 without running anything for it. +# Secret needed: FORGEJO_TOKEN, a token of the owner with the scopes write:repository and write:package. +name: release + +on: + push: + branches: [main] + +# One release at a time: two merges close together must not make two versions at once. +concurrency: + group: release + cancel-in-progress: false + +jobs: + release: + runs-on: docker + # The commit that the release makes (CHANGELOG.md) says [skip ci]; this is the belt for those braces. + if: ${{ !contains(github.event.head_commit.message, '[skip ci]') }} + outputs: + version: ${{ steps.version.outputs.version }} + steps: + - uses: actions/checkout@v4 + with: + fetch-depth: 0 # the whole history: the next version depends on every commit since the last tag + token: ${{ secrets.FORGEJO_TOKEN }} + - uses: actions/setup-node@v4 + with: + node-version: 24 + - name: Release + env: + GITEA_TOKEN: ${{ secrets.FORGEJO_TOKEN }} + GITEA_URL: https://git.kmalloc.org + GIT_AUTHOR_NAME: sonda-release + GIT_AUTHOR_EMAIL: squid@kmalloc.org + GIT_COMMITTER_NAME: sonda-release + GIT_COMMITTER_EMAIL: squid@kmalloc.org + run: > + npx --yes + -p semantic-release@25 + -p @semantic-release/commit-analyzer@13.0.1 + -p @semantic-release/release-notes-generator@14.1.1 + -p @semantic-release/changelog@7.0.0 + -p @semantic-release/git@11.0.1 + -p conventional-changelog-conventionalcommits@8.0.0 + -p @saithodev/semantic-release-gitea@2.1.0 + semantic-release + - name: Which version was made, if any + id: version + run: | + # The tag of a release points at the commit the release made, which is where the checkout now is. + tag="$(git tag --points-at HEAD | grep -E '^v[0-9]+\.[0-9]+\.[0-9]+$' | head -n 1 || true)" + echo "version=${tag#v}" >> "$GITHUB_OUTPUT" + echo "released: ${tag:-nothing}" + + # The Alpine of the arm64 image, by digest: kaniko, which has no emulation here, takes the base of every stage for the + # platform of the runner, so the last stage is told which one to use. + base: + needs: release + if: ${{ needs.release.outputs.version != '' }} + runs-on: docker + container: + image: gcr.io/go-containerregistry/crane:debug + outputs: + arm64: ${{ steps.digest.outputs.arm64 }} + steps: + - id: digest + run: echo "arm64=alpine@$(crane digest --platform linux/arm64 alpine:3.22)" >> "$GITHUB_OUTPUT" + + # One image for each architecture. The Go program crosses to the other one with no emulation, and the last stage of the + # Dockerfile runs no command (see the Dockerfile). + image: + needs: [release, base] + if: ${{ needs.release.outputs.version != '' }} + runs-on: docker + strategy: + matrix: + arch: [amd64, arm64] + container: + image: gcr.io/kaniko-project/executor:v1.23.2-debug + steps: + - name: Build the image from the tag and push it as X.Y.Z-ARCH + env: + VERSION: ${{ needs.release.outputs.version }} + ARCH: ${{ matrix.arch }} + ARM64_BASE: ${{ needs.base.outputs.arm64 }} + REGISTRY_USER: squid + REGISTRY_TOKEN: ${{ secrets.FORGEJO_TOKEN }} + run: | + set -eu + mkdir -p /kaniko/.docker + auth="$(printf '%s:%s' "$REGISTRY_USER" "$REGISTRY_TOKEN" | base64 | tr -d '\n')" + printf '{"auths":{"git.kmalloc.org":{"auth":"%s"}}}' "$auth" > /kaniko/.docker/config.json + base=alpine:3.22 + if [ "$ARCH" = arm64 ]; then base="$ARM64_BASE"; fi + /kaniko/executor \ + --dockerfile Dockerfile \ + --context "git://git.kmalloc.org/squid/sonda.git#refs/tags/v${VERSION}" \ + --build-arg "VERSION=${VERSION}" \ + --build-arg "SONDA_ARCH=${ARCH}" \ + --build-arg "RUNTIME_BASE=${base}" \ + --label "org.opencontainers.image.version=${VERSION}" \ + --destination "git.kmalloc.org/squid/sonda:${VERSION}-${ARCH}" \ + --verbosity info + + # The tags that people use (X.Y.Z, X.Y, latest) point at a list of the two images, so that each machine takes its own. + manifest: + needs: [release, image] + if: ${{ needs.release.outputs.version != '' }} + runs-on: docker + container: + image: gcr.io/go-containerregistry/crane:debug + steps: + - name: Join the images under X.Y.Z, X.Y and latest + env: + VERSION: ${{ needs.release.outputs.version }} + REGISTRY_USER: squid + REGISTRY_TOKEN: ${{ secrets.FORGEJO_TOKEN }} + run: | + set -eu + image=git.kmalloc.org/squid/sonda + crane auth login git.kmalloc.org -u "$REGISTRY_USER" -p "$REGISTRY_TOKEN" + # Kaniko writes the architecture of the runner in both images: say the right one for each. + for arch in amd64 arm64; do + crane mutate "${image}:${VERSION}-${arch}" --set-platform "linux/${arch}" --tag "${image}:${VERSION}-${arch}" + done + crane index append \ + --tag "${image}:${VERSION}" \ + --manifest "${image}:${VERSION}-amd64" \ + --manifest "${image}:${VERSION}-arm64" + crane tag "${image}:${VERSION}" "${VERSION%.*}" + crane tag "${image}:${VERSION}" latest diff --git a/.releaserc.json b/.releaserc.json new file mode 100644 index 0000000..a042e35 --- /dev/null +++ b/.releaserc.json @@ -0,0 +1,35 @@ +{ + "branches": ["main"], + "tagFormat": "v${version}", + "plugins": [ + ["@semantic-release/commit-analyzer", { "preset": "conventionalcommits" }], + [ + "@semantic-release/release-notes-generator", + { + "preset": "conventionalcommits", + "presetConfig": { + "types": [ + { "type": "feat", "section": "Features" }, + { "type": "fix", "section": "Bug fixes" }, + { "type": "perf", "section": "Performance" }, + { "type": "refactor", "section": "Refactoring" }, + { "type": "docs", "section": "Documentation" }, + { "type": "style", "hidden": true }, + { "type": "test", "hidden": true }, + { "type": "chore", "hidden": true }, + { "type": "ci", "hidden": true } + ] + } + } + ], + ["@semantic-release/changelog", { "changelogFile": "CHANGELOG.md", "changelogTitle": "# Changelog" }], + [ + "@semantic-release/git", + { + "assets": ["CHANGELOG.md"], + "message": "chore(release): ${nextRelease.version} [skip ci]\n\n${nextRelease.notes}" + } + ], + ["@saithodev/semantic-release-gitea", { "giteaUrl": "https://git.kmalloc.org" }] + ] +} diff --git a/CHANGELOG.md b/CHANGELOG.md new file mode 100644 index 0000000..c54bc8d --- /dev/null +++ b/CHANGELOG.md @@ -0,0 +1,46 @@ +# Changelog + +## [0.5.0](https://git.kmalloc.org/squid/sonda/compare/v0.4.2...v0.5.0) (2026-11-17) + +### Features + +* **android:** add an Android app ([ba10b8e](https://git.kmalloc.org/squid/sonda/commit/ba10b8ef7bbcf4fe3735e7b931d1b687259cc044)), closes [#47](https://git.kmalloc.org/squid/sonda/issues/47) +* **web:** talk to the Android app ([995f2e5](https://git.kmalloc.org/squid/sonda/commit/995f2e5ae013897a56743b60eeedea909fe04db9)) + +### Bug fixes + +* **web:** show a restored queue on the lock screen ([a2d6d2a](https://git.kmalloc.org/squid/sonda/commit/a2d6d2a925edf8de89a7a4df0afbfa82004ccf87)) + +## [0.4.2](https://git.kmalloc.org/squid/sonda/compare/v0.4.1...v0.4.2) (2026-11-17) + +### Bug fixes + +* **web:** make the seek bar fit the width of a phone ([6220238](https://git.kmalloc.org/squid/sonda/commit/6220238068c446a97d1726697601f7ba5e126028)), closes [#45](https://git.kmalloc.org/squid/sonda/issues/45) + +## [0.4.1](https://git.kmalloc.org/squid/sonda/compare/v0.4.0...v0.4.1) (2026-11-17) + +### Bug fixes + +* **web:** keep the controls of the full-screen player on screen on a phone ([a757743](https://git.kmalloc.org/squid/sonda/commit/a757743161ac3f7a348884a9f7b2490ab09b99e1)), closes [#43](https://git.kmalloc.org/squid/sonda/issues/43) + +## [0.4.0](https://git.kmalloc.org/squid/sonda/compare/v0.3.0...v0.4.0) (2026-11-16) + +### Features + +* **web:** make Sonda feel like an app on a phone ([75a7898](https://git.kmalloc.org/squid/sonda/commit/75a7898c68ca65c8c4efa0f51b72d62ac9a4db6e)) + +### Documentation + +* note that this repo moved to git.kmalloc.org ([ee31e0e](https://git.kmalloc.org/squid/sonda/commit/ee31e0ee7caf9e7510b7cfde1f4e096721966e90)) + +## [0.3.0](https://git.kmalloc.org/squid/sonda/compare/v0.2.0...v0.3.0) (2026-11-16) + +### Features + +* publish the Docker image for ARM as well ([b37e3db](https://git.kmalloc.org/squid/sonda/commit/b37e3db037a442af439c5183cf4937a9be630a14)) + +## [0.2.0](https://git.kmalloc.org/squid/sonda/compare/v0.1.0...v0.2.0) (2026-11-16) + +### Features + +* scan the libraries by themselves when their music changed ([89f1b52](https://git.kmalloc.org/squid/sonda/commit/89f1b5275a3f1d0115f1cdd22512daebebf964d2)) diff --git a/Dockerfile b/Dockerfile index c952f15..786dc20 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,8 +1,11 @@ # syntax=docker/dockerfile:1 +# RUNTIME_BASE is alpine:3.22 unless the CI release asks for another architecture, with the digest of that one. +ARG RUNTIME_BASE=alpine:3.22 + # The web app: built once here, written (by its Vite config) to /src/internal/webui/dist, where the Go # build below embeds it. Nothing of Node reaches the final image. -FROM node:24-alpine AS web +FROM --platform=$BUILDPLATFORM node:24-alpine AS web WORKDIR /src/web COPY web/package.json web/package-lock.json ./ RUN npm ci @@ -12,7 +15,13 @@ RUN npm run build # Build: Sonda has no CGO (SQLite, PostgreSQL and the tag reader are pure Go), so the binary # is static and the final image needs nothing but it and the CA certificates. The web app is inside it # (-tags webui), so sondad serves it on / and the API on /api. -FROM golang:1.27-alpine AS build +FROM --platform=$BUILDPLATFORM golang:1.27-alpine AS build +# Built on the machine that builds, for the machine that runs: Go crosses to another architecture with no emulation +# (TARGETOS and TARGETARCH come from the platform asked for). +ARG TARGETOS +ARG TARGETARCH +# SONDA_ARCH is for a builder that cannot say TARGETARCH (the CI release, see .forgejo/workflows/release.yml). +ARG SONDA_ARCH WORKDIR /src COPY go.mod go.sum ./ RUN go mod download @@ -20,19 +29,28 @@ COPY cmd ./cmd COPY internal ./internal COPY migrations ./migrations COPY --from=web /src/internal/webui/dist ./internal/webui/dist -RUN CGO_ENABLED=0 go build -tags webui -trimpath -ldflags="-s -w" -o /out/sondad ./cmd/sondad +# The version of the release (see .releaserc.json), as GET /version and the User-Agent of the providers say it. +ARG VERSION=dev +RUN CGO_ENABLED=0 GOOS=${TARGETOS:-linux} GOARCH=${SONDA_ARCH:-${TARGETARCH:-amd64}} go build -tags webui -trimpath -ldflags="-s -w -X main.version=${VERSION}" -o /out/sondad ./cmd/sondad -FROM alpine:3.22 +# What the image has besides the program (the zones of tzdata, the user, the folders) is made here, on the machine that +# builds. The last stage then runs no command, so it can be built for another architecture with no emulation. +FROM --platform=$BUILDPLATFORM alpine:3.22 AS rootfs +RUN apk add --no-cache tzdata \ + && addgroup -S -g 10001 sonda \ + && adduser -S -u 10001 -G sonda -h /data -H sonda \ + && mkdir -p /out/data /out/music + +FROM ${RUNTIME_BASE} LABEL org.opencontainers.image.title="Sonda" \ org.opencontainers.image.description="A privacy-first, self-hosted music server" \ org.opencontainers.image.source="https://git.kmalloc.org/squid/sonda" -# ca-certificates: the providers an admin may switch on are reached over https. -# tzdata: log times in the zone the operator sets with TZ. -RUN apk add --no-cache ca-certificates tzdata \ - && addgroup -S -g 10001 sonda \ - && adduser -S -u 10001 -G sonda -h /data -H sonda \ - && mkdir -p /data /music \ - && chown sonda:sonda /data +# The certificates of alpine (ca-certificates-bundle) are what the providers an admin may switch on are reached with, +# over https. tzdata is for the log times in the zone the operator sets with TZ. +COPY --from=rootfs /usr/share/zoneinfo /usr/share/zoneinfo +COPY --from=rootfs /etc/passwd /etc/group /etc/shadow /etc/ +COPY --from=rootfs --chown=10001:10001 /out/data /data +COPY --from=rootfs /out/music /music COPY --from=build /out/sondad /usr/local/bin/sondad # Everything Sonda writes is under /data: the database and the files it makes (covers, pictures). diff --git a/Makefile b/Makefile index c2f008f..75ee9da 100644 --- a/Makefile +++ b/Makefile @@ -8,8 +8,11 @@ .PHONY: build web test +# The version is the last release tag, and how far this checkout is from it (v1.2.3-4-gabcdef), or "dev" outside git. +VERSION ?= $(shell git describe --tags --always 2>/dev/null | sed 's/^v//' || echo dev) + build: web - CGO_ENABLED=0 go build -tags webui -trimpath -ldflags="-s -w" -o bin/sondad ./cmd/sondad + CGO_ENABLED=0 go build -tags webui -trimpath -ldflags="-s -w -X main.version=$(VERSION)" -o bin/sondad ./cmd/sondad web: cd web && npm ci && npm run build diff --git a/README.md b/README.md index 8cc969a..0ddc654 100644 --- a/README.md +++ b/README.md @@ -1,5 +1,9 @@ # Sonda +**This repository has moved.** Development continues at +[git.kmalloc.org/squid/sonda](https://git.kmalloc.org/squid/sonda); this +Codeberg mirror is archived and read-only. + Sonda is a privacy-first, self-hosted music server written in Go. It streams the music you already own, from your own disks, and keeps everything it knows about you on your own machine. It is a single executable, one database (SQLite by default, PostgreSQL if you prefer) and the folders that hold your music. There is no Redis, no message broker and no cloud account. @@ -10,7 +14,7 @@ It is a single executable, one database (SQLite by default, PostgreSQL if you pr - **Accounts.** An account is an email address and a password. The first user to register becomes the admin and registration then closes; admins create the other users. The address only identifies the account: Sonda sends no mail, does not check that the address exists, and keeps it on your server. It is trimmed and lowercased, and unique. Accounts made before addresses were asked for keep the plain name they had as their login. Short-lived access tokens (JWT) plus rotating refresh tokens, so a stolen refresh token is detected. - **Libraries.** A library is a name and a folder, managed through the API. Sonda only reads your music folders: it never writes or renames a file, and it deletes one only when an admin asks to remove the extra copy of a song and you turned on `library.allow_delete` (see **Duplicates**), which is off by default. -- **Scanner.** Reads MP3 and FLAC tags and audio properties with several workers in parallel. Rescans are incremental, renamed files keep their identity, vanished files are flagged (never deleted), and a library whose folder looks empty or unreadable (an unmounted NAS) is left alone instead of being wiped. Audio in other formats (m4a, ogg, opus, wav, wma and similar) is not read yet, but it is counted as `unsupported` in the scan result instead of disappearing silently. NAS housekeeping folders (`@Recycle`, `#recycle`, `@eaDir`, `.@__thumb`, `$RECYCLE.BIN`) are skipped. +- **Scanner.** Reads MP3 and FLAC tags and audio properties with several workers in parallel. Rescans are incremental, renamed files keep their identity, vanished files are flagged (never deleted), and a library whose folder looks empty or unreadable (an unmounted NAS) is left alone instead of being wiped. Audio in other formats (m4a, ogg, opus, wav, wma and similar) is not read yet, but it is counted as `unsupported` in the scan result instead of disappearing silently. NAS housekeeping folders (`@Recycle`, `#recycle`, `@eaDir`, `.@__thumb`, `$RECYCLE.BIN`) are skipped. **Scans by itself.** Every 15 minutes (`library.auto_scan_minutes`) Sonda looks at the folders of each library, which costs only the names of the files, and scans a library whose music changed: a song or a folder came, went or was renamed. A library is also scanned at least once a day, to find a song that was tagged again where it stands. It never scans while another scan runs, and a folder it cannot read (a NAS that is not mounted) is left alone. - **Catalog.** Browse and search artists, albums and songs, with paging, by library, artist or album. Only songs you can actually play are listed. - **Duplicates.** `GET /library/duplicates` (admin) lists the songs that are in more than one file: the same set of main artists, the same title and durations within 3 seconds, possibly on different albums. It is worked out from the index, touches no file, and returns no file path. Each group proposes the copy to keep (lossless first, then the higher bitrate, then the bigger file, then the oldest). A background job (`POST /library/duplicates/check`, like the other bulk jobs) reads the files of the groups and keeps their SHA-256, so a group can be called `identical` (byte for byte). `POST /library/duplicates/clean` **deletes the extra copies of one song from the disk**, and it is the one thing Sonda does that writes in your music folders, so it is off until you set `library.allow_delete` (or `SONDA_ALLOW_DELETE=true`) and mount the folders writable. It deletes only when an admin asks, never by itself, and the server checks again at that moment that no scan is running, that the songs are copies of one song, and that every file is still the one the last scan saw (same size and date, a regular file, not a link, inside its library): so the last copy of a song is never deleted, a file that changed is not deleted, and every file is checked before the first is deleted. The listens and the playlist items of a deleted copy move to the one that stays, so your taste and your playlists are not lost. Folders are never removed, and nothing is sent anywhere. The web app has a Duplicates section in Admin: a table of the copies of each song with the copy to keep already chosen (you can pick another), the check with its progress and a Stop button, **Delete the others** for one song and **Clean all suggestions** for all of them, each after a question that lists the files and the space it frees; with deleting off everything is visible and the delete buttons are disabled. - **Streaming.** `GET` and `HEAD` with `Range` support, so players can seek. Opening or prefetching a stream does not record a listen. `GET /tracks/{id}/peaks` gives the shape of a song for the seek bar: 120 levels from 0 to 255, how loud it is along its length. The server finds it by decoding the file (MP3 and FLAC, in pure Go: nothing else to install), which takes a few seconds, so the first request starts the work in the background and answers `202` with `Retry-After`; it is done once for each file, worked out again if the size or the date of the file change, and one song at a time, so a NAS is not kept busy. A file that cannot be decoded answers `waveform_unavailable`, and that is remembered too. A friend's song has no shape yet. @@ -65,7 +69,7 @@ A plain `go build -o bin/sondad ./cmd/sondad` needs no Node and gives the API on The image holds `sondad` with the web app inside, and nothing else: it builds the app itself, so you need no Node on your machine. It runs as an ordinary user, keeps the database and the files Sonda makes under `/data`, listens on port 8080 inside the container, and does not start without `SONDA_JWT_SECRET`. -The image is published on the registry of git.kmalloc.org, so you do not have to build it: `git.kmalloc.org/squid/sonda:latest` is the last one, and `git.kmalloc.org/squid/sonda:` (the first seven characters of a commit of `main`) is one you can stay on. Anyone can pull it, with no login. To build it yourself instead, run `docker build -t sonda .` and use `sonda` where the commands below say `git.kmalloc.org/squid/sonda:latest`. +The image is published on the registry of git.kmalloc.org, so you do not have to build it: `git.kmalloc.org/squid/sonda:latest` is the last one, and `git.kmalloc.org/squid/sonda:0.3.0` (a version from [CHANGELOG.md](CHANGELOG.md)) is one you can stay on. It runs on amd64 and on arm64 (a Raspberry Pi, an ARM NAS): one tag gives each machine its own. Anyone can pull it, with no login. To build it yourself instead, run `docker build -t sonda .` and use `sonda` where the commands below say `git.kmalloc.org/squid/sonda:latest`. ```bash docker pull git.kmalloc.org/squid/sonda:latest @@ -104,6 +108,7 @@ Precedence is: built-in defaults, then the file, then environment variables. An |---|---|---|---| | `server.listen` | `SONDA_LISTEN` | `127.0.0.1:8080` | Address to listen on. Localhost by default. | | `library.scan_workers` | | `4` | Files whose tags are read in parallel during a scan. | +| `library.auto_scan_minutes` | `SONDA_AUTO_SCAN_MINUTES` | `15` | How often, in minutes, Sonda looks at the folders of the libraries and scans the ones whose music changed (a song or a folder came, went or was renamed); `0` turns it off. Looking reads the names of the files and nothing else, so it is cheap for a NAS. A library is scanned at least once a day anyway, which finds a song that was tagged again where it stands. A folder that cannot be read (a NAS that is not mounted) is left alone. | | `library.allow_delete` | `SONDA_ALLOW_DELETE` | `false` | Lets an admin delete the extra copy of a song from the music folders (see **Duplicates**). It is the one thing that makes Sonda write there, so it needs the folders mounted writable. A value that is not `true` or `false` is an error. | | `database.driver` | `SONDA_DB_DRIVER` | `sqlite` | `sqlite` or `postgres`. | | `database.path` | `SONDA_DB_PATH` | `sonda.db` | SQLite file (driver `sqlite`). | @@ -389,7 +394,7 @@ Back up the database and `sonda.toml`. Your music stays wherever you keep it. ## Web app -A web client lives in `web/` (React, Vite and shadcn/ui). It talks only to the Sonda server: no CDN, no external fonts, no analytics. With the app built into the binary (`make build`, or the Docker image) `sondad` serves it: open the address of the server, for example `http://127.0.0.1:8080`, and sign in. The page carries a strict Content-Security-Policy (only resources of the server itself, no inline scripts), cannot be framed and sends no referrer, and a link inside the app (`/admin/users`) works when you reload it. The player draws a live picture of what is playing, in the browser, from the sound itself (Web Audio). Settings has a choice for it, kept on the device: a spectrogram (the last seconds, low notes at the bottom, the default), the classic bars with falling caps, an oscilloscope, Milkdrop, or nothing. The bars, the oscilloscope and the spectrogram take the colour of this server or, for a friend's song, the colour of the friend. Milkdrop fills the background of the full-screen player with the pictures Winamp made famous, drawn on the device with [butterchurn](https://github.com/jberg/butterchurn) (MIT) and its presets, which are part of the app: nothing is fetched from outside. It is loaded only when chosen, and anyone who asked the system for less motion gets the spectrogram instead, because the pictures flash. The player listens to the sound and changes nothing of it, and draws only while something plays. +A web client lives in `web/` (React, Vite and shadcn/ui). It talks only to the Sonda server: no CDN, no external fonts, no analytics. With the app built into the binary (`make build`, or the Docker image) `sondad` serves it: open the address of the server, for example `http://127.0.0.1:8080`, and sign in. The page carries a strict Content-Security-Policy (only resources of the server itself, no inline scripts), cannot be framed and sends no referrer, and a link inside the app (`/admin/users`) works when you reload it. The player draws a live picture of what is playing, in the browser, from the sound itself (Web Audio). Settings has a choice for it, kept on the device: a spectrogram (the last seconds, low notes at the bottom, the default), the classic bars with falling caps, an oscilloscope, Milkdrop, or nothing. The bars, the oscilloscope and the spectrogram take the colour of this server or, for a friend's song, the colour of the friend. Milkdrop fills the background of the full-screen player with the pictures Winamp made famous, drawn on the device with [butterchurn](https://github.com/jberg/butterchurn) (MIT) and its presets, which are part of the app: nothing is fetched from outside. It is loaded only when chosen, and anyone who asked the system for less motion gets the spectrogram instead, because the pictures flash. The player listens to the sound and changes nothing of it, and draws only while something plays. On a phone the player is one row at the foot of the page (and is not there while nothing plays); a tap or a swipe up opens the full-screen player, a swipe down or the Back gesture closes it, and the lock screen shows the song with its seek bar and follows play and pause. The queue is kept in the browser, so a page that is reloaded, or a tab that Android throws away, comes back paused on the same song at the same second. To work on the interface itself, run the Vite dev server next to a running `sondad` (set `SONDA_URL` to where it listens: the default is `http://127.0.0.1:8080`): @@ -403,6 +408,38 @@ What it does today: sign in (and create the first account of a new server), brow More commands, all run in `web/`: `npm test`, `npm run build`, and `npm run gen:api`, which rebuilds `src/api/schema.d.ts` from the OpenAPI spec (it fetches the generator with `npx`, so it needs the network once). `npm run build` writes to `internal/webui/dist` (git-ignored), not to `web/dist`. +## Android app + +`android/` holds a small Android app: a Capacitor shell that opens a Sonda server in a WebView, with its own icon and no browser bars. It is for a phone whose browser cannot install a PWA. It has no copy of the web app: it shows the one of your server, so a new version of the server is a new version of the app. + +- The first time it asks for the address of the server (`music.example.org`, or `http://192.168.1.5:8080`) and remembers it. Settings has Change server, shown only inside the app. +- It trusts the certificate authorities installed on the phone, so a server behind a private CA opens once the CA is installed (Settings, Security, Install a certificate). It also opens a server on plain `http`. +- A WebView has no Media Session API, so the app keeps its own: a notification with the song, its cover and the buttons, and the lock screen and headset buttons work. The music goes on with the screen off. From Android 13 it asks to show notifications; without a yes the music still plays and only the notification is hidden. + +To build it you need Node, a JDK 21 and the Android SDK (platform 36 and its build tools; set `ANDROID_HOME`): + +```bash +cd android +npm ci +npm run apk # android/android/app/build/outputs/apk/debug/app-debug.apk +adb install -r android/app/build/outputs/apk/debug/app-debug.apk +``` + +The APK is signed with the debug key, which is fine for your own phone. It is not part of the release pipeline, because the runner has no Android SDK. `npm test` checks how an address typed by hand is read. + +## Releases + +Every merge into `main` can make a release, by itself (`.forgejo/workflows/release.yml`, [semantic-release](https://semantic-release.gitbook.io)). The next version comes from the messages of the commits since the last one, written as [Conventional Commits](https://www.conventionalcommits.org): + +| Commit | Release | +|---|---| +| `fix: ...`, `perf: ...` | patch (0.2.0 to 0.2.1) | +| `feat: ...` | minor (0.2.0 to 0.3.0) | +| `feat!: ...`, or `BREAKING CHANGE:` in the body | major (0.2.0 to 1.0.0) | +| `docs:`, `test:`, `chore:`, `ci:`, `style:` | none by themselves | + +A release adds its entry to [CHANGELOG.md](CHANGELOG.md), tags the commit (`v0.3.0`), makes the release on the forge, and the image is built from the tag and pushed to `git.kmalloc.org/squid/sonda` as `0.3.0`, `0.3` and `latest`. The version is inside the binary: `GET /version` and the User-Agent of the providers say it (a build that no release made says `dev`). The commit that writes `CHANGELOG.md` says `[skip ci]`. The image is made for amd64 and for arm64, and each tag points at both. The runner has no Docker and cannot emulate ARM, so the images are built with [kaniko](https://github.com/GoogleContainerTools/kaniko): the Go program is compiled for ARM with no emulation, the last stage of the Dockerfile runs no command, and a last job (with [crane](https://github.com/google/go-containerregistry)) says the architecture of each image and joins them. The workflow needs the secret `FORGEJO_TOKEN`: a token of the owner with the scopes `write:repository` and `write:package`. + ## Development ```bash diff --git a/android/.gitignore b/android/.gitignore new file mode 100644 index 0000000..b29e650 --- /dev/null +++ b/android/.gitignore @@ -0,0 +1,14 @@ +node_modules/ +# Build output and local settings of the Android project +android/.gradle/ +android/build/ +android/app/build/ +android/local.properties +android/.idea/ +android/captures/ +android/app/src/main/assets/public/ +android/app/src/main/assets/capacitor.config.json +android/app/src/main/assets/capacitor.plugins.json +android/capacitor-cordova-android-plugins/ +*.keystore +*.jks diff --git a/android/android/.gitignore b/android/android/.gitignore new file mode 100644 index 0000000..48354a3 --- /dev/null +++ b/android/android/.gitignore @@ -0,0 +1,101 @@ +# Using Android gitignore template: https://github.com/github/gitignore/blob/HEAD/Android.gitignore + +# Built application files +*.apk +*.aar +*.ap_ +*.aab + +# Files for the ART/Dalvik VM +*.dex + +# Java class files +*.class + +# Generated files +bin/ +gen/ +out/ +# Uncomment the following line in case you need and you don't have the release build type files in your app +# release/ + +# Gradle files +.gradle/ +build/ + +# Local configuration file (sdk path, etc) +local.properties + +# Proguard folder generated by Eclipse +proguard/ + +# Log Files +*.log + +# Android Studio Navigation editor temp files +.navigation/ + +# Android Studio captures folder +captures/ + +# IntelliJ +*.iml +.idea/workspace.xml +.idea/tasks.xml +.idea/gradle.xml +.idea/assetWizardSettings.xml +.idea/dictionaries +.idea/libraries +# Android Studio 3 in .gitignore file. +.idea/caches +.idea/modules.xml +# Comment next line if keeping position of elements in Navigation Editor is relevant for you +.idea/navEditor.xml + +# Keystore files +# Uncomment the following lines if you do not want to check your keystore files in. +#*.jks +#*.keystore + +# External native build folder generated in Android Studio 2.2 and later +.externalNativeBuild +.cxx/ + +# Google Services (e.g. APIs or Firebase) +# google-services.json + +# Freeline +freeline.py +freeline/ +freeline_project_description.json + +# fastlane +fastlane/report.xml +fastlane/Preview.html +fastlane/screenshots +fastlane/test_output +fastlane/readme.md + +# Version control +vcs.xml + +# lint +lint/intermediates/ +lint/generated/ +lint/outputs/ +lint/tmp/ +# lint/reports/ + +# Android Profiling +*.hprof + +# Cordova plugins for Capacitor +capacitor-cordova-android-plugins + +# Copied web assets +app/src/main/assets/public + +# Generated Config files +app/src/main/assets/capacitor.config.json +app/src/main/assets/capacitor.plugins.json +app/src/main/res/xml/config.xml diff --git a/android/android/app/.gitignore b/android/android/app/.gitignore new file mode 100644 index 0000000..043df80 --- /dev/null +++ b/android/android/app/.gitignore @@ -0,0 +1,2 @@ +/build/* +!/build/.npmkeep diff --git a/android/android/app/build.gradle b/android/android/app/build.gradle new file mode 100644 index 0000000..8e18dfd --- /dev/null +++ b/android/android/app/build.gradle @@ -0,0 +1,55 @@ +apply plugin: 'com.android.application' + +android { + namespace = "app.sonda" + compileSdk = rootProject.ext.compileSdkVersion + defaultConfig { + applicationId "app.sonda" + minSdkVersion rootProject.ext.minSdkVersion + targetSdkVersion rootProject.ext.targetSdkVersion + versionCode 1 + versionName "1.0" + testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner" + aaptOptions { + // Files and dirs to omit from the packaged assets dir, modified to accommodate modern web apps. + // Default: https://android.googlesource.com/platform/frameworks/base/+/282e181b58cf72b6ca770dc7ca5f91f135444502/tools/aapt/AaptAssets.cpp#61 + ignoreAssetsPattern = '!.svn:!.git:!.ds_store:!*.scc:.*:!CVS:!thumbs.db:!picasa.ini:!*~' + } + } + buildTypes { + release { + minifyEnabled false + proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' + } + } +} + +repositories { + flatDir{ + dirs '../capacitor-cordova-android-plugins/src/main/libs', 'libs' + } +} + +dependencies { + implementation fileTree(include: ['*.jar'], dir: 'libs') + implementation "androidx.appcompat:appcompat:$androidxAppCompatVersion" + implementation "androidx.coordinatorlayout:coordinatorlayout:$androidxCoordinatorLayoutVersion" + implementation "androidx.core:core-splashscreen:$coreSplashScreenVersion" + implementation "androidx.media:media:1.7.0" + implementation project(':capacitor-android') + testImplementation "junit:junit:$junitVersion" + androidTestImplementation "androidx.test.ext:junit:$androidxJunitVersion" + androidTestImplementation "androidx.test.espresso:espresso-core:$androidxEspressoCoreVersion" + implementation project(':capacitor-cordova-android-plugins') +} + +apply from: 'capacitor.build.gradle' + +try { + def servicesJSON = file('google-services.json') + if (servicesJSON.text) { + apply plugin: 'com.google.gms.google-services' + } +} catch(Exception e) { + logger.info("google-services.json not found, google-services plugin not applied. Push Notifications won't work") +} diff --git a/android/android/app/capacitor.build.gradle b/android/android/app/capacitor.build.gradle new file mode 100644 index 0000000..1005ebc --- /dev/null +++ b/android/android/app/capacitor.build.gradle @@ -0,0 +1,19 @@ +// DO NOT EDIT THIS FILE! IT IS GENERATED EACH TIME "capacitor update" IS RUN + +android { + compileOptions { + sourceCompatibility JavaVersion.VERSION_21 + targetCompatibility JavaVersion.VERSION_21 + } +} + +apply from: "../capacitor-cordova-android-plugins/cordova.variables.gradle" +dependencies { + implementation project(':capacitor-app') + +} + + +if (hasProperty('postBuildExtras')) { + postBuildExtras() +} diff --git a/android/android/app/proguard-rules.pro b/android/android/app/proguard-rules.pro new file mode 100644 index 0000000..f1b4245 --- /dev/null +++ b/android/android/app/proguard-rules.pro @@ -0,0 +1,21 @@ +# Add project specific ProGuard rules here. +# You can control the set of applied configuration files using the +# proguardFiles setting in build.gradle. +# +# For more details, see +# http://developer.android.com/guide/developing/tools/proguard.html + +# If your project uses WebView with JS, uncomment the following +# and specify the fully qualified class name to the JavaScript interface +# class: +#-keepclassmembers class fqcn.of.javascript.interface.for.webview { +# public *; +#} + +# Uncomment this to preserve the line number information for +# debugging stack traces. +#-keepattributes SourceFile,LineNumberTable + +# If you keep the line number information, uncomment this to +# hide the original source file name. +#-renamesourcefileattribute SourceFile diff --git a/android/android/app/src/main/AndroidManifest.xml b/android/android/app/src/main/AndroidManifest.xml new file mode 100644 index 0000000..fa41fea --- /dev/null +++ b/android/android/app/src/main/AndroidManifest.xml @@ -0,0 +1,50 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/android/android/app/src/main/java/app/sonda/MainActivity.java b/android/android/app/src/main/java/app/sonda/MainActivity.java new file mode 100644 index 0000000..83e23a3 --- /dev/null +++ b/android/android/app/src/main/java/app/sonda/MainActivity.java @@ -0,0 +1,24 @@ +package app.sonda; + +import android.os.Bundle; +import android.webkit.WebView; +import com.getcapacitor.BridgeActivity; + +public class MainActivity extends BridgeActivity { + @Override + public void onCreate(Bundle savedInstanceState) { + super.onCreate(savedInstanceState); + WebView web = getBridge().getWebView(); + web.addJavascriptInterface(new SondaNative(this), "SondaNative"); + // The buttons of the notification and of the lock screen go back to the page. + MediaService.listener = (name, ms) -> web.post(() -> web.evaluateJavascript( + "window.sondaNativeAction && window.sondaNativeAction('" + name + "'," + ms + ")", null)); + } + + @Override + public void onDestroy() { + MediaService.listener = null; + if (isFinishing()) MediaService.end(this); + super.onDestroy(); + } +} diff --git a/android/android/app/src/main/java/app/sonda/MediaService.java b/android/android/app/src/main/java/app/sonda/MediaService.java new file mode 100644 index 0000000..552ed9c --- /dev/null +++ b/android/android/app/src/main/java/app/sonda/MediaService.java @@ -0,0 +1,219 @@ +package app.sonda; + +import android.app.Notification; +import android.app.NotificationChannel; +import android.app.NotificationManager; +import android.app.PendingIntent; +import android.app.Service; +import android.content.Context; +import android.content.Intent; +import android.content.pm.ServiceInfo; +import android.graphics.Bitmap; +import android.graphics.BitmapFactory; +import android.os.Build; +import android.os.IBinder; +import android.support.v4.media.MediaMetadataCompat; +import android.support.v4.media.session.MediaSessionCompat; +import android.support.v4.media.session.PlaybackStateCompat; +import androidx.core.app.NotificationCompat; +import androidx.core.content.ContextCompat; +import androidx.media.app.NotificationCompat.MediaStyle; +import java.io.InputStream; +import java.net.HttpURLConnection; +import java.net.URL; + +/** + * Keeps the playback alive while the screen is off or another app is in front, and shows what plays with its + * controls in a notification and on the lock screen. The web app does the playing; this only mirrors it, and + * passes the buttons back through {@link #listener}. + */ +public class MediaService extends Service { + /** Where a press of a button goes: the name is play, pause, next, previous or seekto. */ + interface Listener { + void onAction(String name, long ms); + } + + static volatile Listener listener; + + private static final String CHANNEL = "playback"; + private static final int NOTIFICATION_ID = 1; + private static final String PLAY = "app.sonda.PLAY"; + private static final String PAUSE = "app.sonda.PAUSE"; + private static final String NEXT = "app.sonda.NEXT"; + private static final String PREVIOUS = "app.sonda.PREVIOUS"; + + // The latest word of the page, kept here because the service may start after it was said. + private static NowPlaying latest; + private static MediaService instance; + + private MediaSessionCompat session; + private String artworkUrl = ""; + private Bitmap artwork; + + /** Shows what plays. The first time it starts the service; after that it only updates it. */ + static void show(Context context, NowPlaying now) { + latest = now; + if (instance != null) { + instance.apply(now); + } else { + ContextCompat.startForegroundService(context, new Intent(context, MediaService.class)); + } + } + + /** Nothing plays any more: the notification goes. */ + static void end(Context context) { + latest = null; + if (instance != null) instance.shutDown(); + else context.stopService(new Intent(context, MediaService.class)); + } + + @Override + public void onCreate() { + super.onCreate(); + instance = this; + createChannel(); + session = new MediaSessionCompat(this, "Sonda"); + session.setCallback(new MediaSessionCompat.Callback() { + @Override public void onPlay() { send("play", 0); } + @Override public void onPause() { send("pause", 0); } + @Override public void onSkipToNext() { send("next", 0); } + @Override public void onSkipToPrevious() { send("previous", 0); } + @Override public void onSeekTo(long pos) { send("seekto", pos); } + }); + } + + @Override + public int onStartCommand(Intent intent, int flags, int startId) { + String action = intent == null ? null : intent.getAction(); + if (PLAY.equals(action)) send("play", 0); + else if (PAUSE.equals(action)) send("pause", 0); + else if (NEXT.equals(action)) send("next", 0); + else if (PREVIOUS.equals(action)) send("previous", 0); + if (latest != null) { + apply(latest); + } else { + // Started with nothing to show, or after the app was killed: Android wants a notification anyway, then it goes. + startForeground(NOTIFICATION_ID, notification(null)); + shutDown(); + } + return START_NOT_STICKY; + } + + /** The person swiped the app away: the page is gone, so the music and its notification go too. */ + @Override + public void onTaskRemoved(Intent rootIntent) { + latest = null; + shutDown(); + } + + @Override + public void onDestroy() { + instance = null; + if (session != null) { + session.setActive(false); + session.release(); + session = null; + } + super.onDestroy(); + } + + @Override + public IBinder onBind(Intent intent) { + return null; + } + + private void send(String name, long ms) { + Listener l = listener; + if (l != null) l.onAction(name, ms); + } + + private void shutDown() { + stopForeground(STOP_FOREGROUND_REMOVE); + stopSelf(); + } + + private void apply(NowPlaying now) { + session.setMetadata( + new MediaMetadataCompat.Builder() + .putString(MediaMetadataCompat.METADATA_KEY_TITLE, now.title) + .putString(MediaMetadataCompat.METADATA_KEY_ARTIST, now.artist) + .putString(MediaMetadataCompat.METADATA_KEY_ALBUM, now.album) + .putLong(MediaMetadataCompat.METADATA_KEY_DURATION, now.durationMs) + .putBitmap(MediaMetadataCompat.METADATA_KEY_ALBUM_ART, now.artworkUrl.equals(artworkUrl) ? artwork : null) + .build()); + long actions = PlaybackStateCompat.ACTION_PLAY | PlaybackStateCompat.ACTION_PAUSE | PlaybackStateCompat.ACTION_PLAY_PAUSE + | PlaybackStateCompat.ACTION_SKIP_TO_NEXT | PlaybackStateCompat.ACTION_SKIP_TO_PREVIOUS | PlaybackStateCompat.ACTION_SEEK_TO; + session.setPlaybackState( + new PlaybackStateCompat.Builder() + .setActions(actions) + .setState(now.playing ? PlaybackStateCompat.STATE_PLAYING : PlaybackStateCompat.STATE_PAUSED, now.positionNow(), now.playing ? 1f : 0f) + .build()); + session.setActive(true); + + Notification n = notification(now); + if (Build.VERSION.SDK_INT >= 29) { + startForeground(NOTIFICATION_ID, n, ServiceInfo.FOREGROUND_SERVICE_TYPE_MEDIA_PLAYBACK); + } else { + startForeground(NOTIFICATION_ID, n); + } + if (!now.artworkUrl.isEmpty() && !now.artworkUrl.equals(artworkUrl)) fetchArtwork(now.artworkUrl); + } + + private Notification notification(NowPlaying now) { + NotificationCompat.Builder b = new NotificationCompat.Builder(this, CHANNEL) + .setSmallIcon(R.drawable.ic_stat_sonda) + .setVisibility(NotificationCompat.VISIBILITY_PUBLIC) + .setOnlyAlertOnce(true) + .setShowWhen(false) + .setContentIntent(PendingIntent.getActivity( + this, 0, new Intent(this, MainActivity.class).setFlags(Intent.FLAG_ACTIVITY_SINGLE_TOP), PendingIntent.FLAG_IMMUTABLE | PendingIntent.FLAG_UPDATE_CURRENT)); + if (now == null) return b.setContentTitle("Sonda").build(); + b.setContentTitle(now.title).setContentText(now.artist).setSubText(now.album); + if (now.artworkUrl.equals(artworkUrl) && artwork != null) b.setLargeIcon(artwork); + b.addAction(android.R.drawable.ic_media_previous, getString(R.string.previous), button(PREVIOUS)); + if (now.playing) b.addAction(android.R.drawable.ic_media_pause, getString(R.string.pause), button(PAUSE)); + else b.addAction(android.R.drawable.ic_media_play, getString(R.string.play), button(PLAY)); + b.addAction(android.R.drawable.ic_media_next, getString(R.string.next), button(NEXT)); + b.setStyle(new MediaStyle().setMediaSession(session.getSessionToken()).setShowActionsInCompactView(0, 1, 2)); + return b.build(); + } + + private PendingIntent button(String action) { + return PendingIntent.getService( + this, action.hashCode(), new Intent(this, MediaService.class).setAction(action), PendingIntent.FLAG_IMMUTABLE | PendingIntent.FLAG_UPDATE_CURRENT); + } + + private void createChannel() { + if (Build.VERSION.SDK_INT < 26) return; + NotificationChannel channel = new NotificationChannel(CHANNEL, getString(R.string.channel_playback), NotificationManager.IMPORTANCE_LOW); + channel.setShowBadge(false); + getSystemService(NotificationManager.class).createNotificationChannel(channel); + } + + /** The cover comes from the server with the token in its address; a cover that does not come leaves the notification without one. */ + private void fetchArtwork(String url) { + artworkUrl = url; + artwork = null; + new Thread(() -> { + Bitmap bitmap = null; + try { + HttpURLConnection c = (HttpURLConnection) new URL(url).openConnection(); + c.setConnectTimeout(8000); + c.setReadTimeout(8000); + try (InputStream in = c.getInputStream()) { + bitmap = BitmapFactory.decodeStream(in); + } finally { + c.disconnect(); + } + } catch (Exception ignored) { + // No cover: the notification stays as it is. + } + final Bitmap result = bitmap; + ContextCompat.getMainExecutor(this).execute(() -> { + if (instance != this || !url.equals(artworkUrl) || result == null) return; + artwork = result; + if (latest != null) apply(latest); + }); + }).start(); + } +} diff --git a/android/android/app/src/main/java/app/sonda/NowPlaying.java b/android/android/app/src/main/java/app/sonda/NowPlaying.java new file mode 100644 index 0000000..7c1d696 --- /dev/null +++ b/android/android/app/src/main/java/app/sonda/NowPlaying.java @@ -0,0 +1,51 @@ +package app.sonda; + +import android.os.SystemClock; +import org.json.JSONException; +import org.json.JSONObject; + +/** What the web app says is playing: the song, whether it plays and where it is. */ +final class NowPlaying { + final String title; + final String artist; + final String album; + final String artworkUrl; + final boolean playing; + final long durationMs; + private final long positionMs; + private final long receivedAt; + + private NowPlaying(String title, String artist, String album, String artworkUrl, boolean playing, long positionMs, long durationMs) { + this.title = title; + this.artist = artist; + this.album = album; + this.artworkUrl = artworkUrl; + this.playing = playing; + this.positionMs = positionMs; + this.durationMs = durationMs; + this.receivedAt = SystemClock.elapsedRealtime(); + } + + /** Where the song is now: what the page said, plus the time that has passed if it plays. */ + long positionNow() { + long position = playing ? positionMs + (SystemClock.elapsedRealtime() - receivedAt) : positionMs; + return durationMs > 0 ? Math.min(position, durationMs) : position; + } + + /** The JSON the page sends; null when it is not what was expected. */ + static NowPlaying parse(String json) { + try { + JSONObject o = new JSONObject(json); + return new NowPlaying( + o.optString("title"), + o.optString("artist"), + o.optString("album"), + o.optString("artworkUrl"), + o.optBoolean("playing"), + Math.max(0, o.optLong("positionMs")), + Math.max(0, o.optLong("durationMs"))); + } catch (JSONException e) { + return null; + } + } +} diff --git a/android/android/app/src/main/java/app/sonda/SondaNative.java b/android/android/app/src/main/java/app/sonda/SondaNative.java new file mode 100644 index 0000000..57f2370 --- /dev/null +++ b/android/android/app/src/main/java/app/sonda/SondaNative.java @@ -0,0 +1,47 @@ +package app.sonda; + +import android.Manifest; +import android.app.Activity; +import android.content.pm.PackageManager; +import android.os.Build; +import android.webkit.JavascriptInterface; +import androidx.core.app.ActivityCompat; +import androidx.core.content.ContextCompat; + +/** + * What the web page can ask of the app. A WebView has no Media Session API, so the page tells the app what plays + * and the app keeps a notification with the controls, and the playback alive while the screen is off. + * It is on every page the WebView loads, which is the server the person chose. + */ +final class SondaNative { + private final Activity activity; + private boolean askedForNotifications = false; + + SondaNative(Activity activity) { + this.activity = activity; + } + + @JavascriptInterface + public void update(String json) { + NowPlaying now = NowPlaying.parse(json); + if (now == null) return; + activity.runOnUiThread(() -> { + askForNotifications(); + MediaService.show(activity, now); + }); + } + + @JavascriptInterface + public void stop() { + activity.runOnUiThread(() -> MediaService.end(activity)); + } + + /** From Android 13 a notification needs a yes. Without it the playback goes on, only the notification is hidden. */ + private void askForNotifications() { + if (askedForNotifications || Build.VERSION.SDK_INT < 33) return; + askedForNotifications = true; + if (ContextCompat.checkSelfPermission(activity, Manifest.permission.POST_NOTIFICATIONS) != PackageManager.PERMISSION_GRANTED) { + ActivityCompat.requestPermissions(activity, new String[] {Manifest.permission.POST_NOTIFICATIONS}, 1); + } + } +} diff --git a/android/android/app/src/main/res/drawable/ic_stat_sonda.xml b/android/android/app/src/main/res/drawable/ic_stat_sonda.xml new file mode 100644 index 0000000..1a8e985 --- /dev/null +++ b/android/android/app/src/main/res/drawable/ic_stat_sonda.xml @@ -0,0 +1,10 @@ + + + + diff --git a/android/android/app/src/main/res/drawable/splash.xml b/android/android/app/src/main/res/drawable/splash.xml new file mode 100644 index 0000000..9047d46 --- /dev/null +++ b/android/android/app/src/main/res/drawable/splash.xml @@ -0,0 +1,6 @@ + + + + + + diff --git a/android/android/app/src/main/res/layout/activity_main.xml b/android/android/app/src/main/res/layout/activity_main.xml new file mode 100644 index 0000000..b5ad138 --- /dev/null +++ b/android/android/app/src/main/res/layout/activity_main.xml @@ -0,0 +1,12 @@ + + + + + diff --git a/android/android/app/src/main/res/mipmap-anydpi-v26/ic_launcher.xml b/android/android/app/src/main/res/mipmap-anydpi-v26/ic_launcher.xml new file mode 100644 index 0000000..036d09b --- /dev/null +++ b/android/android/app/src/main/res/mipmap-anydpi-v26/ic_launcher.xml @@ -0,0 +1,5 @@ + + + + + \ No newline at end of file diff --git a/android/android/app/src/main/res/mipmap-anydpi-v26/ic_launcher_round.xml b/android/android/app/src/main/res/mipmap-anydpi-v26/ic_launcher_round.xml new file mode 100644 index 0000000..036d09b --- /dev/null +++ b/android/android/app/src/main/res/mipmap-anydpi-v26/ic_launcher_round.xml @@ -0,0 +1,5 @@ + + + + + \ No newline at end of file diff --git a/android/android/app/src/main/res/mipmap-hdpi/ic_launcher.png b/android/android/app/src/main/res/mipmap-hdpi/ic_launcher.png new file mode 100644 index 0000000..f370e24 Binary files /dev/null and b/android/android/app/src/main/res/mipmap-hdpi/ic_launcher.png differ diff --git a/android/android/app/src/main/res/mipmap-hdpi/ic_launcher_foreground.png b/android/android/app/src/main/res/mipmap-hdpi/ic_launcher_foreground.png new file mode 100644 index 0000000..4929e74 Binary files /dev/null and b/android/android/app/src/main/res/mipmap-hdpi/ic_launcher_foreground.png differ diff --git a/android/android/app/src/main/res/mipmap-hdpi/ic_launcher_round.png b/android/android/app/src/main/res/mipmap-hdpi/ic_launcher_round.png new file mode 100644 index 0000000..1a7d99e Binary files /dev/null and b/android/android/app/src/main/res/mipmap-hdpi/ic_launcher_round.png differ diff --git a/android/android/app/src/main/res/mipmap-mdpi/ic_launcher.png b/android/android/app/src/main/res/mipmap-mdpi/ic_launcher.png new file mode 100644 index 0000000..f8fb412 Binary files /dev/null and b/android/android/app/src/main/res/mipmap-mdpi/ic_launcher.png differ diff --git a/android/android/app/src/main/res/mipmap-mdpi/ic_launcher_foreground.png b/android/android/app/src/main/res/mipmap-mdpi/ic_launcher_foreground.png new file mode 100644 index 0000000..043dc73 Binary files /dev/null and b/android/android/app/src/main/res/mipmap-mdpi/ic_launcher_foreground.png differ diff --git a/android/android/app/src/main/res/mipmap-mdpi/ic_launcher_round.png b/android/android/app/src/main/res/mipmap-mdpi/ic_launcher_round.png new file mode 100644 index 0000000..6b09617 Binary files /dev/null and b/android/android/app/src/main/res/mipmap-mdpi/ic_launcher_round.png differ diff --git a/android/android/app/src/main/res/mipmap-xhdpi/ic_launcher.png b/android/android/app/src/main/res/mipmap-xhdpi/ic_launcher.png new file mode 100644 index 0000000..dc2937a Binary files /dev/null and b/android/android/app/src/main/res/mipmap-xhdpi/ic_launcher.png differ diff --git a/android/android/app/src/main/res/mipmap-xhdpi/ic_launcher_foreground.png b/android/android/app/src/main/res/mipmap-xhdpi/ic_launcher_foreground.png new file mode 100644 index 0000000..d336698 Binary files /dev/null and b/android/android/app/src/main/res/mipmap-xhdpi/ic_launcher_foreground.png differ diff --git a/android/android/app/src/main/res/mipmap-xhdpi/ic_launcher_round.png b/android/android/app/src/main/res/mipmap-xhdpi/ic_launcher_round.png new file mode 100644 index 0000000..27e58a4 Binary files /dev/null and b/android/android/app/src/main/res/mipmap-xhdpi/ic_launcher_round.png differ diff --git a/android/android/app/src/main/res/mipmap-xxhdpi/ic_launcher.png b/android/android/app/src/main/res/mipmap-xxhdpi/ic_launcher.png new file mode 100644 index 0000000..8456688 Binary files /dev/null and b/android/android/app/src/main/res/mipmap-xxhdpi/ic_launcher.png differ diff --git a/android/android/app/src/main/res/mipmap-xxhdpi/ic_launcher_foreground.png b/android/android/app/src/main/res/mipmap-xxhdpi/ic_launcher_foreground.png new file mode 100644 index 0000000..00694df Binary files /dev/null and b/android/android/app/src/main/res/mipmap-xxhdpi/ic_launcher_foreground.png differ diff --git a/android/android/app/src/main/res/mipmap-xxhdpi/ic_launcher_round.png b/android/android/app/src/main/res/mipmap-xxhdpi/ic_launcher_round.png new file mode 100644 index 0000000..b65234e Binary files /dev/null and b/android/android/app/src/main/res/mipmap-xxhdpi/ic_launcher_round.png differ diff --git a/android/android/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png b/android/android/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png new file mode 100644 index 0000000..9b8d206 Binary files /dev/null and b/android/android/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png differ diff --git a/android/android/app/src/main/res/mipmap-xxxhdpi/ic_launcher_foreground.png b/android/android/app/src/main/res/mipmap-xxxhdpi/ic_launcher_foreground.png new file mode 100644 index 0000000..dbeb894 Binary files /dev/null and b/android/android/app/src/main/res/mipmap-xxxhdpi/ic_launcher_foreground.png differ diff --git a/android/android/app/src/main/res/mipmap-xxxhdpi/ic_launcher_round.png b/android/android/app/src/main/res/mipmap-xxxhdpi/ic_launcher_round.png new file mode 100644 index 0000000..16adc97 Binary files /dev/null and b/android/android/app/src/main/res/mipmap-xxxhdpi/ic_launcher_round.png differ diff --git a/android/android/app/src/main/res/values/ic_launcher_background.xml b/android/android/app/src/main/res/values/ic_launcher_background.xml new file mode 100644 index 0000000..b492c0e --- /dev/null +++ b/android/android/app/src/main/res/values/ic_launcher_background.xml @@ -0,0 +1,4 @@ + + + #08161D + diff --git a/android/android/app/src/main/res/values/strings.xml b/android/android/app/src/main/res/values/strings.xml new file mode 100644 index 0000000..5f3d23e --- /dev/null +++ b/android/android/app/src/main/res/values/strings.xml @@ -0,0 +1,12 @@ + + + Sonda + Sonda + app.sonda + app.sonda + Previous + Pause + Play + Next + Playback + diff --git a/android/android/app/src/main/res/values/styles.xml b/android/android/app/src/main/res/values/styles.xml new file mode 100644 index 0000000..72d8deb --- /dev/null +++ b/android/android/app/src/main/res/values/styles.xml @@ -0,0 +1,28 @@ + + + + + + + + + + + \ No newline at end of file diff --git a/android/android/app/src/main/res/xml/file_paths.xml b/android/android/app/src/main/res/xml/file_paths.xml new file mode 100644 index 0000000..bd0c4d8 --- /dev/null +++ b/android/android/app/src/main/res/xml/file_paths.xml @@ -0,0 +1,5 @@ + + + + + \ No newline at end of file diff --git a/android/android/app/src/main/res/xml/network_security_config.xml b/android/android/app/src/main/res/xml/network_security_config.xml new file mode 100644 index 0000000..9237ac6 --- /dev/null +++ b/android/android/app/src/main/res/xml/network_security_config.xml @@ -0,0 +1,10 @@ + + + + + + + + + + diff --git a/android/android/build.gradle b/android/android/build.gradle new file mode 100644 index 0000000..f8f0e43 --- /dev/null +++ b/android/android/build.gradle @@ -0,0 +1,29 @@ +// Top-level build file where you can add configuration options common to all sub-projects/modules. + +buildscript { + + repositories { + google() + mavenCentral() + } + dependencies { + classpath 'com.android.tools.build:gradle:8.13.0' + classpath 'com.google.gms:google-services:4.4.4' + + // NOTE: Do not place your application dependencies here; they belong + // in the individual module build.gradle files + } +} + +apply from: "variables.gradle" + +allprojects { + repositories { + google() + mavenCentral() + } +} + +task clean(type: Delete) { + delete rootProject.buildDir +} diff --git a/android/android/capacitor.settings.gradle b/android/android/capacitor.settings.gradle new file mode 100644 index 0000000..2085c86 --- /dev/null +++ b/android/android/capacitor.settings.gradle @@ -0,0 +1,6 @@ +// DO NOT EDIT THIS FILE! IT IS GENERATED EACH TIME "capacitor update" IS RUN +include ':capacitor-android' +project(':capacitor-android').projectDir = new File('../node_modules/@capacitor/android/capacitor') + +include ':capacitor-app' +project(':capacitor-app').projectDir = new File('../node_modules/@capacitor/app/android') diff --git a/android/android/gradle.properties b/android/android/gradle.properties new file mode 100644 index 0000000..2e87c52 --- /dev/null +++ b/android/android/gradle.properties @@ -0,0 +1,22 @@ +# Project-wide Gradle settings. + +# IDE (e.g. Android Studio) users: +# Gradle settings configured through the IDE *will override* +# any settings specified in this file. + +# For more details on how to configure your build environment visit +# http://www.gradle.org/docs/current/userguide/build_environment.html + +# Specifies the JVM arguments used for the daemon process. +# The setting is particularly useful for tweaking memory settings. +org.gradle.jvmargs=-Xmx1536m + +# When configured, Gradle will run in incubating parallel mode. +# This option should only be used with decoupled projects. More details, visit +# http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects +# org.gradle.parallel=true + +# AndroidX package structure to make it clearer which packages are bundled with the +# Android operating system, and which are packaged with your app's APK +# https://developer.android.com/topic/libraries/support-library/androidx-rn +android.useAndroidX=true diff --git a/android/android/gradle/wrapper/gradle-wrapper.jar b/android/android/gradle/wrapper/gradle-wrapper.jar new file mode 100644 index 0000000..1b33c55 Binary files /dev/null and b/android/android/gradle/wrapper/gradle-wrapper.jar differ diff --git a/android/android/gradle/wrapper/gradle-wrapper.properties b/android/android/gradle/wrapper/gradle-wrapper.properties new file mode 100644 index 0000000..7705927 --- /dev/null +++ b/android/android/gradle/wrapper/gradle-wrapper.properties @@ -0,0 +1,7 @@ +distributionBase=GRADLE_USER_HOME +distributionPath=wrapper/dists +distributionUrl=https\://services.gradle.org/distributions/gradle-8.14.3-all.zip +networkTimeout=10000 +validateDistributionUrl=true +zipStoreBase=GRADLE_USER_HOME +zipStorePath=wrapper/dists diff --git a/android/android/gradlew b/android/android/gradlew new file mode 100755 index 0000000..23d15a9 --- /dev/null +++ b/android/android/gradlew @@ -0,0 +1,251 @@ +#!/bin/sh + +# +# Copyright © 2015-2021 the original authors. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# https://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +# SPDX-License-Identifier: Apache-2.0 +# + +############################################################################## +# +# Gradle start up script for POSIX generated by Gradle. +# +# Important for running: +# +# (1) You need a POSIX-compliant shell to run this script. If your /bin/sh is +# noncompliant, but you have some other compliant shell such as ksh or +# bash, then to run this script, type that shell name before the whole +# command line, like: +# +# ksh Gradle +# +# Busybox and similar reduced shells will NOT work, because this script +# requires all of these POSIX shell features: +# * functions; +# * expansions «$var», «${var}», «${var:-default}», «${var+SET}», +# «${var#prefix}», «${var%suffix}», and «$( cmd )»; +# * compound commands having a testable exit status, especially «case»; +# * various built-in commands including «command», «set», and «ulimit». +# +# Important for patching: +# +# (2) This script targets any POSIX shell, so it avoids extensions provided +# by Bash, Ksh, etc; in particular arrays are avoided. +# +# The "traditional" practice of packing multiple parameters into a +# space-separated string is a well documented source of bugs and security +# problems, so this is (mostly) avoided, by progressively accumulating +# options in "$@", and eventually passing that to Java. +# +# Where the inherited environment variables (DEFAULT_JVM_OPTS, JAVA_OPTS, +# and GRADLE_OPTS) rely on word-splitting, this is performed explicitly; +# see the in-line comments for details. +# +# There are tweaks for specific operating systems such as AIX, CygWin, +# Darwin, MinGW, and NonStop. +# +# (3) This script is generated from the Groovy template +# https://github.com/gradle/gradle/blob/HEAD/platforms/jvm/plugins-application/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt +# within the Gradle project. +# +# You can find Gradle at https://github.com/gradle/gradle/. +# +############################################################################## + +# Attempt to set APP_HOME + +# Resolve links: $0 may be a link +app_path=$0 + +# Need this for daisy-chained symlinks. +while + APP_HOME=${app_path%"${app_path##*/}"} # leaves a trailing /; empty if no leading path + [ -h "$app_path" ] +do + ls=$( ls -ld "$app_path" ) + link=${ls#*' -> '} + case $link in #( + /*) app_path=$link ;; #( + *) app_path=$APP_HOME$link ;; + esac +done + +# This is normally unused +# shellcheck disable=SC2034 +APP_BASE_NAME=${0##*/} +# Discard cd standard output in case $CDPATH is set (https://github.com/gradle/gradle/issues/25036) +APP_HOME=$( cd -P "${APP_HOME:-./}" > /dev/null && printf '%s\n' "$PWD" ) || exit + +# Use the maximum available, or set MAX_FD != -1 to use that value. +MAX_FD=maximum + +warn () { + echo "$*" +} >&2 + +die () { + echo + echo "$*" + echo + exit 1 +} >&2 + +# OS specific support (must be 'true' or 'false'). +cygwin=false +msys=false +darwin=false +nonstop=false +case "$( uname )" in #( + CYGWIN* ) cygwin=true ;; #( + Darwin* ) darwin=true ;; #( + MSYS* | MINGW* ) msys=true ;; #( + NONSTOP* ) nonstop=true ;; +esac + +CLASSPATH="\\\"\\\"" + + +# Determine the Java command to use to start the JVM. +if [ -n "$JAVA_HOME" ] ; then + if [ -x "$JAVA_HOME/jre/sh/java" ] ; then + # IBM's JDK on AIX uses strange locations for the executables + JAVACMD=$JAVA_HOME/jre/sh/java + else + JAVACMD=$JAVA_HOME/bin/java + fi + if [ ! -x "$JAVACMD" ] ; then + die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME + +Please set the JAVA_HOME variable in your environment to match the +location of your Java installation." + fi +else + JAVACMD=java + if ! command -v java >/dev/null 2>&1 + then + die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. + +Please set the JAVA_HOME variable in your environment to match the +location of your Java installation." + fi +fi + +# Increase the maximum file descriptors if we can. +if ! "$cygwin" && ! "$darwin" && ! "$nonstop" ; then + case $MAX_FD in #( + max*) + # In POSIX sh, ulimit -H is undefined. That's why the result is checked to see if it worked. + # shellcheck disable=SC2039,SC3045 + MAX_FD=$( ulimit -H -n ) || + warn "Could not query maximum file descriptor limit" + esac + case $MAX_FD in #( + '' | soft) :;; #( + *) + # In POSIX sh, ulimit -n is undefined. That's why the result is checked to see if it worked. + # shellcheck disable=SC2039,SC3045 + ulimit -n "$MAX_FD" || + warn "Could not set maximum file descriptor limit to $MAX_FD" + esac +fi + +# Collect all arguments for the java command, stacking in reverse order: +# * args from the command line +# * the main class name +# * -classpath +# * -D...appname settings +# * --module-path (only if needed) +# * DEFAULT_JVM_OPTS, JAVA_OPTS, and GRADLE_OPTS environment variables. + +# For Cygwin or MSYS, switch paths to Windows format before running java +if "$cygwin" || "$msys" ; then + APP_HOME=$( cygpath --path --mixed "$APP_HOME" ) + CLASSPATH=$( cygpath --path --mixed "$CLASSPATH" ) + + JAVACMD=$( cygpath --unix "$JAVACMD" ) + + # Now convert the arguments - kludge to limit ourselves to /bin/sh + for arg do + if + case $arg in #( + -*) false ;; # don't mess with options #( + /?*) t=${arg#/} t=/${t%%/*} # looks like a POSIX filepath + [ -e "$t" ] ;; #( + *) false ;; + esac + then + arg=$( cygpath --path --ignore --mixed "$arg" ) + fi + # Roll the args list around exactly as many times as the number of + # args, so each arg winds up back in the position where it started, but + # possibly modified. + # + # NB: a `for` loop captures its iteration list before it begins, so + # changing the positional parameters here affects neither the number of + # iterations, nor the values presented in `arg`. + shift # remove old arg + set -- "$@" "$arg" # push replacement arg + done +fi + + +# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. +DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"' + +# Collect all arguments for the java command: +# * DEFAULT_JVM_OPTS, JAVA_OPTS, and optsEnvironmentVar are not allowed to contain shell fragments, +# and any embedded shellness will be escaped. +# * For example: A user cannot expect ${Hostname} to be expanded, as it is an environment variable and will be +# treated as '${Hostname}' itself on the command line. + +set -- \ + "-Dorg.gradle.appname=$APP_BASE_NAME" \ + -classpath "$CLASSPATH" \ + -jar "$APP_HOME/gradle/wrapper/gradle-wrapper.jar" \ + "$@" + +# Stop when "xargs" is not available. +if ! command -v xargs >/dev/null 2>&1 +then + die "xargs is not available" +fi + +# Use "xargs" to parse quoted args. +# +# With -n1 it outputs one arg per line, with the quotes and backslashes removed. +# +# In Bash we could simply go: +# +# readarray ARGS < <( xargs -n1 <<<"$var" ) && +# set -- "${ARGS[@]}" "$@" +# +# but POSIX shell has neither arrays nor command substitution, so instead we +# post-process each arg (as a line of input to sed) to backslash-escape any +# character that might be a shell metacharacter, then use eval to reverse +# that process (while maintaining the separation between arguments), and wrap +# the whole thing up as a single "set" statement. +# +# This will of course break if any of these variables contains a newline or +# an unmatched quote. +# + +eval "set -- $( + printf '%s\n' "$DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS" | + xargs -n1 | + sed ' s~[^-[:alnum:]+,./:=@_]~\\&~g; ' | + tr '\n' ' ' + )" '"$@"' + +exec "$JAVACMD" "$@" diff --git a/android/android/gradlew.bat b/android/android/gradlew.bat new file mode 100644 index 0000000..5eed7ee --- /dev/null +++ b/android/android/gradlew.bat @@ -0,0 +1,94 @@ +@rem +@rem Copyright 2015 the original author or authors. +@rem +@rem Licensed under the Apache License, Version 2.0 (the "License"); +@rem you may not use this file except in compliance with the License. +@rem You may obtain a copy of the License at +@rem +@rem https://www.apache.org/licenses/LICENSE-2.0 +@rem +@rem Unless required by applicable law or agreed to in writing, software +@rem distributed under the License is distributed on an "AS IS" BASIS, +@rem WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +@rem See the License for the specific language governing permissions and +@rem limitations under the License. +@rem +@rem SPDX-License-Identifier: Apache-2.0 +@rem + +@if "%DEBUG%"=="" @echo off +@rem ########################################################################## +@rem +@rem Gradle startup script for Windows +@rem +@rem ########################################################################## + +@rem Set local scope for the variables with windows NT shell +if "%OS%"=="Windows_NT" setlocal + +set DIRNAME=%~dp0 +if "%DIRNAME%"=="" set DIRNAME=. +@rem This is normally unused +set APP_BASE_NAME=%~n0 +set APP_HOME=%DIRNAME% + +@rem Resolve any "." and ".." in APP_HOME to make it shorter. +for %%i in ("%APP_HOME%") do set APP_HOME=%%~fi + +@rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. +set DEFAULT_JVM_OPTS="-Xmx64m" "-Xms64m" + +@rem Find java.exe +if defined JAVA_HOME goto findJavaFromJavaHome + +set JAVA_EXE=java.exe +%JAVA_EXE% -version >NUL 2>&1 +if %ERRORLEVEL% equ 0 goto execute + +echo. 1>&2 +echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. 1>&2 +echo. 1>&2 +echo Please set the JAVA_HOME variable in your environment to match the 1>&2 +echo location of your Java installation. 1>&2 + +goto fail + +:findJavaFromJavaHome +set JAVA_HOME=%JAVA_HOME:"=% +set JAVA_EXE=%JAVA_HOME%/bin/java.exe + +if exist "%JAVA_EXE%" goto execute + +echo. 1>&2 +echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% 1>&2 +echo. 1>&2 +echo Please set the JAVA_HOME variable in your environment to match the 1>&2 +echo location of your Java installation. 1>&2 + +goto fail + +:execute +@rem Setup the command line + +set CLASSPATH= + + +@rem Execute Gradle +"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" -jar "%APP_HOME%\gradle\wrapper\gradle-wrapper.jar" %* + +:end +@rem End local scope for the variables with windows NT shell +if %ERRORLEVEL% equ 0 goto mainEnd + +:fail +rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of +rem the _cmd.exe /c_ return code! +set EXIT_CODE=%ERRORLEVEL% +if %EXIT_CODE% equ 0 set EXIT_CODE=1 +if not ""=="%GRADLE_EXIT_CONSOLE%" exit %EXIT_CODE% +exit /b %EXIT_CODE% + +:mainEnd +if "%OS%"=="Windows_NT" endlocal + +:omega diff --git a/android/android/settings.gradle b/android/android/settings.gradle new file mode 100644 index 0000000..3b4431d --- /dev/null +++ b/android/android/settings.gradle @@ -0,0 +1,5 @@ +include ':app' +include ':capacitor-cordova-android-plugins' +project(':capacitor-cordova-android-plugins').projectDir = new File('./capacitor-cordova-android-plugins/') + +apply from: 'capacitor.settings.gradle' \ No newline at end of file diff --git a/android/android/variables.gradle b/android/android/variables.gradle new file mode 100644 index 0000000..ee4ba41 --- /dev/null +++ b/android/android/variables.gradle @@ -0,0 +1,16 @@ +ext { + minSdkVersion = 24 + compileSdkVersion = 36 + targetSdkVersion = 36 + androidxActivityVersion = '1.11.0' + androidxAppCompatVersion = '1.7.1' + androidxCoordinatorLayoutVersion = '1.3.0' + androidxCoreVersion = '1.17.0' + androidxFragmentVersion = '1.8.9' + coreSplashScreenVersion = '1.2.0' + androidxWebkitVersion = '1.14.0' + junitVersion = '4.13.2' + androidxJunitVersion = '1.3.0' + androidxEspressoCoreVersion = '3.7.0' + cordovaAndroidVersion = '14.0.1' +} \ No newline at end of file diff --git a/android/capacitor.config.ts b/android/capacitor.config.ts new file mode 100644 index 0000000..757fc1a --- /dev/null +++ b/android/capacitor.config.ts @@ -0,0 +1,27 @@ +import type { CapacitorConfig } from '@capacitor/cli' + +// The app is a window on a Sonda server. The page in www asks for the address the first time and remembers it; +// the settings of Sonda have a way back to that page, for another server. +const config: CapacitorConfig = { + appId: 'app.sonda', + appName: 'Sonda', + webDir: 'www', + server: { + // The page in www is on http, so that it can look for a server on http as well as on https: from an https page a request to http is blocked. + androidScheme: 'http', + // The server is anywhere the user types, on http or https. + allowNavigation: ['*'], + cleartext: true, + }, + plugins: { + // The app is dark: light clock and icons on the bars. + SystemBars: { style: 'DARK' }, + }, + android: { + backgroundColor: '#08161d', + // The web app knows it is inside the app by this word in the user agent. + appendUserAgent: 'SondaApp', + }, +} + +export default config diff --git a/android/package-lock.json b/android/package-lock.json new file mode 100644 index 0000000..9c03d4d --- /dev/null +++ b/android/package-lock.json @@ -0,0 +1,1618 @@ +{ + "name": "sonda-android", + "version": "0.0.0", + "lockfileVersion": 3, + "requires": true, + "packages": { + "": { + "name": "sonda-android", + "version": "0.0.0", + "dependencies": { + "@capacitor/android": "^8.6.2", + "@capacitor/app": "^8.1.2", + "@capacitor/core": "^8.6.2" + }, + "devDependencies": { + "@capacitor/cli": "^8.6.2", + "typescript": "^7.0.2" + } + }, + "node_modules/@capacitor/android": { + "version": "8.6.2", + "resolved": "https://registry.npmjs.org/@capacitor/android/-/android-8.6.2.tgz", + "integrity": "sha512-dWXnXmOVTtxU91n5h11MzoQ7PAMjyzU1qguw0mBJZiwSuhGvLKTG/IlsQ75H8qeE0a1acV2f573x15wYvyzuVA==", + "license": "MIT", + "peerDependencies": { + "@capacitor/core": "^8.6.0" + } + }, + "node_modules/@capacitor/app": { + "version": "8.1.2", + "resolved": "https://registry.npmjs.org/@capacitor/app/-/app-8.1.2.tgz", + "integrity": "sha512-uKBlsrXH0IdvUn69e/KKYbZ32A06pcrUdG8LWuZ/6y33YMXZXLEEdNSwl+jKS/SrsTWqnePs8EqSWaiQM3mUGA==", + "license": "MIT", + "peerDependencies": { + "@capacitor/core": ">=8.0.0" + } + }, + "node_modules/@capacitor/cli": { + "version": "8.6.2", + "resolved": "https://registry.npmjs.org/@capacitor/cli/-/cli-8.6.2.tgz", + "integrity": "sha512-3HeNPX3cEWBSljJT0sJviZCxXRoToTLAufhUcIJh+JMj1xOhLFZpuj8oFRnJ0kNYAf7DIBHQDmilIXloK9+YYg==", + "dev": true, + "license": "MIT", + "dependencies": { + "@ionic/cli-framework-output": "^2.2.8", + "@ionic/utils-subprocess": "^3.0.1", + "@ionic/utils-terminal": "^2.3.5", + "commander": "^12.1.0", + "debug": "^4.4.0", + "env-paths": "^2.2.0", + "fs-extra": "^11.2.0", + "kleur": "^4.1.5", + "native-run": "^2.0.3", + "open": "^8.4.0", + "plist": "^3.1.0", + "prompts": "^2.4.2", + "rimraf": "^6.0.1", + "semver": "^7.6.3", + "tar": "^7.5.3", + "tslib": "^2.8.1", + "xcode": "^4.0.0", + "xml2js": "^0.6.2" + }, + "bin": { + "cap": "bin/capacitor", + "capacitor": "bin/capacitor" + }, + "engines": { + "node": ">=22.0.0" + } + }, + "node_modules/@capacitor/core": { + "version": "8.6.2", + "resolved": "https://registry.npmjs.org/@capacitor/core/-/core-8.6.2.tgz", + "integrity": "sha512-UEb9crRuqEAe2Iu2eGOEuQ8rLQxpwg7ZZIpl17UJoytEpnV1e4oXXW0K7yYS2NsCOGmJjyLeKjNlgG7tkAoX8g==", + "license": "MIT", + "dependencies": { + "tslib": "^2.1.0" + } + }, + "node_modules/@ionic/cli-framework-output": { + "version": "2.2.8", + "resolved": "https://registry.npmjs.org/@ionic/cli-framework-output/-/cli-framework-output-2.2.8.tgz", + "integrity": "sha512-TshtaFQsovB4NWRBydbNFawql6yul7d5bMiW1WYYf17hd99V6xdDdk3vtF51bw6sLkxON3bDQpWsnUc9/hVo3g==", + "dev": true, + "license": "MIT", + "dependencies": { + "@ionic/utils-terminal": "2.3.5", + "debug": "^4.0.0", + "tslib": "^2.0.1" + }, + "engines": { + "node": ">=16.0.0" + } + }, + "node_modules/@ionic/utils-array": { + "version": "2.1.6", + "resolved": "https://registry.npmjs.org/@ionic/utils-array/-/utils-array-2.1.6.tgz", + "integrity": "sha512-0JZ1Zkp3wURnv8oq6Qt7fMPo5MpjbLoUoa9Bu2Q4PJuSDWM8H8gwF3dQO7VTeUj3/0o1IB1wGkFWZZYgUXZMUg==", + "dev": true, + "license": "MIT", + "dependencies": { + "debug": "^4.0.0", + "tslib": "^2.0.1" + }, + "engines": { + "node": ">=16.0.0" + } + }, + "node_modules/@ionic/utils-fs": { + "version": "3.1.7", + "resolved": "https://registry.npmjs.org/@ionic/utils-fs/-/utils-fs-3.1.7.tgz", + "integrity": "sha512-2EknRvMVfhnyhL1VhFkSLa5gOcycK91VnjfrTB0kbqkTFCOXyXgVLI5whzq7SLrgD9t1aqos3lMMQyVzaQ5gVA==", + "dev": true, + "license": "MIT", + "dependencies": { + "@types/fs-extra": "^8.0.0", + "debug": "^4.0.0", + "fs-extra": "^9.0.0", + "tslib": "^2.0.1" + }, + "engines": { + "node": ">=16.0.0" + } + }, + "node_modules/@ionic/utils-fs/node_modules/fs-extra": { + "version": "9.1.0", + "resolved": "https://registry.npmjs.org/fs-extra/-/fs-extra-9.1.0.tgz", + "integrity": "sha512-hcg3ZmepS30/7BSFqRvoo3DOMQu7IjqxO5nCDt+zM9XWjb33Wg7ziNT+Qvqbuc3+gWpzO02JubVyk2G4Zvo1OQ==", + "dev": true, + "license": "MIT", + "dependencies": { + "at-least-node": "^1.0.0", + "graceful-fs": "^4.2.0", + "jsonfile": "^6.0.1", + "universalify": "^2.0.0" + }, + "engines": { + "node": ">=10" + } + }, + "node_modules/@ionic/utils-object": { + "version": "2.1.6", + "resolved": "https://registry.npmjs.org/@ionic/utils-object/-/utils-object-2.1.6.tgz", + "integrity": "sha512-vCl7sl6JjBHFw99CuAqHljYJpcE88YaH2ZW4ELiC/Zwxl5tiwn4kbdP/gxi2OT3MQb1vOtgAmSNRtusvgxI8ww==", + "dev": true, + "license": "MIT", + "dependencies": { + "debug": "^4.0.0", + "tslib": "^2.0.1" + }, + "engines": { + "node": ">=16.0.0" + } + }, + "node_modules/@ionic/utils-process": { + "version": "2.1.12", + "resolved": "https://registry.npmjs.org/@ionic/utils-process/-/utils-process-2.1.12.tgz", + "integrity": "sha512-Jqkgyq7zBs/v/J3YvKtQQiIcxfJyplPgECMWgdO0E1fKrrH8EF0QGHNJ9mJCn6PYe2UtHNS8JJf5G21e09DfYg==", + "dev": true, + "license": "MIT", + "dependencies": { + "@ionic/utils-object": "2.1.6", + "@ionic/utils-terminal": "2.3.5", + "debug": "^4.0.0", + "signal-exit": "^3.0.3", + "tree-kill": "^1.2.2", + "tslib": "^2.0.1" + }, + "engines": { + "node": ">=16.0.0" + } + }, + "node_modules/@ionic/utils-stream": { + "version": "3.1.7", + "resolved": "https://registry.npmjs.org/@ionic/utils-stream/-/utils-stream-3.1.7.tgz", + "integrity": "sha512-eSELBE7NWNFIHTbTC2jiMvh1ABKGIpGdUIvARsNPMNQhxJB3wpwdiVnoBoTYp+5a6UUIww4Kpg7v6S7iTctH1w==", + "dev": true, + "license": "MIT", + "dependencies": { + "debug": "^4.0.0", + "tslib": "^2.0.1" + }, + "engines": { + "node": ">=16.0.0" + } + }, + "node_modules/@ionic/utils-subprocess": { + "version": "3.0.1", + "resolved": "https://registry.npmjs.org/@ionic/utils-subprocess/-/utils-subprocess-3.0.1.tgz", + "integrity": "sha512-cT4te3AQQPeIM9WCwIg8ohroJ8TjsYaMb2G4ZEgv9YzeDqHZ4JpeIKqG2SoaA3GmVQ3sOfhPM6Ox9sxphV/d1A==", + "dev": true, + "license": "MIT", + "dependencies": { + "@ionic/utils-array": "2.1.6", + "@ionic/utils-fs": "3.1.7", + "@ionic/utils-process": "2.1.12", + "@ionic/utils-stream": "3.1.7", + "@ionic/utils-terminal": "2.3.5", + "cross-spawn": "^7.0.3", + "debug": "^4.0.0", + "tslib": "^2.0.1" + }, + "engines": { + "node": ">=16.0.0" + } + }, + "node_modules/@ionic/utils-terminal": { + "version": "2.3.5", + "resolved": "https://registry.npmjs.org/@ionic/utils-terminal/-/utils-terminal-2.3.5.tgz", + "integrity": "sha512-3cKScz9Jx2/Pr9ijj1OzGlBDfcmx7OMVBt4+P1uRR0SSW4cm1/y3Mo4OY3lfkuaYifMNBW8Wz6lQHbs1bihr7A==", + "dev": true, + "license": "MIT", + "dependencies": { + "@types/slice-ansi": "^4.0.0", + "debug": "^4.0.0", + "signal-exit": "^3.0.3", + "slice-ansi": "^4.0.0", + "string-width": "^4.1.0", + "strip-ansi": "^6.0.0", + "tslib": "^2.0.1", + "untildify": "^4.0.0", + "wrap-ansi": "^7.0.0" + }, + "engines": { + "node": ">=16.0.0" + } + }, + "node_modules/@isaacs/fs-minipass": { + "version": "4.0.1", + "resolved": "https://registry.npmjs.org/@isaacs/fs-minipass/-/fs-minipass-4.0.1.tgz", + "integrity": "sha512-wgm9Ehl2jpeqP3zw/7mo3kRHFp5MEDhqAdwy1fTGkHAwnkGOVsgpvQhL8B5n1qlb01jV3n/bI0ZfZp5lWA1k4w==", + "dev": true, + "license": "ISC", + "dependencies": { + "minipass": "^7.0.4" + }, + "engines": { + "node": ">=18.0.0" + } + }, + "node_modules/@isaacs/nonrecursive-glob-match": { + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/@isaacs/nonrecursive-glob-match/-/nonrecursive-glob-match-1.1.0.tgz", + "integrity": "sha512-GPm/Dbvk5RLmhRnxXIa7nTpK0xtl4E0wj0MslsuNiJ1FIROU+2+9lgUC/dgF7Ey4QCWhfEsgxilMRMCdHPfDfw==", + "dev": true, + "license": "BlueOak-1.0.0" + }, + "node_modules/@types/fs-extra": { + "version": "8.1.5", + "resolved": "https://registry.npmjs.org/@types/fs-extra/-/fs-extra-8.1.5.tgz", + "integrity": "sha512-0dzKcwO+S8s2kuF5Z9oUWatQJj5Uq/iqphEtE3GQJVRRYm/tD1LglU2UnXi2A8jLq5umkGouOXOR9y0n613ZwQ==", + "dev": true, + "license": "MIT", + "dependencies": { + "@types/node": "*" + } + }, + "node_modules/@types/node": { + "version": "26.6.6", + "resolved": "https://registry.npmjs.org/@types/node/-/node-26.6.6.tgz", + "integrity": "sha512-MzQj+8Kx3XI40OmUAE6Qoh58ZMNstNNMwn2nfd3qWsfe7nDNSqJNzes4njhz6AHwrSHOffSLwXU6yb474Q4aog==", + "dev": true, + "license": "MIT", + "dependencies": { + "undici-types": "~8.9.0" + } + }, + "node_modules/@types/slice-ansi": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/@types/slice-ansi/-/slice-ansi-4.0.0.tgz", + "integrity": "sha512-+OpjSaq85gvlZAYINyzKpLeiFkSC4EsC6IIiT6v6TLSU5k5U83fHGj9Lel8oKEXM0HqgrMVCjXPDPVICtxF7EQ==", + "dev": true, + "license": "MIT" + }, + "node_modules/@typescript/typescript-aix-ppc64": { + "version": "7.0.2", + "resolved": "https://registry.npmjs.org/@typescript/typescript-aix-ppc64/-/typescript-aix-ppc64-7.0.2.tgz", + "integrity": "sha512-MTKKkWB7p/0E9xi1d1tHtZ5PiLkGEMIq88pK2CubZjOsLtYTLqhgIgi6zepFa+9GHZ6h05NMCkQxGKiPXMxXtQ==", + "cpu": [ + "ppc64" + ], + "dev": true, + "license": "Apache-2.0", + "optional": true, + "os": [ + "aix" + ], + "engines": { + "node": ">=16.20.0" + } + }, + "node_modules/@typescript/typescript-darwin-arm64": { + "version": "7.0.2", + "resolved": "https://registry.npmjs.org/@typescript/typescript-darwin-arm64/-/typescript-darwin-arm64-7.0.2.tgz", + "integrity": "sha512-gowzar9MwS/aRWp6f3a4KUqzRjAZjOsmGNCM6LcTgXum+dBfgsBVMN+AgvOCCbguXyick6LJhpBszxMebJ8syA==", + "cpu": [ + "arm64" + ], + "dev": true, + "license": "Apache-2.0", + "optional": true, + "os": [ + "darwin" + ], + "engines": { + "node": ">=16.20.0" + } + }, + "node_modules/@typescript/typescript-darwin-x64": { + "version": "7.0.2", + "resolved": "https://registry.npmjs.org/@typescript/typescript-darwin-x64/-/typescript-darwin-x64-7.0.2.tgz", + "integrity": "sha512-SZ9xZInqApNlNGc9s0W1VSsktYSOe9cFqNOIqmN1Gs8SmkjKZYFt017G4VwPxASInODuAdbTW7sXiFUf893RgA==", + "cpu": [ + "x64" + ], + "dev": true, + "license": "Apache-2.0", + "optional": true, + "os": [ + "darwin" + ], + "engines": { + "node": ">=16.20.0" + } + }, + "node_modules/@typescript/typescript-freebsd-arm64": { + "version": "7.0.2", + "resolved": "https://registry.npmjs.org/@typescript/typescript-freebsd-arm64/-/typescript-freebsd-arm64-7.0.2.tgz", + "integrity": "sha512-W5NH4y/J0plIIS5b2xvTEkU7JFxyqdMAOgf+Ilhl0vHQXKO5dZoxd+C/jEtq56c4F3wk71RB4BMRQ2XdI+bwYQ==", + "cpu": [ + "arm64" + ], + "dev": true, + "license": "Apache-2.0", + "optional": true, + "os": [ + "freebsd" + ], + "engines": { + "node": ">=16.20.0" + } + }, + "node_modules/@typescript/typescript-freebsd-x64": { + "version": "7.0.2", + "resolved": "https://registry.npmjs.org/@typescript/typescript-freebsd-x64/-/typescript-freebsd-x64-7.0.2.tgz", + "integrity": "sha512-UMGDx5sTpzNw3WiPebH7l90IWfJggEd+egHt/q6p7/Cm3zqoV7VxkGXt+3DxPIw8CcmvAB0j3sVVfbhX+M4Tpw==", + "cpu": [ + "x64" + ], + "dev": true, + "license": "Apache-2.0", + "optional": true, + "os": [ + "freebsd" + ], + "engines": { + "node": ">=16.20.0" + } + }, + "node_modules/@typescript/typescript-linux-arm": { + "version": "7.0.2", + "resolved": "https://registry.npmjs.org/@typescript/typescript-linux-arm/-/typescript-linux-arm-7.0.2.tgz", + "integrity": "sha512-gffT3xPz9sR7j/YJExkyPntrI0P2EP9XbOyWzth2/Gs0RstK+90RBcO0ncXoXy/beYll1SXw846Nf2zdnEz0QQ==", + "cpu": [ + "arm" + ], + "dev": true, + "license": "Apache-2.0", + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": ">=16.20.0" + } + }, + "node_modules/@typescript/typescript-linux-arm64": { + "version": "7.0.2", + "resolved": "https://registry.npmjs.org/@typescript/typescript-linux-arm64/-/typescript-linux-arm64-7.0.2.tgz", + "integrity": "sha512-Qh4eU4/y3yDjnfjjyPYihMj5/ODIlmt+Bzu17OI+fiSRDW57QmU5SiN63exPRNJPKUzcc1INa1NXdrJ+MqHjUQ==", + "cpu": [ + "arm64" + ], + "dev": true, + "license": "Apache-2.0", + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": ">=16.20.0" + } + }, + "node_modules/@typescript/typescript-linux-loong64": { + "version": "7.0.2", + "resolved": "https://registry.npmjs.org/@typescript/typescript-linux-loong64/-/typescript-linux-loong64-7.0.2.tgz", + "integrity": "sha512-uEHck9i8hoAzXPiYRib1O7miOnz23SxIeVl6F4LXox+qov1K35jHcEW6VHKvZI+pyvl7fZEP4MCU5LYvIq1GuQ==", + "cpu": [ + "loong64" + ], + "dev": true, + "license": "Apache-2.0", + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": ">=16.20.0" + } + }, + "node_modules/@typescript/typescript-linux-mips64el": { + "version": "7.0.2", + "resolved": "https://registry.npmjs.org/@typescript/typescript-linux-mips64el/-/typescript-linux-mips64el-7.0.2.tgz", + "integrity": "sha512-R4KvAMnE43W5Qeqb0Ly56O3mWMWIAgsMyz36DCaycd5nbg/9kzm0liw3JocfRqyJY0KPmzFjbswozXyW0DnIYA==", + "cpu": [ + "mips64el" + ], + "dev": true, + "license": "Apache-2.0", + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": ">=16.20.0" + } + }, + "node_modules/@typescript/typescript-linux-ppc64": { + "version": "7.0.2", + "resolved": "https://registry.npmjs.org/@typescript/typescript-linux-ppc64/-/typescript-linux-ppc64-7.0.2.tgz", + "integrity": "sha512-DORx5b3sd/4S7eayxm4FQv+A7CrkUIGRaHiwI8oiHTAI1fAPWhF4J0vAlkC8biAlHSVVwxMQ3tjZ2/DVbnQiiA==", + "cpu": [ + "ppc64" + ], + "dev": true, + "license": "Apache-2.0", + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": ">=16.20.0" + } + }, + "node_modules/@typescript/typescript-linux-riscv64": { + "version": "7.0.2", + "resolved": "https://registry.npmjs.org/@typescript/typescript-linux-riscv64/-/typescript-linux-riscv64-7.0.2.tgz", + "integrity": "sha512-wf0jqEDOjrPRnKwYRyyJDRo11KMbvMFrU+q4zqKyChODBzvlkbhNQfKvLxQCcwTpdDaXSHZTVuh0JoCrKCUMHQ==", + "cpu": [ + "riscv64" + ], + "dev": true, + "license": "Apache-2.0", + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": ">=16.20.0" + } + }, + "node_modules/@typescript/typescript-linux-s390x": { + "version": "7.0.2", + "resolved": "https://registry.npmjs.org/@typescript/typescript-linux-s390x/-/typescript-linux-s390x-7.0.2.tgz", + "integrity": "sha512-IkwJc3L7yhytWd/ewjyxNDfOmswCm9GWMJT/ue/dU4aZNbwZeYAetq42VyLmsmSjvoX7z74X6ZaYCtzAr0EuGw==", + "cpu": [ + "s390x" + ], + "dev": true, + "license": "Apache-2.0", + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": ">=16.20.0" + } + }, + "node_modules/@typescript/typescript-linux-x64": { + "version": "7.0.2", + "resolved": "https://registry.npmjs.org/@typescript/typescript-linux-x64/-/typescript-linux-x64-7.0.2.tgz", + "integrity": "sha512-EYdf2cNg7rgCWJnxCdJ+F3V39O8ihb37eHAu1LK8oAFizgTQbPOK7zHHXbPt8rX24COqODXeI3sIf0fCXG7H/A==", + "cpu": [ + "x64" + ], + "dev": true, + "license": "Apache-2.0", + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": ">=16.20.0" + } + }, + "node_modules/@typescript/typescript-netbsd-arm64": { + "version": "7.0.2", + "resolved": "https://registry.npmjs.org/@typescript/typescript-netbsd-arm64/-/typescript-netbsd-arm64-7.0.2.tgz", + "integrity": "sha512-+polYF4MF04aPpO5FTkHran9yUQDSXqy5GiSDKpsll5jy3l3+g9QLhpf39T+ePtefhXLOGrLl0QIjkQP6VnelA==", + "cpu": [ + "arm64" + ], + "dev": true, + "license": "Apache-2.0", + "optional": true, + "os": [ + "netbsd" + ], + "engines": { + "node": ">=16.20.0" + } + }, + "node_modules/@typescript/typescript-netbsd-x64": { + "version": "7.0.2", + "resolved": "https://registry.npmjs.org/@typescript/typescript-netbsd-x64/-/typescript-netbsd-x64-7.0.2.tgz", + "integrity": "sha512-8YIT0EHM/3dq10ZOVF/A7pc/YSMtbcecct4rWtexrnSCHOPcpC2KTLXfTCR6vDpnSiY12heNb1GiN/wu+T/FyA==", + "cpu": [ + "x64" + ], + "dev": true, + "license": "Apache-2.0", + "optional": true, + "os": [ + "netbsd" + ], + "engines": { + "node": ">=16.20.0" + } + }, + "node_modules/@typescript/typescript-openbsd-arm64": { + "version": "7.0.2", + "resolved": "https://registry.npmjs.org/@typescript/typescript-openbsd-arm64/-/typescript-openbsd-arm64-7.0.2.tgz", + "integrity": "sha512-APT8+ClYnuYm1u9+kgGXoMj2VzWzcymwh2gNSQVySHfkRDGOTVkoWLjCmOQSaO+PoqQ57B0flRp9SA+7GnnkzQ==", + "cpu": [ + "arm64" + ], + "dev": true, + "license": "Apache-2.0", + "optional": true, + "os": [ + "openbsd" + ], + "engines": { + "node": ">=16.20.0" + } + }, + "node_modules/@typescript/typescript-openbsd-x64": { + "version": "7.0.2", + "resolved": "https://registry.npmjs.org/@typescript/typescript-openbsd-x64/-/typescript-openbsd-x64-7.0.2.tgz", + "integrity": "sha512-yX7s+Q0Dln0Dt9tEzZsAjXXR/+ytBM7AlglaqyeMPxQszJ1JhlJdZ6jLA+IzldHtflX81em7lDao1xXu+aRRkg==", + "cpu": [ + "x64" + ], + "dev": true, + "license": "Apache-2.0", + "optional": true, + "os": [ + "openbsd" + ], + "engines": { + "node": ">=16.20.0" + } + }, + "node_modules/@typescript/typescript-sunos-x64": { + "version": "7.0.2", + "resolved": "https://registry.npmjs.org/@typescript/typescript-sunos-x64/-/typescript-sunos-x64-7.0.2.tgz", + "integrity": "sha512-dLJDGaLZ1D4HPQn62u1n8mBDkJREwMsAkCdkwd4Ieqw+x3TUyTsqY0YiBCtE6H6OzzgGk3iuZ3vFWRS+E8/d1g==", + "cpu": [ + "x64" + ], + "dev": true, + "license": "Apache-2.0", + "optional": true, + "os": [ + "sunos" + ], + "engines": { + "node": ">=16.20.0" + } + }, + "node_modules/@typescript/typescript-win32-arm64": { + "version": "7.0.2", + "resolved": "https://registry.npmjs.org/@typescript/typescript-win32-arm64/-/typescript-win32-arm64-7.0.2.tgz", + "integrity": "sha512-Gyl1Vy6OsWesLzmq+EP0Fb7b4Nid5232AvcA2SFcdYreldpNtYFFofPjnt62y9hQy7VTaZp65ICJjuAQRaVcIQ==", + "cpu": [ + "arm64" + ], + "dev": true, + "license": "Apache-2.0", + "optional": true, + "os": [ + "win32" + ], + "engines": { + "node": ">=16.20.0" + } + }, + "node_modules/@typescript/typescript-win32-x64": { + "version": "7.0.2", + "resolved": "https://registry.npmjs.org/@typescript/typescript-win32-x64/-/typescript-win32-x64-7.0.2.tgz", + "integrity": "sha512-0BQ3HkAHHlKLSp1qRvf3SUhGpGsDuhB/jgFw75guyqbxJqEaS0Cw/VFO8i2nHglJUzQCRtMMR/IBAKE3ETMC4g==", + "cpu": [ + "x64" + ], + "dev": true, + "license": "Apache-2.0", + "optional": true, + "os": [ + "win32" + ], + "engines": { + "node": ">=16.20.0" + } + }, + "node_modules/@xmldom/xmldom": { + "version": "0.9.12", + "resolved": "https://registry.npmjs.org/@xmldom/xmldom/-/xmldom-0.9.12.tgz", + "integrity": "sha512-5AXjrcMClTryPe9LgZrygpB1lj7s0S9E0+W+AHaVKAVyHanafK86iPSvG5xHVSp/jC+VH1UXu0TAEmY279xH7A==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=14.6" + } + }, + "node_modules/ansi-regex": { + "version": "5.0.1", + "resolved": "https://registry.npmjs.org/ansi-regex/-/ansi-regex-5.0.1.tgz", + "integrity": "sha512-quJQXlTSUGL2LH9SUXo8VwsY4soanhgo6LNSm84E1LBcE8s3O0wpdiRzyR9z/ZZJMlMWv37qOOb9pdJlMUEKFQ==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=8" + } + }, + "node_modules/ansi-styles": { + "version": "4.3.0", + "resolved": "https://registry.npmjs.org/ansi-styles/-/ansi-styles-4.3.0.tgz", + "integrity": "sha512-zbB9rCJAT1rbjiVDb2hqKFHNYLxgtk8NURxZ3IZwD3F6NtxbXZQCnnSi1Lkx+IDohdPlFp222wVALIheZJQSEg==", + "dev": true, + "license": "MIT", + "dependencies": { + "color-convert": "^2.0.1" + }, + "engines": { + "node": ">=8" + }, + "funding": { + "url": "https://github.com/chalk/ansi-styles?sponsor=1" + } + }, + "node_modules/astral-regex": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/astral-regex/-/astral-regex-2.0.0.tgz", + "integrity": "sha512-Z7tMw1ytTXt5jqMcOP+OQteU1VuNK9Y02uuJtKQ1Sv69jXQKKg5cibLwGJow8yzZP+eAc18EmLGPal0bp36rvQ==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=8" + } + }, + "node_modules/at-least-node": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/at-least-node/-/at-least-node-1.0.0.tgz", + "integrity": "sha512-+q/t7Ekv1EDY2l6Gda6LLiX14rU9TV20Wa3ofeQmwPFZbOMo9DXrLbOjFaaclkXKWidIaopwAObQDqwWtGUjqg==", + "dev": true, + "license": "ISC", + "engines": { + "node": ">= 4.0.0" + } + }, + "node_modules/balanced-match": { + "version": "4.0.4", + "resolved": "https://registry.npmjs.org/balanced-match/-/balanced-match-4.0.4.tgz", + "integrity": "sha512-BLrgEcRTwX2o6gGxGOCNyMvGSp35YofuYzw9h1IMTRmKqttAZZVU67bdb9Pr2vUHA8+j3i2tJfjO6C6+4myGTA==", + "dev": true, + "license": "MIT", + "engines": { + "node": "18 || 20 || >=22" + } + }, + "node_modules/base64-js": { + "version": "1.5.1", + "resolved": "https://registry.npmjs.org/base64-js/-/base64-js-1.5.1.tgz", + "integrity": "sha512-AKpaYlHn8t4SVbOHCy+b5+KKgvR4vrsD8vbvrbiQJps7fKDTkjkDry6ji0rUJjC0kzbNePLwzxq8iypo41qeWA==", + "dev": true, + "funding": [ + { + "type": "github", + "url": "https://github.com/sponsors/feross" + }, + { + "type": "patreon", + "url": "https://www.patreon.com/feross" + }, + { + "type": "consulting", + "url": "https://feross.org/support" + } + ], + "license": "MIT" + }, + "node_modules/big-integer": { + "version": "1.6.52", + "resolved": "https://registry.npmjs.org/big-integer/-/big-integer-1.6.52.tgz", + "integrity": "sha512-QxD8cf2eVqJOOz63z6JIN9BzvVs/dlySa5HGSBH5xtR8dPteIRQnBxxKqkNTiT6jbDTF6jAfrd4oMcND9RGbQg==", + "dev": true, + "license": "Unlicense", + "engines": { + "node": ">=0.6" + } + }, + "node_modules/bplist-creator": { + "version": "0.1.0", + "resolved": "https://registry.npmjs.org/bplist-creator/-/bplist-creator-0.1.0.tgz", + "integrity": "sha512-sXaHZicyEEmY86WyueLTQesbeoH/mquvarJaQNbjuOQO+7gbFcDEWqKmcWA4cOTLzFlfgvkiVxolk1k5bBIpmg==", + "dev": true, + "license": "MIT", + "dependencies": { + "stream-buffers": "2.2.x" + } + }, + "node_modules/bplist-parser": { + "version": "0.3.2", + "resolved": "https://registry.npmjs.org/bplist-parser/-/bplist-parser-0.3.2.tgz", + "integrity": "sha512-apC2+fspHGI3mMKj+dGevkGo/tCqVB8jMb6i+OX+E29p0Iposz07fABkRIfVUPNd5A5VbuOz1bZbnmkKLYF+wQ==", + "dev": true, + "license": "MIT", + "dependencies": { + "big-integer": "1.6.x" + }, + "engines": { + "node": ">= 5.10.0" + } + }, + "node_modules/brace-expansion": { + "version": "5.0.13", + "resolved": "https://registry.npmjs.org/brace-expansion/-/brace-expansion-5.0.13.tgz", + "integrity": "sha512-Vh3dmFbc4wZeox7M9I/0L9GfFd83Su4+yCck/OF9Gi/P/dAHn0RT7X4K9R7gMNMhDck3DvhR6QXsnQdjjgwNvQ==", + "dev": true, + "license": "MIT", + "dependencies": { + "balanced-match": "^4.0.2" + }, + "engines": { + "node": "20 || >=22" + } + }, + "node_modules/buffer-crc32": { + "version": "0.2.13", + "resolved": "https://registry.npmjs.org/buffer-crc32/-/buffer-crc32-0.2.13.tgz", + "integrity": "sha512-VO9Ht/+p3SN7SKWqcrgEzjGbRSJYTx+Q1pTQC0wrWqHx0vpJraQ6GtHx8tvcg1rlK1byhU5gccxgOgj7B0TDkQ==", + "dev": true, + "license": "MIT", + "engines": { + "node": "*" + } + }, + "node_modules/chownr": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/chownr/-/chownr-3.0.0.tgz", + "integrity": "sha512-+IxzY9BZOQd/XuYPRmrvEVjF/nqj5kgT4kEq7VofrDoM1MxoRjEWkrCC3EtLi59TVawxTAn+orJwFQcrqEN1+g==", + "dev": true, + "license": "BlueOak-1.0.0", + "engines": { + "node": ">=18" + } + }, + "node_modules/color-convert": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/color-convert/-/color-convert-2.0.1.tgz", + "integrity": "sha512-RRECPsj7iu/xb5oKYcsFHSppFNnsj/52OVTRKb4zP5onXwVF3zVmmToNcOfGC+CRDpfK/U584fMg38ZHCaElKQ==", + "dev": true, + "license": "MIT", + "dependencies": { + "color-name": "~1.1.4" + }, + "engines": { + "node": ">=7.0.0" + } + }, + "node_modules/color-name": { + "version": "1.1.4", + "resolved": "https://registry.npmjs.org/color-name/-/color-name-1.1.4.tgz", + "integrity": "sha512-dOy+3AuW3a2wNbZHIuMZpTcgjGuLU/uBL/ubcZF9OXbDo8ff4O8yVp5Bf0efS8uEoYo5q4Fx7dY9OgQGXgAsQA==", + "dev": true, + "license": "MIT" + }, + "node_modules/commander": { + "version": "12.1.0", + "resolved": "https://registry.npmjs.org/commander/-/commander-12.1.0.tgz", + "integrity": "sha512-Vw8qHK3bZM9y/P10u3Vib8o/DdkvA2OtPtZvD871QKjy74Wj1WSKFILMPRPSdUSx5RFK1arlJzEtA4PkFgnbuA==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=18" + } + }, + "node_modules/cross-spawn": { + "version": "7.0.6", + "resolved": "https://registry.npmjs.org/cross-spawn/-/cross-spawn-7.0.6.tgz", + "integrity": "sha512-uV2QOWP2nWzsy2aMp8aRibhi9dlzF5Hgh5SHaB9OiTGEyDTiJJyx0uy51QXdyWbtAHNua4XJzUKca3OzKUd3vA==", + "dev": true, + "license": "MIT", + "dependencies": { + "path-key": "^3.1.0", + "shebang-command": "^2.0.0", + "which": "^2.0.1" + }, + "engines": { + "node": ">= 8" + } + }, + "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/define-lazy-prop": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/define-lazy-prop/-/define-lazy-prop-2.0.0.tgz", + "integrity": "sha512-Ds09qNh8yw3khSjiJjiUInaGX9xlqZDY7JVryGxdxV7NPeuqQfplOpQ66yJFZut3jLa5zOwkXw1g9EI2uKh4Og==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=8" + } + }, + "node_modules/elementtree": { + "version": "0.1.7", + "resolved": "https://registry.npmjs.org/elementtree/-/elementtree-0.1.7.tgz", + "integrity": "sha512-wkgGT6kugeQk/P6VZ/f4T+4HB41BVgNBq5CDIZVbQ02nvTVqAiVTbskxxu3eA/X96lMlfYOwnLQpN2v5E1zDEg==", + "dev": true, + "license": "Apache-2.0", + "dependencies": { + "sax": "1.1.4" + }, + "engines": { + "node": ">= 0.4.0" + } + }, + "node_modules/emoji-regex": { + "version": "8.0.0", + "resolved": "https://registry.npmjs.org/emoji-regex/-/emoji-regex-8.0.0.tgz", + "integrity": "sha512-MSjYzcWNOA0ewAHpz0MxpYFvwg6yjy1NG3xteoqz644VCo/RPgnr1/GGt+ic3iJTzQ8Eu3TdM14SawnVUmGE6A==", + "dev": true, + "license": "MIT" + }, + "node_modules/env-paths": { + "version": "2.2.1", + "resolved": "https://registry.npmjs.org/env-paths/-/env-paths-2.2.1.tgz", + "integrity": "sha512-+h1lkLKhZMTYjog1VEpJNG7NZJWcuc2DDk/qsqSTRRCOXiLjeQ1d1/udrUGhqMxUgAlwKNZ0cf2uqan5GLuS2A==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=6" + } + }, + "node_modules/fd-slicer": { + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/fd-slicer/-/fd-slicer-1.1.0.tgz", + "integrity": "sha512-cE1qsB/VwyQozZ+q1dGxR8LBYNZeofhEdUNGSMbQD3Gw2lAzX9Zb3uIU6Ebc/Fmyjo9AWWfnn0AUCHqtevs/8g==", + "dev": true, + "license": "MIT", + "dependencies": { + "pend": "~1.2.0" + } + }, + "node_modules/fs-extra": { + "version": "11.4.1", + "resolved": "https://registry.npmjs.org/fs-extra/-/fs-extra-11.4.1.tgz", + "integrity": "sha512-KYAb4c9BJQI6QqGKthV68OHe0badztdXJWKo0WtBA9IuCFPTKvE5ZdUBglP833aMjhaSPNO4A5j/EkzZtGlKjA==", + "dev": true, + "license": "MIT", + "dependencies": { + "graceful-fs": "^4.2.0", + "jsonfile": "^6.0.1", + "universalify": "^2.0.0" + }, + "engines": { + "node": ">=14.14" + } + }, + "node_modules/glob": { + "version": "14.0.6", + "resolved": "https://registry.npmjs.org/glob/-/glob-14.0.6.tgz", + "integrity": "sha512-OwXjVP2svY5EyLY75Vek96C8qK43gqrt4xsZ+qSILdnaEiJPXkd62mcfUSNx/TQErQRdu5uM5kF67sfONragKw==", + "dev": true, + "license": "BlueOak-1.0.0", + "dependencies": { + "minimatch": "^11.0.5", + "minipass": "^7.1.3", + "path-scurry": "^3.0.0" + }, + "engines": { + "node": "18 || 20 || >=22" + }, + "funding": { + "url": "https://github.com/sponsors/isaacs" + } + }, + "node_modules/graceful-fs": { + "version": "4.2.12", + "resolved": "https://registry.npmjs.org/graceful-fs/-/graceful-fs-4.2.12.tgz", + "integrity": "sha512-iuyGF2E4oafQfPsRrG2wtY2ILupMhvtdrhzrxB+0VcjsPpSPttpfYdjnGFGsTi5MaJFjI1jOKHPQ6UTbTj9TAw==", + "dev": true, + "license": "BlueOak-1.0.0" + }, + "node_modules/inherits": { + "version": "2.0.4", + "resolved": "https://registry.npmjs.org/inherits/-/inherits-2.0.4.tgz", + "integrity": "sha512-k/vGaX4/Yla3WzyMCvTQOXYeIHvqOKtnqBduzTHpzpQZzAskKMhZ2K+EnBiSM9zGSoIFeMpXKxa4dYeZIQqewQ==", + "dev": true, + "license": "ISC" + }, + "node_modules/ini": { + "version": "4.1.3", + "resolved": "https://registry.npmjs.org/ini/-/ini-4.1.3.tgz", + "integrity": "sha512-X7rqawQBvfdjS10YU1y1YVreA3SsLrW9dX2CewP2EbBJM4ypVNLDkO5y04gejPwKIY9lR+7r9gn3rFPt/kmWFg==", + "dev": true, + "license": "ISC", + "engines": { + "node": "^14.17.0 || ^16.13.0 || >=18.0.0" + } + }, + "node_modules/is-docker": { + "version": "2.2.1", + "resolved": "https://registry.npmjs.org/is-docker/-/is-docker-2.2.1.tgz", + "integrity": "sha512-F+i2BKsFrH66iaUFc0woD8sLy8getkwTwtOBjvs56Cx4CgJDeKQeqfz8wAYiSb8JOprWhHH5p77PbmYCvvUuXQ==", + "dev": true, + "license": "MIT", + "bin": { + "is-docker": "cli.js" + }, + "engines": { + "node": ">=8" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, + "node_modules/is-fullwidth-code-point": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/is-fullwidth-code-point/-/is-fullwidth-code-point-3.0.0.tgz", + "integrity": "sha512-zymm5+u+sCsSWyD9qNaejV3DFvhCKclKdizYaJUuHA83RLjb7nSuGnddCHGv0hk+KY7BMAlsWeK4Ueg6EV6XQg==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=8" + } + }, + "node_modules/is-wsl": { + "version": "2.2.0", + "resolved": "https://registry.npmjs.org/is-wsl/-/is-wsl-2.2.0.tgz", + "integrity": "sha512-fKzAra0rGJUUBwGBgNkHZuToZcn+TtXHpeCgmkMJMMYx1sQDYaCSyjJBSCa2nH1DGm7s3n1oBnohoVTBaN7Lww==", + "dev": true, + "license": "MIT", + "dependencies": { + "is-docker": "^2.0.0" + }, + "engines": { + "node": ">=8" + } + }, + "node_modules/isexe": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/isexe/-/isexe-2.0.0.tgz", + "integrity": "sha512-RHxMLp9lnKHGHRng9QFhRCMbYAcVpn69smSGcq3f36xjgVVWThj4qqLbTLlq7Ssj8B+fIQ1EuCEGI2lKsyQeIw==", + "dev": true, + "license": "ISC" + }, + "node_modules/jsonfile": { + "version": "6.2.1", + "resolved": "https://registry.npmjs.org/jsonfile/-/jsonfile-6.2.1.tgz", + "integrity": "sha512-zwOTdL3rFQ/lRdBnntKVOX6k5cKJwEc1HdilT71BWEu7J41gXIB2MRp+vxduPSwZJPWBxEzv4yH1wYLJGUHX4Q==", + "dev": true, + "license": "MIT", + "dependencies": { + "universalify": "^2.0.0" + }, + "optionalDependencies": { + "graceful-fs": "^4.1.6" + } + }, + "node_modules/kleur": { + "version": "4.1.5", + "resolved": "https://registry.npmjs.org/kleur/-/kleur-4.1.5.tgz", + "integrity": "sha512-o+NO+8WrRiQEE4/7nwRJhN1HWpVmJm511pBHUxPLtp0BUISzlBplORYSmTclCnJvQq2tKu/sgl3xVpkc7ZWuQQ==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=6" + } + }, + "node_modules/lru-cache": { + "version": "11.5.3", + "resolved": "https://registry.npmjs.org/lru-cache/-/lru-cache-11.5.3.tgz", + "integrity": "sha512-U4N8FgzmWxc8k1VH8Kr6lQg18U7Fjvby6wXHVRX/ZZ7IwWbRMgrRbP0Wrb5q5NVinryp4SQampHKdvtecItxUg==", + "dev": true, + "license": "BlueOak-1.0.0", + "engines": { + "node": "20 || >=22" + } + }, + "node_modules/minimatch": { + "version": "11.0.9", + "resolved": "https://registry.npmjs.org/minimatch/-/minimatch-11.0.9.tgz", + "integrity": "sha512-KCFkfyjqerNlSstjlhIGNXIKZGA/6O4V4RlhZ+Dsr621SPPw0mzlypE9D9ZOoPiVefHID+j7/XuMMlqfD/F60Q==", + "dev": true, + "license": "BlueOak-1.0.0", + "dependencies": { + "@isaacs/nonrecursive-glob-match": "^1.1.0", + "brace-expansion": "^5.0.12" + }, + "engines": { + "node": "20 || >=22" + }, + "funding": { + "url": "https://github.com/sponsors/isaacs" + } + }, + "node_modules/minipass": { + "version": "7.1.3", + "resolved": "https://registry.npmjs.org/minipass/-/minipass-7.1.3.tgz", + "integrity": "sha512-tEBHqDnIoM/1rXME1zgka9g6Q2lcoCkxHLuc7ODJ5BxbP5d4c2Z5cGgtXAku59200Cx7diuHTOYfSBD8n6mm8A==", + "dev": true, + "license": "BlueOak-1.0.0", + "engines": { + "node": ">=16 || 14 >=14.17" + } + }, + "node_modules/minizlib": { + "version": "3.1.0", + "resolved": "https://registry.npmjs.org/minizlib/-/minizlib-3.1.0.tgz", + "integrity": "sha512-KZxYo1BUkWD2TVFLr0MQoM8vUUigWD3LlD83a/75BqC+4qE0Hb1Vo5v1FgcfaNXvfXzr+5EhQ6ing/CaBijTlw==", + "dev": true, + "license": "MIT", + "dependencies": { + "minipass": "^7.1.2" + }, + "engines": { + "node": ">= 18" + } + }, + "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/native-run": { + "version": "2.1.0", + "resolved": "https://registry.npmjs.org/native-run/-/native-run-2.1.0.tgz", + "integrity": "sha512-JhEph/fyMwBHmMLiZ1OZX8X92+N1gt5+/ecLtgeRbyDHIyIW7EDt0A3kBZu594y1P4yKDr1CIHe+DDYQ7ZlKjg==", + "dev": true, + "license": "MIT", + "dependencies": { + "@ionic/utils-fs": "^3.1.7", + "@ionic/utils-terminal": "^2.3.4", + "bplist-parser": "^0.3.2", + "debug": "^4.3.4", + "elementtree": "^0.1.7", + "ini": "^4.1.1", + "plist": "^3.1.0", + "split2": "^4.2.0", + "through2": "^4.0.2", + "tslib": "^2.6.2", + "yauzl": "^2.10.0" + }, + "bin": { + "native-run": "bin/native-run" + }, + "engines": { + "node": ">=16.0.0" + } + }, + "node_modules/open": { + "version": "8.4.2", + "resolved": "https://registry.npmjs.org/open/-/open-8.4.2.tgz", + "integrity": "sha512-7x81NCL719oNbsq/3mh+hVrAWmFuEYUqrq/Iw3kUzH8ReypT9QQ0BLoJS7/G9k6N81XjW4qHWtjWwe/9eLy1EQ==", + "dev": true, + "license": "MIT", + "dependencies": { + "define-lazy-prop": "^2.0.0", + "is-docker": "^2.1.1", + "is-wsl": "^2.2.0" + }, + "engines": { + "node": ">=12" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, + "node_modules/package-json-from-dist": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/package-json-from-dist/-/package-json-from-dist-1.0.1.tgz", + "integrity": "sha512-UEZIS3/by4OC8vL3P2dTXRETpebLI2NiI5vIrjaD/5UtrkFX/tNbwjTSRAGC/+7CAo2pIcBaRgWmcBBHcsaCIw==", + "dev": true, + "license": "BlueOak-1.0.0" + }, + "node_modules/path-key": { + "version": "3.1.1", + "resolved": "https://registry.npmjs.org/path-key/-/path-key-3.1.1.tgz", + "integrity": "sha512-ojmeN0qd+y0jszEtoY48r0Peq5dwMEkIlCOu6Q5f41lfkswXuKtYrhgoTpLnyIcHm24Uhqx+5Tqm2InSwLhE6Q==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=8" + } + }, + "node_modules/path-scurry": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/path-scurry/-/path-scurry-3.0.0.tgz", + "integrity": "sha512-1pTbQqH1wIwMi/eleQ5leFTTCkzFsPcgXNjwOA8YGGW/W4/kHT3dssE7Z6NH+zuqNLOzOB0uaD61yl7cAcVhgg==", + "dev": true, + "license": "BlueOak-1.0.0", + "dependencies": { + "lru-cache": "^11.0.0", + "minipass": "^7.1.2" + }, + "engines": { + "node": "18 || 20 || >=22" + }, + "funding": { + "url": "https://github.com/sponsors/isaacs" + } + }, + "node_modules/pend": { + "version": "1.2.0", + "resolved": "https://registry.npmjs.org/pend/-/pend-1.2.0.tgz", + "integrity": "sha512-F3asv42UuXchdzt+xXqfW1OGlVBe+mxa2mqI0pg5yAHZPvFmY3Y6drSf/GQ1A86WgWEN9Kzh/WrgKa6iGcHXLg==", + "dev": true, + "license": "MIT" + }, + "node_modules/plist": { + "version": "3.1.1", + "resolved": "https://registry.npmjs.org/plist/-/plist-3.1.1.tgz", + "integrity": "sha512-ZIfcLJC+7E7FBFnDxm9MPmt7D+DidyQ26lewieO75AdhA2ayMtsJSES0iWzqJQbcVRSrTufQoy0DR94xHue0oA==", + "dev": true, + "license": "MIT", + "dependencies": { + "@xmldom/xmldom": "^0.9.10", + "base64-js": "^1.5.1", + "xmlbuilder": "^15.1.1" + }, + "engines": { + "node": ">=10.4.0" + } + }, + "node_modules/prompts": { + "version": "2.4.2", + "resolved": "https://registry.npmjs.org/prompts/-/prompts-2.4.2.tgz", + "integrity": "sha512-NxNv/kLguCA7p3jE8oL2aEBsrJWgAakBpgmgK6lpPWV+WuOmY6r2/zbAVnP+T8bQlA0nzHXSJSJW0Hq7ylaD2Q==", + "dev": true, + "license": "MIT", + "dependencies": { + "kleur": "^3.0.3", + "sisteransi": "^1.0.5" + }, + "engines": { + "node": ">= 6" + } + }, + "node_modules/prompts/node_modules/kleur": { + "version": "3.0.3", + "resolved": "https://registry.npmjs.org/kleur/-/kleur-3.0.3.tgz", + "integrity": "sha512-eTIzlVOSUR+JxdDFepEYcBMtZ9Qqdef+rnzWdRZuMbOywu5tO2w2N7rqjoANZ5k9vywhL6Br1VRjUIgTQx4E8w==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=6" + } + }, + "node_modules/readable-stream": { + "version": "3.6.2", + "resolved": "https://registry.npmjs.org/readable-stream/-/readable-stream-3.6.2.tgz", + "integrity": "sha512-9u/sniCrY3D5WdsERHzHE4G2YCXqoG5FTHUiCC4SIbr6XcLZBY05ya9EKjYek9O5xOAwjGq+1JdGBAS7Q9ScoA==", + "dev": true, + "license": "MIT", + "dependencies": { + "inherits": "^2.0.3", + "string_decoder": "^1.1.1", + "util-deprecate": "^1.0.1" + }, + "engines": { + "node": ">= 6" + } + }, + "node_modules/rimraf": { + "version": "6.1.4", + "resolved": "https://registry.npmjs.org/rimraf/-/rimraf-6.1.4.tgz", + "integrity": "sha512-Fk3reQDVPZUMbEm7Zwxz03BWQMW3V5buSk9aU8OckTrO8A1nQtbqvYsAantGNermwsIsXcuOBqcoJ3HuMELctw==", + "dev": true, + "license": "BlueOak-1.0.0", + "dependencies": { + "glob": "^14.0.3", + "package-json-from-dist": "^1.0.1" + }, + "bin": { + "rimraf": "dist/esm/bin.mjs" + }, + "engines": { + "node": "20 || >=22" + }, + "funding": { + "url": "https://github.com/sponsors/isaacs" + } + }, + "node_modules/safe-buffer": { + "version": "5.2.1", + "resolved": "https://registry.npmjs.org/safe-buffer/-/safe-buffer-5.2.1.tgz", + "integrity": "sha512-rp3So07KcdmmKbGvgaNxQSJr7bGVSVk5S9Eq1F+ppbRo70+YeaDxkw5Dd8NPN+GD6bjnYm2VuPuCXmpuYvmCXQ==", + "dev": true, + "funding": [ + { + "type": "github", + "url": "https://github.com/sponsors/feross" + }, + { + "type": "patreon", + "url": "https://www.patreon.com/feross" + }, + { + "type": "consulting", + "url": "https://feross.org/support" + } + ], + "license": "MIT" + }, + "node_modules/sax": { + "version": "1.1.4", + "resolved": "https://registry.npmjs.org/sax/-/sax-1.1.4.tgz", + "integrity": "sha512-5f3k2PbGGp+YtKJjOItpg3P99IMD84E4HOvcfleTb5joCHNXYLsR9yWFPOYGgaeMPDubQILTCMdsFb2OMeOjtg==", + "dev": true, + "license": "ISC" + }, + "node_modules/semver": { + "version": "7.8.6", + "resolved": "https://registry.npmjs.org/semver/-/semver-7.8.6.tgz", + "integrity": "sha512-9lpSSU4Mly3mrtruwLs1eLK6+gzbzqeBFwRNjIjE+9LuDpWdYctrQlQ3ej1Ilgi7gknpsTRnPoLP8DpCHqHIJw==", + "dev": true, + "license": "ISC", + "bin": { + "semver": "bin/semver.js" + }, + "engines": { + "node": ">=10" + } + }, + "node_modules/shebang-command": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/shebang-command/-/shebang-command-2.0.0.tgz", + "integrity": "sha512-kHxr2zZpYtdmrN1qDjrrX/Z1rR1kG8Dx+gkpK1G4eXmvXswmcE1hTWBWYUzlraYw1/yZp6YuDY77YtvbN0dmDA==", + "dev": true, + "license": "MIT", + "dependencies": { + "shebang-regex": "^3.0.0" + }, + "engines": { + "node": ">=8" + } + }, + "node_modules/shebang-regex": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/shebang-regex/-/shebang-regex-3.0.0.tgz", + "integrity": "sha512-7++dFhtcx3353uBaq8DDR4NuxBetBzC7ZQOhmTQInHEd6bSrXdiEyzCvG07Z44UYdLShWUyXt5M/yhz8ekcb1A==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=8" + } + }, + "node_modules/signal-exit": { + "version": "3.0.7", + "resolved": "https://registry.npmjs.org/signal-exit/-/signal-exit-3.0.7.tgz", + "integrity": "sha512-wnD2ZE+l+SPC/uoS0vXeE9L1+0wuaMqKlfz9AMUo38JsyLSBWSFcHR1Rri62LZc12vLr1gb3jl7iwQhgwpAbGQ==", + "dev": true, + "license": "ISC" + }, + "node_modules/simple-plist": { + "version": "1.3.1", + "resolved": "https://registry.npmjs.org/simple-plist/-/simple-plist-1.3.1.tgz", + "integrity": "sha512-iMSw5i0XseMnrhtIzRb7XpQEXepa9xhWxGUojHBL43SIpQuDQkh3Wpy67ZbDzZVr6EKxvwVChnVpdl8hEVLDiw==", + "dev": true, + "license": "MIT", + "dependencies": { + "bplist-creator": "0.1.0", + "bplist-parser": "0.3.1", + "plist": "^3.0.5" + } + }, + "node_modules/simple-plist/node_modules/bplist-parser": { + "version": "0.3.1", + "resolved": "https://registry.npmjs.org/bplist-parser/-/bplist-parser-0.3.1.tgz", + "integrity": "sha512-PyJxiNtA5T2PlLIeBot4lbp7rj4OadzjnMZD/G5zuBNt8ei/yCU7+wW0h2bag9vr8c+/WuRWmSxbqAl9hL1rBA==", + "dev": true, + "license": "MIT", + "dependencies": { + "big-integer": "1.6.x" + }, + "engines": { + "node": ">= 5.10.0" + } + }, + "node_modules/sisteransi": { + "version": "1.0.5", + "resolved": "https://registry.npmjs.org/sisteransi/-/sisteransi-1.0.5.tgz", + "integrity": "sha512-bLGGlR1QxBcynn2d5YmDX4MGjlZvy2MRBDRNHLJ8VI6l6+9FUiyTFNJ0IveOSP0bcXgVDPRcfGqA0pjaqUpfVg==", + "dev": true, + "license": "MIT" + }, + "node_modules/slice-ansi": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/slice-ansi/-/slice-ansi-4.0.0.tgz", + "integrity": "sha512-qMCMfhY040cVHT43K9BFygqYbUPFZKHOg7K73mtTWJRb8pyP3fzf4Ixd5SzdEJQ6MRUg/WBnOLxghZtKKurENQ==", + "dev": true, + "license": "MIT", + "dependencies": { + "ansi-styles": "^4.0.0", + "astral-regex": "^2.0.0", + "is-fullwidth-code-point": "^3.0.0" + }, + "engines": { + "node": ">=10" + }, + "funding": { + "url": "https://github.com/chalk/slice-ansi?sponsor=1" + } + }, + "node_modules/split2": { + "version": "4.2.0", + "resolved": "https://registry.npmjs.org/split2/-/split2-4.2.0.tgz", + "integrity": "sha512-UcjcJOWknrNkF6PLX83qcHM6KHgVKNkV62Y8a5uYDVv9ydGQVwAHMKqHdJje1VTWpljG0WYpCDhrCdAOYH4TWg==", + "dev": true, + "license": "ISC", + "engines": { + "node": ">= 10.x" + } + }, + "node_modules/stream-buffers": { + "version": "2.2.0", + "resolved": "https://registry.npmjs.org/stream-buffers/-/stream-buffers-2.2.0.tgz", + "integrity": "sha512-uyQK/mx5QjHun80FLJTfaWE7JtwfRMKBLkMne6udYOmvH0CawotVa7TfgYHzAnpphn4+TweIx1QKMnRIbipmUg==", + "dev": true, + "license": "Unlicense", + "engines": { + "node": ">= 0.10.0" + } + }, + "node_modules/string_decoder": { + "version": "1.3.0", + "resolved": "https://registry.npmjs.org/string_decoder/-/string_decoder-1.3.0.tgz", + "integrity": "sha512-hkRX8U1WjJFd8LsDJ2yQ/wWWxaopEsABU1XfkM8A+j0+85JAGppt16cr1Whg6KIbb4okU6Mql6BOj+uup/wKeA==", + "dev": true, + "license": "MIT", + "dependencies": { + "safe-buffer": "~5.2.0" + } + }, + "node_modules/string-width": { + "version": "4.2.3", + "resolved": "https://registry.npmjs.org/string-width/-/string-width-4.2.3.tgz", + "integrity": "sha512-wKyQRQpjJ0sIp62ErSZdGsjMJWsap5oRNihHhu6G7JVO/9jIB6UyevL+tXuOqrng8j/cxKTWyWUwvSTriiZz/g==", + "dev": true, + "license": "MIT", + "dependencies": { + "emoji-regex": "^8.0.0", + "is-fullwidth-code-point": "^3.0.0", + "strip-ansi": "^6.0.1" + }, + "engines": { + "node": ">=8" + } + }, + "node_modules/strip-ansi": { + "version": "6.0.1", + "resolved": "https://registry.npmjs.org/strip-ansi/-/strip-ansi-6.0.1.tgz", + "integrity": "sha512-Y38VPSHcqkFrCpFnQ9vuSXmquuv5oXOKpGeT6aGrr3o3Gc9AlVa6JBfUSOCnbxGGZF+/0ooI7KrPuUSztUdU5A==", + "dev": true, + "license": "MIT", + "dependencies": { + "ansi-regex": "^5.0.1" + }, + "engines": { + "node": ">=8" + } + }, + "node_modules/tar": { + "version": "7.5.23", + "resolved": "https://registry.npmjs.org/tar/-/tar-7.5.23.tgz", + "integrity": "sha512-lkukzdoGngZHJZXxW4S/E4Fp9ghTDlyZXrQGRNoJ/LXvDKcXUTq2sg5yQe74po7Voea6n/IN09+wE/QvJMiifA==", + "dev": true, + "license": "BlueOak-1.0.0", + "dependencies": { + "@isaacs/fs-minipass": "^4.0.0", + "chownr": "^3.0.0", + "minipass": "^7.1.2", + "minizlib": "^3.1.0", + "yallist": "^5.0.0" + }, + "engines": { + "node": ">=18" + } + }, + "node_modules/through2": { + "version": "4.0.2", + "resolved": "https://registry.npmjs.org/through2/-/through2-4.0.2.tgz", + "integrity": "sha512-iOqSav00cVxEEICeD7TjLB1sueEL+81Wpzp2bY17uZjZN0pWZPuo4suZ/61VujxmqSGFfgOcNuTZ85QJwNZQpw==", + "dev": true, + "license": "MIT", + "dependencies": { + "readable-stream": "3" + } + }, + "node_modules/tree-kill": { + "version": "1.2.2", + "resolved": "https://registry.npmjs.org/tree-kill/-/tree-kill-1.2.2.tgz", + "integrity": "sha512-L0Orpi8qGpRG//Nd+H90vFB+3iHnue1zSSGmNOOCh1GLJ7rUKVwV2HvijphGQS2UmhUZewS9VgvxYIdgr+fG1A==", + "dev": true, + "license": "MIT", + "bin": { + "tree-kill": "cli.js" + } + }, + "node_modules/tslib": { + "version": "2.9.1", + "resolved": "https://registry.npmjs.org/tslib/-/tslib-2.9.1.tgz", + "integrity": "sha512-a4Ux9VKuIMHsOS7ENbEq6hK2ZGYIT27Rtl0E4eD9KqwxhKiQeMZE/9xb3IdYwWaSOyIBQLExhQgXDTYoiCxnWA==", + "license": "0BSD" + }, + "node_modules/typescript": { + "version": "7.0.2", + "resolved": "https://registry.npmjs.org/typescript/-/typescript-7.0.2.tgz", + "integrity": "sha512-8FYau96o3NKOhbjKi/qNvG/W5jhzxkbdm5sj9AbZ/5T5sWqn3hJgLfGx27sRKZWTvyzCP8dLRBTf5tBTSRVUNA==", + "dev": true, + "license": "Apache-2.0", + "bin": { + "tsc": "bin/tsc" + }, + "engines": { + "node": ">=16.20.0" + }, + "optionalDependencies": { + "@typescript/typescript-aix-ppc64": "7.0.2", + "@typescript/typescript-darwin-arm64": "7.0.2", + "@typescript/typescript-darwin-x64": "7.0.2", + "@typescript/typescript-freebsd-arm64": "7.0.2", + "@typescript/typescript-freebsd-x64": "7.0.2", + "@typescript/typescript-linux-arm": "7.0.2", + "@typescript/typescript-linux-arm64": "7.0.2", + "@typescript/typescript-linux-loong64": "7.0.2", + "@typescript/typescript-linux-mips64el": "7.0.2", + "@typescript/typescript-linux-ppc64": "7.0.2", + "@typescript/typescript-linux-riscv64": "7.0.2", + "@typescript/typescript-linux-s390x": "7.0.2", + "@typescript/typescript-linux-x64": "7.0.2", + "@typescript/typescript-netbsd-arm64": "7.0.2", + "@typescript/typescript-netbsd-x64": "7.0.2", + "@typescript/typescript-openbsd-arm64": "7.0.2", + "@typescript/typescript-openbsd-x64": "7.0.2", + "@typescript/typescript-sunos-x64": "7.0.2", + "@typescript/typescript-win32-arm64": "7.0.2", + "@typescript/typescript-win32-x64": "7.0.2" + } + }, + "node_modules/undici-types": { + "version": "8.9.0", + "resolved": "https://registry.npmjs.org/undici-types/-/undici-types-8.9.0.tgz", + "integrity": "sha512-KTDyRTYX8sWmKXAikPHHSyc63CRPETMctyjKFupcC6OBLXT3xsN0e9aF7m+mIXutFWpUXuedtowG7iLOzp0kQg==", + "dev": true, + "license": "MIT" + }, + "node_modules/universalify": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/universalify/-/universalify-2.0.1.tgz", + "integrity": "sha512-gptHNQghINnc/vTGIk0SOFGFNXw7JVrlRUtConJRlvaw6DuX0wO5Jeko9sWrMBhh+PsYAZ7oXAiOnf/UKogyiw==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">= 10.0.0" + } + }, + "node_modules/untildify": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/untildify/-/untildify-4.0.0.tgz", + "integrity": "sha512-KK8xQ1mkzZeg9inewmFVDNkg3l5LUhoq9kN6iWYB/CC9YMG8HA+c1Q8HwDe6dEX7kErrEVNVBO3fWsVq5iDgtw==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=8" + } + }, + "node_modules/util-deprecate": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/util-deprecate/-/util-deprecate-1.0.2.tgz", + "integrity": "sha512-EPD5q1uXyFxJpCrLnCc1nHnq3gOa6DZBocAIiI2TaSCA7VCJ1UJDMagCzIkXNsUYfD1daK//LTEQ8xiIbrHtcw==", + "dev": true, + "license": "MIT" + }, + "node_modules/which": { + "version": "2.0.2", + "resolved": "https://registry.npmjs.org/which/-/which-2.0.2.tgz", + "integrity": "sha512-BLI3Tl1TW3Pvl70l3yq3Y64i+awpwXqsGBYWkkqMtnbXgrMD+yj7rhW0kuEDxzJaYXGjEW5ogapKNMEKNMjibA==", + "dev": true, + "license": "ISC", + "dependencies": { + "isexe": "^2.0.0" + }, + "bin": { + "node-which": "bin/node-which" + }, + "engines": { + "node": ">= 8" + } + }, + "node_modules/wrap-ansi": { + "version": "7.0.0", + "resolved": "https://registry.npmjs.org/wrap-ansi/-/wrap-ansi-7.0.0.tgz", + "integrity": "sha512-YVGIj2kamLSTxw6NsZjoBxfSwsn0ycdesmc4p+Q21c5zPuZ1pl+NfxVdxPtdHvmNVOQ6XSYG4AUtyt/Fi7D16Q==", + "dev": true, + "license": "MIT", + "dependencies": { + "ansi-styles": "^4.0.0", + "string-width": "^4.1.0", + "strip-ansi": "^6.0.0" + }, + "engines": { + "node": ">=10" + }, + "funding": { + "url": "https://github.com/chalk/wrap-ansi?sponsor=1" + } + }, + "node_modules/xcode": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/xcode/-/xcode-4.0.0.tgz", + "integrity": "sha512-dDaoWzc9EP2fp9FS9PVZUkyvFxY4y1TOV9pcKaKLk++Ei/qb97XDFEVP7GnW7Osii/TzVABJ0jq2F+9/lq0TVA==", + "dev": true, + "license": "Apache-2.0", + "dependencies": { + "simple-plist": "^1.3.1" + }, + "engines": { + "node": ">=14.17.0" + } + }, + "node_modules/xml2js": { + "version": "0.6.2", + "resolved": "https://registry.npmjs.org/xml2js/-/xml2js-0.6.2.tgz", + "integrity": "sha512-T4rieHaC1EXcES0Kxxj4JWgaUQHDk+qwHcYOCFHfiwKz7tOVPLq7Hjq9dM1WCMhylqMEfP7hMcOIChvotiZegA==", + "dev": true, + "license": "MIT", + "dependencies": { + "sax": ">=0.6.0", + "xmlbuilder": "~11.0.0" + }, + "engines": { + "node": ">=4.0.0" + } + }, + "node_modules/xml2js/node_modules/xmlbuilder": { + "version": "11.0.1", + "resolved": "https://registry.npmjs.org/xmlbuilder/-/xmlbuilder-11.0.1.tgz", + "integrity": "sha512-fDlsI/kFEx7gLvbecc0/ohLG50fugQp8ryHzMTuW9vSa1GJ0XYWKnhsUx7oie3G98+r56aTQIUB4kht42R3JvA==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=4.0" + } + }, + "node_modules/xmlbuilder": { + "version": "15.1.1", + "resolved": "https://registry.npmjs.org/xmlbuilder/-/xmlbuilder-15.1.1.tgz", + "integrity": "sha512-yMqGBqtXyeN1e3TGYvgNgDVZ3j84W4cwkOXQswghol6APgZWaff9lnbvN7MHYJOiXsvGPXtjTYJEiC9J2wv9Eg==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=8.0" + } + }, + "node_modules/yallist": { + "version": "5.0.0", + "resolved": "https://registry.npmjs.org/yallist/-/yallist-5.0.0.tgz", + "integrity": "sha512-YgvUTfwqyc7UXVMrB+SImsVYSmTS8X/tSrtdNZMImM+n7+QTriRXyXim0mBrTXNeqzVF0KWGgHPeiyViFFrNDw==", + "dev": true, + "license": "BlueOak-1.0.0", + "engines": { + "node": ">=18" + } + }, + "node_modules/yauzl": { + "version": "2.10.0", + "resolved": "https://registry.npmjs.org/yauzl/-/yauzl-2.10.0.tgz", + "integrity": "sha512-p4a9I6X6nu6IhoGmBqAcbJy1mlC4j27vEPZX9F4L4/vZT3Lyq1VkFHw/V/PUcB9Buo+DG3iHkT0x3Qya58zc3g==", + "dev": true, + "license": "MIT", + "dependencies": { + "buffer-crc32": "~0.2.3", + "fd-slicer": "~1.1.0" + } + } + } +} diff --git a/android/package.json b/android/package.json new file mode 100644 index 0000000..cb90233 --- /dev/null +++ b/android/package.json @@ -0,0 +1,21 @@ +{ + "name": "sonda-android", + "private": true, + "version": "0.0.0", + "description": "Capacitor shell that opens a Sonda server in an Android app", + "scripts": { + "test": "node --test test/*.test.mjs", + "sync": "cap sync android", + "apk": "cap sync android && cd android && ./gradlew assembleDebug" + }, + "dependencies": { + "@capacitor/android": "^8.6.2", + "@capacitor/app": "^8.1.2", + "@capacitor/core": "^8.6.2" + }, + "devDependencies": { + "@capacitor/cli": "^8.6.2", + "typescript": "^7.0.2" + }, + "type": "module" +} diff --git a/android/test/server.test.mjs b/android/test/server.test.mjs new file mode 100644 index 0000000..bdc3361 --- /dev/null +++ b/android/test/server.test.mjs @@ -0,0 +1,23 @@ +import assert from 'node:assert/strict' +import { test } from 'node:test' +import { normalizeAddress } from '../www/server.js' + +test('a bare host gets https', () => { + assert.equal(normalizeAddress('music.example.org'), 'https://music.example.org') +}) + +test('a scheme that was typed is kept, and so is the port', () => { + assert.equal(normalizeAddress('http://192.168.1.5:8080'), 'http://192.168.1.5:8080') + assert.equal(normalizeAddress('https://music.example.org:8443'), 'https://music.example.org:8443') +}) + +test('spaces, a trailing slash, a path and a query are dropped', () => { + assert.equal(normalizeAddress(' https://music.example.org/ '), 'https://music.example.org') + assert.equal(normalizeAddress('https://music.example.org/albums/3?x=1#top'), 'https://music.example.org') +}) + +test('nothing, or something that is not an address, is refused', () => { + for (const bad of ['', ' ', null, undefined, 'ftp://music.example.org', 'http://', 'not an address']) { + assert.equal(normalizeAddress(bad), null, String(bad)) + } +}) diff --git a/android/www/index.html b/android/www/index.html new file mode 100644 index 0000000..1a7bda9 --- /dev/null +++ b/android/www/index.html @@ -0,0 +1,94 @@ + + + + + + + Sonda + + + +
+

Sonda

+

Opening your server…

+ +
+ + + diff --git a/android/www/server.js b/android/www/server.js new file mode 100644 index 0000000..d0cc46e --- /dev/null +++ b/android/www/server.js @@ -0,0 +1,16 @@ +/** Turns what was typed into the address of a Sonda server, or null when it is not one. */ +export function normalizeAddress(input) { + const text = String(input ?? '').trim() + if (text === '') return null + const withScheme = /^[a-z][a-z0-9+.-]*:\/\//i.test(text) ? text : `https://${text}` + let url + try { + url = new URL(withScheme) + } catch { + return null + } + if (url.protocol !== 'https:' && url.protocol !== 'http:') return null + if (url.hostname === '') return null + // The app lives at the root of the server: a path, a query or a fragment typed by mistake is dropped. + return url.origin +} diff --git a/cmd/sondad/main.go b/cmd/sondad/main.go index b10faba..eaadfff 100644 --- a/cmd/sondad/main.go +++ b/cmd/sondad/main.go @@ -60,8 +60,10 @@ import ( const defaultConfigFile = "sonda.toml" -// version goes into the User-Agent sent to providers. -const version = "0.1.0" +// version goes into the User-Agent sent to providers, and is what GET /version says. The release sets it +// (-ldflags "-X main.version=1.2.3": see the Dockerfile and the Makefile); a build that was not made by a release says +// "dev". +var version = "dev" // lastfmMinInterval spaces the requests to Last.fm well below its limit. const lastfmMinInterval = 250 * time.Millisecond @@ -153,6 +155,17 @@ func run() error { scanner := library.NewScanner(libraryRepo, library.TaglibReader{}, library.NewHub(), cfg.Library.ScanWorkers) scans := library.NewManager(scanner, libraryRepo) logScanResults(logger, scans) + // The libraries are scanned by themselves when their music changed: looking costs only the names of the files. + if cfg.Library.AutoScanMinutes > 0 { + auto := library.NewAutoScanner(scans, libraryRepo, time.Duration(cfg.Library.AutoScanMinutes)*time.Minute) + auto.OnScan = func(lib library.Library, signatureErr, _ error) { + if signatureErr != nil { // a NAS that is not mounted says this all the time: not news + logger.Debug("auto scan: the folder of a library cannot be read", zap.Int64("library", lib.ID), zap.Error(signatureErr)) + } + } + go auto.Run(ctx) + logger.Info("libraries are scanned by themselves when their music changed", zap.Int("every_minutes", cfg.Library.AutoScanMinutes)) + } libraries := library.NewLibraries(libraryRepo) libraries.SetBusy(func() bool { return scans.Status().Running }) diff --git a/internal/config/config.go b/internal/config/config.go index f20f5bf..7823a0d 100644 --- a/internal/config/config.go +++ b/internal/config/config.go @@ -42,6 +42,9 @@ type Server struct { // in the database and are managed through the API. type Library struct { ScanWorkers int `toml:"scan_workers"` // parallel tag readers per scan + // AutoScanMinutes is how often Sonda looks at the folders of the libraries and scans the ones whose music changed; + // 0 turns it off. Looking reads the names of the files and nothing else. + AutoScanMinutes int `toml:"auto_scan_minutes"` // AllowDelete lets an admin delete the extra copies of a song from the music folders. It is the // one thing that makes Sonda write there, so it is off until the operator turns it on (and it // needs the folders mounted writable). @@ -142,7 +145,7 @@ type Storage struct { func Default() Config { return Config{ Server: Server{Listen: "127.0.0.1:8080"}, - Library: Library{ScanWorkers: 4}, + Library: Library{ScanWorkers: 4, AutoScanMinutes: 15}, Database: Database{Driver: "sqlite", Path: "sonda.db"}, Log: Log{Env: "production"}, Auth: Auth{AccessTTLMinutes: 15, RefreshTTLHours: 720}, // 15 minutes, 30 days @@ -185,6 +188,13 @@ func Load(path string) (Config, error) { } cfg.Library.AllowDelete = allow } + if v := os.Getenv("SONDA_AUTO_SCAN_MINUTES"); v != "" { + n, err := strconv.Atoi(v) + if err != nil { + return Config{}, fmt.Errorf("SONDA_AUTO_SCAN_MINUTES must be a whole number of minutes, got %q", v) + } + cfg.Library.AutoScanMinutes = n + } if cfg.Storage.DataDir == "" { cfg.Storage.DataDir = defaultDataDir(cfg.Database) } @@ -285,6 +295,9 @@ func (c Config) Validate() error { if c.Storage.DataDir == "" { errs = append(errs, errors.New("storage.data_dir must not be empty")) } + if c.Library.AutoScanMinutes < 0 || c.Library.AutoScanMinutes > 10080 { + errs = append(errs, errors.New("library.auto_scan_minutes must be between 0 (off) and 10080 (a week)")) + } if c.Library.ScanWorkers < 1 { errs = append(errs, errors.New("library.scan_workers must be at least 1")) } diff --git a/internal/config/config_test.go b/internal/config/config_test.go index 5f72e19..3a4eff9 100644 --- a/internal/config/config_test.go +++ b/internal/config/config_test.go @@ -37,6 +37,9 @@ func TestLoadEmptyPathReturnsDefaults(t *testing.T) { if cfg.Library.ScanWorkers != 4 { t.Errorf("scan workers = %d", cfg.Library.ScanWorkers) } + if cfg.Library.AutoScanMinutes != 15 { + t.Errorf("auto scan = %d minutes, want 15", cfg.Library.AutoScanMinutes) + } if cfg.Listening.MinListen() != 20*time.Second { t.Errorf("min listen = %v, want 20s", cfg.Listening.MinListen()) } @@ -146,6 +149,9 @@ func TestValidate(t *testing.T) { {"two wikipedia languages", func(c *Config) { c.Wikipedia.Languages = []string{"it", "en"} }, ""}, {"empty data dir", func(c *Config) { c.Storage.DataDir = "" }, "storage.data_dir"}, {"bad workers", func(c *Config) { c.Library.ScanWorkers = 0 }, "library.scan_workers"}, + {"a negative auto scan", func(c *Config) { c.Library.AutoScanMinutes = -1 }, "library.auto_scan_minutes"}, + {"an auto scan of a year", func(c *Config) { c.Library.AutoScanMinutes = 525600 }, "library.auto_scan_minutes"}, + {"auto scan off", func(c *Config) { c.Library.AutoScanMinutes = 0 }, ""}, {"bad access ttl", func(c *Config) { c.Auth.AccessTTLMinutes = 0 }, "auth.access_ttl_minutes"}, {"bad refresh ttl", func(c *Config) { c.Auth.RefreshTTLHours = 0 }, "auth.refresh_ttl_hours"}, } @@ -341,3 +347,20 @@ func TestAllowDeleteEnvironmentVariableMustBeABoolean(t *testing.T) { t.Errorf("got %v, want an error naming SONDA_ALLOW_DELETE", err) } } + +func TestTheAutoScanComesFromTheFileOrTheEnvironment(t *testing.T) { + dir := t.TempDir() + p := writeFile(t, dir, "[library]\nauto_scan_minutes = 5\n") + cfg, err := Load(p) + if err != nil || cfg.Library.AutoScanMinutes != 5 { + t.Fatalf("file: %d %v", cfg.Library.AutoScanMinutes, err) + } + t.Setenv("SONDA_AUTO_SCAN_MINUTES", "0") + if cfg, err = Load(p); err != nil || cfg.Library.AutoScanMinutes != 0 { + t.Fatalf("environment over file: %d %v", cfg.Library.AutoScanMinutes, err) + } + t.Setenv("SONDA_AUTO_SCAN_MINUTES", "often") + if _, err = Load(""); err == nil { + t.Fatal("a value that is not a number was taken") + } +} diff --git a/internal/library/autoscan.go b/internal/library/autoscan.go new file mode 100644 index 0000000..fbcee70 --- /dev/null +++ b/internal/library/autoscan.go @@ -0,0 +1,199 @@ +package library + +import ( + "context" + "crypto/sha256" + "encoding/hex" + "errors" + "fmt" + "os" + "path/filepath" + "time" +) + +// forceEvery is how long a library may go without a scan even when its folders look the same: a song that is tagged +// again keeps its place and its name, so only a scan of the file finds it. +const forceEvery = 24 * time.Hour + +// Signature says how a folder looks: a hash of the names of everything in it, folder by folder, and of the time of each +// folder. It reads the names and nothing else (no file is opened or measured), which is why it is cheap enough to +// ask often of a NAS, and it changes when a song or a folder comes, goes or is renamed. It does not change when a +// file is changed where it stands. The housekeeping folders of a NAS (see isSystemDir) and the links inside the folder +// are left out, as the scanner leaves them out; a link as the folder itself is followed. A folder that cannot be read is +// an error. +func Signature(ctx context.Context, root string) (string, error) { + top, err := filepath.EvalSymlinks(root) + if err != nil { + return "", err + } + info, err := os.Stat(top) + if err != nil { + return "", err + } + if !info.IsDir() { + return "", fmt.Errorf("%s is not a directory", root) + } + h := sha256.New() + var walk func(dir, rel string) error + walk = func(dir, rel string) error { + if err := ctx.Err(); err != nil { + return err + } + entries, err := os.ReadDir(dir) + if err != nil { + if rel == "" { + return err + } + fmt.Fprintf(h, "! %s\n", rel) // a folder that cannot be read is a state of its own + return nil + } + var mtime int64 + if st, err := os.Stat(dir); err == nil { + mtime = st.ModTime().UnixNano() + } + fmt.Fprintf(h, "d %s %d\n", rel, mtime) + for _, e := range entries { // os.ReadDir sorts them by name + if e.IsDir() && isSystemDir(e.Name()) { + continue + } + kind := 'f' + switch { + case e.Type()&os.ModeSymlink != 0: + kind = 'l' + case e.IsDir(): + kind = 'd' + } + fmt.Fprintf(h, "%c %s\n", kind, e.Name()) + } + for _, e := range entries { + if e.IsDir() && e.Type()&os.ModeSymlink == 0 && !isSystemDir(e.Name()) { + if err := walk(filepath.Join(dir, e.Name()), rel+e.Name()+"/"); err != nil { + return err + } + } + } + return nil + } + if err := walk(top, ""); err != nil { + return "", err + } + return hex.EncodeToString(h.Sum(nil)), nil +} + +// scans is what the watcher asks of the manager of the scans: *Manager. +type scans interface { + StartLibrary(ctx context.Context, id int64, opts ...ScanOption) error + Status() Status +} + +// AutoScanner scans the libraries by itself when their music changed. Every `interval` it takes the Signature of each +// library and scans the ones that do not look as they did the last time (the first time, all of them), and every library +// at least once a day. A scan is the usual one: it reads only the files that are new or changed. Nothing is scanned +// while another scan runs, and a scan that failed is tried again at the next look. +type AutoScanner struct { + scans scans + libs LibrarySource + interval time.Duration + // first is how long after the start the first look comes: the server is not busy with it while it starts. + first time.Duration + now func() time.Time + poll time.Duration // how often it asks whether a scan it started is over + // OnScan, when set, is told about each library it scans and about each one it could not look at. + OnScan func(lib Library, signatureErr, scanErr error) + + seen map[int64]seenLibrary +} + +type seenLibrary struct { + sig string + at time.Time +} + +// NewAutoScanner builds an AutoScanner that looks every interval. +func NewAutoScanner(s scans, libs LibrarySource, interval time.Duration) *AutoScanner { + return &AutoScanner{ + scans: s, libs: libs, interval: interval, first: 30 * time.Second, + now: time.Now, poll: time.Second, seen: map[int64]seenLibrary{}, + } +} + +// Run looks at the libraries until ctx ends. +func (a *AutoScanner) Run(ctx context.Context) { + timer := time.NewTimer(a.first) + defer timer.Stop() + for { + select { + case <-ctx.Done(): + return + case <-timer.C: + a.tick(ctx) + timer.Reset(a.interval) + } + } +} + +// tick looks at every library once. +func (a *AutoScanner) tick(ctx context.Context) { + libs, err := a.libs.ListLibraries(ctx) + if err != nil { + return + } + present := map[int64]bool{} + for _, l := range libs { + present[l.ID] = true + } + for id := range a.seen { + if !present[id] { + delete(a.seen, id) // a library that is gone: a new one with its number starts from nothing + } + } + for _, lib := range libs { + if ctx.Err() != nil { + return + } + sig, err := Signature(ctx, lib.Path) + if err != nil { + // Not there (a NAS that is not mounted): nothing is known about it, and the scan would only say so. + a.told(lib, err, nil) + continue + } + prev, ok := a.seen[lib.ID] + if ok && prev.sig == sig && a.now().Sub(prev.at) < forceEvery { + continue + } + switch err := a.scans.StartLibrary(ctx, lib.ID); { + case errors.Is(err, ErrScanRunning): + return // another scan has the turn: the rest wait for the next look + case err != nil: + a.told(lib, nil, err) + continue + } + scanErr := a.wait(ctx) + a.told(lib, nil, scanErr) + if scanErr == nil && ctx.Err() == nil { + // The signature is the one taken before the scan: what changed while it ran is seen at the next look. + a.seen[lib.ID] = seenLibrary{sig: sig, at: a.now()} + } + } +} + +// wait holds until the scan that was started is over, and says how it ended. +func (a *AutoScanner) wait(ctx context.Context) error { + for a.scans.Status().Running { + select { + case <-ctx.Done(): + return ctx.Err() + case <-time.After(a.poll): + } + } + if msg := a.scans.Status().LastError; msg != "" { + return errors.New(msg) + } + return nil +} + +func (a *AutoScanner) told(lib Library, sigErr, scanErr error) { + if a.OnScan != nil { + a.OnScan(lib, sigErr, scanErr) + } +} diff --git a/internal/library/autoscan_test.go b/internal/library/autoscan_test.go new file mode 100644 index 0000000..47262c1 --- /dev/null +++ b/internal/library/autoscan_test.go @@ -0,0 +1,328 @@ +package library + +import ( + "context" + "errors" + "os" + "path/filepath" + "sync" + "testing" + "time" +) + +// ---- the signature of a folder ---- + +func tree(t *testing.T) string { + t.Helper() + root := t.TempDir() + for _, f := range []string{"a/one.mp3", "a/two.flac", "b/c/three.mp3"} { + touch(t, root, f) + } + settle(t, root) + return root +} + +func touch(t *testing.T, root, rel string) { + t.Helper() + p := filepath.Join(root, filepath.FromSlash(rel)) + if err := os.MkdirAll(filepath.Dir(p), 0o755); err != nil { + t.Fatal(err) + } + if err := os.WriteFile(p, []byte("x"), 0o644); err != nil { + t.Fatal(err) + } +} + +// settle gives every folder of the tree a moment far in the past, so that a change made after it moves the time of the +// folder it touches, whatever the resolution of the file system. +func settle(t *testing.T, root string) { + t.Helper() + old := time.Date(2020, 1, 1, 12, 0, 0, 0, time.UTC) // always the same, so that two calls leave the same time + var dirs []string + _ = filepath.WalkDir(root, func(p string, d os.DirEntry, err error) error { + if err == nil && d.IsDir() { + dirs = append(dirs, p) + } + return nil + }) + for i := len(dirs) - 1; i >= 0; i-- { + if err := os.Chtimes(dirs[i], old, old); err != nil { + t.Fatal(err) + } + } +} + +func sig(t *testing.T, root string) string { + t.Helper() + s, err := Signature(context.Background(), root) + if err != nil { + t.Fatal(err) + } + return s +} + +func TestTheSignatureOfAFolderChangesWhenMusicComesOrGoes(t *testing.T) { + root := tree(t) + base := sig(t, root) + if sig(t, root) != base { + t.Fatal("the same folder, two signatures") + } + + for name, change := range map[string]func(){ + "a song comes": func() { touch(t, root, "a/new.mp3") }, + "a song goes": func() { _ = os.Remove(filepath.Join(root, "a/one.mp3")) }, + "a song is renamed": func() { _ = os.Rename(filepath.Join(root, "a/two.flac"), filepath.Join(root, "a/deux.flac")) }, + "a folder comes": func() { touch(t, root, "d/new.mp3") }, + "a folder goes": func() { _ = os.RemoveAll(filepath.Join(root, "b")) }, + "something is dropped": func() { touch(t, root, "b/c/cover.jpg") }, + "a deep folder changes": func() { touch(t, root, "b/c/more.flac") }, + } { + fresh := tree(t) + before := sig(t, fresh) + root = fresh + change() + if sig(t, fresh) == before { + t.Errorf("%s: the signature did not change", name) + } + } +} + +func TestTheSignatureLeavesOutTheHousekeepingFoldersOfANAS(t *testing.T) { + root := tree(t) + base := sig(t, root) + // A NAS writes thumbnails in @eaDir all the time: what happens inside it is not a change of the music. + if err := os.MkdirAll(filepath.Join(root, "a", "@eaDir"), 0o755); err != nil { + t.Fatal(err) + } + settle(t, root) + withDir := sig(t, root) + touch(t, root, "a/@eaDir/thumb.jpg") + touch(t, root, "a/@eaDir/deeper/thumb2.jpg") + settle(t, root) + if got := sig(t, root); got != withDir { + t.Errorf("a change inside @eaDir moved the signature") + } + _ = base +} + +func TestTheSignatureOfAFolderThatCannotBeReadIsAnError(t *testing.T) { + if _, err := Signature(context.Background(), filepath.Join(t.TempDir(), "nothing")); err == nil { + t.Fatal("no error for a folder that is not there") + } + file := filepath.Join(t.TempDir(), "f") + _ = os.WriteFile(file, nil, 0o644) + if _, err := Signature(context.Background(), file); err == nil { + t.Fatal("no error for a file") + } +} + +func TestTheSignatureFollowsTheLinkOfTheRootButNotOthers(t *testing.T) { + root := tree(t) + link := filepath.Join(t.TempDir(), "music") + if err := os.Symlink(root, link); err != nil { + t.Skip("no symlinks here") + } + if sig(t, link) != sig(t, root) { + t.Error("a library that is a link has another signature than its target") + } + outside := tree(t) + if err := os.Symlink(outside, filepath.Join(root, "outside")); err != nil { + t.Fatal(err) + } + settle(t, root) + before := sig(t, root) + touch(t, outside, "a/changed.mp3") + if sig(t, root) != before { + t.Error("a link inside the folder was followed") + } +} + +func TestTheSignatureStopsWithTheContext(t *testing.T) { + ctx, cancel := context.WithCancel(context.Background()) + cancel() + if _, err := Signature(ctx, tree(t)); !errors.Is(err, context.Canceled) { + t.Fatalf("err = %v", err) + } +} + +// ---- the watcher ---- + +type fakeScans struct { + mu sync.Mutex + started []int64 + running bool + busy bool // StartLibrary answers ErrScanRunning + lastErr string // what the scan that finished says + finishes int // how many Status calls say "running" before it is over + left int +} + +func (f *fakeScans) StartLibrary(_ context.Context, id int64, _ ...ScanOption) error { + f.mu.Lock() + defer f.mu.Unlock() + if f.busy { + return ErrScanRunning + } + f.started = append(f.started, id) + f.left = f.finishes + return nil +} + +func (f *fakeScans) Status() Status { + f.mu.Lock() + defer f.mu.Unlock() + if f.left > 0 { + f.left-- + return Status{Running: true} + } + return Status{LastError: f.lastErr} +} + +func (f *fakeScans) count() int { + f.mu.Lock() + defer f.mu.Unlock() + return len(f.started) +} + +type fakeLibs struct{ libs []Library } + +func (f *fakeLibs) ListLibraries(context.Context) ([]Library, error) { return f.libs, nil } +func (f *fakeLibs) GetLibrary(_ context.Context, id int64) (Library, error) { + for _, l := range f.libs { + if l.ID == id { + return l, nil + } + } + return Library{}, ErrLibraryNotFound +} + +func newWatcher(scans *fakeScans, libs ...Library) (*AutoScanner, *time.Time) { + now := time.Unix(1_700_000_000, 0) + a := NewAutoScanner(scans, &fakeLibs{libs: libs}, time.Minute) + a.now = func() time.Time { return now } + a.poll = time.Millisecond + return a, &now +} + +func TestTheWatcherScansALibraryThatChangedAndLeavesOneThatDidNot(t *testing.T) { + ctx := context.Background() + rock, jazz := tree(t), tree(t) + scans := &fakeScans{} + a, _ := newWatcher(scans, Library{ID: 1, Path: rock}, Library{ID: 2, Path: jazz}) + + a.tick(ctx) // the first time nothing is known: each library is looked at + if scans.count() != 2 { + t.Fatalf("first tick: %v", scans.started) + } + a.tick(ctx) + if scans.count() != 2 { + t.Fatalf("nothing changed, yet %v", scans.started) + } + touch(t, jazz, "a/new.flac") + a.tick(ctx) + if got := scans.started; len(got) != 3 || got[2] != 2 { + t.Fatalf("only jazz changed: %v", got) + } + a.tick(ctx) + if scans.count() != 3 { + t.Fatalf("after the scan nothing changed: %v", scans.started) + } +} + +func TestAScanThatCouldNotStartOrFailedIsTriedAgain(t *testing.T) { + ctx := context.Background() + root := tree(t) + scans := &fakeScans{busy: true} + a, _ := newWatcher(scans, Library{ID: 1, Path: root}) + + a.tick(ctx) // somebody else is scanning + scans.busy = false + a.tick(ctx) + if scans.count() != 1 { + t.Fatalf("a scan that did not start was forgotten: %v", scans.started) + } + + scans.lastErr = "directory is empty but 10 indexed files exist" + touch(t, root, "a/new.mp3") + a.tick(ctx) // starts, and fails + a.tick(ctx) // the same change is still not scanned: try again + if scans.count() != 3 { + t.Fatalf("a failed scan was not tried again: %v", scans.started) + } + scans.lastErr = "" + a.tick(ctx) + a.tick(ctx) + if scans.count() != 4 { + t.Fatalf("after it worked it was scanned again: %v", scans.started) + } +} + +func TestAnUnreadableLibraryIsLeftAlone(t *testing.T) { + scans := &fakeScans{} + a, _ := newWatcher(scans, Library{ID: 1, Path: filepath.Join(t.TempDir(), "unmounted")}) + a.tick(context.Background()) + if scans.count() != 0 { + t.Fatalf("a library that cannot be read was scanned: %v", scans.started) + } +} + +func TestEveryLibraryIsScannedOnceADayEvenIfNothingMovedItsFolders(t *testing.T) { + // A song that is tagged again keeps its folder as it was: only the file knows. A scan once a day finds it. + ctx := context.Background() + scans := &fakeScans{} + a, now := newWatcher(scans, Library{ID: 1, Path: tree(t)}) + a.tick(ctx) + *now = now.Add(23 * time.Hour) + a.tick(ctx) + if scans.count() != 1 { + t.Fatalf("after 23 hours: %v", scans.started) + } + *now = now.Add(2 * time.Hour) + a.tick(ctx) + if scans.count() != 2 { + t.Fatalf("after 25 hours: %v", scans.started) + } +} + +func TestTheWatcherWaitsForTheScanToEndBeforeItGoesOn(t *testing.T) { + ctx := context.Background() + scans := &fakeScans{finishes: 3} + a, _ := newWatcher(scans, Library{ID: 1, Path: tree(t)}, Library{ID: 2, Path: tree(t)}) + a.tick(ctx) + if scans.count() != 2 || scans.left != 0 { + t.Fatalf("%v, %d left", scans.started, scans.left) + } +} + +func TestADeletedLibraryIsForgottenAndANewOneIsLookedAt(t *testing.T) { + ctx := context.Background() + scans := &fakeScans{} + libs := &fakeLibs{libs: []Library{{ID: 1, Path: tree(t)}}} + a := NewAutoScanner(scans, libs, time.Minute) + a.poll = time.Millisecond + a.tick(ctx) + libs.libs = nil + a.tick(ctx) + if len(a.seen) != 0 { + t.Fatalf("a library that is gone is still remembered: %v", a.seen) + } + libs.libs = []Library{{ID: 1, Path: tree(t)}} // another one with the same id, later + a.tick(ctx) + if scans.count() != 2 { + t.Fatalf("a new library with an old id: %v", scans.started) + } +} + +func TestRunStopsWithItsContext(t *testing.T) { + scans := &fakeScans{} + a := NewAutoScanner(scans, &fakeLibs{}, time.Hour) + ctx, cancel := context.WithCancel(context.Background()) + done := make(chan struct{}) + go func() { a.Run(ctx); close(done) }() + cancel() + select { + case <-done: + case <-time.After(2 * time.Second): + t.Fatal("Run did not stop") + } +} diff --git a/sonda.example.toml b/sonda.example.toml index 57399e6..c3e0b55 100644 --- a/sonda.example.toml +++ b/sonda.example.toml @@ -9,6 +9,9 @@ listen = "127.0.0.1:8080" # localhost by default # Libraries (name + directory) are managed through the API: POST /api/v1/libraries. [library] scan_workers = 4 # parallel tag readers during a scan +auto_scan_minutes = 15 # how often to look at the folders and scan the libraries whose music changed + # (0 turns it off). Looking reads the names of the files, nothing else, so it is + # cheap for a NAS; a library is scanned at least once a day. Or SONDA_AUTO_SCAN_MINUTES. # allow_delete = true # let an admin delete the extra copy of a song from the music folders. # Off by default: it is the one thing that makes Sonda write there, and it # needs the folders mounted writable. Or set SONDA_ALLOW_DELETE=true. diff --git a/web/index.html b/web/index.html index b6c7099..243714a 100644 --- a/web/index.html +++ b/web/index.html @@ -9,7 +9,7 @@ - + Sonda diff --git a/web/src/auth/AuthGate.tsx b/web/src/auth/AuthGate.tsx index 7f5fe51..7b24792 100644 --- a/web/src/auth/AuthGate.tsx +++ b/web/src/auth/AuthGate.tsx @@ -9,7 +9,7 @@ export default function AuthGate({ children }: { children: ReactNode }) { const { t } = useTranslation() if (status === 'loading') { - return
+ return
} if (status === 'anonymous') return return <>{children} diff --git a/web/src/auth/LoginPage.tsx b/web/src/auth/LoginPage.tsx index 3f225b9..1ad513e 100644 --- a/web/src/auth/LoginPage.tsx +++ b/web/src/auth/LoginPage.tsx @@ -31,7 +31,7 @@ export default function LoginPage() { } return ( -
+

{creating ? t('auth.registerTitle') : t('auth.signInTitle')}

diff --git a/web/src/components/Cover.test.tsx b/web/src/components/Cover.test.tsx index 7b610e0..207f55a 100644 --- a/web/src/components/Cover.test.tsx +++ b/web/src/components/Cover.test.tsx @@ -16,7 +16,7 @@ function placeholder(container: HTMLElement) { test('a cover asks for the album cover of the API', () => { const { container } = render() const img = container.querySelector('img')! - expect(img.getAttribute('src')).toBe('/api/v1/albums/12/cover') + expect(img.getAttribute('src')).toBe('/api/v1/albums/12/cover?size=small') expect(img).toHaveAttribute('loading', 'lazy') expect(img).toHaveAttribute('alt', '') expect(placeholder(container)).toBeNull() @@ -25,9 +25,9 @@ test('a cover asks for the album cover of the API', () => { test('the cover URL carries the access token and follows it when it changes', () => { sessionStore.setState({ accessToken: 'tok1' }) const { container } = render() - expect(container.querySelector('img')!.getAttribute('src')).toBe('/api/v1/albums/12/cover?access_token=tok1') + expect(container.querySelector('img')!.getAttribute('src')).toBe('/api/v1/albums/12/cover?size=small&access_token=tok1') act(() => sessionStore.setState({ accessToken: 'tok2' })) - expect(container.querySelector('img')!.getAttribute('src')).toBe('/api/v1/albums/12/cover?access_token=tok2') + expect(container.querySelector('img')!.getAttribute('src')).toBe('/api/v1/albums/12/cover?size=small&access_token=tok2') }) test('a cover that fails to load is replaced by the placeholder', () => { @@ -116,3 +116,10 @@ test('a cover that cannot be loaded falls back to the rings, and the picture hid expect(placeholder(container)).not.toBeNull() expect(container.querySelector('img')).toBeNull() }) + +test('a big cover asks for the full picture, a friend’s cover for the only one the friend has', () => { + const big = render() + expect(big.container.querySelector('img')!.getAttribute('src')).toBe('/api/v1/albums/12/cover') + const friend = render() + expect(friend.container.querySelector('img')!.getAttribute('src')).toBe('/api/v1/friends/3/albums/12/cover') +}) diff --git a/web/src/components/Cover.tsx b/web/src/components/Cover.tsx index 1ce7bca..92e1d1c 100644 --- a/web/src/components/Cover.tsx +++ b/web/src/components/Cover.tsx @@ -19,10 +19,14 @@ const RINGS = [ { size: '68%', opacity: 0.3 }, ] as const +/** Up to this size (CSS pixels) a cover is drawn from the small picture. */ +const SMALL_UP_TO = 150 + /** The cover of an album, or the rings of Sonda when there is none (or it cannot be loaded). */ export default function Cover({ albumId, friend, size, fluid = false }: CoverProps) { useAccessToken() // the URL carries the token, so it has to follow a renewal - const src = albumId === null ? null : mediaUrl(coverPath(friend, albumId)) + // A thumbnail asks for the small picture: a phone does not need to fetch 1000 pixels to draw 56. + const src = albumId === null ? null : mediaUrl(coverPath(friend, albumId, size <= SMALL_UP_TO)) // A failure is remembered for this URL only: a renewed token makes a new URL, which is tried again. const [failed, setFailed] = useState(null) const showImage = src !== null && failed !== src @@ -36,7 +40,16 @@ export default function Cover({ albumId, friend, size, fluid = false }: CoverPro className="relative shrink-0 overflow-hidden rounded-sm bg-muted" > {showImage ? ( - setFailed(src)} /> + window.matchMedia?.('(pointer: coarse)').matches && e.preventDefault()} + className="size-full object-cover" + onError={() => setFailed(src)} + /> ) : (