commit 89c543030807b48f3d9ecf922e110e49db938af1 Author: Cedric Date: Thu Nov 19 10:30:47 2026 +0100 Up And Down : première version diff --git a/.claude/launch.json b/.claude/launch.json new file mode 100644 index 0000000..c441850 --- /dev/null +++ b/.claude/launch.json @@ -0,0 +1,11 @@ +{ + "version": "0.0.1", + "configurations": [ + { + "name": "upandown-dev", + "runtimeExecutable": "sh", + "runtimeArgs": ["-c", "LISTEN_ADDR=:8099 DATA_DIR=./.devdata AUTH_MODE=both REGISTRATION=approval ADMIN_USER=admin ADMIN_PASSWORD=dev-password-123 OIDC_ISSUER=https://idp.invalid OIDC_CLIENT_ID=upandown OIDC_NAME=Authentik ./bin/upandown"], + "port": 8099 + } + ] +} diff --git a/.dockerignore b/.dockerignore new file mode 100644 index 0000000..fd7aa8c --- /dev/null +++ b/.dockerignore @@ -0,0 +1,7 @@ +**/node_modules +web/dist +data +.devdata +bin +*.md +.git diff --git a/.env.example b/.env.example new file mode 100644 index 0000000..4171f4c --- /dev/null +++ b/.env.example @@ -0,0 +1,22 @@ +UPANDOWN_PORT=8080 +# local, oidc, both ou none +AUTH_MODE=local +ADMIN_USER= +ADMIN_PASSWORD= +# closed, approval ou open +REGISTRATION=closed +OIDC_ISSUER= +OIDC_CLIENT_ID= +OIDC_CLIENT_SECRET= +OIDC_REDIRECT_URL= +OIDC_NAME=SSO +OIDC_ALLOWED_GROUPS= +OIDC_ADMIN_GROUPS= +OIDC_ADMIN_EMAILS= +SESSION_SECRET= +PUBLIC_URL= +MAX_UPLOAD_MB=0 +USER_QUOTA_MB=0 +COMMON_READONLY=false +TRASH_DAYS=0 +HISTORY_KEEP=10 diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..7694161 --- /dev/null +++ b/.gitignore @@ -0,0 +1,7 @@ +/data/ +/.devdata/ +/bin/ +web/dist/* +!web/dist/.gitkeep +frontend/node_modules/ +.DS_Store diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..cf2d026 --- /dev/null +++ b/Dockerfile @@ -0,0 +1,34 @@ +# syntax=docker/dockerfile:1 + +# --- 1. Frontend : React + Vite -> /src/web/dist +FROM node:22-alpine AS frontend +WORKDIR /src/frontend +COPY frontend/package.json frontend/package-lock.json ./ +RUN --mount=type=cache,target=/root/.npm npm ci --no-audit --no-fund +COPY frontend/ ./ +RUN npm run build + +# --- 2. Backend : binaire Go statique embarquant le frontend +FROM golang:1.24-alpine AS backend +ARG VERSION=dev +WORKDIR /src +COPY go.mod ./ +COPY cmd ./cmd +COPY internal ./internal +COPY web/embed.go ./web/ +COPY --from=frontend /src/web/dist ./web/dist +RUN --mount=type=cache,target=/root/.cache/go-build \ + CGO_ENABLED=0 go test ./... && \ + CGO_ENABLED=0 go build -trimpath -ldflags="-s -w -X main.version=${VERSION}" -o /out/server ./cmd/server && \ + mkdir -p /out/data + +# --- 3. Image finale : distroless, non-root (uid 65532) +FROM gcr.io/distroless/static-debian12:nonroot +COPY --from=backend /out/server /server +COPY --from=backend --chown=65532:65532 /out/data /data +ENV LISTEN_ADDR=:8080 DATA_DIR=/data +VOLUME ["/data"] +EXPOSE 8080 +USER nonroot:nonroot +HEALTHCHECK --interval=30s --timeout=5s --start-period=5s --retries=3 CMD ["/server", "healthcheck"] +ENTRYPOINT ["/server"] diff --git a/LICENSE b/LICENSE new file mode 100644 index 0000000..0612a10 --- /dev/null +++ b/LICENSE @@ -0,0 +1,21 @@ +MIT License + +Copyright (c) 2026 vLab-BZH + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. diff --git a/LICENSE.fr.md b/LICENSE.fr.md new file mode 100644 index 0000000..1d18e7c --- /dev/null +++ b/LICENSE.fr.md @@ -0,0 +1,26 @@ +# Licence MIT (traduction française) + +> Traduction fournie à titre informatif. Seule la version anglaise du fichier [`LICENSE`](LICENSE) fait foi. + +```text +Copyright (c) 2026 vLab-BZH + +L'autorisation est accordée, gracieusement, à toute personne obtenant une copie +de ce logiciel et des fichiers de documentation associés (le « Logiciel »), de +commercialiser le Logiciel sans restriction, notamment les droits d'utiliser, +de copier, de modifier, de fusionner, de publier, de distribuer, de +sous-licencier et/ou de vendre des copies du Logiciel, ainsi que d'autoriser +les personnes auxquelles le Logiciel est fourni à le faire, sous réserve des +conditions suivantes : + +La déclaration de copyright ci-dessus et la présente autorisation doivent être +incluses dans toutes copies ou parties substantielles du Logiciel. + +LE LOGICIEL EST FOURNI « TEL QUEL », SANS GARANTIE D'AUCUNE SORTE, EXPLICITE OU +IMPLICITE, NOTAMMENT SANS GARANTIE DE QUALITÉ MARCHANDE, D'ADÉQUATION À UN +USAGE PARTICULIER ET D'ABSENCE DE CONTREFAÇON. EN AUCUN CAS LES AUTEURS OU +TITULAIRES DU DROIT D'AUTEUR NE SERONT RESPONSABLES DE TOUT DOMMAGE, +RÉCLAMATION OU AUTRE RESPONSABILITÉ, QUE CE SOIT DANS LE CADRE D'UN CONTRAT, +D'UN DÉLIT OU AUTRE, EN PROVENANCE DE, CONSÉCUTIF À OU EN RELATION AVEC LE +LOGICIEL OU SON UTILISATION, OU AVEC D'AUTRES ÉLÉMENTS DU LOGICIEL. +``` diff --git a/README.md b/README.md new file mode 100644 index 0000000..1e06685 --- /dev/null +++ b/README.md @@ -0,0 +1,90 @@ +# Up And Down + +Dépôt et téléchargement de fichiers **auto-hébergé**, avec un navigateur de fichiers complet. Même modèle qu'[Excalicloud](https://github.com/vLab-BZH/excalicloud) (explorateur, espaces personnels, favoris, tags, corbeille, partage, authentification OIDC ou locale), mais pour des fichiers **de tout type**. + +- **Envoi** : glisser-déposer de fichiers et de dossiers entiers, envoi en flux (pas de limite de mémoire), plusieurs fichiers en parallèle, progression, annulation, nouvel essai, choix « garder les deux / remplacer / ignorer », date de modification d'origine conservée. +- **Navigation** : 4 affichages (liste, tableau triable, vignettes, galerie), recherche (noms, tags, **contenu des fichiers texte**), tags, favoris (fichiers et dossiers), sélection multiple, glisser-déposer pour déplacer, miniatures d'images (EXIF pris en compte). +- **Aperçu intégré** : images, vidéo, audio, PDF, texte et code, avec navigation ←/→ dans le dossier. +- **Téléchargement** : fichier (reprise possible, `Range`) ou dossier / sélection en **ZIP** généré en flux. +- **Espaces** : arborescence commune + espace **Personnel** privé par utilisateur ; poubelle ; historique des versions (chaque remplacement garde l'ancien contenu, restauration en un clic). +- **Partage** par lien (`/s/`) d'un fichier ou d'un dossier : durée au choix, **mot de passe** facultatif, compteur de téléchargements, révocation, sans compte pour le destinataire. +- **Comptes** : comptes locaux avec **inscription** (fermée, avec validation, ou libre), **connexion OIDC** (Authentik, Keycloak...), ou les deux. Rôles administrateur / utilisateur, quotas, jetons d'API. +- **Sécurité** : conteneur non-root en lecture seule, un seul binaire Go (bibliothèque standard, aucune dépendance), fichiers servis sans jamais exécuter leur contenu dans l'origine de l'application. + +## Démarrage + +```bash +cp .env.example .env # optionnel +docker compose up -d --build +# http://localhost:8080 : le premier compte créé devient l'administrateur +``` + +Pour imposer l'administrateur : `ADMIN_USER` et `ADMIN_PASSWORD` dans `.env`. Les fichiers sont de simples fichiers sur le volume `./data` (`chown -R 65532:65532 ./data` pour un bind mount). + +## Authentification + +| `AUTH_MODE` | Comportement | +|---|---| +| `local` (défaut) | Comptes locaux (mot de passe PBKDF2-SHA256), inscription selon `REGISTRATION` | +| `oidc` | Connexion uniquement via le fournisseur OIDC | +| `both` | Formulaire local **et** bouton OIDC | +| `none` | Aucune authentification intégrée (reverse proxy qui authentifie) ; un seul utilisateur, tout le monde administre | + +**Inscription** (`REGISTRATION`, modifiable ensuite dans *Administration > Général*) : `closed` (l'administrateur crée les comptes), `approval` (les inscrits attendent la validation d'un administrateur), `open`. Tant qu'aucun administrateur n'existe, le premier compte créé (inscription ou première connexion OIDC) le devient. + +**OIDC** : `OIDC_ISSUER`, `OIDC_CLIENT_ID`, `OIDC_CLIENT_SECRET` (vide : client public, PKCE seul), URI de redirection `https:///auth/callback` (ou `OIDC_REDIRECT_URL`). `OIDC_ALLOWED_GROUPS` restreint l'accès ; `OIDC_ADMIN_GROUPS` / `OIDC_ADMIN_EMAILS` désignent les administrateurs (synchronisés à chaque connexion). Les comptes OIDC sont créés à la première connexion ; un e-mail identique d'un autre sujet ne fusionne jamais deux comptes. + +## Variables + +| Variable | Défaut | Rôle | +|---|---|---| +| `LISTEN_ADDR` / `DATA_DIR` | `:8080` / `/data` | Écoute et volume | +| `MAX_UPLOAD_MB` | `0` | Taille max d'un fichier (0 : illimité) | +| `USER_QUOTA_MB` | `0` | Quota de l'espace personnel (0 : illimité) | +| `COMMON_READONLY` | `false` | Commun en lecture seule pour les non-administrateurs | +| `TRASH_DAYS` | `0` | Purge de la poubelle (0 : jamais) | +| `HISTORY_KEEP` / `HISTORY_INTERVAL` / `HISTORY_MAX_AGE` | `10` / `0` / `0` | Versions gardées par fichier, écart minimal, âge maximal | +| `SESSION_TTL` / `SESSION_SECRET` | `24h` / aléatoire | Session ; clé de signature (sinon `DATA_DIR/.session-secret`) | +| `SHARE_SECRET` | aléatoire | Clé de signature des liens de partage | +| `PUBLIC_URL` | | URL publique (cookies `Secure`) | + +Les valeurs d'inscription, de quota, de lecture seule et de poubelle sont des défauts : une fois modifiées dans l'interface, c'est le réglage de l'interface qui prime. + +## API et jetons + +Chaque utilisateur peut créer des jetons (*Jetons d'API*) pour scripter : + +```bash +curl -T rapport.pdf -H "Authorization: Bearer upd_..." \ + "https://cloud.example.org/api/file?path=.perso/rapport.pdf&conflict=overwrite" +curl -OJ -H "Authorization: Bearer upd_..." "https://cloud.example.org/api/file?path=.perso/rapport.pdf" +``` + +Les routes sont décrites en tête de [`internal/api/api.go`](internal/api/api.go). `.perso/...` est l'espace personnel, `.favoris` les favoris, `.poubelle` la poubelle. + +## Sécurité : ce qui est fait + +- Un fichier déposé ne s'exécute jamais dans l'application : seuls les types sûrs (images, vidéo, audio, PDF, texte) s'affichent en ligne ; HTML, SVG hors ``, scripts et inconnus sont téléchargés (`attachment`), le texte est servi en `text/plain`, et un SVG ouvert directement l'est sous un CSP `sandbox`. +- Chemins normalisés sous la racine, noms cachés (`.trash`, `.accounts.json`...) refusés, liens symboliques ignorés ou refusés. +- Sessions invalidées dès qu'un compte est désactivé ou supprimé ; limitation des tentatives de connexion, d'inscription et de déverrouillage de lien ; en-tête `Origin` contrôlé sur les requêtes modifiantes ; jeton d'un lien absent des journaux. +- Jetons et mots de passe de liens conservés hachés ; liens non énumérables (id 128 bits signé HMAC). +- Suppression d'un compte : son espace personnel est mis de côté (`.users-removed`), jamais hérité par un homonyme. + +À faire par l'exploitant : TLS devant le service (Traefik, Caddy, nginx), purge de `.trash` / `.users-removed`, sauvegarde du volume. + +## Développement + +```bash +go test ./... # backend (sans ouvrir de port) +cd frontend && npm install && npm run build # construit web/dist, embarqué dans le binaire +go run ./cmd/server # http://localhost:8080 (DATA_DIR=./data) +cd frontend && npm run dev # rechargement à chaud, proxy vers :8080 +``` + +## Évolutions possibles + +Envoi par morceaux (reprise après coupure, proxys à limite de corps), liens de dépôt (envoi seul), WebDAV, miniatures vidéo/PDF/WebP, recherche dans les PDF et documents Office, 2FA. + +## Licence + +MIT, voir [`LICENSE`](LICENSE). Une partie du code (authentification OIDC, explorateur, icônes Tabler) est reprise d'Excalicloud, voir [`THIRD_PARTY_NOTICES.md`](THIRD_PARTY_NOTICES.md). diff --git a/THIRD_PARTY_NOTICES.md b/THIRD_PARTY_NOTICES.md new file mode 100644 index 0000000..50b8c30 --- /dev/null +++ b/THIRD_PARTY_NOTICES.md @@ -0,0 +1,7 @@ +# Composants tiers + +- **Excalicloud** (MIT, vLab-BZH) : paquet d'authentification OIDC (`internal/auth`), organisation du stockage (espaces personnels, favoris, corbeille, tags, partage) et composants de l'explorateur. +- **Icônes Tabler** (MIT, Paweł Kuna) : tracés repris dans `frontend/src/icons.tsx` et `folderIcons.tsx`. +- **React** (MIT, Meta), **Vite** (MIT). + +Aucune autre dépendance : le serveur n'utilise que la bibliothèque standard de Go. diff --git a/cmd/server/main.go b/cmd/server/main.go new file mode 100644 index 0000000..fea584d --- /dev/null +++ b/cmd/server/main.go @@ -0,0 +1,454 @@ +// Commande server : API de gestion de fichiers + frontend embarqué. +package main + +import ( + "context" + "errors" + "fmt" + "io/fs" + "log/slog" + "net" + "net/http" + "net/url" + "os" + "os/signal" + "path" + "strconv" + "strings" + "syscall" + "time" + + "github.com/vblogio/upandown/internal/api" + "github.com/vblogio/upandown/internal/auth" + "github.com/vblogio/upandown/internal/storage" + "github.com/vblogio/upandown/internal/tokens" + "github.com/vblogio/upandown/web" +) + +// version est renseignée au build (-ldflags "-X main.version=..."). +var version = "dev" + +func env(key, def string) string { + if v := os.Getenv(key); v != "" { + return v + } + return def +} + +// envBool lit un booléen ; une valeur illisible est une erreur de configuration. +func envBool(key string, def bool) bool { + v := os.Getenv(key) + if v == "" { + return def + } + b, err := strconv.ParseBool(v) + if err != nil { + fatal(key + " invalide (true ou false)") + } + return b +} + +func envInt(key string, def int64) int64 { + v := os.Getenv(key) + if v == "" { + return def + } + n, err := strconv.ParseInt(v, 10, 64) + if err != nil || n < 0 { + fatal(key + " invalide (entier >= 0)") + } + return n +} + +func fatal(msg string, args ...any) { + slog.Error(msg, args...) + os.Exit(1) +} + +// secretEnv lit un secret dans NAME, ou dans le fichier NAME_FILE (secrets Docker). +func secretEnv(name string) string { + if v := os.Getenv(name); v != "" { + return v + } + if f := os.Getenv(name + "_FILE"); f != "" { + b, err := os.ReadFile(f) + if err != nil { + fatal(name+"_FILE illisible", "err", err) + } + return strings.TrimSpace(string(b)) + } + return "" +} + +func main() { + slog.SetDefault(slog.New(slog.NewJSONHandler(os.Stdout, nil))) + + addr := env("LISTEN_ADDR", ":8080") + // `server healthcheck` : sonde pour l'image distroless (pas de curl/wget). + if len(os.Args) > 1 && os.Args[1] == "healthcheck" { + os.Exit(healthcheck(addr)) + } + dataDir := env("DATA_DIR", "./data") + + store, err := storage.New(dataDir) + if err != nil { + fatal("initialisation du stockage", "dir", dataDir, "err", err) + } + if store.History, err = historyPolicy(); err != nil { + fatal("historique", "err", err) + } + store.Defaults = storage.SettingsDefaults{ + Registration: strings.ToLower(env("REGISTRATION", storage.RegClosed)), + QuotaMB: envInt("USER_QUOTA_MB", 0), + CommonReadonly: envBool("COMMON_READONLY", false), + TrashDays: int(envInt("TRASH_DAYS", 0)), + } + if !storage.ValidRegistration(store.Defaults.Registration) { + fatal("REGISTRATION invalide (closed, approval ou open)") + } + // Clé de signature des liens de partage : SHARE_SECRET, sinon DATA_DIR/.share-secret. + if secret := os.Getenv("SHARE_SECRET"); secret != "" { + if len(secret) < 16 { + fatal("SHARE_SECRET trop court (16 caractères minimum)") + } + store.SetShareSecret(secret) + } + + ctx, stop := signal.NotifyContext(context.Background(), os.Interrupt, syscall.SIGTERM) + defer stop() + + spaces := storage.NewSpaces(store) + spaces.MaxUpload = envInt("MAX_UPLOAD_MB", 0) << 20 // 0 : illimité + + mode := strings.ToLower(env("AUTH_MODE", "local")) + handler := (&api.Handler{Store: store, Spaces: spaces, Mode: mode, Version: version}).Init() + mux := http.NewServeMux() + var root http.Handler = mux + tokenStore, err := tokens.Open(dataDir) + if err != nil { + fatal("jetons d'accès", "err", err) + } + ts := &tokens.Server{Store: tokenStore, UserID: api.UserID} + + switch mode { + case "none": + // Aucune authentification intégrée (reverse proxy avec SSO, usage local). + slog.Warn("aucune authentification intégrée (AUTH_MODE=none) : à réserver à un reverse proxy qui authentifie") + ts.Resolve = func(string) (*auth.User, bool) { return nil, true } + case "local", "oidc", "both": + accounts, err := auth.OpenAccounts(dataDir) + if err != nil { + fatal("comptes", "err", err) + } + handler.Accounts = accounts + a, err := authentication(ctx, mode, dataDir, accounts, store, handler) + if err != nil { + fatal("authentification", "err", err) + } + a.Register(mux) + handler.Auth = a + root = a.Middleware(mux, public) + ts.Resolve = func(id string) (*auth.User, bool) { + acc, ok := accounts.Get(id) + if !ok || acc.Status != auth.StatusActive { + return nil, false + } + u := acc.User() + return &u, true + } + handler.OnUserRemoved = tokenStore.RevokeUser + default: + fatal(fmt.Sprintf("AUTH_MODE %q inconnu (local, oidc, both ou none)", mode)) + } + + handler.Register(mux) + ts.Register(mux) + mux.HandleFunc("GET /healthz", func(w http.ResponseWriter, _ *http.Request) { _, _ = w.Write([]byte("ok")) }) + mux.Handle("/", spa()) + + h := logRequests(securityHeaders(sameOrigin(ts.Middleware(root, mux)))) + srv := &http.Server{ + Addr: addr, + Handler: h, + ReadHeaderTimeout: 10 * time.Second, + IdleTimeout: 120 * time.Second, + // Pas de ReadTimeout ni de WriteTimeout : les dépôts et téléchargements de + // gros fichiers peuvent durer longtemps ; seule l'inactivité est bornée. + } + go func() { + slog.Info("démarrage", "addr", addr, "data", dataDir, "auth", mode, "version", version, + "history_keep", store.History.Keep, "max_upload_mb", spaces.MaxUpload>>20) + if err := srv.ListenAndServe(); err != nil && !errors.Is(err, http.ErrServerClosed) { + fatal("serveur", "err", err) + } + }() + <-ctx.Done() + shutdownCtx, cancel := context.WithTimeout(context.Background(), 10*time.Second) + defer cancel() + _ = srv.Shutdown(shutdownCtx) + slog.Info("arrêt") +} + +// authentication prépare l'authentification locale (comptes, inscription) et/ou OIDC. +func authentication(ctx context.Context, mode, dataDir string, accounts *auth.Accounts, store *storage.Store, h *api.Handler) (*auth.Auth, error) { + secret, err := auth.LoadSecret(os.Getenv("SESSION_SECRET"), dataDir) + if err != nil { + return nil, err + } + ttl, err := time.ParseDuration(env("SESSION_TTL", "24h")) + if err != nil || ttl < 5*time.Minute { + return nil, errors.New("SESSION_TTL invalide (ex. 24h, minimum 5m)") + } + pub := publicURL() + secureCookies := strings.HasPrefix(pub, "https://") || strings.HasPrefix(os.Getenv("OIDC_REDIRECT_URL"), "https://") + sessions := auth.NewSessions(secret, ttl, secureCookies) + h.SecureCookies = secureCookies + + a := auth.New(&auth.Auth{ + Accounts: accounts, + Sessions: sessions, + Local: mode == "local" || mode == "both", + Registration: func() string { + if st, err := store.ReadSettings(); err == nil { + return st.Registration + } + return storage.RegClosed + }, + OIDCName: env("OIDC_NAME", "SSO"), + }) + h.OIDCName = a.OIDCName + + if a.Local { + if user := os.Getenv("ADMIN_USER"); user != "" { + pass := secretEnv("ADMIN_PASSWORD") + if pass == "" { + return nil, errors.New("ADMIN_USER défini sans ADMIN_PASSWORD") + } + if err := accounts.EnsureAdmin(user, pass); err != nil { + return nil, fmt.Errorf("administrateur initial : %w", err) + } + } + if accounts.NeedsSetup() { + slog.Warn("aucun administrateur : le premier compte créé (inscription) le deviendra ; définir ADMIN_USER et ADMIN_PASSWORD pour l'imposer") + } + } + if mode == "local" { + return a, nil + } + + // OIDC + cfg, err := oidcConfig(secret, ttl) + if err != nil { + return nil, err + } + cfg.Sessions = sessions + policy := auth.OIDCPolicy{AdminGroups: fields(os.Getenv("OIDC_ADMIN_GROUPS")), AdminEmails: fields(os.Getenv("OIDC_ADMIN_EMAILS"))} + cfg.Provision = func(u auth.User, groups []string) (auth.User, error) { + return accounts.UpsertOIDC(u, groups, policy) + } + o, err := auth.NewOIDC(ctx, cfg) + if err != nil { + return nil, err + } + a.OIDC = o + slog.Info("authentification OIDC activée", "issuer", cfg.Issuer, "client_id", cfg.ClientID, + "groups", cfg.AllowedGroups, "admin_groups", policy.AdminGroups, "session_ttl", ttl.String()) + return a, nil +} + +// publicURL est l'origine publique du service : PUBLIC_URL, sinon celle de +// OIDC_REDIRECT_URL ; vide, elle est déduite de chaque requête. +func publicURL() string { + if v := os.Getenv("PUBLIC_URL"); v != "" { + return strings.TrimRight(v, "/") + } + if u, err := url.Parse(os.Getenv("OIDC_REDIRECT_URL")); err == nil && u.Scheme != "" && u.Host != "" { + return u.Scheme + "://" + u.Host + } + return "" +} + +// oidcConfig lit les variables OIDC_*. +func oidcConfig(secret []byte, ttl time.Duration) (auth.Config, error) { + cfg := auth.Config{ + Issuer: os.Getenv("OIDC_ISSUER"), + ClientID: os.Getenv("OIDC_CLIENT_ID"), + ClientSecret: secretEnv("OIDC_CLIENT_SECRET"), + RedirectURL: os.Getenv("OIDC_REDIRECT_URL"), + Scopes: fields(env("OIDC_SCOPES", "openid profile email")), + GroupsClaim: env("OIDC_GROUPS_CLAIM", "groups"), + SessionTTL: ttl, + Secret: secret, + } + cfg.AllowedGroups = fields(os.Getenv("OIDC_ALLOWED_GROUPS")) + var err error + if cfg.EndSession, err = strconv.ParseBool(env("OIDC_LOGOUT", "true")); err != nil { + return cfg, errors.New("OIDC_LOGOUT invalide (true ou false)") + } + return cfg, nil +} + +// fields découpe une liste séparée par des espaces ou des virgules. +func fields(s string) []string { + return strings.FieldsFunc(s, func(r rune) bool { return r == ' ' || r == ',' }) +} + +func historyPolicy() (storage.HistoryPolicy, error) { + p := storage.DefaultHistory + keep, err := strconv.Atoi(env("HISTORY_KEEP", strconv.Itoa(p.Keep))) + if err != nil || keep < 0 { + return p, errors.New("HISTORY_KEEP invalide (entier >= 0)") + } + p.Keep = keep + if p.Interval, err = time.ParseDuration(env("HISTORY_INTERVAL", "0")); err != nil || p.Interval < 0 { + return p, errors.New("HISTORY_INTERVAL invalide (ex. 10m, 0 : à chaque remplacement)") + } + if p.MaxAge, err = time.ParseDuration(env("HISTORY_MAX_AGE", "0")); err != nil || p.MaxAge < 0 { + return p, errors.New("HISTORY_MAX_AGE invalide (ex. 2160h, 0 : illimité)") + } + return p, nil +} + +func healthcheck(addr string) int { + host, port, err := net.SplitHostPort(addr) + if err != nil { + return 1 + } + if host == "" || host == "0.0.0.0" || host == "::" { + host = "127.0.0.1" + } + c := http.Client{Timeout: 3 * time.Second} + res, err := c.Get("http://" + net.JoinHostPort(host, port) + "/healthz") + if err != nil { + return 1 + } + res.Body.Close() + if res.StatusCode != http.StatusOK { + return 1 + } + return 0 +} + +// spa sert le build Vite embarqué ; toute route inconnue renvoie index.html. +func spa() http.Handler { + dist, _ := fs.Sub(web.Dist, "dist") + files := http.FileServerFS(dist) + return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { + p := path.Clean(r.URL.Path) + if p != "/" { + if fi, err := fs.Stat(dist, p[1:]); err == nil && !fi.IsDir() { + // Les assets Vite sont nommés par empreinte : cache long. + if path.Dir(p) == "/assets" { + w.Header().Set("Cache-Control", "public, max-age=31536000, immutable") + } + files.ServeHTTP(w, r) + return + } + } + index, err := fs.ReadFile(dist, "index.html") + if err != nil { + http.Error(w, "frontend absent : lancer `npm run build` dans frontend/", http.StatusNotFound) + return + } + w.Header().Set("Content-Type", "text/html; charset=utf-8") + w.Header().Set("Cache-Control", "no-cache") + _, _ = w.Write(index) + }) +} + +// public indique les chemins servis sans session : sonde, liens de partage +// (/s/ et son API), état de la connexion (/api/me, logo : page de +// connexion) et fichiers statiques du build (code de l'application, sans +// aucune donnée). +func public(p string) bool { + switch { + case p == "/healthz", strings.HasPrefix(p, "/s/"), strings.HasPrefix(p, "/api/public/"), p == "/api/me", p == "/api/logo": + return true + case strings.HasPrefix(p, "/api/"), p == "/", p == "/index.html": + return false + } + dist, _ := fs.Sub(web.Dist, "dist") + fi, err := fs.Stat(dist, strings.TrimPrefix(path.Clean(p), "/")) + return err == nil && !fi.IsDir() +} + +// sameOrigin refuse les requêtes qui modifient des données et viennent d'un +// autre site (CSRF) : l'en-tête Origin d'une requête de navigateur doit +// désigner l'hôte du service. Les requêtes sans Origin (curl, jetons d'API) +// ne sont pas concernées. +func sameOrigin(next http.Handler) http.Handler { + return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { + switch r.Method { + case http.MethodGet, http.MethodHead, http.MethodOptions: + default: + if r.Header.Get("Sec-Fetch-Site") == "cross-site" { + http.Error(w, "origine refusée", http.StatusForbidden) + return + } + if o := r.Header.Get("Origin"); o != "" && o != "null" { + host := r.Host + if h := r.Header.Get("X-Forwarded-Host"); h != "" { + host, _, _ = strings.Cut(h, ",") + host = strings.TrimSpace(host) + } + if u, err := url.Parse(o); err != nil || !strings.EqualFold(u.Host, host) { + http.Error(w, "origine refusée", http.StatusForbidden) + return + } + } + } + next.ServeHTTP(w, r) + }) +} + +func securityHeaders(next http.Handler) http.Handler { + return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { + h := w.Header() + h.Set("X-Content-Type-Options", "nosniff") + h.Set("Referrer-Policy", "same-origin") + h.Set("X-Frame-Options", "SAMEORIGIN") + if strings.HasPrefix(r.URL.Path, "/s/") || strings.HasPrefix(r.URL.Path, "/api/public/") { + h.Set("X-Robots-Tag", "noindex, nofollow") // liens de partage + } + next.ServeHTTP(w, r) + }) +} + +type statusWriter struct { + http.ResponseWriter + status int +} + +func (s *statusWriter) WriteHeader(code int) { + s.status = code + s.ResponseWriter.WriteHeader(code) +} + +// Unwrap permet à http.ResponseController (Flush, SetWriteDeadline) d'atteindre +// l'écrivain d'origine. +func (s *statusWriter) Unwrap() http.ResponseWriter { return s.ResponseWriter } + +func (s *statusWriter) Flush() { + if f, ok := s.ResponseWriter.(http.Flusher); ok { + f.Flush() + } +} + +func logRequests(next http.Handler) http.Handler { + return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { + start := time.Now() + sw := &statusWriter{ResponseWriter: w, status: http.StatusOK} + next.ServeHTTP(sw, r) + if r.URL.Path != "/healthz" { + // Le jeton d'un lien de partage fait partie du chemin : il n'est pas journalisé. + p := r.URL.Path + if strings.HasPrefix(p, "/s/") { + p = "/s/…" + } else if strings.HasPrefix(p, "/api/public/") { + p = "/api/public/…" + } + slog.Info("http", "method", r.Method, "path", p, "status", sw.status, + "dur_ms", time.Since(start).Milliseconds()) + } + }) +} diff --git a/cmd/server/main_test.go b/cmd/server/main_test.go new file mode 100644 index 0000000..0267c9b --- /dev/null +++ b/cmd/server/main_test.go @@ -0,0 +1,86 @@ +package main + +import ( + "bytes" + "log/slog" + "net/http" + "net/http/httptest" + "strings" + "testing" +) + +func TestSameOrigin(t *testing.T) { + h := sameOrigin(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { w.WriteHeader(204) })) + do := func(method, host string, hdr map[string]string) int { + r := httptest.NewRequest(method, "http://"+host+"/api/file", nil) + for k, v := range hdr { + r.Header.Set(k, v) + } + w := httptest.NewRecorder() + h.ServeHTTP(w, r) + return w.Code + } + cases := []struct { + name string + method string + hdr map[string]string + want int + }{ + {"GET entre sites", "GET", map[string]string{"Origin": "https://evil.example"}, 204}, + {"PUT sans Origin (curl, jeton)", "PUT", nil, 204}, + {"PUT même origine", "PUT", map[string]string{"Origin": "https://cloud.example"}, 204}, + {"PUT autre origine", "PUT", map[string]string{"Origin": "https://evil.example"}, 403}, + {"POST cross-site", "POST", map[string]string{"Sec-Fetch-Site": "cross-site"}, 403}, + {"POST same-origin", "POST", map[string]string{"Sec-Fetch-Site": "same-origin", "Origin": "https://cloud.example"}, 204}, + {"DELETE autre origine", "DELETE", map[string]string{"Origin": "http://cloud.example.evil.org"}, 403}, + {"proxy : X-Forwarded-Host", "PUT", map[string]string{"Origin": "https://cloud.example", "X-Forwarded-Host": "cloud.example"}, 204}, + } + for _, c := range cases { + host := "cloud.example" + if c.name == "proxy : X-Forwarded-Host" { + host = "upandown:8080" + } + if got := do(c.method, host, c.hdr); got != c.want { + t.Errorf("%s : %d, attendu %d", c.name, got, c.want) + } + } +} + +func TestPublicPaths(t *testing.T) { + for p, want := range map[string]bool{ + "/healthz": true, "/s/abc": true, "/api/public/abc/file": true, "/api/me": true, "/api/logo": true, + "/api/list": false, "/api/file": false, "/api/admin/users": false, "/api/tokens": false, + "/": false, "/index.html": false, + } { + if got := public(p); got != want { + t.Errorf("public(%q) = %v", p, got) + } + } +} + +func TestSpaFallbackWithoutBuild(t *testing.T) { + w := httptest.NewRecorder() + spa().ServeHTTP(w, httptest.NewRequest("GET", "/dossier/x", nil)) + if w.Code != 404 { // web/dist ne contient que .gitkeep tant que le frontend n'est pas construit + t.Logf("spa sans build : %d (frontend construit ?)", w.Code) + } +} + +func TestLogRequestsHidesShareTokens(t *testing.T) { + // Le jeton d'un lien fait partie du chemin : il ne doit pas finir dans les journaux. + var buf bytes.Buffer + old := slog.Default() + slog.SetDefault(slog.New(slog.NewTextHandler(&buf, nil))) + defer slog.SetDefault(old) + h := logRequests(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { w.WriteHeader(204) })) + for _, p := range []string{"/s/jeton-secret", "/api/public/jeton-secret/file", "/api/list"} { + h.ServeHTTP(httptest.NewRecorder(), httptest.NewRequest("GET", p, nil)) + } + out := buf.String() + if strings.Contains(out, "jeton-secret") { + t.Errorf("jeton journalisé : %s", out) + } + if !strings.Contains(out, "/api/list") { + t.Errorf("requête ordinaire non journalisée : %s", out) + } +} diff --git a/docker-compose.yml b/docker-compose.yml new file mode 100644 index 0000000..4c6803e --- /dev/null +++ b/docker-compose.yml @@ -0,0 +1,49 @@ +# Up And Down +services: + upandown: + build: . + image: upandown:local + restart: unless-stopped + ports: + - "${UPANDOWN_PORT:-8080}:8080" + environment: + # Authentification : local (comptes + inscription), oidc, both ou none (reverse proxy qui authentifie). + AUTH_MODE: ${AUTH_MODE:-local} + # Administrateur initial (mode local ou both). Sans eux, le premier compte créé le devient. + ADMIN_USER: ${ADMIN_USER:-} + ADMIN_PASSWORD: ${ADMIN_PASSWORD:-} + # Inscription des comptes locaux : closed, approval (validation par un administrateur) ou open. + # Modifiable ensuite dans l'interface (Administration > Général). + REGISTRATION: ${REGISTRATION:-closed} + # OIDC (AUTH_MODE=oidc ou both). URI de redirection chez le fournisseur : https:///auth/callback + OIDC_ISSUER: ${OIDC_ISSUER:-} + OIDC_CLIENT_ID: ${OIDC_CLIENT_ID:-} + OIDC_CLIENT_SECRET: ${OIDC_CLIENT_SECRET:-} + OIDC_REDIRECT_URL: ${OIDC_REDIRECT_URL:-} + OIDC_SCOPES: ${OIDC_SCOPES:-openid profile email} + OIDC_NAME: ${OIDC_NAME:-SSO} + OIDC_ALLOWED_GROUPS: ${OIDC_ALLOWED_GROUPS:-} + OIDC_GROUPS_CLAIM: ${OIDC_GROUPS_CLAIM:-groups} + OIDC_ADMIN_GROUPS: ${OIDC_ADMIN_GROUPS:-} + OIDC_ADMIN_EMAILS: ${OIDC_ADMIN_EMAILS:-} + OIDC_LOGOUT: ${OIDC_LOGOUT:-true} + SESSION_TTL: ${SESSION_TTL:-24h} + SESSION_SECRET: ${SESSION_SECRET:-} + PUBLIC_URL: ${PUBLIC_URL:-} + # Dépôts : taille maximale d'un fichier (Mo, 0 : illimité) ; quota par utilisateur (Mo, 0 : illimité). + MAX_UPLOAD_MB: ${MAX_UPLOAD_MB:-0} + USER_QUOTA_MB: ${USER_QUOTA_MB:-0} + COMMON_READONLY: ${COMMON_READONLY:-false} + TRASH_DAYS: ${TRASH_DAYS:-0} + # Historique des versions (remplacements) : versions gardées par fichier (0 : désactivé). + HISTORY_KEEP: ${HISTORY_KEEP:-10} + HISTORY_INTERVAL: ${HISTORY_INTERVAL:-0} + HISTORY_MAX_AGE: ${HISTORY_MAX_AGE:-0} + SHARE_SECRET: ${SHARE_SECRET:-} + volumes: + # Bind mount : chown -R 65532:65532 ./data + - ./data:/data + read_only: true + cap_drop: [ALL] + security_opt: + - no-new-privileges:true diff --git a/frontend/.gitignore b/frontend/.gitignore new file mode 100644 index 0000000..c2658d7 --- /dev/null +++ b/frontend/.gitignore @@ -0,0 +1 @@ +node_modules/ diff --git a/frontend/index.html b/frontend/index.html new file mode 100644 index 0000000..b47f59d --- /dev/null +++ b/frontend/index.html @@ -0,0 +1,23 @@ + + + + + + + + + Up And Down + + + +
+ + + diff --git a/frontend/package-lock.json b/frontend/package-lock.json new file mode 100644 index 0000000..b7cb176 --- /dev/null +++ b/frontend/package-lock.json @@ -0,0 +1,1877 @@ +{ + "name": "upandown-frontend", + "version": "0.1.0", + "lockfileVersion": 3, + "requires": true, + "packages": { + "": { + "name": "upandown-frontend", + "version": "0.1.0", + "dependencies": { + "react": "^19.1.0", + "react-dom": "^19.1.0" + }, + "devDependencies": { + "@types/react": "^19.1.0", + "@types/react-dom": "^19.1.0", + "@vitejs/plugin-react": "^5.0.0", + "typescript": "^5.8.0", + "vite": "^7.0.0" + } + }, + "node_modules/@babel/code-frame": { + "version": "7.29.7", + "resolved": "https://registry.npmjs.org/@babel/code-frame/-/code-frame-7.29.7.tgz", + "integrity": "sha512-Aup7aUOfpbAUg2ROOJN6Iw5f9DMBlzu0mIkm/malLQFN/YQgO48wCj0Kxa3sEHJvPVFg7siR+qRInwXd2qhQKw==", + "dev": true, + "license": "MIT", + "dependencies": { + "@babel/helper-validator-identifier": "^7.29.7", + "js-tokens": "^4.0.0", + "picocolors": "^1.1.1" + }, + "engines": { + "node": ">=6.9.0" + } + }, + "node_modules/@babel/compat-data": { + "version": "7.29.7", + "resolved": "https://registry.npmjs.org/@babel/compat-data/-/compat-data-7.29.7.tgz", + "integrity": "sha512-locTkQyKvwIEgBzVrn8693ebc97F2U8ZHjbXwDXJ5Fn2TCpNwTlKcaKLkdHop5c/icOFE7qt7Q9JC5hnKNa6Gg==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=6.9.0" + } + }, + "node_modules/@babel/core": { + "version": "7.29.13", + "resolved": "https://registry.npmjs.org/@babel/core/-/core-7.29.13.tgz", + "integrity": "sha512-j1nvOQCZYSgp7HLmisnCXFTpVvFODiijQ9QHkORfGKWH6YDtskTEeCJS7eV545GZ9UBzrq0e2xsOd5QQ5PjIqw==", + "dev": true, + "license": "MIT", + "dependencies": { + "@babel/code-frame": "^7.29.7", + "@babel/generator": "^7.29.13", + "@babel/helper-compilation-targets": "^7.29.13", + "@babel/helper-module-transforms": "^7.29.13", + "@babel/helpers": "^7.29.13", + "@babel/parser": "^7.29.13", + "@babel/template": "^7.29.7", + "@babel/traverse": "^7.29.13", + "@babel/types": "^7.29.11", + "@jridgewell/remapping": "^2.3.5", + "convert-source-map": "^2.0.0", + "debug": "^4.1.0", + "gensync": "^1.0.0-beta.2", + "json5": "^2.2.3", + "semver": "^6.3.1" + }, + "engines": { + "node": ">=6.9.0" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/babel" + } + }, + "node_modules/@babel/generator": { + "version": "7.29.14", + "resolved": "https://registry.npmjs.org/@babel/generator/-/generator-7.29.14.tgz", + "integrity": "sha512-qSY56jgW5JnSXzuekLVil6zaOQxOCtOHidr65KkaMBw772IuAY28Qx4ZykAcDn8+FRF15qk80XzKwgSc/RYW6g==", + "dev": true, + "license": "MIT", + "dependencies": { + "@babel/parser": "^7.29.14", + "@babel/types": "^7.29.14", + "@jridgewell/gen-mapping": "^0.3.12", + "@jridgewell/trace-mapping": "^0.3.28", + "jsesc": "^3.0.2" + }, + "engines": { + "node": ">=6.9.0" + } + }, + "node_modules/@babel/helper-compilation-targets": { + "version": "7.29.13", + "resolved": "https://registry.npmjs.org/@babel/helper-compilation-targets/-/helper-compilation-targets-7.29.13.tgz", + "integrity": "sha512-8WxJ4/Vmes3ghacj8VOJy3NW8eyHiFY/4thU/LSBuBE470+igjR/j1ZTNn8fV5VdNrLx6iXUwig526UdOvfP0w==", + "dev": true, + "license": "MIT", + "dependencies": { + "@babel/compat-data": "^7.29.7", + "@babel/helper-validator-option": "^7.29.7", + "browserslist": "^4.24.0", + "lru-cache": "^5.1.1", + "semver": "^6.3.1" + }, + "engines": { + "node": ">=6.9.0" + } + }, + "node_modules/@babel/helper-globals": { + "version": "7.29.7", + "resolved": "https://registry.npmjs.org/@babel/helper-globals/-/helper-globals-7.29.7.tgz", + "integrity": "sha512-3nQVUAtvkKH9zahfWgw96Jc/uFOmjACE1kQz82E2lqWmHBgjzbNlsC22nuQTfahmWeQtTq5nQ/4Nnd2A1wj4zA==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=6.9.0" + } + }, + "node_modules/@babel/helper-module-imports": { + "version": "7.29.7", + "resolved": "https://registry.npmjs.org/@babel/helper-module-imports/-/helper-module-imports-7.29.7.tgz", + "integrity": "sha512-ejHwrQQYcm9xnTivShn2IDOlIzInN34AXskvq9QicvCtEzq1Vzclu/tKF8Jq1Cg8JG2GL6/EmjgsCT7lXepE3g==", + "dev": true, + "license": "MIT", + "dependencies": { + "@babel/traverse": "^7.29.7", + "@babel/types": "^7.29.7" + }, + "engines": { + "node": ">=6.9.0" + } + }, + "node_modules/@babel/helper-module-transforms": { + "version": "7.29.14", + "resolved": "https://registry.npmjs.org/@babel/helper-module-transforms/-/helper-module-transforms-7.29.14.tgz", + "integrity": "sha512-2XDvQVd9JESaOgGc4jT2/jquTAO7ppA5noTZQqH+MmZ89yjCzScLwtCPbWtkPZylL+TLWR49IwWmk+QkRR4GsA==", + "dev": true, + "license": "MIT", + "dependencies": { + "@babel/helper-module-imports": "^7.29.7", + "@babel/helper-validator-identifier": "^7.29.7", + "@babel/traverse": "^7.29.14" + }, + "engines": { + "node": ">=6.9.0" + }, + "peerDependencies": { + "@babel/core": "^7.0.0" + } + }, + "node_modules/@babel/helper-plugin-utils": { + "version": "7.29.7", + "resolved": "https://registry.npmjs.org/@babel/helper-plugin-utils/-/helper-plugin-utils-7.29.7.tgz", + "integrity": "sha512-G7sHYigPY17oO5SYWnfD/0MTBwVR781S/JI643e/JhUYgVgWE/61SoW3NH9KWUKyKq5LVh3npif99Wkt6j86Jw==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=6.9.0" + } + }, + "node_modules/@babel/helper-string-parser": { + "version": "7.29.14", + "resolved": "https://registry.npmjs.org/@babel/helper-string-parser/-/helper-string-parser-7.29.14.tgz", + "integrity": "sha512-CXvKMFvM80ihI7Vox9jb+kQjnyjESQNPM+vB7U0Zz6TWuZA+Z/FL0QPMH300h33qJtIx+REeBhXqWOPW48TcAQ==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=6.9.0" + } + }, + "node_modules/@babel/helper-validator-identifier": { + "version": "7.29.7", + "resolved": "https://registry.npmjs.org/@babel/helper-validator-identifier/-/helper-validator-identifier-7.29.7.tgz", + "integrity": "sha512-qehxGkRj55h/ff8EMaJ+cYhyaKlHIxqYDn682wQD7RNp9UujOQsHog2uS0r2vzr4pW+sXf90NeeayjcNaX3fFg==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=6.9.0" + } + }, + "node_modules/@babel/helper-validator-option": { + "version": "7.29.7", + "resolved": "https://registry.npmjs.org/@babel/helper-validator-option/-/helper-validator-option-7.29.7.tgz", + "integrity": "sha512-N9ZErrD+yW5geCDtBqnOoxmR8+tNKiGuxKlDpuJxfsqpa2dFcexaziGAE/qoHLiDDreVNMupxGmSoNlyvsA3gw==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=6.9.0" + } + }, + "node_modules/@babel/helpers": { + "version": "7.29.14", + "resolved": "https://registry.npmjs.org/@babel/helpers/-/helpers-7.29.14.tgz", + "integrity": "sha512-6E3Mi1r0B0umq6vmZa4/78q+64fqO2YY0THUdjDPKUCKhNb0yQy5NQIaPHCSD3ryTgiTss//P4JsWS80AsZ6LQ==", + "dev": true, + "license": "MIT", + "dependencies": { + "@babel/template": "^7.29.7", + "@babel/types": "^7.29.14" + }, + "engines": { + "node": ">=6.9.0" + } + }, + "node_modules/@babel/parser": { + "version": "7.29.14", + "resolved": "https://registry.npmjs.org/@babel/parser/-/parser-7.29.14.tgz", + "integrity": "sha512-VL220vXuyO2z3rNIQwY7ftj9UwpqOt+33sH+sBWkOekbsSR2g7EEMnOx24ZlCH0xOA3DM/33SifVFGbnJD8r/w==", + "dev": true, + "license": "MIT", + "dependencies": { + "@babel/types": "^7.29.14" + }, + "bin": { + "parser": "bin/babel-parser.js" + }, + "engines": { + "node": ">=6.0.0" + } + }, + "node_modules/@babel/plugin-transform-react-jsx-self": { + "version": "7.29.7", + "resolved": "https://registry.npmjs.org/@babel/plugin-transform-react-jsx-self/-/plugin-transform-react-jsx-self-7.29.7.tgz", + "integrity": "sha512-TL0hMc9xzy86VD31nUiwzd5otRAcyEPcsegCxolO0PvcXuH1v0kECe/UIznYFihpkvU5wg/jk4v0TTEFfm53fw==", + "dev": true, + "license": "MIT", + "dependencies": { + "@babel/helper-plugin-utils": "^7.29.7" + }, + "engines": { + "node": ">=6.9.0" + }, + "peerDependencies": { + "@babel/core": "^7.0.0-0" + } + }, + "node_modules/@babel/plugin-transform-react-jsx-source": { + "version": "7.29.7", + "resolved": "https://registry.npmjs.org/@babel/plugin-transform-react-jsx-source/-/plugin-transform-react-jsx-source-7.29.7.tgz", + "integrity": "sha512-06IyK09H3wi4cGbhDBwp5gUGo0IKtnYa8tyTiephirPCK6fbobVGiXMMI5zLQ4aKEYP3wZ3ArU44o+8KMrSG/Q==", + "dev": true, + "license": "MIT", + "dependencies": { + "@babel/helper-plugin-utils": "^7.29.7" + }, + "engines": { + "node": ">=6.9.0" + }, + "peerDependencies": { + "@babel/core": "^7.0.0-0" + } + }, + "node_modules/@babel/template": { + "version": "7.29.7", + "resolved": "https://registry.npmjs.org/@babel/template/-/template-7.29.7.tgz", + "integrity": "sha512-puq+Gf35oI24FeN11LkoUQFqv9uwNeWpxXZi/Ji3rRIoKAzKnxRaZ+Gkj0vKS9ZCiTESfng1N9LyOyXvo+m+Gg==", + "dev": true, + "license": "MIT", + "dependencies": { + "@babel/code-frame": "^7.29.7", + "@babel/parser": "^7.29.7", + "@babel/types": "^7.29.7" + }, + "engines": { + "node": ">=6.9.0" + } + }, + "node_modules/@babel/traverse": { + "version": "7.29.14", + "resolved": "https://registry.npmjs.org/@babel/traverse/-/traverse-7.29.14.tgz", + "integrity": "sha512-RAdQJrBgmIH1FWvN0X+1hoDxzMzlP4cv/1Zi4dn4tG1H0cTb+rw7CzUxQJhp1f4ANd8j5vH3fy8BAWFGkBDEsA==", + "dev": true, + "license": "MIT", + "dependencies": { + "@babel/code-frame": "^7.29.7", + "@babel/generator": "^7.29.14", + "@babel/helper-globals": "^7.29.7", + "@babel/parser": "^7.29.14", + "@babel/template": "^7.29.7", + "@babel/types": "^7.29.14", + "debug": "^4.3.1" + }, + "engines": { + "node": ">=6.9.0" + } + }, + "node_modules/@babel/types": { + "version": "7.29.14", + "resolved": "https://registry.npmjs.org/@babel/types/-/types-7.29.14.tgz", + "integrity": "sha512-UjI/dKmwJwT9pOszJitq2G6EObZPnsZUfdCr92z2TlF3EZK9J3EdfOKUrCzHl6wFthbzwhzl1Soc/UIwxRiq6w==", + "dev": true, + "license": "MIT", + "dependencies": { + "@babel/helper-string-parser": "^7.29.14", + "@babel/helper-validator-identifier": "^7.29.7" + }, + "engines": { + "node": ">=6.9.0" + } + }, + "node_modules/@esbuild/aix-ppc64": { + "version": "0.28.2", + "resolved": "https://registry.npmjs.org/@esbuild/aix-ppc64/-/aix-ppc64-0.28.2.tgz", + "integrity": "sha512-XExcO+dvLKvVtNTibSTBej1NCAbaGhWn9Ww1ZPx80qsahhPFe/8jgWP0IchNe0F3HwkU7n8ejhH8bjonqht8mQ==", + "cpu": [ + "ppc64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "aix" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/@esbuild/android-arm": { + "version": "0.28.2", + "resolved": "https://registry.npmjs.org/@esbuild/android-arm/-/android-arm-0.28.2.tgz", + "integrity": "sha512-kXXoiPVVGQcnIYGOeaovwOURpniDBpSq4A03qkQ+BMQqtGG6HYap3xne9C1O1yo4TR3qxlCX5IqqmX6fFo2Lqg==", + "cpu": [ + "arm" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "android" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/@esbuild/android-arm64": { + "version": "0.28.2", + "resolved": "https://registry.npmjs.org/@esbuild/android-arm64/-/android-arm64-0.28.2.tgz", + "integrity": "sha512-5YfKeeI8qWfBZIX+u2xZC3Zlb3Os/gLS2sbEKM+I4ZOcsWmHS2WLysCcQZDAFRslDUU5Oiq44gf6PYN1vGwG5A==", + "cpu": [ + "arm64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "android" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/@esbuild/android-x64": { + "version": "0.28.2", + "resolved": "https://registry.npmjs.org/@esbuild/android-x64/-/android-x64-0.28.2.tgz", + "integrity": "sha512-O387ite7SzUyCcy3JQX4P4bLtEA7bLLkx+esve5JHnyYfNTxcVpXZo9jhdB0lTKN44gztELTdU7nS8Nr16Fs1Q==", + "cpu": [ + "x64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "android" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/@esbuild/darwin-arm64": { + "version": "0.28.2", + "resolved": "https://registry.npmjs.org/@esbuild/darwin-arm64/-/darwin-arm64-0.28.2.tgz", + "integrity": "sha512-n4KqkOQrraxHJcgjM1RvwbigfQKIKJVpM7xp+KsxiyUSrRdIXnt73VhrPAx0fV44hgfmIVKjxMN9J1t5jySVkw==", + "cpu": [ + "arm64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "darwin" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/@esbuild/darwin-x64": { + "version": "0.28.2", + "resolved": "https://registry.npmjs.org/@esbuild/darwin-x64/-/darwin-x64-0.28.2.tgz", + "integrity": "sha512-uq6suIWYP37qzGddBKPw5QEQPi6HiLGsO7UmkpfyaYNQ3D+rN6w6WfwH+nuqcGXWvawGwxOEroO4YGnFh95azw==", + "cpu": [ + "x64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "darwin" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/@esbuild/freebsd-arm64": { + "version": "0.28.2", + "resolved": "https://registry.npmjs.org/@esbuild/freebsd-arm64/-/freebsd-arm64-0.28.2.tgz", + "integrity": "sha512-n+I0BTSRIoy+d6RPKnEVwql5UwBJolytvY4mAOIEJorKlqgPII8ix6slVVrfZ5Tnj7glIZvloylbB/EJPMWEXw==", + "cpu": [ + "arm64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "freebsd" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/@esbuild/freebsd-x64": { + "version": "0.28.2", + "resolved": "https://registry.npmjs.org/@esbuild/freebsd-x64/-/freebsd-x64-0.28.2.tgz", + "integrity": "sha512-78XJTJkvPs0kz2w61301PJjXl4g7q3JqiYMZ/M/yVI73EHBrCRTgkhu9oqG7vPqq+a/yadEW8aD+agKlk5xrmg==", + "cpu": [ + "x64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "freebsd" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/@esbuild/linux-arm": { + "version": "0.28.2", + "resolved": "https://registry.npmjs.org/@esbuild/linux-arm/-/linux-arm-0.28.2.tgz", + "integrity": "sha512-XlDnu2q5yoqems+xay6wSAcg9DDD7K9RLKZEBOMZm3ckNpJBvOX20tSfby8KfrrhINDyv9V2YVZKY/SpoGJI8w==", + "cpu": [ + "arm" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/@esbuild/linux-arm64": { + "version": "0.28.2", + "resolved": "https://registry.npmjs.org/@esbuild/linux-arm64/-/linux-arm64-0.28.2.tgz", + "integrity": "sha512-pW4AC0P3it8c7do9MVM4p51FzHzdM/TZrerurgRcHJ2WTa1VQ1CIq18xncfpBJw4ojkiZZrKW2yIBWBP92j6Ug==", + "cpu": [ + "arm64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/@esbuild/linux-ia32": { + "version": "0.28.2", + "resolved": "https://registry.npmjs.org/@esbuild/linux-ia32/-/linux-ia32-0.28.2.tgz", + "integrity": "sha512-CYbnj78HsIeA+DhgUKgFCfvNsTHFhMMrinUrMZpDXJXKN8T3XViTZ/+wtHeVxEWY8ewSzTFN+nRmSwO2tZaLUQ==", + "cpu": [ + "ia32" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/@esbuild/linux-loong64": { + "version": "0.28.2", + "resolved": "https://registry.npmjs.org/@esbuild/linux-loong64/-/linux-loong64-0.28.2.tgz", + "integrity": "sha512-buwkd8nsph4R+ajRvw0qM5Hja/TXQow3ptzWO2EbG/cqcIkHloRrdlBtQlshyYGTNFvfkfJ5tpPLVkY4DtsPfQ==", + "cpu": [ + "loong64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/@esbuild/linux-mips64el": { + "version": "0.28.2", + "resolved": "https://registry.npmjs.org/@esbuild/linux-mips64el/-/linux-mips64el-0.28.2.tgz", + "integrity": "sha512-ZVykbDyk7519VwiNb9Lcj9m8XM6v5V9uKPvrEMkkEedVewf+0itkhahp4HDpgERXhwLRpWFypsGbG/J8s0QjJA==", + "cpu": [ + "mips64el" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/@esbuild/linux-ppc64": { + "version": "0.28.2", + "resolved": "https://registry.npmjs.org/@esbuild/linux-ppc64/-/linux-ppc64-0.28.2.tgz", + "integrity": "sha512-CAXl+Dtd9UUuJd8pKKdwh6MLm3MUMiqMPmhZ3tTSXPqfyQ3vDl6R5hZdZ/kYojK4ofXtdfSv1tFq8XzWx3heNQ==", + "cpu": [ + "ppc64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/@esbuild/linux-riscv64": { + "version": "0.28.2", + "resolved": "https://registry.npmjs.org/@esbuild/linux-riscv64/-/linux-riscv64-0.28.2.tgz", + "integrity": "sha512-GeXCej4IQtU1B+QlDV8W/RRvbzI3O/Stss+/bCXv4lZls5WGRtu2a+3JkA3i4qIUlMXpcHebWpF8AkJhATowuA==", + "cpu": [ + "riscv64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/@esbuild/linux-s390x": { + "version": "0.28.2", + "resolved": "https://registry.npmjs.org/@esbuild/linux-s390x/-/linux-s390x-0.28.2.tgz", + "integrity": "sha512-3H1weTYZPxt/WOhByszQZybS9w5lKzUn1FDMsgEChbHWQwHYQQRfBxgCcZvPhjHfKyJjIievvMmEUawJrdY9Dg==", + "cpu": [ + "s390x" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/@esbuild/linux-x64": { + "version": "0.28.2", + "resolved": "https://registry.npmjs.org/@esbuild/linux-x64/-/linux-x64-0.28.2.tgz", + "integrity": "sha512-4xTZr1FUmSoQW4XIWmit3tzQrUTZM+N3P0XV8xROKYF50XfI7xeO90+1bZvNwxIufQ9hDQVRJH5YhgPVF8A/HQ==", + "cpu": [ + "x64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/@esbuild/netbsd-arm64": { + "version": "0.28.2", + "resolved": "https://registry.npmjs.org/@esbuild/netbsd-arm64/-/netbsd-arm64-0.28.2.tgz", + "integrity": "sha512-sSATRjPeDBg3pdgHoQfoYBob11Kk1FGa9lui5RIHZCoCkJa9QKlvl3/vKz2usCmYYjs7ymJR/2Nnsqe+Hjt5nw==", + "cpu": [ + "arm64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "netbsd" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/@esbuild/netbsd-x64": { + "version": "0.28.2", + "resolved": "https://registry.npmjs.org/@esbuild/netbsd-x64/-/netbsd-x64-0.28.2.tgz", + "integrity": "sha512-lqnzCV+mM0gIADaKihiCg6ifgfU2L3h5E33rNQBN1Y4MaVGnzryzmvvf7UHxprpQdE8hpqLolJ9Rl+SkIRDpyw==", + "cpu": [ + "x64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "netbsd" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/@esbuild/openbsd-arm64": { + "version": "0.28.2", + "resolved": "https://registry.npmjs.org/@esbuild/openbsd-arm64/-/openbsd-arm64-0.28.2.tgz", + "integrity": "sha512-AL2qJILH7lNjrDmCQDvdxMfAUIv8KMNZOvrwAQ8i8//ntL9FflhOyMJ8OZSMBb8/AWXe3/5v5S20y3zCoZWKoQ==", + "cpu": [ + "arm64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "openbsd" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/@esbuild/openbsd-x64": { + "version": "0.28.2", + "resolved": "https://registry.npmjs.org/@esbuild/openbsd-x64/-/openbsd-x64-0.28.2.tgz", + "integrity": "sha512-QtiuPytchRyC4rwUKhexJdQKvDuZ6hWloi3igqPQNUJCS1/v9EiO3UTOXR6A3FoMo4fnAKbWJdqaIwhOzh8qEw==", + "cpu": [ + "x64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "openbsd" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/@esbuild/openharmony-arm64": { + "version": "0.28.2", + "resolved": "https://registry.npmjs.org/@esbuild/openharmony-arm64/-/openharmony-arm64-0.28.2.tgz", + "integrity": "sha512-WkhYDmpTjLvGlScA1rwjRUmhl4k8oXR3cIbtqWmELgU/dFeHHlEllxDvdWcNJV9rbzCexB5vz8gtNewWLgCT7Q==", + "cpu": [ + "arm64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "openharmony" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/@esbuild/sunos-x64": { + "version": "0.28.2", + "resolved": "https://registry.npmjs.org/@esbuild/sunos-x64/-/sunos-x64-0.28.2.tgz", + "integrity": "sha512-GPMSkTOtMnv2U2F8gxe4Io6qmVs+YKyp832Etqqxr0hFngmXQ3rzwytelm3GIn7T4VviRUlf3sOgBOiTdvaf7g==", + "cpu": [ + "x64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "sunos" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/@esbuild/win32-arm64": { + "version": "0.28.2", + "resolved": "https://registry.npmjs.org/@esbuild/win32-arm64/-/win32-arm64-0.28.2.tgz", + "integrity": "sha512-PIhhEkE9uPBleRBrQEJpUn7MBnibZzbGzYWPmY3x+YoVg/95zbjB4CxPPOQ8l5tYYM4mMaCthF8/1DIfBQQyWQ==", + "cpu": [ + "arm64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "win32" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/@esbuild/win32-ia32": { + "version": "0.28.2", + "resolved": "https://registry.npmjs.org/@esbuild/win32-ia32/-/win32-ia32-0.28.2.tgz", + "integrity": "sha512-YmJbfTlvU7Sdn9BB+4PRES4oB6pxgS37MAONj+hBr/cpXS1aBPKXxNnDbu+QCWPj0o9dgyxeq79g6c5P8KeuYA==", + "cpu": [ + "ia32" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "win32" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/@esbuild/win32-x64": { + "version": "0.28.2", + "resolved": "https://registry.npmjs.org/@esbuild/win32-x64/-/win32-x64-0.28.2.tgz", + "integrity": "sha512-5ebpxr3nWMzrL/rnUI755Jkuee0bHL/Gq0WTF9lvcpv73wAp5eu8MfBUgWK9bhWvZjj7yX8etf/8tI8Ney695g==", + "cpu": [ + "x64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "win32" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/@jridgewell/gen-mapping": { + "version": "0.3.13", + "resolved": "https://registry.npmjs.org/@jridgewell/gen-mapping/-/gen-mapping-0.3.13.tgz", + "integrity": "sha512-2kkt/7niJ6MgEPxF0bYdQ6etZaA+fQvDcLKckhy1yIQOzaoKjBBjSj63/aLVjYE3qhRt5dvM+uUyfCg6UKCBbA==", + "dev": true, + "license": "MIT", + "dependencies": { + "@jridgewell/sourcemap-codec": "^1.5.0", + "@jridgewell/trace-mapping": "^0.3.24" + } + }, + "node_modules/@jridgewell/remapping": { + "version": "2.3.5", + "resolved": "https://registry.npmjs.org/@jridgewell/remapping/-/remapping-2.3.5.tgz", + "integrity": "sha512-LI9u/+laYG4Ds1TDKSJW2YPrIlcVYOwi2fUC6xB43lueCjgxV4lffOCZCtYFiH6TNOX+tQKXx97T4IKHbhyHEQ==", + "dev": true, + "license": "MIT", + "dependencies": { + "@jridgewell/gen-mapping": "^0.3.5", + "@jridgewell/trace-mapping": "^0.3.24" + } + }, + "node_modules/@jridgewell/resolve-uri": { + "version": "3.1.3", + "resolved": "https://registry.npmjs.org/@jridgewell/resolve-uri/-/resolve-uri-3.1.3.tgz", + "integrity": "sha512-lhTtjtoEArWBjismtfS761S9Hlyn+nIZqOZVYoZ1Xn82PMNMVnk+jj/NhC4fAXGTs7ydONcJiR5vyQBTMDu27g==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=6.0.0" + } + }, + "node_modules/@jridgewell/sourcemap-codec": { + "version": "1.6.0", + "resolved": "https://registry.npmjs.org/@jridgewell/sourcemap-codec/-/sourcemap-codec-1.6.0.tgz", + "integrity": "sha512-T7jf+5zgsZHwNJ4lvQ7/aezbyk0nNX+zJVWpmHA7VYsEx7a7qr5Rg5IbtJFqkgze5Y2sruq1RUY8Q837Od7iFw==", + "dev": true, + "license": "MIT" + }, + "node_modules/@jridgewell/trace-mapping": { + "version": "0.3.31", + "resolved": "https://registry.npmjs.org/@jridgewell/trace-mapping/-/trace-mapping-0.3.31.tgz", + "integrity": "sha512-zzNR+SdQSDJzc8joaeP8QQoCQr8NuYx2dIIytl1QeBEZHJ9uW6hebsrYgbz8hJwUQao3TWCMtmfV8Nu1twOLAw==", + "dev": true, + "license": "MIT", + "dependencies": { + "@jridgewell/resolve-uri": "^3.1.0", + "@jridgewell/sourcemap-codec": "^1.4.14" + } + }, + "node_modules/@rolldown/pluginutils": { + "version": "1.0.0-rc.3", + "resolved": "https://registry.npmjs.org/@rolldown/pluginutils/-/pluginutils-1.0.0-rc.3.tgz", + "integrity": "sha512-eybk3TjzzzV97Dlj5c+XrBFW57eTNhzod66y9HrBlzJ6NsCrWCp/2kaPS3K9wJmurBC0Tdw4yPjXKZqlznim3Q==", + "dev": true, + "license": "MIT" + }, + "node_modules/@rollup/rollup-android-arm-eabi": { + "version": "4.68.7", + "resolved": "https://registry.npmjs.org/@rollup/rollup-android-arm-eabi/-/rollup-android-arm-eabi-4.68.7.tgz", + "integrity": "sha512-ZL7MgOeMUiBum1bjzzyBotE3DuHVz+UUxcDVlLL7gpdhDM4RpjG4bZOIly7ensIcXw9jhWl7HTIIQ9KsgjykGQ==", + "cpu": [ + "arm" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "android" + ] + }, + "node_modules/@rollup/rollup-android-arm64": { + "version": "4.68.7", + "resolved": "https://registry.npmjs.org/@rollup/rollup-android-arm64/-/rollup-android-arm64-4.68.7.tgz", + "integrity": "sha512-cKZ2Hz/xt5DLY/vdUmMXEn3gnjLgwdeB/npHagbdTljLvBE6b/xKcPCcRWTiT0pHeVf8akl5Cb9K7ylRxbtHng==", + "cpu": [ + "arm64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "android" + ] + }, + "node_modules/@rollup/rollup-android-x64": { + "version": "4.68.7", + "resolved": "https://registry.npmjs.org/@rollup/rollup-android-x64/-/rollup-android-x64-4.68.7.tgz", + "integrity": "sha512-P9vs1uCC2drepKKuiXrhY+r7ry/jtDCrBS8SUCYm2Rr7rVTR9eFH6XVAmD9TdfYFlDgRe5r1eH8tLQVuz+l/VA==", + "cpu": [ + "x64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "android" + ] + }, + "node_modules/@rollup/rollup-darwin-arm64": { + "version": "4.68.7", + "resolved": "https://registry.npmjs.org/@rollup/rollup-darwin-arm64/-/rollup-darwin-arm64-4.68.7.tgz", + "integrity": "sha512-Lgu2AV7jbOTNNhkQ/OurNm7Snqu1Ux/3y7k8q47fbpPa3q63aIzKKp1xFzax5KH4pcdUzbnX/riuFsxKflsF+g==", + "cpu": [ + "arm64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "darwin" + ] + }, + "node_modules/@rollup/rollup-darwin-x64": { + "version": "4.68.7", + "resolved": "https://registry.npmjs.org/@rollup/rollup-darwin-x64/-/rollup-darwin-x64-4.68.7.tgz", + "integrity": "sha512-wKo6rOzla+/3rN8QBqTgcrsQMfyqwa3y14TvCTotLLib/ACWTxX1zWDTYze90s2RWtYiSfTlavHLmZv0Jsafrw==", + "cpu": [ + "x64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "darwin" + ] + }, + "node_modules/@rollup/rollup-freebsd-arm64": { + "version": "4.68.7", + "resolved": "https://registry.npmjs.org/@rollup/rollup-freebsd-arm64/-/rollup-freebsd-arm64-4.68.7.tgz", + "integrity": "sha512-vAeCwbFyEu/vBt9O/uHCHJSvwtOpTSssnM/PoZgn8rmvAkS+9ixaUfJZ2IP3ltom+rvpuQQEIEqltPY7qhC9lQ==", + "cpu": [ + "arm64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "freebsd" + ] + }, + "node_modules/@rollup/rollup-freebsd-x64": { + "version": "4.68.7", + "resolved": "https://registry.npmjs.org/@rollup/rollup-freebsd-x64/-/rollup-freebsd-x64-4.68.7.tgz", + "integrity": "sha512-HvjSxOKI+6Si4ytmaoCEpjwDMrH/1s0uWeTAhdE5oXY8/RMI92hCePI/psZuJtY5EHWoT7MfyvTz0HBDZb1ZwQ==", + "cpu": [ + "x64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "freebsd" + ] + }, + "node_modules/@rollup/rollup-linux-arm-gnueabihf": { + "version": "4.68.7", + "resolved": "https://registry.npmjs.org/@rollup/rollup-linux-arm-gnueabihf/-/rollup-linux-arm-gnueabihf-4.68.7.tgz", + "integrity": "sha512-nz/Eu1sag3w5gPiKLJhAbKa4D9hUUJpDc9XzKXxGNHZqwgT2AbuVS2e4k9CIoLQp5dPhSN9ntiEVuz2jTzu1Gg==", + "cpu": [ + "arm" + ], + "dev": true, + "libc": [ + "glibc" + ], + "license": "MIT", + "optional": true, + "os": [ + "linux" + ] + }, + "node_modules/@rollup/rollup-linux-arm-musleabihf": { + "version": "4.68.7", + "resolved": "https://registry.npmjs.org/@rollup/rollup-linux-arm-musleabihf/-/rollup-linux-arm-musleabihf-4.68.7.tgz", + "integrity": "sha512-05CEv2G/kI261A1WQBZL8gx6xXULjPfVnTKAkfnV/0uqHeLo+dNEOeUzMaiK/HDGR0Z1Nn7KJjm/34bNbNcfTA==", + "cpu": [ + "arm" + ], + "dev": true, + "libc": [ + "musl" + ], + "license": "MIT", + "optional": true, + "os": [ + "linux" + ] + }, + "node_modules/@rollup/rollup-linux-arm64-gnu": { + "version": "4.68.7", + "resolved": "https://registry.npmjs.org/@rollup/rollup-linux-arm64-gnu/-/rollup-linux-arm64-gnu-4.68.7.tgz", + "integrity": "sha512-wrqk3EkxQt98lTdiYhjcaWmFHwvKiSgHFi7XmPTSF4X8+uGUTBOAc0CaynEvpUhBgkPRbwASrYoU/5uJPF+LFA==", + "cpu": [ + "arm64" + ], + "dev": true, + "libc": [ + "glibc" + ], + "license": "MIT", + "optional": true, + "os": [ + "linux" + ] + }, + "node_modules/@rollup/rollup-linux-arm64-musl": { + "version": "4.68.7", + "resolved": "https://registry.npmjs.org/@rollup/rollup-linux-arm64-musl/-/rollup-linux-arm64-musl-4.68.7.tgz", + "integrity": "sha512-DnuEUWvzeSxHxzu5lvrN+I/UzrcQkR/fQ4Bibetdp73Rf7aP0XgFpalSDuHmVWsCLETE+Lrl3GVOqIvFP7rcjw==", + "cpu": [ + "arm64" + ], + "dev": true, + "libc": [ + "musl" + ], + "license": "MIT", + "optional": true, + "os": [ + "linux" + ] + }, + "node_modules/@rollup/rollup-linux-loong64-gnu": { + "version": "4.68.7", + "resolved": "https://registry.npmjs.org/@rollup/rollup-linux-loong64-gnu/-/rollup-linux-loong64-gnu-4.68.7.tgz", + "integrity": "sha512-n0sr2s+rzVw8ntRucOxGhWeJ9lEl9KxCRzF3RmnZLE/tRnfKiloLuK8UqWrKFqVigEAh0IkRkPz5LVaV9/ZfvA==", + "cpu": [ + "loong64" + ], + "dev": true, + "libc": [ + "glibc" + ], + "license": "MIT", + "optional": true, + "os": [ + "linux" + ] + }, + "node_modules/@rollup/rollup-linux-loong64-musl": { + "version": "4.68.7", + "resolved": "https://registry.npmjs.org/@rollup/rollup-linux-loong64-musl/-/rollup-linux-loong64-musl-4.68.7.tgz", + "integrity": "sha512-qDVJyMCbh7ekjt1kM9CZsyCFZvv5UW1QTIx3YfJ/gh8LkqpoPNpl9dCeYeOa+bsDOGTWZiMG2riXuoFSRISimQ==", + "cpu": [ + "loong64" + ], + "dev": true, + "libc": [ + "musl" + ], + "license": "MIT", + "optional": true, + "os": [ + "linux" + ] + }, + "node_modules/@rollup/rollup-linux-ppc64-gnu": { + "version": "4.68.7", + "resolved": "https://registry.npmjs.org/@rollup/rollup-linux-ppc64-gnu/-/rollup-linux-ppc64-gnu-4.68.7.tgz", + "integrity": "sha512-GiIOHHIzgpMoR5DT1pA1b9qMk5i0Ngg2FRj4D6XFSBC8e/axHuIdB7K/OBozO2RtCVAMnH1rXcuJrGScg+bvzA==", + "cpu": [ + "ppc64" + ], + "dev": true, + "libc": [ + "glibc" + ], + "license": "MIT", + "optional": true, + "os": [ + "linux" + ] + }, + "node_modules/@rollup/rollup-linux-ppc64-musl": { + "version": "4.68.7", + "resolved": "https://registry.npmjs.org/@rollup/rollup-linux-ppc64-musl/-/rollup-linux-ppc64-musl-4.68.7.tgz", + "integrity": "sha512-B132V2fwDl7UGLhvK6s3Ay7eNQ4dmDSDgsBm/Wwbz+Wgnunz0le4R2wzDp6TL5ExMu3MC1auJIrVtk2gOyxbyw==", + "cpu": [ + "ppc64" + ], + "dev": true, + "libc": [ + "musl" + ], + "license": "MIT", + "optional": true, + "os": [ + "linux" + ] + }, + "node_modules/@rollup/rollup-linux-riscv64-gnu": { + "version": "4.68.7", + "resolved": "https://registry.npmjs.org/@rollup/rollup-linux-riscv64-gnu/-/rollup-linux-riscv64-gnu-4.68.7.tgz", + "integrity": "sha512-3NueHQilbssjxgJMx9hXBV+U5keb3CBzmW5WhoBG3iSLFcmz9U2FVoG4MUYpZoZ+KSNMQPN2AA79dTxlEF0VxQ==", + "cpu": [ + "riscv64" + ], + "dev": true, + "libc": [ + "glibc" + ], + "license": "MIT", + "optional": true, + "os": [ + "linux" + ] + }, + "node_modules/@rollup/rollup-linux-riscv64-musl": { + "version": "4.68.7", + "resolved": "https://registry.npmjs.org/@rollup/rollup-linux-riscv64-musl/-/rollup-linux-riscv64-musl-4.68.7.tgz", + "integrity": "sha512-8XRwbf76oAF1zZzg6OT8EY3swvCptZnLmiqMgO5+STyhTZ9s7rXa+tY8jESZW9IDyKACcVBGqa/RACDaLzRVjQ==", + "cpu": [ + "riscv64" + ], + "dev": true, + "libc": [ + "musl" + ], + "license": "MIT", + "optional": true, + "os": [ + "linux" + ] + }, + "node_modules/@rollup/rollup-linux-s390x-gnu": { + "version": "4.68.7", + "resolved": "https://registry.npmjs.org/@rollup/rollup-linux-s390x-gnu/-/rollup-linux-s390x-gnu-4.68.7.tgz", + "integrity": "sha512-pvqqfjNdxVLvmovH681K5cPIL9DXj5n1RROaa0vb9JrtHddiScLrkHPRKj5flTKHF1M7xvRy0SS2yTRIc2TO0Q==", + "cpu": [ + "s390x" + ], + "dev": true, + "libc": [ + "glibc" + ], + "license": "MIT", + "optional": true, + "os": [ + "linux" + ] + }, + "node_modules/@rollup/rollup-linux-x64-gnu": { + "version": "4.68.7", + "resolved": "https://registry.npmjs.org/@rollup/rollup-linux-x64-gnu/-/rollup-linux-x64-gnu-4.68.7.tgz", + "integrity": "sha512-rsTjTf5HAm6F4sI6uUfJf2pc+7AWBKxgc2RveGvwB2OvVa1GezSSCDD1rtXPuFhcg3itPv7iHgcZsq/RwWvJ4Q==", + "cpu": [ + "x64" + ], + "dev": true, + "libc": [ + "glibc" + ], + "license": "MIT", + "optional": true, + "os": [ + "linux" + ] + }, + "node_modules/@rollup/rollup-linux-x64-musl": { + "version": "4.68.7", + "resolved": "https://registry.npmjs.org/@rollup/rollup-linux-x64-musl/-/rollup-linux-x64-musl-4.68.7.tgz", + "integrity": "sha512-VNLvsYMD5+zLCi5SohwDdL8PpicC9PnArLwyMJXXUcAduzrM3k9aZT9XiHw+mn5dOWr3UEyfyqJbOvxwJ2fCWQ==", + "cpu": [ + "x64" + ], + "dev": true, + "libc": [ + "musl" + ], + "license": "MIT", + "optional": true, + "os": [ + "linux" + ] + }, + "node_modules/@rollup/rollup-openbsd-x64": { + "version": "4.68.7", + "resolved": "https://registry.npmjs.org/@rollup/rollup-openbsd-x64/-/rollup-openbsd-x64-4.68.7.tgz", + "integrity": "sha512-7aOjdahkwiECWWOmjAemPd21yeQ18TW59DUiLWttzolMe5tDwHyBhlOfmxRUHOQnepTNkZ2Qwp1T6LxFZ5v7yQ==", + "cpu": [ + "x64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "openbsd" + ] + }, + "node_modules/@rollup/rollup-openharmony-arm64": { + "version": "4.68.7", + "resolved": "https://registry.npmjs.org/@rollup/rollup-openharmony-arm64/-/rollup-openharmony-arm64-4.68.7.tgz", + "integrity": "sha512-BnNkTwE4FMCAoz3UYiJ6D6Y3pGozYIYZ2W+onH64uhiTI2iwD3KOaNSlkuHYfupZVemls3YTlvbPnuKwHsraiQ==", + "cpu": [ + "arm64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "openharmony" + ] + }, + "node_modules/@rollup/rollup-win32-arm64-msvc": { + "version": "4.68.7", + "resolved": "https://registry.npmjs.org/@rollup/rollup-win32-arm64-msvc/-/rollup-win32-arm64-msvc-4.68.7.tgz", + "integrity": "sha512-OH8tGWsJcRW6Vn0dmndyWJGdQa46bH2/2/PVfleBGUWuBd5/HVkIvw2UslgBwUZdtV78bJaoCNBmYI5+bcTJ4A==", + "cpu": [ + "arm64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "win32" + ] + }, + "node_modules/@rollup/rollup-win32-ia32-msvc": { + "version": "4.68.7", + "resolved": "https://registry.npmjs.org/@rollup/rollup-win32-ia32-msvc/-/rollup-win32-ia32-msvc-4.68.7.tgz", + "integrity": "sha512-SpYx5X9+2JOF3hXe1cRaiFn562h4AMJhfgxkyHyiuh9dJ7PanPm7FTp8GJReSbS9N+TfjRiBbKacVk1g35kKxg==", + "cpu": [ + "ia32" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "win32" + ] + }, + "node_modules/@rollup/rollup-win32-x64-gnu": { + "version": "4.68.7", + "resolved": "https://registry.npmjs.org/@rollup/rollup-win32-x64-gnu/-/rollup-win32-x64-gnu-4.68.7.tgz", + "integrity": "sha512-0ncKtQ55fqElV9Sk4cZ/4tiXVGlWxaH5PvDOlx1Sx8GuHIpSWgYrTcyrO51JnVFfy7LvAJiffkEg63ZHKwTMag==", + "cpu": [ + "x64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "win32" + ] + }, + "node_modules/@rollup/rollup-win32-x64-msvc": { + "version": "4.68.7", + "resolved": "https://registry.npmjs.org/@rollup/rollup-win32-x64-msvc/-/rollup-win32-x64-msvc-4.68.7.tgz", + "integrity": "sha512-XY9DYHO5UxxVR8G6AErXDlccQmDpvGTLgKHFpvkgsyjwG/PrQuInRjQQfpEzBRuT+bhBtwfS8yDe9sPhVcq/9A==", + "cpu": [ + "x64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "win32" + ] + }, + "node_modules/@types/babel__core": { + "version": "7.20.5", + "resolved": "https://registry.npmjs.org/@types/babel__core/-/babel__core-7.20.5.tgz", + "integrity": "sha512-qoQprZvz5wQFJwMDqeseRXWv3rqMvhgpbXFfVyWhbx9X47POIA6i/+dXefEmZKoAgOaTdaIgNSMqMIU61yRyzA==", + "dev": true, + "license": "MIT", + "dependencies": { + "@babel/parser": "^7.20.7", + "@babel/types": "^7.20.7", + "@types/babel__generator": "*", + "@types/babel__template": "*", + "@types/babel__traverse": "*" + } + }, + "node_modules/@types/babel__generator": { + "version": "7.27.0", + "resolved": "https://registry.npmjs.org/@types/babel__generator/-/babel__generator-7.27.0.tgz", + "integrity": "sha512-ufFd2Xi92OAVPYsy+P4n7/U7e68fex0+Ee8gSG9KX7eo084CWiQ4sdxktvdl0bOPupXtVJPY19zk6EwWqUQ8lg==", + "dev": true, + "license": "MIT", + "dependencies": { + "@babel/types": "^7.0.0" + } + }, + "node_modules/@types/babel__template": { + "version": "7.4.4", + "resolved": "https://registry.npmjs.org/@types/babel__template/-/babel__template-7.4.4.tgz", + "integrity": "sha512-h/NUaSyG5EyxBIp8YRxo4RMe2/qQgvyowRwVMzhYhBCONbW8PUsg4lkFMrhgZhUe5z3L3MiLDuvyJ/CaPa2A8A==", + "dev": true, + "license": "MIT", + "dependencies": { + "@babel/parser": "^7.1.0", + "@babel/types": "^7.0.0" + } + }, + "node_modules/@types/babel__traverse": { + "version": "7.28.0", + "resolved": "https://registry.npmjs.org/@types/babel__traverse/-/babel__traverse-7.28.0.tgz", + "integrity": "sha512-8PvcXf70gTDZBgt9ptxJ8elBeBjcLOAcOtoO/mPJjtji1+CdGbHgm77om1GrsPxsiE+uXIpNSK64UYaIwQXd4Q==", + "dev": true, + "license": "MIT", + "dependencies": { + "@babel/types": "^7.28.2" + } + }, + "node_modules/@types/estree": { + "version": "1.0.10", + "resolved": "https://registry.npmjs.org/@types/estree/-/estree-1.0.10.tgz", + "integrity": "sha512-lTyOMnOcmRBzdCv6/4zUZCrEhV0xrqQiUZBZtVcbmLHBXKLnN8q89v/wKRF/Q0HbwVsqbIG3o5HDoFl9sduM+g==", + "dev": true, + "license": "MIT" + }, + "node_modules/@types/react": { + "version": "19.3.0", + "resolved": "https://registry.npmjs.org/@types/react/-/react-19.3.0.tgz", + "integrity": "sha512-N0rFCuH9YoxG9/m61l9MfpJKfmLOVU0em7ipIz6TRgSSkvReLB9vL85GB+yr8Bs5leqpvg96JSwF4ZS1s4viQg==", + "dev": true, + "license": "MIT", + "dependencies": { + "csstype": "^3.2.2" + } + }, + "node_modules/@types/react-dom": { + "version": "19.3.0", + "resolved": "https://registry.npmjs.org/@types/react-dom/-/react-dom-19.3.0.tgz", + "integrity": "sha512-ZI7bU42mZXXKHn/qNLEw2IrbiINU7X5+vfgdixBHkCNpYWXjKgfQ/P+uyGb5CjOLB9UcnTeg3rylQtV2hym44Q==", + "dev": true, + "license": "MIT", + "peerDependencies": { + "@types/react": "^19.3.0" + } + }, + "node_modules/@vitejs/plugin-react": { + "version": "5.2.0", + "resolved": "https://registry.npmjs.org/@vitejs/plugin-react/-/plugin-react-5.2.0.tgz", + "integrity": "sha512-YmKkfhOAi3wsB1PhJq5Scj3GXMn3WvtQ/JC0xoopuHoXSdmtdStOpFrYaT1kie2YgFBcIe64ROzMYRjCrYOdYw==", + "dev": true, + "license": "MIT", + "dependencies": { + "@babel/core": "^7.29.0", + "@babel/plugin-transform-react-jsx-self": "^7.27.1", + "@babel/plugin-transform-react-jsx-source": "^7.27.1", + "@rolldown/pluginutils": "1.0.0-rc.3", + "@types/babel__core": "^7.20.5", + "react-refresh": "^0.18.0" + }, + "engines": { + "node": "^20.19.0 || >=22.12.0" + }, + "peerDependencies": { + "vite": "^4.2.0 || ^5.0.0 || ^6.0.0 || ^7.0.0 || ^8.0.0" + } + }, + "node_modules/baseline-browser-mapping": { + "version": "2.11.38", + "resolved": "https://registry.npmjs.org/baseline-browser-mapping/-/baseline-browser-mapping-2.11.38.tgz", + "integrity": "sha512-rMgy5YW7x28SMfXHLlVZDBqlWzYZ0x2rVR/6FWrNBF0chjigARK1H6nM0hKA1Um3kPOlkQFVtjJs00d2N1ezuw==", + "dev": true, + "license": "Apache-2.0", + "bin": { + "baseline-browser-mapping": "dist/cli.cjs" + }, + "engines": { + "node": ">=6.0.0" + } + }, + "node_modules/browserslist": { + "version": "4.29.6", + "resolved": "https://registry.npmjs.org/browserslist/-/browserslist-4.29.6.tgz", + "integrity": "sha512-CmVVIQ3RVc5HxYEc9X84GvxK/C8C1wH8TlKAiO7uTxF8PDwt7r8t9Qk3J9NkMOVzX5O/HbLv3yzxZg9HPrnI9w==", + "dev": true, + "funding": [ + { + "type": "opencollective", + "url": "https://opencollective.com/browserslist" + }, + { + "type": "tidelift", + "url": "https://tidelift.com/funding/github/npm/browserslist" + }, + { + "type": "github", + "url": "https://github.com/sponsors/ai" + } + ], + "license": "MIT", + "dependencies": { + "baseline-browser-mapping": "^2.11.37", + "caniuse-lite": "^1.0.30001826", + "electron-to-chromium": "^1.5.486", + "node-releases": "^2.0.64", + "update-browserslist-db": "^1.4.0" + }, + "bin": { + "browserslist": "cli.js" + }, + "engines": { + "node": "^6 || ^7 || ^8 || ^9 || ^10 || ^11 || ^12 || >=13.7" + } + }, + "node_modules/caniuse-lite": { + "version": "1.0.30001826", + "resolved": "https://registry.npmjs.org/caniuse-lite/-/caniuse-lite-1.0.30001826.tgz", + "integrity": "sha512-wTB+9tIbLro/BCXwLuNV1meHE4L9dS6dArMDwgYfNBPMYScqClHyGunhkCSDtHhe/69Xl0sHlKgBVZ+fNsYtWA==", + "dev": true, + "funding": [ + { + "type": "opencollective", + "url": "https://opencollective.com/browserslist" + }, + { + "type": "tidelift", + "url": "https://tidelift.com/funding/github/npm/caniuse-lite" + }, + { + "type": "github", + "url": "https://github.com/sponsors/ai" + } + ], + "license": "CC-BY-4.0" + }, + "node_modules/convert-source-map": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/convert-source-map/-/convert-source-map-2.0.0.tgz", + "integrity": "sha512-Kvp459HrV2FEJ1CAsi1Ku+MY3kasH19TFykTz2xWmMeq6bk2NU3XXvfJ+Q61m0xktWwt+1HSYf3JZsTms3aRJg==", + "dev": true, + "license": "MIT" + }, + "node_modules/csstype": { + "version": "3.2.4", + "resolved": "https://registry.npmjs.org/csstype/-/csstype-3.2.4.tgz", + "integrity": "sha512-PoKaoPzQapnEoqUSnHx1u6W6ku8CVEgKsnpmmzU3m1nwkidpPBQ8V/Zq2+bWNrsOKoKLwTGdbx6xF7BXP1zLVQ==", + "dev": true, + "license": "MIT" + }, + "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/electron-to-chromium": { + "version": "1.5.491", + "resolved": "https://registry.npmjs.org/electron-to-chromium/-/electron-to-chromium-1.5.491.tgz", + "integrity": "sha512-zMOQrvaTekJMwENqx1Rnyl3qieqGxIui5CRu9g6ktKzQ/T54fq0Qfr3V/SEhGrkStWI3eYMSzMN4rbyFwfQSzA==", + "dev": true, + "license": "ISC" + }, + "node_modules/esbuild": { + "version": "0.28.2", + "resolved": "https://registry.npmjs.org/esbuild/-/esbuild-0.28.2.tgz", + "integrity": "sha512-HKVLS8dvII+xoKW9kmqxbRKrnWEXfJJr/FZhhJmiqIB0e053QNYFqOBouTMO/k5sID4MvCiUCvv8b9M4h32wIA==", + "dev": true, + "hasInstallScript": true, + "license": "MIT", + "bin": { + "esbuild": "bin/esbuild" + }, + "engines": { + "node": ">=18" + }, + "optionalDependencies": { + "@esbuild/aix-ppc64": "0.28.2", + "@esbuild/android-arm": "0.28.2", + "@esbuild/android-arm64": "0.28.2", + "@esbuild/android-x64": "0.28.2", + "@esbuild/darwin-arm64": "0.28.2", + "@esbuild/darwin-x64": "0.28.2", + "@esbuild/freebsd-arm64": "0.28.2", + "@esbuild/freebsd-x64": "0.28.2", + "@esbuild/linux-arm": "0.28.2", + "@esbuild/linux-arm64": "0.28.2", + "@esbuild/linux-ia32": "0.28.2", + "@esbuild/linux-loong64": "0.28.2", + "@esbuild/linux-mips64el": "0.28.2", + "@esbuild/linux-ppc64": "0.28.2", + "@esbuild/linux-riscv64": "0.28.2", + "@esbuild/linux-s390x": "0.28.2", + "@esbuild/linux-x64": "0.28.2", + "@esbuild/netbsd-arm64": "0.28.2", + "@esbuild/netbsd-x64": "0.28.2", + "@esbuild/openbsd-arm64": "0.28.2", + "@esbuild/openbsd-x64": "0.28.2", + "@esbuild/openharmony-arm64": "0.28.2", + "@esbuild/sunos-x64": "0.28.2", + "@esbuild/win32-arm64": "0.28.2", + "@esbuild/win32-ia32": "0.28.2", + "@esbuild/win32-x64": "0.28.2" + } + }, + "node_modules/escalade": { + "version": "3.2.0", + "resolved": "https://registry.npmjs.org/escalade/-/escalade-3.2.0.tgz", + "integrity": "sha512-WUj2qlxaQtO4g6Pq5c29GTcWGDyd8itL8zTlipgECz3JesAiiOKotd8JU6otB3PACgG6xkJUyVhboMS+bje/jA==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=6" + } + }, + "node_modules/fdir": { + "version": "6.5.0", + "resolved": "https://registry.npmjs.org/fdir/-/fdir-6.5.0.tgz", + "integrity": "sha512-tIbYtZbucOs0BRGqPJkshJUYdL+SDH7dVM8gjy+ERp3WAUjLEFJE+02kanyHtwjWOnwrKYBiwAmM0p4kLJAnXg==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=12.0.0" + }, + "peerDependencies": { + "picomatch": "^3 || ^4" + }, + "peerDependenciesMeta": { + "picomatch": { + "optional": true + } + } + }, + "node_modules/fsevents": { + "version": "2.3.3", + "resolved": "https://registry.npmjs.org/fsevents/-/fsevents-2.3.3.tgz", + "integrity": "sha512-5xoDfX+fL7faATnagmWPpbFtwh/R77WmMMqqHGS65C3vvB0YHrgF+B1YmZ3441tMj5n63k0212XNoJwzlhffQw==", + "dev": true, + "hasInstallScript": true, + "license": "MIT", + "optional": true, + "os": [ + "darwin" + ], + "engines": { + "node": "^8.16.0 || ^10.6.0 || >=11.0.0" + } + }, + "node_modules/gensync": { + "version": "1.0.0-beta.2", + "resolved": "https://registry.npmjs.org/gensync/-/gensync-1.0.0-beta.2.tgz", + "integrity": "sha512-3hN7NaskYvMDLQY55gnW3NQ+mesEAepTqlg+VEbj7zzqEMBVNhzcGYYeqFo/TlYz6eQiFcp1HcsCZO+nGgS8zg==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=6.9.0" + } + }, + "node_modules/js-tokens": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/js-tokens/-/js-tokens-4.0.0.tgz", + "integrity": "sha512-RdJUflcE3cUzKiMqQgsCu06FPu9UdIJO0beYbPhHN4k6apgJtifcoCtT9bcxOpYBtpD2kCM6Sbzg4CausW/PKQ==", + "dev": true, + "license": "MIT" + }, + "node_modules/jsesc": { + "version": "3.1.0", + "resolved": "https://registry.npmjs.org/jsesc/-/jsesc-3.1.0.tgz", + "integrity": "sha512-/sM3dO2FOzXjKQhJuo0Q173wf2KOo8t4I8vHy6lF9poUp7bKT0/NHE8fPX23PwfhnykfqnC2xRxOnVw5XuGIaA==", + "dev": true, + "license": "MIT", + "bin": { + "jsesc": "bin/jsesc" + }, + "engines": { + "node": ">=6" + } + }, + "node_modules/json5": { + "version": "2.2.3", + "resolved": "https://registry.npmjs.org/json5/-/json5-2.2.3.tgz", + "integrity": "sha512-XmOWe7eyHYH14cLdVPoyg+GOH3rYX++KpzrylJwSW98t3Nk+U8XOl8FWKOgwtzdb8lXGf6zYwDUzeHMWfxasyg==", + "dev": true, + "license": "MIT", + "bin": { + "json5": "lib/cli.js" + }, + "engines": { + "node": ">=6" + } + }, + "node_modules/lru-cache": { + "version": "5.1.1", + "resolved": "https://registry.npmjs.org/lru-cache/-/lru-cache-5.1.1.tgz", + "integrity": "sha512-KpNARQA3Iwv+jTA0utUVVbrh+Jlrr1Fv0e56GGzAFOXN7dk/FviaDW8LHmK52DlcH4WP2n6gI8vN1aesBFgo9w==", + "dev": true, + "license": "ISC", + "dependencies": { + "yallist": "^3.0.2" + } + }, + "node_modules/ms": { + "version": "2.1.3", + "resolved": "https://registry.npmjs.org/ms/-/ms-2.1.3.tgz", + "integrity": "sha512-6FlzubTLZG3J2a/NVCAleEhjzq5oxgHyaCU9yYXvcLsvoVaHJq/s5xXI6/XXP6tz7R9xAOtHnSO/tXtF3WRTlA==", + "dev": true, + "license": "MIT" + }, + "node_modules/nanoid": { + "version": "3.3.20", + "resolved": "https://registry.npmjs.org/nanoid/-/nanoid-3.3.20.tgz", + "integrity": "sha512-uKdg2G3GNCKQn9byYOpxbGqrT2fGO5KRt5J/8b3pok8rT6qxGWF6hxMyJiEYtAf+FVyYuD9hRaDqX5uPFYJ4ZQ==", + "dev": true, + "funding": [ + { + "type": "github", + "url": "https://github.com/sponsors/ai" + } + ], + "license": "MIT", + "bin": { + "nanoid": "bin/nanoid.cjs" + }, + "engines": { + "node": "^10 || ^12 || ^13.7 || ^14 || >=15.0.1" + } + }, + "node_modules/node-releases": { + "version": "2.0.65", + "resolved": "https://registry.npmjs.org/node-releases/-/node-releases-2.0.65.tgz", + "integrity": "sha512-PfvofsGQ+MiOQIPkX9fU8ELUWmy5zL74CdQaph/ismKszfFkfwXaw0cGiwbwym2hT9k5+mdyl8O5WQ1MD8EHmA==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=18" + } + }, + "node_modules/picocolors": { + "version": "1.1.1", + "resolved": "https://registry.npmjs.org/picocolors/-/picocolors-1.1.1.tgz", + "integrity": "sha512-xceH2snhtb5M9liqDsmEw56le376mTZkEX/jEb/RxNFyegNul7eNslCXP9FDj/Lcu0X8KEyMceP2ntpaHrDEVA==", + "dev": true, + "license": "ISC" + }, + "node_modules/picomatch": { + "version": "4.0.7", + "resolved": "https://registry.npmjs.org/picomatch/-/picomatch-4.0.7.tgz", + "integrity": "sha512-qcJu88Q2IWqJsDD529JKMdwGm/dvInW4HvQnRwiH9JtihJvzGOscDtHE3x1pBKeUOTysQ8kVmLnJ2kJu7yhcGA==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=12" + }, + "funding": { + "url": "https://github.com/sponsors/jonschlinkert" + } + }, + "node_modules/postcss": { + "version": "8.5.33", + "resolved": "https://registry.npmjs.org/postcss/-/postcss-8.5.33.tgz", + "integrity": "sha512-RVHEU9/Pp1Fnjr/MpAJsZoADukCKhfIi15OunEYiGktIkYLkPVvC1sioWolGDS7XByMTx9m/IGbro0Js13zhnQ==", + "dev": true, + "funding": [ + { + "type": "opencollective", + "url": "https://opencollective.com/postcss/" + }, + { + "type": "tidelift", + "url": "https://tidelift.com/funding/github/npm/postcss" + }, + { + "type": "github", + "url": "https://github.com/sponsors/ai" + } + ], + "license": "MIT", + "dependencies": { + "nanoid": "^3.3.20", + "picocolors": "^1.1.1", + "source-map-js": "^1.2.2" + }, + "engines": { + "node": "^10 || ^12 || >=14" + } + }, + "node_modules/react": { + "version": "19.3.1", + "resolved": "https://registry.npmjs.org/react/-/react-19.3.1.tgz", + "integrity": "sha512-QNhWdt7nrgVWWQG58QuGsAR3jv3Hbe4mb4vz7w2csnHavciZJgda1CPNaldF6eVxv90ud3jUXpKlHL69gO38yw==", + "license": "MIT", + "engines": { + "node": ">=0.10.0" + } + }, + "node_modules/react-dom": { + "version": "19.3.1", + "resolved": "https://registry.npmjs.org/react-dom/-/react-dom-19.3.1.tgz", + "integrity": "sha512-Y0bARz53lhEC1NMCASs0/j+faB/zqt3R8hpvg1e8+61ZVJ4UL0UdC4cBbXfZMcIuhrfgeILTLe+ZeBCavQPtKQ==", + "license": "MIT", + "dependencies": { + "scheduler": "^0.28.0" + }, + "peerDependencies": { + "react": "^19.3.1" + } + }, + "node_modules/react-refresh": { + "version": "0.18.0", + "resolved": "https://registry.npmjs.org/react-refresh/-/react-refresh-0.18.0.tgz", + "integrity": "sha512-QgT5//D3jfjJb6Gsjxv0Slpj23ip+HtOpnNgnb2S5zU3CB26G/IDPGoy4RJB42wzFE46DRsstbW6tKHoKbhAxw==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=0.10.0" + } + }, + "node_modules/rollup": { + "version": "4.68.7", + "resolved": "https://registry.npmjs.org/rollup/-/rollup-4.68.7.tgz", + "integrity": "sha512-CxhzUIc+ocxPAWxHuff+PAluoW1otD6dHqqPK2h2Q38WA1VYk+3gizX6NEg5t2a8yNGQaiHM1R7V+qdwWuvp5Q==", + "dev": true, + "license": "MIT", + "dependencies": { + "@types/estree": "^1.0.10" + }, + "bin": { + "rollup": "dist/bin/rollup" + }, + "engines": { + "node": ">=18.0.0", + "npm": ">=8.0.0" + }, + "optionalDependencies": { + "@rollup/rollup-android-arm-eabi": "4.68.7", + "@rollup/rollup-android-arm64": "4.68.7", + "@rollup/rollup-android-x64": "4.68.7", + "@rollup/rollup-darwin-arm64": "4.68.7", + "@rollup/rollup-darwin-x64": "4.68.7", + "@rollup/rollup-freebsd-arm64": "4.68.7", + "@rollup/rollup-freebsd-x64": "4.68.7", + "@rollup/rollup-linux-arm-gnueabihf": "4.68.7", + "@rollup/rollup-linux-arm-musleabihf": "4.68.7", + "@rollup/rollup-linux-arm64-gnu": "4.68.7", + "@rollup/rollup-linux-arm64-musl": "4.68.7", + "@rollup/rollup-linux-loong64-gnu": "4.68.7", + "@rollup/rollup-linux-loong64-musl": "4.68.7", + "@rollup/rollup-linux-ppc64-gnu": "4.68.7", + "@rollup/rollup-linux-ppc64-musl": "4.68.7", + "@rollup/rollup-linux-riscv64-gnu": "4.68.7", + "@rollup/rollup-linux-riscv64-musl": "4.68.7", + "@rollup/rollup-linux-s390x-gnu": "4.68.7", + "@rollup/rollup-linux-x64-gnu": "4.68.7", + "@rollup/rollup-linux-x64-musl": "4.68.7", + "@rollup/rollup-openbsd-x64": "4.68.7", + "@rollup/rollup-openharmony-arm64": "4.68.7", + "@rollup/rollup-win32-arm64-msvc": "4.68.7", + "@rollup/rollup-win32-ia32-msvc": "4.68.7", + "@rollup/rollup-win32-x64-gnu": "4.68.7", + "@rollup/rollup-win32-x64-msvc": "4.68.7", + "fsevents": "~2.3.2" + } + }, + "node_modules/scheduler": { + "version": "0.28.0", + "resolved": "https://registry.npmjs.org/scheduler/-/scheduler-0.28.0.tgz", + "integrity": "sha512-juorfCmIkIw8tT+p5BXSm6PJjQF/ycEYmKyzURCIt/RaZIhL+PulbQ9Yu2z1HdOJDdqDTlxA1+xKBmHXJsczAw==", + "license": "MIT" + }, + "node_modules/semver": { + "version": "6.3.2", + "resolved": "https://registry.npmjs.org/semver/-/semver-6.3.2.tgz", + "integrity": "sha512-GYrCADwpu6yV5OAvchkQ27Z5wwMxWAEMg5NNWjyHh/5DboFFqbdbvYNIvZouQpxXyeMPoTOh0vdPYKlf0ZswdQ==", + "dev": true, + "license": "ISC", + "bin": { + "semver": "bin/semver.js" + } + }, + "node_modules/source-map-js": { + "version": "1.2.3", + "resolved": "https://registry.npmjs.org/source-map-js/-/source-map-js-1.2.3.tgz", + "integrity": "sha512-xj+WrAkyv5Qp+t7r9N5HvCBu7g1qOe6CKRNpq22X1GGcPEQADFU54v5qsPVs3/vrUFQ7XivFrcAVKA2stI0kWA==", + "dev": true, + "license": "BSD-3-Clause", + "engines": { + "node": ">=0.10.0" + } + }, + "node_modules/tinyglobby": { + "version": "0.2.17", + "resolved": "https://registry.npmjs.org/tinyglobby/-/tinyglobby-0.2.17.tgz", + "integrity": "sha512-wXR/dYpcqKmfWpEdZjiKJOwCNFndD0DMnrW/cYjVGttEkBfVgcLFHoNrlj47mjOVic9yyNu65alsgF4NQyTa2g==", + "dev": true, + "license": "MIT", + "dependencies": { + "fdir": "^6.5.0", + "picomatch": "^4.0.4" + }, + "engines": { + "node": ">=12.0.0" + }, + "funding": { + "url": "https://github.com/sponsors/SuperchupuDev" + } + }, + "node_modules/typescript": { + "version": "5.9.3", + "resolved": "https://registry.npmjs.org/typescript/-/typescript-5.9.3.tgz", + "integrity": "sha512-jl1vZzPDinLr9eUt3J/t7V6FgNEw9QjvBPdysz9KfQDD41fQrC2Y4vKQdiaUpFT4bXlb1RHhLpp8wtm6M5TgSw==", + "dev": true, + "license": "Apache-2.0", + "bin": { + "tsc": "bin/tsc", + "tsserver": "bin/tsserver" + }, + "engines": { + "node": ">=14.17" + } + }, + "node_modules/update-browserslist-db": { + "version": "1.4.0", + "resolved": "https://registry.npmjs.org/update-browserslist-db/-/update-browserslist-db-1.4.0.tgz", + "integrity": "sha512-WPJuOnjI9FWDct4fB+ej4Mz8opLaw5CDcZ2t44tFZ0vIQVYWzBhWR3mkixuUj/A7+vY4V9+ApOZ2YYLwdgq46w==", + "dev": true, + "funding": [ + { + "type": "opencollective", + "url": "https://opencollective.com/browserslist" + }, + { + "type": "tidelift", + "url": "https://tidelift.com/funding/github/npm/browserslist" + }, + { + "type": "github", + "url": "https://github.com/sponsors/ai" + } + ], + "license": "MIT", + "dependencies": { + "escalade": "^3.2.0", + "picocolors": "^1.1.1" + }, + "bin": { + "update-browserslist-db": "cli.js" + }, + "peerDependencies": { + "browserslist": ">= 4.21.0" + } + }, + "node_modules/vite": { + "version": "7.3.8", + "resolved": "https://registry.npmjs.org/vite/-/vite-7.3.8.tgz", + "integrity": "sha512-3tTi78MAKhVk9h+YZVXMQ8POmneJuE97QUPAWtJghHzhH7BAyiqQOC2KZh1DWOsu/USB2cRXhznPByaabvYXfw==", + "dev": true, + "license": "MIT", + "dependencies": { + "esbuild": "^0.27.0 || ^0.28.0", + "fdir": "^6.5.0", + "picomatch": "^4.0.3", + "postcss": "^8.5.6", + "rollup": "^4.43.0", + "tinyglobby": "^0.2.15" + }, + "bin": { + "vite": "bin/vite.js" + }, + "engines": { + "node": "^20.19.0 || >=22.12.0" + }, + "funding": { + "url": "https://github.com/vitejs/vite?sponsor=1" + }, + "optionalDependencies": { + "fsevents": "~2.3.3" + }, + "peerDependencies": { + "@types/node": "^20.19.0 || >=22.12.0", + "jiti": ">=1.21.0", + "less": "^4.0.0", + "lightningcss": "^1.21.0", + "sass": "^1.70.0", + "sass-embedded": "^1.70.0", + "stylus": ">=0.54.8", + "sugarss": "^5.0.0", + "terser": "^5.16.0", + "tsx": "^4.8.1", + "yaml": "^2.4.2" + }, + "peerDependenciesMeta": { + "@types/node": { + "optional": true + }, + "jiti": { + "optional": true + }, + "less": { + "optional": true + }, + "lightningcss": { + "optional": true + }, + "sass": { + "optional": true + }, + "sass-embedded": { + "optional": true + }, + "stylus": { + "optional": true + }, + "sugarss": { + "optional": true + }, + "terser": { + "optional": true + }, + "tsx": { + "optional": true + }, + "yaml": { + "optional": true + } + } + }, + "node_modules/yallist": { + "version": "3.1.1", + "resolved": "https://registry.npmjs.org/yallist/-/yallist-3.1.1.tgz", + "integrity": "sha512-a4UGQaWPH59mOXUYnAG2ewncQS4i4F43Tv3JoAM+s2VDAmS9NsK8GpDMLrCHPksFT7h3K6TOoUNn2pb7RoXx4g==", + "dev": true, + "license": "ISC" + } + } +} diff --git a/frontend/package.json b/frontend/package.json new file mode 100644 index 0000000..b13b510 --- /dev/null +++ b/frontend/package.json @@ -0,0 +1,22 @@ +{ + "name": "upandown-frontend", + "private": true, + "version": "0.1.0", + "type": "module", + "scripts": { + "dev": "vite", + "build": "tsc --noEmit && vite build", + "preview": "vite preview" + }, + "dependencies": { + "react": "^19.1.0", + "react-dom": "^19.1.0" + }, + "devDependencies": { + "@types/react": "^19.1.0", + "@types/react-dom": "^19.1.0", + "@vitejs/plugin-react": "^5.0.0", + "typescript": "^5.8.0", + "vite": "^7.0.0" + } +} diff --git a/frontend/src/ActionMenu.tsx b/frontend/src/ActionMenu.tsx new file mode 100644 index 0000000..d0f0662 --- /dev/null +++ b/frontend/src/ActionMenu.tsx @@ -0,0 +1,92 @@ +import { useEffect, useLayoutEffect, useRef, useState } from "react"; +import type { ReactNode } from "react"; +import { createPortal } from "react-dom"; + +interface Props { + /** Bouton « … » qui a ouvert le menu : le menu s'aligne sur lui. */ + anchor: HTMLElement; + onClose: () => void; + children: ReactNode; +} + +const MARGIN = 8; // écart minimal avec les bords de la fenêtre + +/** + * Menu déroulant des actions d'un élément, ouvert sous le bouton « … » et aligné + * sur son bord droit (au-dessus s'il manque de place en bas). Rendu dans + * pour ne pas être rogné par le défilement de la liste ; refermé par un clic + * ailleurs, Échap, un défilement, un redimensionnement ou le choix d'une action. + */ +export function ActionMenu({ anchor, onClose, children }: Props) { + const ref = useRef(null); + const [pos, setPos] = useState<{ top: number; left: number } | null>(null); + + useLayoutEffect(() => { + const menu = ref.current; + if (!menu) return; + const a = anchor.getBoundingClientRect(); + const { offsetWidth: w, offsetHeight: h } = menu; + let top = a.bottom + 4; + if (top + h > innerHeight - MARGIN) top = Math.max(MARGIN, a.top - 4 - h); + const left = Math.min(Math.max(MARGIN, a.right - w), innerWidth - w - MARGIN); + setPos({ top, left }); + }, [anchor]); + + // Focus sur la première action une fois le menu placé (masqué, il ne le prend pas). + useEffect(() => { + if (pos) ref.current?.querySelector("button, a")?.focus({ preventScroll: true }); + }, [pos]); + + useEffect(() => { + const inside = (t: EventTarget | null) => t instanceof Node && (ref.current?.contains(t) || anchor.contains(t)); + const onDown = (ev: PointerEvent) => { + if (!inside(ev.target)) onClose(); + }; + const onKey = (ev: KeyboardEvent) => { + if (ev.key === "Escape") { + // Ni désélection, ni fermeture du panneau flottant : seulement le menu. + ev.preventDefault(); + ev.stopPropagation(); + onClose(); + anchor.focus(); + } else if (ev.key === "ArrowDown" || ev.key === "ArrowUp") { + const items = [...(ref.current?.querySelectorAll("button, a") ?? [])]; + if (!items.length) return; + ev.preventDefault(); + const i = items.indexOf(document.activeElement as HTMLElement); + const next = ev.key === "ArrowDown" ? (i + 1) % items.length : (i - 1 + items.length) % items.length; + items[next].focus(); + } + }; + const onScroll = (ev: Event) => { + if (!(ev.target instanceof Node && ref.current?.contains(ev.target))) onClose(); + }; + document.addEventListener("pointerdown", onDown, true); + document.addEventListener("keydown", onKey, true); + document.addEventListener("scroll", onScroll, true); + window.addEventListener("resize", onClose); + return () => { + document.removeEventListener("pointerdown", onDown, true); + document.removeEventListener("keydown", onKey, true); + document.removeEventListener("scroll", onScroll, true); + window.removeEventListener("resize", onClose); + }; + }, [anchor, onClose]); + + return createPortal( +
{ + if ((ev.target as HTMLElement).closest("button, a")) setTimeout(onClose); + }} + > + {children} +
, + document.body, + ); +} diff --git a/frontend/src/App.tsx b/frontend/src/App.tsx new file mode 100644 index 0000000..dd64245 --- /dev/null +++ b/frontend/src/App.tsx @@ -0,0 +1,316 @@ +import { useCallback, useEffect, useRef, useState } from "react"; +import { api, FAVORIS, PERSO, POUBELLE, type Entry, type Me } from "./api"; +import { ActionMenu } from "./ActionMenu"; +import { Explorer } from "./Explorer"; +import { Login } from "./Login"; +import { SettingsDialog } from "./SettingsDialog"; +import { Splitter } from "./Splitter"; +import { UploadPanel } from "./UploadPanel"; +import { fmtSize, initials } from "./format"; +import { + CloudUpIcon, + FolderIcon, + KeyIcon, + LogoutIcon, + MenuIcon, + MoonIcon, + SettingsIcon, + ShareIcon, + ShieldIcon, + StarFilledIcon, + SunIcon, + TrashFullIcon, + TrashIcon, + UserIcon, + UsersIcon, +} from "./icons"; + +type Theme = "light" | "dark"; + +const initialTheme = (): Theme => (document.documentElement.dataset.theme === "dark" ? "dark" : "light"); + +const SIDEBAR_MIN = 200; +const SIDEBAR_MAX = 420; +const SIDEBAR_DEFAULT = 248; + +const hashDir = () => { + const h = location.hash.replace(/^#\/?/, ""); + try { + return decodeURIComponent(h); + } catch { + return ""; + } +}; + +export default function App() { + const [me, setMe] = useState(null); + const [loadError, setLoadError] = useState(null); + + const loadMe = useCallback( + () => + api + .me() + .then((m) => { + setMe(m); + setLoadError(null); + document.title = m.title || "Up And Down"; + }) + .catch((e) => setLoadError(e instanceof Error ? e.message : String(e))), + [], + ); + + useEffect(() => { + loadMe(); + }, [loadMe]); + + // OIDC seul : pas de page de connexion locale, direction le fournisseur. + const redirecting = !!me && !me.user && me.oidc && !me.local; + useEffect(() => { + if (redirecting) location.replace(`/auth/login?next=${encodeURIComponent(location.pathname + location.search + location.hash)}`); + }, [redirecting]); + + if (loadError) { + return ( +
+
+

{loadError}

+ +
+
+ ); + } + if (!me || redirecting) return
Chargement…
; + if (!me.user) return ; + return ; +} + +function Shell({ me, reloadMe }: { me: Me; reloadMe: () => Promise }) { + const [theme, setTheme] = useState(initialTheme); + const [dir, setDir] = useState(""); + const [goto, setGoto] = useState<{ dir: string; seq: number }>({ dir: hashDir(), seq: 0 }); + const [refreshKey, setRefreshKey] = useState(0); + const [places, setPlaces] = useState([]); + const [drawer, setDrawer] = useState(false); + const [settings, setSettings] = useState<"account" | "tokens" | "shares" | "general" | "users" | null>(null); + const [userMenu, setUserMenu] = useState(null); + const [sidebarW, setSidebarW] = useState(() => { + try { + const n = Number(localStorage.getItem("udSidebar")); + return n >= SIDEBAR_MIN && n <= SIDEBAR_MAX ? n : SIDEBAR_DEFAULT; + } catch { + return SIDEBAR_DEFAULT; + } + }); + const [resizing, setResizing] = useState(false); + const dirRef = useRef(""); + const title = me.title || "Up And Down"; + + useEffect(() => { + document.documentElement.dataset.theme = theme; + try { + localStorage.setItem("udTheme", theme); + } catch { + /* stockage indisponible */ + } + }, [theme]); + + // Dossier courant dans l'adresse (#/dossier/sous) : liens directs et bouton « précédent ». + const onDirChange = useCallback((d: string) => { + dirRef.current = d; + setDir(d); + const want = d ? `#/${d.split("/").map(encodeURIComponent).join("/")}` : ""; + if (decodeURIComponent(location.hash.replace(/^#\/?/, "")) !== d) { + if (want) location.hash = want; + else history.pushState(null, "", location.pathname + location.search); + } + }, []); + + useEffect(() => { + const onHash = () => { + const d = hashDir(); + if (d !== dirRef.current) setGoto((g) => ({ dir: d, seq: g.seq + 1 })); + }; + window.addEventListener("hashchange", onHash); + window.addEventListener("popstate", onHash); + return () => { + window.removeEventListener("hashchange", onHash); + window.removeEventListener("popstate", onHash); + }; + }, []); + + const go = (d: string) => { + setGoto((g) => ({ dir: d, seq: g.seq + 1 })); + setDrawer(false); + }; + + // Dossiers virtuels (Favoris, Personnel, Poubelle) et leurs compteurs. + const loadPlaces = useCallback(() => { + api + .list("") + .then((es) => setPlaces(es.filter((e) => e.special))) + .catch(() => setPlaces([])); + }, []); + useEffect(loadPlaces, [loadPlaces, refreshKey]); + + const onMutated = useCallback(() => { + loadPlaces(); + reloadMe(); + }, [loadPlaces, reloadMe]); + + const trash = places.find((p) => p.special === "poubelle"); + const user = me.user!; + const root = dir.split("/")[0]; + const current = root === PERSO || root === FAVORIS || root === POUBELLE ? root : ""; + + const navItem = (id: string, text: string, icon: React.ReactNode, active: boolean, badge?: number) => ( + + ); + + const usage = me.usage; + const pct = usage && usage.quota > 0 ? Math.min(100, Math.round((usage.used / usage.quota) * 100)) : 0; + + return ( +
+
+ + (e.preventDefault(), go(""))} title={title}> + {me.logo ? : } + {title} + + + + +
+ +
+ {drawer &&
setDrawer(false)} />} + + { + const v = Math.min(SIDEBAR_MAX, Math.max(SIDEBAR_MIN, w)); + setSidebarW(v); + try { + localStorage.setItem("udSidebar", String(v)); + } catch { + /* stockage indisponible */ + } + }} onDragging={setResizing} onReset={() => setSidebarW(SIDEBAR_DEFAULT)} /> +
+ setDrawer(true)} aria-label="Menu" title="Menu"> + + + } + /> +
+
+ + + + {userMenu && ( + setUserMenu(null)}> +
+ {user.name} + {user.email || user.id} + {me.admin && me.mode !== "none" ? "Administrateur" : ""} +
+
+ + + + {me.admin && me.mode !== "none" && ( + <> +
+ + + )} + {me.admin && ( + + )} + {me.logout && ( + <> +
+ + + Se déconnecter + + + )} +
+ )} + + {settings && ( + setSettings(null)} + onChanged={() => { + reloadMe(); + setRefreshKey((k) => k + 1); + }} + /> + )} +
+ ); +} diff --git a/frontend/src/DetailsPanel.tsx b/frontend/src/DetailsPanel.tsx new file mode 100644 index 0000000..8512703 --- /dev/null +++ b/frontend/src/DetailsPanel.tsx @@ -0,0 +1,183 @@ +import { useEffect, useState } from "react"; +import { api, dirname, displayPath, type Entry } from "./api"; +import { CloseIcon, DownloadIcon, EyeIcon, FolderIcon, HistoryIcon, ShareIcon, StarFilledIcon, StarIcon } from "./icons"; +import { FolderGlyph } from "./folderIcons"; +import { FileGlyph, Thumb, thumbSource } from "./FileGlyph"; +import { previewable, typeLabel } from "./filetypes"; +import { fmtDate, fmtSize, plural, who } from "./format"; + +interface Props { + entry: Entry; + onClose: () => void; + onOpen: (e: Entry) => void; + onShare: (e: Entry) => void; + onHistory: (e: Entry) => void; + onFavorite: (e: Entry) => void; + onTag: (t: string) => void; + onLocate: (dir: string) => void; +} + +const Row = ({ label, children }: { label: string; children: React.ReactNode }) => ( +
+
{label}
+
{children}
+
+); + +/** Panneau Détails : propriétés d'un fichier ou d'un dossier, actions rapides. */ +export function DetailsPanel({ entry: e, onClose, onOpen, onShare, onHistory, onFavorite, onTag, onLocate }: Props) { + const d = e.details ?? {}; + const [hash, setHash] = useState(null); + const [hashing, setHashing] = useState(false); + const [hashError, setHashError] = useState(null); + const by = who(e.editedBy); + + useEffect(() => { + setHash(null); + setHashError(null); + }, [e.path, e.modTime]); + + useEffect(() => { + const onKey = (ev: KeyboardEvent) => ev.key === "Escape" && onClose(); + window.addEventListener("keydown", onKey); + return () => window.removeEventListener("keydown", onKey); + }, [onClose]); + + const computeHash = async () => { + setHashing(true); + setHashError(null); + try { + setHash(await api.hash(e.path)); + } catch (err) { + setHashError(err instanceof Error ? err.message : String(err)); + } finally { + setHashing(false); + } + }; + + return ( + + ); +} diff --git a/frontend/src/Dialogs.tsx b/frontend/src/Dialogs.tsx new file mode 100644 index 0000000..d64a59d --- /dev/null +++ b/frontend/src/Dialogs.tsx @@ -0,0 +1,98 @@ +import { useEffect, useRef, useState } from "react"; +import type { ReactNode } from "react"; + +function useEscape(onClose: () => void) { + useEffect(() => { + const onKey = (e: KeyboardEvent) => e.key === "Escape" && onClose(); + window.addEventListener("keydown", onKey); + return () => window.removeEventListener("keydown", onKey); + }, [onClose]); +} + +interface PromptProps { + title: string; + label?: string; + initial?: string; + placeholder?: string; + submit?: string; + /** Sélectionne seulement le nom, sans l'extension (renommage d'un fichier). */ + stem?: boolean; + onSubmit: (value: string) => void; + onClose: () => void; +} + +/** Saisie d'un nom (nouveau dossier, renommage), à la place de prompt(). */ +export function PromptDialog({ title, label, initial = "", placeholder, submit = "Valider", stem, onSubmit, onClose }: PromptProps) { + const [value, setValue] = useState(initial); + const ref = useRef(null); + useEscape(onClose); + + useEffect(() => { + const el = ref.current; + if (!el) return; + el.focus(); + const dot = initial.lastIndexOf("."); + el.setSelectionRange(0, stem && dot > 0 ? dot : initial.length); + }, [initial, stem]); + + const trimmed = value.trim(); + return ( +
+
e.stopPropagation()} + onSubmit={(e) => { + e.preventDefault(); + if (trimmed) onSubmit(trimmed); + }} + > +

{title}

+ +
+ + + +
+
+
+ ); +} + +interface ConfirmProps { + title: string; + children: ReactNode; + confirm: string; + danger?: boolean; + onConfirm: () => void; + onClose: () => void; +} + +/** Confirmation d'une action destructrice, à la place de confirm(). */ +export function ConfirmDialog({ title, children, confirm, danger, onConfirm, onClose }: ConfirmProps) { + useEscape(onClose); + return ( +
+
e.stopPropagation()}> +

{title}

+
{children}
+
+ + + +
+
+
+ ); +} diff --git a/frontend/src/Explorer.tsx b/frontend/src/Explorer.tsx new file mode 100644 index 0000000..fbfd6b8 --- /dev/null +++ b/frontend/src/Explorer.tsx @@ -0,0 +1,1242 @@ +import { useCallback, useEffect, useMemo, useRef, useState } from "react"; +import type { DragEvent, KeyboardEvent, MouseEvent, ReactNode } from "react"; +import { + api, + ApiError, + basename, + dirname, + displayPath, + inFavoris, + inPoubelle, + join, + label, + POUBELLE, + type Entry, + type Hit, + type Me, + type TagCount, +} from "./api"; +import { + CloseIcon, + ClockIcon, + CopyIcon, + DeselectIcon, + DotsIcon, + DownloadIcon, + EditIcon, + EyeIcon, + FolderIcon, + FolderPlusIcon, + FolderUploadIcon, + GalleryIcon, + GridIcon, + HistoryIcon, + InfoIcon, + ListIcon, + MoveIcon, + RefreshIcon, + RestoreIcon, + SearchIcon, + SelectAllIcon, + ShareIcon, + SizeIcon, + SortIcon, + StarFilledIcon, + StarIcon, + TableIcon, + TagIcon, + TrashFullIcon, + TrashIcon, + UpIcon, + UploadIcon, + UserIcon, +} from "./icons"; +import { ActionMenu } from "./ActionMenu"; +import { ConfirmDialog, PromptDialog } from "./Dialogs"; +import { DetailsPanel } from "./DetailsPanel"; +import { FileGlyph, Thumb, thumbSource } from "./FileGlyph"; +import { FolderGlyph } from "./folderIcons"; +import { fmtDate, fmtRelative, fmtSize, plural, who } from "./format"; +import { HistoryDialog } from "./HistoryDialog"; +import { IconDialog } from "./IconDialog"; +import { collectDrop, collectFiles, hasFiles, type Collected } from "./importer"; +import { MoveDialog } from "./MoveDialog"; +import { Preview, type PreviewFile } from "./Preview"; +import { ShareDialog } from "./ShareDialog"; +import { TagsDialog } from "./TagsDialog"; +import { kindOf, previewable, typeLabel } from "./filetypes"; +import { uploads } from "./uploads"; + +/** Liste, détails (tableau), vignettes, ou Galerie (grandes tuiles avec métadonnées). */ +export type View = "list" | "details" | "grid" | "gallery"; + +type SortKey = "name" | "modified" | "size" | "type"; + +const DND_TYPE = "application/x-upandown-paths"; + +const stored = (key: string, allowed: readonly T[], fallback: T): T => { + try { + const v = localStorage.getItem(key) as T | null; + return v && allowed.includes(v) ? v : fallback; + } catch { + return fallback; + } +}; + +const collator = new Intl.Collator("fr", { numeric: true, sensitivity: "base" }); + +/** Rang d'affichage : dossiers virtuels, puis dossiers, puis fichiers. */ +const rank = (e: Entry) => (e.special ? 0 : e.isDir ? 1 : 2); + +const compare = (key: SortKey): ((a: Entry, b: Entry) => number) => { + switch (key) { + case "modified": + return (a, b) => Date.parse(a.modTime) - Date.parse(b.modTime); + case "size": + return (a, b) => a.size - b.size; + case "type": + return (a, b) => collator.compare(typeLabel(a.name), typeLabel(b.name)) || collator.compare(a.name, b.name); + default: + return (a, b) => collator.compare(a.name, b.name); + } +}; + +/** Un élément peut-il être déplacé dans targetDir ? (pas sur place, pas dans lui-même) */ +const canMoveInto = (path: string, targetDir: string) => + dirname(path) !== targetDir && targetDir !== path && !targetDir.startsWith(path + "/"); + +interface Props { + me: Me; + /** Incrémenté par le parent pour forcer un rafraîchissement. */ + refreshKey: number; + /** Navigation demandée par le parent (barre latérale, fil d'Ariane) ; seq change à chaque demande. */ + goto?: { dir: string; seq: number }; + /** Dossier affiché, signalé au parent (adresse de la page). */ + onDirChange: (dir: string) => void; + /** Quelque chose a changé (fichiers, tags, poubelle) : le parent met à jour ses compteurs. */ + onMutated: () => void; + /** Contenu ajouté au début de la barre d'outils (bouton du menu sur mobile). */ + toolbarStart?: ReactNode; +} + +export function Explorer({ me, refreshKey, goto, onDirChange, onMutated, toolbarStart }: Props) { + const [dir, setDir] = useState(""); + const [entries, setEntries] = useState([]); + const [loaded, setLoaded] = useState(false); + const [query, setQuery] = useState(""); + const [results, setResults] = useState(null); + const [view, setView] = useState(() => stored("udView", ["list", "details", "grid", "gallery"], "grid")); + const [sort, setSort] = useState(() => stored("udSort", ["name", "modified", "size", "type"], "name")); + const [desc, setDesc] = useState(() => stored("udDesc", ["0", "1"], "0") === "1"); + const [selected, setSelected] = useState>(new Set()); + const [anchor, setAnchor] = useState(null); + const [menu, setMenu] = useState<{ entry: Hit; anchor: HTMLElement } | null>(null); + const [dropTarget, setDropTarget] = useState(null); + const [error, setError] = useState(null); + const [notice, setNotice] = useState<{ text: string; detail?: string } | null>(null); + const [fileDrag, setFileDrag] = useState(false); + const [tags, setTags] = useState([]); + const [tagFilter, setTagFilter] = useState(null); + const [trashDays, setTrashDays] = useState(null); + + // Dialogues + const [moving, setMoving] = useState(null); + const [tagging, setTagging] = useState(null); + const [iconing, setIconing] = useState(null); + const [sharing, setSharing] = useState(null); + const [history, setHistory] = useState(null); + const [inspect, setInspect] = useState(null); + const [renaming, setRenaming] = useState(null); + const [naming, setNaming] = useState(false); + const [confirming, setConfirming] = useState(null); + const [emptying, setEmptying] = useState(false); + const [previewPath, setPreviewPath] = useState(null); + + const fileInput = useRef(null); + const dirInput = useRef(null); + + const list = results ?? entries; + const favView = !results && inFavoris(dir); + const trashView = !results && inPoubelle(dir); + const locked = favView || trashView; // ni création, ni envoi, ni déplacement + const filtering = query.trim() !== "" || tagFilter !== null; + const gallery = view === "gallery"; + const readonlyHere = !dir.startsWith(".perso") && !locked && me.commonReadonly && !me.admin; + + const shown = useMemo(() => { + if (results) return results; // pertinence : ordre du serveur + const cmp = compare(sort); + return [...entries].sort((a, b) => rank(a) - rank(b) || (a.special ? 0 : (desc ? -1 : 1) * cmp(a, b))); + }, [entries, results, sort, desc]); + const selectable = shown.filter((e) => !e.special); + const files = useMemo(() => shown.filter((e) => !e.isDir && !e.special && !e.broken), [shown]); + + const guard = useCallback(async (fn: () => Promise) => { + setError(null); + try { + await fn(); + } catch (e) { + setError(e instanceof Error ? e.message : String(e)); + } + }, []); + + const closeMenu = useCallback(() => setMenu(null), []); + useEffect(closeMenu, [view, dir, results, closeMenu]); + useEffect(() => setInspect(null), [dir, results === null]); + + const refresh = useCallback( + () => + guard(async () => { + const [next, tagList] = await Promise.all([api.list(dir, gallery || inspect !== null), api.tags()]); + setEntries(next); + setLoaded(true); + setTags(tagList); + setTagFilter((t) => (t && tagList.some((x) => x.name === t) ? t : null)); + setMenu(null); + setSelected((s) => { + if (s.size === 0) return s; + const still = new Set(next.map((e) => e.path)); + return new Set([...s].filter((p) => still.has(p))); + }); + }), + // eslint-disable-next-line react-hooks/exhaustive-deps + [dir, gallery, guard, inspect !== null], + ); + + useEffect(() => { + refresh(); + }, [refresh, refreshKey]); + + // Les envois terminés rafraîchissent l'explorateur. + const refreshRef = useRef(refresh); + refreshRef.current = refresh; + const mutatedRef = useRef(onMutated); + mutatedRef.current = onMutated; + useEffect( + () => + uploads.onDone(() => { + refreshRef.current(); + mutatedRef.current(); + }), + [], + ); + + useEffect(() => { + setSelected(new Set()); + setAnchor(null); + }, [dir, results === null]); + + // Navigation demandée par le parent : recherche et filtre annulés. + useEffect(() => { + if (!goto) return; + setQuery(""); + setTagFilter(null); + setPreviewPath(null); + setDir(goto.dir); + // eslint-disable-next-line react-hooks/exhaustive-deps + }, [goto?.seq]); + + useEffect(() => onDirChange(dir), [dir, onDirChange]); + + // Recherche (texte, tag) avec anti-rebond. + useEffect(() => { + if (!filtering) { + setResults(null); + return; + } + const t = setTimeout(() => guard(async () => setResults(await api.search(query, { tag: tagFilter }, gallery || inspect !== null))), 250); + return () => clearTimeout(t); + // eslint-disable-next-line react-hooks/exhaustive-deps + }, [query, tagFilter, guard, refreshKey, gallery]); + + const reload = async () => { + await refresh(); + if (filtering) setResults(await api.search(query, { tag: tagFilter }, gallery || inspect !== null)); + onMutated(); + }; + + useEffect(() => { + if (!trashView) return; + api + .settings() + .then((s) => setTrashDays(s.trashDays)) + .catch(() => setTrashDays(null)); + }, [trashView, refreshKey]); + + useEffect(() => { + try { + localStorage.setItem("udView", view); + localStorage.setItem("udSort", sort); + localStorage.setItem("udDesc", desc ? "1" : "0"); + } catch { + /* stockage indisponible */ + } + }, [view, sort, desc]); + + // --- Sélection ----------------------------------------------------------- + + const clearSelection = () => { + setSelected(new Set()); + setAnchor(null); + }; + + const toggle = (path: string) => { + setSelected((s) => { + const n = new Set(s); + if (!n.delete(path)) n.add(path); + return n; + }); + setAnchor(path); + }; + + const selectRange = (path: string) => { + const paths = selectable.map((e) => e.path); + const a = anchor ? paths.indexOf(anchor) : -1; + const b = paths.indexOf(path); + if (a < 0 || b < 0) return toggle(path); + const [lo, hi] = a < b ? [a, b] : [b, a]; + setSelected((s) => new Set([...s, ...paths.slice(lo, hi + 1)])); + }; + + const selectAll = () => setSelected(new Set(selectable.map((e) => e.path))); + + const openDir = (path: string) => { + setQuery(""); + setTagFilter(null); + setDir(path); + }; + + const onItemClick = (ev: MouseEvent, e: Entry) => { + if (!e.special) { + if (ev.shiftKey) return selectRange(e.path); + if (trashView) return toggle(e.path); // un élément de la poubelle ne s'ouvre pas + if (ev.ctrlKey || ev.metaKey || selected.size > 0) return toggle(e.path); + } + if (e.broken) return; + if (e.isDir) openDir(e.path); + else setPreviewPath(e.path); + }; + + const onKeyDown = (ev: KeyboardEvent) => { + const t = ev.target as HTMLElement; + if (t.tagName === "INPUT" || t.tagName === "SELECT" || t.tagName === "TEXTAREA") return; + if (ev.key === "Escape" && selected.size > 0) { + ev.preventDefault(); + clearSelection(); + } else if ((ev.ctrlKey || ev.metaKey) && ev.key.toLowerCase() === "a") { + ev.preventDefault(); + selectAll(); + } else if (ev.key === "Delete" && selected.size > 0) { + ev.preventDefault(); + askRemove([...selected]); + } + }; + + // --- Actions ------------------------------------------------------------- + + const newFolder = (name: string) => + guard(async () => { + setNaming(false); + await api.mkdir(join(dir, name)); + await reload(); + }); + + const rename = (e: Entry, name: string) => + guard(async () => { + setRenaming(null); + const to = join(dirname(e.path), name); + if (to !== e.path) await api.move(e.path, to); + await reload(); + }); + + /** Déplace plusieurs éléments dans targetDir ; les échecs partiels sont listés. */ + const moveMany = (paths: string[], targetDir: string) => + guard(async () => { + const todo = paths.filter((p) => canMoveInto(p, targetDir)); + if (todo.length === 0) return; + const res = await api.moveMany(todo, targetDir); + const failed = res.filter((r) => r.error).map((r) => `${basename(r.from)} : ${r.error}`); + clearSelection(); + setMoving(null); + await reload(); + if (failed.length) setError(`${plural(failed.length, "élément")} non déplacé${failed.length > 1 ? "s" : ""} - ${failed.join(" ; ")}`); + }); + + /** Favoris : la sélection devient favorite, sauf si elle l'est déjà entièrement. */ + const toggleFavorite = (items: Entry[]) => + guard(async () => { + const targets = items.filter((e) => !e.special); + if (targets.length === 0) return; + const fav = favView ? false : !targets.every((e) => e.favorite); + await api.setFavorite( + targets.map((e) => e.path), + fav, + ); + setMenu(null); + if (favView) clearSelection(); + await reload(); + }); + + const addFavorites = (paths: string[]) => + toggleFavorite(paths.map((p) => list.find((e) => e.path === p) ?? { name: basename(p), path: p, isDir: false, size: 0, modTime: "" })); + + const duplicate = (e: Entry) => + guard(async () => { + const dot = e.isDir ? -1 : e.name.lastIndexOf("."); + const stem = dot > 0 ? e.name.slice(0, dot) : e.name; + const ext = dot > 0 ? e.name.slice(dot) : ""; + for (let i = 1; i < 100; i++) { + const to = join(dirname(e.path), `${stem} (copie${i > 1 ? ` ${i}` : ""})${ext}`); + try { + await api.copy(e.path, to); + break; + } catch (err) { + if (!(err instanceof ApiError && err.status === 409)) throw err; + } + } + await reload(); + }); + + const askRemove = (paths: string[]) => { + // Dans Favoris, « Supprimer » retire le lien ; l'original reste en place. + if (favView) { + guard(async () => { + await api.setFavorite(paths, false); + clearSelection(); + await reload(); + }); + return; + } + setConfirming(paths); + }; + + const removeMany = (paths: string[]) => + guard(async () => { + setConfirming(null); + for (const p of paths) await api.remove(p, true); + clearSelection(); + await reload(); + }); + + const restoreMany = (paths: string[]) => + guard(async () => { + const res = await api.restoreTrash(paths); + const failed = res.filter((r) => r.error); + const done = res.filter((r) => r.to); + clearSelection(); + await reload(); + if (done.length) { + setNotice({ + text: `${plural(done.length, "élément")} restauré${done.length > 1 ? "s" : ""}`, + detail: done.map((r) => displayPath(r.to!)).join("\n"), + }); + } + if (failed.length) { + const name = (p: string) => list.find((e) => e.path === p)?.name ?? basename(p); + setError(`${plural(failed.length, "élément")} non restauré${failed.length > 1 ? "s" : ""} - ${failed.map((r) => `${name(r.from)} : ${r.error}`).join(" ; ")}`); + } + }); + + const emptyTrash = () => + guard(async () => { + setEmptying(false); + await api.remove(POUBELLE, true); + clearSelection(); + await reload(); + }); + + /** Télécharge : un fichier directement, un dossier ou une sélection en ZIP. */ + const download = (items: Entry[]) => { + if (items.length === 1 && !items[0].isDir) { + const a = document.createElement("a"); + a.href = api.downloadUrl(items[0].path); + a.download = items[0].name; + a.click(); + } else if (items.length === 1) { + location.assign(api.zipUrl(items[0].path)); + } else api.zipSelection(items.map((e) => e.path)); + }; + + /** Envoie fichiers et arborescences dans targetDir (file d'envoi : voir uploads.ts). */ + const sendFiles = (pending: Collected | Promise, targetDir: string) => + guard(async () => { + const c = await pending; + setNotice(null); + if (c.files.length === 0 && c.dirs.length === 0) { + if (c.ignored.length) setNotice({ text: `${plural(c.ignored.length, "élément")} caché${c.ignored.length > 1 ? "s" : ""} ignoré${c.ignored.length > 1 ? "s" : ""}`, detail: c.ignored.join("\n") }); + return; + } + uploads.add(targetDir, c); + if (c.ignored.length) setNotice({ text: `${plural(c.ignored.length, "fichier")} caché${c.ignored.length > 1 ? "s" : ""} ignoré${c.ignored.length > 1 ? "s" : ""} (.DS_Store, .git...)`, detail: c.ignored.join("\n") }); + }); + + // --- Glisser-déposer (souris) ; sur mobile : sélection + « Déplacer vers… » - + + const onDragStart = (ev: DragEvent, e: Entry) => { + const paths = selected.has(e.path) ? [...selected] : [e.path]; + ev.dataTransfer.setData(DND_TYPE, JSON.stringify(paths)); + ev.dataTransfer.effectAllowed = "linkMove"; + if (paths.length > 1) { + const ghost = document.createElement("div"); + ghost.className = "drag-ghost"; + ghost.textContent = plural(paths.length, "élément"); + document.body.appendChild(ghost); + ev.dataTransfer.setDragImage(ghost, 12, 12); + setTimeout(() => ghost.remove()); + } + }; + + // Cibles de dépôt : dossiers, fil d'Ariane et « .. ». Accepte les éléments de + // l'explorateur (déplacement) et les fichiers du système (envoi). + const dropProps = (targetDir: string) => ({ + onDragOver: (ev: DragEvent) => { + const external = hasFiles(ev.dataTransfer); + if (!external && !ev.dataTransfer.types.includes(DND_TYPE)) return; + if (external && (inFavoris(targetDir) || inPoubelle(targetDir))) return; + ev.preventDefault(); + ev.dataTransfer.dropEffect = external ? "copy" : inFavoris(targetDir) ? "link" : "move"; + setDropTarget(targetDir); + }, + onDragLeave: () => setDropTarget(null), + onDrop: (ev: DragEvent) => { + ev.preventDefault(); + ev.stopPropagation(); // l'explorateur n'envoie pas une seconde fois + setDropTarget(null); + setFileDrag(false); + if (hasFiles(ev.dataTransfer)) return sendFiles(collectDrop(ev.dataTransfer), targetDir); + let paths: string[] = []; + try { + paths = JSON.parse(ev.dataTransfer.getData(DND_TYPE)); + } catch { + return; + } + if (inFavoris(targetDir)) addFavorites(paths); + else if (inPoubelle(targetDir)) askRemove(paths); + else moveMany(paths, targetDir); + }, + }); + + const importDir = results || locked ? "" : dir; + + const zoneProps = { + onDragOver: (ev: DragEvent) => { + if (locked || !hasFiles(ev.dataTransfer)) return; + ev.preventDefault(); + ev.dataTransfer.dropEffect = "copy"; + setFileDrag(true); + }, + onDragLeave: (ev: DragEvent) => { + if (!ev.currentTarget.contains(ev.relatedTarget as Node | null)) setFileDrag(false); + }, + onDrop: (ev: DragEvent) => { + if (locked || !hasFiles(ev.dataTransfer)) return; + ev.preventDefault(); + setFileDrag(false); + sendFiles(collectDrop(ev.dataTransfer), importDir); + }, + }; + + // --- Rendu --------------------------------------------------------------- + + const crumbs = dir ? dir.split("/") : []; + const where = (p: string) => displayPath(dirname(p)) || "Racine"; + const deletedInfo = (e: Entry) => + `Supprimé le ${fmtDate(e.modTime)}${e.by ? ` par ${e.by}` : ""}\nEmplacement d'origine : ${e.origin ? where(e.origin) : "inconnu"}`; + + const big = view === "grid" ? 44 : gallery ? 56 : 22; + const thumb = (e: Entry, glyph: number) => ( + api.thumbUrl(e.path, e.modTime), + () => api.downloadUrl(e.path, true), + )} + /> + ); + const icon = (e: Entry) => + e.special ? ( + + {e.special === "favoris" ? : e.special === "poubelle" ? e.count ? : : } + + ) : e.broken ? ( + + + + ) : e.isDir ? ( + + + + ) : trashView ? ( + + + + ) : view === "list" || view === "details" ? ( + kindOf(e.name) === "image" ? ( + thumb(e, 20) + ) : ( + + + + ) + ) : ( + thumb(e, big) + ); + + const previewIndex = previewPath ? files.findIndex((e) => e.path === previewPath) : -1; + const toPreview = (e: Entry): PreviewFile => ({ + name: e.name, + size: e.size, + modTime: e.modTime, + src: api.downloadUrl(e.path, true), + download: api.downloadUrl(e.path), + text: () => api.readText(e.path), + }); + const previewFiles = useMemo(() => (previewIndex >= 0 ? files.map(toPreview) : []), [previewIndex >= 0, files]); // eslint-disable-line react-hooks/exhaustive-deps + + const detailsEntry = inspect ? (shown.find((e) => e.path === inspect) ?? null) : null; + + const menuItems = (e: Hit) => { + if (trashView) { + return ( + <> + +
+ + {deletedInfo(e)} + + ); + } + return ( + <> + {!e.isDir && !e.broken && ( + + )} + {e.isDir && ( + + )} + {!e.broken && ( + + )} + {!e.broken && ( + + )} + {!e.broken && ( + + )} + {favView || results ? ( + !e.broken && ( + + ) + ) : null} + {!favView && ( + <> +
+ + + + + )} + {!e.isDir && !e.broken && ( + + )} + {!e.broken && !favView && ( + + )} + {!e.broken && ( + + )} + {e.isDir && !e.broken && ( + + )} +
+ + {!e.isDir && {fmtSize(e.size)}} + + ); + }; + + const itemClass = (e: Hit) => + ["item", e.isDir ? "dir" : "file", selected.has(e.path) ? "selected" : "", e.special ? "special" : "", e.broken ? "broken" : "", dropTarget === e.path ? "drop" : "", inspect === e.path ? "inspected" : ""].join(" "); + + const checkbox = (e: Hit) => + !e.special && ( + { + ev.stopPropagation(); + if (ev.shiftKey) { + ev.preventDefault(); + selectRange(e.path); + } + }} + onChange={() => toggle(e.path)} + /> + ); + + const moreButton = (e: Hit) => + !e.special && ( + + ); + + const tagChips = (e: Hit) => + !!e.tags?.length && ( + + {e.tags.map((t) => ( + + ))} + + ); + + const dirSummary = (e: Hit) => { + const d = e.details; + if (!d) return null; + const parts = [d.files ? plural(d.files, "fichier") : "", d.dirs ? plural(d.dirs, "dossier") : ""].filter(Boolean); + return {parts.length ? parts.join(" · ") : "vide"}; + }; + + const rowTitle = (e: Hit) => + e.broken ? "Original introuvable : retirer ce favori" : trashView ? deletedInfo(e) : e.special === "poubelle" ? (e.count ? `Poubelle : ${plural(e.count, "élément")}` : "Poubelle vide") : displayPath(e.path); + + const favMark = (e: Hit) => + e.favorite && ( + + + + ); + + /** Liste, vignettes et galerie : une ligne ou une tuile par élément. */ + const item = (e: Hit) => { + const d = e.details ?? {}; + const by = who(e.editedBy); + return ( +
  • +
    onDragStart(ev, e)} {...(e.isDir ? dropProps(e.path) : {})}> + {checkbox(e)} + + {view === "list" && tagChips(e)} + {view === "list" && !e.isDir && {fmtSize(e.size)}} + {view === "list" && (!e.isDir || trashView) && {fmtDate(e.modTime)}} + {gallery && !e.special && {moreButton(e)}} + {!gallery && moreButton(e)} + {gallery && !e.broken && !e.special && ( +
    + {(results || favView) && {where(e.path)}} + {e.isDir ? ( + dirSummary(e) + ) : ( + <> + + + + {fmtRelative(e.modTime)} + {by && · {by}} + + + + + + {fmtSize(e.size)} + + {!!d.width && ( + + {d.width} × {d.height} + + )} + {!!d.versions && ( + + + {d.versions} + + )} + {!!d.shares && ( + + + {d.shares} + + )} + + + )} + {tagChips(e)} + {e.snippet && {e.snippet}} +
    + )} +
    +
  • + ); + }; + + /** Tableau : une ligne par élément, colonnes triables. */ + const row = (e: Hit) => ( + onDragStart(ev, e)} {...(e.isDir ? dropProps(e.path) : {})}> + {checkbox(e)} + + + + {e.isDir || e.special ? "" : fmtSize(e.size)} + + {e.special ? "" : fmtRelative(e.modTime)} + + {trashView ? (e.by ?? "") : who(e.editedBy)} + {e.special ? "" : e.isDir ? "Dossier" : typeLabel(e.name)} + {moreButton(e)} + + ); + + const sortHeader = (key: SortKey, text: string) => ( + + + + ); + + const upItem = !results && dir && ( +
  • +
    + + {gallery && ( +
    + {where(dir)} +
    + )} +
    +
  • + ); + + const emptyText = results ? "Aucun résultat" : favView ? "Aucun favori : étoile ou glisser-déposer un élément ici" : trashView ? "La poubelle est vide" : "Dossier vide"; + + const confirmItems = confirming ? confirming.map((p) => list.find((e) => e.path === p)).filter((e): e is Hit => !!e) : []; + const confirmWhat = + confirming && confirming.length > 1 + ? `${plural(confirming.length, "élément")} (dossiers compris avec leur contenu)` + : confirmItems[0]?.isDir + ? `le dossier « ${confirmItems[0].name} » et tout son contenu` + : `« ${confirmItems[0]?.name ?? (confirming ? basename(confirming[0]) : "")} »`; + + const body = + view === "details" ? ( +
    + 0 ? "selecting" : ""}`}> + + + + {sortHeader("type", "Type")} + + + + {!results && dir && ( + + + + )} + {shown.map(row)} + +
    + {sortHeader("name", "Nom")} + {sortHeader("size", "Taille")} + {sortHeader("modified", "Modifié")} + Par +
    + + +
    + {list.length === 0 && loaded &&

    {emptyText}

    } +
    + ) : ( +
      0 ? "selecting" : ""}`}> + {upItem} + {shown.map(item)} + {list.length === 0 && loaded &&
    • {emptyText}
    • } +
    + ); + + return ( +
    +
    +
    + {toolbarStart} + + + + { + if (ev.target.files) sendFiles(collectFiles(ev.target.files), importDir); + ev.target.value = ""; + }} + /> + { + if (ev.target.files) sendFiles(collectFiles(ev.target.files), importDir); + ev.target.value = ""; + }} + /> +
    + +
    + +
    + {( + [ + ["list", ListIcon, "Liste"], + ["details", TableIcon, "Détails : tableau triable"], + ["grid", GridIcon, "Vignettes"], + ["gallery", GalleryIcon, "Galerie : grandes tuiles et détails"], + ] as const + ).map(([v, Icon, title]) => ( + + ))} +
    + +
    +
    + + {tags.length > 0 && ( +
    + {tags.map((t) => ( + + ))} +
    + )} + +
    + {results ? ( + {plural(results.length, "résultat")} + ) : ( + + )} + {view !== "details" && !results && ( + + )} +
    + + {trashView && ( +
    + {trashDays === null ? "" : trashDays === 0 ? "Conservés jusqu'à suppression définitive" : `Supprimés définitivement après ${plural(trashDays, "jour")}`} + +
    + )} + + {readonlyHere &&
    L'arborescence commune est en lecture seule : déposer dans « Personnel » ou demander à un administrateur.
    } + + {selected.size > 0 && ( +
    + + {plural(selected.size, "sélectionné")} + + {trashView ? ( + + ) : ( + <> + + {selected.size === 1 && ( + + )} + + + + )} + {!locked && ( + + )} + +
    + )} + + {error && ( +
    setError(null)}> + {error} +
    + )} + {notice && ( +
    setNotice(null)} title={notice.detail ? `${notice.detail}\n\n(clic pour masquer)` : "Clic pour masquer"}> + {notice.text} +
    + )} + +
    +
    {body}
    + {detailsEntry && ( + setInspect(null)} + onOpen={(e) => (e.isDir ? openDir(e.path) : setPreviewPath(e.path))} + onShare={setSharing} + onHistory={setHistory} + onFavorite={(e) => toggleFavorite([e])} + onTag={setTagFilter} + onLocate={openDir} + /> + )} +
    + + {fileDrag && ( +
    + + Déposer pour envoyer dans « {importDir ? label(basename(importDir)) : "Racine"} » + Les dossiers sont envoyés avec leur arborescence +
    + )} + + {previewIndex >= 0 && ( + setPreviewPath(files[i].path)} + onClose={() => setPreviewPath(null)} + actions={(f) => { + const e = files.find((x) => x.name === f.name && api.downloadUrl(x.path, true) === f.src); + return ( + e && ( + <> + + + + ) + ); + }} + /> + )} + + {tagging && list.find((e) => e.path === t.path) ?? t)} known={tags} onChanged={reload} onClose={() => setTagging(null)} />} + {iconing && setIconing(null)} />} + {sharing && setSharing(null)} onChanged={() => refresh()} />} + {history && setHistory(null)} onChanged={reload} />} + {moving && setMoving(null)} onConfirm={(target) => moveMany(moving, target)} />} + {naming && setNaming(false)} />} + {renaming && rename(renaming, n)} onClose={() => setRenaming(null)} />} + {confirming && confirming.length > 0 && ( + removeMany(confirming)} + onClose={() => setConfirming(null)} + > + {trashView ?

    Supprimer définitivement {confirmWhat} ? Cette action est irréversible.

    :

    Mettre {confirmWhat} à la poubelle ? Vous pourrez le restaurer depuis la Poubelle.

    } +
    + )} + {emptying && ( + setEmptying(false)}> +

    Supprimer définitivement {plural(list.length, "élément")} ? Cette action est irréversible.

    +
    + )} + + {menu && ( + + {menuItems(menu.entry)} + + )} +
    + ); +} diff --git a/frontend/src/FileGlyph.tsx b/frontend/src/FileGlyph.tsx new file mode 100644 index 0000000..72038e6 --- /dev/null +++ b/frontend/src/FileGlyph.tsx @@ -0,0 +1,64 @@ +import { useState } from "react"; +import { + FileCodeIcon, + FileIcon, + FileImageIcon, + FileMusicIcon, + FilePdfIcon, + FileSheetIcon, + FileSlidesIcon, + FileTextIcon, + FileVideoIcon, + FileZipIcon, +} from "./icons"; +import { browserImage, kindOf, serverThumb, type Kind } from "./filetypes"; + +const glyphs: Record["type"] | ((p: { size?: number }) => React.ReactElement)> = { + image: FileImageIcon, + video: FileVideoIcon, + audio: FileMusicIcon, + pdf: FilePdfIcon, + text: FileTextIcon, + code: FileCodeIcon, + archive: FileZipIcon, + doc: FileTextIcon, + sheet: FileSheetIcon, + slides: FileSlidesIcon, + other: FileIcon, +}; + +/** Icône d'un fichier d'après son type, colorée par famille (classe k-). */ +export function FileGlyph({ name, size = 20 }: { name: string; size?: number }) { + const kind = kindOf(name); + const Icon = glyphs[kind] as (p: { size?: number }) => React.ReactElement; + return ( + + + + ); +} + +/** Taille au-delà de laquelle une image n'est pas chargée telle quelle comme miniature. */ +const MAX_DIRECT = 12 << 20; + +/** + * Adresse d'une miniature : miniature du serveur pour JPEG, PNG et GIF, l'image + * elle-même pour les autres formats du navigateur (WebP, SVG...) si elle est + * raisonnable, sinon rien (icône de type). + */ +export const thumbSource = (name: string, size: number, thumb: () => string, direct: () => string): string | null => { + if (serverThumb(name)) return thumb(); + if (browserImage(name) && size <= MAX_DIRECT) return direct(); + return null; +}; + +/** Miniature d'image avec repli sur l'icône du type (format illisible, erreur de chargement). */ +export function Thumb({ name, src, glyph = 40, className = "" }: { name: string; src: string | null; glyph?: number; className?: string }) { + const [failed, setFailed] = useState(null); + const ok = src && failed !== src; + return ( + + {ok ? setFailed(src)} /> : } + + ); +} diff --git a/frontend/src/HistoryDialog.tsx b/frontend/src/HistoryDialog.tsx new file mode 100644 index 0000000..1bf3497 --- /dev/null +++ b/frontend/src/HistoryDialog.tsx @@ -0,0 +1,99 @@ +import { useCallback, useEffect, useState } from "react"; +import { api, type Version } from "./api"; +import { DownloadIcon, HistoryIcon, RestoreIcon } from "./icons"; +import { fmtDate, fmtRelative, fmtSize } from "./format"; + +interface Props { + path: string; + name: string; + onClose: () => void; + /** Appelé après une restauration (le fichier a changé). */ + onChanged: () => void; +} + +/** Versions antérieures d'un fichier : téléchargement, restauration, création d'une version à la demande. */ +export function HistoryDialog({ path, name, onClose, onChanged }: Props) { + const [versions, setVersions] = useState(null); + const [busy, setBusy] = useState(false); + const [error, setError] = useState(null); + const [notice, setNotice] = useState(null); + + const load = useCallback(() => api.history(path).then(setVersions).catch((e) => setError(e.message)), [path]); + useEffect(() => { + load(); + }, [load]); + + useEffect(() => { + const onKey = (e: KeyboardEvent) => e.key === "Escape" && onClose(); + window.addEventListener("keydown", onKey); + return () => window.removeEventListener("keydown", onKey); + }, [onClose]); + + const run = async (fn: () => Promise, done?: string) => { + setBusy(true); + setError(null); + setNotice(null); + try { + await fn(); + await load(); + if (done) setNotice(done); + } catch (e) { + setError(e instanceof Error ? e.message : String(e)); + } finally { + setBusy(false); + } + }; + + return ( +
    +
    e.stopPropagation()}> +

    Historique · {name}

    +

    + Quand un fichier est remplacé, son contenu précédent est conservé ici. Restaurer une version garde l'état actuel dans l'historique : l'opération s'annule. +

    + {error &&
    {error}
    } + {notice &&
    {notice}
    } +
      + {versions?.map((v) => ( +
    • + +
      + {fmtRelative(v.time)} + + {" "} + · {fmtDate(v.time)} · {fmtSize(v.size)} + +
      + + + + +
    • + ))} + {versions && versions.length === 0 &&
    • Aucune version antérieure.
    • } + {!versions && !error &&
    • Chargement…
    • } +
    +
    + + + +
    +
    +
    + ); +} diff --git a/frontend/src/IconDialog.tsx b/frontend/src/IconDialog.tsx new file mode 100644 index 0000000..3174504 --- /dev/null +++ b/frontend/src/IconDialog.tsx @@ -0,0 +1,76 @@ +import { useEffect, useState } from "react"; +import { api, type Entry } from "./api"; +import { FOLDER_ICONS, FolderGlyph } from "./folderIcons"; + +interface Props { + /** Dossiers concernés. */ + items: Entry[]; + /** Appelé après le changement pour rafraîchir l'explorateur. */ + onChanged: () => Promise; + onClose: () => void; +} + +/** Choix de l'icône d'un ou plusieurs dossiers (partagée par tous les utilisateurs). */ +export function IconDialog({ items, onChanged, onClose }: Props) { + const [busy, setBusy] = useState(false); + const [error, setError] = useState(null); + // Icône commune aux dossiers (sinon aucune n'est marquée). + const current = items.every((e) => (e.icon ?? "") === (items[0].icon ?? "")) ? (items[0].icon ?? "") : null; + + useEffect(() => { + const onKey = (e: KeyboardEvent) => e.key === "Escape" && onClose(); + window.addEventListener("keydown", onKey); + return () => window.removeEventListener("keydown", onKey); + }, [onClose]); + + const choose = async (name: string) => { + setBusy(true); + setError(null); + try { + await api.setIcon( + items.map((e) => e.path), + name, + ); + await onChanged(); + onClose(); + } catch (e) { + setError(e instanceof Error ? e.message : String(e)); + setBusy(false); + } + }; + + const title = items.length === 1 ? `Icône · ${items[0].name}` : `Icône · ${items.length} dossiers`; + const choice = (name: string, label: string) => ( + + ); + + return ( +
    +
    e.stopPropagation()}> +

    {title}

    +
    + {choice("", "Par défaut")} + {FOLDER_ICONS.map((i) => choice(i.name, i.label))} +
    + {error &&
    {error}
    } +
    + + +
    +
    +
    + ); +} diff --git a/frontend/src/Login.tsx b/frontend/src/Login.tsx new file mode 100644 index 0000000..721b519 --- /dev/null +++ b/frontend/src/Login.tsx @@ -0,0 +1,126 @@ +import { useState } from "react"; +import { api, ApiError, type Me } from "./api"; +import { CloudUpIcon } from "./icons"; + +interface Props { + me: Me; + /** Connexion ou inscription réussie (session ouverte) : recharge l'application. */ + onLoggedIn: () => void; +} + +/** Page de connexion : compte local, inscription (selon le mode choisi par l'administrateur) et bouton OIDC. */ +export function Login({ me, onLoggedIn }: Props) { + const canRegister = me.local && (me.registration !== "closed" || !!me.setup); + const [mode, setMode] = useState<"login" | "register">(me.setup ? "register" : "login"); + const [f, setF] = useState({ username: "", name: "", email: "", password: "", confirm: "" }); + const [busy, setBusy] = useState(false); + const [error, setError] = useState(null); + const [info, setInfo] = useState(null); + const title = me.title || "Up And Down"; + const next = encodeURIComponent(location.pathname + location.search + location.hash); + + const set = (k: keyof typeof f) => (e: React.ChangeEvent) => setF({ ...f, [k]: e.target.value }); + + const submit = async (e: React.FormEvent) => { + e.preventDefault(); + setError(null); + setInfo(null); + if (mode === "register" && f.password !== f.confirm) { + setError("Les deux mots de passe sont différents."); + return; + } + setBusy(true); + try { + if (mode === "login") { + await api.login(f.username, f.password); + onLoggedIn(); + } else { + const status = await api.register({ username: f.username, name: f.name, email: f.email, password: f.password }); + if (status === "pending") { + setInfo("Compte créé. Un administrateur doit le valider avant votre première connexion."); + setMode("login"); + setF({ ...f, password: "", confirm: "" }); + } else onLoggedIn(); + } + } catch (err) { + if (err instanceof ApiError && err.code === "pending") setInfo("Votre compte est en attente de validation par un administrateur."); + else setError(err instanceof Error ? err.message : String(err)); + } finally { + setBusy(false); + } + }; + + return ( +
    +
    +
    + {me.logo ? : } +

    {title}

    +

    Envoyez, rangez et partagez vos fichiers.

    +
    + + {me.setup && ( +
    + Première utilisation. Le compte créé ici devient l'administrateur. +
    + )} + {info &&
    {info}
    } + {error &&
    {error}
    } + + {me.local && ( +
    + {canRegister && !me.setup && ( +
    + + +
    + )} + + {mode === "register" && ( + <> + + + + )} + + {mode === "register" && ( + + )} + + {mode === "register" && me.registration === "approval" && !me.setup &&

    Votre compte devra être validé par un administrateur.

    } +
    + )} + + {me.oidc && ( + <> + {me.local &&
    ou
    } + + Se connecter avec {me.oidcName || "SSO"} + + + )} +
    +
    + ); +} diff --git a/frontend/src/MoveDialog.tsx b/frontend/src/MoveDialog.tsx new file mode 100644 index 0000000..c47019c --- /dev/null +++ b/frontend/src/MoveDialog.tsx @@ -0,0 +1,100 @@ +import { useEffect, useState } from "react"; +import { api, basename, dirname, join, label, type Entry } from "./api"; +import { FolderIcon, FolderPlusIcon } from "./icons"; +import { PromptDialog } from "./Dialogs"; + +interface Props { + /** Éléments à déplacer. */ + paths: string[]; + startDir: string; + onCancel: () => void; + onConfirm: (dir: string) => void; +} + +/** Sélecteur de dossier de destination (utilisable au doigt comme à la souris). */ +export function MoveDialog({ paths, startDir, onCancel, onConfirm }: Props) { + const [dir, setDir] = useState(startDir); + const [folders, setFolders] = useState([]); + const [error, setError] = useState(null); + const [naming, setNaming] = useState(false); + + useEffect(() => { + let live = true; + setError(null); + api + .list(dir) + .then((es) => live && setFolders(es.filter((e) => e.isDir && e.special !== "favoris" && e.special !== "poubelle"))) + .catch((e) => live && setError(e.message)); + return () => { + live = false; + }; + }, [dir]); + + useEffect(() => { + const onKey = (e: KeyboardEvent) => e.key === "Escape" && !naming && onCancel(); + window.addEventListener("keydown", onKey); + return () => window.removeEventListener("keydown", onKey); + }, [onCancel, naming]); + + // Un dossier déplacé ne peut pas recevoir son propre contenu. + const blocked = (p: string) => paths.some((m) => p === m || p.startsWith(m + "/")); + const crumbs = dir ? dir.split("/") : []; + + const newFolder = async (name: string) => { + setNaming(false); + try { + const e = await api.mkdir(join(dir, name)); + setDir(e.path); + } catch (err) { + setError(err instanceof Error ? err.message : String(err)); + } + }; + + const title = paths.length === 1 ? `Déplacer « ${basename(paths[0])} »` : `Déplacer ${paths.length} éléments`; + + return ( +
    +
    e.stopPropagation()}> +

    {title}

    + + {error &&
    {error}
    } +
      + {folders.map((f) => ( +
    • + +
    • + ))} + {folders.length === 0 &&
    • Aucun sous-dossier
    • } +
    +
    + + + + +
    +
    + {naming && setNaming(false)} />} +
    + ); +} diff --git a/frontend/src/Preview.tsx b/frontend/src/Preview.tsx new file mode 100644 index 0000000..6b4bf99 --- /dev/null +++ b/frontend/src/Preview.tsx @@ -0,0 +1,163 @@ +import { useEffect, useState } from "react"; +import type { ReactNode } from "react"; +import { createPortal } from "react-dom"; +import { ChevronLeftIcon, ChevronRightIcon, CloseIcon, DownloadIcon, ExpandIcon } from "./icons"; +import { FileGlyph } from "./FileGlyph"; +import { kindOf, monospace, previewable, typeLabel } from "./filetypes"; +import { fmtDate, fmtSize } from "./format"; + +/** Fichier à prévisualiser : adresses d'affichage et de téléchargement fournies par l'appelant. */ +export interface PreviewFile { + name: string; + size: number; + modTime: string; + /** Adresse d'affichage en ligne (images, vidéo, PDF). */ + src: string; + download: string; + /** Lit le début du contenu texte. */ + text: () => Promise<{ text: string; truncated: boolean }>; +} + +interface Props { + files: PreviewFile[]; + index: number; + onIndex: (i: number) => void; + onClose: () => void; + /** Boutons supplémentaires de la barre (partage, détails...). */ + actions?: (file: PreviewFile) => ReactNode; +} + +/** Visionneuse plein écran : image, vidéo, audio, PDF, texte ; navigation ←/→ entre les fichiers du dossier. */ +export function Preview({ files, index, onIndex, onClose, actions }: Props) { + const file = files[index]; + const many = files.length > 1; + + useEffect(() => { + const onKey = (e: KeyboardEvent) => { + if ((e.target as HTMLElement).tagName === "INPUT") return; + if (e.key === "Escape") onClose(); + else if (e.key === "ArrowLeft" && index > 0) onIndex(index - 1); + else if (e.key === "ArrowRight" && index < files.length - 1) onIndex(index + 1); + else return; + e.preventDefault(); + }; + window.addEventListener("keydown", onKey); + return () => window.removeEventListener("keydown", onKey); + }, [index, files.length, onIndex, onClose]); + + if (!file) return null; + return createPortal( +
    +
    + + +
    + {file.name} + + {typeLabel(file.name)} · {fmtSize(file.size)} · {fmtDate(file.modTime)} + {many && ` · ${index + 1}/${files.length}`} + +
    + + {actions?.(file)} + + + Télécharger + +
    +
    e.target === e.currentTarget && onClose()}> + {many && index > 0 && ( + + )} + + {many && index < files.length - 1 && ( + + )} +
    +
    , + document.body, + ); +} + +function Viewer({ file }: { file: PreviewFile }) { + const kind = kindOf(file.name); + const [zoom, setZoom] = useState(false); + const [error, setError] = useState(false); + + if (!previewable(file.name) || error) { + return ( +
    + +

    + {file.name} +

    +

    {error ? "Impossible d'afficher ce fichier dans le navigateur." : "Pas d'aperçu pour ce type de fichier."}

    + + + Télécharger ({fmtSize(file.size)}) + +
    + ); + } + switch (kind) { + case "image": + return ( +
    + {file.name} setZoom((z) => !z)} onError={() => setError(true)} draggable={false} /> + +
    + ); + case "video": + return