From 23cdd88e11e44deb62336b1c42bcf40321cdcf56 Mon Sep 17 00:00:00 2001 From: Gabriel20xx Date: Wed, 23 Sep 2026 15:48:17 +0200 Subject: [PATCH] Sync shared snapshot from a348409 --- shared/README.md | 34 ++++++++++- .../carriernodeclient/carriernodeclient.go | 5 ++ shared/backend/mediacore/mediacore.go | 56 +++++++++++++------ shared/backend/mediacore/migrate.go | 6 ++ 4 files changed, 82 insertions(+), 19 deletions(-) diff --git a/shared/README.md b/shared/README.md index 6f33417..85a2f62 100644 --- a/shared/README.md +++ b/shared/README.md @@ -20,13 +20,45 @@ The single source of truth for code reused across every project in this workspac | Package | Language | Purpose | |---|---|---| | `@gabriel20xx/design-tokens` | CSS | Colors, typography, spacing, radii, shadows, light/dark theme variables. | -| `@gabriel20xx/web-ui` | Svelte | Application shell, header/navigation, auth screens, dialogs, buttons, cards, badges. | +| `@gabriel20xx/web-ui` | Svelte | Shared application shell and reusable UI components. The complete public component inventory is documented below. | | `@gabriel20xx/legacy-assets` | Browser JS/CSS | Legacy client-side assets, kept for a handful of older pages. | | `repos.gfranz.ch/Gabriel20xx/shared/backend` | Go | Env config, `pgx` pools/transactions, auth persistence, an AuthGuard client (`authclient`), log shipping (`logshipper`), embedded Goose migrations, and the media-family's shared route/table surface (`mediaauth`, `mediacore`, `carriernodeclient`, `syncsocket`). | | `@gabriel20xx/node-backend` | Node.js | `pg` pool/config/transactions/migrations, auth/session persistence, an AuthGuard client. | | `gabriel20xx-shared-backend` | Python | `asyncpg` pool/config, auth/session persistence, an AuthGuard client. | | `com.gabriel20xx.shared.auth` | Java | An AuthGuard client, mirroring the Go/Node/Python ones. | +### Public `web-ui` components + +These are the complete Svelte component exports from `packages/web-ui/src/lib/index.ts` (23 components): + +| Component | Includes | +|---|---| +| `AboutDialog` | About modal with application branding, description, version, links, and custom content. | +| `AppShell` | Application layout that composes the header, page header, notification stack, theme, and primary-color handling. | +| `AuthPage` | Login, first-time setup, password-reset, and optional TOTP authentication flows. | +| `Badge` | Small inline label with default, primary, success, warning, and danger variants. | +| `Button` | Button with primary, secondary, outline, ghost, and danger variants; multiple sizes and full-width mode. | +| `Card` | Styled content section for grouping application content. | +| `Dialog` | Generic modal dialog with title, description, body, footer, and bindable open state. | +| `EmptyState` | Empty-content message with an inbox icon, title, and description. | +| `Header` | Branded application header with navigation, icons, actions, profile/settings menus, and logout. | +| `MediaPlayer` | Audio/video player with playback, seeking, volume, quality, fullscreen, keyboard controls, and custom end controls. | +| `MediaPlayerControls` | Reusable media controls for playback, seeking, volume, quality, fullscreen, optional graph toggling, and custom end controls. | +| `Metric` | Labeled metric/value display with optional detail and semantic variants. | +| `NotificationStack` | Global stack of dismissible success, error, warning, and informational notifications. | +| `PageHeader` | Page title with optional subtitle/description, child content, and action area. | +| `Pagination` | Page navigation and page-size selection with total/item counts. | +| `PrimaryColorPicker` | Per-project primary-color selector backed by the shared color persistence helpers. | +| `ProfileDialog` | Profile username/email/password editing and TOTP settings. | +| `SectionTitle` | Section heading with optional description. | +| `SettingsDialog` | Generic settings modal with custom content or a default empty-settings message. | +| `StatusDialog` | Detailed service health/readiness status modal with refresh support. | +| `StatusWidget` | Header-friendly health/readiness indicator that polls `/healthz` and `/ready` and opens `StatusDialog`. | +| `TotpSettings` | TOTP status, setup, enable, and disable controls. | +| `UserManagement` | Role-aware user administration with listing, creation, editing, deletion, project scopes, and pagination. | + +This inventory describes the public component API only; the package also exports notification helpers, primary-color helpers, and TypeScript types. When a public component is added, removed, renamed, or materially changes responsibility, update this table in the same change as `packages/web-ui/src/lib/index.ts`. Keep the table aligned with that barrel file, and do not add internal or generated components to it. + The `web-ui` components don't import `$app/state`, `$lib` stores, or a project-specific API — applications provide those through props and callbacks. --- diff --git a/shared/backend/carriernodeclient/carriernodeclient.go b/shared/backend/carriernodeclient/carriernodeclient.go index 4495adf..e106b98 100644 --- a/shared/backend/carriernodeclient/carriernodeclient.go +++ b/shared/backend/carriernodeclient/carriernodeclient.go @@ -505,6 +505,11 @@ type ProbeResult struct { DurationMs int64 `json:"durationMs"` Width int `json:"width"` Height int `json:"height"` + IsVR bool `json:"isVr"` + // Pointers keep the distinction between a newer CarrierNode explicitly + // reporting false and an older one that does not return these fields yet. + HasVideo *bool `json:"hasVideo"` + HasAudio *bool `json:"hasAudio"` } func (c *Client) probeMediaOne(ctx context.Context, baseURL, relative string) (ProbeResult, error) { diff --git a/shared/backend/mediacore/mediacore.go b/shared/backend/mediacore/mediacore.go index e148329..86fc629 100644 --- a/shared/backend/mediacore/mediacore.go +++ b/shared/backend/mediacore/mediacore.go @@ -43,6 +43,7 @@ import ( "time" "github.com/go-chi/chi/v5" + "github.com/jackc/pgx/v5/pgtype" "github.com/jackc/pgx/v5/pgxpool" sharedauth "repos.gfranz.ch/Gabriel20xx/shared/backend/auth" @@ -152,22 +153,25 @@ func (c *Core) putSyncState(w http.ResponseWriter, r *http.Request) { // MediaRecord is one row of the shared `media` table. type MediaRecord struct { - ID int64 - MediaKey string - MediaType string - Title *string - Description *string - FilePath string - OriginalName string - Source string - Width *int - Height *int - DurationMs *int64 - SizeBytes *int64 - IsVR bool - HasFunscript bool - Speed *float32 - ModifiedAt time.Time + ID int64 + MediaKey string + MediaType string + Title *string + Description *string + FilePath string + OriginalName string + Source string + Width *int + Height *int + DurationMs *int64 + SizeBytes *int64 + IsVR bool + HasFunscript bool + FunscriptActionCount *int + FunscriptAvgSpeed *float32 + FunscriptMaxSpeed *float32 + Speed *float32 + ModifiedAt time.Time } func (c *Core) streamMediaByQuery(w http.ResponseWriter, r *http.Request) { @@ -725,15 +729,30 @@ func (c *Core) findMedia(ctx context.Context, identifier string) (MediaRecord, e SELECT id, media_key, COALESCE(media_type, 'unknown'), COALESCE(title, ''), COALESCE(description, ''), COALESCE(NULLIF(file_path, ''), media_key), COALESCE(original_filename, ''), COALESCE(source, 'Filesystem'), COALESCE(width, 0), COALESCE(height, 0), COALESCE(duration_ms, 0), COALESCE(size_bytes, 0), - COALESCE(is_vr, FALSE), COALESCE(has_funscript, FALSE), COALESCE(speed, 0), COALESCE(modified_at, created_at) + COALESCE(is_vr, FALSE), COALESCE(has_funscript, FALSE), funscript_action_count, + funscript_avg_speed, funscript_max_speed, COALESCE(speed, 0), COALESCE(modified_at, created_at) FROM media WHERE media_key=$1 OR CAST(id AS TEXT)=$1 LIMIT 1`, identifier) var title, description string var width, height int var duration, size int64 + var funscriptActionCount pgtype.Int4 + var funscriptAvgSpeed, funscriptMaxSpeed pgtype.Float4 var speed float32 - if err := row.Scan(&record.ID, &record.MediaKey, &record.MediaType, &title, &description, &record.FilePath, &record.OriginalName, &record.Source, &width, &height, &duration, &size, &record.IsVR, &record.HasFunscript, &speed, &record.ModifiedAt); err != nil { + if err := row.Scan(&record.ID, &record.MediaKey, &record.MediaType, &title, &description, &record.FilePath, &record.OriginalName, &record.Source, &width, &height, &duration, &size, &record.IsVR, &record.HasFunscript, &funscriptActionCount, &funscriptAvgSpeed, &funscriptMaxSpeed, &speed, &record.ModifiedAt); err != nil { return MediaRecord{}, err } + if funscriptActionCount.Valid { + value := int(funscriptActionCount.Int32) + record.FunscriptActionCount = &value + } + if funscriptAvgSpeed.Valid { + value := funscriptAvgSpeed.Float32 + record.FunscriptAvgSpeed = &value + } + if funscriptMaxSpeed.Valid { + value := funscriptMaxSpeed.Float32 + record.FunscriptMaxSpeed = &value + } if title != "" { record.Title = &title } @@ -778,6 +797,7 @@ func (record MediaRecord) ToJSON() map[string]any { "url": mediaStreamURL(record.MediaKey), "thumbnail": mediaThumbnailURL(record.MediaKey), "width": intValue(record.Width), "height": intValue(record.Height), "durationMs": int64Value(record.DurationMs), "sizeBytes": int64Value(record.SizeBytes), "isVr": record.IsVR, "hasFunscript": record.HasFunscript, "speed": floatValue(record.Speed), + "funscriptActionCount": intValue(record.FunscriptActionCount), "funscriptAvgSpeed": floatValue(record.FunscriptAvgSpeed), "funscriptMaxSpeed": floatValue(record.FunscriptMaxSpeed), "modifiedAt": record.ModifiedAt, } } diff --git a/shared/backend/mediacore/migrate.go b/shared/backend/mediacore/migrate.go index ad457e5..eac783c 100644 --- a/shared/backend/mediacore/migrate.go +++ b/shared/backend/mediacore/migrate.go @@ -73,10 +73,16 @@ var migrationStatements = []string{ size_bytes BIGINT, is_vr BOOLEAN NOT NULL DEFAULT FALSE, has_funscript BOOLEAN NOT NULL DEFAULT FALSE, + funscript_action_count INT, + funscript_avg_speed REAL, + funscript_max_speed REAL, speed REAL, created_at TIMESTAMPTZ NOT NULL DEFAULT NOW(), modified_at TIMESTAMPTZ NOT NULL DEFAULT NOW() )`, + `ALTER TABLE media ADD COLUMN IF NOT EXISTS funscript_action_count INT`, + `ALTER TABLE media ADD COLUMN IF NOT EXISTS funscript_avg_speed REAL`, + `ALTER TABLE media ADD COLUMN IF NOT EXISTS funscript_max_speed REAL`, `CREATE INDEX IF NOT EXISTS media_active_idx ON media (active)`, `CREATE INDEX IF NOT EXISTS media_file_path_idx ON media (file_path)`, `CREATE INDEX IF NOT EXISTS media_search_idx ON media USING GIN (to_tsvector('simple', COALESCE(title, '') || ' ' || COALESCE(original_filename, '') || ' ' || COALESCE(file_path, '')))`,