22 Commits
Author SHA1 Message Date
Gabriel20xx fa69e6ef3c feat: add Pagination component to shared web-ui
AutoCode's actions page depends on a Pagination component that only
ever existed in its consumer-side shared/ snapshot, never in this
canonical repo. Every sync-consumers.ps1 run deleted it as stale,
repeatedly breaking AutoCode's lint and Docker builds. Adding it here
makes the sync idempotent instead of destructive.
2026-08-29 12:58:27 +02:00
Gabriel20xx 91f372612a Fix stale consumer project path for HordeWorker
The folder was renamed from HordeWorkerReGen to HordeWorker; the sync
script's project list still pointed at the old name, so that consumer
silently stopped receiving shared-package syncs.
2026-08-29 12:42:48 +02:00
Gabriel20xx 3f5ff73a49 Standardize AppShell container gaps to 16px
The page title box and the content below it (e.g. a search/filter
panel) were separated by 24px, and main had 32px/48px top/bottom
padding around that stack. Both now use a consistent 16px.
2026-08-29 12:31:15 +02:00
Gabriel20xx fc0e376df8 feat: add NotificationStack component and notify API for toast notifications 2026-08-27 13:32:13 +02:00
Gabriel20xx d005ee6f51 feat: implement notification system with customizable message handling 2026-08-27 13:29:34 +02:00
Gabriel20xx e8a9b25037 fix: update setup handling logic to improve account creation flow 2026-08-23 22:18:20 +02:00
Gabriel20xx 4227293345 fix: adjust visited color for profile menu items to maintain consistency 2026-08-20 17:03:14 +02:00
Gabriel20xxandClaude Sonnet 5 a53bafff3f feat: add admin dialog and move user management out of settings/profile modals
- Add a dedicated admin entry (with icon) to the header profile dropdown, visible only to admins
- Move all user-management settings from SettingsDialog/ProfileDialog into a new AdminDialog
- Export AdminDialog from the package index

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
2026-08-20 14:02:16 +02:00
Gabriel20xx c94f749430 fix: reformat config.py to match its declared 100-column line length
One line was wrapped as if for an 88-column budget, violating the
100-column ruff line-length this package declares in its own
pyproject.toml - ruff format (which respects that nested config)
correctly flagged it as unformatted.
2026-08-19 13:04:17 +02:00
Gabriel20xx a90f4eb71f fix: give header brand icon a fixed size
The brand <img> sized itself with width/height:100%, but it isn't
wrapped in a sized container like the fallback letter-mark is, and its
flex-item parent has no definite size for the percentage to resolve
against - so it rendered at whatever intrinsic size the favicon
happened to report instead of a consistent icon size.
2026-08-19 12:06:17 +02:00
Gabriel20xx 6c364623fd feat: add icons to profile menu items
- Simplify brand logo markup
- Add profile, settings, and about icons
2026-08-14 07:33:11 +00:00
Gabriel20xx 5ebaafc113 fix: center mobile menu button in header 2026-08-12 06:57:12 +00:00
Gabriel20xx 61bed33c8a Reading additional input from stdin...
OpenAI Codex v0.147.0
--------
workdir: /workspace/Personal/Web/shared
model: gpt-5.6-luna
provider: openai
approval: never
sandbox: read-only
reasoning effort: xhigh
reasoning summaries: none
session id: 019febcc-0ed6-7d22-87cb-e6ad13926ec6
--------
user
Write a concise git commit message for the following diff. Use the Conventional Commits style (e.g. "feat: ...", "fix: ..."), a summary line under 72 characters, optionally followed by a blank line and up to 3 short bullet points for notable details. Output only the commit message itself - no preamble, no explanation, no markdown fences.

diff --git a/scripts/sync-consumers.ps1 b/scripts/sync-consumers.ps1
index fd6591f..1895c21 100644
--- a/scripts/sync-consumers.ps1
+++ b/scripts/sync-consumers.ps1
@@ -103,7 +103,12 @@ function Convert-ToConsumerWebUiPackage {

     $manifest = Get-Content -LiteralPath $PackagePath -Raw | ConvertFrom-Json
     $manifest.files = @('src', 'README.md')
-    $manifest.dependencies = [pscustomobject]@{}
+    if ($null -ne $manifest.dependencies) {
+        $designTokensDependency = $manifest.dependencies.PSObject.Properties['@gabriel20xx/design-tokens']
+        if ($null -ne $designTokensDependency) {
+            $manifest.dependencies.PSObject.Properties.Remove('@gabriel20xx/design-tokens')
+        }
+    }
     $manifest.svelte = './src/index.ts'
     $manifest.types = './src/index.ts'

@@ -133,6 +138,7 @@ function Convert-ToConsumerWebUiSources {
     if (Test-Path -LiteralPath $stylesPath) {
         $styles = Get-Content -LiteralPath $stylesPath -Raw
         $styles = $styles.Replace("@import '@gabriel20xx/design-tokens/theme.css';", "@import '../../../design-tokens/theme.css';")
+        $styles = $styles.Replace('@import "@gabriel20xx/design-tokens/theme.css";', "@import '../../../design-tokens/theme.css';")
         Write-Utf8NoBom -Path $stylesPath -Content $styles
     }

warning: Codex could not find bubblewrap on PATH. Install bubblewrap with your OS package manager. See the sandbox prerequisites: https://developers.openai.com/codex/concepts/sandboxing#prerequisites. Codex will use the bundled bubblewrap in the meantime.
codex
fix: preserve consumer dependencies and rewrite token imports

- Remove only the design-tokens dependency
- Support single- and double-quoted CSS imports
tokens used
10,345
fix: preserve consumer dependencies and rewrite token imports

- Remove only the design-tokens dependency
- Support single- and double-quoted CSS imports
2026-08-10 13:10:54 +00:00
Gabriel20xx 81077527ac Add favicon support and loading state to authentication components 2026-08-10 10:42:40 +02:00
Gabriel20xx d0b18a4902 Update shared web UI auth and profile menu 2026-08-09 10:34:06 +02:00
Gabriel20xx e3544617e1 Enhance web-ui components and styles with new features and dependencies
- Added @lucide/svelte as a dependency for icon support in various components.
- Updated AboutDialog, AppShell, AuthPage, Header, SettingsDialog, and styles for improved functionality and UI consistency.
- Introduced new props and state management for better user experience.
- Refactored CSS for cleaner styling and improved layout.
2026-08-07 15:18:50 +02:00
Gabriel20xx ce6db8a457 Bump package versions to 0.1.1 and update npm publish workflow with registry authentication 2026-08-06 21:35:49 +02:00
Gabriel20xx da1cdca3b2 Rename shared code references 2026-08-06 16:55:51 +02:00
Gabriel20xx df68167d04 Fix Windows Git hook launcher 2026-08-06 16:09:51 +02:00
Gabriel20xx 9a79e6f649 Add automatic SharedCode consumer synchronization 2026-08-06 16:09:41 +02:00
Gabriel20xx dfae1cb572 Bump Go and Python package release to 0.1.1
Publish npm packages / Publish shared npm packages (push) Failing after 39s
Publish Python package / Publish shared Python package (push) Successful in 12s
Publish Go package / Publish shared Go module (push) Successful in 57s
2026-08-06 12:12:04 +02:00
Gabriel20xx 752f3ba433 Fix Go and Python package publishing workflows 2026-08-06 12:07:26 +02:00
31 changed files with 1665 additions and 199 deletions

No files matched your search

+5
View File
@@ -0,0 +1,5 @@
---
"@gabriel20xx/web-ui": minor
---
Add a shared `NotificationStack` component and `notify` API (`notify.success/error/warning/info`) for toast-style action feedback. `AppShell` now mounts `NotificationStack` automatically, so any application using `AppShell` gets it without further wiring.
+23 -5
View File
@@ -38,9 +38,10 @@ jobs:
RELEASE_TAG: ${{ github.event_name == 'release' && github.event.release.tag_name || github.ref_name }}
run: |
package_directory='gitea-go-package'
rm -rf "$package_directory"
mkdir -p "$package_directory"
bash scripts/package-go-module.sh "$RELEASE_TAG" "$package_directory"
mkdir -p "$RUNNER_TEMP/gitea-go-package"
cp "$package_directory"/*.zip "$RUNNER_TEMP/gitea-go-package/"
find "$package_directory" -maxdepth 1 -type f -name '*.zip' -print -quit | grep -q .
- name: Publish to Gitea Package Registry
env:
@@ -53,8 +54,25 @@ jobs:
echo 'PACKAGE_REGISTRY_USERNAME and PACKAGE_REGISTRY_TOKEN secrets are required.' >&2
exit 1
fi
package_file="$(find "$RUNNER_TEMP/gitea-go-package" -maxdepth 1 -type f -name '*.zip' -print -quit)"
package_file="$(find gitea-go-package -maxdepth 1 -type f -name '*.zip' -print -quit)"
test -n "$package_file"
curl --fail-with-body --user "$PACKAGE_REGISTRY_USERNAME:$PACKAGE_REGISTRY_TOKEN" \
response_file="$(mktemp)"
http_status="$(curl --silent --show-error --fail-with-body \
--user "$PACKAGE_REGISTRY_USERNAME:$PACKAGE_REGISTRY_TOKEN" \
--output "$response_file" \
--write-out '%{http_code}' \
--upload-file "$package_file" \
"$GITEA_GO_REGISTRY"
"$GITEA_GO_REGISTRY" || true)"
case "$http_status" in
201)
echo 'Go package published.'
;;
409)
echo 'Go package version already exists; leaving the immutable package unchanged.'
;;
*)
cat "$response_file" >&2
echo "Gitea Go package upload failed with HTTP status $http_status." >&2
exit 1
;;
esac
+32 -5
View File
@@ -50,17 +50,44 @@ jobs:
- name: Publish npm packages
env:
PACKAGE_REGISTRY_USERNAME: ${{ secrets.PACKAGE_REGISTRY_USERNAME }}
PACKAGE_REGISTRY_TOKEN: ${{ secrets.PACKAGE_REGISTRY_TOKEN }}
NPM_REGISTRY: https://repos.gfranz.ch/api/packages/Gabriel20xx/npm/
run: |
set -euo pipefail
if [ -z "$PACKAGE_REGISTRY_USERNAME" ] || [ -z "$PACKAGE_REGISTRY_TOKEN" ]; then
echo 'PACKAGE_REGISTRY_USERNAME and PACKAGE_REGISTRY_TOKEN secrets are required.' >&2
exit 1
fi
for package in \
@gabriel20xx/design-tokens \
@gabriel20xx/web-ui \
@gabriel20xx/node-backend; do
version="$(npm pkg get version --workspace="$package" | tr -d '"[:space:]')"
if npm view "$package@$version" version --registry="$NPM_REGISTRY" >/dev/null 2>&1; then
echo "$package@$version is already published; skipping."
else
npm publish --workspace="$package" --registry="$NPM_REGISTRY"
fi
package_path="${package//@/%40}"
package_path="${package_path//\//%2f}"
metadata_file="$(mktemp)"
metadata_status="$(curl --silent --show-error --fail-with-body \
--user "$PACKAGE_REGISTRY_USERNAME:$PACKAGE_REGISTRY_TOKEN" \
--output "$metadata_file" \
--write-out '%{http_code}' \
"${NPM_REGISTRY}${package_path}" || true)"
case "$metadata_status" in
200)
if grep -Fq "\"$version\"" "$metadata_file"; then
echo "$package@$version is already published; skipping."
rm -f "$metadata_file"
continue
fi
;;
404)
;;
*)
cat "$metadata_file" >&2
echo "Gitea npm metadata lookup failed with HTTP status $metadata_status." >&2
exit 1
;;
esac
npm publish --workspace="$package" --registry="$NPM_REGISTRY"
rm -f "$metadata_file"
done
+33 -1
View File
@@ -37,6 +37,38 @@ jobs:
python -m pip install --disable-pip-version-check --no-cache-dir build twine
package_directory="$RUNNER_TEMP/gitea-pypi-package"
python -m build packages/python-backend --outdir "$package_directory"
package_index_url="${TWINE_REPOSITORY_URL%/}/simple/gabriel20xx-shared-backend/"
package_index_file="$(mktemp)"
package_index_status="$(curl --silent --show-error --fail-with-body \
--user "$PACKAGE_REGISTRY_USERNAME:$PACKAGE_REGISTRY_TOKEN" \
--output "$package_index_file" \
--write-out '%{http_code}' \
"$package_index_url" || true)"
package_files=("$package_directory"/*)
files_to_upload=()
case "$package_index_status" in
200)
for package_file in "${package_files[@]}"; do
if ! grep -Fq "$(basename "$package_file")" "$package_index_file"; then
files_to_upload+=("$package_file")
fi
done
;;
404)
files_to_upload=("${package_files[@]}")
;;
*)
cat "$package_index_file" >&2
echo "Gitea PyPI package lookup failed with HTTP status $package_index_status." >&2
exit 1
;;
esac
if [ "${#files_to_upload[@]}" -eq 0 ]; then
echo 'Python package version already exists with all build artifacts; leaving it unchanged.'
exit 0
fi
TWINE_USERNAME="$PACKAGE_REGISTRY_USERNAME" \
TWINE_PASSWORD="$PACKAGE_REGISTRY_TOKEN" \
python -m twine upload --non-interactive --skip-existing "$package_directory"/*
python -m twine upload --non-interactive \
--repository-url "$TWINE_REPOSITORY_URL" \
"${files_to_upload[@]}"
+14
View File
@@ -0,0 +1,14 @@
#!/bin/sh
set -euo pipefail
repo_root="$(git rev-parse --show-toplevel)"
sync_script="$repo_root/scripts/sync-consumers.ps1"
if command -v pwsh >/dev/null 2>&1; then
pwsh -NoProfile -NonInteractive -ExecutionPolicy Bypass -File "$sync_script" -Commit
elif command -v powershell.exe >/dev/null 2>&1; then
powershell.exe -NoProfile -NonInteractive -ExecutionPolicy Bypass -File "$sync_script" -Commit
else
echo "shared synchronization requires pwsh or powershell.exe." >&2
exit 1
fi
+4 -25
View File
@@ -1,4 +1,4 @@
# SharedCode packages
# shared packages
This folder is the single source of truth for reusable web UI across the projects in this workspace.
@@ -33,30 +33,6 @@ go test ./...
go vet ./...
```
## Consume from the Gitea repository
The repository is the canonical source and is installable directly from Gitea. The root package
builds the Svelte package during installation and exposes the runtime packages as subpaths:
```bash
npm install --save-exact git+https://repos.gfranz.ch/Gabriel20xx/shared#<commit>
```
Use the shared UI from the root package:
```ts
import { AppShell, AuthPage, Header, SettingsDialog } from '@gabriel20xx/shared-code/web-ui';
```
Import the shared stylesheet once from the application's global stylesheet:
```css
@import '@gabriel20xx/shared-code/web-ui/styles.css';
```
The dependency should be pinned to a commit in application lockfiles. Update it when a new
SharedCode version has been validated.
## Publish the individual packages
The package names use the `@gabriel20xx` npm scope. The `publish-npm.yml` and
@@ -220,11 +196,14 @@ The Node and Python packages intentionally expose the same infrastructure concep
/>
```
The shared profile menu exposes Profile, Settings, About, and Log out. It uses the `About` navigation item's href automatically; pass `aboutHref` or `onAbout` to `AppShell` when a project uses a custom About destination or dialog.
For authentication, use the same shell with `AuthPage` and connect the callbacks to the application's existing auth service:
```svelte
<AuthPage
brand="My application"
faviconHref="/favicon.svg"
onLogin={(credentials) => auth.login(credentials.identifier, credentials.password)}
onSetup={(credentials) => auth.setup(credentials)}
onRequestReset={() => auth.requestAdminReset()}
+16 -26
View File
@@ -1,12 +1,12 @@
{
"name": "@gabriel20xx/shared-code",
"version": "0.1.0",
"version": "0.1.1",
"lockfileVersion": 3,
"requires": true,
"packages": {
"": {
"name": "@gabriel20xx/shared-code",
"version": "0.1.0",
"version": "0.1.1",
"license": "MIT",
"workspaces": [
"packages/*"
@@ -776,7 +776,6 @@
"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",
@@ -787,7 +786,6 @@
"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",
@@ -798,7 +796,6 @@
"version": "3.1.2",
"resolved": "https://registry.npmjs.org/@jridgewell/resolve-uri/-/resolve-uri-3.1.2.tgz",
"integrity": "sha512-bRISgCIjP20/tbWSPWMEi54QVPRZExkuD9lJL+UIxUKtwVJA8wW1Trb1jMs1RFXo1CBTNZ/5hpC9QvmKWdopKw==",
"dev": true,
"license": "MIT",
"engines": {
"node": ">=6.0.0"
@@ -808,20 +805,27 @@
"version": "1.5.5",
"resolved": "https://registry.npmjs.org/@jridgewell/sourcemap-codec/-/sourcemap-codec-1.5.5.tgz",
"integrity": "sha512-cYQ9310grqxueWbl+WuIUIaiUaDcj7WOq5fVhEljNVgRfOUhY9fy2zTvfoqWsnebh8Sl70VScFbICvJnLKB0Og==",
"dev": true,
"license": "MIT"
},
"node_modules/@jridgewell/trace-mapping": {
"version": "0.3.31",
"resolved": "https://registry.npmjs.org/@jridgewell/trace-mapping/-/trace-mapping-0.3.31.tgz",
"integrity": "sha512-zzNR+SdQSDJzc8joaeP8QQoCQr8NuYx2dIIytl1QeBEZHJ9uW6hebsrYgbz8hJwUQao3TWCMtmfV8Nu1twOLAw==",
"dev": true,
"license": "MIT",
"dependencies": {
"@jridgewell/resolve-uri": "^3.1.0",
"@jridgewell/sourcemap-codec": "^1.4.14"
}
},
"node_modules/@lucide/svelte": {
"version": "1.28.0",
"resolved": "https://registry.npmjs.org/@lucide/svelte/-/svelte-1.28.0.tgz",
"integrity": "sha512-C1Ge84KW2z4q44/WDIEo/2KC2jby5u6mSlta7q+p6g7u0ld8sC/w1fMBiSswF+4bxAl9jlzzaVTpp79qqkiy5g==",
"license": "ISC",
"peerDependencies": {
"svelte": "^5"
}
},
"node_modules/@manypkg/find-root": {
"version": "1.1.0",
"resolved": "https://registry.npmjs.org/@manypkg/find-root/-/find-root-1.1.0.tgz",
@@ -1371,7 +1375,6 @@
"version": "1.0.11",
"resolved": "https://registry.npmjs.org/@sveltejs/acorn-typescript/-/acorn-typescript-1.0.11.tgz",
"integrity": "sha512-LFuZUkjJ9iF7JZye/aG5XM0SFcQ5VyL0oVX4WJ9dc0Va3R3s0OauX1BESVCb+YN/ol8TAfqGDDAQsTG627Y5kw==",
"dev": true,
"license": "MIT",
"peerDependencies": {
"acorn": "^8.9.0"
@@ -1453,21 +1456,18 @@
"version": "1.0.9",
"resolved": "https://registry.npmjs.org/@types/estree/-/estree-1.0.9.tgz",
"integrity": "sha512-GhdPgy1el4/ImP05X05Uw4cw2/M93BCUmnEvWZNStlCzEKME4Fkk+YpoA5OiHNQmoS7Cafb8Xa3Pya8m1Qrzeg==",
"dev": true,
"license": "MIT"
},
"node_modules/@types/trusted-types": {
"version": "2.0.7",
"resolved": "https://registry.npmjs.org/@types/trusted-types/-/trusted-types-2.0.7.tgz",
"integrity": "sha512-ScaPdn1dQczgbl0QFTeTOmVHFULt394XJgOQNoyVhZ6r2vLnMLJfBPd53SB52T/3G36VI1/g2MZaX0cwDuXsfw==",
"dev": true,
"license": "MIT"
},
"node_modules/acorn": {
"version": "8.18.0",
"resolved": "https://registry.npmjs.org/acorn/-/acorn-8.18.0.tgz",
"integrity": "sha512-lGq+9yr1/GuAWaVYIHRjvvySG5/4VfKIvC8EWxStPdcDh/Ka7FG3twP6v4d5BkravUilhIAsG4Qj83t02LWUPQ==",
"dev": true,
"license": "MIT",
"bin": {
"acorn": "bin/acorn"
@@ -1507,7 +1507,6 @@
"version": "5.3.1",
"resolved": "https://registry.npmjs.org/aria-query/-/aria-query-5.3.1.tgz",
"integrity": "sha512-Z/ZeOgVl7bcSYZ/u/rh0fOpvEpq//LZmdbkXyc7syVzjPAhfOa9ebsdTSjEBDU4vs5nC98Kfduj1uFo0qyET3g==",
"dev": true,
"license": "Apache-2.0",
"engines": {
"node": ">= 0.4"
@@ -1527,7 +1526,6 @@
"version": "4.1.0",
"resolved": "https://registry.npmjs.org/axobject-query/-/axobject-query-4.1.0.tgz",
"integrity": "sha512-qIj0G9wZbMGNLjLmg1PT6v2mE9AH2zlnADJD/2tC6E00hgmhUOfEB6greHPAfLRSufHqROIUTkw6E+M3lH0PTQ==",
"dev": true,
"license": "Apache-2.0",
"engines": {
"node": ">= 0.4"
@@ -1586,7 +1584,6 @@
"version": "2.1.1",
"resolved": "https://registry.npmjs.org/clsx/-/clsx-2.1.1.tgz",
"integrity": "sha512-eYm0QWBtUrBWZWG0d386OGAw16Z995PiOVo2B7bjWSbHedGl5e0ZWaq65kOGgUSNesEIDkB9ISbTg/JK9dhCZA==",
"dev": true,
"license": "MIT",
"engines": {
"node": ">=6"
@@ -1638,7 +1635,6 @@
"version": "5.9.0",
"resolved": "https://registry.npmjs.org/devalue/-/devalue-5.9.0.tgz",
"integrity": "sha512-RWrqdArjvPbsATEhOPUo6Wndc/iWnkWKlhIrdlF3zMMYo/c3CVtoaVAyLtWxz5h8nSlkHzxnzV2uLydPXmtF+A==",
"dev": true,
"license": "MIT"
},
"node_modules/dir-glob": {
@@ -1715,7 +1711,6 @@
"version": "1.2.2",
"resolved": "https://registry.npmjs.org/esm-env/-/esm-env-1.2.2.tgz",
"integrity": "sha512-Epxrv+Nr/CaL4ZcFGPJIYLWFom+YeV1DqMLHJoEd9SYRxNbaFruBwfEX/kkHUJf55j2+TUbmDcmuilbP1TmXHA==",
"dev": true,
"license": "MIT"
},
"node_modules/esprima": {
@@ -1736,7 +1731,6 @@
"version": "2.3.0",
"resolved": "https://registry.npmjs.org/esrap/-/esrap-2.3.0.tgz",
"integrity": "sha512-GQ/7RN8uOtEfNpzZzBMTzW9JBcX42oaSVtPzdF+6cEL8pqIL094iUpr9jzYGn4O4P/1S60dJ6izyT8F4LYARng==",
"dev": true,
"license": "MIT",
"dependencies": {
"@jridgewell/sourcemap-codec": "^1.4.15"
@@ -1975,7 +1969,6 @@
"version": "3.0.3",
"resolved": "https://registry.npmjs.org/is-reference/-/is-reference-3.0.3.tgz",
"integrity": "sha512-ixkJoqQvAP88E6wLydLGGqCJsrFUnqoH6HnaczB8XmDH1oaWU+xxdptvikTgaEhtZ53Ky6YXiBuUI2WXLMCwjw==",
"dev": true,
"license": "MIT",
"dependencies": {
"@types/estree": "^1.0.6"
@@ -2058,7 +2051,6 @@
"version": "3.0.0",
"resolved": "https://registry.npmjs.org/locate-character/-/locate-character-3.0.0.tgz",
"integrity": "sha512-SW13ws7BjaeJ6p7Q6CO2nchbYEc3X3J6WrmTTDto7yMPqVSZTUyY5Tjbid+Ab8gLnATtygYtiDIJGQRRn2ZOiA==",
"dev": true,
"license": "MIT"
},
"node_modules/locate-path": {
@@ -2085,7 +2077,6 @@
"version": "0.30.21",
"resolved": "https://registry.npmjs.org/magic-string/-/magic-string-0.30.21.tgz",
"integrity": "sha512-vd2F4YUyEXKGcLHoq+TEyCjxueSeHnFxyyjNp80yg0XV4vUhnDer/lvvlqM/arB5bXQN5K2/3oinyCRyx8T2CQ==",
"dev": true,
"license": "MIT",
"dependencies": {
"@jridgewell/sourcemap-codec": "^1.5.5"
@@ -2821,7 +2812,6 @@
"version": "5.56.8",
"resolved": "https://registry.npmjs.org/svelte/-/svelte-5.56.8.tgz",
"integrity": "sha512-PY8LOw7xP6c8IOiVqdo0sbbZVYhXRSfklOQLAUyGBKqjTX0wx/z4l/9J+PmBpmlLnxzEb1NqltxQ5/wZme/Cmg==",
"dev": true,
"license": "MIT",
"dependencies": {
"@jridgewell/remapping": "^2.3.4",
@@ -3108,17 +3098,16 @@
"version": "1.1.4",
"resolved": "https://registry.npmjs.org/zimmerframe/-/zimmerframe-1.1.4.tgz",
"integrity": "sha512-B58NGBEoc8Y9MWWCQGl/gq9xBCe4IiKM0a2x7GZdQKOW5Exr8S1W24J6OgM1njK8xCRGvAJIL/MxXHf6SkmQKQ==",
"dev": true,
"license": "MIT"
},
"packages/design-tokens": {
"name": "@gabriel20xx/design-tokens",
"version": "0.1.0",
"version": "0.1.1",
"license": "MIT"
},
"packages/node-backend": {
"name": "@gabriel20xx/node-backend",
"version": "0.1.0",
"version": "0.1.1",
"license": "MIT",
"dependencies": {
"pg": "^8.17.2"
@@ -3129,10 +3118,11 @@
},
"packages/web-ui": {
"name": "@gabriel20xx/web-ui",
"version": "0.1.0",
"version": "0.1.1",
"license": "MIT",
"dependencies": {
"@gabriel20xx/design-tokens": "0.1.0"
"@gabriel20xx/design-tokens": "0.1.1",
"@lucide/svelte": "1.28.0"
},
"devDependencies": {
"@sveltejs/package": "^2.5.0",
+1 -1
View File
@@ -1,6 +1,6 @@
{
"name": "@gabriel20xx/shared-code",
"version": "0.1.0",
"version": "0.1.1",
"description": "Shared UI and backend packages for Gabriel20xx projects.",
"license": "MIT",
"repository": {
+1 -1
View File
@@ -1,6 +1,6 @@
{
"name": "@gabriel20xx/design-tokens",
"version": "0.1.0",
"version": "0.1.1",
"description": "Shared visual tokens for Gabriel20xx web projects.",
"license": "MIT",
"files": [
+1 -1
View File
@@ -17,4 +17,4 @@ legacy package as a compatibility layer until every consumer has moved.
Pass a service-specific `tableName` to `runMigrations` when multiple services
share one PostgreSQL database, so their migration histories cannot collide.
Run `npm test` from this package or `npm run test --workspace=@gabriel20xx/node-backend` from `SharedCode`.
Run `npm test` from this package or `npm run test --workspace=@gabriel20xx/node-backend` from `shared`.
+1 -1
View File
@@ -1,6 +1,6 @@
{
"name": "@gabriel20xx/node-backend",
"version": "0.1.0",
"version": "0.1.1",
"description": "Shared PostgreSQL, configuration, migration, and authentication primitives for Node.js services.",
"license": "MIT",
"type": "module",
+1 -1
View File
@@ -9,7 +9,7 @@ Shared Python backend infrastructure for services using `asyncpg`:
- common account/session persistence for the single-admin or optional multi-user model.
HTTP framework adapters stay in each service. Install this package from the
published index or directly from the SharedCode repository with a subdirectory
published index or directly from the shared repository with a subdirectory
install during development:
```bash
+1 -1
View File
@@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"
[project]
name = "gabriel20xx-shared-backend"
version = "0.1.0"
version = "0.1.1"
description = "Shared PostgreSQL and authentication primitives for Python services."
readme = "README.md"
requires-python = ">=3.10"
@@ -43,7 +43,5 @@ class DatabaseConfig:
min_size=min_size,
max_size=max_size,
timeout=float(_int_value(source, "DATABASE_CONNECT_TIMEOUT_SECONDS", 5, 1)),
command_timeout=float(
_int_value(source, "DATABASE_COMMAND_TIMEOUT_SECONDS", 15, 1)
),
command_timeout=float(_int_value(source, "DATABASE_COMMAND_TIMEOUT_SECONDS", 15, 1)),
)
+3 -2
View File
@@ -1,6 +1,6 @@
{
"name": "@gabriel20xx/web-ui",
"version": "0.1.0",
"version": "0.1.1",
"description": "Shared Svelte UI, layout, authentication, and account components for Gabriel20xx web projects.",
"license": "MIT",
"type": "module",
@@ -15,7 +15,8 @@
"svelte": "^5.0.0"
},
"dependencies": {
"@gabriel20xx/design-tokens": "0.1.0"
"@gabriel20xx/design-tokens": "0.1.1",
"@lucide/svelte": "1.28.0"
},
"devDependencies": {
"@sveltejs/package": "^2.5.0",
@@ -7,22 +7,37 @@
brand = 'Application',
children,
description = '',
icon,
links = [],
onClose,
open = $bindable(false),
version = ''
}: {
brand?: string;
children?: Snippet;
description?: string;
icon?: Snippet;
links?: AboutLink[];
onClose?: () => void | Promise<void>;
open?: boolean;
version?: string;
} = $props();
let wasOpen = false;
$effect(() => {
if (wasOpen && !open) void onClose?.();
wasOpen = open;
});
</script>
<Dialog bind:open title={`About ${brand}`}>
<div class="sc-auth-brand">
<span aria-hidden="true" class="sc-brand-mark">{brand.slice(0, 1).toUpperCase()}</span>
{#if icon}
{@render icon()}
{:else}
<span aria-hidden="true" class="sc-brand-mark">{brand.slice(0, 1).toUpperCase()}</span>
{/if}
<strong>{brand}</strong>
</div>
@@ -0,0 +1,86 @@
<script lang="ts">
import type {
UserCreateRequest,
UserDeleteRequest,
UserId,
UserListRequest,
UserRole,
UserUpdateRequest
} from '../types';
import Dialog from './Dialog.svelte';
import UserManagement from './UserManagement.svelte';
let {
currentRole = 'user',
currentUserId,
description = 'Manage accounts and access for this application.',
loginRequired = true,
onCreateUser,
onDeleteUser,
onLoginRequiredChange,
onListUsers,
onUpdateUser,
open = $bindable(false),
title = 'Admin'
}: {
currentRole?: UserRole;
currentUserId?: UserId;
description?: string;
loginRequired?: boolean;
onCreateUser?: UserCreateRequest;
onDeleteUser?: UserDeleteRequest;
onLoginRequiredChange?: (required: boolean) => void | Promise<void>;
onListUsers?: UserListRequest;
onUpdateUser?: UserUpdateRequest;
open?: boolean;
title?: string;
} = $props();
let loginRequiredValue = $state<boolean>(true);
let loginSettingError = $state('');
$effect(() => {
loginRequiredValue = loginRequired;
});
async function updateLoginRequired(required: boolean) {
const previous = loginRequiredValue;
loginRequiredValue = required;
loginSettingError = '';
try {
await onLoginRequiredChange?.(required);
} catch (error) {
loginRequiredValue = previous;
loginSettingError = error instanceof Error ? error.message : 'The setting could not be saved.';
}
}
</script>
<Dialog bind:open {description} {title}>
{#if onLoginRequiredChange}
<div class="sc-field">
<label class="flex items-center gap-3">
<input
class="size-4 accent-primary"
type="checkbox"
checked={loginRequiredValue}
onchange={(event) => updateLoginRequired((event.currentTarget as HTMLInputElement).checked)}
/>
<span>
<span class="block font-medium">Require login to access app</span>
<span class="sc-muted">Admins and superadmins can change this setting.</span>
</span>
</label>
{#if loginSettingError}<p class="sc-error" role="alert">{loginSettingError}</p>{/if}
</div>
{/if}
<UserManagement
currentRole={currentRole}
currentUserId={currentUserId}
onCreate={onCreateUser}
onDelete={onDeleteUser}
onList={onListUsers}
onUpdate={onUpdateUser}
/>
</Dialog>
@@ -2,47 +2,71 @@
import type { Snippet } from 'svelte';
import type { NavItem } from '../types';
import Header from './Header.svelte';
import NotificationStack from './NotificationStack.svelte';
import PageHeader from './PageHeader.svelte';
let {
aboutHref,
brand = 'Application',
brandHref = '/',
children,
class: className = '',
currentPath = '',
faviconHref = '/favicon.svg',
headerActions,
navItems = [],
onAbout,
onAdmin,
onLogout,
onNavigate,
onProfile,
onSettings,
showPageHeader = true,
showSettings = true,
theme = 'dark',
username = ''
username = '',
}: {
aboutHref?: string;
brand?: string;
brandHref?: string;
children?: Snippet;
class?: string;
currentPath?: string;
faviconHref?: string;
headerActions?: Snippet;
navItems?: NavItem[];
onAbout?: () => void | Promise<void>;
onAdmin?: () => void | Promise<void>;
onLogout?: () => void | Promise<void>;
onNavigate?: (item: NavItem) => void;
onProfile?: () => void;
onSettings?: () => void;
showPageHeader?: boolean;
showSettings?: boolean;
theme?: 'dark' | 'light' | 'system';
username?: string;
} = $props();
const activeNavItem = $derived(
navItems.find((item) =>
item.href === '/' ? currentPath === '/' : currentPath === item.href || currentPath.startsWith(`${item.href}/`),
),
);
</script>
<div class={`sc-root sc-app-shell ${className}`} data-theme={theme === 'system' ? undefined : theme}>
<NotificationStack />
<Header
aboutHref={aboutHref ?? navItems.find((item) => item.label.toLowerCase() === 'about')?.href ?? '/about'}
{brand}
{brandHref}
{currentPath}
{faviconHref}
actions={headerActions}
{navItems}
{onAbout}
{onAdmin}
{onLogout}
{onNavigate}
{onProfile}
@@ -52,6 +76,13 @@
/>
<main class="sc-main">
{#if showPageHeader && activeNavItem?.href !== '/about'}
<PageHeader
title={activeNavItem?.label ?? brand}
description={activeNavItem?.description ??
`Explore the ${activeNavItem?.label?.toLowerCase() ?? 'application'} section.`}
/>
{/if}
{@render children?.()}
</main>
</div>
@@ -12,6 +12,7 @@
brand = 'Application',
children,
error = '',
faviconHref = '/favicon.svg',
loading = false,
onLogin,
onConfirmReset,
@@ -24,6 +25,7 @@
brand?: string;
children?: Snippet;
error?: string;
faviconHref?: string;
loading?: boolean;
onLogin?: (input: AuthLoginInput) => void | Promise<void>;
onConfirmReset?: AuthResetConfirm;
@@ -39,6 +41,7 @@
let identifier = $state('');
let password = $state('');
let totpToken = $state('');
let totpRequired = $state(false);
let confirmPassword = $state('');
let submitError = $state('');
let submitting = $state(false);
@@ -47,11 +50,27 @@
let resetOpen = $state(false);
let resetting = $state(false);
// A failed status fetch tells us nothing about whether setup is actually required —
// defaulting to the setup view in that case would wrongly invite creating a new
// account when the real problem is that the server couldn't be reached.
let effectiveSetupRequired = $derived(error ? false : setupRequired);
function isTotpChallenge(caught: unknown): boolean {
if (!(caught instanceof Error)) return false;
const message = caught.message.toLowerCase();
return (
message.includes('two-factor authentication code required') ||
message.includes('multi-factor authentication code required') ||
(message.includes('totp') && message.includes('required')) ||
(message.includes('mfa') && message.includes('required'))
);
}
async function submit(event: SubmitEvent): Promise<void> {
event.preventDefault();
submitError = '';
if (setupRequired && password !== confirmPassword) {
if (effectiveSetupRequired && password !== confirmPassword) {
submitError = 'Passwords do not match.';
return;
}
@@ -59,15 +78,28 @@
submitting = true;
try {
if (setupRequired) {
if (effectiveSetupRequired) {
if (!onSetup) throw new Error('The application has not configured its setup handler.');
await onSetup({ username, email, password });
} else {
if (!onLogin) throw new Error('The application has not configured its login handler.');
if (totpRequired && !totpToken.trim()) {
submitError = 'Enter the six-digit authenticator code to continue.';
return;
}
await onLogin({ identifier, password, totpToken: totpToken.trim() });
}
} catch (caught) {
submitError = caught instanceof Error ? caught.message : 'Authentication failed.';
if (!effectiveSetupRequired && showTotp && isTotpChallenge(caught)) {
totpRequired = true;
submitError = 'Enter the six-digit authenticator code to continue.';
} else {
if (!effectiveSetupRequired) {
totpRequired = false;
totpToken = '';
}
submitError = caught instanceof Error ? caught.message : 'Authentication failed.';
}
} finally {
submitting = false;
}
@@ -107,19 +139,24 @@
</script>
<div class="sc-root sc-auth-page">
<section aria-labelledby="sc-auth-title" class="sc-auth-card">
<section aria-busy={loading} aria-labelledby="sc-auth-title" class="sc-auth-card">
<div class="sc-auth-brand">
<span aria-hidden="true" class="sc-brand-mark">{brand.slice(0, 1).toUpperCase()}</span>
<img alt="" aria-hidden="true" class="sc-auth-brand-icon" src={faviconHref} />
<span>{brand}</span>
</div>
<h1 id="sc-auth-title">{setupRequired ? 'Create your account' : 'Welcome back'}</h1>
{#if loading}
<h1 id="sc-auth-title">Loading...</h1>
{:else}
<h1 id="sc-auth-title">{effectiveSetupRequired ? 'Create your account' : 'Welcome back'}</h1>
{/if}
{#if !loading}
{#if tagline}
<p class="sc-auth-subtitle">{tagline}</p>
{/if}
<form class="sc-form sc-auth-form" onsubmit={submit}>
{#if setupRequired}
{#if effectiveSetupRequired}
<label class="sc-field">
<span class="sc-label">Username</span>
<input
@@ -160,7 +197,7 @@
<label class="sc-field">
<span class="sc-label">Password</span>
<input
autocomplete={setupRequired ? 'new-password' : 'current-password'}
autocomplete={effectiveSetupRequired ? 'new-password' : 'current-password'}
class="sc-input"
minlength="8"
name="password"
@@ -170,9 +207,9 @@
/>
</label>
{#if showTotp && !setupRequired}
{#if showTotp && !effectiveSetupRequired && totpRequired}
<label class="sc-field">
<span class="sc-label">Authenticator code <span class="sc-label-optional">(if enabled)</span></span>
<span class="sc-label">Authenticator code</span>
<input
autocomplete="one-time-code"
class="sc-input"
@@ -184,7 +221,7 @@
</label>
{/if}
{#if setupRequired}
{#if effectiveSetupRequired}
<label class="sc-field">
<span class="sc-label">Confirm password</span>
<input
@@ -204,7 +241,7 @@
{/if}
<Button disabled={loading || submitting} fullWidth size="lg" type="submit">
{loading || submitting ? 'Please wait…' : setupRequired ? 'Create account' : 'Log in'}
{loading || submitting ? 'Please wait…' : effectiveSetupRequired ? 'Create account' : 'Log in'}
</Button>
</form>
@@ -212,7 +249,7 @@
<div class="sc-auth-extra">{@render children()}</div>
{/if}
{#if !setupRequired && onRequestReset && onConfirmReset}
{#if !effectiveSetupRequired && onRequestReset && onConfirmReset}
{#if resetOpen}
<div class="sc-auth-reset" aria-live="polite">
<p class="sc-auth-reset-hint">A reset code has been printed to the server console.</p>
@@ -241,5 +278,6 @@
</button>
{/if}
{/if}
{/if}
</section>
</div>
+230 -16
View File
@@ -1,34 +1,159 @@
<script lang="ts">
import {
Activity,
Archive,
BarChart3,
Bot,
Box,
CircleAlert,
CircleHelp,
CircleUserRound,
CloudDownload,
Database,
FileCog,
FolderOpen,
Gamepad2,
GalleryHorizontalEnd,
HardDrive,
Image,
Info,
LayoutDashboard,
ListVideo,
LogOut,
Logs,
Magnet,
Map,
MapPinned,
MessageCircle,
MonitorPlay,
Play,
Plug,
RefreshCw,
ScanSearch,
ScrollText,
Send,
Server,
Settings2,
ShieldCheck,
SlidersHorizontal,
Sparkles,
Tags,
Upload,
Users,
WandSparkles,
Workflow,
Wrench,
} from '@lucide/svelte';
import type { Snippet } from 'svelte';
import type { NavItem } from '../types';
const icons: Record<string, typeof LayoutDashboard> = {
activity: Activity,
archive: Archive,
'bar-chart-3': BarChart3,
bot: Bot,
box: Box,
'circle-alert': CircleAlert,
'circle-help': CircleHelp,
'cloud-download': CloudDownload,
database: Database,
'file-cog': FileCog,
'folder-open': FolderOpen,
gamepad: Gamepad2,
'gallery-horizontal-end': GalleryHorizontalEnd,
'hard-drive': HardDrive,
image: Image,
info: Info,
'layout-dashboard': LayoutDashboard,
'list-video': ListVideo,
logs: Logs,
magnet: Magnet,
map: Map,
'map-pinned': MapPinned,
'message-circle': MessageCircle,
'monitor-play': MonitorPlay,
play: Play,
plug: Plug,
'refresh-cw': RefreshCw,
'scan-search': ScanSearch,
'scroll-text': ScrollText,
send: Send,
server: Server,
'settings-2': Settings2,
'shield-check': ShieldCheck,
'sliders-horizontal': SlidersHorizontal,
sparkles: Sparkles,
tags: Tags,
upload: Upload,
users: Users,
'wand-sparkles': WandSparkles,
workflow: Workflow,
wrench: Wrench,
};
let {
aboutHref = '/about',
brand = 'Application',
brandHref = '/',
currentPath = '',
faviconHref = '/favicon.svg',
navItems = [],
actions,
onAbout,
onAdmin,
onLogout,
onNavigate,
onProfile,
onSettings,
showSettings = true,
username = ''
username = '',
}: {
aboutHref?: string;
brand?: string;
brandHref?: string;
currentPath?: string;
faviconHref?: string;
navItems?: NavItem[];
actions?: Snippet;
onAbout?: () => void | Promise<void>;
onAdmin?: () => void | Promise<void>;
onLogout?: () => void | Promise<void>;
onNavigate?: (item: NavItem) => void;
onProfile?: () => void;
onSettings?: () => void;
onProfile?: () => void | Promise<void>;
onSettings?: () => void | Promise<void>;
showSettings?: boolean;
username?: string;
} = $props();
let navOpen = $state(false);
let profileOpen = $state(false);
// onAdmin is only ever passed by the caller when the signed-in user's role qualifies, so its
// presence alone is enough to decide visibility here - same as onProfile/onLogout below.
const hasProfileMenu = $derived(
Boolean(
username && (onProfile || onAdmin || (showSettings && onSettings) || onAbout || aboutHref || onLogout),
),
);
function closeMenus(): void {
navOpen = false;
profileOpen = false;
}
function handleWindowKeydown(event: KeyboardEvent): void {
if (event.key === 'Escape') closeMenus();
}
function handleWindowClick(event: MouseEvent): void {
if (event.target instanceof Element && !event.target.closest('[data-profile-menu]')) {
profileOpen = false;
}
}
function iconFor(item: NavItem) {
return icons[item.icon ?? 'layout-dashboard'] ?? LayoutDashboard;
}
function isActive(item: NavItem): boolean {
return item.href === '/'
@@ -37,14 +162,17 @@
}
</script>
<svelte:window onclick={handleWindowClick} onkeydown={handleWindowKeydown} />
<header class="sc-header">
<a class="sc-brand" href={brandHref} onclick={() => (navOpen = false)}>
<span aria-hidden="true" class="sc-brand-mark">{brand.slice(0, 1).toUpperCase()}</span>
<a class="sc-brand" href={brandHref} onclick={closeMenus}>
<img alt="" class="sc-brand-icon" src={faviconHref} />
<span>{brand}</span>
</a>
<nav aria-label="Primary navigation" class="sc-nav" data-open={navOpen}>
{#each navItems as item}
{@const Icon = iconFor(item)}
<a
aria-current={isActive(item) ? 'page' : undefined}
class="sc-nav-link"
@@ -55,9 +183,10 @@
event.preventDefault();
onNavigate(item);
}
navOpen = false;
closeMenus();
}}
>
<Icon aria-hidden="true" class="sc-nav-icon" size={16} strokeWidth={2} />
{item.label}
</a>
{/each}
@@ -66,18 +195,103 @@
<div class="sc-header-actions">
{#if actions}{@render actions()}{/if}
{#if showSettings && onSettings}
<button aria-label="Open settings" class="sc-icon-button" type="button" onclick={onSettings}>⚙</button>
{/if}
{#if hasProfileMenu}
<div class="sc-profile-menu" data-profile-menu>
<button
aria-expanded={profileOpen}
aria-haspopup="menu"
class="sc-profile-button"
type="button"
onclick={() => (profileOpen = !profileOpen)}
>
<CircleUserRound aria-hidden="true" class="sc-profile-icon" size={16} strokeWidth={2} />
<span>{username}</span>
</button>
{#if username && onProfile}
<button class="sc-profile-button" type="button" onclick={onProfile}>{username}</button>
{/if}
{#if profileOpen}
<div aria-label="Account menu" class="sc-profile-dropdown" role="menu">
{#if onProfile}
<button
class="sc-profile-menu-item"
role="menuitem"
type="button"
onclick={() => {
profileOpen = false;
void onProfile?.();
}}
>
<CircleUserRound aria-hidden="true" size={15} strokeWidth={2} />
Profile
</button>
{/if}
{#if onLogout}
<button class="sc-button sc-button-ghost sc-button-sm" type="button" onclick={() => void onLogout?.()}>
Log out
</button>
{#if onAdmin}
<button
class="sc-profile-menu-item"
role="menuitem"
type="button"
onclick={() => {
profileOpen = false;
void onAdmin?.();
}}
>
<ShieldCheck aria-hidden="true" size={15} strokeWidth={2} />
Admin
</button>
{/if}
{#if showSettings && onSettings}
<button
class="sc-profile-menu-item"
role="menuitem"
type="button"
onclick={() => {
profileOpen = false;
void onSettings?.();
}}
>
<Settings2 aria-hidden="true" size={15} strokeWidth={2} />
Settings
</button>
{/if}
{#if onAbout}
<button
class="sc-profile-menu-item"
role="menuitem"
type="button"
onclick={() => {
profileOpen = false;
void onAbout?.();
}}
>
<Info aria-hidden="true" size={15} strokeWidth={2} />
About
</button>
{:else if aboutHref}
<a class="sc-profile-menu-item" href={aboutHref} role="menuitem" onclick={() => (profileOpen = false)}>
<Info aria-hidden="true" size={15} strokeWidth={2} />
About
</a>
{/if}
{#if onLogout}
<button
class="sc-profile-menu-item"
role="menuitem"
type="button"
onclick={() => {
profileOpen = false;
void onLogout?.();
}}
>
<LogOut aria-hidden="true" size={15} strokeWidth={2} />
Log out
</button>
{/if}
</div>
{/if}
</div>
{/if}
<button
@@ -0,0 +1,31 @@
<script lang="ts">
import { CircleAlert, CircleCheck, Info, OctagonAlert, X } from '@lucide/svelte';
import { fly } from 'svelte/transition';
import { notifications } from '../notifications.svelte';
import type { NotificationVariant } from '../notifications.svelte';
const icons: Record<NotificationVariant, typeof Info> = {
success: CircleCheck,
error: OctagonAlert,
warning: CircleAlert,
info: Info
};
</script>
<div aria-live="polite" class="sc-notification-stack" role="status">
{#each notifications.entries as entry (entry.id)}
{@const Icon = icons[entry.variant]}
<div class="sc-notification" data-variant={entry.variant} transition:fly={{ y: -12, duration: 180 }}>
<Icon aria-hidden="true" class="sc-notification-icon" size={18} />
<p class="sc-notification-message">{entry.message}</p>
<button
aria-label="Dismiss notification"
class="sc-notification-close"
type="button"
onclick={() => notifications.dismiss(entry.id)}
>
<X aria-hidden="true" size={16} />
</button>
</div>
{/each}
</div>
@@ -0,0 +1,100 @@
<script lang="ts">
import { ChevronFirst, ChevronLast, ChevronLeft, ChevronRight } from '@lucide/svelte';
const PAGE_SIZE_OPTIONS = [12, 24, 48, 96];
export type PaginationChange = {
page: number;
pageSize: number;
};
let {
page,
pageSize = 24,
pageLength = 0,
totalLength = 0,
onPaging
}: {
page: number;
pageSize?: number;
pageLength?: number;
totalLength?: number;
onPaging: (change: PaginationChange) => void;
} = $props();
const pageCount = $derived(Math.max(1, Math.ceil(totalLength / pageSize)));
const currentPage = $derived(Math.min(Math.max(1, page), pageCount));
const firstItemIndex = $derived(totalLength === 0 ? 0 : (currentPage - 1) * pageSize + 1);
const lastItemIndex = $derived(
totalLength === 0 ? 0 : Math.min(totalLength, (currentPage - 1) * pageSize + pageLength)
);
const hasPreviousPage = $derived(currentPage > 1);
const hasNextPage = $derived(currentPage < pageCount);
function goToPage(nextPage: number) {
onPaging({ page: Math.min(pageCount, Math.max(1, nextPage)), pageSize });
}
function changePageSize(event: Event) {
const nextPageSize = Number((event.currentTarget as HTMLSelectElement).value);
if (PAGE_SIZE_OPTIONS.includes(nextPageSize)) {
onPaging({ page: 1, pageSize: nextPageSize });
}
}
</script>
<nav class="sc-pagination" aria-label="Pagination">
<select
class="sc-pagination-page-size"
aria-label="Items per page"
value={String(pageSize)}
onchange={changePageSize}
>
{#each PAGE_SIZE_OPTIONS as option}
<option value={option}>{option}</option>
{/each}
</select>
<p class="sc-pagination-info">
{firstItemIndex.toLocaleString()}–{lastItemIndex.toLocaleString()} of {totalLength.toLocaleString()}
</p>
<div class="sc-pagination-controls">
<button
type="button"
class="sc-pagination-button"
aria-label="First page"
disabled={!hasPreviousPage}
onclick={() => goToPage(1)}
>
<ChevronFirst aria-hidden="true" size={16} />
</button>
<button
type="button"
class="sc-pagination-button"
aria-label="Previous page"
disabled={!hasPreviousPage}
onclick={() => goToPage(currentPage - 1)}
>
<ChevronLeft aria-hidden="true" size={16} />
</button>
<button
type="button"
class="sc-pagination-button"
aria-label="Next page"
disabled={!hasNextPage}
onclick={() => goToPage(currentPage + 1)}
>
<ChevronRight aria-hidden="true" size={16} />
</button>
<button
type="button"
class="sc-pagination-button"
aria-label="Last page"
disabled={!hasNextPage}
onclick={() => goToPage(pageCount)}
>
<ChevronLast aria-hidden="true" size={16} />
</button>
</div>
</nav>
@@ -1,51 +1,27 @@
<script lang="ts">
import type {
ProfileUpdateInput,
TotpSetupRequest,
TotpStatusRequest,
TotpTokenAction,
UserCreateRequest,
UserDeleteRequest,
UserId,
UserListRequest,
UserRole,
UserUpdateRequest
} from '../types';
import type { ProfileUpdateInput, TotpSetupRequest, TotpStatusRequest, TotpTokenAction } from '../types';
import Button from './Button.svelte';
import Dialog from './Dialog.svelte';
import TotpSettings from './TotpSettings.svelte';
import UserManagement from './UserManagement.svelte';
let {
currentEmail = '',
currentRole = 'user',
currentUserId,
onCreateUser,
onDeleteUser,
onListUsers,
currentUsername = '',
onSave,
onTotpDisable,
onTotpEnable,
onTotpSetup,
onTotpStatus,
onUpdateUser,
totpEnabled = false,
open = $bindable(false)
}: {
currentEmail?: string;
currentRole?: UserRole;
currentUserId?: UserId;
onCreateUser?: UserCreateRequest;
onDeleteUser?: UserDeleteRequest;
onListUsers?: UserListRequest;
currentUsername?: string;
onSave?: (input: ProfileUpdateInput) => void | Promise<void>;
onTotpDisable?: TotpTokenAction;
onTotpEnable?: TotpTokenAction;
onTotpSetup?: TotpSetupRequest;
onTotpStatus?: TotpStatusRequest;
onUpdateUser?: UserUpdateRequest;
totpEnabled?: boolean;
open?: boolean;
} = $props();
@@ -158,13 +134,4 @@
enabled={totpEnabled}
/>
{/if}
<UserManagement
currentRole={currentRole}
currentUserId={currentUserId}
onCreate={onCreateUser}
onDelete={onDeleteUser}
onList={onListUsers}
onUpdate={onUpdateUser}
/>
</Dialog>
@@ -1,36 +1,15 @@
<script lang="ts">
import type { Snippet } from 'svelte';
import type {
UserCreateRequest,
UserDeleteRequest,
UserId,
UserListRequest,
UserRole,
UserUpdateRequest
} from '../types';
import Dialog from './Dialog.svelte';
import UserManagement from './UserManagement.svelte';
let {
children,
description = '',
currentRole = 'user',
currentUserId,
onCreateUser,
onDeleteUser,
onListUsers,
onUpdateUser,
open = $bindable(false),
title = 'Settings'
}: {
children?: Snippet;
description?: string;
currentRole?: UserRole;
currentUserId?: UserId;
onCreateUser?: UserCreateRequest;
onDeleteUser?: UserDeleteRequest;
onListUsers?: UserListRequest;
onUpdateUser?: UserUpdateRequest;
open?: boolean;
title?: string;
} = $props();
@@ -42,12 +21,4 @@
{:else}
<p class="sc-muted">No settings have been configured for this application yet.</p>
{/if}
<UserManagement
currentRole={currentRole}
currentUserId={currentUserId}
onCreate={onCreateUser}
onDelete={onDeleteUser}
onList={onListUsers}
onUpdate={onUpdateUser}
/>
</Dialog>
+5
View File
@@ -1,4 +1,5 @@
export { default as AboutDialog } from './components/AboutDialog.svelte';
export { default as AdminDialog } from './components/AdminDialog.svelte';
export { default as AppShell } from './components/AppShell.svelte';
export { default as AuthPage } from './components/AuthPage.svelte';
export { default as Badge } from './components/Badge.svelte';
@@ -6,11 +7,15 @@ export { default as Button } from './components/Button.svelte';
export { default as Card } from './components/Card.svelte';
export { default as Dialog } from './components/Dialog.svelte';
export { default as Header } from './components/Header.svelte';
export { default as NotificationStack } from './components/NotificationStack.svelte';
export { default as PageHeader } from './components/PageHeader.svelte';
export { default as Pagination } from './components/Pagination.svelte';
export { default as ProfileDialog } from './components/ProfileDialog.svelte';
export { default as SettingsDialog } from './components/SettingsDialog.svelte';
export { default as TotpSettings } from './components/TotpSettings.svelte';
export { default as UserManagement } from './components/UserManagement.svelte';
export { notifications, notify } from './notifications.svelte';
export type { NotificationEntry, NotificationVariant } from './notifications.svelte';
export type {
AboutLink,
AsyncAction,
@@ -0,0 +1,54 @@
export type NotificationVariant = "success" | "error" | "warning" | "info";
export interface NotificationEntry {
id: number;
variant: NotificationVariant;
message: string;
duration: number;
}
const DEFAULT_DURATION = 5000;
let entries = $state<NotificationEntry[]>([]);
let nextId = 0;
const timeouts = new Map<number, ReturnType<typeof setTimeout>>();
function dismissNotification(id: number): void {
const timeout = timeouts.get(id);
if (timeout !== undefined) {
clearTimeout(timeout);
timeouts.delete(id);
}
entries = entries.filter((entry) => entry.id !== id);
}
function pushNotification(
variant: NotificationVariant,
message: string,
duration: number = DEFAULT_DURATION,
): number {
const id = ++nextId;
entries = [...entries, { id, variant, message, duration }];
if (duration > 0) {
timeouts.set(
id,
setTimeout(() => dismissNotification(id), duration),
);
}
return id;
}
export const notifications = {
get entries() {
return entries;
},
dismiss: dismissNotification,
};
export const notify = {
success: (message: string, duration?: number) => pushNotification("success", message, duration),
error: (message: string, duration?: number) => pushNotification("error", message, duration),
warning: (message: string, duration?: number) => pushNotification("warning", message, duration),
info: (message: string, duration?: number) => pushNotification("info", message, duration),
dismiss: dismissNotification,
};
+192 -14
View File
@@ -1,4 +1,4 @@
@import '@gabriel20xx/design-tokens/theme.css';
@import "@gabriel20xx/design-tokens/theme.css";
:where(.sc-root, .sc-root *) {
box-sizing: border-box;
@@ -31,7 +31,7 @@
.sc-main {
width: min(100% - 2rem, 90rem);
margin: 0 auto;
padding: 2rem 0 3rem;
padding: 1rem 0 1rem;
}
.sc-header {
@@ -62,6 +62,7 @@
}
.sc-brand-mark {
overflow: hidden;
display: grid;
width: 2rem;
height: 2rem;
@@ -73,6 +74,18 @@
font-weight: 800;
}
.sc-brand-icon {
/* Fixed instead of percentage-based: the icon isn't wrapped in a sized container (unlike
.sc-brand-mark, which this rule mirrors), and .sc-brand's own width is content-driven, so
a percentage here has no definite box to resolve against and lets the image render at
whatever intrinsic size its source happens to have. */
width: 2rem;
height: 2rem;
padding: 0.25rem;
object-fit: contain;
border-radius: var(--sc-radius-md);
}
.sc-nav {
display: flex;
flex: 1 1 auto;
@@ -85,7 +98,17 @@
.sc-icon-button {
border: 1px solid transparent;
border-radius: var(--sc-radius-md);
transition: color 140ms ease, background 140ms ease, border-color 140ms ease;
transition:
color 140ms ease,
background 140ms ease,
border-color 140ms ease;
}
.sc-nav-link,
.sc-profile-button {
display: inline-flex;
align-items: center;
gap: 0.4rem;
}
.sc-nav-link {
@@ -96,7 +119,7 @@
}
.sc-nav-link:hover,
.sc-nav-link[data-active='true'] {
.sc-nav-link[data-active="true"] {
color: var(--sc-fg);
background: var(--sc-surface-hover);
border-color: var(--sc-border);
@@ -129,6 +152,54 @@
font-size: 0.875rem;
}
.sc-profile-menu {
position: relative;
}
.sc-profile-dropdown {
position: absolute;
top: calc(100% + 0.5rem);
right: 0;
z-index: 20;
display: grid;
min-width: 11rem;
gap: 0.125rem;
padding: 0.375rem;
background: var(--sc-surface);
border: 1px solid var(--sc-border);
border-radius: var(--sc-radius-md);
box-shadow: var(--sc-shadow-lg);
}
.sc-profile-menu-item {
display: flex;
width: 100%;
align-items: center;
gap: 0.5rem;
padding: 0.625rem 0.75rem;
color: var(--sc-muted-fg);
background: transparent;
border: 0;
border-radius: var(--sc-radius-sm);
font: inherit;
font-size: 0.875rem;
text-align: left;
text-decoration: none;
cursor: pointer;
}
/* The About item falls back to an <a> when no onAbout handler is wired, unlike the other
button-based items - without this, the browser's default a:visited color (higher specificity
than the class color above) makes it drift from the other dropdown items' color once clicked. */
.sc-profile-menu-item:visited {
color: var(--sc-muted-fg);
}
.sc-profile-menu-item:hover {
color: var(--sc-fg);
background: var(--sc-surface-hover);
}
.sc-icon-button:hover,
.sc-profile-button:hover {
color: var(--sc-fg);
@@ -145,7 +216,12 @@
align-items: flex-start;
justify-content: space-between;
gap: 1rem;
margin-bottom: 1.5rem;
margin-bottom: 1rem;
padding: 1rem 1.25rem;
background: var(--sc-surface);
border: 1px solid var(--sc-border);
border-radius: var(--sc-radius-lg);
box-shadow: var(--sc-shadow-sm);
}
.sc-page-header h1,
@@ -209,19 +285,19 @@
font-weight: 650;
}
.sc-badge[data-variant='success'] {
.sc-badge[data-variant="success"] {
color: var(--sc-success-fg);
background: var(--sc-success);
border-color: transparent;
}
.sc-badge[data-variant='warning'] {
.sc-badge[data-variant="warning"] {
color: var(--sc-warning-fg);
background: var(--sc-warning);
border-color: transparent;
}
.sc-badge[data-variant='danger'] {
.sc-badge[data-variant="danger"] {
color: var(--sc-danger-fg);
background: var(--sc-danger);
border-color: transparent;
@@ -240,7 +316,11 @@
font-weight: 650;
line-height: 1;
cursor: pointer;
transition: color 140ms ease, background 140ms ease, border-color 140ms ease, opacity 140ms ease;
transition:
color 140ms ease,
background 140ms ease,
border-color 140ms ease,
opacity 140ms ease;
}
.sc-button:hover:not(:disabled) {
@@ -255,6 +335,7 @@
.sc-button:focus-visible,
.sc-icon-button:focus-visible,
.sc-profile-button:focus-visible,
.sc-profile-menu-item:focus-visible,
.sc-nav-link:focus-visible,
.sc-dialog-close:focus-visible {
outline: 3px solid color-mix(in srgb, var(--sc-ring) 45%, transparent);
@@ -406,7 +487,9 @@
border: 1px solid var(--sc-border);
border-radius: var(--sc-radius-md);
outline: none;
transition: border-color 140ms ease, box-shadow 140ms ease;
transition:
border-color 140ms ease,
box-shadow 140ms ease;
}
.sc-textarea {
@@ -558,7 +641,11 @@
padding: 1.5rem;
color: var(--sc-fg);
background:
radial-gradient(circle at 15% 10%, color-mix(in srgb, var(--sc-primary) 18%, transparent), transparent 35%),
radial-gradient(
circle at 15% 10%,
color-mix(in srgb, var(--sc-primary) 18%, transparent),
transparent 35%
),
var(--sc-bg);
}
@@ -579,6 +666,14 @@
font-weight: 750;
}
.sc-auth-brand-icon {
display: block;
width: 2rem;
height: 2rem;
object-fit: contain;
border-radius: var(--sc-radius-md);
}
.sc-auth-card h1 {
font-size: 1.7rem;
}
@@ -622,6 +717,86 @@
color: var(--sc-fg);
}
.sc-notification-stack {
position: fixed;
z-index: 200;
top: 1rem;
right: 1rem;
display: grid;
gap: 0.625rem;
width: min(100% - 2rem, 24rem);
pointer-events: none;
}
.sc-notification {
display: flex;
align-items: flex-start;
gap: 0.625rem;
padding: 0.875rem 1rem;
color: var(--sc-fg);
background: var(--sc-surface-raised);
border: 1px solid var(--sc-border);
border-radius: var(--sc-radius-md);
box-shadow: var(--sc-shadow-lg);
pointer-events: auto;
}
.sc-notification-icon {
flex: 0 0 auto;
margin-top: 0.125rem;
color: var(--sc-muted-fg);
}
.sc-notification[data-variant="success"] .sc-notification-icon {
color: var(--sc-success);
}
.sc-notification[data-variant="error"] .sc-notification-icon {
color: var(--sc-danger);
}
.sc-notification[data-variant="warning"] .sc-notification-icon {
color: var(--sc-warning);
}
.sc-notification[data-variant="info"] .sc-notification-icon {
color: var(--sc-primary);
}
.sc-notification-message {
flex: 1 1 auto;
margin: 0;
font-size: 0.875rem;
line-height: 1.45;
}
.sc-notification-close {
display: grid;
flex: 0 0 auto;
width: 1.5rem;
height: 1.5rem;
place-items: center;
color: var(--sc-muted-fg);
background: transparent;
border: 0;
border-radius: var(--sc-radius-sm);
cursor: pointer;
}
.sc-notification-close:hover {
color: var(--sc-fg);
background: var(--sc-surface-hover);
}
@media (max-width: 30rem) {
.sc-notification-stack {
top: 0.75rem;
right: 0.75rem;
left: 0.75rem;
width: auto;
}
}
.sc-dialog-backdrop {
position: fixed;
z-index: 100;
@@ -727,12 +902,15 @@
}
.sc-mobile-menu-button {
position: absolute;
left: 50%;
display: grid;
order: 3;
width: 2.25rem;
height: 2.25rem;
margin-left: auto;
margin-left: 0;
place-items: center;
transform: translateX(-50%);
}
.sc-nav {
@@ -744,7 +922,7 @@
padding-bottom: 0.25rem;
}
.sc-nav[data-open='true'] {
.sc-nav[data-open="true"] {
display: flex;
}
@@ -753,7 +931,7 @@
}
.sc-header-actions {
margin-left: 0;
margin-left: auto;
}
.sc-profile-button {
+13 -5
View File
@@ -1,10 +1,12 @@
import type { Snippet } from 'svelte';
import type { Snippet } from "svelte";
export type AsyncAction<T = void> = (value: T) => void | Promise<void>;
export interface NavItem {
href: string;
label: string;
icon?: string;
description?: string;
}
export interface AuthSetupInput {
@@ -27,7 +29,8 @@ export interface TotpSetupResponse {
export type TotpStatusRequest = () => boolean | Promise<boolean>;
export type TotpSetupRequest = () => TotpSetupResponse | Promise<TotpSetupResponse>;
export type TotpSetupRequest = () =>
TotpSetupResponse | Promise<TotpSetupResponse>;
export type TotpTokenAction = (token: string) => void | Promise<void>;
@@ -41,7 +44,7 @@ export interface ProfileUpdateInput {
password?: string;
}
export type UserRole = 'superadmin' | 'admin' | 'user';
export type UserRole = "superadmin" | "admin" | "user";
export type UserId = string | number;
@@ -71,9 +74,14 @@ export interface UserUpdateInput {
export type UserListRequest = () => ManagedUser[] | Promise<ManagedUser[]>;
export type UserCreateRequest = (input: UserCreateInput) => void | Promise<void | ManagedUser>;
export type UserCreateRequest = (
input: UserCreateInput,
) => void | Promise<void | ManagedUser>;
export type UserUpdateRequest = (id: UserId, input: UserUpdateInput) => void | Promise<void | ManagedUser>;
export type UserUpdateRequest = (
id: UserId,
input: UserUpdateInput,
) => void | Promise<void | ManagedUser>;
export type UserDeleteRequest = (id: UserId) => void | Promise<void>;
+13
View File
@@ -0,0 +1,13 @@
$ErrorActionPreference = 'Stop'
$repositoryRoot = (& git -C $PSScriptRoot rev-parse --show-toplevel).Trim()
if ($LASTEXITCODE -ne 0 -or [string]::IsNullOrWhiteSpace($repositoryRoot)) {
throw 'Could not locate the shared Git repository.'
}
& git -C $repositoryRoot config core.hooksPath .githooks
if ($LASTEXITCODE -ne 0) {
throw 'Could not configure the shared Git hooks path.'
}
Write-Host "Installed shared post-commit synchronization hook in $repositoryRoot."
+348
View File
@@ -0,0 +1,348 @@
[CmdletBinding()]
param(
[string]$SourceRepository,
[switch]$Force,
[switch]$Commit,
[switch]$Push
)
$ErrorActionPreference = 'Stop'
if ($Push -and -not $Commit) {
throw 'The -Push switch requires -Commit so that only generated synchronization changes are pushed.'
}
$consumerProjects = @(
'Original/AutoCode',
'Original/SimpleCollection',
'Original/CollabTable',
'Original/GameStream',
'Original/SyncServer',
'Original/UnraidMonitor',
'Original/PubliSafe',
'Original/MediaCollection',
'Forks/Bitmagnet',
'Forks/Heretic',
'Original/InfiniteVideo',
'Forks/MegaBasterd',
'Forks/HordeWorker',
'Original/OutdoorGames'
)
function Invoke-GitText {
param(
[Parameter(Mandatory = $true)]
[string]$WorkingDirectory,
[Parameter(Mandatory = $true)]
[string[]]$Arguments
)
$output = & git -C $WorkingDirectory @Arguments 2>&1
$exitCode = $LASTEXITCODE
if ($exitCode -ne 0) {
$diagnostics = @($output | ForEach-Object { [string]$_ } | Where-Object { -not [string]::IsNullOrWhiteSpace($_) })
$blockingDiagnostics = @($diagnostics | Where-Object { $_ -notmatch '^\s*(warning|hint):' })
if ($blockingDiagnostics.Count -eq 0) {
$diagnostics | ForEach-Object { Write-Warning $_ }
}
else {
$details = $diagnostics -join [Environment]::NewLine
throw "git $($Arguments -join ' ') failed in '$WorkingDirectory'. $details"
}
}
return @($output | ForEach-Object { [string]$_ })
}
function Resolve-FullPath {
param(
[Parameter(Mandatory = $true)]
[string]$Path
)
return (Resolve-Path -LiteralPath $Path -ErrorAction Stop).Path
}
function Get-RelativePath {
param(
[Parameter(Mandatory = $true)]
[string]$BasePath,
[Parameter(Mandatory = $true)]
[string]$TargetPath
)
$base = (Resolve-FullPath $BasePath).TrimEnd('\') + '\'
$target = Resolve-FullPath $TargetPath
if (-not $target.StartsWith($base, [System.StringComparison]::OrdinalIgnoreCase)) {
throw "'$TargetPath' is not inside '$BasePath'."
}
return $target.Substring($base.Length).Replace('\', '/')
}
function Write-Utf8NoBom {
param(
[Parameter(Mandatory = $true)]
[string]$Path,
[Parameter(Mandatory = $true)]
[string]$Content
)
$encoding = New-Object System.Text.UTF8Encoding($false)
$normalizedContent = $Content.Replace("`r`n", "`n").Replace("`r", "`n")
[System.IO.File]::WriteAllText($Path, $normalizedContent, $encoding)
}
function Convert-ToConsumerWebUiPackage {
param(
[Parameter(Mandatory = $true)]
[string]$PackagePath
)
$manifest = Get-Content -LiteralPath $PackagePath -Raw | ConvertFrom-Json
$manifest.files = @('src', 'README.md')
if ($null -ne $manifest.dependencies) {
$designTokensDependency = $manifest.dependencies.PSObject.Properties['@gabriel20xx/design-tokens']
if ($null -ne $designTokensDependency) {
$manifest.dependencies.PSObject.Properties.Remove('@gabriel20xx/design-tokens')
}
}
$manifest.svelte = './src/index.ts'
$manifest.types = './src/index.ts'
$rootExport = $manifest.exports.PSObject.Properties | Where-Object { $_.Name -eq '.' }
if ($null -ne $rootExport) {
$rootExport.Value.types = './src/index.ts'
$rootExport.Value.svelte = './src/index.ts'
$rootExport.Value.import = './src/index.ts'
}
$stylesExport = $manifest.exports.PSObject.Properties | Where-Object { $_.Name -eq './styles.css' }
if ($null -ne $stylesExport) {
$stylesExport.Value = './src/lib/styles.css'
}
$json = $manifest | ConvertTo-Json -Depth 20
Write-Utf8NoBom -Path $PackagePath -Content ($json + [Environment]::NewLine)
}
function Convert-ToConsumerWebUiSources {
param(
[Parameter(Mandatory = $true)]
[string]$WebUiRoot
)
$stylesPath = Join-Path $WebUiRoot 'src/lib/styles.css'
if (Test-Path -LiteralPath $stylesPath) {
$styles = Get-Content -LiteralPath $stylesPath -Raw
$styles = $styles.Replace("@import '@gabriel20xx/design-tokens/theme.css';", "@import '../../../design-tokens/theme.css';")
$styles = $styles.Replace('@import "@gabriel20xx/design-tokens/theme.css";', "@import '../../../design-tokens/theme.css';")
Write-Utf8NoBom -Path $stylesPath -Content $styles
}
$svelteConfigPath = Join-Path $WebUiRoot 'svelte.config.js'
if (Test-Path -LiteralPath $svelteConfigPath) {
Write-Utf8NoBom -Path $svelteConfigPath -Content "export default {};`n"
}
}
function Test-LocalSharedDependency {
param(
[Parameter(Mandatory = $true)]
$PackageManifest
)
$localPackageNames = @(
'@gabriel20xx/web-ui',
'@gabriel20xx/node-backend'
)
foreach ($sectionName in @('dependencies', 'devDependencies', 'optionalDependencies')) {
$sectionProperty = $PackageManifest.PSObject.Properties[$sectionName]
if ($null -eq $sectionProperty -or $null -eq $sectionProperty.Value) {
continue
}
foreach ($dependency in $sectionProperty.Value.PSObject.Properties) {
if ($dependency.Name -in $localPackageNames -and ([string]$dependency.Value).StartsWith('file:')) {
return $true
}
}
}
return $false
}
if ([string]::IsNullOrWhiteSpace($SourceRepository)) {
$scriptParent = Resolve-FullPath (Join-Path $PSScriptRoot '..')
$scriptParentGitRoot = (Invoke-GitText -WorkingDirectory $scriptParent -Arguments @('rev-parse', '--show-toplevel') | Select-Object -First 1).Trim()
$scriptParentGitRoot = Resolve-FullPath $scriptParentGitRoot
if ($scriptParentGitRoot -ieq $scriptParent) {
$SourceRepository = $scriptParent
}
else {
$workspaceRoot = Split-Path -Parent (Split-Path -Parent $scriptParentGitRoot)
$SourceRepository = Join-Path $workspaceRoot 'shared'
}
}
$sourceRoot = Resolve-FullPath $SourceRepository
$sourceRepositoryRoot = (Invoke-GitText -WorkingDirectory $sourceRoot -Arguments @('rev-parse', '--show-toplevel') | Select-Object -First 1).Trim()
$sourceRoot = Resolve-FullPath $sourceRepositoryRoot
$workspaceRoot = Split-Path -Parent $sourceRoot
$sourceCommit = (Invoke-GitText -WorkingDirectory $sourceRoot -Arguments @('rev-parse', '--short', 'HEAD') | Select-Object -First 1).Trim()
$sourceFiles = @(Invoke-GitText -WorkingDirectory $sourceRoot -Arguments @('ls-files') | Where-Object { -not [string]::IsNullOrWhiteSpace($_) })
$sourceFileSet = @{}
foreach ($sourceFile in $sourceFiles) {
$sourceFileSet[$sourceFile.Replace('\', '/')] = $true
}
Write-Host "Synchronizing $($sourceFiles.Count) tracked shared files from $sourceCommit."
$failures = New-Object 'System.Collections.Generic.List[string]'
foreach ($relativeProject in $consumerProjects) {
$projectRoot = Join-Path $workspaceRoot ($relativeProject -replace '/', '\')
if (-not (Test-Path -LiteralPath $projectRoot -PathType Container)) {
$failures.Add("${relativeProject}: project directory not found")
continue
}
try {
$projectRoot = Resolve-FullPath $projectRoot
$destinationRoot = Join-Path $projectRoot 'shared'
$legacyDirectoryName = ('Shared' + 'Code')
$projectDirectories = @(Get-ChildItem -LiteralPath $projectRoot -Directory -Force)
$destinationEntry = $projectDirectories | Where-Object { $_.Name -ceq 'shared' }
$legacyEntry = $projectDirectories | Where-Object { $_.Name -ceq $legacyDirectoryName }
if ($null -ne $destinationEntry -and $null -ne $legacyEntry) {
throw "Both shared and the legacy shared snapshot directory exist. Remove the legacy directory before synchronizing."
}
$dirtyshared = @(Invoke-GitText -WorkingDirectory $projectRoot -Arguments @('status', '--porcelain', '--', 'shared'))
$dirtyLegacy = @(Invoke-GitText -WorkingDirectory $projectRoot -Arguments @('status', '--porcelain', '--', $legacyDirectoryName))
if (($dirtyshared.Count -gt 0 -or $dirtyLegacy.Count -gt 0) -and -not $Force) {
throw "shared has local changes. Commit them or rerun with -Force."
}
if ($null -ne $legacyEntry) {
$temporaryRenamePath = Join-Path $projectRoot ('.shared-sync-rename-' + [Guid]::NewGuid().ToString('N'))
Move-Item -LiteralPath $legacyEntry.FullName -Destination $temporaryRenamePath
Move-Item -LiteralPath $temporaryRenamePath -Destination $destinationRoot
}
New-Item -ItemType Directory -Force -Path $destinationRoot | Out-Null
$existingSharedFiles = @(Invoke-GitText -WorkingDirectory $projectRoot -Arguments @('ls-files', '--', 'shared') | Where-Object { $_ -like 'shared/*' })
foreach ($existingSharedFile in $existingSharedFiles) {
$relativeSharedFile = $existingSharedFile.Substring('shared/'.Length).Replace('\', '/')
if (-not $sourceFileSet.ContainsKey($relativeSharedFile)) {
$stalePath = Join-Path $destinationRoot ($relativeSharedFile -replace '/', '\')
if (Test-Path -LiteralPath $stalePath -PathType Leaf) {
Remove-Item -LiteralPath $stalePath -Force
}
}
}
foreach ($sourceFile in $sourceFiles) {
$sourcePath = Join-Path $sourceRoot ($sourceFile -replace '/', '\')
$destinationPath = Join-Path $destinationRoot ($sourceFile -replace '/', '\')
$destinationDirectory = Split-Path -Parent $destinationPath
New-Item -ItemType Directory -Force -Path $destinationDirectory | Out-Null
Copy-Item -LiteralPath $sourcePath -Destination $destinationPath -Force
}
$webUiPackagePath = Join-Path $destinationRoot 'packages/web-ui/package.json'
if (Test-Path -LiteralPath $webUiPackagePath) {
Convert-ToConsumerWebUiPackage -PackagePath $webUiPackagePath
Convert-ToConsumerWebUiSources -WebUiRoot (Join-Path $destinationRoot 'packages/web-ui')
}
$lockFiles = @()
$sharedPrefix = ((Resolve-FullPath $destinationRoot).TrimEnd('\') + '\')
$packageFiles = @(Get-ChildItem -LiteralPath $projectRoot -Recurse -File -Filter 'package.json' -Force |
Where-Object {
$_.FullName -notlike "$sharedPrefix*" -and
$_.FullName -notmatch '\\node_modules\\'
})
foreach ($packageFile in $packageFiles) {
$packageManifest = Get-Content -LiteralPath $packageFile.FullName -Raw | ConvertFrom-Json
if (-not (Test-LocalSharedDependency -PackageManifest $packageManifest)) {
continue
}
$lockPath = Join-Path $packageFile.DirectoryName 'package-lock.json'
if (-not (Test-Path -LiteralPath $lockPath -PathType Leaf)) {
continue
}
$relativeLockPath = Get-RelativePath -BasePath $projectRoot -TargetPath $lockPath
$trackedLock = @(Invoke-GitText -WorkingDirectory $projectRoot -Arguments @('ls-files', '--', $relativeLockPath))
$shouldStageLock = $trackedLock.Count -gt 0
Write-Host " Updating $relativeProject/$(Get-RelativePath -BasePath $projectRoot -TargetPath $lockPath)"
Push-Location -LiteralPath $packageFile.DirectoryName
try {
& npm install --package-lock-only --ignore-scripts --prefer-offline
if ($LASTEXITCODE -ne 0) {
throw "npm install --package-lock-only failed with exit code $LASTEXITCODE."
}
}
finally {
Pop-Location
}
if ($shouldStageLock -and $lockFiles -notcontains $relativeLockPath) {
$lockFiles += $relativeLockPath
}
elseif (-not $shouldStageLock) {
Write-Host " Leaving untracked/ignored lockfile out of the generated commit: $relativeLockPath"
}
}
$null = Invoke-GitText -WorkingDirectory $projectRoot -Arguments @('add', '--', 'shared')
foreach ($lockFile in $lockFiles) {
$null = Invoke-GitText -WorkingDirectory $projectRoot -Arguments @('add', '--', $lockFile)
}
$targetPaths = @('shared') + $lockFiles
$stagedChanges = @(Invoke-GitText -WorkingDirectory $projectRoot -Arguments (@('diff', '--cached', '--name-only', '--') + $targetPaths))
if ($Commit -and $stagedChanges.Count -gt 0) {
$commitMessage = "Sync shared snapshot from $sourceCommit"
$commitArguments = @('commit', '--only', '-m', $commitMessage, '--') + $targetPaths
$commitOutput = @(Invoke-GitText -WorkingDirectory $projectRoot -Arguments $commitArguments)
$commitOutput | ForEach-Object { Write-Host " $_" }
$remainingStagedChanges = @(Invoke-GitText -WorkingDirectory $projectRoot -Arguments (@('diff', '--cached', '--name-only', '--') + $targetPaths))
if ($remainingStagedChanges.Count -gt 0) {
throw 'The generated synchronization changes remain staged after the commit.'
}
}
if ($Push) {
$pushOutput = @(Invoke-GitText -WorkingDirectory $projectRoot -Arguments @('push', 'origin', 'main'))
$pushOutput | ForEach-Object { Write-Host " $_" }
}
if ($stagedChanges.Count -gt 0) {
Write-Host "Synced $relativeProject."
}
else {
Write-Host "$relativeProject is already synchronized."
}
}
catch {
$message = "${relativeProject}: $($_.Exception.Message)"
$failures.Add($message)
Write-Warning $message
}
}
if ($failures.Count -gt 0) {
throw "shared synchronization failed for $($failures.Count) project(s): $($failures -join '; ')"
}
Write-Host 'shared synchronization completed.'
+356 -13
View File
@@ -1,5 +1,7 @@
@import './packages/design-tokens/theme.css';
@import "@gabriel20xx/design-tokens/theme.css";
:where(.sc-root, .sc-root *) {
box-sizing: border-box;
}
@@ -31,7 +33,7 @@
.sc-main {
width: min(100% - 2rem, 90rem);
margin: 0 auto;
padding: 2rem 0 3rem;
padding: 1rem 0 1rem;
}
.sc-header {
@@ -62,6 +64,7 @@
}
.sc-brand-mark {
overflow: hidden;
display: grid;
width: 2rem;
height: 2rem;
@@ -73,6 +76,18 @@
font-weight: 800;
}
.sc-brand-icon {
/* Fixed instead of percentage-based: the icon isn't wrapped in a sized container (unlike
.sc-brand-mark, which this rule mirrors), and .sc-brand's own width is content-driven, so
a percentage here has no definite box to resolve against and lets the image render at
whatever intrinsic size its source happens to have. */
width: 2rem;
height: 2rem;
padding: 0.25rem;
object-fit: contain;
border-radius: var(--sc-radius-md);
}
.sc-nav {
display: flex;
flex: 1 1 auto;
@@ -85,7 +100,17 @@
.sc-icon-button {
border: 1px solid transparent;
border-radius: var(--sc-radius-md);
transition: color 140ms ease, background 140ms ease, border-color 140ms ease;
transition:
color 140ms ease,
background 140ms ease,
border-color 140ms ease;
}
.sc-nav-link,
.sc-profile-button {
display: inline-flex;
align-items: center;
gap: 0.4rem;
}
.sc-nav-link {
@@ -96,7 +121,7 @@
}
.sc-nav-link:hover,
.sc-nav-link[data-active='true'] {
.sc-nav-link[data-active="true"] {
color: var(--sc-fg);
background: var(--sc-surface-hover);
border-color: var(--sc-border);
@@ -129,6 +154,54 @@
font-size: 0.875rem;
}
.sc-profile-menu {
position: relative;
}
.sc-profile-dropdown {
position: absolute;
top: calc(100% + 0.5rem);
right: 0;
z-index: 20;
display: grid;
min-width: 11rem;
gap: 0.125rem;
padding: 0.375rem;
background: var(--sc-surface);
border: 1px solid var(--sc-border);
border-radius: var(--sc-radius-md);
box-shadow: var(--sc-shadow-lg);
}
.sc-profile-menu-item {
display: flex;
width: 100%;
align-items: center;
gap: 0.5rem;
padding: 0.625rem 0.75rem;
color: var(--sc-muted-fg);
background: transparent;
border: 0;
border-radius: var(--sc-radius-sm);
font: inherit;
font-size: 0.875rem;
text-align: left;
text-decoration: none;
cursor: pointer;
}
/* The About item falls back to an <a> when no onAbout handler is wired, unlike the other
button-based items - without this, the browser's default a:visited color (higher specificity
than the class color above) makes it drift from the other dropdown items' color once clicked. */
.sc-profile-menu-item:visited {
color: var(--sc-muted-fg);
}
.sc-profile-menu-item:hover {
color: var(--sc-fg);
background: var(--sc-surface-hover);
}
.sc-icon-button:hover,
.sc-profile-button:hover {
color: var(--sc-fg);
@@ -145,7 +218,12 @@
align-items: flex-start;
justify-content: space-between;
gap: 1rem;
margin-bottom: 1.5rem;
margin-bottom: 1rem;
padding: 1rem 1.25rem;
background: var(--sc-surface);
border: 1px solid var(--sc-border);
border-radius: var(--sc-radius-lg);
box-shadow: var(--sc-shadow-sm);
}
.sc-page-header h1,
@@ -209,19 +287,19 @@
font-weight: 650;
}
.sc-badge[data-variant='success'] {
.sc-badge[data-variant="success"] {
color: var(--sc-success-fg);
background: var(--sc-success);
border-color: transparent;
}
.sc-badge[data-variant='warning'] {
.sc-badge[data-variant="warning"] {
color: var(--sc-warning-fg);
background: var(--sc-warning);
border-color: transparent;
}
.sc-badge[data-variant='danger'] {
.sc-badge[data-variant="danger"] {
color: var(--sc-danger-fg);
background: var(--sc-danger);
border-color: transparent;
@@ -240,7 +318,11 @@
font-weight: 650;
line-height: 1;
cursor: pointer;
transition: color 140ms ease, background 140ms ease, border-color 140ms ease, opacity 140ms ease;
transition:
color 140ms ease,
background 140ms ease,
border-color 140ms ease,
opacity 140ms ease;
}
.sc-button:hover:not(:disabled) {
@@ -255,6 +337,7 @@
.sc-button:focus-visible,
.sc-icon-button:focus-visible,
.sc-profile-button:focus-visible,
.sc-profile-menu-item:focus-visible,
.sc-nav-link:focus-visible,
.sc-dialog-close:focus-visible {
outline: 3px solid color-mix(in srgb, var(--sc-ring) 45%, transparent);
@@ -335,6 +418,66 @@
font-weight: 400;
}
.sc-totp-settings {
display: grid;
gap: 0.75rem;
margin-top: 1.5rem;
padding-top: 1.25rem;
border-top: 1px solid var(--sc-border);
}
.sc-totp-heading {
display: flex;
align-items: flex-start;
justify-content: space-between;
gap: 1rem;
}
.sc-totp-heading h3 {
margin: 0;
font-size: 0.95rem;
}
.sc-totp-heading p {
margin: 0.25rem 0 0;
}
.sc-totp-status {
flex: 0 0 auto;
border: 1px solid var(--sc-border);
border-radius: 999px;
padding: 0.2rem 0.55rem;
color: var(--sc-muted-fg);
font-size: 0.75rem;
font-weight: 600;
}
.sc-totp-status.sc-totp-enabled {
border-color: var(--sc-success);
color: var(--sc-success);
}
.sc-totp-secret {
display: grid;
gap: 0.5rem;
color: var(--sc-muted-fg);
font-size: 0.8rem;
overflow-wrap: anywhere;
}
.sc-totp-secret p {
margin: 0;
}
.sc-totp-secret code {
display: block;
border-radius: 0.4rem;
background: var(--sc-input-bg);
padding: 0.6rem;
color: var(--sc-fg);
font-size: 0.7rem;
}
.sc-input,
.sc-select,
.sc-textarea {
@@ -346,7 +489,9 @@
border: 1px solid var(--sc-border);
border-radius: var(--sc-radius-md);
outline: none;
transition: border-color 140ms ease, box-shadow 140ms ease;
transition:
border-color 140ms ease,
box-shadow 140ms ease;
}
.sc-textarea {
@@ -388,6 +533,109 @@
color: var(--sc-success);
}
.sc-user-management {
display: grid;
gap: 1rem;
margin-top: 1.5rem;
padding-top: 1.5rem;
border-top: 1px solid var(--sc-border);
}
.sc-user-management-header,
.sc-user-row,
.sc-user-edit-row {
display: flex;
align-items: center;
gap: 0.75rem;
}
.sc-user-management-header {
justify-content: space-between;
}
.sc-user-management-header h3 {
margin: 0;
}
.sc-user-management-header p {
margin: 0.25rem 0 0;
}
.sc-user-form,
.sc-user-list {
display: grid;
gap: 0.75rem;
}
.sc-user-form {
padding: 0.9rem;
border: 1px solid var(--sc-border);
border-radius: 0.6rem;
background: var(--sc-surface-raised);
}
.sc-user-grid {
display: grid;
grid-template-columns: repeat(2, minmax(0, 1fr));
gap: 0.6rem;
}
.sc-user-row {
min-width: 0;
justify-content: space-between;
padding: 0.7rem 0;
border-bottom: 1px solid var(--sc-border);
}
.sc-user-row > div:first-child {
display: grid;
min-width: 0;
}
.sc-user-row > div:first-child span {
overflow: hidden;
color: var(--sc-muted-fg);
text-overflow: ellipsis;
white-space: nowrap;
}
.sc-user-role {
color: var(--sc-muted-fg);
font-size: 0.8rem;
text-transform: capitalize;
}
.sc-user-actions {
display: flex;
flex-shrink: 0;
gap: 0.4rem;
}
.sc-user-edit-row {
align-items: stretch;
flex-wrap: wrap;
}
.sc-user-edit-row .sc-input {
flex: 1 1 10rem;
min-width: 8rem;
}
@media (max-width: 620px) {
.sc-user-grid {
grid-template-columns: 1fr;
}
.sc-user-row {
align-items: flex-start;
flex-wrap: wrap;
}
.sc-user-actions {
width: 100%;
}
}
.sc-auth-page {
display: grid;
min-height: 100vh;
@@ -395,7 +643,11 @@
padding: 1.5rem;
color: var(--sc-fg);
background:
radial-gradient(circle at 15% 10%, color-mix(in srgb, var(--sc-primary) 18%, transparent), transparent 35%),
radial-gradient(
circle at 15% 10%,
color-mix(in srgb, var(--sc-primary) 18%, transparent),
transparent 35%
),
var(--sc-bg);
}
@@ -416,6 +668,14 @@
font-weight: 750;
}
.sc-auth-brand-icon {
display: block;
width: 2rem;
height: 2rem;
object-fit: contain;
border-radius: var(--sc-radius-md);
}
.sc-auth-card h1 {
font-size: 1.7rem;
}
@@ -459,6 +719,86 @@
color: var(--sc-fg);
}
.sc-notification-stack {
position: fixed;
z-index: 200;
top: 1rem;
right: 1rem;
display: grid;
gap: 0.625rem;
width: min(100% - 2rem, 24rem);
pointer-events: none;
}
.sc-notification {
display: flex;
align-items: flex-start;
gap: 0.625rem;
padding: 0.875rem 1rem;
color: var(--sc-fg);
background: var(--sc-surface-raised);
border: 1px solid var(--sc-border);
border-radius: var(--sc-radius-md);
box-shadow: var(--sc-shadow-lg);
pointer-events: auto;
}
.sc-notification-icon {
flex: 0 0 auto;
margin-top: 0.125rem;
color: var(--sc-muted-fg);
}
.sc-notification[data-variant="success"] .sc-notification-icon {
color: var(--sc-success);
}
.sc-notification[data-variant="error"] .sc-notification-icon {
color: var(--sc-danger);
}
.sc-notification[data-variant="warning"] .sc-notification-icon {
color: var(--sc-warning);
}
.sc-notification[data-variant="info"] .sc-notification-icon {
color: var(--sc-primary);
}
.sc-notification-message {
flex: 1 1 auto;
margin: 0;
font-size: 0.875rem;
line-height: 1.45;
}
.sc-notification-close {
display: grid;
flex: 0 0 auto;
width: 1.5rem;
height: 1.5rem;
place-items: center;
color: var(--sc-muted-fg);
background: transparent;
border: 0;
border-radius: var(--sc-radius-sm);
cursor: pointer;
}
.sc-notification-close:hover {
color: var(--sc-fg);
background: var(--sc-surface-hover);
}
@media (max-width: 30rem) {
.sc-notification-stack {
top: 0.75rem;
right: 0.75rem;
left: 0.75rem;
width: auto;
}
}
.sc-dialog-backdrop {
position: fixed;
z-index: 100;
@@ -564,12 +904,15 @@
}
.sc-mobile-menu-button {
position: absolute;
left: 50%;
display: grid;
order: 3;
width: 2.25rem;
height: 2.25rem;
margin-left: auto;
margin-left: 0;
place-items: center;
transform: translateX(-50%);
}
.sc-nav {
@@ -581,7 +924,7 @@
padding-bottom: 0.25rem;
}
.sc-nav[data-open='true'] {
.sc-nav[data-open="true"] {
display: flex;
}
@@ -590,7 +933,7 @@
}
.sc-header-actions {
margin-left: 0;
margin-left: auto;
}
.sc-profile-button {