Compare commits
No commits in common. "main" and "v0.8.41" have entirely different histories.
|
|
@ -9,7 +9,7 @@
|
||||||
"name": "storebound",
|
"name": "storebound",
|
||||||
"source": ".",
|
"source": ".",
|
||||||
"description": "Take a mobile app or game from nothing to Submit for review on both stores: skills for every store step and questionnaire plus the storebound CLI and MCP server.",
|
"description": "Take a mobile app or game from nothing to Submit for review on both stores: skills for every store step and questionnaire plus the storebound CLI and MCP server.",
|
||||||
"version": "0.8.78",
|
"version": "0.8.41",
|
||||||
"category": "development",
|
"category": "development",
|
||||||
"tags": [
|
"tags": [
|
||||||
"mobile",
|
"mobile",
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,6 @@
|
||||||
{
|
{
|
||||||
"name": "storebound",
|
"name": "storebound",
|
||||||
"version": "0.8.78",
|
"version": "0.8.41",
|
||||||
"description": "Take a mobile app or game from nothing to Submit for review on Google Play and the App Store: app records, listings in every language, in-app products and subscriptions with regional prices, every questionnaire (Data safety, App access and demo accounts, account deletion, IARC, target audience, ads, App Privacy, age rating, export compliance), privacy, icons, screenshots and previews, validate, TestFlight, release management, and after launch: crash vitals, review replies, price sheets, store analytics, Product Page Optimization. Agent Skills plus a Bun CLI and MCP server (storebound); you press Submit. CRTkafa's own toolchain, open-sourced.",
|
"description": "Take a mobile app or game from nothing to Submit for review on Google Play and the App Store: app records, listings in every language, in-app products and subscriptions with regional prices, every questionnaire (Data safety, App access and demo accounts, account deletion, IARC, target audience, ads, App Privacy, age rating, export compliance), privacy, icons, screenshots and previews, validate, TestFlight, release management, and after launch: crash vitals, review replies, price sheets, store analytics, Product Page Optimization. Agent Skills plus a Bun CLI and MCP server (storebound); you press Submit. CRTkafa's own toolchain, open-sourced.",
|
||||||
"author": {
|
"author": {
|
||||||
"name": "CRTkafa"
|
"name": "CRTkafa"
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,6 @@
|
||||||
{
|
{
|
||||||
"name": "storebound",
|
"name": "storebound",
|
||||||
"version": "0.8.78",
|
"version": "0.8.41",
|
||||||
"description": "Take a mobile app or game from nothing to Submit for review on Google Play and the App Store: app records, listings in every language, in-app products and subscriptions with regional prices, every questionnaire (Data safety, App access and demo accounts, account deletion, IARC, target audience, ads, App Privacy, age rating, export compliance), privacy, icons, screenshots and previews, validate, TestFlight, release management, and after launch: crash vitals, review replies, price sheets, store analytics, Product Page Optimization. Agent Skills plus a Bun CLI and MCP server (storebound); you press Submit. CRTkafa's own toolchain, open-sourced.",
|
"description": "Take a mobile app or game from nothing to Submit for review on Google Play and the App Store: app records, listings in every language, in-app products and subscriptions with regional prices, every questionnaire (Data safety, App access and demo accounts, account deletion, IARC, target audience, ads, App Privacy, age rating, export compliance), privacy, icons, screenshots and previews, validate, TestFlight, release management, and after launch: crash vitals, review replies, price sheets, store analytics, Product Page Optimization. Agent Skills plus a Bun CLI and MCP server (storebound); you press Submit. CRTkafa's own toolchain, open-sourced.",
|
||||||
"author": {
|
"author": {
|
||||||
"name": "CRTkafa"
|
"name": "CRTkafa"
|
||||||
|
|
|
||||||
|
|
@ -20,12 +20,6 @@ storebound plus you, the AI agent, do the work. The owner is not your pair of ha
|
||||||
testers. (Also the owner's: canceling a submission, starting or stopping a store experiment, a console form's final
|
testers. (Also the owner's: canceling a submission, starting or stopping a store experiment, a console form's final
|
||||||
Submit / Create that a console plan lists in `buttons.final`, signing in and granting account permissions.) For
|
Submit / Create that a console plan lists in `buttons.final`, signing in and granting account permissions.) For
|
||||||
these you prepare everything, show the dry run, and the owner presses one button or says yes.
|
these you prepare everything, show the dry run, and the owner presses one button or says yes.
|
||||||
**Updates are agent steps:** a new version of an app that is already on the store (Play: the production track holds
|
|
||||||
a published release; App Store: a version of the platform is or was on sale) is yours end to end, no owner gate
|
|
||||||
per update: `storebound play release <aab> --production completed --yes`, `storebound play upload --track
|
|
||||||
production --yes`, `storebound apple submit --build <n> --yes`, `storebound apple release --manual-release --yes`
|
|
||||||
(docs/bypass.md). Only the **first-ever release** of an app stays the owner's (exit 3 `OWNER_STEP`: after the
|
|
||||||
owner's yes re-run with `--first-release`), plus removal from sale, live price changes and anything that costs money.
|
|
||||||
**Bypass mode** (`storebound settings bypass status`): when the owner turned it on, you run these owner steps too:
|
**Bypass mode** (`storebound settings bypass status`): when the owner turned it on, you run these owner steps too:
|
||||||
MCP `owner_step` (dry run first, then `dry_run: false`), `storebound api ... --yes --confirm <operationId>`, and
|
MCP `owner_step` (dry run first, then `dry_run: false`), `storebound api ... --yes --confirm <operationId>`, and
|
||||||
console plans' `buttons.final`. Say in one line what you pressed; every action is logged to
|
console plans' `buttons.final`. Say in one line what you pressed; every action is logged to
|
||||||
|
|
|
||||||
|
|
@ -26,7 +26,6 @@ runs:
|
||||||
with:
|
with:
|
||||||
path: |
|
path: |
|
||||||
~/.bun/install/cache
|
~/.bun/install/cache
|
||||||
~/.cache/tauri
|
|
||||||
~/.cargo/registry/index
|
~/.cargo/registry/index
|
||||||
~/.cargo/registry/cache
|
~/.cargo/registry/cache
|
||||||
~/.cargo/git/db
|
~/.cargo/git/db
|
||||||
|
|
@ -36,7 +35,7 @@ runs:
|
||||||
shell: bash
|
shell: bash
|
||||||
run: |
|
run: |
|
||||||
P="${FORGEJO_PATH:-$GITHUB_PATH}"
|
P="${FORGEJO_PATH:-$GITHUB_PATH}"
|
||||||
bash tools/ci-install-bun.sh
|
curl -fsSL https://bun.sh/install | bash -s "bun-v${BUN_VERSION}" >/dev/null
|
||||||
echo "$HOME/.bun/bin" >> "$P"
|
echo "$HOME/.bun/bin" >> "$P"
|
||||||
command -v rustup || curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y --profile minimal
|
command -v rustup || curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y --profile minimal
|
||||||
echo "$HOME/.cargo/bin" >> "$P"
|
echo "$HOME/.cargo/bin" >> "$P"
|
||||||
|
|
|
||||||
|
|
@ -33,7 +33,7 @@ jobs:
|
||||||
if: ${{ matrix.platform == 'Linux' }}
|
if: ${{ matrix.platform == 'Linux' }}
|
||||||
shell: bash
|
shell: bash
|
||||||
run: |
|
run: |
|
||||||
bash tools/ci-install-bun.sh
|
curl -fsSL https://bun.sh/install | bash -s "bun-v${BUN_VERSION}" >/dev/null
|
||||||
echo "$HOME/.bun/bin" >> "${FORGEJO_PATH:-$GITHUB_PATH}"
|
echo "$HOME/.bun/bin" >> "${FORGEJO_PATH:-$GITHUB_PATH}"
|
||||||
- name: Acceptance matrix (Linux)
|
- name: Acceptance matrix (Linux)
|
||||||
if: ${{ matrix.platform == 'Linux' }}
|
if: ${{ matrix.platform == 'Linux' }}
|
||||||
|
|
@ -97,7 +97,7 @@ jobs:
|
||||||
path: acceptance-runs/Windows-bun
|
path: acceptance-runs/Windows-bun
|
||||||
- name: Matrix (markdown), red cells fail the job
|
- name: Matrix (markdown), red cells fail the job
|
||||||
run: |
|
run: |
|
||||||
bash tools/ci-install-bun.sh
|
curl -fsSL https://bun.sh/install | bash -s "bun-v${BUN_VERSION}" >/dev/null
|
||||||
export PATH="$HOME/.bun/bin:$PATH"
|
export PATH="$HOME/.bun/bin:$PATH"
|
||||||
V=$(bun tools/desktop-version.ts --print)
|
V=$(bun tools/desktop-version.ts --print)
|
||||||
mkdir -p out
|
mkdir -p out
|
||||||
|
|
|
||||||
|
|
@ -102,7 +102,7 @@ jobs:
|
||||||
if: ${{ matrix.platform == 'Linux' }}
|
if: ${{ matrix.platform == 'Linux' }}
|
||||||
shell: bash
|
shell: bash
|
||||||
run: |
|
run: |
|
||||||
bash tools/ci-install-bun.sh
|
curl -fsSL https://bun.sh/install | bash -s "bun-v${BUN_VERSION}" >/dev/null
|
||||||
echo "$HOME/.bun/bin" >> "${FORGEJO_PATH:-$GITHUB_PATH}"
|
echo "$HOME/.bun/bin" >> "${FORGEJO_PATH:-$GITHUB_PATH}"
|
||||||
- name: Acceptance matrix (Linux)
|
- name: Acceptance matrix (Linux)
|
||||||
if: ${{ matrix.platform == 'Linux' }}
|
if: ${{ matrix.platform == 'Linux' }}
|
||||||
|
|
@ -173,9 +173,7 @@ jobs:
|
||||||
working-directory: apps/desktop
|
working-directory: apps/desktop
|
||||||
run: |
|
run: |
|
||||||
rm -rf "$CARGO_TARGET_DIR/release/bundle"
|
rm -rf "$CARGO_TARGET_DIR/release/bundle"
|
||||||
# the AppImage tools come from GitHub releases, which answer 504 now and then (cached in ~/.cache/tauri)
|
bun ../../tools/desktop-release.ts exec -- bunx tauri build --bundles appimage,deb --ci
|
||||||
bash ../../tools/ci-tauri-tools.sh
|
|
||||||
for i in 1 2 3; do bun ../../tools/desktop-release.ts exec -- bunx tauri build --bundles appimage,deb --ci && break; [ $i = 3 ] && exit 1; sleep 30; done
|
|
||||||
- name: Self-test the exact artifacts
|
- name: Self-test the exact artifacts
|
||||||
run: |
|
run: |
|
||||||
V=$(bun tools/desktop-version.ts --print)
|
V=$(bun tools/desktop-version.ts --print)
|
||||||
|
|
@ -225,34 +223,6 @@ jobs:
|
||||||
name: storebound-desktop-linux
|
name: storebound-desktop-linux
|
||||||
path: out/
|
path: out/
|
||||||
retention-days: 7
|
retention-days: 7
|
||||||
# dev channel (tools/desktop-dev.ts): the same commit again with the version <next patch>-dev.<commit UTC>, only in
|
|
||||||
# this workspace (never committed); a failure here never touches the release candidate above
|
|
||||||
- name: Dev build (AppImage + deb, dev version)
|
|
||||||
id: dev
|
|
||||||
if: github.event_name == 'push' && github.ref == 'refs/heads/main'
|
|
||||||
continue-on-error: true
|
|
||||||
env:
|
|
||||||
FORBIDDEN_TERMS: ${{ secrets.FORBIDDEN_TERMS }}
|
|
||||||
run: |
|
|
||||||
set -euo pipefail
|
|
||||||
V=$(bun tools/desktop-dev.ts set)
|
|
||||||
bun tools/build-sidecars.ts --target bun-linux-x64
|
|
||||||
patchelf --set-rpath '$ORIGIN/../lib' apps/desktop/src-tauri/binaries/storebound-x86_64-unknown-linux-gnu
|
|
||||||
B="$CARGO_TARGET_DIR/release/bundle"; rm -rf "$B"
|
|
||||||
bash tools/ci-tauri-tools.sh
|
|
||||||
for i in 1 2 3; do (cd apps/desktop && bun ../../tools/desktop-release.ts exec -- bunx tauri build --bundles appimage,deb --ci) && break; [ $i = 3 ] && exit 1; sleep 30; done
|
|
||||||
mkdir -p dev && cp "$B/appimage/storebound_${V}_amd64.AppImage" "$B/deb/storebound_${V}_amd64.deb" dev/
|
|
||||||
chmod +x dev/*.AppImage
|
|
||||||
(cd /tmp && rm -rf squashfs-root && "$GITHUB_WORKSPACE/dev/storebound_${V}_amd64.AppImage" --appimage-extract >/dev/null && squashfs-root/usr/bin/storebound-desktop --self-test)
|
|
||||||
umask 077; printf '%s\n' "$FORBIDDEN_TERMS" > "$RUNNER_TEMP/terms.txt"
|
|
||||||
rc=0; STOREBOUND_FORBIDDEN_TERMS="$RUNNER_TEMP/terms.txt" bun tools/privacy-scan.ts dev/ || rc=$?
|
|
||||||
rm -f "$RUNNER_TEMP/terms.txt"; git checkout -- . ; exit $rc
|
|
||||||
- uses: actions/upload-artifact@v3
|
|
||||||
if: steps.dev.outcome == 'success'
|
|
||||||
with:
|
|
||||||
name: storebound-desktop-dev-linux
|
|
||||||
path: dev/
|
|
||||||
retention-days: 3
|
|
||||||
|
|
||||||
windows:
|
windows:
|
||||||
needs: gate
|
needs: gate
|
||||||
|
|
@ -318,78 +288,6 @@ jobs:
|
||||||
name: storebound-desktop-windows
|
name: storebound-desktop-windows
|
||||||
path: out/
|
path: out/
|
||||||
retention-days: 7
|
retention-days: 7
|
||||||
# dev channel (tools/desktop-dev.ts): see the linux job
|
|
||||||
- name: Dev build (NSIS, dev version)
|
|
||||||
id: dev
|
|
||||||
if: github.event_name == 'push' && github.ref == 'refs/heads/main'
|
|
||||||
continue-on-error: true
|
|
||||||
shell: pwsh
|
|
||||||
env:
|
|
||||||
FORBIDDEN_TERMS: ${{ secrets.FORBIDDEN_TERMS }}
|
|
||||||
run: |
|
|
||||||
$ErrorActionPreference = 'Stop'
|
|
||||||
$V = bun tools/desktop-dev.ts set
|
|
||||||
if ($LASTEXITCODE -ne 0) { throw "dev version stamp refused" }
|
|
||||||
bun tools/build-sidecars.ts --target bun-windows-x64
|
|
||||||
Remove-Item -Recurse -Force "$env:CARGO_TARGET_DIR\release\bundle\nsis" -ErrorAction SilentlyContinue
|
|
||||||
Push-Location apps/desktop
|
|
||||||
bun ../../tools/desktop-release.ts exec -- bunx tauri build --bundles nsis --ci
|
|
||||||
if ($LASTEXITCODE -ne 0) { throw "dev build failed" }
|
|
||||||
Pop-Location
|
|
||||||
New-Item -ItemType Directory -Force dev | Out-Null
|
|
||||||
Copy-Item "$env:CARGO_TARGET_DIR\release\bundle\nsis\storebound_${V}_x64-setup.exe" dev\
|
|
||||||
Start-Process -Wait -FilePath "dev\storebound_${V}_x64-setup.exe" -ArgumentList '/S'
|
|
||||||
& "$env:LOCALAPPDATA\storebound\storebound-desktop.exe" --self-test
|
|
||||||
if ($LASTEXITCODE -ne 0) { throw "dev self-test failed" }
|
|
||||||
Start-Process -Wait -FilePath "$env:LOCALAPPDATA\storebound\uninstall.exe" -ArgumentList '/S'
|
|
||||||
$t = Join-Path $env:RUNNER_TEMP "terms-$([guid]::NewGuid()).txt"
|
|
||||||
Set-Content -Path $t -Value $env:FORBIDDEN_TERMS -NoNewline:$false
|
|
||||||
$env:STOREBOUND_FORBIDDEN_TERMS = $t
|
|
||||||
bun tools/privacy-scan.ts dev
|
|
||||||
$rc = $LASTEXITCODE
|
|
||||||
Remove-Item -Force $t
|
|
||||||
git checkout -- .
|
|
||||||
if ($rc -ne 0) { throw "privacy scan failed" }
|
|
||||||
- uses: actions/upload-artifact@v3
|
|
||||||
if: steps.dev.outcome == 'success'
|
|
||||||
with:
|
|
||||||
name: storebound-desktop-dev-windows
|
|
||||||
path: dev/
|
|
||||||
retention-days: 3
|
|
||||||
|
|
||||||
# dev channel: the dev bundles of both jobs go to a Forgejo draft dev-<version> (no tag; the newest 5 kept); the VDS
|
|
||||||
# (tools/vds/storebound-desktop-dev, a root timer) signs them with the updater key and publishes
|
|
||||||
# storebound.dev/desktop/dev/latest.json. macOS has no dev build: Developer ID signing needs the Mac's GUI session.
|
|
||||||
dev:
|
|
||||||
needs: [linux, windows]
|
|
||||||
if: ${{ always() && github.event_name == 'push' && github.ref == 'refs/heads/main' && needs.linux.result == 'success' && needs.windows.result == 'success' }}
|
|
||||||
runs-on: ubuntu-22.04
|
|
||||||
timeout-minutes: 40
|
|
||||||
env:
|
|
||||||
FORGEJO_TOKEN: ${{ secrets.RELEASE_TOKEN }}
|
|
||||||
FORGEJO_URL: ${{ github.server_url }}
|
|
||||||
FORGEJO_ORIGIN: ${{ secrets.FORGEJO_ORIGIN }}
|
|
||||||
SHA: ${{ github.sha }}
|
|
||||||
steps:
|
|
||||||
- uses: actions/checkout@v4
|
|
||||||
- name: Tools
|
|
||||||
run: |
|
|
||||||
bash tools/ci-install-bun.sh
|
|
||||||
echo "$HOME/.bun/bin" >> "${FORGEJO_PATH:-$GITHUB_PATH}"
|
|
||||||
- uses: actions/download-artifact@v3
|
|
||||||
with:
|
|
||||||
name: storebound-desktop-dev-linux
|
|
||||||
path: dev
|
|
||||||
- uses: actions/download-artifact@v3
|
|
||||||
with:
|
|
||||||
name: storebound-desktop-dev-windows
|
|
||||||
path: dev
|
|
||||||
- name: Draft dev-<version> (newest 5 kept), then wait for the VDS to publish it
|
|
||||||
run: |
|
|
||||||
ls -la dev
|
|
||||||
bun tools/desktop-dev.ts record --dir dev --yes
|
|
||||||
V=$(ls dev | sed -n 's/^storebound_\(.*\)_x64-setup\.exe$/\1/p')
|
|
||||||
bun tools/desktop-dev.ts wait "$V" --minutes 20
|
|
||||||
|
|
||||||
record:
|
record:
|
||||||
needs: [gate, linux, windows]
|
needs: [gate, linux, windows]
|
||||||
|
|
@ -409,7 +307,7 @@ jobs:
|
||||||
# no apt: the installers were scanned with the private terms in their own jobs; this job only records
|
# no apt: the installers were scanned with the private terms in their own jobs; this job only records
|
||||||
- name: Tools
|
- name: Tools
|
||||||
run: |
|
run: |
|
||||||
bash tools/ci-install-bun.sh
|
curl -fsSL https://bun.sh/install | bash -s "bun-v${BUN_VERSION}" >/dev/null
|
||||||
echo "$HOME/.bun/bin" >> "${FORGEJO_PATH:-$GITHUB_PATH}"
|
echo "$HOME/.bun/bin" >> "${FORGEJO_PATH:-$GITHUB_PATH}"
|
||||||
[ -n "$FORGEJO_TOKEN" ] || { echo "secret RELEASE_TOKEN is missing (repo Settings > Actions > Secrets)" >&2; exit 1; }
|
[ -n "$FORGEJO_TOKEN" ] || { echo "secret RELEASE_TOKEN is missing (repo Settings > Actions > Secrets)" >&2; exit 1; }
|
||||||
- uses: actions/download-artifact@v3
|
- uses: actions/download-artifact@v3
|
||||||
|
|
|
||||||
|
|
@ -61,7 +61,7 @@ jobs:
|
||||||
- name: Tag, package.json version, every version copy and the CHANGELOG agree
|
- name: Tag, package.json version, every version copy and the CHANGELOG agree
|
||||||
id: check
|
id: check
|
||||||
run: |
|
run: |
|
||||||
bash tools/ci-install-bun.sh
|
curl -fsSL https://bun.sh/install | bash -s "bun-v${BUN_VERSION}" >/dev/null
|
||||||
echo "$HOME/.bun/bin" >> "${FORGEJO_PATH:-$GITHUB_PATH}"
|
echo "$HOME/.bun/bin" >> "${FORGEJO_PATH:-$GITHUB_PATH}"
|
||||||
export PATH="$HOME/.bun/bin:$PATH"
|
export PATH="$HOME/.bun/bin:$PATH"
|
||||||
bun tools/desktop-version.ts
|
bun tools/desktop-version.ts
|
||||||
|
|
|
||||||
6
.github/copilot-instructions.md
vendored
|
|
@ -20,12 +20,6 @@ storebound plus you, the AI agent, do the work. The owner is not your pair of ha
|
||||||
testers. (Also the owner's: canceling a submission, starting or stopping a store experiment, a console form's final
|
testers. (Also the owner's: canceling a submission, starting or stopping a store experiment, a console form's final
|
||||||
Submit / Create that a console plan lists in `buttons.final`, signing in and granting account permissions.) For
|
Submit / Create that a console plan lists in `buttons.final`, signing in and granting account permissions.) For
|
||||||
these you prepare everything, show the dry run, and the owner presses one button or says yes.
|
these you prepare everything, show the dry run, and the owner presses one button or says yes.
|
||||||
**Updates are agent steps:** a new version of an app that is already on the store (Play: the production track holds
|
|
||||||
a published release; App Store: a version of the platform is or was on sale) is yours end to end, no owner gate
|
|
||||||
per update: `storebound play release <aab> --production completed --yes`, `storebound play upload --track
|
|
||||||
production --yes`, `storebound apple submit --build <n> --yes`, `storebound apple release --manual-release --yes`
|
|
||||||
(docs/bypass.md). Only the **first-ever release** of an app stays the owner's (exit 3 `OWNER_STEP`: after the
|
|
||||||
owner's yes re-run with `--first-release`), plus removal from sale, live price changes and anything that costs money.
|
|
||||||
**Bypass mode** (`storebound settings bypass status`): when the owner turned it on, you run these owner steps too:
|
**Bypass mode** (`storebound settings bypass status`): when the owner turned it on, you run these owner steps too:
|
||||||
MCP `owner_step` (dry run first, then `dry_run: false`), `storebound api ... --yes --confirm <operationId>`, and
|
MCP `owner_step` (dry run first, then `dry_run: false`), `storebound api ... --yes --confirm <operationId>`, and
|
||||||
console plans' `buttons.final`. Say in one line what you pressed; every action is logged to
|
console plans' `buttons.final`. Say in one line what you pressed; every action is logged to
|
||||||
|
|
|
||||||
|
|
@ -21,12 +21,6 @@ storebound plus you, the AI agent, do the work. The owner is not your pair of ha
|
||||||
testers. (Also the owner's: canceling a submission, starting or stopping a store experiment, a console form's final
|
testers. (Also the owner's: canceling a submission, starting or stopping a store experiment, a console form's final
|
||||||
Submit / Create that a console plan lists in `buttons.final`, signing in and granting account permissions.) For
|
Submit / Create that a console plan lists in `buttons.final`, signing in and granting account permissions.) For
|
||||||
these you prepare everything, show the dry run, and the owner presses one button or says yes.
|
these you prepare everything, show the dry run, and the owner presses one button or says yes.
|
||||||
**Updates are agent steps:** a new version of an app that is already on the store (Play: the production track holds
|
|
||||||
a published release; App Store: a version of the platform is or was on sale) is yours end to end, no owner gate
|
|
||||||
per update: `storebound play release <aab> --production completed --yes`, `storebound play upload --track
|
|
||||||
production --yes`, `storebound apple submit --build <n> --yes`, `storebound apple release --manual-release --yes`
|
|
||||||
(docs/bypass.md). Only the **first-ever release** of an app stays the owner's (exit 3 `OWNER_STEP`: after the
|
|
||||||
owner's yes re-run with `--first-release`), plus removal from sale, live price changes and anything that costs money.
|
|
||||||
**Bypass mode** (`storebound settings bypass status`): when the owner turned it on, you run these owner steps too:
|
**Bypass mode** (`storebound settings bypass status`): when the owner turned it on, you run these owner steps too:
|
||||||
MCP `owner_step` (dry run first, then `dry_run: false`), `storebound api ... --yes --confirm <operationId>`, and
|
MCP `owner_step` (dry run first, then `dry_run: false`), `storebound api ... --yes --confirm <operationId>`, and
|
||||||
console plans' `buttons.final`. Say in one line what you pressed; every action is logged to
|
console plans' `buttons.final`. Say in one line what you pressed; every action is logged to
|
||||||
|
|
|
||||||
200
CHANGELOG.md
|
|
@ -3,187 +3,11 @@
|
||||||
|
|
||||||
## Unreleased
|
## Unreleased
|
||||||
|
|
||||||
## 0.8.78 · 2026-11-16
|
## 0.8.41 · 2026-10-23
|
||||||
|
|
||||||
- **apple build:** the device-family stop prints short `fix:` lines first (e.g. `fix: apple.ipad: true in storebound.config.ts`); a test proves a stopped build exits non-zero through the ship-step path.
|
|
||||||
|
|
||||||
## 0.8.77 · 2026-11-08
|
|
||||||
|
|
||||||
- **iPhone Duo:** outer and inner files are no longer cut to the first 10: the limit comes from Apple's reference data, and over it nothing changes and nothing is dropped. `apple screenshots --duo-only` writes only the Duo set. `apple cpp` no longer lists creative-assets flags.
|
|
||||||
|
|
||||||
## 0.8.76 · 2026-11-08
|
|
||||||
|
|
||||||
- 0.8.75 was tagged but not published (GitHub 502/504 in the Linux AppImage bundling). CI now takes the AppImage tools from a checked mirror instead of GitHub.
|
|
||||||
|
|
||||||
## 0.8.75 · 2026-11-08
|
|
||||||
|
|
||||||
- 0.8.74 was tagged but not published (GitHub release downloads answered 504 during the Linux AppImage bundling); 0.8.75 ships its section.
|
|
||||||
|
|
||||||
## 0.8.74 · 2026-11-08
|
|
||||||
|
|
||||||
- 0.8.73 was tagged but not published (a GitHub 504 in the Linux AppImage bundling); 0.8.74 ships its section below. CI caches the AppImage tools and retries the Linux bundle.
|
|
||||||
|
|
||||||
## 0.8.73 · 2026-11-08
|
|
||||||
|
|
||||||
- **iPhone Duo:** the live API names the platform IPHONE_APP_STORE (not IOS); accepted. A Duo problem now warns and the other screenshot sets still upload.
|
|
||||||
|
|
||||||
## 0.8.72 · 2026-11-08
|
|
||||||
|
|
||||||
- **iPhone Duo screenshots upload.** `apple screenshots` now sends them through the App Asset Library (display class
|
|
||||||
IPHONE_DUO, placement APP_SCREENSHOT) instead of skipping them as "not in the API" (pitfall 130).
|
|
||||||
|
|
||||||
## 0.8.71 · 2026-11-07
|
|
||||||
|
|
||||||
- 0.8.69 and 0.8.70 were tagged but not published (the desktop release check stopped them); 0.8.71 ships both sections below. Desktop Portfolio: the Play state of an app uses the same words as Releases ("Not live yet: in review or blocked before review").
|
|
||||||
|
|
||||||
## 0.8.70 · 2026-11-07
|
|
||||||
|
|
||||||
- Public MCP server: the bare host is the endpoint too. `POST /` answers MCP like `/mcp` (someone who pastes `https://mcp.example.com` into a connector gets connected), `GET /` sends a browser to the landing page and names the connect URL to any other client. A signed-in server keeps `/` closed.
|
|
||||||
|
|
||||||
## 0.8.69 · 2026-11-07
|
|
||||||
|
|
||||||
- Play: `play status` and `validate` list every build still active on a testing track below the production build, with the `play release --version-code <n> --<track> completed` that replaces it (an old build with a policy issue, e.g. READ_MEDIA_IMAGES, blocks Send changes for review for the whole app). A completed production release the store page does not show yet reads "Not live yet: in review or blocked before review" instead of "In review" (CLI and desktop). A commit with `--not-sent-for-review` that Play answers with 400 "Changes are sent for review automatically" is redone without the parameter (pitfalls #129).
|
|
||||||
|
|
||||||
## 0.8.68 · 2026-11-07
|
|
||||||
|
|
||||||
- Desktop app: `storebound` works in a terminal with only the app installed. On every start the app puts a launcher for its own CLI on the PATH (Windows: `%LOCALAPPDATA%\storebound\bin`, added to the user PATH once; macOS / Linux: `~/.local/bin`, added to `~/.zprofile` / `~/.profile` when missing). An npm / bun install stays first, a file that is not the app's launcher is never overwritten, AppImage runs skip it, `STOREBOUND_NO_CLI_SHIM=1` turns it off.
|
|
||||||
- `apple resubmit` / `apple submit --platform macos`: `apple.macos.noIap` leaves every in-app purchase out of the macOS submission and, without `apple.macos.gameCenter: true`, the Game Center switch is not touched (no `gameCenterAppVersions` call); the dry run names what it left out and why (pitfalls #128).
|
|
||||||
|
|
||||||
## 0.8.67 · 2026-11-03
|
|
||||||
|
|
||||||
- `apple build --platform macos`: runs `apple.macos.prebuild` (new) before `tauri build`, no longer `build.prebuild` / `apple.prebuild`, which belong to the iOS project (a Capacitor sync or OTA gate ran for a Tauri Mac build); the dry run names the skipped one.
|
|
||||||
|
|
||||||
## 0.8.66 · 2026-11-03
|
|
||||||
|
|
||||||
- `apple.macos: { listing, reviewNotes, gameCenter, noIap }`: an app with iOS and macOS versions gets its own Mac listing file and review notes (`apple listing --platform macos`, `apple review-details --platform macos`, new there); `validate` warns about iOS-only claims in a macOS version's texts (Game Center, tap / swipe, iPhone / iPad, in-app purchases with `noIap`).
|
|
||||||
- `apple upload <pkg>`: reading the package is bounded (pkgutil signature check 90 s, expand 5 min, then the `apple build` .json) and logged; the processing wait finds macOS builds (it looked only at iOS and sat silently until --timeout); every slow read prints a heartbeat; an SSH / non-GUI session is warned about up front.
|
|
||||||
- `apple build --platform macos`: `--tauri` takes a `tauri.<name>.conf.json` overlay (merged over tauri.conf.json and passed to `tauri build --config`; `tauri.appstore.conf.json` / `tauri.mas.conf.json` next to it are used by themselves); the Mac App Store entitlements come from `--entitlements`, `apple.macos.entitlements` or the merged config (a two-channel project signed the App Store app with its Developer ID plist); the plan lists the final keys, `get-task-allow` / `cs.disable-library-validation` stop the build (`--allow-entitlements`), other hardened-runtime exceptions warn.
|
|
||||||
- MCP `apple_review_details` takes `platform`.
|
|
||||||
- `apple release`: a 409 on a release type change is recognized again (a stray control character had broken the pattern).
|
|
||||||
|
|
||||||
## 0.8.65 · 2026-11-03
|
|
||||||
|
|
||||||
- `validate`: in-app purchases removed from sale (DEVELOPER_REMOVED_FROM_SALE, REMOVED_FROM_SALE) are no blockers; a warning only when the config still sells one.
|
|
||||||
- `shots capture --device landscape`: Mac App Store / Chromebook frames from a web build (desktop viewport at `shots.landscape.size`, default 1440x900 @2x) into `<lang>/landscape/`; on by default when the project renders a landscape size. The simulator and emulator sources skip it with a warning.
|
|
||||||
- `shots render` / `capture`: "playwright not found" now lists each place looked at and why it failed (an import error was reported as not found).
|
|
||||||
|
|
||||||
## 0.8.64 · 2026-11-02
|
|
||||||
|
|
||||||
- `validate` / `release plan`: a macOS version is checked against Mac screenshots (APP_DESKTOP, with `apple.mac`), not the iPhone / iPad sets; with no editable version, iOS is picked over macOS.
|
|
||||||
- `validate --play`: reads go through the locked read-only edit and retry once on a fresh edit when Play ends it ("This Edit has been deleted" was shown as a blocker; it is now a warning to re-run at most).
|
|
||||||
- Build numbers for macOS (`apple build --platform macos`, `apple upload` of a .pkg) come from every build of the app, as `apple next-build` does (a macOS-only list proposed a number an iOS build already had).
|
|
||||||
- `apple build --platform macos` runs `build.prebuild` / `apple.prebuild` before `tauri build` (`--no-prebuild` skips it), and the new `apple.macAppCheck` command on the built .app before productbuild ({file} = the .app; a nonzero exit stops the build).
|
|
||||||
- `apple signing status` / the Mac build dry run on Windows or Linux say the keys live on the Mac that made the certificates (build there) instead of suggesting a new certificate.
|
|
||||||
- Flows: a dry `flow run` plans the upload, TestFlight wait and distribute steps after a dry build instead of failing on the missing IPA; `beta` and `release` need VERSION (no silent 1.0.0); `beta` distributes to the config's internal TestFlight group when GROUP is empty; `release` has optional macOS steps (MAC_TAURI), PLAY_TRACK (e.g. beta = open testing) and a promote owner step.
|
|
||||||
## 0.8.63 · 2026-11-02
|
|
||||||
|
|
||||||
- Desktop: a second start at logon (`--hidden`, e.g. a Startup folder shortcut next to the Run entry) keeps the app in the tray instead of opening its window.
|
|
||||||
|
|
||||||
## 0.8.62 · 2026-10-29
|
|
||||||
|
|
||||||
- `doctor` warns when storebound runs from a folder macOS guards (~/Desktop, ~/Documents, ~/Downloads, iCloud Drive; e.g. a `bun link` to a checkout there): a launchd job or CI agent without access to it blocks in open() with no output.
|
|
||||||
- `apple build` prints a line before each slow step (App Store Connect reads, device families, web build), so a run without a terminal that stalls shows where.
|
|
||||||
## 0.8.61 · 2026-10-29
|
|
||||||
|
|
||||||
- TestFlight: `apple.testflight.description` takes a language id or its App Store locale (`en` or `en-US`; an `en-US` key was skipped silently), `check` names an unknown key, and `distribute --submit-review` stops (dry run: warns) when the app's primary locale has no beta localization (Beta App Review answers 422 MISSING_BETA_APP_LOCALIZATION).
|
|
||||||
## 0.8.60 · 2026-10-29
|
|
||||||
|
|
||||||
- `apple listing` creates a new version with the release type of the newest version before it (MANUAL or AFTER_APPROVAL) when `apple.releaseType` is not set; a first version stays MANUAL. The plan names where the type came from, and warns when `apple.releaseType` differs from the previous version's.
|
|
||||||
- `play release <aab> --dry` uploads nothing: it names the versionCode it would upload and the track changes it would make (the bundle went into a discarded edit, and a long upload could outlive the edit: "This edit has expired").
|
|
||||||
- `play build`: an absolute `--dir` / `play.build.dir` stays absolute (it was taken as a folder under the project and lost its leading slash); a `gradlew` without the exec bit (committed from Windows) is made executable with a note to commit the mode. The desktop release signs by key path only.
|
|
||||||
|
|
||||||
## 0.8.59 · 2026-10-29
|
|
||||||
|
|
||||||
- `mcp --http`: a `tools/call` that accepts `text/event-stream` gets SSE keepalive comments every 20 s and then its result, so long calls survive proxies that cut silent responses. The public server's App Store search keeps one budget of 20 calls a minute (Apple's limit).
|
|
||||||
- `storebound mcp --http --public`: a public, key-less MCP server (no sign-in, no store credentials, no project folders, no child processes, read-only). Tools: `skills_list`, `skill_get`, `pitfalls_search`, `store_limits`, `listing_lint` and `aso_search` (the public iTunes Search API, the only network call). Rate limit per client (`--rate`, 429 with Retry-After; `--trust-proxy` for X-Forwarded-For), 64 KB request bodies, CORS preflight. docs/mcp.md.
|
|
||||||
|
|
||||||
## 0.8.58 · 2026-10-29
|
|
||||||
|
|
||||||
- `check` and `scan` are fast on big repos: project walks skip dot folders (tool state, worktree copies), linked git worktrees and the folders git ignores (Pods, Carthage, SourcePackages and ios / android stay in), and read entry types from the listing instead of a stat per file. A game repo with worktree copies went from 244 s to 46 s for `check`.
|
|
||||||
- `storebound mcp --http`: one Streamable HTTP MCP server that every agent session of a machine shares (no process per session). Each tool gets a `project` argument (absolute path inside `--roots`); auth is a local bearer token (`~/.storebound/mcp-token`, made on first start) or, for a server behind TLS, OAuth bearer tokens checked by introspection (RFC 7662) with protected resource metadata (RFC 9728). docs/mcp.md.
|
|
||||||
|
|
||||||
## 0.8.57 · 2026-10-27
|
|
||||||
|
|
||||||
- `apple upload` finds the IPA of a build made with `--out`: `apple build` notes its IPA and out folder in `.storebound/last-apple-build.json`, and upload searches `--out` (new flag), then that last build's out, then `apple.build.out` / `build/ios`. When nothing is found, the error names every folder it searched and the last build's IPA.
|
|
||||||
|
|
||||||
## 0.8.56 · 2026-10-27
|
|
||||||
|
|
||||||
- Release type. `apple.releaseType: afterApproval | manual | scheduled` (+ `apple.earliestReleaseDate`): `apple listing` creates versions with it (MANUAL when unset, existing versions untouched) and `apple submit` / `resubmit` set it before submitting when it differs, the dry run showing old -> new. New `apple release --after-approval | --manual | --scheduled <ISO date> [--platform] [--version] [--first-release] --yes` changes it on a version App Review has not approved yet (clear refusal otherwise, with `--manual-release` as the way out); exit 7 when it already has that type; an update is an agent step, after-approval on the first version of an app is exit 3 OWNER_STEP. Pitfall 125.
|
|
||||||
- Device families. `validate` and `apple build` read the device families of the last live version (build bundle `deviceProtocols`, device models, iPad screenshot sets) and compare them with TARGETED_DEVICE_FAMILY in the Xcode project and `apple.ipad`; a gap stops `apple build` before the archive with the exact fix (ITMS-90101 otherwise comes after the build; `--allow-device-gap` overrides). Offline `check` warns when the live families are unknown or the config and project disagree. Pitfall 126.
|
|
||||||
- TestFlight. `apple testflight testers --invite` checks that the tester's group has an installable build (past Beta App Review for external groups); without one it adds the tester, skips the invite and prints when it can go out (exit 0). Apple's 409 NO_INSTALLABLE_BUILDS is handled the same way; `distribute --submit-review` prints the hint for testers not invited yet. Pitfall 127.
|
|
||||||
|
|
||||||
## 0.8.55 · 2026-10-26
|
|
||||||
|
|
||||||
- `apple build --path-free`: a checkout in a shared build folder outside the home folder is no longer a leak needle (dsymutil and the module cache record it; only home and user-name paths count).
|
|
||||||
|
|
||||||
## 0.8.54 · 2026-10-26
|
|
||||||
|
|
||||||
- `apple build` is hermetic and can be path-free. `--derived-data <dir>` (`apple.build.derivedData`) is xcodebuild `-derivedDataPath`; with `--out` (or `apple.build.out`) it defaults to `<out>/DerivedData` instead of `~/Library/Developer/Xcode/DerivedData` (without `--out` Xcode's folder stays). `--path-free` (`apple.build.pathFree`) remaps the home folder, checkout, out and DerivedData out of the app binary and the archive's dSYMs / Symbols (Swift `-debug-prefix-map` / `-file-prefix-map`, clang `-ffile-prefix-map`; dwarf-with-dsym stays, symbol upload keeps working), scans the archive and stops before the export with the hit count and the first file + offsets (never the paths). `--scan-paths` only scans and warns. A `--out` outside the home folder prints a hint. `--json` / `latest.json` carry `derivedData`, `pathFree` and `leaks`. Store-pitfalls 124.
|
|
||||||
|
|
||||||
## 0.8.53 · 2026-10-26
|
|
||||||
|
|
||||||
- Updates are agent steps (the owner's standing rule), first releases stay the owner's. `play release <aab> --production completed|inProgress --yes`, `play upload --track production --yes`, `apple submit --build <n> --yes` and `apple release --manual-release --yes` run without an owner gate, in a terminal and in a pipeline, when the store says the app is already live (Play: the production track holds a completed / inProgress / halted release; App Store: a version of the platform is or was `READY_FOR_SALE` / `READY_FOR_DISTRIBUTION` / `REPLACED_WITH_NEW_VERSION`; `cli/lib/release-kind.ts`). The result line carries `releaseKind`; a re-run is exit 7. The first-ever release of an app with `--yes` is exit 3 `OWNER_STEP` ("first release of this app: the owner approves it once"), approved by `--first-release` (after the owner's yes) or bypass mode; a person answering the prompt (no `--yes`) is the approval too. `apple release` is now a ship step (`--json`, `--result-file`, exit 7 when the version is released already). Policy in docs/bypass.md ("Updates are agent steps"), docs/ship-step.md, the release-management and play-first-release skills, AGENTS.md; pitfall 123 / 96.
|
|
||||||
|
|
||||||
## 0.8.52 · 2026-10-26
|
|
||||||
|
|
||||||
- `analytics snapshot` and `reports` for a collector: a store-only config may name the App Store app by `apple.appId` alone (`bundleId` null or absent; every write still needs it); the Play reports bucket also comes from env `PLAY_REPORTS_BUCKET` or the credential profile's `reportsBucket` when `play.reportsBucket` is missing; `analytics snapshot --json` prints the snapshot as one JSON document on stdout (also when every store failed, with the exit code 1) and `--no-write` skips the file.
|
|
||||||
- Snapshots carry active-user numbers per day: App Store App Usage (`sessions`, `activeDevices`, `sessionSeconds`, `crashes` from the App Sessions and App Crashes reports; a missing usage report is a `notes` line, not a failure) and Play `activeDeviceInstalls` and `totalUserInstalls` (installs overview file, else the country file summed) next to `installs` (Daily User Installs).
|
|
||||||
- `reports apple-sales --days N | --from YYYY-MM-DD [--to ...] --json` reads the daily SALES reports of a range into one JSON (per-day summary and totals per currency, range totals per currency, `missing` days listed, never errors); `reports play-sales --days N | --from ...` gives the daily revenue per currency from the estimated sales reports (orders, refunds, charged, refunded, net, by order charged date). MCP `reports` takes `days`, `from`, `to`.
|
|
||||||
- Release: the dev-channel CI job no longer gates a release.
|
|
||||||
|
|
||||||
## 0.8.51 · 2026-10-26
|
|
||||||
|
|
||||||
- Tagged but not published (the dev-channel job hit a CDN 502); everything ships in the next version.
|
|
||||||
|
|
||||||
## 0.8.50 · 2026-10-25
|
|
||||||
|
|
||||||
- App Groups fail early under automatic signing too: `apple signing status` / `ensure` and `apple build` read the App ID's APP_GROUPS capability settings and the newest profile the API lists for each bundle id (an Xcode-managed one too) and compare it with the target's `com.apple.security.application-groups`. A profile without the group (or the capability off) stops `signing ensure` and `apple build` before the archive with the exact portal steps (Certificates, Identifiers & Profiles > Identifiers > the ID > App Groups > Configure > tick the group > Continue > Save), the deep link `.../identifiers/bundleId/edit/<resource id>`, the plan command and `signing ensure --refresh-profile`; a group nothing can prove only warns with the same steps. `apple build --allow-app-group-gap` overrides.
|
|
||||||
- New `storebound console plan apple-app-group [--bundle-id <id>] [--groups group.a,group.b] [--lookup]` (MCP `console_plan`: `bundleId`, `groups`, `lookup`): the agent-first developer portal plan to assign an App Group to an extension's App ID (start URL per bundle id resource id, portal labels, answer sheet per extension, never-press list: Remove / Delete / Revoke). Its final Save is the agent's own (`buttons.finalByAgent`: a capability edit, not a store submission). `console verify apple-app-group` (MCP `console_verify`, API only) re-reads the App ID and the newest profile and fails while a group is missing or cannot be proven.
|
|
||||||
- Google access through a credential broker (`~/.storebound/broker.json`: `url`, `apiKeyFile`; env `STOREBOUND_BROKER_URL` / `STOREBOUND_BROKER_KEY_FILE`): Play tokens come from the broker's `POST /api/google/token` (in memory until 5 minutes before expiry, one request per account and scope, never logged; ya29. tokens and the API key redacted in errors), the local service account key stays the fallback when the broker does not answer or does not know the account; a broker that refuses the API key stops without retry. `PLAY_SERVICE_ACCOUNT_EMAIL` names the account (env, profile, project file); a profile opts out with `"broker": false`. The key file must be mode 600 on macOS / Linux. Play write commands read the package's Play permissions and enabled APIs from the broker first and stop before any Play call on a missing one (`CAN_MANAGE_TRACK_APKS`, `CAN_MANAGE_PUBLIC_LISTING`, `CAN_MANAGE_ORDERS`, `CAN_MANAGE_APP_CONTENT`, the Games Configuration API) with the exact permission or API and its link; `validate` lists them (gaps are blockers, SDK config drift a warning) and `--json` carries `credentials.play.source`; `doctor`, `accounts` and `apps check` / the desktop's Accounts view say whether tokens come from the broker or the key file. A Google 403 SERVICE_DISABLED / PERMISSION_DENIED in the Play client names the API or grant with its fix link and is never retried (pitfall 122, docs/credential-broker.md).
|
|
||||||
|
|
||||||
## 0.8.49 · 2026-10-25
|
|
||||||
|
|
||||||
- `play listing` for a language Play does not have yet uploads, in the same edit as the text, everything Play requires to commit it: icon, feature graphic, 2+ phone screenshots from `store/renders/<lang>/` and the tablet sets when the other languages have them (a set the folder lacks falls back to the default language's). The dry run lists the uploads or refuses with the missing file, instead of a 403 "too few screenshots" at commit. `play images` creates a Play listing that does not exist yet (text from the listing file) together with its images instead of skipping the language (pitfall 102).
|
|
||||||
|
|
||||||
## 0.8.48 · 2026-10-24
|
|
||||||
|
|
||||||
- Desktop tray: the right-click menu is drawn by the app (the design system's menu look) instead of the OS menu. Each submenu opens as its own small panel; the pin button, Ctrl+click or a middle click keeps a panel open (pinned): it can be dragged, steps aside so it never covers another pinned panel, and comes back after a restart. Values (the apps and their store state, mute) update in place after every store read without closing anything. The native menu stays as a fallback (and on Linux), built from the same menu tree. The left-click tray card is unchanged.
|
|
||||||
- Desktop right-click menus in the window work the same way: a menu's pin button keeps it open as a floating panel, a submenu can be torn off (its pin button, Ctrl+click or a middle click), pinned panels survive the next menu, can be dragged, and update in place when the data behind them changes ("Gone" when the thing they were for left the screen).
|
|
||||||
- `shots.feature.rotate` (degrees) is honoured by the Play feature graphic like a scene frame's `rotate`: added to the template tilt and the phone is re-fitted (`-90` stands a landscape game frame upright); with `shots.layout: "bleed"` the frame image is turned and still covers the canvas.
|
|
||||||
- `shots check` / `shots render` without frames for a language that has copy use the default language's frames (an info line, no failure); `shots.perLanguageFrames: true` requires per-language frames. `shots fonts --lang en,tr` limits the report to those languages (the font manifest keeps all of them).
|
|
||||||
- `shots capture` web shots take `waitSelector` and `click` selector lists per layout (`{ phone, tablet, any }`, data attributes first, `text=` fallback). A miss names the selector and the size with every candidate's match count; `shots capture --dry` prints the candidates per size and `--dry --probe` opens the pages and reports which one matched or MISSed on which size.
|
|
||||||
|
|
||||||
- `apple signing ensure` signs every target of the Xcode project, not only the app: it reads the pbxproj targets (app, app extensions such as a share extension or widget, watch app, App Clip: Release PRODUCT_BUNDLE_IDENTIFIER and entitlements), registers each extension's bundle id (`POST /v1/bundleIds`, platform from the profile type), enables the capabilities its entitlements need (read back) and, with manual signing, creates its App Store profile; `--dry` lists every target. `apple.signing.extensions` (`bundleId`, `name`, `capabilities`, `appGroups`) replaces the detected extensions when detection is wrong; `status` shows a target table.
|
|
||||||
- App Groups: the API cannot assign a group to a bundle id, so `signing status` / `ensure` and (manual signing) `apple build` decode the profile and compare its `com.apple.security.application-groups` with the target's entitlements; a gap names the developer portal link (`.../identifiers/bundleId/edit/<id>`) and the steps to tick the group. `signing ensure --refresh-profile` makes the profile again afterwards; `apple build --allow-app-group-gap` overrides.
|
|
||||||
- `apple build` over SSH / in CI: the refusal now names the fixes (GUI session `.command` file, a CI runner with an unlocked keychain, a build keychain). New `--keychain-unlock` (keychain password from `STOREBOUND_KEYCHAIN_PASSWORD`, never printed; runs `security unlock-keychain` and `set-key-partition-list`) and `--keychain <path>` (sign with a build keychain).
|
|
||||||
- `storebound api` writes: the usage, the dry-run message and the refusals show the agent form with an example (`--yes --confirm <operationId>`), and the store-api skill says both flags are needed.
|
|
||||||
- Play managed publishing: `storebound console plan play-publish-changes` (Publishing overview > "Changes ready to publish" > the owner's final "Publish N changes" + its confirm dialog; never-press: Discard changes, Stop managed publishing; `--lookup` lists the ready production releases from the API) and `console verify play-publish-changes` (API: passes when no production release is left ready to publish; or the page text). `play status` (and `--json` `readyToPublish`) prints the ready items and the plan hint, `storebound status` names the plan, and the desktop Releases tab shows the same hint with a button that opens Publishing overview. A release counts as ready to publish only when the public store page positively shows an older version; a 404, a failed or stale page read, a same or unparseable version is never ready (verify says "not determined" instead of a mismatch).
|
|
||||||
- `apple upload` / `play upload` `--pre-check "<cmd with {file}>"` (config `upload.preCheck`) runs your gate before any byte is sent; a nonzero exit refuses the upload (ship-step exit 1, `PRE_CHECK_FAILED`). `--evidence <path.json>` (`upload.evidence`) writes file, sha256, size, command, exit code, stdout tail, time and version, also on failure, and the result carries it as `preCheck`.
|
|
||||||
- New `storebound shots copy translate --to de,es` fills store/shots/copy.json per language (agent translation or `--translate "<cmd>"`), machine-translated until `shots copy reviewed`, caption limits respected; `shots copy check`; `check` / `shots render` name this command for a missing language.
|
|
||||||
- `apple game-center --locale-map en=en-GB` (config `games.localeMap`) maps a config language to the live Game Center locale; the dry run suggests it when the live Game Center has exactly one variant of the language.
|
|
||||||
- `play games`: a 403 SERVICE_DISABLED / accessNotConfigured names the Google Play Game Services Publishing API, the enable URL for the project and `console plan play-games-services`.
|
|
||||||
|
|
||||||
- `apple build --platform macos --tauri <src-tauri> [--path-free] [--unsigned]`: Mac App Store build of a Tauri app. Generated sandbox entitlements, Mac App Store profile (installed, `--profile` or from the API), Apple Distribution / Mac Installer Distribution identities, `tauri build --bundles app`, checks of the .app, `productbuild` to a signed .pkg, `pkgutil --check-signature`; `--path-free` remaps local paths in rustc and fails on any leak of the home folder or user name. `apple upload <pkg> --platform macos` uploads it (platform MAC_OS). New certificate types MAC_APP_DISTRIBUTION and MAC_INSTALLER_DISTRIBUTION. Pitfall 119.
|
|
||||||
- Desktop dev update channel: Settings > Updates offers Stable (the npm releases) and Dev (every push to main). Each push to main builds Windows and Linux bundles stamped `<next patch>-dev.<UTC commit time>` (above the current stable, below the next one); the VDS signs them and serves `storebound.dev/desktop/dev/latest.json` (newest 5 kept). The app checks its channel at start, every 15 minutes, after sleep and right after a channel switch, installs a strictly newer build quietly (deferred while the window is in use), never downgrades (dev back to stable waits for a newer stable), rewrites its logon autostart on every start, and the tray card shows version and channel. No macOS dev builds (Developer ID signing needs the Mac's GUI session).
|
|
||||||
- `shots` full-bleed layout: `shots.layout: "bleed"` fills the image with the app's own frame (no device, no background) and puts the scene title as a short corner caption (`corner`, `captionScale`, `captionWidth`, `captionInset` per scene) legible through a text shadow and soft glow only; the Play feature graphic shows the logo or `shots.feature.title`. Frames are captured per size at its own pixels in `<frames>/<lang>/<size>/<name>.png` (feature: `<lang>/feature/`), including the `mac` and `chromebook` sizes; `shots check` / `capture --source folder` verify aspect and native width. `shots.orientation: "landscape"` (bleed only) renders every portrait size landscape (stores accept it). Templates `template-bleed.html`, `feature-bleed.html`.
|
|
||||||
- `storebound desktop`: "opened" now also works when a hidden tray copy is already running. On Windows it prints "opened" only when a process of the installed path has a visible window (the running copy shows it through the single-instance handoff); on macOS / Linux a visible start or a handoff to the running copy counts, otherwise it says only a tray copy runs. The graceful stop waits 3 s on Windows (closing a tray app only hides it), then stops by PID.
|
|
||||||
|
|
||||||
## 0.8.47 · 2026-10-23
|
|
||||||
|
|
||||||
- `storebound desktop`: an update no longer reports "installed" while the old app stays. It stops the running app first (exact install path only, graceful close, then by PID), checks the installed exe's own version (Windows PE version resource instead of the registry entry; Info.plist on macOS) and fails with what it found, and prints "opened" only when a visible (not `--hidden`) process started from the installed path, otherwise it names the app's log.
|
|
||||||
- `play products` / `play subscriptions`: regions outside Play's min / max (a 649.99 USD product in KR: "must be between ₩70 and ₩600,000") are flagged in the dry run (old -> new) and clamped to the bound on write with a warning; `--skip-out-of-range-regions` leaves them out. Limits Play reports in a 400 are learned (`.storebound/play-price-limits.json`) and the write is retried. A product or subscription that fails no longer stops the others: per-product results, exit 1 at the end.
|
|
||||||
- `apple iap` / `apple subscriptions`: edits to approved (ACTIVE) localizations, which App Store Connect refuses with 409 UNMODIFIABLE, are marked "not editable now" in the dry run and skipped with a warning on write; prices and the other changes still apply. One IAP failing no longer stops the rest (results at the end, exit 1).
|
|
||||||
|
|
||||||
## 0.8.46 · 2026-10-23
|
|
||||||
|
|
||||||
- `storebound watch` has an `ingest` sink (`--notify ingest`, `ingest` in ~/.storebound/watch.json): a JSON POST per event to a push ingest endpoint with a Bearer token read from a file at send time (refused when group or world readable), 8 KiB body cap, 60 sends a minute, one retry on 5xx; `watch test` covers it.
|
|
||||||
- Ship-step contract for release pipelines (docs/ship-step.md): `play build | upload | release`, `apple build | upload | submit | resubmit` exit 0 ok, 1 failure, 2 usage, 3 needs the owner (with `error.code` and the console deep link), 4 store refused, 7 nothing to do; `--json` ends with exactly one result line on stdout, `--result-file` writes it atomically (also on failure), `--progress json` gives one JSON line per phase on stderr.
|
|
||||||
- `--env-file <path>` loads KEY=VALUE secrets before the credentials resolve (POSIX: mode 600 or stricter) and every known secret value is scrubbed from stdout, stderr and the result file; `--version-from version.json` takes the version and build ({version, build}, {versionName, versionCode}, {marketing, build}).
|
|
||||||
- Re-runs never upload twice: `play upload` with a versionCode Play has and `apple upload` with a build number App Store Connect has end with exit 7 and what is there; `play release` with the same release and `apple submit` of an already submitted build too.
|
|
||||||
- `play upload --track production` (the pipeline's update step; `--status draft` keeps it for the Console) and `--version-code N` to pick the AAB.
|
|
||||||
- New `storebound status [--app <name|store id|folder>] [--json]`: per platform the live and next version, build, track, review state and rollout %, read-only. `release status --app` also takes a folder or a store id.
|
|
||||||
- Desktop: every read goes through one registry: one store call per read however many buttons are clicked, overlapping buttons (Refresh all, card refresh, Check again, Import, Test) are busy and disabled together, a read just finished is not repeated, and all reads share the scheduler's rate limits and backoff.
|
- Desktop: every read goes through one registry: one store call per read however many buttons are clicked, overlapping buttons (Refresh all, card refresh, Check again, Import, Test) are busy and disabled together, a read just finished is not repeated, and all reads share the scheduler's rate limits and backoff.
|
||||||
- Desktop: tray mini card on left click (rejections, releases moving, crash alerts, recent low reviews, refresh, quick actions); right click keeps the menu.
|
- Desktop: tray mini card on left click (rejections, releases moving, crash alerts, recent low reviews, refresh, quick actions); right click keeps the menu.
|
||||||
|
|
||||||
- `apple build` / `apple upload`: `--allow-version-mismatch` is accepted (it was missing from the flag list); 1.0 and 1.0.0 count as the same version train, as on App Store Connect.
|
- `apple build` / `apple upload`: `--allow-version-mismatch` is accepted (it was missing from the flag list); 1.0 and 1.0.0 count as the same version train, as on App Store Connect.
|
||||||
- Desktop: custom context menus everywhere (apps, releases, art, reviews, checks, fields, products, accounts, folders) with keyboard navigation, Shift+F10 and submenus; the WebView2 browser menu and browser shortcuts are off.
|
- Desktop: custom context menus everywhere (apps, releases, art, reviews, checks, fields, products, accounts, folders) with keyboard navigation, Shift+F10 and submenus; the WebView2 browser menu and browser shortcuts are off.
|
||||||
- Desktop: each app shows once again (a folder project no longer appears a second time as a store-only app); a store app with a folder's bundle id or package is never listed separately.
|
- Desktop: each app shows once again (a folder project no longer appears a second time as a store-only app); a store app with a folder's bundle id or package is never listed separately.
|
||||||
|
|
@ -192,26 +16,6 @@
|
||||||
- Desktop: tabs in one row with a More menu, one Refresh, reviews keyboard (J/K, R, C, O), Settings and More tools search, sticky first column and compact density for wide tables, styled in-app dry-run preview before every write.
|
- Desktop: tabs in one row with a More menu, one Refresh, reviews keyboard (J/K, R, C, O), Settings and More tools search, sticky first column and compact density for wide tables, styled in-app dry-run preview before every write.
|
||||||
- Checks: "Open guide" opens the matching skill for every finding.
|
- Checks: "Open guide" opens the matching skill for every finding.
|
||||||
|
|
||||||
## 0.8.45 · 2026-10-23
|
|
||||||
|
|
||||||
- Tagged but not published (the release upload could not reach the server after an IP change); everything ships in the next version.
|
|
||||||
|
|
||||||
## 0.8.44 · 2026-10-23
|
|
||||||
|
|
||||||
- Tagged but not published (desktop clippy red on the bump commit); everything ships in the next version.
|
|
||||||
|
|
||||||
## 0.8.43 · 2026-10-23
|
|
||||||
|
|
||||||
- Tagged but not published (CI red: scrub hits in test fixtures, a ship-step test); everything ships in the next version.
|
|
||||||
|
|
||||||
## 0.8.42 · 2026-10-23
|
|
||||||
|
|
||||||
- Tagged but not published (generated API tables differed on Linux CI); everything ships in the next version.
|
|
||||||
|
|
||||||
## 0.8.41 · 2026-10-23
|
|
||||||
|
|
||||||
- Tagged but not published (a generated API table was stale in CI); everything ships in the next version.
|
|
||||||
|
|
||||||
## 0.8.40 · 2026-10-23
|
## 0.8.40 · 2026-10-23
|
||||||
|
|
||||||
- Tagged but not published (the desktop boot check stopped it); everything ships in the next version.
|
- Tagged but not published (the desktop boot check stopped it); everything ships in the next version.
|
||||||
|
|
|
||||||
|
|
@ -19,12 +19,6 @@ storebound plus you, the AI agent, do the work. The owner is not your pair of ha
|
||||||
testers. (Also the owner's: canceling a submission, starting or stopping a store experiment, a console form's final
|
testers. (Also the owner's: canceling a submission, starting or stopping a store experiment, a console form's final
|
||||||
Submit / Create that a console plan lists in `buttons.final`, signing in and granting account permissions.) For
|
Submit / Create that a console plan lists in `buttons.final`, signing in and granting account permissions.) For
|
||||||
these you prepare everything, show the dry run, and the owner presses one button or says yes.
|
these you prepare everything, show the dry run, and the owner presses one button or says yes.
|
||||||
**Updates are agent steps:** a new version of an app that is already on the store (Play: the production track holds
|
|
||||||
a published release; App Store: a version of the platform is or was on sale) is yours end to end, no owner gate
|
|
||||||
per update: `storebound play release <aab> --production completed --yes`, `storebound play upload --track
|
|
||||||
production --yes`, `storebound apple submit --build <n> --yes`, `storebound apple release --manual-release --yes`
|
|
||||||
(docs/bypass.md). Only the **first-ever release** of an app stays the owner's (exit 3 `OWNER_STEP`: after the
|
|
||||||
owner's yes re-run with `--first-release`), plus removal from sale, live price changes and anything that costs money.
|
|
||||||
**Bypass mode** (`storebound settings bypass status`): when the owner turned it on, you run these owner steps too:
|
**Bypass mode** (`storebound settings bypass status`): when the owner turned it on, you run these owner steps too:
|
||||||
MCP `owner_step` (dry run first, then `dry_run: false`), `storebound api ... --yes --confirm <operationId>`, and
|
MCP `owner_step` (dry run first, then `dry_run: false`), `storebound api ... --yes --confirm <operationId>`, and
|
||||||
console plans' `buttons.final`. Say in one line what you pressed; every action is logged to
|
console plans' `buttons.final`. Say in one line what you pressed; every action is logged to
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,6 @@
|
||||||
{
|
{
|
||||||
"name": "@storebound/desktop",
|
"name": "@storebound/desktop",
|
||||||
"version": "0.8.78",
|
"version": "0.8.41",
|
||||||
"private": true,
|
"private": true,
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
"type": "module",
|
"type": "module",
|
||||||
|
|
|
||||||
3
apps/desktop/src-tauri/Cargo.lock
generated
|
|
@ -4096,7 +4096,7 @@ checksum = "a2eb9349b6444b326872e140eb1cf5e7c522154d69e7a0ffb0fb81c06b37543f"
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "storebound-desktop"
|
name = "storebound-desktop"
|
||||||
version = "0.8.78"
|
version = "0.8.41"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"base64 0.22.1",
|
"base64 0.22.1",
|
||||||
"getrandom 0.3.4",
|
"getrandom 0.3.4",
|
||||||
|
|
@ -4126,7 +4126,6 @@ dependencies = [
|
||||||
"url",
|
"url",
|
||||||
"webview2-com",
|
"webview2-com",
|
||||||
"windows-core",
|
"windows-core",
|
||||||
"winreg",
|
|
||||||
"zip",
|
"zip",
|
||||||
]
|
]
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,6 @@
|
||||||
[package]
|
[package]
|
||||||
name = "storebound-desktop"
|
name = "storebound-desktop"
|
||||||
version = "0.8.78"
|
version = "0.8.41"
|
||||||
description = "storebound desktop: every game's releases on both stores in one window"
|
description = "storebound desktop: every game's releases on both stores in one window"
|
||||||
license = "MIT"
|
license = "MIT"
|
||||||
edition = "2021"
|
edition = "2021"
|
||||||
|
|
@ -53,8 +53,6 @@ zip = { version = "4", default-features = false, features = ["deflate-flate2-zli
|
||||||
[target.'cfg(windows)'.dependencies]
|
[target.'cfg(windows)'.dependencies]
|
||||||
webview2-com = "0.39"
|
webview2-com = "0.39"
|
||||||
windows-core = "0.62"
|
windows-core = "0.62"
|
||||||
# reads Startup apps' StartupApproved value (already in the tree through the autostart plugin)
|
|
||||||
winreg = "0.56"
|
|
||||||
|
|
||||||
[dev-dependencies]
|
[dev-dependencies]
|
||||||
tempfile = "3"
|
tempfile = "3"
|
||||||
|
|
|
||||||
|
|
@ -5,7 +5,7 @@ include!("src/commands_list.rs");
|
||||||
fn main() {
|
fn main() {
|
||||||
tauri_build::try_build(
|
tauri_build::try_build(
|
||||||
tauri_build::Attributes::new()
|
tauri_build::Attributes::new()
|
||||||
.app_manifest(tauri_build::AppManifest::new().commands(Box::leak([COMMANDS, CARD_COMMANDS, MENU_COMMANDS].concat().into_boxed_slice()))),
|
.app_manifest(tauri_build::AppManifest::new().commands(Box::leak([COMMANDS, CARD_COMMANDS].concat().into_boxed_slice()))),
|
||||||
)
|
)
|
||||||
.expect("tauri build script failed");
|
.expect("tauri build script failed");
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,21 +0,0 @@
|
||||||
{
|
|
||||||
"$schema": "../gen/schemas/desktop-schema.json",
|
|
||||||
"identifier": "menu-window",
|
|
||||||
"description": "The tray menu panels (menu-1, menu-2...: small frameless windows the app opens on a right click on the tray icon, one per open or pinned submenu) with the app's own bundled tray-menu page only. They may listen to app events (the live menu tree) and call the menu commands: read their panel, report their size, open, pin and close panels, pick a row, which runs the same tray action as the native menu, and start a drag of their own window (a pinned panel's header). They never read the stores or reach the sidecar; every command re-checks the window label and page origin in Rust.",
|
|
||||||
"windows": ["menu-*"],
|
|
||||||
"local": true,
|
|
||||||
"permissions": [
|
|
||||||
"core:event:allow-listen",
|
|
||||||
"core:event:allow-unlisten",
|
|
||||||
"core:window:allow-start-dragging",
|
|
||||||
"allow-menu-state",
|
|
||||||
"allow-menu-ready",
|
|
||||||
"allow-menu-open-sub",
|
|
||||||
"allow-menu-pin-sub",
|
|
||||||
"allow-menu-close-subs",
|
|
||||||
"allow-menu-close",
|
|
||||||
"allow-menu-dismiss",
|
|
||||||
"allow-menu-pin",
|
|
||||||
"allow-menu-select"
|
|
||||||
]
|
|
||||||
}
|
|
||||||
|
Before Width: | Height: | Size: 22 KiB After Width: | Height: | Size: 15 KiB |
|
Before Width: | Height: | Size: 69 KiB After Width: | Height: | Size: 43 KiB |
|
Before Width: | Height: | Size: 69 KiB After Width: | Height: | Size: 43 KiB |
|
Before Width: | Height: | Size: 2.4 KiB After Width: | Height: | Size: 1.6 KiB |
|
Before Width: | Height: | Size: 7.3 KiB After Width: | Height: | Size: 5.1 KiB |
|
Before Width: | Height: | Size: 16 KiB After Width: | Height: | Size: 15 KiB |
|
Before Width: | Height: | Size: 25 KiB After Width: | Height: | Size: 22 KiB |
|
Before Width: | Height: | Size: 27 KiB After Width: | Height: | Size: 24 KiB |
|
Before Width: | Height: | Size: 77 KiB After Width: | Height: | Size: 62 KiB |
|
Before Width: | Height: | Size: 2 KiB After Width: | Height: | Size: 1.5 KiB |
|
Before Width: | Height: | Size: 89 KiB After Width: | Height: | Size: 73 KiB |
|
Before Width: | Height: | Size: 3.7 KiB After Width: | Height: | Size: 2.3 KiB |
|
Before Width: | Height: | Size: 8.1 KiB After Width: | Height: | Size: 7.7 KiB |
|
Before Width: | Height: | Size: 12 KiB After Width: | Height: | Size: 11 KiB |
|
Before Width: | Height: | Size: 4.6 KiB After Width: | Height: | Size: 4.4 KiB |
|
Before Width: | Height: | Size: 158 KiB After Width: | Height: | Size: 73 KiB |
|
Before Width: | Height: | Size: 228 KiB After Width: | Height: | Size: 119 KiB |
|
|
@ -1,11 +0,0 @@
|
||||||
# Automatically generated - DO NOT EDIT!
|
|
||||||
|
|
||||||
[[permission]]
|
|
||||||
identifier = "allow-menu-close"
|
|
||||||
description = "Enables the menu_close command without any pre-configured scope."
|
|
||||||
commands.allow = ["menu_close"]
|
|
||||||
|
|
||||||
[[permission]]
|
|
||||||
identifier = "deny-menu-close"
|
|
||||||
description = "Denies the menu_close command without any pre-configured scope."
|
|
||||||
commands.deny = ["menu_close"]
|
|
||||||
|
|
@ -1,11 +0,0 @@
|
||||||
# Automatically generated - DO NOT EDIT!
|
|
||||||
|
|
||||||
[[permission]]
|
|
||||||
identifier = "allow-menu-close-subs"
|
|
||||||
description = "Enables the menu_close_subs command without any pre-configured scope."
|
|
||||||
commands.allow = ["menu_close_subs"]
|
|
||||||
|
|
||||||
[[permission]]
|
|
||||||
identifier = "deny-menu-close-subs"
|
|
||||||
description = "Denies the menu_close_subs command without any pre-configured scope."
|
|
||||||
commands.deny = ["menu_close_subs"]
|
|
||||||
|
|
@ -1,11 +0,0 @@
|
||||||
# Automatically generated - DO NOT EDIT!
|
|
||||||
|
|
||||||
[[permission]]
|
|
||||||
identifier = "allow-menu-dismiss"
|
|
||||||
description = "Enables the menu_dismiss command without any pre-configured scope."
|
|
||||||
commands.allow = ["menu_dismiss"]
|
|
||||||
|
|
||||||
[[permission]]
|
|
||||||
identifier = "deny-menu-dismiss"
|
|
||||||
description = "Denies the menu_dismiss command without any pre-configured scope."
|
|
||||||
commands.deny = ["menu_dismiss"]
|
|
||||||
|
|
@ -1,11 +0,0 @@
|
||||||
# Automatically generated - DO NOT EDIT!
|
|
||||||
|
|
||||||
[[permission]]
|
|
||||||
identifier = "allow-menu-open-sub"
|
|
||||||
description = "Enables the menu_open_sub command without any pre-configured scope."
|
|
||||||
commands.allow = ["menu_open_sub"]
|
|
||||||
|
|
||||||
[[permission]]
|
|
||||||
identifier = "deny-menu-open-sub"
|
|
||||||
description = "Denies the menu_open_sub command without any pre-configured scope."
|
|
||||||
commands.deny = ["menu_open_sub"]
|
|
||||||
|
|
@ -1,11 +0,0 @@
|
||||||
# Automatically generated - DO NOT EDIT!
|
|
||||||
|
|
||||||
[[permission]]
|
|
||||||
identifier = "allow-menu-pin"
|
|
||||||
description = "Enables the menu_pin command without any pre-configured scope."
|
|
||||||
commands.allow = ["menu_pin"]
|
|
||||||
|
|
||||||
[[permission]]
|
|
||||||
identifier = "deny-menu-pin"
|
|
||||||
description = "Denies the menu_pin command without any pre-configured scope."
|
|
||||||
commands.deny = ["menu_pin"]
|
|
||||||
|
|
@ -1,11 +0,0 @@
|
||||||
# Automatically generated - DO NOT EDIT!
|
|
||||||
|
|
||||||
[[permission]]
|
|
||||||
identifier = "allow-menu-pin-sub"
|
|
||||||
description = "Enables the menu_pin_sub command without any pre-configured scope."
|
|
||||||
commands.allow = ["menu_pin_sub"]
|
|
||||||
|
|
||||||
[[permission]]
|
|
||||||
identifier = "deny-menu-pin-sub"
|
|
||||||
description = "Denies the menu_pin_sub command without any pre-configured scope."
|
|
||||||
commands.deny = ["menu_pin_sub"]
|
|
||||||
|
|
@ -1,11 +0,0 @@
|
||||||
# Automatically generated - DO NOT EDIT!
|
|
||||||
|
|
||||||
[[permission]]
|
|
||||||
identifier = "allow-menu-ready"
|
|
||||||
description = "Enables the menu_ready command without any pre-configured scope."
|
|
||||||
commands.allow = ["menu_ready"]
|
|
||||||
|
|
||||||
[[permission]]
|
|
||||||
identifier = "deny-menu-ready"
|
|
||||||
description = "Denies the menu_ready command without any pre-configured scope."
|
|
||||||
commands.deny = ["menu_ready"]
|
|
||||||
|
|
@ -1,11 +0,0 @@
|
||||||
# Automatically generated - DO NOT EDIT!
|
|
||||||
|
|
||||||
[[permission]]
|
|
||||||
identifier = "allow-menu-select"
|
|
||||||
description = "Enables the menu_select command without any pre-configured scope."
|
|
||||||
commands.allow = ["menu_select"]
|
|
||||||
|
|
||||||
[[permission]]
|
|
||||||
identifier = "deny-menu-select"
|
|
||||||
description = "Denies the menu_select command without any pre-configured scope."
|
|
||||||
commands.deny = ["menu_select"]
|
|
||||||
|
|
@ -1,11 +0,0 @@
|
||||||
# Automatically generated - DO NOT EDIT!
|
|
||||||
|
|
||||||
[[permission]]
|
|
||||||
identifier = "allow-menu-state"
|
|
||||||
description = "Enables the menu_state command without any pre-configured scope."
|
|
||||||
commands.allow = ["menu_state"]
|
|
||||||
|
|
||||||
[[permission]]
|
|
||||||
identifier = "deny-menu-state"
|
|
||||||
description = "Denies the menu_state command without any pre-configured scope."
|
|
||||||
commands.deny = ["menu_state"]
|
|
||||||
|
|
@ -62,7 +62,7 @@ pub fn place(tray: Rect, work: Rect, card_w: f64, card_h: f64, gap: f64) -> (f64
|
||||||
|
|
||||||
/// Whether a card action word is one the card may send.
|
/// Whether a card action word is one the card may send.
|
||||||
pub fn valid_action(a: &str) -> bool {
|
pub fn valid_action(a: &str) -> bool {
|
||||||
matches!(a, "hide" | "open" | "route" | "refresh" | "mute" | "quit" | "external" | "ready" | "size")
|
matches!(a, "hide" | "open" | "route" | "refresh" | "mute" | "quit" | "external" | "ready")
|
||||||
}
|
}
|
||||||
|
|
||||||
// ---- the last snapshot ----
|
// ---- the last snapshot ----
|
||||||
|
|
@ -123,38 +123,6 @@ mod window {
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
/// The icon rectangle of the last show, so a size change keeps the card anchored to the icon.
|
|
||||||
static LAST_ICON: Mutex<Option<Rect>> = Mutex::new(None);
|
|
||||||
|
|
||||||
/// Card height in CSS px (what the page measured), clamped; the window keeps WIDTH.
|
|
||||||
fn height_px(h: f64) -> f64 { h.clamp(120.0, HEIGHT) }
|
|
||||||
|
|
||||||
/// Puts the card next to `tray` at its current height: its edge GAP from the icon, inside the work area.
|
|
||||||
fn anchor<R: Runtime>(app: &AppHandle<R>, w: &tauri::WebviewWindow<R>, tray: Rect, css_h: f64) {
|
|
||||||
let monitor = app.monitor_from_point(tray.x + tray.w / 2.0, tray.y + tray.h / 2.0).ok().flatten().or_else(|| w.primary_monitor().ok().flatten());
|
|
||||||
if let Some(m) = monitor {
|
|
||||||
let s = m.scale_factor();
|
|
||||||
let wa = m.work_area();
|
|
||||||
let work = Rect { x: wa.position.x as f64, y: wa.position.y as f64, w: wa.size.width as f64, h: wa.size.height as f64 };
|
|
||||||
let _ = w.set_size(tauri::PhysicalSize::new((WIDTH * s).round() as u32, (css_h * s).round() as u32));
|
|
||||||
let (x, y) = place(tray, work, WIDTH * s, css_h * s, GAP * s);
|
|
||||||
let _ = w.set_position(PhysicalPosition::new(x as i32, y as i32));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/// The page measured its height: resize the window to it and keep it anchored (the bottom edge stays above a bottom
|
|
||||||
/// taskbar, no empty band under the content).
|
|
||||||
pub fn resize<R: Runtime>(app: &AppHandle<R>, css_h: f64) {
|
|
||||||
let Some(w) = app.get_webview_window(LABEL) else { return };
|
|
||||||
let h = height_px(css_h);
|
|
||||||
if let Ok(mut c) = CURRENT_H.lock() { *c = h; }
|
|
||||||
if let Some(tray) = LAST_ICON.lock().ok().and_then(|t| *t) {
|
|
||||||
anchor(app, &w, tray, h);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
static CURRENT_H: Mutex<f64> = Mutex::new(HEIGHT);
|
|
||||||
|
|
||||||
/// A left click on the tray icon: shows the card next to the icon, or hides it when it is open.
|
/// A left click on the tray icon: shows the card next to the icon, or hides it when it is open.
|
||||||
pub fn toggle<R: Runtime>(app: &AppHandle<R>, tray: Rect) {
|
pub fn toggle<R: Runtime>(app: &AppHandle<R>, tray: Rect) {
|
||||||
let Some(w) = app.get_webview_window(LABEL) else { return };
|
let Some(w) = app.get_webview_window(LABEL) else { return };
|
||||||
|
|
@ -166,9 +134,14 @@ mod window {
|
||||||
if just_hidden() {
|
if just_hidden() {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if let Ok(mut t) = LAST_ICON.lock() { *t = Some(tray); }
|
let monitor = app.monitor_from_point(tray.x + tray.w / 2.0, tray.y + tray.h / 2.0).ok().flatten().or_else(|| w.primary_monitor().ok().flatten());
|
||||||
let h = CURRENT_H.lock().map(|c| *c).unwrap_or(HEIGHT);
|
if let Some(m) = monitor {
|
||||||
anchor(app, &w, tray, h);
|
let s = m.scale_factor();
|
||||||
|
let wa = m.work_area();
|
||||||
|
let work = Rect { x: wa.position.x as f64, y: wa.position.y as f64, w: wa.size.width as f64, h: wa.size.height as f64 };
|
||||||
|
let (x, y) = place(tray, work, WIDTH * s, HEIGHT * s, GAP * s);
|
||||||
|
let _ = w.set_position(PhysicalPosition::new(x as i32, y as i32));
|
||||||
|
}
|
||||||
let _ = w.show();
|
let _ = w.show();
|
||||||
let _ = w.set_focus();
|
let _ = w.set_focus();
|
||||||
let _ = app.emit_to(LABEL, "card-shown", ());
|
let _ = app.emit_to(LABEL, "card-shown", ());
|
||||||
|
|
@ -185,4 +158,4 @@ mod window {
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(desktop)]
|
#[cfg(desktop)]
|
||||||
pub use window::{create, hide, resize, toggle};
|
pub use window::{create, hide, toggle};
|
||||||
|
|
|
||||||
|
|
@ -49,11 +49,6 @@ fn guard_card(w: &WebviewWindow) -> Res<()> {
|
||||||
policy::require_card(w.label(), &url, cfg!(debug_assertions)).map_err(Fail::host)
|
policy::require_card(w.label(), &url, cfg!(debug_assertions)).map_err(Fail::host)
|
||||||
}
|
}
|
||||||
|
|
||||||
fn guard_menu(w: &WebviewWindow) -> Res<()> {
|
|
||||||
let url = w.url().map_err(|e| Fail::host(e.to_string()))?;
|
|
||||||
policy::require_menu(w.label(), &url, cfg!(debug_assertions)).map_err(Fail::host)
|
|
||||||
}
|
|
||||||
|
|
||||||
fn saved(s: &AppState) -> Res<std::sync::MutexGuard<'_, Saved>> {
|
fn saved(s: &AppState) -> Res<std::sync::MutexGuard<'_, Saved>> {
|
||||||
s.saved.lock().map_err(|_| Fail::host("state poisoned"))
|
s.saved.lock().map_err(|_| Fail::host("state poisoned"))
|
||||||
}
|
}
|
||||||
|
|
@ -1251,10 +1246,6 @@ pub fn settings_set(window: WebviewWindow, state: State<'_, AppState>, settings:
|
||||||
guard(&window)?;
|
guard(&window)?;
|
||||||
workspace::check_settings(&settings).map_err(Fail::host)?;
|
workspace::check_settings(&settings).map_err(Fail::host)?;
|
||||||
let mut st = saved(&state)?;
|
let mut st = saved(&state)?;
|
||||||
if st.settings.channel != settings.channel {
|
|
||||||
// a switched channel is checked right away by the background updater (lib.rs auto_update)
|
|
||||||
crate::updates::kick();
|
|
||||||
}
|
|
||||||
st.settings = settings.clone();
|
st.settings = settings.clone();
|
||||||
persist(&state, &st)?;
|
persist(&state, &st)?;
|
||||||
drop(st);
|
drop(st);
|
||||||
|
|
@ -1355,10 +1346,6 @@ pub fn card_action(window: WebviewWindow, app: AppHandle, action: String, arg: O
|
||||||
match action.as_str() {
|
match action.as_str() {
|
||||||
"hide" => crate::card::hide(&app),
|
"hide" => crate::card::hide(&app),
|
||||||
"ready" => { let _ = app.emit_to(policy::MAIN, "card-request", ()); }
|
"ready" => { let _ = app.emit_to(policy::MAIN, "card-request", ()); }
|
||||||
"size" => {
|
|
||||||
let h: f64 = arg.as_deref().unwrap_or_default().parse().map_err(|_| Fail::host("bad size"))?;
|
|
||||||
crate::card::resize(&app, h);
|
|
||||||
}
|
|
||||||
"open" => { crate::card::hide(&app); main(); }
|
"open" => { crate::card::hide(&app); main(); }
|
||||||
"refresh" => { let _ = app.emit_to(policy::MAIN, "tray-action", "read"); }
|
"refresh" => { let _ = app.emit_to(policy::MAIN, "tray-action", "read"); }
|
||||||
"mute" => { let _ = app.emit_to(policy::MAIN, "tray-action", "mute-toggle"); }
|
"mute" => { let _ = app.emit_to(policy::MAIN, "tray-action", "mute-toggle"); }
|
||||||
|
|
@ -1493,7 +1480,7 @@ pub struct UpdateInfo {
|
||||||
pub date: Option<String>,
|
pub date: Option<String>,
|
||||||
}
|
}
|
||||||
|
|
||||||
pub async fn find_update(app: &AppHandle, channel: &str) -> Res<Option<tauri_plugin_updater::Update>> {
|
async fn find_update(app: &AppHandle, channel: &str) -> Res<Option<tauri_plugin_updater::Update>> {
|
||||||
use tauri_plugin_updater::UpdaterExt;
|
use tauri_plugin_updater::UpdaterExt;
|
||||||
let url = url::Url::parse(updates::endpoint(channel)).map_err(|e| Fail::host(e.to_string()))?;
|
let url = url::Url::parse(updates::endpoint(channel)).map_err(|e| Fail::host(e.to_string()))?;
|
||||||
if !updates::endpoint_allowed(&url) {
|
if !updates::endpoint_allowed(&url) {
|
||||||
|
|
@ -1504,8 +1491,6 @@ pub async fn find_update(app: &AppHandle, channel: &str) -> Res<Option<tauri_plu
|
||||||
.endpoints(vec![url])
|
.endpoints(vec![url])
|
||||||
.map_err(|e| Fail::host(e.to_string()))?
|
.map_err(|e| Fail::host(e.to_string()))?
|
||||||
.timeout(std::time::Duration::from_secs(30))
|
.timeout(std::time::Duration::from_secs(30))
|
||||||
// the no-downgrade rule (updates::should_install), also after a switch from dev back to stable
|
|
||||||
.version_comparator(|current, remote| updates::should_install(¤t.to_string(), &remote.version.to_string()))
|
|
||||||
.build()
|
.build()
|
||||||
.map_err(|e| Fail::host(updates::error_text(&e.to_string())))?;
|
.map_err(|e| Fail::host(updates::error_text(&e.to_string())))?;
|
||||||
updater.check().await.map_err(|e| Fail::host(updates::error_text(&e.to_string())))
|
updater.check().await.map_err(|e| Fail::host(updates::error_text(&e.to_string())))
|
||||||
|
|
@ -1674,79 +1659,3 @@ pub async fn ai_fix_undo(window: WebviewWindow, run_id: String) -> Res<Vec<Strin
|
||||||
let rec = ai_fix::runs().lock().ok().and_then(|mut m| m.remove(&run_id)).ok_or_else(|| Fail::host("no such AI fix run"))?;
|
let rec = ai_fix::runs().lock().ok().and_then(|mut m| m.remove(&run_id)).ok_or_else(|| Fail::host("no such AI fix run"))?;
|
||||||
tauri::async_runtime::spawn_blocking(move || ai_fix::undo(&rec.0, &rec.1)).await.map_err(|e| Fail::host(e.to_string()))?.map_err(Fail::host)
|
tauri::async_runtime::spawn_blocking(move || ai_fix::undo(&rec.0, &rec.1)).await.map_err(|e| Fail::host(e.to_string()))?.map_err(Fail::host)
|
||||||
}
|
}
|
||||||
|
|
||||||
// ---- the tray menu panels (menu_panel.rs; only `menu-*` windows) ----
|
|
||||||
|
|
||||||
/// A panel: what it shows (the whole tree and its path into it).
|
|
||||||
#[tauri::command]
|
|
||||||
pub fn menu_state(window: WebviewWindow) -> Res<Option<crate::menu_panel::PanelInfo>> {
|
|
||||||
guard_menu(&window)?;
|
|
||||||
Ok(crate::menu_panel::panel_state(&window))
|
|
||||||
}
|
|
||||||
|
|
||||||
/// A panel measured itself (CSS px): sized, placed inside the work area and shown.
|
|
||||||
#[tauri::command]
|
|
||||||
pub fn menu_ready(window: WebviewWindow, width: f64, height: f64) -> Res<()> {
|
|
||||||
guard_menu(&window)?;
|
|
||||||
crate::menu_panel::ready(&window, width, height);
|
|
||||||
Ok(())
|
|
||||||
}
|
|
||||||
|
|
||||||
/// Opens a submenu beside this panel at the row whose top is `top` (CSS px).
|
|
||||||
#[tauri::command]
|
|
||||||
pub fn menu_open_sub(window: WebviewWindow, key: String, top: f64, focus: bool) -> Res<()> {
|
|
||||||
guard_menu(&window)?;
|
|
||||||
crate::menu_panel::open_sub(&window, &key, top, focus, false);
|
|
||||||
Ok(())
|
|
||||||
}
|
|
||||||
|
|
||||||
/// Ctrl / middle click on a submenu row: opens it as its own pinned panel.
|
|
||||||
#[tauri::command]
|
|
||||||
pub fn menu_pin_sub(window: WebviewWindow, key: String, top: f64) -> Res<()> {
|
|
||||||
guard_menu(&window)?;
|
|
||||||
crate::menu_panel::open_sub(&window, &key, top, false, true);
|
|
||||||
Ok(())
|
|
||||||
}
|
|
||||||
|
|
||||||
/// The pointer moved to a plain row: this panel's submenus close.
|
|
||||||
#[tauri::command]
|
|
||||||
pub fn menu_close_subs(window: WebviewWindow) -> Res<()> {
|
|
||||||
guard_menu(&window)?;
|
|
||||||
crate::menu_panel::close_subs(&window);
|
|
||||||
Ok(())
|
|
||||||
}
|
|
||||||
|
|
||||||
/// Closes this panel (Left / Esc in a submenu, X on a pinned one).
|
|
||||||
#[tauri::command]
|
|
||||||
pub fn menu_close(window: WebviewWindow, refocus_parent: bool) -> Res<()> {
|
|
||||||
guard_menu(&window)?;
|
|
||||||
crate::menu_panel::close(&window, refocus_parent);
|
|
||||||
Ok(())
|
|
||||||
}
|
|
||||||
|
|
||||||
/// Esc on the root menu: every transient panel closes.
|
|
||||||
#[tauri::command]
|
|
||||||
pub fn menu_dismiss(window: WebviewWindow) -> Res<()> {
|
|
||||||
guard_menu(&window)?;
|
|
||||||
crate::menu_panel::dismiss(window.app_handle());
|
|
||||||
Ok(())
|
|
||||||
}
|
|
||||||
|
|
||||||
/// Pins or unpins this panel.
|
|
||||||
#[tauri::command]
|
|
||||||
pub fn menu_pin(window: WebviewWindow, pinned: bool) -> Res<()> {
|
|
||||||
guard_menu(&window)?;
|
|
||||||
crate::menu_panel::pin(&window, pinned);
|
|
||||||
Ok(())
|
|
||||||
}
|
|
||||||
|
|
||||||
/// A pick: the same action as the native tray menu (an id tray.rs knows; anything else is refused).
|
|
||||||
#[tauri::command]
|
|
||||||
pub fn menu_select(window: WebviewWindow, id: String) -> Res<()> {
|
|
||||||
guard_menu(&window)?;
|
|
||||||
if id.len() > 300 || crate::tray::action_of(&id).is_none() {
|
|
||||||
return Err(Fail::host("unknown menu item"));
|
|
||||||
}
|
|
||||||
crate::menu_panel::select(&window, id);
|
|
||||||
Ok(())
|
|
||||||
}
|
|
||||||
|
|
|
||||||
|
|
@ -56,6 +56,3 @@ pub const COMMANDS: &[&str] = &[
|
||||||
|
|
||||||
/// The tray card window's commands (capabilities/card.json grants them to the `card` window only).
|
/// The tray card window's commands (capabilities/card.json grants them to the `card` window only).
|
||||||
pub const CARD_COMMANDS: &[&str] = &["card_get", "card_action"];
|
pub const CARD_COMMANDS: &[&str] = &["card_get", "card_action"];
|
||||||
|
|
||||||
/// The tray menu panels' commands (capabilities/menu.json grants them to the `menu-*` windows only).
|
|
||||||
pub const MENU_COMMANDS: &[&str] = &["menu_state", "menu_ready", "menu_open_sub", "menu_pin_sub", "menu_close_subs", "menu_close", "menu_dismiss", "menu_pin", "menu_select"];
|
|
||||||
|
|
|
||||||
|
|
@ -8,7 +8,6 @@ pub mod commands;
|
||||||
pub mod confirm;
|
pub mod confirm;
|
||||||
pub mod downloads;
|
pub mod downloads;
|
||||||
pub mod logs;
|
pub mod logs;
|
||||||
pub mod menu_panel;
|
|
||||||
pub mod policy;
|
pub mod policy;
|
||||||
pub mod profiles;
|
pub mod profiles;
|
||||||
pub mod registry;
|
pub mod registry;
|
||||||
|
|
@ -27,6 +26,7 @@ use tauri::menu::{Menu, MenuItem, PredefinedMenuItem, Submenu, WINDOW_SUBMENU_ID
|
||||||
use tauri::tray::{MouseButton, MouseButtonState, TrayIconBuilder, TrayIconEvent};
|
use tauri::tray::{MouseButton, MouseButtonState, TrayIconBuilder, TrayIconEvent};
|
||||||
use tauri::{AppHandle, Emitter, Manager, RunEvent, Runtime, WindowEvent};
|
use tauri::{AppHandle, Emitter, Manager, RunEvent, Runtime, WindowEvent};
|
||||||
use tauri_plugin_autostart::{MacosLauncher, ManagerExt};
|
use tauri_plugin_autostart::{MacosLauncher, ManagerExt};
|
||||||
|
use tauri_plugin_updater::UpdaterExt;
|
||||||
use tauri_plugin_deep_link::DeepLinkExt;
|
use tauri_plugin_deep_link::DeepLinkExt;
|
||||||
|
|
||||||
/// WebKitGTK's DMABUF renderer leaves the window blank on some Linux GPU / driver / VM combinations. Turn it off unless
|
/// WebKitGTK's DMABUF renderer leaves the window blank on some Linux GPU / driver / VM combinations. Turn it off unless
|
||||||
|
|
@ -44,76 +44,17 @@ fn started_hidden() -> bool {
|
||||||
std::env::args().any(|a| a == "--hidden")
|
std::env::args().any(|a| a == "--hidden")
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Tray icon: a left click shows the tray card (card.rs), a right click the app's own menu panels (menu_panel.rs, with
|
/// Tray icon: a click shows the window; the menu (tray.rs) opens the window, reads the stores, lists the apps with their
|
||||||
/// the tree from tray.rs: open the window, read the stores, the apps with their state, mute, updates, Settings and Quit,
|
/// state, mutes notifications, checks for updates, opens Settings and quits (the only real quit on Windows and Linux,
|
||||||
/// the only real quit on Windows and Linux, where closing the window keeps the app running in the tray). The window
|
/// where closing the window keeps the app running in the tray). The window refines tooltip, menu and icon after every
|
||||||
/// refines tooltip, menu and icon after every read (`tray_update`). Linux trays send no clicks: the native menu,
|
/// read (`tray_update`).
|
||||||
/// rendered from the same tree, stays on the icon there (and anywhere the panels fail).
|
|
||||||
fn tray(app: &tauri::App) -> tauri::Result<()> {
|
fn tray(app: &tauri::App) -> tauri::Result<()> {
|
||||||
let handle = app.handle();
|
let menu = tray::initial_menu(app.handle())?;
|
||||||
let panels = handle.state::<menu_panel::MenuPanels>();
|
let mut b = TrayIconBuilder::with_id("main").tooltip("storebound").menu(&menu).show_menu_on_left_click(false);
|
||||||
if let Ok(mut n) = panels.nodes.lock() {
|
|
||||||
*n = tray::initial_nodes();
|
|
||||||
}
|
|
||||||
let mut b = TrayIconBuilder::with_id("main").tooltip("storebound").show_menu_on_left_click(false);
|
|
||||||
if cfg!(target_os = "linux") {
|
|
||||||
panels.native.store(true, std::sync::atomic::Ordering::Relaxed);
|
|
||||||
b = b.menu(&tray::native_menu(handle, &tray::initial_nodes())?);
|
|
||||||
}
|
|
||||||
if let Some(icon) = app.default_window_icon() {
|
if let Some(icon) = app.default_window_icon() {
|
||||||
b = b.icon(icon.clone());
|
b = b.icon(icon.clone());
|
||||||
}
|
}
|
||||||
b.on_menu_event(|app, e| dispatch_menu(app, e.id().as_ref()))
|
b.on_menu_event(|app, e| match tray::action_of(e.id().as_ref()) {
|
||||||
.on_tray_icon_event(|t, e| {
|
|
||||||
let TrayIconEvent::Click { button, button_state: MouseButtonState::Up, rect, position, .. } = e else { return };
|
|
||||||
let app = t.app_handle();
|
|
||||||
// both open from the icon's rectangle (not the click point): their edge sits next to the icon, above a
|
|
||||||
// bottom taskbar, so nothing starts inside the taskbar
|
|
||||||
let scale = app.get_webview_window(policy::MAIN).and_then(|w| w.scale_factor().ok()).unwrap_or(1.0);
|
|
||||||
let p = rect.position.to_physical::<f64>(scale);
|
|
||||||
let s = rect.size.to_physical::<f64>(scale);
|
|
||||||
let icon = if s.width > 0.0 && s.height > 0.0 { card::Rect { x: p.x, y: p.y, w: s.width, h: s.height } } else { card::Rect { x: position.x, y: position.y, w: 1.0, h: 1.0 } };
|
|
||||||
match button {
|
|
||||||
MouseButton::Right => menu_panel::open_root(app, menu_panel::Anchor::Tray { x: icon.x, y: icon.y, w: icon.w, h: icon.h }),
|
|
||||||
MouseButton::Left => {
|
|
||||||
if app.get_webview_window(card::LABEL).is_none() {
|
|
||||||
show_main(app);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
card::toggle(app, icon);
|
|
||||||
}
|
|
||||||
_ => {}
|
|
||||||
}
|
|
||||||
})
|
|
||||||
.build(app)?;
|
|
||||||
Ok(())
|
|
||||||
}
|
|
||||||
|
|
||||||
/// A tray menu pick (a menu panel row or the native fallback menu): tray.rs maps the id to what it does.
|
|
||||||
/// Whether the person turned storebound off in Windows' Startup apps (Settings / Task Manager), from the
|
|
||||||
/// HKCU\...\Explorer\StartupApproved\Run value named like the Run entry: its first byte is even when enabled (02, 06),
|
|
||||||
/// odd when disabled (03, 07). No value: not turned off. Pure.
|
|
||||||
pub fn startup_approved_off(value: &[u8]) -> bool {
|
|
||||||
value.first().is_some_and(|b| b & 1 == 1)
|
|
||||||
}
|
|
||||||
|
|
||||||
#[cfg(windows)]
|
|
||||||
fn startup_disabled_by_user() -> bool {
|
|
||||||
use winreg::{enums::HKEY_CURRENT_USER, RegKey};
|
|
||||||
RegKey::predef(HKEY_CURRENT_USER)
|
|
||||||
.open_subkey(r"Software\Microsoft\Windows\CurrentVersion\Explorer\StartupApproved\Run")
|
|
||||||
.and_then(|k| k.get_raw_value("storebound"))
|
|
||||||
.map(|v| startup_approved_off(&v.bytes))
|
|
||||||
.unwrap_or(false)
|
|
||||||
}
|
|
||||||
|
|
||||||
#[cfg(not(windows))]
|
|
||||||
fn startup_disabled_by_user() -> bool {
|
|
||||||
false
|
|
||||||
}
|
|
||||||
|
|
||||||
pub fn dispatch_menu<R: Runtime>(app: &AppHandle<R>, id: &str) {
|
|
||||||
match tray::action_of(id) {
|
|
||||||
Some(tray::Action::Open) => show_main(app),
|
Some(tray::Action::Open) => show_main(app),
|
||||||
Some(tray::Action::Quit) => app.exit(0),
|
Some(tray::Action::Quit) => app.exit(0),
|
||||||
Some(tray::Action::Event(word)) => {
|
Some(tray::Action::Event(word)) => {
|
||||||
|
|
@ -124,84 +65,50 @@ pub fn dispatch_menu<R: Runtime>(app: &AppHandle<R>, id: &str) {
|
||||||
let _ = app.emit_to(policy::MAIN, "tray-route", route);
|
let _ = app.emit_to(policy::MAIN, "tray-route", route);
|
||||||
}
|
}
|
||||||
None => {}
|
None => {}
|
||||||
|
})
|
||||||
|
.on_tray_icon_event(|t, e| {
|
||||||
|
// left click: the tray card next to the icon (right click keeps the native menu)
|
||||||
|
if let TrayIconEvent::Click { button: MouseButton::Left, button_state: MouseButtonState::Up, rect, .. } = e {
|
||||||
|
let app = t.app_handle();
|
||||||
|
if app.get_webview_window(card::LABEL).is_none() {
|
||||||
|
show_main(app);
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
|
let scale = app.get_webview_window(policy::MAIN).and_then(|w| w.scale_factor().ok()).unwrap_or(1.0);
|
||||||
|
let p = rect.position.to_physical::<f64>(scale);
|
||||||
|
let s = rect.size.to_physical::<f64>(scale);
|
||||||
|
card::toggle(app, card::Rect { x: p.x, y: p.y, w: s.width, h: s.height });
|
||||||
|
}
|
||||||
|
})
|
||||||
|
.build(app)?;
|
||||||
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Silent self-update: at start (after a minute) and every 30 minutes, a signed update from storebound.dev is
|
/// Silent self-update: at start (after a minute) and every 30 minutes, a signed update from storebound.dev is
|
||||||
/// downloaded, installed and the app restarts with the same arguments (`--hidden` stays hidden). Errors are logged.
|
/// downloaded, installed and the app restarts with the same arguments (`--hidden` stays hidden). Errors are logged.
|
||||||
/// Background updater (docs/desktop-release.md, "Dev channel"): asks the chosen channel's latest.json at start, every
|
|
||||||
/// 15 minutes, right after a resume from sleep and when Settings switched the channel; installs a strictly newer, signed
|
|
||||||
/// build silently (the plugin checks the minisign signature first), deferred while the main window is in use (at most
|
|
||||||
/// updates::MAX_DEFERS checks in a row). Every step goes to host.log as `auto-update ...`.
|
|
||||||
fn auto_update(app: AppHandle) {
|
fn auto_update(app: AppHandle) {
|
||||||
tauri::async_runtime::spawn(async move {
|
tauri::async_runtime::spawn(async move {
|
||||||
use std::time::{Duration, Instant, SystemTime};
|
tokio::time::sleep(std::time::Duration::from_secs(60)).await;
|
||||||
tokio::time::sleep(Duration::from_secs(10)).await;
|
|
||||||
let mut first = true;
|
|
||||||
let mut last_check = Instant::now();
|
|
||||||
let mut last_wall = SystemTime::now();
|
|
||||||
let mut defers = 0u32;
|
|
||||||
loop {
|
loop {
|
||||||
let now_wall = SystemTime::now();
|
match app.updater() {
|
||||||
let gap = now_wall.duration_since(last_wall).map(|d| d.as_secs()).unwrap_or(0);
|
Ok(u) => match u.check().await {
|
||||||
last_wall = now_wall;
|
Ok(Some(update)) => {
|
||||||
let kicked = updates::take_kick();
|
logs::host("info", &format!("auto-update: {} available, installing", update.version));
|
||||||
if updates::check_due(first, kicked, gap, last_check.elapsed().as_secs()) {
|
match update.download_and_install(|_, _| {}, || {}).await {
|
||||||
let why = if first { "start" } else if kicked { "channel switched" } else if gap > updates::TICK_SECS + 60 { "resume" } else { "every 15 min" };
|
Ok(()) => app.restart(),
|
||||||
first = false;
|
Err(e) => logs::host("warn", &format!("auto-update: install failed: {e}")),
|
||||||
last_check = Instant::now();
|
|
||||||
defers = auto_update_once(&app, why, defers).await;
|
|
||||||
}
|
}
|
||||||
tokio::time::sleep(Duration::from_secs(updates::TICK_SECS)).await;
|
}
|
||||||
|
Ok(None) => {}
|
||||||
|
Err(e) => logs::host("warn", &format!("auto-update: check failed: {e}")),
|
||||||
|
},
|
||||||
|
Err(e) => logs::host("warn", &format!("auto-update: no updater: {e}")),
|
||||||
|
}
|
||||||
|
tokio::time::sleep(std::time::Duration::from_secs(30 * 60)).await;
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
/// One check of the background updater; returns the new count of deferred installs.
|
|
||||||
async fn auto_update_once(app: &AppHandle, why: &str, defers: u32) -> u32 {
|
|
||||||
let state = app.state::<commands::AppState>();
|
|
||||||
let channel = match state.saved.lock() {
|
|
||||||
Ok(s) => s.settings.channel.clone(),
|
|
||||||
Err(_) => return defers,
|
|
||||||
};
|
|
||||||
let current = env!("CARGO_PKG_VERSION");
|
|
||||||
let update = match commands::find_update(app, &channel).await {
|
|
||||||
Ok(Some(u)) => u,
|
|
||||||
Ok(None) => {
|
|
||||||
logs::host("info", &format!("auto-update ({why}): {current} is current on {channel}"));
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
Err(e) => {
|
|
||||||
logs::host("warn", &format!("auto-update ({why}): check of {channel} failed: {}", e.message));
|
|
||||||
return defers;
|
|
||||||
}
|
|
||||||
};
|
|
||||||
if !updates::should_install(current, &update.version) {
|
|
||||||
logs::host("info", &format!("auto-update ({why}): {channel} offers {}, not newer than {current}: no downgrade", update.version));
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
let main = app.get_webview_window(policy::MAIN);
|
|
||||||
let visible = main.as_ref().and_then(|w| w.is_visible().ok()).unwrap_or(false);
|
|
||||||
let focused = main.as_ref().and_then(|w| w.is_focused().ok()).unwrap_or(false);
|
|
||||||
if updates::defer_install(visible, focused, defers) {
|
|
||||||
logs::host("info", &format!("auto-update ({why}): {} on {channel} waits, the window is in use ({}/{})", update.version, defers + 1, updates::MAX_DEFERS));
|
|
||||||
return defers + 1;
|
|
||||||
}
|
|
||||||
logs::host("info", &format!("auto-update ({why}): installing {} from {channel} (this is {current})", update.version));
|
|
||||||
// the sidecar binary lives inside the app bundle that is about to be replaced
|
|
||||||
state.sidecar.shutdown().await;
|
|
||||||
match update.download_and_install(|_, _| {}, || {}).await {
|
|
||||||
Ok(()) => {
|
|
||||||
logs::host("info", &format!("auto-update: {} installed, restarting", update.version));
|
|
||||||
app.restart()
|
|
||||||
}
|
|
||||||
Err(e) => {
|
|
||||||
logs::host("warn", &format!("auto-update: install of {} failed: {}", update.version, updates::error_text(&e.to_string())));
|
|
||||||
0
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
fn show_main<R: Runtime>(app: &AppHandle<R>) {
|
fn show_main<R: Runtime>(app: &AppHandle<R>) {
|
||||||
if let Some(w) = app.get_webview_window(policy::MAIN) {
|
if let Some(w) = app.get_webview_window(policy::MAIN) {
|
||||||
let _ = w.unminimize();
|
let _ = w.unminimize();
|
||||||
|
|
@ -322,12 +229,11 @@ pub fn run() {
|
||||||
early_trace();
|
early_trace();
|
||||||
linux_webkit_env();
|
linux_webkit_env();
|
||||||
let app = tauri::Builder::default()
|
let app = tauri::Builder::default()
|
||||||
// single-instance first: a second start (or a storebound:// link) focuses the running app instead; a second
|
// single-instance first: a second start (or a storebound:// link) focuses the running app instead
|
||||||
// logon start (--hidden: the Run entry plus a Startup folder shortcut) stays in the tray
|
.plugin(tauri_plugin_single_instance::init(|app, _argv, _cwd| show_main(app)))
|
||||||
.plugin(tauri_plugin_single_instance::init(|app, argv, _cwd| if !argv.iter().any(|a| a == "--hidden") { show_main(app) }))
|
|
||||||
.plugin(tauri_plugin_deep_link::init())
|
.plugin(tauri_plugin_deep_link::init())
|
||||||
// never restore "visible": a --hidden start would otherwise pop the window up
|
// never restore "visible": a --hidden start would otherwise pop the window up
|
||||||
.plugin(tauri_plugin_window_state::Builder::new().with_filter(|label| !label.starts_with(menu_panel::LABEL_PREFIX)).with_state_flags(tauri_plugin_window_state::StateFlags::all() & !tauri_plugin_window_state::StateFlags::VISIBLE).build())
|
.plugin(tauri_plugin_window_state::Builder::new().with_state_flags(tauri_plugin_window_state::StateFlags::all() & !tauri_plugin_window_state::StateFlags::VISIBLE).build())
|
||||||
.plugin(tauri_plugin_autostart::init(MacosLauncher::LaunchAgent, Some(vec!["--hidden"])))
|
.plugin(tauri_plugin_autostart::init(MacosLauncher::LaunchAgent, Some(vec!["--hidden"])))
|
||||||
.plugin(tauri_plugin_shell::init())
|
.plugin(tauri_plugin_shell::init())
|
||||||
.plugin(tauri_plugin_opener::init())
|
.plugin(tauri_plugin_opener::init())
|
||||||
|
|
@ -375,22 +281,16 @@ pub fn run() {
|
||||||
if let Err(e) = commands::sync_machine(&state) {
|
if let Err(e) = commands::sync_machine(&state) {
|
||||||
logs::host("warn", &format!("accounts / app folders not synced at start: {}", e.message));
|
logs::host("warn", &format!("accounts / app folders not synced at start: {}", e.message));
|
||||||
}
|
}
|
||||||
// start at logon, in the tray: rewritten on every start (Windows: the HKCU Run entry then points at the
|
// start at logon, in the tray: set once (first run); the owner can turn it off in the OS afterwards
|
||||||
// running exe, so a moved or updated install fixes itself)
|
let marker = state.data_dir.join("autostart-set");
|
||||||
// ...unless the person turned it off (Windows Settings > Apps > Startup / Task Manager): that choice stands
|
if !marker.exists() {
|
||||||
if startup_disabled_by_user() {
|
|
||||||
logs::host("info", "autostart at logon left off (turned off in Windows Startup apps)");
|
|
||||||
} else {
|
|
||||||
match app.autolaunch().enable() {
|
match app.autolaunch().enable() {
|
||||||
Ok(()) => logs::host("info", "autostart at logon set (--hidden, tray)"),
|
Ok(()) => { let _ = std::fs::write(&marker, "1"); logs::host("info", "autostart at logon enabled (--hidden, tray)"); }
|
||||||
Err(e) => logs::host("warn", &format!("autostart not set: {e}")),
|
Err(e) => logs::host("warn", &format!("autostart not enabled: {e}")),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
app.manage(state);
|
app.manage(state);
|
||||||
app.manage(menu_panel::MenuPanels::default());
|
|
||||||
tray(app)?;
|
tray(app)?;
|
||||||
// pinned tray menu panels of the last session come back
|
|
||||||
menu_panel::restore(app.handle());
|
|
||||||
if let Err(e) = card::create(app.handle()) {
|
if let Err(e) = card::create(app.handle()) {
|
||||||
logs::host("warn", &format!("tray card not created: {e}"));
|
logs::host("warn", &format!("tray card not created: {e}"));
|
||||||
}
|
}
|
||||||
|
|
@ -491,15 +391,6 @@ pub fn run() {
|
||||||
commands::ai_fix_undo,
|
commands::ai_fix_undo,
|
||||||
commands::card_get,
|
commands::card_get,
|
||||||
commands::card_action,
|
commands::card_action,
|
||||||
commands::menu_state,
|
|
||||||
commands::menu_ready,
|
|
||||||
commands::menu_open_sub,
|
|
||||||
commands::menu_pin_sub,
|
|
||||||
commands::menu_close_subs,
|
|
||||||
commands::menu_close,
|
|
||||||
commands::menu_dismiss,
|
|
||||||
commands::menu_pin,
|
|
||||||
commands::menu_select,
|
|
||||||
])
|
])
|
||||||
.build(tauri::generate_context!())
|
.build(tauri::generate_context!())
|
||||||
.expect("storebound desktop failed to start");
|
.expect("storebound desktop failed to start");
|
||||||
|
|
|
||||||
|
|
@ -1,749 +0,0 @@
|
||||||
//! The tray's right-click menu, drawn by the app itself instead of the OS menu (tray-menu.html, src/traymenu/).
|
|
||||||
//!
|
|
||||||
//! - One tree: tray.rs builds the menu as `Entry`s, turned here into `Node`s. Every submenu has a stable key (its label
|
|
||||||
//! without the live part), so an open or pinned panel finds its submenu again after the values change.
|
|
||||||
//! - One window per panel: the root menu and each submenu are their own frameless, always-on-top `menu-N` windows. The
|
|
||||||
//! page measures itself and calls `menu_ready`; Rust sizes, places (inside the monitor's work area) and shows it.
|
|
||||||
//! - The panel book (`Book`, pure, tests/menu_panel.rs) records which panels are open, which are pinned and whose child
|
|
||||||
//! each one is. Transient panels close together (focus left all of them, Esc, a pick); pinned ones stay, can be
|
|
||||||
//! dragged, step aside so they never cover each other and come back after a restart (`menuPins` in state.json).
|
|
||||||
//! - Live: every `tray_update` pushes the tree to the open panels (`menu-model`), which update in place. Nothing polls.
|
|
||||||
//! - Idle: a closed panel is destroyed, never hidden.
|
|
||||||
//! - Fallback: when a panel window cannot be built or never reports ready, the native tray menu (rendered from the same
|
|
||||||
//! tree) comes back. Linux always uses it (its tray sends no click events).
|
|
||||||
//!
|
|
||||||
//! The top half is pure and covered by tests/menu_panel.rs.
|
|
||||||
use std::collections::BTreeMap;
|
|
||||||
use std::sync::atomic::{AtomicBool, AtomicU64, Ordering};
|
|
||||||
use std::sync::Mutex;
|
|
||||||
use std::time::Duration;
|
|
||||||
|
|
||||||
use serde::{Deserialize, Serialize};
|
|
||||||
|
|
||||||
use crate::tray::Entry;
|
|
||||||
|
|
||||||
pub const LABEL_PREFIX: &str = "menu-";
|
|
||||||
pub const PAGE: &str = "tray-menu.html";
|
|
||||||
pub const MODEL_EVENT: &str = "menu-model";
|
|
||||||
pub const PANEL_EVENT: &str = "menu-panel";
|
|
||||||
/// Gap to the work area's edges (physical px at scale 1).
|
|
||||||
pub const GAP: f64 = 8.0;
|
|
||||||
/// The estimated size of a panel before it measured itself (logical px).
|
|
||||||
pub const EST: (f64, f64) = (280.0, 220.0);
|
|
||||||
|
|
||||||
// ---------------------------------------------------------------- model
|
|
||||||
|
|
||||||
#[derive(Serialize, Clone, Debug, PartialEq, Eq)]
|
|
||||||
#[serde(tag = "kind", rename_all = "camelCase")]
|
|
||||||
pub enum Node {
|
|
||||||
Item { id: String, label: String, enabled: bool },
|
|
||||||
Sep,
|
|
||||||
Sub { key: String, label: String, items: Vec<Node> },
|
|
||||||
}
|
|
||||||
|
|
||||||
/// A submenu's stable key: its label without status glyphs and without the live part after ':' / '·' / '('
|
|
||||||
/// ("Apps (3)" -> "apps", "Apps · 2 need you" -> "apps"). Pinned panels are found again by these keys.
|
|
||||||
pub fn sub_key(label: &str) -> String {
|
|
||||||
let head = label.split([':', '\u{00B7}', '(']).next().unwrap_or("");
|
|
||||||
let mut out = String::new();
|
|
||||||
for c in head.chars() {
|
|
||||||
if c.is_alphanumeric() {
|
|
||||||
out.extend(c.to_lowercase());
|
|
||||||
} else if (c == ' ' || c == '-' || c == '_') && !out.is_empty() && !out.ends_with('-') {
|
|
||||||
out.push('-');
|
|
||||||
}
|
|
||||||
}
|
|
||||||
let out = out.trim_end_matches('-').to_string();
|
|
||||||
if out.is_empty() { "sub".into() } else { out }
|
|
||||||
}
|
|
||||||
|
|
||||||
/// Sibling submenus with the same key get "-2", "-3"...
|
|
||||||
pub fn unique_keys(mut nodes: Vec<Node>) -> Vec<Node> {
|
|
||||||
let mut seen: BTreeMap<String, u32> = BTreeMap::new();
|
|
||||||
for n in nodes.iter_mut() {
|
|
||||||
if let Node::Sub { key, .. } = n {
|
|
||||||
let count = seen.entry(key.clone()).or_insert(0);
|
|
||||||
*count += 1;
|
|
||||||
if *count > 1 {
|
|
||||||
*key = format!("{key}-{count}");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
nodes
|
|
||||||
}
|
|
||||||
|
|
||||||
/// The tray menu entries as panel nodes. A submenu keeps the fixed key tray.rs gives it (so a translated label never
|
|
||||||
/// changes it), else the key comes from its label.
|
|
||||||
pub fn from_entries(entries: &[Entry]) -> Vec<Node> {
|
|
||||||
let nodes = entries
|
|
||||||
.iter()
|
|
||||||
.map(|e| match e {
|
|
||||||
Entry::Item { id, label, enabled } => Node::Item { id: id.clone(), label: label.clone(), enabled: *enabled },
|
|
||||||
Entry::Separator => Node::Sep,
|
|
||||||
Entry::Sub { key, label, items } => Node::Sub { key: if key.is_empty() { sub_key(label) } else { sub_key(key) }, label: label.clone(), items: from_entries(items) },
|
|
||||||
})
|
|
||||||
.collect();
|
|
||||||
unique_keys(nodes)
|
|
||||||
}
|
|
||||||
|
|
||||||
/// The items of the submenu at `path` (empty path: the root) and its label.
|
|
||||||
pub fn find<'a>(nodes: &'a [Node], path: &[String]) -> Option<(&'a [Node], Option<&'a str>)> {
|
|
||||||
let mut current = nodes;
|
|
||||||
let mut label = None;
|
|
||||||
for key in path {
|
|
||||||
let (items, l) = current.iter().find_map(|n| match n {
|
|
||||||
Node::Sub { key: k, label: l, items } if k == key => Some((items.as_slice(), l.as_str())),
|
|
||||||
_ => None,
|
|
||||||
})?;
|
|
||||||
current = items;
|
|
||||||
label = Some(l);
|
|
||||||
}
|
|
||||||
Some((current, label))
|
|
||||||
}
|
|
||||||
|
|
||||||
// ---------------------------------------------------------------- placement
|
|
||||||
|
|
||||||
#[derive(Clone, Copy, Debug, PartialEq)]
|
|
||||||
pub enum Anchor {
|
|
||||||
/// The tray click point (physical).
|
|
||||||
Point { x: f64, y: f64 },
|
|
||||||
/// The tray icon's rectangle (physical): the root opens from the icon's edge that faces the screen, like the card.
|
|
||||||
Tray { x: f64, y: f64, w: f64, h: f64 },
|
|
||||||
/// Beside a parent panel: its left and right edge and the row's top (physical).
|
|
||||||
Beside { left: f64, right: f64, top: f64 },
|
|
||||||
/// A remembered top-left (pinned panels).
|
|
||||||
At { x: f64, y: f64 },
|
|
||||||
}
|
|
||||||
|
|
||||||
/// x, y, width, height (physical px).
|
|
||||||
pub type Rect = (f64, f64, f64, f64);
|
|
||||||
|
|
||||||
/// Keeps a panel of size w x h fully inside the work area (with `GAP`).
|
|
||||||
pub fn clamp_into(x: f64, y: f64, w: f64, h: f64, work: Rect) -> (f64, f64) {
|
|
||||||
let (wx, wy, ww, wh) = work;
|
|
||||||
(x.clamp(wx + GAP, (wx + ww - w - GAP).max(wx + GAP)), y.clamp(wy + GAP, (wy + wh - h - GAP).max(wy + GAP)))
|
|
||||||
}
|
|
||||||
|
|
||||||
/// Where a panel of `size` goes for `anchor`, inside the work area: the root opens away from the taskbar / menu bar the
|
|
||||||
/// click is near, a submenu beside its parent (flipped left at the screen edge), a pinned panel at its spot.
|
|
||||||
pub fn place_menu(anchor: Anchor, size: (f64, f64), work: Rect) -> (f64, f64) {
|
|
||||||
let (w, h) = size;
|
|
||||||
let (wx, wy, ww, wh) = work;
|
|
||||||
let (x, y) = match anchor {
|
|
||||||
Anchor::Point { x, y } => (if x + w > wx + ww { x - w } else { x }, if y + h > wy + wh { y - h } else { y }),
|
|
||||||
// same rule as the card: the panel's edge sits GAP from the icon, never over the taskbar
|
|
||||||
Anchor::Tray { x, y, w: iw, h: ih } => return crate::card::place(crate::card::Rect { x, y, w: iw, h: ih }, crate::card::Rect { x: wx, y: wy, w: ww, h: wh }, w, h, GAP),
|
|
||||||
Anchor::Beside { left, right, top } => (if right + w <= wx + ww - GAP { right - 2.0 } else { left - w + 2.0 }, top - 5.0),
|
|
||||||
Anchor::At { x, y } => (x, y),
|
|
||||||
};
|
|
||||||
clamp_into(x, y, w, h, work)
|
|
||||||
}
|
|
||||||
|
|
||||||
pub fn overlaps(a: Rect, b: Rect) -> bool {
|
|
||||||
a.0 < b.0 + b.2 && b.0 < a.0 + a.2 && a.1 < b.1 + b.3 && b.1 < a.1 + a.3
|
|
||||||
}
|
|
||||||
|
|
||||||
/// A spot for a newly pinned panel that covers no other pinned panel: below whatever it overlaps, then the next column.
|
|
||||||
/// Gives up after a while (a screen full of pins) and returns the clamped wish.
|
|
||||||
pub fn free_spot(want: Rect, others: &[Rect], work: Rect) -> (f64, f64) {
|
|
||||||
let (mut x, mut y, w, h) = want;
|
|
||||||
for _ in 0..64 {
|
|
||||||
let Some(hit) = others.iter().find(|o| overlaps((x, y, w, h), **o)) else {
|
|
||||||
return clamp_into(x, y, w, h, work);
|
|
||||||
};
|
|
||||||
y = hit.1 + hit.3 + GAP;
|
|
||||||
if y + h > work.1 + work.3 {
|
|
||||||
y = work.1 + GAP;
|
|
||||||
x += w + GAP;
|
|
||||||
if x + w > work.0 + work.2 {
|
|
||||||
x = work.0 + GAP;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
clamp_into(want.0, want.1, w, h, work)
|
|
||||||
}
|
|
||||||
|
|
||||||
// ---------------------------------------------------------------- panel book
|
|
||||||
|
|
||||||
#[derive(Clone, Debug, PartialEq)]
|
|
||||||
pub struct Panel {
|
|
||||||
pub path: Vec<String>,
|
|
||||||
pub pinned: bool,
|
|
||||||
pub parent: Option<String>,
|
|
||||||
pub anchor: Anchor,
|
|
||||||
/// Measured and shown once.
|
|
||||||
pub shown: bool,
|
|
||||||
/// Physical top-left once shown (kept for pins).
|
|
||||||
pub pos: Option<(f64, f64)>,
|
|
||||||
/// Opened from the keyboard: takes focus and starts on its first row.
|
|
||||||
pub focus: bool,
|
|
||||||
}
|
|
||||||
|
|
||||||
/// A pinned panel as state.json keeps it (`menuPins`).
|
|
||||||
#[derive(Serialize, Deserialize, Clone, Debug, PartialEq, Eq)]
|
|
||||||
pub struct PinRecord {
|
|
||||||
pub path: Vec<String>,
|
|
||||||
pub x: i32,
|
|
||||||
pub y: i32,
|
|
||||||
}
|
|
||||||
|
|
||||||
/// Which panels are open, which are pinned, who is whose child.
|
|
||||||
#[derive(Default, Debug)]
|
|
||||||
pub struct Book {
|
|
||||||
pub panels: BTreeMap<String, Panel>,
|
|
||||||
next: u32,
|
|
||||||
}
|
|
||||||
|
|
||||||
impl Book {
|
|
||||||
fn add(&mut self, path: Vec<String>, pinned: bool, parent: Option<String>, anchor: Anchor) -> String {
|
|
||||||
self.next += 1;
|
|
||||||
let label = format!("{LABEL_PREFIX}{}", self.next);
|
|
||||||
self.panels.insert(label.clone(), Panel { path, pinned, parent, anchor, shown: false, pos: None, focus: false });
|
|
||||||
label
|
|
||||||
}
|
|
||||||
|
|
||||||
fn remove_all(&mut self, labels: &[String]) {
|
|
||||||
for l in labels {
|
|
||||||
self.panels.remove(l);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
pub fn transient(&self) -> Vec<String> {
|
|
||||||
self.panels.iter().filter(|(_, p)| !p.pinned).map(|(l, _)| l.clone()).collect()
|
|
||||||
}
|
|
||||||
|
|
||||||
/// Transient panels below `label` (children first).
|
|
||||||
pub fn descendants(&self, label: &str) -> Vec<String> {
|
|
||||||
let mut out = Vec::new();
|
|
||||||
let mut frontier = vec![label.to_string()];
|
|
||||||
while let Some(l) = frontier.pop() {
|
|
||||||
for (child, p) in &self.panels {
|
|
||||||
if p.parent.as_deref() == Some(l.as_str()) && !p.pinned && !out.contains(child) {
|
|
||||||
out.push(child.clone());
|
|
||||||
frontier.push(child.clone());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
out
|
|
||||||
}
|
|
||||||
|
|
||||||
/// A fresh root menu: every transient panel closes, pinned ones stay. Returns the new label and the closed ones.
|
|
||||||
pub fn open_root(&mut self, anchor: Anchor) -> (String, Vec<String>) {
|
|
||||||
let closes = self.transient();
|
|
||||||
self.remove_all(&closes);
|
|
||||||
(self.add(vec![], false, None, anchor), closes)
|
|
||||||
}
|
|
||||||
|
|
||||||
/// Opens submenu `key` of `parent`; its other transient children close. None when that submenu already is the open
|
|
||||||
/// child, or the parent is gone. `pinned`: torn off as its own pinned panel (one pinned copy per submenu).
|
|
||||||
pub fn open_sub(&mut self, parent: &str, key: &str, anchor: Anchor, pinned: bool) -> Option<(String, Vec<String>)> {
|
|
||||||
let mut path = self.panels.get(parent)?.path.clone();
|
|
||||||
path.push(key.to_string());
|
|
||||||
if !pinned && self.panels.values().any(|p| p.parent.as_deref() == Some(parent) && !p.pinned && p.path == path) {
|
|
||||||
return None;
|
|
||||||
}
|
|
||||||
let mut closes = self.descendants(parent);
|
|
||||||
self.remove_all(&closes);
|
|
||||||
if pinned {
|
|
||||||
let old: Vec<String> = self.panels.iter().filter(|(_, p)| p.pinned && p.path == path).map(|(l, _)| l.clone()).collect();
|
|
||||||
for l in old {
|
|
||||||
closes.extend(self.close(&l));
|
|
||||||
}
|
|
||||||
return Some((self.add(path, true, None, anchor), closes));
|
|
||||||
}
|
|
||||||
Some((self.add(path, false, Some(parent.to_string()), anchor), closes))
|
|
||||||
}
|
|
||||||
|
|
||||||
/// Closes `label` and its transient children.
|
|
||||||
pub fn close(&mut self, label: &str) -> Vec<String> {
|
|
||||||
if !self.panels.contains_key(label) {
|
|
||||||
return vec![];
|
|
||||||
}
|
|
||||||
let mut out = self.descendants(label);
|
|
||||||
out.push(label.to_string());
|
|
||||||
self.remove_all(&out);
|
|
||||||
out
|
|
||||||
}
|
|
||||||
|
|
||||||
/// Every transient panel closes (Esc on the root, a pick, focus left the menus).
|
|
||||||
pub fn dismiss(&mut self) -> Vec<String> {
|
|
||||||
let t = self.transient();
|
|
||||||
self.remove_all(&t);
|
|
||||||
t
|
|
||||||
}
|
|
||||||
|
|
||||||
/// Pin or unpin. Pinning detaches the panel from its chain: the transient panels that are not its own children
|
|
||||||
/// close (returned). A second pinned copy of the same submenu closes too.
|
|
||||||
pub fn pin(&mut self, label: &str, on: bool) -> Vec<String> {
|
|
||||||
let Some(p) = self.panels.get(label) else { return vec![] };
|
|
||||||
let path = p.path.clone();
|
|
||||||
if !on {
|
|
||||||
if let Some(p) = self.panels.get_mut(label) {
|
|
||||||
p.pinned = false;
|
|
||||||
}
|
|
||||||
return vec![];
|
|
||||||
}
|
|
||||||
let mut closes: Vec<String> = self.panels.iter().filter(|(l, p)| p.pinned && p.path == path && l.as_str() != label).map(|(l, _)| l.clone()).collect();
|
|
||||||
if let Some(p) = self.panels.get_mut(label) {
|
|
||||||
p.pinned = true;
|
|
||||||
p.parent = None;
|
|
||||||
}
|
|
||||||
let mine = self.descendants(label);
|
|
||||||
closes.extend(self.transient().into_iter().filter(|l| l != label && !mine.contains(l)));
|
|
||||||
self.remove_all(&closes);
|
|
||||||
closes
|
|
||||||
}
|
|
||||||
|
|
||||||
/// The tree changed: transient panels whose submenu is gone close (with their children). Pinned ones stay and show
|
|
||||||
/// that their submenu is gone until it comes back (an app that is read again) or they are closed.
|
|
||||||
pub fn prune(&mut self, nodes: &[Node]) -> Vec<String> {
|
|
||||||
let gone: Vec<String> = self.panels.iter().filter(|(_, p)| !p.pinned && find(nodes, &p.path).is_none()).map(|(l, _)| l.clone()).collect();
|
|
||||||
let mut out = Vec::new();
|
|
||||||
for l in gone {
|
|
||||||
if self.panels.contains_key(&l) {
|
|
||||||
out.extend(self.close(&l));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
out
|
|
||||||
}
|
|
||||||
|
|
||||||
/// The pinned panels to save (only placed ones; in label order, so the order is stable).
|
|
||||||
pub fn pins(&self) -> Vec<PinRecord> {
|
|
||||||
self.panels
|
|
||||||
.values()
|
|
||||||
.filter(|p| p.pinned)
|
|
||||||
.filter_map(|p| p.pos.map(|(x, y)| PinRecord { path: p.path.clone(), x: x.round() as i32, y: y.round() as i32 }))
|
|
||||||
.collect()
|
|
||||||
}
|
|
||||||
|
|
||||||
/// Recreates pinned panels from a saved list (duplicates and more than `MAX_PINS` dropped).
|
|
||||||
pub fn restore(&mut self, pins: &[PinRecord]) -> Vec<String> {
|
|
||||||
let mut out = Vec::new();
|
|
||||||
for r in pins.iter().take(MAX_PINS) {
|
|
||||||
if self.panels.values().any(|p| p.pinned && p.path == r.path) || r.path.len() > 8 {
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
let (x, y) = (r.x as f64, r.y as f64);
|
|
||||||
let l = self.add(r.path.clone(), true, None, Anchor::At { x, y });
|
|
||||||
if let Some(p) = self.panels.get_mut(&l) {
|
|
||||||
p.pos = Some((x, y));
|
|
||||||
}
|
|
||||||
out.push(l);
|
|
||||||
}
|
|
||||||
out
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/// At most this many pinned panels are restored after a restart.
|
|
||||||
pub const MAX_PINS: usize = 12;
|
|
||||||
|
|
||||||
/// A panel label the app made (`menu-` and a number), for the window / command checks.
|
|
||||||
pub fn is_menu_label(label: &str) -> bool {
|
|
||||||
label.strip_prefix(LABEL_PREFIX).is_some_and(|n| !n.is_empty() && n.len() <= 9 && n.chars().all(|c| c.is_ascii_digit()))
|
|
||||||
}
|
|
||||||
|
|
||||||
// ---------------------------------------------------------------- runtime
|
|
||||||
|
|
||||||
#[derive(Serialize, Clone, Debug)]
|
|
||||||
#[serde(rename_all = "camelCase")]
|
|
||||||
pub struct PanelInfo {
|
|
||||||
pub label: String,
|
|
||||||
pub path: Vec<String>,
|
|
||||||
pub pinned: bool,
|
|
||||||
pub has_parent: bool,
|
|
||||||
pub focus_first: bool,
|
|
||||||
pub nodes: Vec<Node>,
|
|
||||||
}
|
|
||||||
|
|
||||||
/// The panels' shared state (managed by the app).
|
|
||||||
#[derive(Default)]
|
|
||||||
pub struct MenuPanels {
|
|
||||||
pub book: Mutex<Book>,
|
|
||||||
pub nodes: Mutex<Vec<Node>>,
|
|
||||||
/// The native menu took over (a panel failed, or Linux).
|
|
||||||
pub native: AtomicBool,
|
|
||||||
/// Bumped on every move of a pinned panel; the save runs once the moves stop.
|
|
||||||
moves: AtomicU64,
|
|
||||||
}
|
|
||||||
|
|
||||||
#[cfg(desktop)]
|
|
||||||
mod runtime {
|
|
||||||
use super::*;
|
|
||||||
use tauri::{AppHandle, Emitter, Manager, PhysicalPosition, PhysicalSize, WebviewUrl, WebviewWindow, WebviewWindowBuilder};
|
|
||||||
|
|
||||||
fn state(app: &AppHandle) -> tauri::State<'_, MenuPanels> {
|
|
||||||
app.state::<MenuPanels>()
|
|
||||||
}
|
|
||||||
|
|
||||||
fn book<R>(app: &AppHandle, f: impl FnOnce(&mut Book) -> R) -> R {
|
|
||||||
let s = state(app);
|
|
||||||
let mut b = s.book.lock().unwrap_or_else(|e| e.into_inner());
|
|
||||||
f(&mut b)
|
|
||||||
}
|
|
||||||
|
|
||||||
fn nodes(app: &AppHandle) -> Vec<Node> {
|
|
||||||
state(app).nodes.lock().map(|n| n.clone()).unwrap_or_default()
|
|
||||||
}
|
|
||||||
|
|
||||||
pub fn native_fallback(app: &AppHandle) -> bool {
|
|
||||||
state(app).native.load(Ordering::Relaxed)
|
|
||||||
}
|
|
||||||
|
|
||||||
/// Puts the native menu (from the current tree) on the tray: the fallback, and Linux.
|
|
||||||
pub fn set_native(app: &AppHandle) {
|
|
||||||
let Some(tray) = app.tray_by_id("main") else { return };
|
|
||||||
match crate::tray::native_menu(app, &nodes(app)) {
|
|
||||||
Ok(m) => {
|
|
||||||
let _ = tray.set_menu(Some(m));
|
|
||||||
}
|
|
||||||
Err(e) => crate::logs::host("warn", &format!("native tray menu not built: {e}")),
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/// Writes the pinned panels into state.json (`menuPins`).
|
|
||||||
fn save_pins(app: &AppHandle) {
|
|
||||||
let pins = book(app, |b| b.pins());
|
|
||||||
let Some(s) = app.try_state::<crate::commands::AppState>() else { return };
|
|
||||||
let Ok(mut st) = s.saved.lock() else { return };
|
|
||||||
if st.menu_pins == pins {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
st.menu_pins = pins;
|
|
||||||
if let Err(e) = crate::store::save(&s.data_dir, &st) {
|
|
||||||
crate::logs::host("warn", &format!("menu pins not saved: {e}"));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/// Stores the latest tree and pushes it to every open panel (they update in place). Panels of a submenu that is gone
|
|
||||||
/// close when transient. Cheap when nothing changed or no panel is open.
|
|
||||||
pub fn set_nodes(app: &AppHandle, next: Vec<Node>) {
|
|
||||||
let changed = {
|
|
||||||
let s = state(app);
|
|
||||||
let mut g = s.nodes.lock().unwrap_or_else(|e| e.into_inner());
|
|
||||||
let changed = *g != next;
|
|
||||||
*g = next.clone();
|
|
||||||
changed
|
|
||||||
};
|
|
||||||
if !changed {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
let (closes, open) = book(app, |b| (b.prune(&next), b.panels.keys().cloned().collect::<Vec<_>>()));
|
|
||||||
destroy(app, &closes);
|
|
||||||
for l in open {
|
|
||||||
let _ = app.emit_to(l.as_str(), MODEL_EVENT, &next);
|
|
||||||
}
|
|
||||||
if native_fallback(app) {
|
|
||||||
set_native(app);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
fn destroy(app: &AppHandle, labels: &[String]) {
|
|
||||||
for l in labels {
|
|
||||||
if let Some(w) = app.get_webview_window(l) {
|
|
||||||
let _ = w.destroy();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
fn build_window(app: &AppHandle, label: &str) -> tauri::Result<WebviewWindow> {
|
|
||||||
let b = WebviewWindowBuilder::new(app, label, WebviewUrl::App(PAGE.into()))
|
|
||||||
.title("storebound")
|
|
||||||
.inner_size(EST.0, EST.1)
|
|
||||||
.decorations(false)
|
|
||||||
.always_on_top(true)
|
|
||||||
.skip_taskbar(true)
|
|
||||||
.resizable(false)
|
|
||||||
.shadow(true)
|
|
||||||
.visible(false)
|
|
||||||
.focused(false);
|
|
||||||
#[cfg(not(target_os = "macos"))]
|
|
||||||
let b = b.transparent(true);
|
|
||||||
let window = b.build()?;
|
|
||||||
#[cfg(target_os = "macos")]
|
|
||||||
let _ = window.set_visible_on_all_workspaces(true);
|
|
||||||
let handle = app.clone();
|
|
||||||
let me = label.to_string();
|
|
||||||
window.on_window_event(move |event| match event {
|
|
||||||
tauri::WindowEvent::Focused(false) => {
|
|
||||||
let handle = handle.clone();
|
|
||||||
std::thread::spawn(move || {
|
|
||||||
std::thread::sleep(Duration::from_millis(160));
|
|
||||||
close_transient_unless_focused(&handle);
|
|
||||||
});
|
|
||||||
}
|
|
||||||
tauri::WindowEvent::Moved(pos) => {
|
|
||||||
let pinned = book(&handle, |b| match b.panels.get_mut(&me) {
|
|
||||||
Some(p) if p.shown => {
|
|
||||||
p.pos = Some((pos.x as f64, pos.y as f64));
|
|
||||||
p.pinned
|
|
||||||
}
|
|
||||||
_ => false,
|
|
||||||
});
|
|
||||||
if pinned {
|
|
||||||
// a drag sends many moves: save once they stop
|
|
||||||
let n = state(&handle).moves.fetch_add(1, Ordering::Relaxed) + 1;
|
|
||||||
let handle = handle.clone();
|
|
||||||
std::thread::spawn(move || {
|
|
||||||
std::thread::sleep(Duration::from_millis(400));
|
|
||||||
if state(&handle).moves.load(Ordering::Relaxed) == n {
|
|
||||||
save_pins(&handle);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
}
|
|
||||||
_ => {}
|
|
||||||
});
|
|
||||||
Ok(window)
|
|
||||||
}
|
|
||||||
|
|
||||||
/// Focus left a menu window: every transient panel closes unless one of them has focus now.
|
|
||||||
fn close_transient_unless_focused(app: &AppHandle) {
|
|
||||||
let transient = book(app, |b| b.transient());
|
|
||||||
if transient.iter().any(|l| app.get_webview_window(l).and_then(|w| w.is_focused().ok()).unwrap_or(false)) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
book(app, |b| {
|
|
||||||
for l in &transient {
|
|
||||||
b.panels.remove(l);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
destroy(app, &transient);
|
|
||||||
}
|
|
||||||
|
|
||||||
/// The panels cannot be shown: the native menu goes on the tray and opens once now.
|
|
||||||
fn native_popup(app: &AppHandle) {
|
|
||||||
if !state(app).native.swap(true, Ordering::Relaxed) {
|
|
||||||
crate::logs::host("warn", "tray menu panels unavailable: the native menu is used");
|
|
||||||
}
|
|
||||||
set_native(app);
|
|
||||||
let handle = app.clone();
|
|
||||||
let _ = app.run_on_main_thread(move || {
|
|
||||||
if let (Some(w), Ok(menu)) = (handle.get_webview_window(crate::policy::MAIN), crate::tray::native_menu(&handle, &nodes(&handle))) {
|
|
||||||
let _ = w.popup_menu(&menu);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
/// A right click on the tray icon: a fresh root menu next to the icon (`anchor`: Anchor::Tray, physical px).
|
|
||||||
pub fn open_root(app: &AppHandle, anchor: Anchor) {
|
|
||||||
if native_fallback(app) {
|
|
||||||
return; // the native menu is on the tray and opens by itself
|
|
||||||
}
|
|
||||||
let (label, closes) = book(app, |b| b.open_root(anchor));
|
|
||||||
destroy(app, &closes);
|
|
||||||
let handle = app.clone();
|
|
||||||
std::thread::spawn(move || {
|
|
||||||
if let Err(e) = build_window(&handle, &label) {
|
|
||||||
crate::logs::host("warn", &format!("tray menu panel not built: {e}"));
|
|
||||||
book(&handle, |b| b.panels.remove(&label));
|
|
||||||
native_popup(&handle);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
std::thread::sleep(Duration::from_millis(2500));
|
|
||||||
if book(&handle, |b| b.panels.get(&label).map(|p| p.shown)) == Some(false) {
|
|
||||||
crate::logs::host("warn", "tray menu panel never reported ready");
|
|
||||||
let closes = book(&handle, |b| b.close(&label));
|
|
||||||
destroy(&handle, &closes);
|
|
||||||
native_popup(&handle);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
/// Brings back the pinned panels of the last session (state.json `menuPins`).
|
|
||||||
pub fn restore(app: &AppHandle) {
|
|
||||||
let pins = app.try_state::<crate::commands::AppState>().and_then(|s| s.saved.lock().ok().map(|st| st.menu_pins.clone())).unwrap_or_default();
|
|
||||||
if pins.is_empty() || native_fallback(app) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
let labels = book(app, |b| b.restore(&pins));
|
|
||||||
let handle = app.clone();
|
|
||||||
std::thread::spawn(move || {
|
|
||||||
for l in labels {
|
|
||||||
if build_window(&handle, &l).is_err() {
|
|
||||||
book(&handle, |b| b.panels.remove(&l));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
fn work_area(app: &AppHandle, x: f64, y: f64) -> Option<Rect> {
|
|
||||||
let m = app.monitor_from_point(x, y).ok().flatten().or_else(|| app.primary_monitor().ok().flatten())?;
|
|
||||||
let w = m.work_area();
|
|
||||||
Some((w.position.x as f64, w.position.y as f64, w.size.width as f64, w.size.height as f64))
|
|
||||||
}
|
|
||||||
|
|
||||||
fn anchor_point(a: Anchor) -> (f64, f64) {
|
|
||||||
match a {
|
|
||||||
Anchor::Point { x, y } | Anchor::At { x, y } => (x, y),
|
|
||||||
Anchor::Tray { x, y, w, h } => (x + w / 2.0, y + h / 2.0),
|
|
||||||
Anchor::Beside { right, top, .. } => (right, top),
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
fn outer_rect(w: &WebviewWindow) -> Option<Rect> {
|
|
||||||
let p = w.outer_position().ok()?;
|
|
||||||
let s = w.outer_size().ok()?;
|
|
||||||
Some((p.x as f64, p.y as f64, s.width as f64, s.height as f64))
|
|
||||||
}
|
|
||||||
|
|
||||||
fn pinned_rects(app: &AppHandle, skip: &str) -> Vec<Rect> {
|
|
||||||
let labels: Vec<String> = book(app, |b| b.panels.iter().filter(|(l, p)| p.pinned && l.as_str() != skip).map(|(l, _)| l.clone()).collect());
|
|
||||||
labels.iter().filter_map(|l| app.get_webview_window(l).and_then(|w| outer_rect(&w))).collect()
|
|
||||||
}
|
|
||||||
|
|
||||||
// ---- what the panel page calls (commands.rs checks the window first) ----
|
|
||||||
|
|
||||||
pub fn panel_state(window: &WebviewWindow) -> Option<PanelInfo> {
|
|
||||||
let app = window.app_handle();
|
|
||||||
let p = book(app, |b| b.panels.get(window.label()).cloned())?;
|
|
||||||
Some(PanelInfo { label: window.label().into(), path: p.path, pinned: p.pinned, has_parent: p.parent.is_some(), focus_first: p.focus, nodes: nodes(app) })
|
|
||||||
}
|
|
||||||
|
|
||||||
/// The panel measured itself (CSS px): size it, place it inside the work area, show it the first time.
|
|
||||||
pub fn ready(window: &WebviewWindow, width: f64, height: f64) {
|
|
||||||
let app = window.app_handle().clone();
|
|
||||||
let Some(panel) = book(&app, |b| b.panels.get(window.label()).cloned()) else { return };
|
|
||||||
let scale = window.scale_factor().unwrap_or(1.0);
|
|
||||||
let size = ((width.clamp(120.0, 600.0) * scale).ceil(), (height.clamp(40.0, 900.0) * scale).ceil());
|
|
||||||
let (ax, ay) = panel.pos.unwrap_or_else(|| anchor_point(panel.anchor));
|
|
||||||
let Some(work) = work_area(&app, ax, ay) else { return };
|
|
||||||
let (x, y) = if panel.shown {
|
|
||||||
let (x, y, _, _) = outer_rect(window).unwrap_or((ax, ay, 0.0, 0.0));
|
|
||||||
clamp_into(x, y, size.0, size.1, work)
|
|
||||||
} else if let Some((x, y)) = panel.pos {
|
|
||||||
clamp_into(x, y, size.0, size.1, work)
|
|
||||||
} else {
|
|
||||||
place_menu(panel.anchor, size, work)
|
|
||||||
};
|
|
||||||
let _ = window.set_size(PhysicalSize::new(size.0 as u32, size.1 as u32));
|
|
||||||
let _ = window.set_position(PhysicalPosition::new(x as i32, y as i32));
|
|
||||||
if !panel.shown {
|
|
||||||
book(&app, |b| {
|
|
||||||
if let Some(p) = b.panels.get_mut(window.label()) {
|
|
||||||
p.shown = true;
|
|
||||||
p.pos = Some((x, y));
|
|
||||||
}
|
|
||||||
});
|
|
||||||
let _ = window.show();
|
|
||||||
if panel.focus || (panel.parent.is_none() && !panel.pinned) {
|
|
||||||
let _ = window.set_focus();
|
|
||||||
}
|
|
||||||
if panel.pinned {
|
|
||||||
save_pins(&app);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/// Opens submenu `key` beside this panel at the row whose top is `top` (CSS px). `pinned`: torn off (Ctrl / middle
|
|
||||||
/// click), placed so it covers no other pinned panel.
|
|
||||||
pub fn open_sub(window: &WebviewWindow, key: &str, top: f64, focus: bool, pinned: bool) {
|
|
||||||
let app = window.app_handle().clone();
|
|
||||||
let Some((wx, wy, ww, _)) = outer_rect(window) else { return };
|
|
||||||
let scale = window.scale_factor().unwrap_or(1.0);
|
|
||||||
let anchor = Anchor::Beside { left: wx, right: wx + ww, top: wy + top.max(0.0) * scale };
|
|
||||||
let Some((label, closes)) = book(&app, |b| b.open_sub(window.label(), key, anchor, pinned)) else { return };
|
|
||||||
destroy(&app, &closes);
|
|
||||||
if pinned {
|
|
||||||
let others = pinned_rects(&app, &label);
|
|
||||||
if let Some(work) = work_area(&app, wx, wy) {
|
|
||||||
let est = (EST.0 * scale, EST.1 * scale);
|
|
||||||
let (x, y) = place_menu(anchor, est, work);
|
|
||||||
let spot = free_spot((x, y, est.0, est.1), &others, work);
|
|
||||||
book(&app, |b| {
|
|
||||||
if let Some(p) = b.panels.get_mut(&label) {
|
|
||||||
p.pos = Some(spot);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
}
|
|
||||||
book(&app, |b| {
|
|
||||||
if let Some(p) = b.panels.get_mut(&label) {
|
|
||||||
p.focus = focus;
|
|
||||||
}
|
|
||||||
});
|
|
||||||
let handle = app.clone();
|
|
||||||
std::thread::spawn(move || {
|
|
||||||
if build_window(&handle, &label).is_err() {
|
|
||||||
book(&handle, |b| b.panels.remove(&label));
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
/// The pointer moved to a plain row: this panel's transient submenus close.
|
|
||||||
pub fn close_subs(window: &WebviewWindow) {
|
|
||||||
let app = window.app_handle().clone();
|
|
||||||
let closes = book(&app, |b| {
|
|
||||||
let d = b.descendants(window.label());
|
|
||||||
for l in &d {
|
|
||||||
b.panels.remove(l);
|
|
||||||
}
|
|
||||||
d
|
|
||||||
});
|
|
||||||
destroy(&app, &closes);
|
|
||||||
}
|
|
||||||
|
|
||||||
/// Closes this panel (Left / Esc in a submenu, X on a pinned one).
|
|
||||||
pub fn close(window: &WebviewWindow, refocus_parent: bool) {
|
|
||||||
let app = window.app_handle().clone();
|
|
||||||
let (closes, parent, was_pinned) = book(&app, |b| {
|
|
||||||
let p = b.panels.get(window.label()).cloned();
|
|
||||||
(b.close(window.label()), p.as_ref().and_then(|p| p.parent.clone()), p.is_some_and(|p| p.pinned))
|
|
||||||
});
|
|
||||||
if refocus_parent {
|
|
||||||
if let Some(w) = parent.and_then(|p| app.get_webview_window(&p)) {
|
|
||||||
let _ = w.set_focus();
|
|
||||||
let _ = app.emit_to(w.label(), PANEL_EVENT, "focus");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
destroy(&app, &closes);
|
|
||||||
if was_pinned {
|
|
||||||
save_pins(&app);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/// Esc on the root menu: every transient panel closes.
|
|
||||||
pub fn dismiss(app: &AppHandle) {
|
|
||||||
let closes = book(app, |b| b.dismiss());
|
|
||||||
destroy(app, &closes);
|
|
||||||
}
|
|
||||||
|
|
||||||
/// Pin or unpin this panel. Pinning steps it aside from the other pinned panels.
|
|
||||||
pub fn pin(window: &WebviewWindow, on: bool) {
|
|
||||||
let app = window.app_handle().clone();
|
|
||||||
let label = window.label().to_string();
|
|
||||||
let closes = book(&app, |b| b.pin(&label, on));
|
|
||||||
destroy(&app, &closes);
|
|
||||||
if on {
|
|
||||||
let others = pinned_rects(&app, &label);
|
|
||||||
if let Some(me) = outer_rect(window) {
|
|
||||||
if let Some(work) = work_area(&app, me.0, me.1) {
|
|
||||||
let (x, y) = free_spot(me, &others, work);
|
|
||||||
if (x, y) != (me.0, me.1) {
|
|
||||||
let _ = window.set_position(PhysicalPosition::new(x as i32, y as i32));
|
|
||||||
}
|
|
||||||
book(&app, |b| {
|
|
||||||
if let Some(p) = b.panels.get_mut(&label) {
|
|
||||||
p.pos = Some((x, y));
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
let _ = app.emit_to(label.as_str(), PANEL_EVENT, if on { "pinned" } else { "unpinned" });
|
|
||||||
save_pins(&app);
|
|
||||||
}
|
|
||||||
|
|
||||||
/// A pick: the same action as the native menu. Transient panels close; pinned ones stay and update in place.
|
|
||||||
pub fn select(window: &WebviewWindow, id: String) {
|
|
||||||
let app = window.app_handle().clone();
|
|
||||||
let pinned = book(&app, |b| b.panels.get(window.label()).map(|p| p.pinned).unwrap_or(false));
|
|
||||||
if !pinned {
|
|
||||||
dismiss(&app);
|
|
||||||
}
|
|
||||||
let handle = app.clone();
|
|
||||||
let _ = app.run_on_main_thread(move || crate::dispatch_menu(&handle, &id));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
#[cfg(desktop)]
|
|
||||||
pub use runtime::*;
|
|
||||||
|
|
@ -56,17 +56,6 @@ pub fn require_card(label: &str, url: &Url, dev: bool) -> Result<(), String> {
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
/// The tray menu panels (`menu-1`, `menu-2`... menu_panel.rs): they may call only the menu commands.
|
|
||||||
pub fn require_menu(label: &str, url: &Url, dev: bool) -> Result<(), String> {
|
|
||||||
if !crate::menu_panel::is_menu_label(label) {
|
|
||||||
return Err(format!("not allowed from window '{label}'"));
|
|
||||||
}
|
|
||||||
if !is_local_origin(url, dev) {
|
|
||||||
return Err("not allowed from this page".into());
|
|
||||||
}
|
|
||||||
Ok(())
|
|
||||||
}
|
|
||||||
|
|
||||||
/// Method kinds the sidecar announces in its `session.hello` descriptors.
|
/// Method kinds the sidecar announces in its `session.hello` descriptors.
|
||||||
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
|
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
|
||||||
pub enum Kind {
|
pub enum Kind {
|
||||||
|
|
|
||||||
|
|
@ -45,14 +45,11 @@ pub struct State {
|
||||||
pub overrides: Overrides,
|
pub overrides: Overrides,
|
||||||
#[serde(default)]
|
#[serde(default)]
|
||||||
pub settings: Settings,
|
pub settings: Settings,
|
||||||
/// Pinned tray menu panels and where they sit (menu_panel.rs); restored at start.
|
|
||||||
#[serde(default, rename = "menuPins", skip_serializing_if = "Vec::is_empty")]
|
|
||||||
pub menu_pins: Vec<crate::menu_panel::PinRecord>,
|
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Default for State {
|
impl Default for State {
|
||||||
fn default() -> State {
|
fn default() -> State {
|
||||||
State { version: VERSION, projects: vec![], accounts: vec![], studios: vec![], overrides: Overrides::default(), settings: Settings::default(), menu_pins: vec![] }
|
State { version: VERSION, projects: vec![], accounts: vec![], studios: vec![], overrides: Overrides::default(), settings: Settings::default() }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -124,7 +121,6 @@ pub fn migrate(mut v: Value) -> (State, u32, Vec<String>) {
|
||||||
studios: list(&o, "studios", &mut notes),
|
studios: list(&o, "studios", &mut notes),
|
||||||
overrides: one(&o, "overrides", &mut notes),
|
overrides: one(&o, "overrides", &mut notes),
|
||||||
settings: one(&o, "settings", &mut notes),
|
settings: one(&o, "settings", &mut notes),
|
||||||
menu_pins: list(&o, "menuPins", &mut notes),
|
|
||||||
};
|
};
|
||||||
// two entries with one id (hand-edited or merged files): the first one wins
|
// two entries with one id (hand-edited or merged files): the first one wins
|
||||||
let mut seen = std::collections::HashSet::new();
|
let mut seen = std::collections::HashSet::new();
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,7 @@
|
||||||
//! The tray: tooltip, attention icon, context menu and the "where to go" memory of the last notification.
|
//! The tray: tooltip, attention icon, context menu and the "where to go" memory of the last notification.
|
||||||
//!
|
//!
|
||||||
//! The window pushes a small summary after every store read (`tray_update`); this module turns it into a menu model
|
//! The window pushes a small summary after every store read (`tray_update`); this module turns it into a menu model
|
||||||
//! (pure, tested in tests/tray.rs), pushes it to the menu panels (menu_panel.rs), sets the tooltip and swaps the icon for one with a red dot while
|
//! (pure, tested in tests/tray.rs), rebuilds the menu, sets the tooltip and swaps the icon for one with a red dot while
|
||||||
//! something needs the owner. Menu clicks come back as events to the window: `tray-route` (a route as JSON) and
|
//! something needs the owner. Menu clicks come back as events to the window: `tray-route` (a route as JSON) and
|
||||||
//! `tray-action` (`read`, `mute-toggle`).
|
//! `tray-action` (`read`, `mute-toggle`).
|
||||||
//!
|
//!
|
||||||
|
|
@ -14,9 +14,7 @@ use std::time::{Duration, Instant};
|
||||||
use serde::Deserialize;
|
use serde::Deserialize;
|
||||||
use serde_json::Value;
|
use serde_json::Value;
|
||||||
use tauri::image::Image;
|
use tauri::image::Image;
|
||||||
use tauri::menu::{IsMenuItem, Menu, MenuItem, PredefinedMenuItem, Submenu};
|
use tauri::menu::{Menu, MenuItem, PredefinedMenuItem, Submenu};
|
||||||
|
|
||||||
use crate::menu_panel::{from_entries, Node};
|
|
||||||
use tauri::{AppHandle, Runtime};
|
use tauri::{AppHandle, Runtime};
|
||||||
|
|
||||||
pub const ID_OPEN: &str = "tray-open";
|
pub const ID_OPEN: &str = "tray-open";
|
||||||
|
|
@ -90,8 +88,7 @@ pub struct TraySummary {
|
||||||
pub enum Entry {
|
pub enum Entry {
|
||||||
Item { id: String, label: String, enabled: bool },
|
Item { id: String, label: String, enabled: bool },
|
||||||
Separator,
|
Separator,
|
||||||
/// `key`: the submenu's fixed key (menu_panel::sub_key), the same in every language.
|
Sub { label: String, items: Vec<Entry> },
|
||||||
Sub { key: String, label: String, items: Vec<Entry> },
|
|
||||||
}
|
}
|
||||||
|
|
||||||
fn clean(s: &str, max: usize) -> String {
|
fn clean(s: &str, max: usize) -> String {
|
||||||
|
|
@ -135,7 +132,7 @@ pub fn menu_model(s: &TraySummary) -> Vec<Entry> {
|
||||||
item(ID_OPEN, &l.open),
|
item(ID_OPEN, &l.open),
|
||||||
item(ID_READ, &l.read_now),
|
item(ID_READ, &l.read_now),
|
||||||
Entry::Separator,
|
Entry::Separator,
|
||||||
Entry::Sub { key: "apps".into(), label: clean(&l.apps, 40), items: apps },
|
Entry::Sub { label: clean(&l.apps, 40), items: apps },
|
||||||
Entry::Separator,
|
Entry::Separator,
|
||||||
item(ID_MUTE, if s.muted { &l.unmute } else { &l.mute }),
|
item(ID_MUTE, if s.muted { &l.unmute } else { &l.mute }),
|
||||||
item(ID_UPDATE, &l.update),
|
item(ID_UPDATE, &l.update),
|
||||||
|
|
@ -236,45 +233,40 @@ pub fn take_pending() -> Option<String> {
|
||||||
|
|
||||||
static LAST: Mutex<Option<String>> = Mutex::new(None);
|
static LAST: Mutex<Option<String>> = Mutex::new(None);
|
||||||
|
|
||||||
/// The native menu items for a panel tree (the fallback, and Linux), nested to any depth.
|
fn build_menu<R: Runtime>(app: &AppHandle<R>, model: &[Entry]) -> tauri::Result<Menu<R>> {
|
||||||
fn native_items<R: Runtime>(app: &AppHandle<R>, nodes: &[Node]) -> tauri::Result<Vec<Box<dyn IsMenuItem<R>>>> {
|
let menu = Menu::new(app)?;
|
||||||
let mut out: Vec<Box<dyn IsMenuItem<R>>> = Vec::new();
|
for e in model {
|
||||||
for n in nodes {
|
match e {
|
||||||
match n {
|
Entry::Item { id, label, enabled } => menu.append(&MenuItem::with_id(app, id, label, *enabled, None::<&str>)?)?,
|
||||||
Node::Item { id, label, enabled } => out.push(Box::new(MenuItem::with_id(app, id, label, *enabled, None::<&str>)?)),
|
Entry::Separator => menu.append(&PredefinedMenuItem::separator(app)?)?,
|
||||||
Node::Sep => out.push(Box::new(PredefinedMenuItem::separator(app)?)),
|
Entry::Sub { label, items } => {
|
||||||
Node::Sub { label, items, .. } => {
|
let sub = Submenu::new(app, label, true)?;
|
||||||
let children = native_items(app, items)?;
|
for it in items {
|
||||||
let refs: Vec<&dyn IsMenuItem<R>> = children.iter().map(|b| b.as_ref()).collect();
|
if let Entry::Item { id, label, enabled } = it {
|
||||||
out.push(Box::new(Submenu::with_items(app, label, true, &refs)?));
|
sub.append(&MenuItem::with_id(app, id, label, *enabled, None::<&str>)?)?;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
menu.append(&sub)?;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Ok(out)
|
Ok(menu)
|
||||||
}
|
}
|
||||||
|
|
||||||
/// The native tray menu, rendered from the same tree as the panels.
|
/// The menu shown before the window has sent anything (English words).
|
||||||
pub fn native_menu<R: Runtime>(app: &AppHandle<R>, nodes: &[Node]) -> tauri::Result<Menu<R>> {
|
pub fn initial_menu<R: Runtime>(app: &AppHandle<R>) -> tauri::Result<Menu<R>> {
|
||||||
let items = native_items(app, nodes)?;
|
build_menu(app, &menu_model(&TraySummary::default()))
|
||||||
let refs: Vec<&dyn IsMenuItem<R>> = items.iter().map(|b| b.as_ref()).collect();
|
|
||||||
Menu::with_items(app, &refs)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// The tree before the window has sent anything (English words).
|
/// Applies a summary: tooltip, menu and icon of the tray with id `main`. Skips the work when nothing changed.
|
||||||
pub fn initial_nodes() -> Vec<Node> {
|
pub fn apply<R: Runtime>(app: &AppHandle<R>, s: &TraySummary) -> tauri::Result<()> {
|
||||||
from_entries(&menu_model(&TraySummary::default()))
|
|
||||||
}
|
|
||||||
|
|
||||||
/// Applies a summary: tooltip and icon of the tray with id `main`, and the menu tree, which goes live to the open menu
|
|
||||||
/// panels (and to the native menu when that is in use). Skips the work when nothing changed.
|
|
||||||
pub fn apply(app: &AppHandle, s: &TraySummary) -> tauri::Result<()> {
|
|
||||||
let Some(tray) = app.tray_by_id("main") else { return Ok(()) };
|
let Some(tray) = app.tray_by_id("main") else { return Ok(()) };
|
||||||
let key = format!("{s:?}");
|
let key = format!("{s:?}");
|
||||||
if LAST.lock().ok().is_some_and(|l| l.as_deref() == Some(key.as_str())) {
|
if LAST.lock().ok().is_some_and(|l| l.as_deref() == Some(key.as_str())) {
|
||||||
return Ok(());
|
return Ok(());
|
||||||
}
|
}
|
||||||
tray.set_tooltip(Some(tooltip_text(s)))?;
|
tray.set_tooltip(Some(tooltip_text(s)))?;
|
||||||
crate::menu_panel::set_nodes(app, from_entries(&menu_model(s)));
|
tray.set_menu(Some(build_menu(app, &menu_model(s))?))?;
|
||||||
if let Some(icon) = app.default_window_icon() {
|
if let Some(icon) = app.default_window_icon() {
|
||||||
let img = if s.attention > 0 { Image::new_owned(with_attention_dot(icon.rgba(), icon.width(), icon.height()), icon.width(), icon.height()) } else { icon.clone() };
|
let img = if s.attention > 0 { Image::new_owned(with_attention_dot(icon.rgba(), icon.width(), icon.height()), icon.width(), icon.height()) } else { icon.clone() };
|
||||||
tray.set_icon(Some(img))?;
|
tray.set_icon(Some(img))?;
|
||||||
|
|
|
||||||
|
|
@ -1,111 +1,22 @@
|
||||||
//! Signed updates from storebound.dev. The updater plugin checks `latest.json` of the chosen channel, downloads the
|
//! Signed updates from storebound.dev. The updater plugin checks `latest.json` of the chosen channel, downloads the
|
||||||
//! platform's bundle and refuses it unless its minisign signature matches the public key in tauri.conf.json (the
|
//! platform's bundle and refuses it unless its minisign signature matches the public key in tauri.conf.json (the
|
||||||
//! private key never leaves the release machine, ~/.storebound-keys). Nothing installs without the owner's click in
|
//! private key never leaves the release machine, ~/.storebound-keys). Nothing installs without the owner's click in
|
||||||
//! a native dialog (commands::update_install), or by the background updater (lib.rs auto_update). Pure parts here so tests can pin them.
|
//! a native dialog (commands::update_install). Pure parts here so tests can pin them.
|
||||||
use std::sync::atomic::{AtomicBool, Ordering};
|
|
||||||
|
|
||||||
use url::Url;
|
use url::Url;
|
||||||
|
|
||||||
/// Set when Settings > Updates switched the channel: the background updater checks on its next tick.
|
|
||||||
pub static KICK: AtomicBool = AtomicBool::new(false);
|
|
||||||
|
|
||||||
pub fn kick() {
|
|
||||||
KICK.store(true, Ordering::SeqCst);
|
|
||||||
}
|
|
||||||
|
|
||||||
pub fn take_kick() -> bool {
|
|
||||||
KICK.swap(false, Ordering::SeqCst)
|
|
||||||
}
|
|
||||||
|
|
||||||
/// `latest.json` of each channel (static files on storebound.dev, published by tools/desktop-release.ts).
|
/// `latest.json` of each channel (static files on storebound.dev, published by tools/desktop-release.ts).
|
||||||
pub const STABLE: &str = "https://storebound.dev/desktop/latest.json";
|
pub const STABLE: &str = "https://storebound.dev/desktop/latest.json";
|
||||||
pub const BETA: &str = "https://storebound.dev/desktop/beta/latest.json";
|
pub const BETA: &str = "https://storebound.dev/desktop/beta/latest.json";
|
||||||
/// Every push to main (Forgejo ci `dev` job, signed on the VDS): `<next patch>-dev.<UTC yyyymmddHHMMSS>`.
|
|
||||||
pub const DEV: &str = "https://storebound.dev/desktop/dev/latest.json";
|
|
||||||
|
|
||||||
/// The channels Settings > Updates accepts (beta is kept for saved states; the window offers stable and dev).
|
|
||||||
pub const CHANNELS: &[&str] = &["stable", "dev", "beta"];
|
|
||||||
|
|
||||||
/// The endpoint of a channel (Settings > Updates); anything unknown is the stable channel.
|
/// The endpoint of a channel (Settings > Updates); anything unknown is the stable channel.
|
||||||
pub fn endpoint(channel: &str) -> &'static str {
|
pub fn endpoint(channel: &str) -> &'static str {
|
||||||
match channel {
|
if channel == "beta" {
|
||||||
"beta" => BETA,
|
BETA
|
||||||
"dev" => DEV,
|
} else {
|
||||||
_ => STABLE,
|
STABLE
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// How often the background updater asks the channel (plus once at start and right after a resume from sleep).
|
|
||||||
pub const CHECK_EVERY_SECS: u64 = 15 * 60;
|
|
||||||
/// The background loop's tick; a wall-clock jump of more than this plus a minute between two ticks is a resume.
|
|
||||||
pub const TICK_SECS: u64 = 5;
|
|
||||||
/// An install waits while the main window is visible and focused, at most this many checks in a row (so an app that
|
|
||||||
/// stays open still updates).
|
|
||||||
pub const MAX_DEFERS: u32 = 4;
|
|
||||||
|
|
||||||
/// A semver version as (major, minor, patch) and its prerelease identifiers; None when it is not one.
|
|
||||||
fn parse(v: &str) -> Option<([u64; 3], Vec<String>)> {
|
|
||||||
let v = v.trim().trim_start_matches('v');
|
|
||||||
let v = v.split('+').next()?;
|
|
||||||
let (core, pre) = match v.split_once('-') {
|
|
||||||
Some((c, p)) => (c, p.split('.').map(str::to_string).collect::<Vec<_>>()),
|
|
||||||
None => (v, Vec::new()),
|
|
||||||
};
|
|
||||||
let mut n = core.split('.').map(|x| x.parse::<u64>().ok());
|
|
||||||
let r = [n.next()??, n.next()??, n.next()??];
|
|
||||||
if n.next().is_some() || pre.iter().any(String::is_empty) {
|
|
||||||
return None;
|
|
||||||
}
|
|
||||||
Some((r, pre))
|
|
||||||
}
|
|
||||||
|
|
||||||
/// semver 2.0 precedence, a > b: a release is above its own prereleases (0.8.48 > 0.8.48-dev.20261023120000), numeric
|
|
||||||
/// identifiers compare as numbers and sort below alphanumeric ones, a longer prerelease is above its prefix.
|
|
||||||
pub fn newer(a: &str, b: &str) -> bool {
|
|
||||||
use std::cmp::Ordering::{Equal, Greater, Less};
|
|
||||||
let (Some((ac, ap)), Some((bc, bp))) = (parse(a), parse(b)) else { return false };
|
|
||||||
match ac.cmp(&bc) {
|
|
||||||
Greater => return true,
|
|
||||||
Less => return false,
|
|
||||||
Equal => {}
|
|
||||||
}
|
|
||||||
match (ap.is_empty(), bp.is_empty()) {
|
|
||||||
(true, true) | (false, true) => return false,
|
|
||||||
(true, false) => return true,
|
|
||||||
_ => {}
|
|
||||||
}
|
|
||||||
for (x, y) in ap.iter().zip(bp.iter()) {
|
|
||||||
let o = match (x.parse::<u64>(), y.parse::<u64>()) {
|
|
||||||
(Ok(i), Ok(j)) => i.cmp(&j),
|
|
||||||
(Ok(_), Err(_)) => Less,
|
|
||||||
(Err(_), Ok(_)) => Greater,
|
|
||||||
_ => x.cmp(y),
|
|
||||||
};
|
|
||||||
if o != Equal {
|
|
||||||
return o == Greater;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
ap.len() > bp.len()
|
|
||||||
}
|
|
||||||
|
|
||||||
/// The no-downgrade rule: an update installs only when the channel's version is strictly newer than this build. A dev
|
|
||||||
/// install switched back to stable stays on its dev build until a stable release passes it.
|
|
||||||
pub fn should_install(current: &str, offered: &str) -> bool {
|
|
||||||
newer(offered, current)
|
|
||||||
}
|
|
||||||
|
|
||||||
/// The background updater defers an install while the owner works in the main window (visible and focused), at most
|
|
||||||
/// MAX_DEFERS checks in a row. A hidden window can report focus, so only a visible one counts.
|
|
||||||
pub fn defer_install(visible: bool, focused: bool, defers_so_far: u32) -> bool {
|
|
||||||
visible && focused && defers_so_far < MAX_DEFERS
|
|
||||||
}
|
|
||||||
|
|
||||||
/// Whether the background updater asks the channel now: the first tick, a kick (channel switched), a resume from sleep
|
|
||||||
/// (the wall clock moved much further than one tick), or CHECK_EVERY_SECS since the last check.
|
|
||||||
pub fn check_due(first: bool, kicked: bool, wall_gap_secs: u64, since_check_secs: u64) -> bool {
|
|
||||||
first || kicked || wall_gap_secs > TICK_SECS + 60 || since_check_secs >= CHECK_EVERY_SECS
|
|
||||||
}
|
|
||||||
|
|
||||||
/// Only storebound.dev over HTTPS, without port or user info, may serve updates.
|
/// Only storebound.dev over HTTPS, without port or user info, may serve updates.
|
||||||
pub fn endpoint_allowed(url: &Url) -> bool {
|
pub fn endpoint_allowed(url: &Url) -> bool {
|
||||||
url.scheme() == "https" && url.host_str() == Some("storebound.dev") && url.port().is_none() && url.username().is_empty() && url.password().is_none() && url.path().starts_with("/desktop/")
|
url.scheme() == "https" && url.host_str() == Some("storebound.dev") && url.port().is_none() && url.username().is_empty() && url.password().is_none() && url.path().starts_with("/desktop/")
|
||||||
|
|
|
||||||
|
|
@ -310,7 +310,7 @@ pub struct Settings {
|
||||||
pub refresh: RefreshSettings,
|
pub refresh: RefreshSettings,
|
||||||
pub cache: CacheSettings,
|
pub cache: CacheSettings,
|
||||||
pub notify: NotifySettings,
|
pub notify: NotifySettings,
|
||||||
/// Update channel (Settings > Updates): stable | dev (beta kept for saved states). crate::updates::endpoint.
|
/// Update channel (placeholder until the updater ships): stable | beta.
|
||||||
pub channel: String,
|
pub channel: String,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -360,8 +360,8 @@ pub fn check_settings(s: &Settings) -> Result<(), String> {
|
||||||
if !valid_hhmm(&s.notify.quiet_hours.from) || !valid_hhmm(&s.notify.quiet_hours.to) {
|
if !valid_hhmm(&s.notify.quiet_hours.from) || !valid_hhmm(&s.notify.quiet_hours.to) {
|
||||||
return Err("quiet hours: times as HH:MM (00:00 to 23:59)".into());
|
return Err("quiet hours: times as HH:MM (00:00 to 23:59)".into());
|
||||||
}
|
}
|
||||||
if !crate::updates::CHANNELS.contains(&s.channel.as_str()) {
|
if !["stable", "beta"].contains(&s.channel.as_str()) {
|
||||||
return Err("channel: stable or dev".into());
|
return Err("channel: stable or beta".into());
|
||||||
}
|
}
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -2,7 +2,7 @@
|
||||||
"$schema": "https://schema.tauri.app/config/2",
|
"$schema": "https://schema.tauri.app/config/2",
|
||||||
"productName": "storebound",
|
"productName": "storebound",
|
||||||
"mainBinaryName": "storebound-desktop",
|
"mainBinaryName": "storebound-desktop",
|
||||||
"version": "0.8.78",
|
"version": "0.8.41",
|
||||||
"identifier": "dev.storebound.desktop",
|
"identifier": "dev.storebound.desktop",
|
||||||
"build": {
|
"build": {
|
||||||
"frontendDist": "../dist",
|
"frontendDist": "../dist",
|
||||||
|
|
@ -50,7 +50,7 @@
|
||||||
"form-action": "'none'"
|
"form-action": "'none'"
|
||||||
},
|
},
|
||||||
"freezePrototype": true,
|
"freezePrototype": true,
|
||||||
"capabilities": ["main-window", "card-window", "menu-window"]
|
"capabilities": ["main-window", "card-window"]
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"bundle": {
|
"bundle": {
|
||||||
|
|
@ -88,7 +88,6 @@
|
||||||
},
|
},
|
||||||
"updater": {
|
"updater": {
|
||||||
"endpoints": ["https://storebound.dev/desktop/latest.json"],
|
"endpoints": ["https://storebound.dev/desktop/latest.json"],
|
||||||
"windows": { "installMode": "quiet" },
|
|
||||||
"pubkey": "dW50cnVzdGVkIGNvbW1lbnQ6IG1pbmlzaWduIHB1YmxpYyBrZXk6IDQ0Rjc4QTc4RDlFRjM4MkEKUldRcU9PL1plSXIzUkJtb2x0L2Z4MTA4bTg5UU5FVW5kUlRGcnVjangwQ0JNb2VGYjcveGhydlcK"
|
"pubkey": "dW50cnVzdGVkIGNvbW1lbnQ6IG1pbmlzaWduIHB1YmxpYyBrZXk6IDQ0Rjc4QTc4RDlFRjM4MkEKUldRcU9PL1plSXIzUkJtb2x0L2Z4MTA4bTg5UU5FVW5kUlRGcnVjangwQ0JNb2VGYjcveGhydlcK"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -3,7 +3,6 @@
|
||||||
use std::fs;
|
use std::fs;
|
||||||
use std::path::{Path, PathBuf};
|
use std::path::{Path, PathBuf};
|
||||||
use std::process::Command;
|
use std::process::Command;
|
||||||
#[cfg(unix)]
|
|
||||||
use std::time::{Duration, Instant};
|
use std::time::{Duration, Instant};
|
||||||
|
|
||||||
use storebound_desktop::ai_fix::*;
|
use storebound_desktop::ai_fix::*;
|
||||||
|
|
|
||||||
|
|
@ -41,13 +41,10 @@ fn updater_has_a_real_minisign_key_and_only_storebound_dev() {
|
||||||
assert_eq!(c["plugins"]["updater"]["endpoints"], serde_json::json!([updates::STABLE]));
|
assert_eq!(c["plugins"]["updater"]["endpoints"], serde_json::json!([updates::STABLE]));
|
||||||
// updater bundles are signed by tools/desktop-release.ts on the release Mac, never by a CI runner
|
// updater bundles are signed by tools/desktop-release.ts on the release Mac, never by a CI runner
|
||||||
assert_eq!(c["bundle"]["createUpdaterArtifacts"], false);
|
assert_eq!(c["bundle"]["createUpdaterArtifacts"], false);
|
||||||
assert_eq!(c["plugins"]["updater"]["windows"]["installMode"], "quiet");
|
for ch in ["stable", "beta", "nightly", ""] {
|
||||||
for ch in ["stable", "beta", "dev", "nightly", ""] {
|
|
||||||
assert!(updates::endpoint_allowed(&Url::parse(updates::endpoint(ch)).unwrap()), "{ch}");
|
assert!(updates::endpoint_allowed(&Url::parse(updates::endpoint(ch)).unwrap()), "{ch}");
|
||||||
}
|
}
|
||||||
assert_eq!(updates::endpoint("beta"), updates::BETA);
|
assert_eq!(updates::endpoint("beta"), updates::BETA);
|
||||||
assert_eq!(updates::endpoint("dev"), updates::DEV);
|
|
||||||
assert_eq!(updates::DEV, "https://storebound.dev/desktop/dev/latest.json");
|
|
||||||
assert_eq!(updates::endpoint("anything"), updates::STABLE);
|
assert_eq!(updates::endpoint("anything"), updates::STABLE);
|
||||||
for bad in ["http://storebound.dev/desktop/latest.json", "https://storebound.dev:8443/desktop/latest.json", "https://evil.test/desktop/latest.json", "https://storebound.dev/latest.json"] {
|
for bad in ["http://storebound.dev/desktop/latest.json", "https://storebound.dev:8443/desktop/latest.json", "https://evil.test/desktop/latest.json", "https://storebound.dev/latest.json"] {
|
||||||
assert!(!updates::endpoint_allowed(&Url::parse(bad).unwrap()), "{bad}");
|
assert!(!updates::endpoint_allowed(&Url::parse(bad).unwrap()), "{bad}");
|
||||||
|
|
@ -106,49 +103,3 @@ fn deep_links_to_folders_ask_before_adding() {
|
||||||
let body = &cmds[at..];
|
let body = &cmds[at..];
|
||||||
assert!(body.find("confirm_dialog_with(").unwrap() < body.find("download_and_install(").unwrap());
|
assert!(body.find("confirm_dialog_with(").unwrap() < body.find("download_and_install(").unwrap());
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
|
||||||
fn dev_versions_sort_and_never_downgrade() {
|
|
||||||
// a dev build of the next patch is above the current stable, below that next stable, and later stamps go up
|
|
||||||
assert!(updates::newer("0.8.48-dev.20261023120000", "0.8.47"));
|
|
||||||
assert!(updates::newer("0.8.48", "0.8.48-dev.20261023120000"));
|
|
||||||
assert!(updates::newer("0.8.48-dev.20261023120001", "0.8.48-dev.20261023120000"));
|
|
||||||
assert!(updates::newer("0.8.48-dev.20261024000000", "0.8.48-dev.9"), "numeric identifiers compare as numbers");
|
|
||||||
assert!(updates::newer("0.8.49-dev.1", "0.8.48"));
|
|
||||||
assert!(updates::newer("0.10.0", "0.9.9"));
|
|
||||||
assert!(!updates::newer("0.8.48", "0.8.48"));
|
|
||||||
assert!(!updates::newer("nonsense", "0.8.48"));
|
|
||||||
// switched from dev back to stable: stays on the dev build until a stable release passes it
|
|
||||||
assert!(!updates::should_install("0.8.48-dev.20261023120000", "0.8.47"));
|
|
||||||
assert!(updates::should_install("0.8.48-dev.20261023120000", "0.8.48"));
|
|
||||||
assert!(updates::should_install("0.8.47", "0.8.48-dev.20261023120000"));
|
|
||||||
assert!(!updates::should_install("0.8.48-dev.20261023120000", "0.8.48-dev.20261023120000"));
|
|
||||||
}
|
|
||||||
|
|
||||||
#[test]
|
|
||||||
fn background_updater_schedule_and_defer() {
|
|
||||||
assert!(updates::check_due(true, false, 0, 0), "at start");
|
|
||||||
assert!(updates::check_due(false, true, 0, 0), "channel switched");
|
|
||||||
assert!(updates::check_due(false, false, 3600, 5), "resume from sleep");
|
|
||||||
assert!(updates::check_due(false, false, 5, updates::CHECK_EVERY_SECS));
|
|
||||||
assert!(!updates::check_due(false, false, 5, 60));
|
|
||||||
assert_eq!(updates::CHECK_EVERY_SECS, 900);
|
|
||||||
assert!(updates::defer_install(true, true, 0));
|
|
||||||
assert!(!updates::defer_install(true, true, updates::MAX_DEFERS), "an open window still updates after a few checks");
|
|
||||||
assert!(!updates::defer_install(false, true, 0), "a hidden window can report focus");
|
|
||||||
assert!(!updates::defer_install(true, false, 0));
|
|
||||||
let _ = updates::take_kick();
|
|
||||||
updates::kick();
|
|
||||||
assert!(updates::take_kick());
|
|
||||||
assert!(!updates::take_kick());
|
|
||||||
}
|
|
||||||
|
|
||||||
#[test]
|
|
||||||
fn startup_apps_choice_is_read_from_startup_approved() {
|
|
||||||
use storebound_desktop::startup_approved_off;
|
|
||||||
assert!(!startup_approved_off(&[0x02, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]));
|
|
||||||
assert!(!startup_approved_off(&[0x06, 0, 0, 0]));
|
|
||||||
assert!(startup_approved_off(&[0x03, 0, 0, 0, 0x20, 0xD1, 0xD3, 0xB1, 0xF0, 0xB3, 0xDC, 0x01]));
|
|
||||||
assert!(startup_approved_off(&[0x07]));
|
|
||||||
assert!(!startup_approved_off(&[]));
|
|
||||||
}
|
|
||||||
|
|
|
||||||
|
|
@ -1,214 +0,0 @@
|
||||||
//! The tray menu panels' pure half: the tree and its stable keys, live updates, placement inside the work area, the
|
|
||||||
//! panel book (transient vs pinned, parents, restore after a restart).
|
|
||||||
use storebound_desktop::menu_panel::*;
|
|
||||||
use storebound_desktop::store::State;
|
|
||||||
use storebound_desktop::tray::{menu_model, Entry, TrayApp, TrayLabels, TraySummary};
|
|
||||||
|
|
||||||
const WORK: Rect = (0.0, 0.0, 1920.0, 1040.0);
|
|
||||||
const AT: Anchor = Anchor::At { x: 0.0, y: 0.0 };
|
|
||||||
|
|
||||||
fn summary(state: &str, apps_label: &str) -> TraySummary {
|
|
||||||
TraySummary {
|
|
||||||
apps: vec![TrayApp { key: "k1".into(), name: "First".into(), state: state.into() }, TrayApp { key: "k2".into(), name: "Second".into(), state: String::new() }],
|
|
||||||
labels: TrayLabels { apps: apps_label.into(), ..TrayLabels::default() },
|
|
||||||
..TraySummary::default()
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
fn tree() -> Vec<Node> {
|
|
||||||
from_entries(&[
|
|
||||||
Entry::Item { id: "open".into(), label: "Open".into(), enabled: true },
|
|
||||||
Entry::Separator,
|
|
||||||
Entry::Sub { key: String::new(), label: "Fleet".into(), items: vec![Entry::Sub { key: String::new(), label: "Recently lowered".into(), items: vec![] }] },
|
|
||||||
Entry::Sub { key: String::new(), label: "Profile: Work".into(), items: vec![] },
|
|
||||||
])
|
|
||||||
}
|
|
||||||
|
|
||||||
#[test]
|
|
||||||
fn keys_ignore_live_parts_and_stay_unique() {
|
|
||||||
assert_eq!(sub_key("Profile: Work"), "profile");
|
|
||||||
assert_eq!(sub_key("\u{25CF} First \u{00B7} ok"), "first");
|
|
||||||
assert_eq!(sub_key("Queue (1 running, 2 queued)"), "queue");
|
|
||||||
assert_eq!(sub_key("\u{2716}"), "sub");
|
|
||||||
let nodes = unique_keys(vec![Node::Sub { key: "a".into(), label: "A".into(), items: vec![] }, Node::Sub { key: "a".into(), label: "A".into(), items: vec![] }]);
|
|
||||||
assert!(matches!(&nodes[1], Node::Sub { key, .. } if key == "a-2"));
|
|
||||||
}
|
|
||||||
|
|
||||||
#[test]
|
|
||||||
fn find_walks_keys() {
|
|
||||||
let t = tree();
|
|
||||||
let (items, label) = find(&t, &["fleet".into(), "recently-lowered".into()]).unwrap();
|
|
||||||
assert_eq!((items.len(), label), (0, Some("Recently lowered")));
|
|
||||||
assert!(find(&t, &["nope".into()]).is_none());
|
|
||||||
assert_eq!(find(&t, &[]).unwrap().0.len(), 4);
|
|
||||||
}
|
|
||||||
|
|
||||||
#[test]
|
|
||||||
fn the_tray_tree_keeps_its_apps_key_in_every_language_and_value() {
|
|
||||||
let en = from_entries(&menu_model(&summary("App Store: In review", "Apps")));
|
|
||||||
let tr = from_entries(&menu_model(&summary("App Store: Live", "Uygulamalar")));
|
|
||||||
let key = |n: &[Node]| n.iter().find_map(|n| if let Node::Sub { key, .. } = n { Some(key.clone()) } else { None }).unwrap();
|
|
||||||
assert_eq!(key(&en), "apps");
|
|
||||||
assert_eq!(key(&tr), "apps");
|
|
||||||
// a live value changed: the tree differs (so it is pushed), the open Apps panel still resolves
|
|
||||||
assert_ne!(en, tr);
|
|
||||||
let (items, _) = find(&tr, &["apps".into()]).unwrap();
|
|
||||||
assert!(matches!(&items[0], Node::Item { id, label, .. } if id == "tray-app:k1" && label.contains("Live")));
|
|
||||||
// the same summary twice: the same tree (nothing is pushed)
|
|
||||||
assert_eq!(from_entries(&menu_model(&summary("x", "Apps"))), from_entries(&menu_model(&summary("x", "Apps"))));
|
|
||||||
}
|
|
||||||
|
|
||||||
#[test]
|
|
||||||
fn the_tree_serializes_as_the_panel_page_reads_it() {
|
|
||||||
let v = serde_json::to_value(tree()).unwrap();
|
|
||||||
assert_eq!(v[0], serde_json::json!({ "kind": "item", "id": "open", "label": "Open", "enabled": true }));
|
|
||||||
assert_eq!(v[1], serde_json::json!({ "kind": "sep" }));
|
|
||||||
assert_eq!(v[2]["kind"], "sub");
|
|
||||||
assert_eq!(v[2]["key"], "fleet");
|
|
||||||
}
|
|
||||||
|
|
||||||
#[test]
|
|
||||||
fn root_opens_away_from_the_taskbar_and_stays_inside() {
|
|
||||||
// bottom taskbar, icon at the right: above and left of the click
|
|
||||||
let (x, y) = place_menu(Anchor::Point { x: 1900.0, y: 1060.0 }, (300.0, 400.0), WORK);
|
|
||||||
assert!(x + 300.0 <= 1920.0 - GAP && y + 400.0 <= 1040.0 - GAP && x >= 0.0 && y >= 0.0);
|
|
||||||
// macOS menu bar at the top: below it
|
|
||||||
let (_, y) = place_menu(Anchor::Point { x: 1800.0, y: 0.0 }, (300.0, 400.0), (0.0, 25.0, 1920.0, 1055.0));
|
|
||||||
assert!(y >= 25.0 + GAP);
|
|
||||||
// a second monitor left of the primary (negative x)
|
|
||||||
let (x, _) = place_menu(Anchor::Point { x: -10.0, y: 500.0 }, (300.0, 400.0), (-1920.0, 0.0, 1920.0, 1080.0));
|
|
||||||
assert!(x + 300.0 <= -GAP + 0.001 && x >= -1920.0);
|
|
||||||
// a panel taller than the work area: pinned to the top edge, never above it
|
|
||||||
let (_, y) = place_menu(Anchor::Point { x: 100.0, y: 100.0 }, (300.0, 2000.0), WORK);
|
|
||||||
assert_eq!(y, GAP);
|
|
||||||
}
|
|
||||||
|
|
||||||
#[test]
|
|
||||||
fn tray_root_sits_just_above_the_icon_never_over_the_taskbar() {
|
|
||||||
// icon in a bottom taskbar (the icon is below the work area): bottom edge exactly GAP above the icon's top
|
|
||||||
let icon = Anchor::Tray { x: 1800.0, y: 1044.0, w: 32.0, h: 32.0 };
|
|
||||||
let (_, y) = place_menu(icon, (260.0, 300.0), WORK);
|
|
||||||
assert_eq!(y + 300.0, 1040.0 - GAP);
|
|
||||||
// even when the reported work area wrongly includes the taskbar, the panel stays above the icon
|
|
||||||
let (_, y) = place_menu(icon, (260.0, 300.0), (0.0, 0.0, 1920.0, 1080.0));
|
|
||||||
assert!(y + 300.0 <= 1044.0 - GAP);
|
|
||||||
}
|
|
||||||
|
|
||||||
#[test]
|
|
||||||
fn submenus_open_beside_and_flip_left_at_the_edge() {
|
|
||||||
let (x, _) = place_menu(Anchor::Beside { left: 1600.0, right: 1880.0, top: 100.0 }, (280.0, 200.0), WORK);
|
|
||||||
assert!(x + 280.0 <= 1602.0);
|
|
||||||
let (x, y) = place_menu(Anchor::Beside { left: 100.0, right: 380.0, top: 100.0 }, (280.0, 200.0), WORK);
|
|
||||||
assert!((378.0..=380.0).contains(&x) && (90.0..=100.0).contains(&y));
|
|
||||||
// a row near the bottom: the submenu moves up into the work area
|
|
||||||
let (_, y) = place_menu(Anchor::Beside { left: 100.0, right: 380.0, top: 1000.0 }, (280.0, 300.0), WORK);
|
|
||||||
assert!(y + 300.0 <= 1040.0 - GAP);
|
|
||||||
}
|
|
||||||
|
|
||||||
#[test]
|
|
||||||
fn pinned_panels_step_aside_and_stay_inside() {
|
|
||||||
let others = [(100.0, 100.0, 280.0, 300.0), (100.0, 408.0, 280.0, 300.0)];
|
|
||||||
let (x, y) = free_spot((120.0, 120.0, 280.0, 300.0), &others, WORK);
|
|
||||||
assert!(others.iter().all(|o| !overlaps((x, y, 280.0, 300.0), *o)));
|
|
||||||
assert!(x >= 0.0 && y >= 0.0 && x + 280.0 <= 1920.0 && y + 300.0 <= 1040.0);
|
|
||||||
// no room left below: the next column
|
|
||||||
let col = [(8.0, 8.0, 280.0, 1000.0)];
|
|
||||||
let (x, _) = free_spot((8.0, 8.0, 280.0, 300.0), &col, WORK);
|
|
||||||
assert!(x >= 288.0);
|
|
||||||
// nothing in the way: where it was
|
|
||||||
assert_eq!(free_spot((500.0, 500.0, 280.0, 300.0), &others, WORK), (500.0, 500.0));
|
|
||||||
}
|
|
||||||
|
|
||||||
#[test]
|
|
||||||
fn several_menus_open_and_pinned_ones_survive_a_new_menu() {
|
|
||||||
let mut b = Book::default();
|
|
||||||
let (root, _) = b.open_root(Anchor::Point { x: 0.0, y: 0.0 });
|
|
||||||
let (fleet, _) = b.open_sub(&root, "fleet", AT, false).unwrap();
|
|
||||||
assert!(b.open_sub(&root, "fleet", AT, false).is_none(), "the same submenu again is a no-op");
|
|
||||||
let (deep, _) = b.open_sub(&fleet, "recently-lowered", AT, false).unwrap();
|
|
||||||
assert_eq!(b.descendants(&root).len(), 2);
|
|
||||||
// pinning the Fleet panel detaches it; the root closes, its own child stays its own
|
|
||||||
let closes = b.pin(&fleet, true);
|
|
||||||
assert_eq!(closes, vec![root.clone()]);
|
|
||||||
assert!(b.panels[&fleet].pinned && b.panels[&fleet].parent.is_none());
|
|
||||||
assert_eq!(b.descendants(&fleet), vec![deep.clone()]);
|
|
||||||
let (root2, closes) = b.open_root(Anchor::Point { x: 0.0, y: 0.0 });
|
|
||||||
assert_eq!(closes, vec![deep]);
|
|
||||||
assert!(b.panels.contains_key(&fleet));
|
|
||||||
assert_eq!(b.transient(), vec![root2.clone()]);
|
|
||||||
// a pick / Esc: transient panels go, the pinned one stays
|
|
||||||
assert_eq!(b.dismiss(), vec![root2]);
|
|
||||||
assert_eq!(b.panels.len(), 1);
|
|
||||||
// unpinned, it behaves like a menu again and goes with the next one
|
|
||||||
b.pin(&fleet, false);
|
|
||||||
let (_, closes) = b.open_root(Anchor::Point { x: 0.0, y: 0.0 });
|
|
||||||
assert!(closes.contains(&fleet));
|
|
||||||
}
|
|
||||||
|
|
||||||
#[test]
|
|
||||||
fn a_torn_off_submenu_keeps_one_pinned_copy() {
|
|
||||||
let mut b = Book::default();
|
|
||||||
let (root, _) = b.open_root(Anchor::Point { x: 0.0, y: 0.0 });
|
|
||||||
let (p1, _) = b.open_sub(&root, "fleet", AT, true).unwrap();
|
|
||||||
let (p2, closes) = b.open_sub(&root, "fleet", AT, true).unwrap();
|
|
||||||
assert!(closes.contains(&p1) && b.panels[&p2].pinned && !b.panels.contains_key(&p1));
|
|
||||||
assert_eq!(b.panels[&p2].path, vec!["fleet".to_string()]);
|
|
||||||
// the root stays open (a tear-off is not a pick)
|
|
||||||
assert!(b.panels.contains_key(&root));
|
|
||||||
// closing a panel that is already gone does nothing
|
|
||||||
assert!(b.close("menu-99").is_empty());
|
|
||||||
}
|
|
||||||
|
|
||||||
#[test]
|
|
||||||
fn a_live_update_closes_nothing_that_still_exists() {
|
|
||||||
let mut b = Book::default();
|
|
||||||
let (root, _) = b.open_root(Anchor::Point { x: 0.0, y: 0.0 });
|
|
||||||
let (profile, _) = b.open_sub(&root, "profile", AT, true).unwrap();
|
|
||||||
let (fleet, _) = b.open_sub(&root, "fleet", AT, false).unwrap();
|
|
||||||
assert!(b.prune(&tree()).is_empty());
|
|
||||||
// the Fleet submenu is gone from the tree: its transient panel closes, the pinned Profile panel stays even when its
|
|
||||||
// submenu goes too (it shows that it is gone)
|
|
||||||
let smaller = from_entries(&[Entry::Item { id: "open".into(), label: "Open".into(), enabled: true }]);
|
|
||||||
assert_eq!(b.prune(&smaller), vec![fleet]);
|
|
||||||
assert!(b.panels.contains_key(&root) && b.panels.contains_key(&profile));
|
|
||||||
}
|
|
||||||
|
|
||||||
#[test]
|
|
||||||
fn pins_are_saved_in_the_state_and_restored_after_a_restart() {
|
|
||||||
let mut b = Book::default();
|
|
||||||
let (root, _) = b.open_root(Anchor::Point { x: 0.0, y: 0.0 });
|
|
||||||
let (p, _) = b.open_sub(&root, "apps", AT, true).unwrap();
|
|
||||||
// not placed yet: nothing to save
|
|
||||||
assert!(b.pins().is_empty());
|
|
||||||
b.panels.get_mut(&p).unwrap().pos = Some((40.4, 50.6));
|
|
||||||
let pins = b.pins();
|
|
||||||
assert_eq!(pins, vec![PinRecord { path: vec!["apps".into()], x: 40, y: 51 }]);
|
|
||||||
// through state.json
|
|
||||||
let st = State { menu_pins: pins.clone(), ..State::default() };
|
|
||||||
let text = serde_json::to_string(&st).unwrap();
|
|
||||||
assert!(text.contains("\"menuPins\""));
|
|
||||||
let back: State = serde_json::from_str(&text).unwrap();
|
|
||||||
assert_eq!(back.menu_pins, pins);
|
|
||||||
// an empty list is not written at all (older files stay as they were)
|
|
||||||
assert!(!serde_json::to_string(&State::default()).unwrap().contains("menuPins"));
|
|
||||||
let mut fresh = Book::default();
|
|
||||||
let mut saved = back.menu_pins.clone();
|
|
||||||
saved.push(saved[0].clone()); // a duplicate is dropped
|
|
||||||
let labels = fresh.restore(&saved);
|
|
||||||
assert_eq!(labels.len(), 1);
|
|
||||||
let r = &fresh.panels[&labels[0]];
|
|
||||||
assert!(r.pinned && r.path == vec!["apps".to_string()] && r.pos == Some((40.0, 51.0)) && r.parent.is_none());
|
|
||||||
// a restored pin survives the next menu
|
|
||||||
let (_, closes) = fresh.open_root(Anchor::Point { x: 0.0, y: 0.0 });
|
|
||||||
assert!(closes.is_empty());
|
|
||||||
let many: Vec<PinRecord> = (0..40).map(|i| PinRecord { path: vec![format!("s{i}")], x: 0, y: 0 }).collect();
|
|
||||||
assert_eq!(Book::default().restore(&many).len(), MAX_PINS);
|
|
||||||
}
|
|
||||||
|
|
||||||
#[test]
|
|
||||||
fn panel_labels_are_menu_and_a_number() {
|
|
||||||
assert!(is_menu_label("menu-1") && is_menu_label("menu-204"));
|
|
||||||
for bad in ["menu-", "menu-a", "card", "main", "menu-1-2", "xmenu-1"] {
|
|
||||||
assert!(!is_menu_label(bad), "{bad}");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
@ -6,7 +6,7 @@ use std::path::{Path, PathBuf};
|
||||||
|
|
||||||
use serde_json::{json, Value};
|
use serde_json::{json, Value};
|
||||||
use storebound_desktop::policy::*;
|
use storebound_desktop::policy::*;
|
||||||
use storebound_desktop::{CARD_COMMANDS, COMMANDS, MENU_COMMANDS};
|
use storebound_desktop::{CARD_COMMANDS, COMMANDS};
|
||||||
use url::Url;
|
use url::Url;
|
||||||
|
|
||||||
fn root() -> PathBuf {
|
fn root() -> PathBuf {
|
||||||
|
|
@ -26,7 +26,7 @@ fn one_capability_for_the_main_window_with_exactly_the_app_commands() {
|
||||||
let dir = root().join("capabilities");
|
let dir = root().join("capabilities");
|
||||||
let mut files: Vec<PathBuf> = fs::read_dir(&dir).unwrap().map(|e| e.unwrap().path()).collect();
|
let mut files: Vec<PathBuf> = fs::read_dir(&dir).unwrap().map(|e| e.unwrap().path()).collect();
|
||||||
files.sort();
|
files.sort();
|
||||||
assert_eq!(files.len(), 3, "main, card and menu capability files expected, found {files:?}");
|
assert_eq!(files.len(), 2, "main and card capability files expected, found {files:?}");
|
||||||
let cap = read_json(&dir.join("main.json"));
|
let cap = read_json(&dir.join("main.json"));
|
||||||
assert_eq!(cap["identifier"], "main-window");
|
assert_eq!(cap["identifier"], "main-window");
|
||||||
assert_eq!(cap["windows"], json!(["main"]));
|
assert_eq!(cap["windows"], json!(["main"]));
|
||||||
|
|
@ -71,45 +71,6 @@ fn the_card_window_gets_only_the_card_commands() {
|
||||||
assert!(require_main("card", &u("tauri://localhost/card.html"), false).is_err());
|
assert!(require_main("card", &u("tauri://localhost/card.html"), false).is_err());
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
|
||||||
fn the_menu_panels_get_only_the_menu_commands() {
|
|
||||||
let cap = read_json(&root().join("capabilities/menu.json"));
|
|
||||||
assert_eq!(cap["identifier"], "menu-window");
|
|
||||||
assert_eq!(cap["windows"], json!(["menu-*"]));
|
|
||||||
assert!(cap.get("webviews").is_none() && cap.get("remote").is_none());
|
|
||||||
assert_ne!(cap["local"], json!(false));
|
|
||||||
let got: BTreeSet<String> = cap["permissions"].as_array().unwrap().iter().map(|p| p.as_str().unwrap().to_string()).collect();
|
|
||||||
let mut want: BTreeSet<String> = MENU_COMMANDS.iter().map(|c| format!("allow-{}", c.replace('_', "-"))).collect();
|
|
||||||
want.insert("core:event:allow-listen".into());
|
|
||||||
want.insert("core:event:allow-unlisten".into());
|
|
||||||
// a pinned panel is dragged by its header (data-tauri-drag-region): only its own window
|
|
||||||
want.insert("core:window:allow-start-dragging".into());
|
|
||||||
assert_eq!(got, want);
|
|
||||||
// the menu commands never leak into the main or card capability
|
|
||||||
for other in ["main.json", "card.json"] {
|
|
||||||
let cap = read_json(&root().join("capabilities").join(other));
|
|
||||||
let perms = cap["permissions"].to_string();
|
|
||||||
for c in MENU_COMMANDS {
|
|
||||||
assert!(!perms.contains(&format!("\"allow-{}\"", c.replace('_', "-"))), "{c} granted in {other}");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
let cmds = fs::read_to_string(root().join("src/commands.rs")).unwrap();
|
|
||||||
for c in MENU_COMMANDS {
|
|
||||||
let at = cmds.find(&format!("pub fn {c}(")).unwrap_or_else(|| panic!("{c} not in commands.rs"));
|
|
||||||
let body = &cmds[at..];
|
|
||||||
let open = body.find('{').unwrap();
|
|
||||||
assert!(body[open + 1..].trim_start().starts_with("guard_menu(&window)?;"), "{c} must start with guard_menu(&window)?");
|
|
||||||
}
|
|
||||||
assert!(require_menu("menu-1", &u("tauri://localhost/tray-menu.html"), false).is_ok());
|
|
||||||
assert!(require_menu("menu-12", &u("http://tauri.localhost/tray-menu.html"), false).is_ok());
|
|
||||||
for bad in ["main", "card", "menu-", "menu-x", "menu-1a", "menus-1"] {
|
|
||||||
assert!(require_menu(bad, &u("tauri://localhost/tray-menu.html"), false).is_err(), "{bad}");
|
|
||||||
}
|
|
||||||
assert!(require_menu("menu-1", &u("https://example.com/tray-menu.html"), false).is_err());
|
|
||||||
assert!(require_main("menu-1", &u("tauri://localhost/tray-menu.html"), false).is_err());
|
|
||||||
assert!(require_card("menu-1", &u("tauri://localhost/tray-menu.html"), false).is_err());
|
|
||||||
}
|
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn every_registered_command_is_in_the_list_and_nothing_else() {
|
fn every_registered_command_is_in_the_list_and_nothing_else() {
|
||||||
let lib = fs::read_to_string(root().join("src/lib.rs")).unwrap();
|
let lib = fs::read_to_string(root().join("src/lib.rs")).unwrap();
|
||||||
|
|
@ -120,7 +81,7 @@ fn every_registered_command_is_in_the_list_and_nothing_else() {
|
||||||
.map(|s| s.trim().trim_start_matches("commands::").to_string())
|
.map(|s| s.trim().trim_start_matches("commands::").to_string())
|
||||||
.filter(|s| !s.is_empty())
|
.filter(|s| !s.is_empty())
|
||||||
.collect();
|
.collect();
|
||||||
assert_eq!(registered, COMMANDS.iter().chain(CARD_COMMANDS).chain(MENU_COMMANDS).map(|s| s.to_string()).collect::<Vec<_>>());
|
assert_eq!(registered, COMMANDS.iter().chain(CARD_COMMANDS).map(|s| s.to_string()).collect::<Vec<_>>());
|
||||||
// every command checks the caller first
|
// every command checks the caller first
|
||||||
let cmds = fs::read_to_string(root().join("src/commands.rs")).unwrap();
|
let cmds = fs::read_to_string(root().join("src/commands.rs")).unwrap();
|
||||||
for c in COMMANDS {
|
for c in COMMANDS {
|
||||||
|
|
@ -148,7 +109,7 @@ fn csp_is_strict_and_the_config_has_no_backdoors() {
|
||||||
assert!(!v.contains("unsafe-eval") && !v.contains("unsafe-inline") && !v.contains('*'), "{k}: {v}");
|
assert!(!v.contains("unsafe-eval") && !v.contains("unsafe-inline") && !v.contains('*'), "{k}: {v}");
|
||||||
assert!(!v.contains("https:") && !v.contains("http://") || v == "ipc: http://ipc.localhost", "{k}: no remote sources: {v}");
|
assert!(!v.contains("https:") && !v.contains("http://") || v == "ipc: http://ipc.localhost", "{k}: no remote sources: {v}");
|
||||||
}
|
}
|
||||||
assert_eq!(conf["app"]["security"]["capabilities"], json!(["main-window", "card-window", "menu-window"]));
|
assert_eq!(conf["app"]["security"]["capabilities"], json!(["main-window", "card-window"]));
|
||||||
assert_eq!(conf["app"]["security"]["freezePrototype"], json!(true));
|
assert_eq!(conf["app"]["security"]["freezePrototype"], json!(true));
|
||||||
assert!(conf["app"].get("withGlobalTauri").is_none() || conf["app"]["withGlobalTauri"] == json!(false));
|
assert!(conf["app"].get("withGlobalTauri").is_none() || conf["app"]["withGlobalTauri"] == json!(false));
|
||||||
let windows = conf["app"]["windows"].as_array().unwrap();
|
let windows = conf["app"]["windows"].as_array().unwrap();
|
||||||
|
|
|
||||||
|
|
@ -23,7 +23,7 @@ fn ids(m: &[Entry]) -> Vec<String> {
|
||||||
fn menu_has_every_entry_in_order() {
|
fn menu_has_every_entry_in_order() {
|
||||||
let m = menu_model(&summary());
|
let m = menu_model(&summary());
|
||||||
assert_eq!(ids(&m), vec![ID_OPEN, ID_READ, ID_MUTE, ID_UPDATE, ID_SETTINGS, ID_QUIT]);
|
assert_eq!(ids(&m), vec![ID_OPEN, ID_READ, ID_MUTE, ID_UPDATE, ID_SETTINGS, ID_QUIT]);
|
||||||
let Entry::Sub { label, items, .. } = &m[3] else { panic!("the Apps submenu comes after the first separator") };
|
let Entry::Sub { label, items } = &m[3] else { panic!("the Apps submenu comes after the first separator") };
|
||||||
assert_eq!(label, "Apps");
|
assert_eq!(label, "Apps");
|
||||||
assert_eq!(items.len(), 2);
|
assert_eq!(items.len(), 2);
|
||||||
let Entry::Item { id, label, enabled } = &items[0] else { panic!() };
|
let Entry::Item { id, label, enabled } = &items[0] else { panic!() };
|
||||||
|
|
@ -90,7 +90,7 @@ fn only_known_small_routes_are_remembered() {
|
||||||
#[test]
|
#[test]
|
||||||
fn attention_dot_changes_only_the_corner() {
|
fn attention_dot_changes_only_the_corner() {
|
||||||
let (w, h) = (32u32, 32u32);
|
let (w, h) = (32u32, 32u32);
|
||||||
let base: Vec<u8> = std::iter::repeat_n([10u8, 20, 30, 255], (w * h) as usize).flatten().collect();
|
let base: Vec<u8> = std::iter::repeat([10u8, 20, 30, 255]).take((w * h) as usize).flatten().collect();
|
||||||
let out = with_attention_dot(&base, w, h);
|
let out = with_attention_dot(&base, w, h);
|
||||||
assert_eq!(out.len(), base.len());
|
assert_eq!(out.len(), base.len());
|
||||||
let at = |v: &[u8], x: u32, y: u32| -> [u8; 4] { let i = ((y * w + x) * 4) as usize; [v[i], v[i + 1], v[i + 2], v[i + 3]] };
|
let at = |v: &[u8], x: u32, y: u32| -> [u8; 4] { let i = ((y * w + x) * 4) as usize; [v[i], v[i + 1], v[i + 2], v[i + 3]] };
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,4 @@
|
||||||
// Shell: sidebar (apps grouped by what they need: attention, in progress, live, not on a store yet; one status line
|
// Shell: sidebar (studios, collapsible, with their apps; the workspace), top bar (breadcrumbs, last read, refresh),
|
||||||
// each; a studio filter; the workspace as a compact footer row), top bar (breadcrumbs, last read, refresh),
|
|
||||||
// the screen, the command palette (Cmd/Ctrl+K), toasts and the first-run welcome guide.
|
// the screen, the command palette (Cmd/Ctrl+K), toasts and the first-run welcome guide.
|
||||||
import { DryRunPreview } from './ui/DryRunPreview';
|
import { DryRunPreview } from './ui/DryRunPreview';
|
||||||
import { useCallback, useEffect, useMemo, useState } from 'react';
|
import { useCallback, useEffect, useMemo, useState } from 'react';
|
||||||
|
|
@ -7,8 +6,8 @@ import { FIXTURES, onDeepLink, onDeepLinkFolder, onTrayRoute } from './api';
|
||||||
import { devSwitch } from './dev/switches';
|
import { devSwitch } from './dev/switches';
|
||||||
import { type Key, t } from './i18n';
|
import { type Key, t } from './i18n';
|
||||||
import { ago, num } from './lib/format';
|
import { ago, num } from './lib/format';
|
||||||
import type { UnifiedApp } from './lib/identity';
|
import { groupByStudio, type UnifiedApp } from './lib/identity';
|
||||||
import { NavCtx, parseRouteJson, parseStart, type Route, sameRoute, SECTION_ICON, SECTION_KEY, sectionOf, sectionsFor, subsOf, TAB_ICON, TAB_KEY, tabsFor, WORKSPACE, type WorkspaceScreen } from './nav';
|
import { NavCtx, parseRouteJson, parseStart, type Route, sameRoute, TAB_ICON, TAB_KEY, tabsFor, WORKSPACE, type WorkspaceScreen } from './nav';
|
||||||
import { usePrefs } from './prefs-ctx';
|
import { usePrefs } from './prefs-ctx';
|
||||||
import { Accounts } from './screens/Accounts';
|
import { Accounts } from './screens/Accounts';
|
||||||
import { AppFolders } from './screens/AppFolders';
|
import { AppFolders } from './screens/AppFolders';
|
||||||
|
|
@ -29,18 +28,16 @@ import { Toasts } from './ui/Toasts';
|
||||||
import { useContextMenu } from './ui/ContextMenu';
|
import { useContextMenu } from './ui/ContextMenu';
|
||||||
import { appMenu } from './ui/app-menu';
|
import { appMenu } from './ui/app-menu';
|
||||||
import { isEditable, isItem, type MenuInput } from './ui/menu-logic';
|
import { isEditable, isItem, type MenuInput } from './ui/menu-logic';
|
||||||
import { attention, isGameSummary, SIDE_GROUPS, type SideGroup, sideStatus } from './lib/model';
|
import { worstTone } from './ui/ds';
|
||||||
|
import { attention } from './lib/model';
|
||||||
|
|
||||||
const WS_ICON: Record<WorkspaceScreen, IconName> = { apps: 'folder', accounts: 'building', ignored: 'eyeOff', dependencies: 'package', settings: 'settings' };
|
const WS_ICON: Record<WorkspaceScreen, IconName> = { apps: 'folder', accounts: 'building', ignored: 'eyeOff', dependencies: 'package', settings: 'settings' };
|
||||||
export const WS_KEY: Record<WorkspaceScreen, Key> = { apps: 'nav.apps', accounts: 'nav.accounts', ignored: 'nav.ignored', dependencies: 'nav.dependencies', settings: 'nav.settings' };
|
export const WS_KEY: Record<WorkspaceScreen, Key> = { apps: 'nav.apps', accounts: 'nav.accounts', ignored: 'nav.ignored', dependencies: 'nav.dependencies', settings: 'nav.settings' };
|
||||||
|
|
||||||
const SIDE_KEY = 'storebound.side.v1';
|
const SIDE_KEY = 'storebound.side.v1';
|
||||||
const STUDIO_KEY = 'storebound.side.studio.v1';
|
|
||||||
function loadCollapsed(): string[] {
|
function loadCollapsed(): string[] {
|
||||||
try { const v = JSON.parse(localStorage.getItem(SIDE_KEY) ?? '[]') as unknown; return Array.isArray(v) ? v.filter((x): x is string => typeof x === 'string') : []; } catch { return []; }
|
try { const v = JSON.parse(localStorage.getItem(SIDE_KEY) ?? '[]') as unknown; return Array.isArray(v) ? v.filter((x): x is string => typeof x === 'string') : []; } catch { return []; }
|
||||||
}
|
}
|
||||||
function loadStudio(): string | null { try { return localStorage.getItem(STUDIO_KEY); } catch { return null; } }
|
|
||||||
const GROUP_KEY: Record<SideGroup | 'ignored', Key> = { attention: 'side.gAttention', progress: 'side.gProgress', live: 'side.gLive', draft: 'side.gDraft', ignored: 'nav.ignored' };
|
|
||||||
|
|
||||||
export function App({ onTheme }: { onTheme: () => void }) {
|
export function App({ onTheme }: { onTheme: () => void }) {
|
||||||
const d = useData();
|
const d = useData();
|
||||||
|
|
@ -50,8 +47,6 @@ export function App({ onTheme }: { onTheme: () => void }) {
|
||||||
const [welcome, setWelcome] = useState(false);
|
const [welcome, setWelcome] = useState(false);
|
||||||
const [started, setStarted] = useState(false);
|
const [started, setStarted] = useState(false);
|
||||||
const [collapsed, setCollapsed] = useState<string[]>(loadCollapsed);
|
const [collapsed, setCollapsed] = useState<string[]>(loadCollapsed);
|
||||||
const [studioFilter, setStudioFilterState] = useState<string | null>(loadStudio);
|
|
||||||
const setStudioFilter = (v: string | null) => { setStudioFilterState(v); try { if (v) localStorage.setItem(STUDIO_KEY, v); else localStorage.removeItem(STUDIO_KEY); } catch { /* private mode */ } };
|
|
||||||
const exports = useExportItems();
|
const exports = useExportItems();
|
||||||
const runExport = useRunExport();
|
const runExport = useRunExport();
|
||||||
|
|
||||||
|
|
@ -61,27 +56,16 @@ export function App({ onTheme }: { onTheme: () => void }) {
|
||||||
const allReads = useReadState({ tags: ['all'] });
|
const allReads = useReadState({ tags: ['all'] });
|
||||||
const [showIgnored, setShowIgnored] = useShowIgnored();
|
const [showIgnored, setShowIgnored] = useShowIgnored();
|
||||||
const ignoredApps = useMemo(() => d.apps.filter(a => a.ignored).sort((a, b) => a.name.localeCompare(b.name)), [d.apps]);
|
const ignoredApps = useMemo(() => d.apps.filter(a => a.ignored).sort((a, b) => a.name.localeCompare(b.name)), [d.apps]);
|
||||||
const gameOf = useCallback((a: UnifiedApp) => isGameSummary(d.statusFor(a)?.summary), [d]);
|
const listed = showIgnored ? [...visible, ...ignoredApps] : visible;
|
||||||
const tabsOf = useCallback((a: UnifiedApp) => tabsFor(!!a.project, gameOf(a)), [gameOf]);
|
const groups = d.studios.length ? groupByStudio(listed.map(a => ({ app: a })), d.studios) : [{ studio: null as string | null, rows: listed.map(a => ({ app: a })) }];
|
||||||
// the sidebar: apps by what they need (attention, in progress, live, not on a store yet), one status line each
|
// Alt+Up / Alt+Down: the previous / next app in sidebar order (keeps the tab when the other app has it)
|
||||||
const studioOn = studioFilter && (studioFilter === 'none' || d.studios.some(s => s.id === studioFilter)) ? studioFilter : null;
|
const sideOrder = groups.flatMap(x => x.rows.map(r => r.app));
|
||||||
const inStudio = useCallback((a: UnifiedApp) => !studioOn || (studioOn === 'none' ? !a.studio : a.studio === studioOn), [studioOn]);
|
|
||||||
const sideRows = useMemo(() => visible.filter(inStudio).map(a => {
|
|
||||||
const e = d.statusFor(a), l = d.liveFor(a);
|
|
||||||
return { app: a, st: sideStatus({ att: attention(a.key, a.name, e, l), all: l?.release.all ?? [], read: !!l || e?.release.source === 'live', missing: !!a.project?.missing, storeOnly: !a.project }) };
|
|
||||||
}), [visible, d, inStudio]);
|
|
||||||
const groups: { id: SideGroup | 'ignored'; rows: typeof sideRows }[] = [
|
|
||||||
...SIDE_GROUPS.map(g => ({ id: g, rows: sideRows.filter(r => r.st.group === g) })).filter(g => g.rows.length),
|
|
||||||
...(showIgnored && ignoredApps.length ? [{ id: 'ignored' as const, rows: ignoredApps.filter(inStudio).map(a => ({ app: a, st: { group: 'draft' as SideGroup, text: t('side.ignored'), tone: 'neutral' as const } })) }] : []),
|
|
||||||
];
|
|
||||||
// Alt+Up / Alt+Down: the previous / next app in sidebar order (keeps the place when the other app has it)
|
|
||||||
const sideOrder = groups.flatMap(x => (collapsed.includes(`g:${x.id}`) ? [] : x.rows.map(r => r.app)));
|
|
||||||
const stepApp = useCallback((dir: 1 | -1) => {
|
const stepApp = useCallback((dir: 1 | -1) => {
|
||||||
if (!sideOrder.length) return;
|
if (!sideOrder.length) return;
|
||||||
const i = route.screen === 'app' ? sideOrder.findIndex(a => a.key === route.appId) : -1;
|
const i = route.screen === 'app' ? sideOrder.findIndex(a => a.key === route.appId) : -1;
|
||||||
const next = sideOrder[i < 0 ? (dir === 1 ? 0 : sideOrder.length - 1) : (i + dir + sideOrder.length) % sideOrder.length]!;
|
const next = sideOrder[i < 0 ? (dir === 1 ? 0 : sideOrder.length - 1) : (i + dir + sideOrder.length) % sideOrder.length]!;
|
||||||
go({ screen: 'app', appId: next.key, tab: route.screen === 'app' && tabsOf(next).includes(route.tab) ? route.tab : 'releases' });
|
go({ screen: 'app', appId: next.key, tab: route.screen === 'app' && tabsFor(!!next.project).includes(route.tab) ? route.tab : 'releases' });
|
||||||
}, [sideOrder, route, go, tabsOf]);
|
}, [sideOrder, route, go]);
|
||||||
const toggleGroup = (id: string) => setCollapsed(c => {
|
const toggleGroup = (id: string) => setCollapsed(c => {
|
||||||
const next = c.includes(id) ? c.filter(x => x !== id) : [...c, id];
|
const next = c.includes(id) ? c.filter(x => x !== id) : [...c, id];
|
||||||
try { localStorage.setItem(SIDE_KEY, JSON.stringify(next)); } catch { /* private mode */ }
|
try { localStorage.setItem(SIDE_KEY, JSON.stringify(next)); } catch { /* private mode */ }
|
||||||
|
|
@ -110,12 +94,9 @@ export function App({ onTheme }: { onTheme: () => void }) {
|
||||||
}, [go, d.reload]);
|
}, [go, d.reload]);
|
||||||
|
|
||||||
const app = route.screen === 'app' ? d.appByKey(route.appId) : undefined;
|
const app = route.screen === 'app' ? d.appByKey(route.appId) : undefined;
|
||||||
const game = app ? gameOf(app) : false;
|
const tabs = app ? tabsFor(!!app.project) : [];
|
||||||
const tabs = app ? tabsOf(app) : [];
|
|
||||||
const sections = app ? sectionsFor(!!app.project, game) : [];
|
|
||||||
|
|
||||||
// keyboard: Cmd/Ctrl+K palette, Cmd/Ctrl+1 portfolio, 2-6 workspace, 1-5 (no modifier) the app's sections,
|
// keyboard: Cmd/Ctrl+K palette, Cmd/Ctrl+1 portfolio, 2-6 workspace, Cmd/Ctrl+Shift+[ ] app tabs
|
||||||
// Cmd/Ctrl+Shift+[ ] the previous / next section
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
const onKey = (e: KeyboardEvent) => {
|
const onKey = (e: KeyboardEvent) => {
|
||||||
const mod = e.metaKey || e.ctrlKey;
|
const mod = e.metaKey || e.ctrlKey;
|
||||||
|
|
@ -128,20 +109,15 @@ export function App({ onTheme }: { onTheme: () => void }) {
|
||||||
go(n === 1 ? { screen: 'portfolio' } : { screen: WORKSPACE[n - 2]! });
|
go(n === 1 ? { screen: 'portfolio' } : { screen: WORKSPACE[n - 2]! });
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (!mod && !e.shiftKey && !e.altKey && /^[1-9]$/.test(e.key) && route.screen === 'app' && app && !isEditable(e.target as HTMLInputElement) && !document.querySelector('.ds-menu, .ds-dialog')) {
|
if (mod && e.shiftKey && (e.key === '[' || e.key === ']' || e.key === '{' || e.key === '}') && route.screen === 'app' && tabs.length) {
|
||||||
const sec = sections[Number(e.key) - 1];
|
|
||||||
if (sec) { e.preventDefault(); go({ ...route, tab: subsOf(sec, !!app.project, game)[0]! }); }
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
if (mod && e.shiftKey && (e.key === '[' || e.key === ']' || e.key === '{' || e.key === '}') && route.screen === 'app' && app && sections.length) {
|
|
||||||
e.preventDefault();
|
e.preventDefault();
|
||||||
const i = sections.indexOf(sectionOf(route.tab)) + (e.key === ']' || e.key === '}' ? 1 : -1);
|
const i = tabs.indexOf(route.tab) + (e.key === ']' || e.key === '}' ? 1 : -1);
|
||||||
go({ ...route, tab: subsOf(sections[(i + sections.length) % sections.length]!, !!app.project, game)[0]! });
|
go({ ...route, tab: tabs[(i + tabs.length) % tabs.length]! });
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
window.addEventListener('keydown', onKey);
|
window.addEventListener('keydown', onKey);
|
||||||
return () => window.removeEventListener('keydown', onKey);
|
return () => window.removeEventListener('keydown', onKey);
|
||||||
}, [palette, welcome, route, go, app, sections, game, stepApp]);
|
}, [palette, welcome, route, go, tabs, stepApp]);
|
||||||
|
|
||||||
const closeWelcome = useCallback(() => {
|
const closeWelcome = useCallback(() => {
|
||||||
setWelcome(false);
|
setWelcome(false);
|
||||||
|
|
@ -155,18 +131,13 @@ export function App({ onTheme }: { onTheme: () => void }) {
|
||||||
const G = { apps: t('palette.gApps'), go: t('palette.gGo'), tabs: t('palette.gTabs'), act: t('palette.gActions'), exp: t('palette.gExport') };
|
const G = { apps: t('palette.gApps'), go: t('palette.gGo'), tabs: t('palette.gTabs'), act: t('palette.gActions'), exp: t('palette.gExport') };
|
||||||
const studioName = (a: UnifiedApp) => d.studios.find(s => s.id === a.studio)?.name;
|
const studioName = (a: UnifiedApp) => d.studios.find(s => s.id === a.studio)?.name;
|
||||||
for (const a of visible) c.push({ id: `app-${a.key}`, group: G.apps, title: a.name, hint: studioName(a) ?? t('palette.openApp'), keywords: `${a.ios?.app.bundleId ?? ''} ${a.android?.app.id ?? ''} ${a.project?.name ?? ''}`, app: { name: a.name, icon: d.iconFor(a) },
|
for (const a of visible) c.push({ id: `app-${a.key}`, group: G.apps, title: a.name, hint: studioName(a) ?? t('palette.openApp'), keywords: `${a.ios?.app.bundleId ?? ''} ${a.android?.app.id ?? ''} ${a.project?.name ?? ''}`, app: { name: a.name, icon: d.iconFor(a) },
|
||||||
run: () => go({ screen: 'app', appId: a.key, tab: route.screen === 'app' && tabsOf(a).includes(route.tab) ? route.tab : 'releases' }) });
|
run: () => go({ screen: 'app', appId: a.key, tab: route.screen === 'app' && tabsFor(!!a.project).includes(route.tab) ? route.tab : 'releases' }) });
|
||||||
c.push({ id: 'go-next-app', group: G.go, title: t('palette.nextApp'), icon: 'arrowRight', hint: 'Alt ↓', keywords: 'next app down j', run: () => stepApp(1) });
|
c.push({ id: 'go-next-app', group: G.go, title: t('palette.nextApp'), icon: 'arrowRight', hint: 'Alt ↓', keywords: 'next app down j', run: () => stepApp(1) });
|
||||||
c.push({ id: 'go-prev-app', group: G.go, title: t('palette.prevApp'), icon: 'arrowLeft', hint: 'Alt ↑', keywords: 'previous app up k', run: () => stepApp(-1) });
|
c.push({ id: 'go-prev-app', group: G.go, title: t('palette.prevApp'), icon: 'arrowLeft', hint: 'Alt ↑', keywords: 'previous app up k', run: () => stepApp(-1) });
|
||||||
c.push({ id: 'go-portfolio', group: G.go, title: t('nav.portfolio'), icon: 'portfolio', hint: `${MOD} 1`, run: () => go({ screen: 'portfolio' }) });
|
c.push({ id: 'go-portfolio', group: G.go, title: t('nav.portfolio'), icon: 'portfolio', hint: `${MOD} 1`, run: () => go({ screen: 'portfolio' }) });
|
||||||
WORKSPACE.forEach((s, i) => c.push({ id: `go-${s}`, group: G.go, title: t(WS_KEY[s]), icon: WS_ICON[s], hint: `${MOD} ${i + 2}`, run: () => go({ screen: s }) }));
|
WORKSPACE.forEach((s, i) => c.push({ id: `go-${s}`, group: G.go, title: t(WS_KEY[s]), icon: WS_ICON[s], hint: `${MOD} ${i + 2}`, run: () => go({ screen: s }) }));
|
||||||
for (const s of d.studios) c.push({ id: `studio-${s.id}`, group: G.go, title: s.name, icon: 'building', keywords: 'studio', hint: t('palette.studio'), run: () => go({ screen: 'accounts', section: s.id }) });
|
for (const s of d.studios) c.push({ id: `studio-${s.id}`, group: G.go, title: s.name, icon: 'building', keywords: 'studio', hint: t('palette.studio'), run: () => go({ screen: 'accounts', section: s.id }) });
|
||||||
// every section of the open app (1-5) and every sub view in it
|
if (app) for (const tab of tabs) c.push({ id: `tab-${tab}`, group: G.tabs, title: `${app.name} · ${t(TAB_KEY[tab])}`, icon: TAB_ICON[tab], run: () => go({ screen: 'app', appId: app.key, tab }) });
|
||||||
if (app) sections.forEach((sec, i) => {
|
|
||||||
const subs = subsOf(sec, !!app.project, game);
|
|
||||||
c.push({ id: `sec-${sec}`, group: G.tabs, title: `${app.name} · ${t(SECTION_KEY[sec])}`, icon: SECTION_ICON[sec], hint: String(i + 1), keywords: subs.map(x => t(TAB_KEY[x])).join(' '), run: () => go({ screen: 'app', appId: app.key, tab: subs[0]! }) });
|
|
||||||
if (subs.length > 1) for (const tab of subs) c.push({ id: `tab-${tab}`, group: G.tabs, title: `${app.name} · ${t(SECTION_KEY[sec])} · ${t(TAB_KEY[tab])}`, icon: TAB_ICON[tab], run: () => go({ screen: 'app', appId: app.key, tab }) });
|
|
||||||
});
|
|
||||||
// the app's own menu (consoles, folder, copy ids, reads, ignore, unpair) as commands: every right-click action is
|
// the app's own menu (consoles, folder, copy ids, reads, ignore, unpair) as commands: every right-click action is
|
||||||
// also one Ctrl+K away; opening a tab is already above
|
// also one Ctrl+K away; opening a tab is already above
|
||||||
if (app) {
|
if (app) {
|
||||||
|
|
@ -195,10 +166,10 @@ export function App({ onTheme }: { onTheme: () => void }) {
|
||||||
c.push({ id: 'act-theme', group: G.act, title: t('action.toggleTheme'), icon: 'moon', keywords: 'dark light', run: onTheme });
|
c.push({ id: 'act-theme', group: G.act, title: t('action.toggleTheme'), icon: 'moon', keywords: 'dark light', run: onTheme });
|
||||||
c.push({ id: 'act-welcome', group: G.act, title: t('action.welcome'), icon: 'sparkle', keywords: 'onboarding start guide', run: () => setWelcome(true) });
|
c.push({ id: 'act-welcome', group: G.act, title: t('action.welcome'), icon: 'sparkle', keywords: 'onboarding start guide', run: () => setWelcome(true) });
|
||||||
return c;
|
return c;
|
||||||
}, [d, visible, app, sections, game, route, go, onTheme, exports, runExport, showIgnored, stepApp, prefs, update, tabsOf]);
|
}, [d, visible, app, tabs, route, go, onTheme, exports, runExport, showIgnored, stepApp, prefs, update]);
|
||||||
|
|
||||||
const crumbs: { label: string; to?: Route }[] = route.screen === 'portfolio' ? [{ label: t('nav.portfolio') }]
|
const crumbs: { label: string; to?: Route }[] = route.screen === 'portfolio' ? [{ label: t('nav.portfolio') }]
|
||||||
: route.screen === 'app' ? [{ label: t('nav.portfolio'), to: { screen: 'portfolio' } }, { label: app?.name ?? '', to: app ? { screen: 'app', appId: app.key, tab: 'releases' } : undefined }, { label: t(SECTION_KEY[sectionOf(route.tab)]), to: app ? { screen: 'app', appId: app.key, tab: subsOf(sectionOf(route.tab), !!app.project, game)[0] ?? route.tab } : undefined }, ...(app && subsOf(sectionOf(route.tab), !!app.project, game).length > 1 ? [{ label: t(TAB_KEY[route.tab]) }] : [])]
|
: route.screen === 'app' ? [{ label: t('nav.portfolio'), to: { screen: 'portfolio' } }, { label: app?.name ?? '', to: app ? { screen: 'app', appId: app.key, tab: 'releases' } : undefined }, { label: t(TAB_KEY[route.tab]) }]
|
||||||
: [{ label: t('nav.workspace') }, { label: t(WS_KEY[route.screen]) }];
|
: [{ label: t('nav.workspace') }, { label: t(WS_KEY[route.screen]) }];
|
||||||
const lastRead = d.live?.at ?? null;
|
const lastRead = d.live?.at ?? null;
|
||||||
// the app on screen is read first by the background reader
|
// the app on screen is read first by the background reader
|
||||||
|
|
@ -209,19 +180,26 @@ export function App({ onTheme }: { onTheme: () => void }) {
|
||||||
const ignoredCount = d.apps.filter(a => a.ignored).length + d.overrides.ignored.filter(i => i.startsWith('account:')).length;
|
const ignoredCount = d.apps.filter(a => a.ignored).length + d.overrides.ignored.filter(i => i.startsWith('account:')).length;
|
||||||
|
|
||||||
const menu = useContextMenu();
|
const menu = useContextMenu();
|
||||||
const appItem = (a: UnifiedApp, st: { text: string; tone: string }) => (
|
const appItem = (a: UnifiedApp) => {
|
||||||
|
const e = d.statusFor(a);
|
||||||
|
const missing = !!a.project?.missing;
|
||||||
|
const tone = missing ? 'bad' : (worstTone(attention(a.key, a.name, e, d.liveFor(a))) ?? (e ? 'ok' : null));
|
||||||
|
const bad = missing ? 1 : (e?.errors.length ?? 0) + (e?.check?.problems.length ?? 0);
|
||||||
|
return (
|
||||||
<div role="listitem" key={a.key}>
|
<div role="listitem" key={a.key}>
|
||||||
<button {...menu(() => appMenu(a, d, nav, { showIgnored }), `app:${a.key}`)} className={`nav nav-app has-line${a.ignored ? ' is-ignored' : ''}`} aria-current={current({ screen: 'app', appId: a.key, tab: 'releases' })}
|
<button {...menu(() => appMenu(a, d, nav, { showIgnored }))} className={`nav nav-app${a.ignored ? ' is-ignored' : ''}`} aria-current={current({ screen: 'app', appId: a.key, tab: 'releases' })}
|
||||||
onClick={() => go({ screen: 'app', appId: a.key, tab: route.screen === 'app' && tabsOf(a).includes(route.tab) ? route.tab : 'releases' })}
|
onClick={() => go({ screen: 'app', appId: a.key, tab: route.screen === 'app' && tabsFor(!!a.project).includes(route.tab) ? route.tab : 'releases' })}>
|
||||||
title={`${a.name} · ${st.text}`}>
|
<span className="ds-side-ic"><AppIcon name={a.name} src={d.iconFor(a)} />{tone && <span className={`ds-sdot ${tone}`} role="img" aria-label={tone === 'bad' ? t('pf.blocker') : tone === 'warn' ? t('pf.warning') : t('pf.note')} />}</span>
|
||||||
<span className="ds-side-ic"><AppIcon name={a.name} src={d.iconFor(a)} />{(st.tone === 'bad' || st.tone === 'warn') && <span className={`ds-sdot ${st.tone}`} role="img" aria-label={st.tone === 'bad' ? t('pf.blocker') : t('pf.warning')} />}</span>
|
<span className="grow">{a.name}</span>
|
||||||
<span className="grow side-t"><span className="side-n">{a.name}</span><span className={`side-s ${st.tone}`} data-testid="side-status">{st.text}</span></span>
|
{a.ignored && <span className="so-dot" title={t('ignored.rowHint')}><Icon name="eyeOff" /></span>}
|
||||||
{!a.ignored && a.ignoredStores.length > 0 && <span className="so-dot" title={t('ignored.sideHint', { stores: a.ignoredStores.map(k => (k === 'ios' ? 'App Store' : 'Google Play')).join(', ') })}><Icon name="eyeOff" /></span>}
|
{!a.ignored && a.ignoredStores.length > 0 && <span className="so-dot" title={t('ignored.sideHint', { stores: a.ignoredStores.map(k => (k === 'ios' ? 'App Store' : 'Google Play')).join(', ') })}><Icon name="eyeOff" /></span>}
|
||||||
{!a.project && <span className="so-dot" title={t('apps.storeOnlyHint')}><Icon name="cloud" /></span>}
|
{!a.project && <span className="so-dot" title={t('apps.storeOnlyHint')}><Icon name="cloud" /></span>}
|
||||||
|
{missing ? <span className="tag-count bad" title={t('folder.missingShort')} aria-label={t('folder.missingShort')}>!</span>
|
||||||
|
: bad > 0 && <span className="tag-count bad" aria-label={t('nav.problems', { count: bad })}>{bad}</span>}
|
||||||
</button>
|
</button>
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
const WS_ROW: (WorkspaceScreen | 'portfolio')[] = ['portfolio', ...WORKSPACE];
|
};
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<NavCtx.Provider value={nav}>
|
<NavCtx.Provider value={nav}>
|
||||||
|
|
@ -235,41 +213,36 @@ export function App({ onTheme }: { onTheme: () => void }) {
|
||||||
</button>
|
</button>
|
||||||
</div>
|
</div>
|
||||||
<div className="side-scroll">
|
<div className="side-scroll">
|
||||||
<div className="side-label" id="apps-label"><span>{t('nav.appsLabel')} <span className="count">{visible.length}</span></span>
|
<button className="nav" aria-current={current({ screen: 'portfolio' })} onClick={() => go({ screen: 'portfolio' })}>
|
||||||
|
<Icon name="portfolio" weight={current({ screen: 'portfolio' }) ? 'fill' : 'regular'} /><span className="grow">{t('nav.portfolio')}</span><span className="count">{visible.length}</span>
|
||||||
|
</button>
|
||||||
|
<div className="side-label" id="apps-label"><span>{d.studios.length ? t('nav.studiosLabel') : t('nav.appsLabel')}</span>
|
||||||
<button onClick={() => go({ screen: 'apps' })} aria-label={t('action.addFolder')} title={t('action.addFolder')}><Icon name="plus" /></button>
|
<button onClick={() => go({ screen: 'apps' })} aria-label={t('action.addFolder')} title={t('action.addFolder')}><Icon name="plus" /></button>
|
||||||
</div>
|
</div>
|
||||||
{d.studios.length > 1 && (
|
|
||||||
<div className="side-studios" role="group" aria-label={t('side.studioFilter')}>
|
|
||||||
<button aria-pressed={!studioOn} onClick={() => setStudioFilter(null)}>{t('side.allStudios')}</button>
|
|
||||||
{d.studios.map(s => <button key={s.id} aria-pressed={studioOn === s.id} onClick={() => setStudioFilter(studioOn === s.id ? null : s.id)}><StudioMark studio={s} size="sm" />{s.name}</button>)}
|
|
||||||
</div>
|
|
||||||
)}
|
|
||||||
{groups.map(g => {
|
{groups.map(g => {
|
||||||
const gid = `g:${g.id}`;
|
const s = d.studios.find(x => x.id === g.studio) ?? null;
|
||||||
|
const gid = g.studio ?? 'none';
|
||||||
const open = !collapsed.includes(gid);
|
const open = !collapsed.includes(gid);
|
||||||
|
if (!d.studios.length) return <div role="list" aria-labelledby="apps-label" key={gid}>{g.rows.map(r => appItem(r.app))}</div>;
|
||||||
return (
|
return (
|
||||||
<div className="side-group" key={gid} data-group={g.id}>
|
<div className="side-group" key={gid}>
|
||||||
<button className="side-group-head" aria-expanded={open} aria-controls={`sg-${g.id}`} onClick={() => toggleGroup(gid)}>
|
<button className="side-group-head" aria-expanded={open} aria-controls={`sg-${gid}`} onClick={() => toggleGroup(gid)}>
|
||||||
<Icon name="chevronRight" className="chev" /><span className="grow">{t(GROUP_KEY[g.id])}</span><span className="count">{g.rows.length}</span>
|
<Icon name="chevronRight" className="chev" /><StudioMark studio={s} size="sm" /><span className="grow">{s?.name ?? t('studio.none')}</span><span className="count">{g.rows.length}</span>
|
||||||
</button>
|
</button>
|
||||||
{open && <div role="list" id={`sg-${g.id}`} aria-label={t(GROUP_KEY[g.id])}>{g.rows.map(r => appItem(r.app, r.st))}</div>}
|
{open && <div role="list" id={`sg-${gid}`} aria-label={s?.name ?? t('studio.none')}>{g.rows.map(r => appItem(r.app))}</div>}
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
})}
|
})}
|
||||||
{!visible.length && !showIgnored && <p className="side-empty">{t('nav.noApps')}</p>}
|
{!visible.length && !showIgnored && <p className="side-empty">{t('nav.noApps')}</p>}
|
||||||
{ignoredApps.length > 0 && <button className="link side-ignored-toggle" aria-pressed={showIgnored} onClick={() => setShowIgnored(!showIgnored)} data-testid="toggle-ignored">{showIgnored ? t('ignored.hide', { count: ignoredApps.length }) : t('ignored.show', { count: ignoredApps.length })}</button>}
|
{ignoredApps.length > 0 && <button className="link side-ignored-toggle" aria-pressed={showIgnored} onClick={() => setShowIgnored(!showIgnored)} data-testid="toggle-ignored">{showIgnored ? t('ignored.hide', { count: ignoredApps.length }) : t('ignored.show', { count: ignoredApps.length })}</button>}
|
||||||
</div>
|
<div className="side-label"><span>{t('nav.workspace')}</span></div>
|
||||||
<div className="side-ws" role="group" aria-label={t('nav.workspace')}>
|
{WORKSPACE.map((s, i) => (
|
||||||
{WS_ROW.map((s, i) => {
|
<button key={s} className="nav" aria-current={current({ screen: s })} onClick={() => go({ screen: s })} title={`${t(WS_KEY[s])} (${MOD} ${i + 2})`}>
|
||||||
const label = s === 'portfolio' ? t('nav.portfolio') : t(WS_KEY[s]);
|
<Icon name={WS_ICON[s]} weight={current({ screen: s }) ? 'fill' : 'regular'} /><span className="grow">{t(WS_KEY[s])}</span>
|
||||||
const n = s === 'accounts' ? d.accounts.length : s === 'ignored' ? ignoredCount : 0;
|
{s === 'accounts' && <span className="count">{d.accounts.length}</span>}
|
||||||
return (
|
{s === 'ignored' && ignoredCount > 0 && <span className="count">{ignoredCount}</span>}
|
||||||
<button key={s} className="nav-ws" aria-current={current({ screen: s })} onClick={() => go({ screen: s })} title={`${label} (${MOD} ${i + 1})`} aria-label={label} data-screen={s}>
|
|
||||||
<Icon name={s === 'portfolio' ? 'portfolio' : WS_ICON[s]} weight={current({ screen: s }) ? 'fill' : 'regular'} />
|
|
||||||
{n > 0 && <span className="ws-n">{n}</span>}
|
|
||||||
</button>
|
</button>
|
||||||
);
|
))}
|
||||||
})}
|
|
||||||
</div>
|
</div>
|
||||||
<div className="side-foot" aria-live="polite">
|
<div className="side-foot" aria-live="polite">
|
||||||
<div className="row"><i className={`dot ${d.sidecar?.running ? 'ok' : d.sidecarError ? 'bad' : ''}`} />
|
<div className="row"><i className={`dot ${d.sidecar?.running ? 'ok' : d.sidecarError ? 'bad' : ''}`} />
|
||||||
|
|
|
||||||
|
|
@ -36,8 +36,7 @@ export interface Settings {
|
||||||
cache: { keepDays: 0 | 7 | 30 | 90 | 365 };
|
cache: { keepDays: 0 | 7 | 30 | 90 | 365 };
|
||||||
/** reviewState: other state changes (submitted, in review); rejected / approved / live: own toggles; crash also covers a halted rollout. quietHours: no notification between from and to (HH:MM, may cross midnight). */
|
/** reviewState: other state changes (submitted, in review); rejected / approved / live: own toggles; crash also covers a halted rollout. quietHours: no notification between from and to (HH:MM, may cross midnight). */
|
||||||
notify: { reviewState: boolean; rejected: boolean; approved: boolean; live: boolean; lowReviews: boolean; crash: boolean; quietHours: { enabled: boolean; from: string; to: string } };
|
notify: { reviewState: boolean; rejected: boolean; approved: boolean; live: boolean; lowReviews: boolean; crash: boolean; quietHours: { enabled: boolean; from: string; to: string } };
|
||||||
/** Update channel: stable (npm releases) or dev (every push to main); beta is kept for saved states. */
|
channel: 'stable' | 'beta';
|
||||||
channel: 'stable' | 'dev' | 'beta';
|
|
||||||
}
|
}
|
||||||
export const DEFAULT_SETTINGS: Settings = { refresh: { autoMinutes: 0, onLaunch: false, parallel: 4, icons: true, autoRead: true, everyMinutes: 15 }, cache: { keepDays: 30 }, notify: { reviewState: true, rejected: true, approved: true, live: true, lowReviews: true, crash: true, quietHours: { enabled: false, from: '23:00', to: '08:00' } }, channel: 'stable' };
|
export const DEFAULT_SETTINGS: Settings = { refresh: { autoMinutes: 0, onLaunch: false, parallel: 4, icons: true, autoRead: true, everyMinutes: 15 }, cache: { keepDays: 30 }, notify: { reviewState: true, rejected: true, approved: true, live: true, lowReviews: true, crash: true, quietHours: { enabled: false, from: '23:00', to: '08:00' } }, channel: 'stable' };
|
||||||
export interface Workspace { studios: Studio[]; overrides: Overrides; settings: Settings }
|
export interface Workspace { studios: Studio[]; overrides: Overrides; settings: Settings }
|
||||||
|
|
@ -48,7 +47,7 @@ export interface CacheEntry<T = unknown> { value: T; at: string }
|
||||||
export interface DownloadInfo { tool: 'ffmpeg' | 'chrome'; available: boolean; version: string | null; size: number | null; license: string; licenseUrl: string; source: string; installed: boolean; folder: string }
|
export interface DownloadInfo { tool: 'ffmpeg' | 'chrome'; available: boolean; version: string | null; size: number | null; license: string; licenseUrl: string; source: string; installed: boolean; folder: string }
|
||||||
export interface DownloadEvent { job: string; tool: string; stage: 'resolve' | 'download' | 'verify' | 'unpack' | 'install' | 'done' | 'error' | 'cancelled'; received: number; total: number | null; message?: string }
|
export interface DownloadEvent { job: string; tool: string; stage: 'resolve' | 'download' | 'verify' | 'unpack' | 'install' | 'done' | 'error' | 'cancelled'; received: number; total: number | null; message?: string }
|
||||||
export type { IconResult as Icon };
|
export type { IconResult as Icon };
|
||||||
export interface UpdateInfo { current: string; channel: 'stable' | 'dev' | 'beta'; available: string | null; notes: string | null; date: string | null }
|
export interface UpdateInfo { current: string; channel: 'stable' | 'beta'; available: string | null; notes: string | null; date: string | null }
|
||||||
|
|
||||||
/** What a failed command rejects with (sidecar.rs `Fail`). */
|
/** What a failed command rejects with (sidecar.rs `Fail`). */
|
||||||
export interface Fail { code: number; message: string; data?: unknown }
|
export interface Fail { code: number; message: string; data?: unknown }
|
||||||
|
|
|
||||||
|
|
@ -1,15 +1,6 @@
|
||||||
// The tray card: store status at a glance next to the tray icon. It only draws the main window's snapshot (card_get /
|
// The tray card: store status at a glance next to the tray icon. It only draws the main window's snapshot (card_get /
|
||||||
// `card-snapshot`) and sends its buttons back (card_action); Refresh is the main window's own Refresh all.
|
// `card-snapshot`) and sends its buttons back (card_action); Refresh is the main window's own Refresh all.
|
||||||
import { ArrowsClockwiseIcon } from '@phosphor-icons/react/dist/csr/ArrowsClockwise';
|
import { ArrowsClockwise, ArrowSquareOut, BellSlash, Bell, DotsThree, Power, Star, WarningOctagon, Pulse, AppWindow } from '@phosphor-icons/react';
|
||||||
import { ArrowSquareOutIcon } from '@phosphor-icons/react/dist/csr/ArrowSquareOut';
|
|
||||||
import { BellSlashIcon } from '@phosphor-icons/react/dist/csr/BellSlash';
|
|
||||||
import { BellIcon } from '@phosphor-icons/react/dist/csr/Bell';
|
|
||||||
import { DotsThreeIcon } from '@phosphor-icons/react/dist/csr/DotsThree';
|
|
||||||
import { PowerIcon } from '@phosphor-icons/react/dist/csr/Power';
|
|
||||||
import { StarIcon } from '@phosphor-icons/react/dist/csr/Star';
|
|
||||||
import { WarningOctagonIcon } from '@phosphor-icons/react/dist/csr/WarningOctagon';
|
|
||||||
import { PulseIcon } from '@phosphor-icons/react/dist/csr/Pulse';
|
|
||||||
import { AppWindowIcon } from '@phosphor-icons/react/dist/csr/AppWindow';
|
|
||||||
import { useCallback, useEffect, useRef, useState, type KeyboardEvent, type ReactNode } from 'react';
|
import { useCallback, useEffect, useRef, useState, type KeyboardEvent, type ReactNode } from 'react';
|
||||||
import type { CardApp, CardRelease, CardSnapshot, CardStore } from './model';
|
import type { CardApp, CardRelease, CardSnapshot, CardStore } from './model';
|
||||||
import { ago, cardT, type CardKey, type CardLang } from './text';
|
import { ago, cardT, type CardKey, type CardLang } from './text';
|
||||||
|
|
@ -18,7 +9,7 @@ export interface CardHost {
|
||||||
get: () => Promise<CardSnapshot | null>;
|
get: () => Promise<CardSnapshot | null>;
|
||||||
onSnapshot: (fn: (s: CardSnapshot) => void) => () => void;
|
onSnapshot: (fn: (s: CardSnapshot) => void) => () => void;
|
||||||
onShown: (fn: () => void) => () => void;
|
onShown: (fn: () => void) => () => void;
|
||||||
action: (action: 'hide' | 'open' | 'route' | 'refresh' | 'mute' | 'quit' | 'external' | 'ready' | 'size', arg?: string) => void;
|
action: (action: 'hide' | 'open' | 'route' | 'refresh' | 'mute' | 'quit' | 'external' | 'ready', arg?: string) => void;
|
||||||
}
|
}
|
||||||
|
|
||||||
const route = (app: string, tab: 'releases' | 'reviews' | 'health') => JSON.stringify({ screen: 'app', appId: app, tab });
|
const route = (app: string, tab: 'releases' | 'reviews' | 'health') => JSON.stringify({ screen: 'app', appId: app, tab });
|
||||||
|
|
@ -39,18 +30,6 @@ export function Card({ host, lang }: { host: CardHost; lang: CardLang }) {
|
||||||
const tm = setInterval(() => setNow(Date.now()), 30_000);
|
const tm = setInterval(() => setNow(Date.now()), 30_000);
|
||||||
return () => { a(); b(); clearInterval(tm); };
|
return () => { a(); b(); clearInterval(tm); };
|
||||||
}, [host]);
|
}, [host]);
|
||||||
// the window is as tall as the card: report the height whenever it changes (the host re-anchors it above the icon)
|
|
||||||
useEffect(() => {
|
|
||||||
const el = root.current;
|
|
||||||
if (!el || typeof ResizeObserver === 'undefined') return;
|
|
||||||
let last = 0;
|
|
||||||
const ro = new ResizeObserver(() => {
|
|
||||||
const h = Math.ceil(el.getBoundingClientRect().height);
|
|
||||||
if (h > 0 && h !== last) { last = h; host.action('size', String(h)); }
|
|
||||||
});
|
|
||||||
ro.observe(el);
|
|
||||||
return () => ro.disconnect();
|
|
||||||
}, [host]);
|
|
||||||
// every show: fade in, focus the first control (keyboard users start at Refresh)
|
// every show: fade in, focus the first control (keyboard users start at Refresh)
|
||||||
useEffect(() => { (root.current?.querySelector<HTMLElement>('button:not([disabled])') ?? root.current)?.focus(); }, [shown, !!s]);
|
useEffect(() => { (root.current?.querySelector<HTMLElement>('button:not([disabled])') ?? root.current)?.focus(); }, [shown, !!s]);
|
||||||
|
|
||||||
|
|
@ -75,18 +54,18 @@ export function Card({ host, lang }: { host: CardHost; lang: CardLang }) {
|
||||||
<header className="tc-head">
|
<header className="tc-head">
|
||||||
<div className="tc-title">
|
<div className="tc-title">
|
||||||
<strong>{T('title')}</strong>
|
<strong>{T('title')}</strong>
|
||||||
<span className="tc-meta">{s?.muted && <span className="tc-muted"><BellSlashIcon size={12} weight="bold" />{T('muted')}</span>}{T('lastRead', { ago: ago(lang, s?.at ?? null, now) })}</span>
|
<span className="tc-meta">{s?.muted && <span className="tc-muted"><BellSlash size={12} weight="bold" />{T('muted')}</span>}{T('lastRead', { ago: ago(lang, s?.at ?? null, now) })}</span>
|
||||||
</div>
|
</div>
|
||||||
<button className="tc-btn tc-primary" data-first onClick={() => host.action('refresh')} disabled={busy} aria-busy={busy} data-testid="card-refresh">
|
<button className="tc-btn tc-primary" data-first onClick={() => host.action('refresh')} disabled={busy} aria-busy={busy} data-testid="card-refresh">
|
||||||
<ArrowsClockwiseIcon size={14} weight="bold" className={busy ? 'spin' : undefined} />{busy ? T('refreshing') : T('refresh')}
|
<ArrowsClockwise size={14} weight="bold" className={busy ? 'spin' : undefined} />{busy ? T('refreshing') : T('refresh')}
|
||||||
</button>
|
</button>
|
||||||
<button className="tc-icon" onClick={() => setMenu(m => !m)} aria-haspopup="menu" aria-expanded={menu} aria-label={T('more')} title={T('more')}><DotsThreeIcon size={18} weight="bold" /></button>
|
<button className="tc-icon" onClick={() => setMenu(m => !m)} aria-haspopup="menu" aria-expanded={menu} aria-label={T('more')} title={T('more')}><DotsThree size={18} weight="bold" /></button>
|
||||||
{menu && (
|
{menu && (
|
||||||
<div className="tc-menu" role="menu">
|
<div className="tc-menu" role="menu">
|
||||||
<button role="menuitem" onClick={() => host.action('open')}><AppWindowIcon size={15} />{T('openMain')}</button>
|
<button role="menuitem" onClick={() => host.action('open')}><AppWindow size={15} />{T('openMain')}</button>
|
||||||
<button role="menuitem" onClick={() => { host.action('mute'); setMenu(false); }}>{s?.muted ? <BellIcon size={15} /> : <BellSlashIcon size={15} />}{s?.muted ? T('unmute') : T('mute')}</button>
|
<button role="menuitem" onClick={() => { host.action('mute'); setMenu(false); }}>{s?.muted ? <Bell size={15} /> : <BellSlash size={15} />}{s?.muted ? T('unmute') : T('mute')}</button>
|
||||||
<hr />
|
<hr />
|
||||||
<button role="menuitem" onClick={() => host.action('quit')}><PowerIcon size={15} />{T('quit')}</button>
|
<button role="menuitem" onClick={() => host.action('quit')}><Power size={15} />{T('quit')}</button>
|
||||||
</div>
|
</div>
|
||||||
)}
|
)}
|
||||||
</header>
|
</header>
|
||||||
|
|
@ -99,7 +78,7 @@ export function Card({ host, lang }: { host: CardHost; lang: CardLang }) {
|
||||||
<Section title={T('rejections')} tone="bad">
|
<Section title={T('rejections')} tone="bad">
|
||||||
{s.rejections.map(r => (
|
{s.rejections.map(r => (
|
||||||
<Row key={`${r.app}:${r.store}:${r.version}`} hue={r.hue} name={r.name} tone="bad" onOpen={() => host.action('route', route(r.app, 'releases'))} openLabel={T('openApp', { name: r.name })}
|
<Row key={`${r.app}:${r.store}:${r.version}`} hue={r.hue} name={r.name} tone="bad" onOpen={() => host.action('route', route(r.app, 'releases'))} openLabel={T('openApp', { name: r.name })}
|
||||||
line={<><WarningOctagonIcon size={13} weight="fill" />{T('rejected')} · {store(r.store)}{r.version ? ` ${r.version}` : ''}</>} sub={r.reason}
|
line={<><WarningOctagon size={13} weight="fill" />{T('rejected')} · {store(r.store)}{r.version ? ` ${r.version}` : ''}</>} sub={r.reason}
|
||||||
consoles={consoles(link(r.app), r.store, host, T)} />
|
consoles={consoles(link(r.app), r.store, host, T)} />
|
||||||
))}
|
))}
|
||||||
</Section>
|
</Section>
|
||||||
|
|
@ -121,7 +100,7 @@ export function Card({ host, lang }: { host: CardHost; lang: CardLang }) {
|
||||||
<Section title={T('health')} tone="warn">
|
<Section title={T('health')} tone="warn">
|
||||||
{s.health.map(h => (
|
{s.health.map(h => (
|
||||||
<Row key={h.app} hue={h.hue} name={h.name} tone="warn" onOpen={() => host.action('route', route(h.app, 'health'))} openLabel={T('openApp', { name: h.name })}
|
<Row key={h.app} hue={h.hue} name={h.name} tone="warn" onOpen={() => host.action('route', route(h.app, 'health'))} openLabel={T('openApp', { name: h.name })}
|
||||||
line={<><PulseIcon size={13} weight="bold" />{h.kinds.length > 1 ? T('crashAnr') : T(h.kinds[0]!)}</>} consoles={consoles(link(h.app), 'android', host, T)} />
|
line={<><Pulse size={13} weight="bold" />{h.kinds.length > 1 ? T('crashAnr') : T(h.kinds[0]!)}</>} consoles={consoles(link(h.app), 'android', host, T)} />
|
||||||
))}
|
))}
|
||||||
</Section>
|
</Section>
|
||||||
)}
|
)}
|
||||||
|
|
@ -130,7 +109,7 @@ export function Card({ host, lang }: { host: CardHost; lang: CardLang }) {
|
||||||
<Section title={T('reviews')} aside={s.reviews.recent ? T('recent', { n: s.reviews.recent }) : T('recentNone')}>
|
<Section title={T('reviews')} aside={s.reviews.recent ? T('recent', { n: s.reviews.recent }) : T('recentNone')}>
|
||||||
{s.reviews.low.map(r => (
|
{s.reviews.low.map(r => (
|
||||||
<button key={`${r.app}:${r.date}:${r.text}`} className="tc-review" onClick={() => host.action('route', route(r.app, 'reviews'))}>
|
<button key={`${r.app}:${r.date}:${r.text}`} className="tc-review" onClick={() => host.action('route', route(r.app, 'reviews'))}>
|
||||||
<span className="tc-stars" aria-label={T('stars', { n: r.rating })}>{[1, 2, 3, 4, 5].map(i => <StarIcon key={i} size={11} weight={i <= r.rating ? 'fill' : 'regular'} />)}</span>
|
<span className="tc-stars" aria-label={T('stars', { n: r.rating })}>{[1, 2, 3, 4, 5].map(i => <Star key={i} size={11} weight={i <= r.rating ? 'fill' : 'regular'} />)}</span>
|
||||||
<span className="tc-rname">{r.name}</span>
|
<span className="tc-rname">{r.name}</span>
|
||||||
<span className="tc-rtext">{r.text}</span>
|
<span className="tc-rtext">{r.text}</span>
|
||||||
</button>
|
</button>
|
||||||
|
|
@ -138,7 +117,6 @@ export function Card({ host, lang }: { host: CardHost; lang: CardLang }) {
|
||||||
</Section>
|
</Section>
|
||||||
)}
|
)}
|
||||||
</div>
|
</div>
|
||||||
{s?.build && <footer className="tc-foot" data-testid="card-build">{T('build', { version: s.build.version, channel: T(s.build.channel === 'dev' ? 'chDev' : s.build.channel === 'beta' ? 'chBeta' : 'chStable') })}</footer>}
|
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
@ -146,7 +124,7 @@ export function Card({ host, lang }: { host: CardHost; lang: CardLang }) {
|
||||||
function consoles(l: CardApp | undefined, st: CardStore, host: CardHost, T: (k: CardKey) => string): ReactNode {
|
function consoles(l: CardApp | undefined, st: CardStore, host: CardHost, T: (k: CardKey) => string): ReactNode {
|
||||||
const url = st === 'ios' ? l?.asc : l?.play;
|
const url = st === 'ios' ? l?.asc : l?.play;
|
||||||
if (!url) return null;
|
if (!url) return null;
|
||||||
return <button className="tc-ext" onClick={e => { e.stopPropagation(); host.action('external', url); }} title={T(st === 'ios' ? 'asc' : 'play')} aria-label={T(st === 'ios' ? 'asc' : 'play')}><ArrowSquareOutIcon size={14} /></button>;
|
return <button className="tc-ext" onClick={e => { e.stopPropagation(); host.action('external', url); }} title={T(st === 'ios' ? 'asc' : 'play')} aria-label={T(st === 'ios' ? 'asc' : 'play')}><ArrowSquareOut size={14} /></button>;
|
||||||
}
|
}
|
||||||
|
|
||||||
function Section({ title, tone, aside, children }: { title: string; tone?: 'bad' | 'warn'; aside?: string; children: ReactNode }) {
|
function Section({ title, tone, aside, children }: { title: string; tone?: 'bad' | 'warn'; aside?: string; children: ReactNode }) {
|
||||||
|
|
|
||||||
|
|
@ -51,7 +51,7 @@ export function TrayCardBridge() {
|
||||||
asc: ios ? ascUrl(ios.ascAppId) : null, play: st?.app?.platforms.android || a.android ? playUrlFor(d, a) : null,
|
asc: ios ? ascUrl(ios.ascAppId) : null, play: st?.app?.platforms.android || a.android ? playUrlFor(d, a) : null,
|
||||||
};
|
};
|
||||||
});
|
});
|
||||||
return cardSnapshot(inputs, { at: d.live?.value.at ?? d.portfolio?.at ?? null, busy: all.busy, muted: d.muteUntil > Date.now(), build: d.info ? { version: d.info.version, channel: d.settings.channel } : null });
|
return cardSnapshot(inputs, { at: d.live?.value.at ?? d.portfolio?.at ?? null, busy: all.busy, muted: d.muteUntil > Date.now() });
|
||||||
}, [visible, d, extra, all.busy]);
|
}, [visible, d, extra, all.busy]);
|
||||||
|
|
||||||
const last = useRef('');
|
const last = useRef('');
|
||||||
|
|
|
||||||
|
|
@ -4,7 +4,7 @@ import { invoke } from '@tauri-apps/api/core';
|
||||||
import { listen } from '@tauri-apps/api/event';
|
import { listen } from '@tauri-apps/api/event';
|
||||||
import type { CardSnapshot } from './model';
|
import type { CardSnapshot } from './model';
|
||||||
|
|
||||||
export type CardAction = 'hide' | 'open' | 'route' | 'refresh' | 'mute' | 'quit' | 'external' | 'ready' | 'size';
|
export type CardAction = 'hide' | 'open' | 'route' | 'refresh' | 'mute' | 'quit' | 'external' | 'ready';
|
||||||
|
|
||||||
export const inTauri = (): boolean => typeof window !== 'undefined' && '__TAURI_INTERNALS__' in window;
|
export const inTauri = (): boolean => typeof window !== 'undefined' && '__TAURI_INTERNALS__' in window;
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,12 +1,12 @@
|
||||||
/* The tray card (card.html): v2 language, 360 wide and as tall as its content (at most 480: the body scrolls), rounded, its own surface; fades in over 120 ms on every show. */
|
/* The tray card (card.html): v2 language at 360 x 480, rounded, its own surface; fades in over 120 ms on every show. */
|
||||||
html:has(body.tc-page), body.tc-page { margin: 0; height: 100%; background: transparent; overflow: hidden; }
|
html:has(body.tc-page), body.tc-page { margin: 0; height: 100%; background: transparent; overflow: hidden; }
|
||||||
body.tc-page { font: var(--ds-t-body)/1.4 system-ui, -apple-system, "Segoe UI", sans-serif; color: var(--ink); }
|
body.tc-page { font: var(--ds-t-body)/1.4 system-ui, -apple-system, "Segoe UI", sans-serif; color: var(--ink); }
|
||||||
body.tc-page #card { height: auto; }
|
body.tc-page #card { height: 100%; }
|
||||||
body.tc-page.tc-in .tc { animation: tc-in 120ms ease-out; }
|
body.tc-page.tc-in .tc { animation: tc-in 120ms ease-out; }
|
||||||
:root[data-motion="reduce"] body.tc-page.tc-in .tc { animation: none; }
|
:root[data-motion="reduce"] body.tc-page.tc-in .tc { animation: none; }
|
||||||
@keyframes tc-in { from { opacity: 0; transform: translateY(4px); } to { opacity: 1; transform: none; } }
|
@keyframes tc-in { from { opacity: 0; transform: translateY(4px); } to { opacity: 1; transform: none; } }
|
||||||
|
|
||||||
.tc { box-sizing: border-box; height: auto; max-height: 480px; display: flex; flex-direction: column; border-radius: var(--ds-r-lg);
|
.tc { box-sizing: border-box; height: 100%; max-height: 480px; display: flex; flex-direction: column; border-radius: var(--ds-r-lg);
|
||||||
border: 1px solid var(--ds-stroke); background: radial-gradient(120% 60% at 100% 0%, color-mix(in srgb, var(--accent-solid) 10%, transparent), transparent 60%), var(--ds-raised); overflow: hidden; outline: none; }
|
border: 1px solid var(--ds-stroke); background: radial-gradient(120% 60% at 100% 0%, color-mix(in srgb, var(--accent-solid) 10%, transparent), transparent 60%), var(--ds-raised); overflow: hidden; outline: none; }
|
||||||
.tc-head { position: relative; display: flex; align-items: center; gap: 8px; padding: 14px 12px 12px 16px; border-bottom: 1px solid var(--ds-stroke); }
|
.tc-head { position: relative; display: flex; align-items: center; gap: 8px; padding: 14px 12px 12px 16px; border-bottom: 1px solid var(--ds-stroke); }
|
||||||
.tc-title { flex: 1; min-width: 0; display: flex; flex-direction: column; }
|
.tc-title { flex: 1; min-width: 0; display: flex; flex-direction: column; }
|
||||||
|
|
@ -25,7 +25,7 @@ body.tc-page.tc-in .tc { animation: tc-in 120ms ease-out; }
|
||||||
.tc-menu button:hover, .tc-menu button:focus-visible { background: var(--hover); outline: none; }
|
.tc-menu button:hover, .tc-menu button:focus-visible { background: var(--hover); outline: none; }
|
||||||
.tc-menu hr { border: 0; border-top: 1px solid var(--ds-stroke); margin: 4px 2px; }
|
.tc-menu hr { border: 0; border-top: 1px solid var(--ds-stroke); margin: 4px 2px; }
|
||||||
|
|
||||||
.tc-body { flex: 1 1 auto; min-height: 0; overflow-y: auto; padding: 6px 10px 12px; scrollbar-width: thin; }
|
.tc-body { flex: 1; overflow-y: auto; padding: 6px 10px 12px; scrollbar-width: thin; }
|
||||||
.tc-empty { margin: 28px 16px; text-align: center; color: var(--muted); }
|
.tc-empty { margin: 28px 16px; text-align: center; color: var(--muted); }
|
||||||
.tc-sec { margin-top: 8px; }
|
.tc-sec { margin-top: 8px; }
|
||||||
.tc-sec h2 { display: flex; align-items: baseline; justify-content: space-between; gap: 8px; margin: 6px 6px 4px; font-size: var(--ds-t-micro); font-weight: var(--ds-w-strong); text-transform: uppercase; letter-spacing: .07em; color: var(--muted); }
|
.tc-sec h2 { display: flex; align-items: baseline; justify-content: space-between; gap: 8px; margin: 6px 6px 4px; font-size: var(--ds-t-micro); font-weight: var(--ds-w-strong); text-transform: uppercase; letter-spacing: .07em; color: var(--muted); }
|
||||||
|
|
@ -56,4 +56,3 @@ body.tc-page.tc-in .tc { animation: tc-in 120ms ease-out; }
|
||||||
.tc-stars { display: inline-flex; gap: 1px; align-items: center; color: var(--warn-solid); }
|
.tc-stars { display: inline-flex; gap: 1px; align-items: center; color: var(--warn-solid); }
|
||||||
.tc-rname { font-weight: var(--ds-w-strong); font-size: var(--ds-t-meta); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
|
.tc-rname { font-weight: var(--ds-w-strong); font-size: var(--ds-t-meta); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
|
||||||
.tc-rtext { grid-column: 1 / -1; font-size: var(--ds-t-meta); color: var(--ink-2); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
|
.tc-rtext { grid-column: 1 / -1; font-size: var(--ds-t-meta); color: var(--ink-2); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
|
||||||
.tc-foot { padding: 6px 12px 8px; color: var(--muted); font-size: var(--ds-t-micro); border-top: 1px solid var(--ds-stroke); font-variant-numeric: tabular-nums; }
|
|
||||||
|
|
|
||||||
|
|
@ -23,8 +23,6 @@ export interface CardSnapshot {
|
||||||
health: CardHealth[];
|
health: CardHealth[];
|
||||||
/** Apps with something on the card, for the quick actions (console links). */
|
/** Apps with something on the card, for the quick actions (console links). */
|
||||||
links: CardApp[];
|
links: CardApp[];
|
||||||
/** This app's version and update channel (Settings > Updates), shown at the card's foot. */
|
|
||||||
build?: { version: string; channel: string } | null;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface CardInput {
|
export interface CardInput {
|
||||||
|
|
@ -50,7 +48,7 @@ export function healthAlerts(h: HealthSnapshot | null | undefined): ('crash' | '
|
||||||
return out;
|
return out;
|
||||||
}
|
}
|
||||||
|
|
||||||
export function cardSnapshot(apps: CardInput[], o: { at: string | null; busy: boolean; muted: boolean; now?: number; build?: { version: string; channel: string } | null }): CardSnapshot {
|
export function cardSnapshot(apps: CardInput[], o: { at: string | null; busy: boolean; muted: boolean; now?: number }): CardSnapshot {
|
||||||
const now = o.now ?? Date.now();
|
const now = o.now ?? Date.now();
|
||||||
const rejections: CardRejection[] = [], releases: CardRelease[] = [], low: CardLowReview[] = [], health: CardHealth[] = [];
|
const rejections: CardRejection[] = [], releases: CardRelease[] = [], low: CardLowReview[] = [], health: CardHealth[] = [];
|
||||||
const touched = new Set<string>();
|
const touched = new Set<string>();
|
||||||
|
|
@ -84,6 +82,5 @@ export function cardSnapshot(apps: CardInput[], o: { at: string | null; busy: bo
|
||||||
rejections: rejections.slice(0, MAX_ROWS), releases: releases.slice(0, MAX_ROWS),
|
rejections: rejections.slice(0, MAX_ROWS), releases: releases.slice(0, MAX_ROWS),
|
||||||
reviews: { recent, low: low.slice(0, MAX_LOW) }, health: health.slice(0, MAX_ROWS),
|
reviews: { recent, low: low.slice(0, MAX_LOW) }, health: health.slice(0, MAX_ROWS),
|
||||||
links: apps.filter(a => touched.has(a.key)).map(a => ({ key: a.key, name: a.name, hue: a.hue, asc: a.asc ?? null, play: a.play ?? null })),
|
links: apps.filter(a => touched.has(a.key)).map(a => ({ key: a.key, name: a.name, hue: a.hue, asc: a.asc ?? null, play: a.play ?? null })),
|
||||||
build: o.build ?? null,
|
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -28,10 +28,6 @@ export const en = {
|
||||||
refresh: 'Refresh',
|
refresh: 'Refresh',
|
||||||
refreshing: 'Reading…',
|
refreshing: 'Reading…',
|
||||||
openMain: 'Open storebound',
|
openMain: 'Open storebound',
|
||||||
build: 'storebound {version} · {channel} channel',
|
|
||||||
chStable: 'stable',
|
|
||||||
chDev: 'dev',
|
|
||||||
chBeta: 'beta',
|
|
||||||
more: 'More',
|
more: 'More',
|
||||||
mute: 'Mute notifications for 1 hour',
|
mute: 'Mute notifications for 1 hour',
|
||||||
unmute: 'Unmute notifications',
|
unmute: 'Unmute notifications',
|
||||||
|
|
@ -74,10 +70,6 @@ export const tr: Record<CardKey, string> = {
|
||||||
refresh: 'Yenile',
|
refresh: 'Yenile',
|
||||||
refreshing: 'Okunuyor…',
|
refreshing: 'Okunuyor…',
|
||||||
openMain: 'storebound\'u aç',
|
openMain: 'storebound\'u aç',
|
||||||
build: 'storebound {version} · {channel} kanalı',
|
|
||||||
chStable: 'kararlı',
|
|
||||||
chDev: 'geliştirme',
|
|
||||||
chBeta: 'beta',
|
|
||||||
more: 'Diğer',
|
more: 'Diğer',
|
||||||
mute: 'Bildirimleri 1 saat sustur',
|
mute: 'Bildirimleri 1 saat sustur',
|
||||||
unmute: 'Bildirimleri aç',
|
unmute: 'Bildirimleri aç',
|
||||||
|
|
|
||||||
|
|
@ -229,19 +229,6 @@
|
||||||
.ds-menu-k { max-width: 150px; overflow: hidden; text-overflow: ellipsis; margin-left: 18px; color: var(--faint); font-size: var(--ds-t-micro); letter-spacing: .02em; font-variant-numeric: tabular-nums; }
|
.ds-menu-k { max-width: 150px; overflow: hidden; text-overflow: ellipsis; margin-left: 18px; color: var(--faint); font-size: var(--ds-t-micro); letter-spacing: .02em; font-variant-numeric: tabular-nums; }
|
||||||
.ds-menu-sub { width: 12px; height: 12px; color: var(--faint); margin-left: 10px; }
|
.ds-menu-sub { width: 12px; height: 12px; color: var(--faint); margin-left: 10px; }
|
||||||
.ds-menu-sep { height: 1px; margin: 5px 6px; background: var(--ds-stroke); }
|
.ds-menu-sep { height: 1px; margin: 5px 6px; background: var(--ds-stroke); }
|
||||||
/* menu header: the pin button (a normal menu or submenu), a pinned panel's title, unpin, close and drag handle */
|
|
||||||
.ds-menu-head { display: flex; align-items: center; gap: 2px; height: 24px; padding: 0 0 0 9px; margin-bottom: 1px; }
|
|
||||||
.ds-menu-head.pinned { cursor: grab; touch-action: none; }
|
|
||||||
.ds-menu-head.pinned:active { cursor: grabbing; }
|
|
||||||
.ds-menu-title { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: var(--ds-t-micro);
|
|
||||||
font-weight: 600; letter-spacing: .04em; text-transform: uppercase; color: var(--faint); }
|
|
||||||
.ds-menu-btn { flex: none; width: 22px; height: 22px; display: grid; place-items: center; padding: 0; border: 0; border-radius: 6px;
|
|
||||||
background: transparent; color: var(--faint); cursor: pointer; }
|
|
||||||
.ds-menu-btn svg { width: 13px; height: 13px; }
|
|
||||||
.ds-menu-btn:hover, .ds-menu-btn:focus-visible { background: var(--ds-inset); color: var(--ink); outline: none; }
|
|
||||||
.ds-menu-btn.on { color: var(--accent); }
|
|
||||||
.ds-menu.pinned { border-color: color-mix(in srgb, var(--accent) 45%, var(--ds-stroke-strong)); transition: opacity 120ms var(--ease); }
|
|
||||||
.ds-menu-gone { max-width: 240px; padding: 6px 10px 8px; color: var(--muted); font-size: var(--ds-t-micro); white-space: normal; }
|
|
||||||
@media (prefers-reduced-motion: reduce) { .ds-menu { transition: none; transform: none; } }
|
@media (prefers-reduced-motion: reduce) { .ds-menu { transition: none; transform: none; } }
|
||||||
:root[data-motion="reduce"] .ds-menu { transition: none; transform: none; }
|
:root[data-motion="reduce"] .ds-menu { transition: none; transform: none; }
|
||||||
/* headings focused by code (dialog / wizard step titles) for screen readers: no ring */
|
/* headings focused by code (dialog / wizard step titles) for screen readers: no ring */
|
||||||
|
|
@ -258,45 +245,3 @@
|
||||||
.table-wrap .table tbody tr:hover > :first-child, .ds-table-wrap .table tbody tr:hover > :first-child { background: color-mix(in srgb, var(--tint, var(--accent-solid)) 6%, var(--ds-surface, var(--surface))); }
|
.table-wrap .table tbody tr:hover > :first-child, .ds-table-wrap .table tbody tr:hover > :first-child { background: color-mix(in srgb, var(--tint, var(--accent-solid)) 6%, var(--ds-surface, var(--surface))); }
|
||||||
/* Settings > Appearance > Tables: compact */
|
/* Settings > Appearance > Tables: compact */
|
||||||
:root[data-density="compact"] .table th, :root[data-density="compact"] .table td { padding-top: 5px; padding-bottom: 5px; padding-left: 8px; padding-right: 8px; font-size: 12.5px; }
|
:root[data-density="compact"] .table th, :root[data-density="compact"] .table td { padding-top: 5px; padding-bottom: 5px; padding-left: 8px; padding-right: 8px; font-size: 12.5px; }
|
||||||
|
|
||||||
/* ---------- App sections (docs IA): section header, next step, sub views ---------- */
|
|
||||||
.ds-tab-k { font: 600 10px/1 var(--mono, ui-monospace, monospace); min-width: 16px; height: 16px; display: inline-grid; place-items: center; border-radius: 4px; color: var(--muted); border: 1px solid var(--ds-stroke); background: var(--ds-surface); margin-left: 2px; opacity: .75; }
|
|
||||||
.ds-tab[aria-selected="true"] .ds-tab-k { opacity: 1; }
|
|
||||||
.sec-head { display: grid; grid-template-columns: minmax(0, 1fr) auto; grid-template-areas: "t next" "subs subs"; gap: 10px 16px; align-items: center; padding: 2px 4px 4px; }
|
|
||||||
.sec-head-t { grid-area: t; min-width: 0; }
|
|
||||||
.sec-head-name { display: flex; align-items: center; gap: 8px; margin: 0; font-size: var(--ds-t-h2, 18px); font-weight: 700; letter-spacing: -.01em; }
|
|
||||||
.sec-head-name svg { width: 18px; height: 18px; color: var(--tint, var(--accent-solid)); }
|
|
||||||
.sec-head-for { margin: 2px 0 0; color: var(--muted); font-size: var(--t-meta); }
|
|
||||||
.sec-next { grid-area: next; display: inline-flex; align-items: center; gap: 8px; padding: 6px 6px 6px 12px; min-height: 32px; box-sizing: border-box; border-radius: var(--ds-r); border: 1px solid var(--ds-stroke); background: var(--ds-surface); font-weight: 600; font-size: var(--t-meta); max-width: 560px; }
|
|
||||||
.sec-next > svg { width: 15px; height: 15px; flex: none; }
|
|
||||||
.sec-next-t { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
|
|
||||||
.sec-next:not(:has(.btn)) { padding-right: 12px; }
|
|
||||||
.sec-next.tone-bad { background: var(--bad-bg); color: var(--bad-ink); border-color: transparent; }
|
|
||||||
.sec-next.tone-warn { background: var(--warn-bg); color: var(--warn-ink); border-color: transparent; }
|
|
||||||
.sec-next.tone-ok > svg { color: var(--ok-solid); }
|
|
||||||
.sec-next.tone-info > svg { color: var(--accent-solid); }
|
|
||||||
.sec-next .btn { flex: none; }
|
|
||||||
.sec-subs { grid-area: subs; justify-self: start; }
|
|
||||||
.sec-subs .ed-dot { margin-left: 2px; }
|
|
||||||
@media (max-width: 1100px) { .sec-head { grid-template-columns: 1fr; grid-template-areas: "t" "next" "subs"; } .sec-next { justify-self: start; } }
|
|
||||||
|
|
||||||
/* ---------- Sidebar: attention groups, one status line per app, workspace footer ---------- */
|
|
||||||
.nav-app.has-line { height: auto; min-height: 40px; padding-top: 4px; padding-bottom: 4px; align-items: center; }
|
|
||||||
.nav-app .side-t { display: grid; min-width: 0; line-height: 1.2; }
|
|
||||||
.nav-app .side-n { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
|
|
||||||
.nav-app .side-s { font-size: 11px; font-weight: 500; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
|
|
||||||
.nav-app .side-s.bad { color: var(--bad-ink); } .nav-app .side-s.warn { color: var(--warn-ink); } .nav-app .side-s.ok { color: var(--ok-ink); }
|
|
||||||
:root[data-theme="dark"] .nav-app .side-s.bad { color: color-mix(in srgb, var(--bad-solid) 70%, white); }
|
|
||||||
:root[data-theme="dark"] .nav-app .side-s.warn { color: color-mix(in srgb, var(--warn-solid) 70%, white); }
|
|
||||||
:root[data-theme="dark"] .nav-app .side-s.ok { color: color-mix(in srgb, var(--ok-solid) 70%, white); }
|
|
||||||
.side-studios { display: flex; flex-wrap: wrap; gap: 4px; margin: 6px 6px 2px; }
|
|
||||||
.side-studios button { all: unset; cursor: pointer; display: inline-flex; align-items: center; gap: 5px; height: 22px; padding: 0 8px; border-radius: 99px; font-size: 11px; font-weight: 600; color: var(--muted); border: 1px solid var(--line); }
|
|
||||||
.side-studios button[aria-pressed="true"] { color: var(--ink); background: var(--surface); box-shadow: var(--shadow-1); }
|
|
||||||
.side-studios button:focus-visible { outline: 2px solid var(--focus); }
|
|
||||||
.side-ws { display: flex; gap: 2px; padding: 6px 8px; border-top: 1px solid var(--line); }
|
|
||||||
.side-ws button { all: unset; cursor: pointer; position: relative; flex: 1; height: 30px; display: grid; place-items: center; border-radius: 7px; color: var(--muted); }
|
|
||||||
.side-ws button:hover { background: var(--hover); color: var(--ink); }
|
|
||||||
.side-ws button[aria-current="page"] { background: var(--surface); color: var(--ink); box-shadow: var(--shadow-1); }
|
|
||||||
.side-ws button:focus-visible { outline: 2px solid var(--focus); }
|
|
||||||
.side-ws svg { width: 17px; height: 17px; }
|
|
||||||
.side-ws .ws-n { position: absolute; top: 2px; right: 4px; font-size: 9.5px; font-weight: 700; color: var(--muted); font-variant-numeric: tabular-nums; }
|
|
||||||
|
|
|
||||||
|
|
@ -430,16 +430,6 @@ const GAMES_PRISM = {
|
||||||
play: { appId: '123456789012', resource: '123456789012 (android/app/src/main/res/values/games-ids.xml)', leaderboards: 2, achievements: 5, config: { leaderboards: 2, achievements: 5 }, changes: [] },
|
play: { appId: '123456789012', resource: '123456789012 (android/app/src/main/res/values/games-ids.xml)', leaderboards: 2, achievements: 5, config: { leaderboards: 2, achievements: 5 }, changes: [] },
|
||||||
findings: [{ store: 'apple', level: 'ok', id: 'gc.entitlement', msg: 'com.apple.developer.game-center in ios/App/App/App.entitlements' }, { store: 'play', level: 'ok', id: 'pgs.app-id', msg: 'games_APP_ID 123456789012 matches the config' }],
|
findings: [{ store: 'apple', level: 'ok', id: 'gc.entitlement', msg: 'com.apple.developer.game-center in ios/App/App/App.entitlements' }, { store: 'play', level: 'ok', id: 'pgs.app-id', msg: 'games_APP_ID 123456789012 matches the config' }],
|
||||||
links: [{ label: 'Play Console: Play Games Services configuration', url: 'https://play.google.com/console/u/0/developers/4444/app/9876/play-games-services/setup' }],
|
links: [{ label: 'Play Console: Play Games Services configuration', url: 'https://play.google.com/console/u/0/developers/4444/app/9876/play-games-services/setup' }],
|
||||||
items: [
|
|
||||||
{ kind: 'leaderboard', id: 'com.example.prismpuddle.best', name: 'Best score', locales: ['en', 'tr', 'ja', 'ar'], ios: true, android: true,
|
|
||||||
apple: { action: 'keep', changed: [], locales: [{ locale: 'en-US', action: 'keep' }, { locale: 'tr', action: 'keep' }, { locale: 'ja', action: 'keep' }, { locale: 'ar-SA', action: 'keep' }] }, play: { action: 'keep', changed: [] } },
|
|
||||||
{ kind: 'leaderboard', id: 'com.example.prismpuddle.daily', name: 'Daily puddle', locales: ['en', 'tr'], ios: true, android: true,
|
|
||||||
apple: { action: 'create', changed: ['referenceName'], locales: [{ locale: 'en-US', action: 'create' }, { locale: 'tr', action: 'create' }] }, play: { action: 'keep', changed: [] } },
|
|
||||||
...['first-drop', 'ten-levels', 'no-hints', 'rainbow', 'speedrun'].map((k, i) => ({ kind: 'achievement', id: `com.example.prismpuddle.${k}`, name: ['First drop', 'Ten levels', 'No hints', 'Rainbow', 'Speedrun'][i]!, locales: ['en', 'tr', 'ja', 'ar'], points: [10, 20, 30, 20, 20][i], hidden: k === 'speedrun', ios: true, android: true,
|
|
||||||
apple: { action: 'keep', changed: [], locales: [{ locale: 'en-US', action: 'keep' }] }, play: { action: i === 2 ? 'update' : 'keep', changed: i === 2 ? ['draft.description'] : [] } })),
|
|
||||||
],
|
|
||||||
localeMap: { configured: { ar: 'ar-SA' }, suggested: [{ id: 'en', from: 'en-US', to: 'en-GB' }] },
|
|
||||||
playApiDisabled: null,
|
|
||||||
};
|
};
|
||||||
const ok = (method: string, data: unknown): ToolResult => ({ method, ok: true, exitCode: 0, dryRun: false, command: `storebound ${method.replace('.', ' ')} --json`, output: '', data });
|
const ok = (method: string, data: unknown): ToolResult => ({ method, ok: true, exitCode: 0, dryRun: false, command: `storebound ${method.replace('.', ' ')} --json`, output: '', data });
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -153,10 +153,7 @@ export const en = {
|
||||||
'phase.releasedUnknown': "Couldn't check the store page",
|
'phase.releasedUnknown': "Couldn't check the store page",
|
||||||
'phase.pageUnknown': "Couldn't check the store page",
|
'phase.pageUnknown': "Couldn't check the store page",
|
||||||
'phase.pageStale': "couldn't check the store page, as of {when}",
|
'phase.pageStale': "couldn't check the store page, as of {when}",
|
||||||
'phase.reviewLive': 'Not live yet (live: {version}): in review or blocked before review',
|
'phase.reviewLive': 'In review (live: {version})',
|
||||||
'phase.playPending': 'Not live yet: in review or blocked before review',
|
|
||||||
'roll.publishReady': 'If the release is approved, publish it in Publishing overview ("Publish N changes"). The agent prepares it with `{cmd}`; the final press is for the owner.',
|
|
||||||
'roll.publishOpen': 'Open Publishing overview',
|
|
||||||
'phase.reviewManaged': 'In review / ready to publish (managed publishing)',
|
'phase.reviewManaged': 'In review / ready to publish (managed publishing)',
|
||||||
'phase.rejected': 'Rejected',
|
'phase.rejected': 'Rejected',
|
||||||
'phase.testing': 'Testing',
|
'phase.testing': 'Testing',
|
||||||
|
|
@ -977,9 +974,7 @@ export const en = {
|
||||||
'set.channel': 'Channel',
|
'set.channel': 'Channel',
|
||||||
'set.stable': 'Stable',
|
'set.stable': 'Stable',
|
||||||
'set.beta': 'Beta',
|
'set.beta': 'Beta',
|
||||||
'set.dev': 'Dev (every change)',
|
'set.updatesText': 'Updates come from storebound.dev and are signed; the app checks the signature before it replaces anything, and installs only when you press Install. Nothing is checked in the background.',
|
||||||
'set.devToStable': 'This is the dev build {version}: it stays until a stable release is newer (no downgrade).',
|
|
||||||
'set.updatesText': 'Updates come from storebound.dev and are signed; the app checks the signature before it replaces anything. It looks for a newer version of the chosen channel at start, every 15 minutes and after sleep, and installs it in the background (not while you work in this window). Stable follows the npm releases; Dev gets every change on main.',
|
|
||||||
'set.updateCheck': 'Check for updates',
|
'set.updateCheck': 'Check for updates',
|
||||||
'set.updateChecking': 'Checking…',
|
'set.updateChecking': 'Checking…',
|
||||||
'set.updateNone': 'storebound {version} is the newest version on the {channel} channel.',
|
'set.updateNone': 'storebound {version} is the newest version on the {channel} channel.',
|
||||||
|
|
@ -2060,12 +2055,6 @@ export const en = {
|
||||||
|
|
||||||
// context menus (ui/ContextMenu.tsx)
|
// context menus (ui/ContextMenu.tsx)
|
||||||
'cm.cut': "Cut",
|
'cm.cut': "Cut",
|
||||||
'cm.pin': "Pin: keeps this menu open",
|
|
||||||
'cm.unpin': "Unpin",
|
|
||||||
'cm.closePanel': "Close",
|
|
||||||
'cm.gone': "Gone: what this menu was for is not on screen now.",
|
|
||||||
'cm.menu': "Menu",
|
|
||||||
'cm.tearOff': "Ctrl+click or middle-click: pin this submenu",
|
|
||||||
'cm.copy': "Copy",
|
'cm.copy': "Copy",
|
||||||
'cm.paste': "Paste",
|
'cm.paste': "Paste",
|
||||||
'cm.selectAll': "Select all",
|
'cm.selectAll': "Select all",
|
||||||
|
|
@ -2086,13 +2075,6 @@ export const en = {
|
||||||
'cm.ignoredNoReads': "Ignored apps are not read",
|
'cm.ignoredNoReads': "Ignored apps are not read",
|
||||||
'cm.ignore': "Ignore",
|
'cm.ignore': "Ignore",
|
||||||
'acct.devId': 'Play developer id {id}',
|
'acct.devId': 'Play developer id {id}',
|
||||||
'acct.viaBroker': 'tokens from the credential broker',
|
|
||||||
'acct.viaFile': 'local key file',
|
|
||||||
'acct.grantsTitle': 'Play permissions on the credential broker',
|
|
||||||
'acct.grantsOk': 'everything storebound needs',
|
|
||||||
'acct.grantsMissing': 'missing: {list}',
|
|
||||||
'acct.grantsNone': 'no permission data',
|
|
||||||
'acct.notRegistered': 'not registered on the broker',
|
|
||||||
'acct.noDevId': 'no Play developer id',
|
'acct.noDevId': 'no Play developer id',
|
||||||
'acct.devIdLabel': 'Play developer account id',
|
'acct.devIdLabel': 'Play developer account id',
|
||||||
'acct.devIdHint': "The digits after /developers/ in the Play Console address. With it, Play Console links open each app's own page; the CLI uses it too.",
|
'acct.devIdHint': "The digits after /developers/ in the Play Console address. With it, Play Console links open each app's own page; the CLI uses it too.",
|
||||||
|
|
@ -2130,106 +2112,4 @@ export const en = {
|
||||||
'cm.copyPrincipal': "Service account / key",
|
'cm.copyPrincipal': "Service account / key",
|
||||||
'cm.copyProfile': "Profile name",
|
'cm.copyProfile': "Profile name",
|
||||||
'cm.openAccounts': "Open Studios & accounts",
|
'cm.openAccounts': "Open Studios & accounts",
|
||||||
"sec.release": "Release",
|
|
||||||
"sec.store": "Store page",
|
|
||||||
"sec.revenue": "Revenue",
|
|
||||||
"sec.players": "Players",
|
|
||||||
"sec.health": "Health",
|
|
||||||
"sec.release.for": "Get a version to players on both stores: builds, TestFlight, review and rollout.",
|
|
||||||
"sec.store.for": "What people see on the store: texts per language, screenshots and app details.",
|
|
||||||
"sec.revenue.for": "What the app sells and for how much: in-app products, subscriptions and prices.",
|
|
||||||
"sec.players.for": "What players say, and for games what they can earn: reviews, Game Center, Play Games.",
|
|
||||||
"sec.health.for": "Is the app well and ready: crashes and ANRs, growth, checks to fix first, more tools.",
|
|
||||||
"sec.views": "{section} views",
|
|
||||||
"tab.games": "Game services",
|
|
||||||
"next.open": "Open {where}",
|
|
||||||
"next.rejected": "{version} was rejected on {store}",
|
|
||||||
"next.halted": "{version} is halted on {store}",
|
|
||||||
"next.blockers": "{count} blockers before submit",
|
|
||||||
"next.blockers_one": "1 blocker before submit",
|
|
||||||
"next.rollout": "{version} is rolling out at {share}",
|
|
||||||
"next.approved": "{version} is approved: release it",
|
|
||||||
"next.submit": "Submit {version} for review",
|
|
||||||
"next.review": "{version} is in review",
|
|
||||||
"next.managed": "{version} waits in Publishing overview (managed publishing)",
|
|
||||||
"next.upload": "Upload a first build",
|
|
||||||
"next.live": "Live: {version}",
|
|
||||||
"next.notRead": "Release state shows once the stores are read",
|
|
||||||
"next.storeLive": "The live store page, read from the stores",
|
|
||||||
"next.listingProblems": "{count} listing problems",
|
|
||||||
"next.listingProblems_one": "1 listing problem",
|
|
||||||
"next.unsaved": "{count} unsaved edits",
|
|
||||||
"next.unsaved_one": "1 unsaved edit",
|
|
||||||
"next.listingsUnread": "Listings not checked yet",
|
|
||||||
"next.storeOk": "Store page in step with the config",
|
|
||||||
"next.catalogDiff": "{count} products differ between the stores",
|
|
||||||
"next.catalogDiff_one": "1 product differs between the stores",
|
|
||||||
"next.noProducts": "No products yet: add one",
|
|
||||||
"next.products": "{products} products · {subs} subscriptions",
|
|
||||||
"next.reviews": "{count} reviews without a reply",
|
|
||||||
"next.reviews_one": "1 review without a reply",
|
|
||||||
"next.reviewsUnread": "See what players say",
|
|
||||||
"next.reviewsOk": "All reviews answered",
|
|
||||||
"next.gamesApiOff": "Play Games Services API is off",
|
|
||||||
"next.gamesBlockers": "{count} game services blockers",
|
|
||||||
"next.gamesBlockers_one": "1 game services blocker",
|
|
||||||
"next.gamesSync": "Game services: {count} changes to sync",
|
|
||||||
"next.gamesSync_one": "Game services: 1 change to sync",
|
|
||||||
"next.fixFirst": "{count} problems to fix first",
|
|
||||||
"next.fixFirst_one": "1 problem to fix first",
|
|
||||||
"next.warnings": "{count} warnings to look at",
|
|
||||||
"next.warnings_one": "1 warning to look at",
|
|
||||||
"next.healthOk": "No problems found",
|
|
||||||
"side.gAttention": "Needs attention",
|
|
||||||
"side.gProgress": "In progress",
|
|
||||||
"side.gLive": "Live",
|
|
||||||
"side.gDraft": "Not on a store yet",
|
|
||||||
"side.missing": "Folder missing",
|
|
||||||
"side.rejected": "Rejected · {what}",
|
|
||||||
"side.halted": "Halted · {what}",
|
|
||||||
"side.blockers": "{count} blockers",
|
|
||||||
"side.blockers_one": "1 blocker",
|
|
||||||
"side.rollout": "Rollout {share} · {what}",
|
|
||||||
"side.review": "In review · {what}",
|
|
||||||
"side.approved": "Approved · {what}",
|
|
||||||
"side.draft": "Draft · {what}",
|
|
||||||
"side.live": "Live · {version}",
|
|
||||||
"side.liveWarn": "Live · {version} · {count} warnings",
|
|
||||||
"side.liveWarn_one": "Live · {version} · 1 warning",
|
|
||||||
"side.storeOnly": "Store only · not read yet",
|
|
||||||
"side.notRead": "Not read yet",
|
|
||||||
"side.warnings": "{count} warnings",
|
|
||||||
"side.warnings_one": "1 warning",
|
|
||||||
"side.notOnStore": "No store version yet",
|
|
||||||
"side.ignored": "Ignored",
|
|
||||||
"side.studioFilter": "Show apps of a studio",
|
|
||||||
"side.allStudios": "All",
|
|
||||||
"games.keep": "In step",
|
|
||||||
"games.update": "Differs",
|
|
||||||
"games.create": "Missing",
|
|
||||||
"games.notOnStore": "Not on this store",
|
|
||||||
"games.notListed": "Not planned",
|
|
||||||
"games.notRead": "Not read",
|
|
||||||
"games.item": "Item",
|
|
||||||
"games.name": "Name",
|
|
||||||
"games.points": "Points",
|
|
||||||
"games.languages": "Languages",
|
|
||||||
"games.leaderboard": "Leaderboard",
|
|
||||||
"games.achievement": "Achievement",
|
|
||||||
"games.hidden": "hidden until earned",
|
|
||||||
"games.localeChanges": "Game Center languages: {list}",
|
|
||||||
"games.checkAgain": "Check again",
|
|
||||||
"games.apiOffTitle": "Play Games Services API is off.",
|
|
||||||
"games.apiOffText": "Turn on {api} in the service account's Google Cloud project, wait a minute, then check again.",
|
|
||||||
"games.itemsTitle": "Leaderboards and achievements",
|
|
||||||
"games.itemsSub": "One list in the config, mapped to both stores: each store's state against the config.",
|
|
||||||
"games.refresh": "Read again",
|
|
||||||
"games.noItems": "No leaderboards or achievements in the config yet (games.leaderboards, games.achievements).",
|
|
||||||
"games.notReadYet": "Reading game services…",
|
|
||||||
"games.images": "Images of leaderboards and achievements are added in the consoles; on Play the existing icon is kept on every sync.",
|
|
||||||
"games.localeMap": "Game Center locale map",
|
|
||||||
"games.localeMapSub": "Config language to the locale the live Game Center uses (games.localeMap).",
|
|
||||||
"games.mapSet": "Set",
|
|
||||||
"games.mapSuggested": "Suggested",
|
|
||||||
"games.mapHint": "Add to games.localeMap: {entries}",
|
|
||||||
} as const;
|
} as const;
|
||||||
|
|
|
||||||
|
|
@ -155,10 +155,7 @@ export const tr: Record<keyof typeof en, string> = {
|
||||||
'phase.releasedUnknown': 'Mağaza sayfası kontrol edilemedi',
|
'phase.releasedUnknown': 'Mağaza sayfası kontrol edilemedi',
|
||||||
'phase.pageUnknown': 'Mağaza sayfası kontrol edilemedi',
|
'phase.pageUnknown': 'Mağaza sayfası kontrol edilemedi',
|
||||||
'phase.pageStale': 'mağaza sayfası kontrol edilemedi, {when} itibarıyla',
|
'phase.pageStale': 'mağaza sayfası kontrol edilemedi, {when} itibarıyla',
|
||||||
'phase.reviewLive': 'Henüz yayında değil (yayında: {version}): incelemede ya da incelemeden önce takıldı',
|
'phase.reviewLive': 'İncelemede (yayında: {version})',
|
||||||
'phase.playPending': 'Henüz yayında değil: incelemede ya da incelemeden önce takıldı',
|
|
||||||
'roll.publishReady': 'Sürüm onaylandıysa Yayınlama özetinde yayınlayın ("Publish N changes"). Ajan `{cmd}` ile hazırlar; son basış sahibine aittir.',
|
|
||||||
'roll.publishOpen': 'Yayınlama özetini aç',
|
|
||||||
'phase.reviewManaged': 'İncelemede / yayına hazır (yönetilen yayınlama)',
|
'phase.reviewManaged': 'İncelemede / yayına hazır (yönetilen yayınlama)',
|
||||||
'phase.rejected': 'Reddedildi',
|
'phase.rejected': 'Reddedildi',
|
||||||
'phase.testing': 'Testte',
|
'phase.testing': 'Testte',
|
||||||
|
|
@ -979,9 +976,7 @@ export const tr: Record<keyof typeof en, string> = {
|
||||||
'set.channel': 'Kanal',
|
'set.channel': 'Kanal',
|
||||||
'set.stable': 'Kararlı',
|
'set.stable': 'Kararlı',
|
||||||
'set.beta': 'Beta',
|
'set.beta': 'Beta',
|
||||||
'set.dev': 'Geliştirme (her değişiklik)',
|
'set.updatesText': 'Güncellemeler storebound.dev\'den imzalı gelir; uygulama bir şeyi değiştirmeden önce imzayı denetler ve yalnızca siz Yükle\'ye bastığınızda yükler. Arka planda denetim yapılmaz.',
|
||||||
'set.devToStable': 'Bu, geliştirme sürümü {version}: daha yeni bir kararlı sürüm çıkana kadar kalır (eski sürüme dönülmez).',
|
|
||||||
'set.updatesText': 'Güncellemeler storebound.dev\'den imzalı gelir; uygulama bir şeyi değiştirmeden önce imzayı denetler. Seçili kanalda daha yeni bir sürümü açılışta, 15 dakikada bir ve uykudan sonra arar, arka planda yükler (siz bu pencerede çalışırken değil). Kararlı, npm sürümlerini izler; Geliştirme, main\'deki her değişikliği alır.',
|
|
||||||
'set.updateCheck': 'Güncellemeleri denetle',
|
'set.updateCheck': 'Güncellemeleri denetle',
|
||||||
'set.updateChecking': 'Denetleniyor…',
|
'set.updateChecking': 'Denetleniyor…',
|
||||||
'set.updateNone': 'storebound {version}, {channel} kanalındaki en yeni sürüm.',
|
'set.updateNone': 'storebound {version}, {channel} kanalındaki en yeni sürüm.',
|
||||||
|
|
@ -2062,12 +2057,6 @@ export const tr: Record<keyof typeof en, string> = {
|
||||||
|
|
||||||
// context menus (ui/ContextMenu.tsx)
|
// context menus (ui/ContextMenu.tsx)
|
||||||
'cm.cut': "Kes",
|
'cm.cut': "Kes",
|
||||||
'cm.pin': "Sabitle: menü açık kalır",
|
|
||||||
'cm.unpin': "Sabitlemeyi kaldır",
|
|
||||||
'cm.closePanel': "Kapat",
|
|
||||||
'cm.gone': "Yok: bu menünün ait olduğu şey şu an ekranda değil.",
|
|
||||||
'cm.menu': "Menü",
|
|
||||||
'cm.tearOff': "Ctrl+tık veya orta tık: bu alt menüyü sabitle",
|
|
||||||
'cm.copy': "Kopyala",
|
'cm.copy': "Kopyala",
|
||||||
'cm.paste': "Yapıştır",
|
'cm.paste': "Yapıştır",
|
||||||
'cm.selectAll': "Tümünü seç",
|
'cm.selectAll': "Tümünü seç",
|
||||||
|
|
@ -2088,13 +2077,6 @@ export const tr: Record<keyof typeof en, string> = {
|
||||||
'cm.ignoredNoReads': "Yok sayılan uygulamalar okunmaz",
|
'cm.ignoredNoReads': "Yok sayılan uygulamalar okunmaz",
|
||||||
'cm.ignore': "Yok say",
|
'cm.ignore': "Yok say",
|
||||||
'acct.devId': 'Play geliştirici kimliği {id}',
|
'acct.devId': 'Play geliştirici kimliği {id}',
|
||||||
'acct.viaBroker': 'jetonlar kimlik aracısından',
|
|
||||||
'acct.viaFile': 'yerel anahtar dosyası',
|
|
||||||
'acct.grantsTitle': 'Kimlik aracısındaki Play izinleri',
|
|
||||||
'acct.grantsOk': 'storebound için gereken her şey var',
|
|
||||||
'acct.grantsMissing': 'eksik: {list}',
|
|
||||||
'acct.grantsNone': 'izin bilgisi yok',
|
|
||||||
'acct.notRegistered': 'aracıda kayıtlı değil',
|
|
||||||
'acct.noDevId': 'Play geliştirici kimliği yok',
|
'acct.noDevId': 'Play geliştirici kimliği yok',
|
||||||
'acct.devIdLabel': 'Play geliştirici hesabı kimliği',
|
'acct.devIdLabel': 'Play geliştirici hesabı kimliği',
|
||||||
'acct.devIdHint': 'Play Console adresinde /developers/ sonrasındaki rakamlar. Girilince Play Console bağlantıları her uygulamanın kendi sayfasını açar; CLI de kullanır.',
|
'acct.devIdHint': 'Play Console adresinde /developers/ sonrasındaki rakamlar. Girilince Play Console bağlantıları her uygulamanın kendi sayfasını açar; CLI de kullanır.',
|
||||||
|
|
@ -2132,106 +2114,4 @@ export const tr: Record<keyof typeof en, string> = {
|
||||||
'cm.copyPrincipal': "Hizmet hesabı / anahtar",
|
'cm.copyPrincipal': "Hizmet hesabı / anahtar",
|
||||||
'cm.copyProfile': "Profil adı",
|
'cm.copyProfile': "Profil adı",
|
||||||
'cm.openAccounts': "Stüdyolar ve hesapları aç",
|
'cm.openAccounts': "Stüdyolar ve hesapları aç",
|
||||||
"sec.release": "Yayın",
|
|
||||||
"sec.store": "Mağaza sayfası",
|
|
||||||
"sec.revenue": "Gelir",
|
|
||||||
"sec.players": "Oyuncular",
|
|
||||||
"sec.health": "Sağlık",
|
|
||||||
"sec.release.for": "Bir sürümü iki mağazada oyunculara ulaştır: build, TestFlight, inceleme ve dağıtım.",
|
|
||||||
"sec.store.for": "Mağazada insanların gördüğü: dile göre metinler, ekran görüntüleri ve uygulama bilgileri.",
|
|
||||||
"sec.revenue.for": "Uygulamanın sattıkları ve fiyatları: uygulama içi ürünler, abonelikler ve fiyatlar.",
|
|
||||||
"sec.players.for": "Oyuncuların söyledikleri ve oyunlarda kazanabilecekleri: yorumlar, Game Center, Play Games.",
|
|
||||||
"sec.health.for": "Uygulama sağlıklı ve hazır mı: çökmeler ve ANR, büyüme, önce düzeltilecek kontroller, diğer araçlar.",
|
|
||||||
"sec.views": "{section} görünümleri",
|
|
||||||
"tab.games": "Oyun servisleri",
|
|
||||||
"next.open": "{where} aç",
|
|
||||||
"next.rejected": "{version}, {store} tarafından reddedildi",
|
|
||||||
"next.halted": "{version}, {store} üzerinde durduruldu",
|
|
||||||
"next.blockers": "Göndermeden önce {count} engel",
|
|
||||||
"next.blockers_one": "Göndermeden önce 1 engel",
|
|
||||||
"next.rollout": "{version} dağıtımı {share} seviyesinde",
|
|
||||||
"next.approved": "{version} onaylandı: yayınla",
|
|
||||||
"next.submit": "{version} sürümünü incelemeye gönder",
|
|
||||||
"next.review": "{version} incelemede",
|
|
||||||
"next.managed": "{version} Yayınlama özeti'nde bekliyor (yönetilen yayınlama)",
|
|
||||||
"next.upload": "İlk build'i yükle",
|
|
||||||
"next.live": "Yayında: {version}",
|
|
||||||
"next.notRead": "Yayın durumu mağazalar okununca görünür",
|
|
||||||
"next.storeLive": "Mağazalardan okunan canlı mağaza sayfası",
|
|
||||||
"next.listingProblems": "{count} mağaza metni sorunu",
|
|
||||||
"next.listingProblems_one": "1 mağaza metni sorunu",
|
|
||||||
"next.unsaved": "{count} kaydedilmemiş düzenleme",
|
|
||||||
"next.unsaved_one": "1 kaydedilmemiş düzenleme",
|
|
||||||
"next.listingsUnread": "Mağaza metinleri henüz kontrol edilmedi",
|
|
||||||
"next.storeOk": "Mağaza sayfası yapılandırmayla uyumlu",
|
|
||||||
"next.catalogDiff": "{count} ürün mağazalar arasında farklı",
|
|
||||||
"next.catalogDiff_one": "1 ürün mağazalar arasında farklı",
|
|
||||||
"next.noProducts": "Henüz ürün yok: bir tane ekle",
|
|
||||||
"next.products": "{products} ürün · {subs} abonelik",
|
|
||||||
"next.reviews": "{count} yorum yanıtsız",
|
|
||||||
"next.reviews_one": "1 yorum yanıtsız",
|
|
||||||
"next.reviewsUnread": "Oyuncuların söylediklerine bak",
|
|
||||||
"next.reviewsOk": "Tüm yorumlar yanıtlandı",
|
|
||||||
"next.gamesApiOff": "Play Games Services API kapalı",
|
|
||||||
"next.gamesBlockers": "{count} oyun servisi engeli",
|
|
||||||
"next.gamesBlockers_one": "1 oyun servisi engeli",
|
|
||||||
"next.gamesSync": "Oyun servisleri: eşitlenecek {count} değişiklik",
|
|
||||||
"next.gamesSync_one": "Oyun servisleri: eşitlenecek 1 değişiklik",
|
|
||||||
"next.fixFirst": "Önce düzeltilecek {count} sorun",
|
|
||||||
"next.fixFirst_one": "Önce düzeltilecek 1 sorun",
|
|
||||||
"next.warnings": "Bakılacak {count} uyarı",
|
|
||||||
"next.warnings_one": "Bakılacak 1 uyarı",
|
|
||||||
"next.healthOk": "Sorun bulunmadı",
|
|
||||||
"side.gAttention": "İlgi bekliyor",
|
|
||||||
"side.gProgress": "Sürüyor",
|
|
||||||
"side.gLive": "Yayında",
|
|
||||||
"side.gDraft": "Henüz mağazada değil",
|
|
||||||
"side.missing": "Klasör bulunamadı",
|
|
||||||
"side.rejected": "Reddedildi · {what}",
|
|
||||||
"side.halted": "Durduruldu · {what}",
|
|
||||||
"side.blockers": "{count} engel",
|
|
||||||
"side.blockers_one": "1 engel",
|
|
||||||
"side.rollout": "Dağıtım {share} · {what}",
|
|
||||||
"side.review": "İncelemede · {what}",
|
|
||||||
"side.approved": "Onaylandı · {what}",
|
|
||||||
"side.draft": "Taslak · {what}",
|
|
||||||
"side.live": "Yayında · {version}",
|
|
||||||
"side.liveWarn": "Yayında · {version} · {count} uyarı",
|
|
||||||
"side.liveWarn_one": "Yayında · {version} · 1 uyarı",
|
|
||||||
"side.storeOnly": "Yalnız mağaza · henüz okunmadı",
|
|
||||||
"side.notRead": "Henüz okunmadı",
|
|
||||||
"side.warnings": "{count} uyarı",
|
|
||||||
"side.warnings_one": "1 uyarı",
|
|
||||||
"side.notOnStore": "Henüz mağaza sürümü yok",
|
|
||||||
"side.ignored": "Yok sayıldı",
|
|
||||||
"side.studioFilter": "Bir stüdyonun uygulamalarını göster",
|
|
||||||
"side.allStudios": "Tümü",
|
|
||||||
"games.keep": "Uyumlu",
|
|
||||||
"games.update": "Farklı",
|
|
||||||
"games.create": "Eksik",
|
|
||||||
"games.notOnStore": "Bu mağazada değil",
|
|
||||||
"games.notListed": "Planlanmadı",
|
|
||||||
"games.notRead": "Okunmadı",
|
|
||||||
"games.item": "Öğe",
|
|
||||||
"games.name": "Ad",
|
|
||||||
"games.points": "Puan",
|
|
||||||
"games.languages": "Diller",
|
|
||||||
"games.leaderboard": "Skor tablosu",
|
|
||||||
"games.achievement": "Başarım",
|
|
||||||
"games.hidden": "kazanılana kadar gizli",
|
|
||||||
"games.localeChanges": "Game Center dilleri: {list}",
|
|
||||||
"games.checkAgain": "Yeniden kontrol et",
|
|
||||||
"games.apiOffTitle": "Play Games Services API kapalı.",
|
|
||||||
"games.apiOffText": "Hizmet hesabının Google Cloud projesinde {api} açın, bir dakika bekleyin, sonra yeniden kontrol edin.",
|
|
||||||
"games.itemsTitle": "Skor tabloları ve başarımlar",
|
|
||||||
"games.itemsSub": "Yapılandırmada tek liste, iki mağazaya eşlenir: her mağazanın yapılandırmaya göre durumu.",
|
|
||||||
"games.refresh": "Yeniden oku",
|
|
||||||
"games.noItems": "Yapılandırmada henüz skor tablosu veya başarım yok (games.leaderboards, games.achievements).",
|
|
||||||
"games.notReadYet": "Oyun servisleri okunuyor…",
|
|
||||||
"games.images": "Skor tablosu ve başarım görselleri konsollarda eklenir; Play'de mevcut simge her eşitlemede korunur.",
|
|
||||||
"games.localeMap": "Game Center dil eşlemesi",
|
|
||||||
"games.localeMapSub": "Yapılandırma dilinden canlı Game Center'ın kullandığı dile (games.localeMap).",
|
|
||||||
"games.mapSet": "Ayarlı",
|
|
||||||
"games.mapSuggested": "Önerilen",
|
|
||||||
"games.mapHint": "games.localeMap'e ekleyin: {entries}",
|
|
||||||
};
|
};
|
||||||
|
|
|
||||||
|
|
@ -2,7 +2,7 @@
|
||||||
// inbox stats, catalog parity matrix, the portfolio's "needs attention" list, and the command palette matcher.
|
// inbox stats, catalog parity matrix, the portfolio's "needs attention" list, and the command palette matcher.
|
||||||
// "Unknown, never false": every derivation keeps "not read" apart from "none" / "ok".
|
// "Unknown, never false": every derivation keeps "not read" apart from "none" / "ok".
|
||||||
import { plainError } from '../../../../cli/lib/google-errors';
|
import { plainError } from '../../../../cli/lib/google-errors';
|
||||||
import type { AppStatus, ProjectSummary, StoreRelease } from '../api';
|
import type { AppStatus, ProjectSummary } from '../api';
|
||||||
import { t } from '../i18n';
|
import { t } from '../i18n';
|
||||||
|
|
||||||
import type { Tone } from '../../../../cli/lib/train';
|
import type { Tone } from '../../../../cli/lib/train';
|
||||||
|
|
@ -138,7 +138,7 @@ export function parityMatrix(s: ProjectSummary | null, diff: CatalogDiff | null)
|
||||||
|
|
||||||
// ---- Portfolio: needs attention ----
|
// ---- Portfolio: needs attention ----
|
||||||
|
|
||||||
export interface Attention { app: string; projectId: string; tone: Tone; text: string; hint?: string; tab?: 'releases' | 'catalog' | 'listings' | 'health' | 'reviews' | 'testflight' | 'checks' | 'games' }
|
export interface Attention { app: string; projectId: string; tone: Tone; text: string; hint?: string; tab?: 'releases' | 'catalog' | 'listings' | 'health' | 'reviews' | 'testflight' | 'checks' }
|
||||||
|
|
||||||
export function attention(projectId: string, name: string, e: AppStatus | undefined, live: AppStatus | undefined, health?: HealthSnapshot | null): Attention[] {
|
export function attention(projectId: string, name: string, e: AppStatus | undefined, live: AppStatus | undefined, health?: HealthSnapshot | null): Attention[] {
|
||||||
const out: Attention[] = [];
|
const out: Attention[] = [];
|
||||||
|
|
@ -203,46 +203,3 @@ export function hueOf(name: string): number {
|
||||||
for (const c of name) h = (h * 31 + c.charCodeAt(0)) >>> 0;
|
for (const c of name) h = (h * 31 + c.charCodeAt(0)) >>> 0;
|
||||||
return h % 360;
|
return h % 360;
|
||||||
}
|
}
|
||||||
|
|
||||||
// ---- App kind and the sidebar ----
|
|
||||||
|
|
||||||
const PLAY_GAME_CATS = ['Action', 'Adventure', 'Arcade', 'Board', 'Card', 'Casino', 'Casual', 'Educational', 'Music', 'Puzzle', 'Racing', 'Role Playing', 'Simulation', 'Sports', 'Strategy', 'Trivia', 'Word'];
|
|
||||||
/** A game: profile game, a games section in the config, or a Play game category. */
|
|
||||||
export function isGameSummary(s: ProjectSummary | null | undefined): boolean {
|
|
||||||
if (!s) return false;
|
|
||||||
return s.profile === 'game' || !!s.games || PLAY_GAME_CATS.includes(s.playRelease?.category ?? '');
|
|
||||||
}
|
|
||||||
|
|
||||||
export type SideGroup = 'attention' | 'progress' | 'live' | 'draft';
|
|
||||||
export interface SideStatus { group: SideGroup; text: string; tone: Tone }
|
|
||||||
|
|
||||||
/** One sidebar row's group and status line: the one thing worth knowing about the app (docs IA). */
|
|
||||||
export function sideStatus(o: { att: Attention[]; all: StoreRelease[]; read: boolean; missing: boolean; storeOnly: boolean }): SideStatus {
|
|
||||||
const sn = (r: StoreRelease) => `${r.store === 'ios' ? 'iOS' : 'Play'} ${r.version ?? ''}`.trim();
|
|
||||||
if (o.missing) return { group: 'attention', text: t('side.missing'), tone: 'bad' };
|
|
||||||
const rej = o.all.find(r => r.phase === 'rejected');
|
|
||||||
if (rej) return { group: 'attention', text: t('side.rejected', { what: sn(rej) }), tone: 'bad' };
|
|
||||||
const halted = o.all.find(r => r.phase === 'halted');
|
|
||||||
if (halted) return { group: 'attention', text: t('side.halted', { what: sn(halted) }), tone: 'bad' };
|
|
||||||
const bad = o.att.filter(a => a.tone === 'bad').length;
|
|
||||||
if (bad) return { group: 'attention', text: t('side.blockers', { count: bad }), tone: 'bad' };
|
|
||||||
const crash = o.att.find(a => a.tab === 'health');
|
|
||||||
if (crash) return { group: 'attention', text: crash.text, tone: crash.tone };
|
|
||||||
const rolling = o.all.find(r => r.phase === 'rollout' && r.fraction !== null && r.fraction < 1);
|
|
||||||
if (rolling) return { group: 'progress', text: t('side.rollout', { share: `${Math.round((rolling.fraction ?? 0) * 100)} %`, what: sn(rolling) }), tone: 'info' };
|
|
||||||
const review = o.all.find(r => r.phase === 'review' || r.phase === 'sent');
|
|
||||||
if (review) return { group: 'progress', text: t('side.review', { what: sn(review) }), tone: 'info' };
|
|
||||||
const approved = o.all.find(r => r.phase === 'approved');
|
|
||||||
if (approved) return { group: 'progress', text: t('side.approved', { what: sn(approved) }), tone: 'info' };
|
|
||||||
const live = o.all.filter(r => r.phase === 'live' || r.phase === 'released' || r.phase === 'rollout');
|
|
||||||
const draft = o.all.find(r => r.phase === 'draft' || r.phase === 'testing');
|
|
||||||
if (draft && !live.length) return { group: 'progress', text: t('side.draft', { what: sn(draft) }), tone: 'neutral' };
|
|
||||||
const warn = o.att.filter(a => a.tone === 'warn').length;
|
|
||||||
if (live.length) {
|
|
||||||
const vs = [...new Set(live.map(r => r.version).filter(Boolean))];
|
|
||||||
return { group: 'live', text: warn ? t('side.liveWarn', { version: vs.join(' / '), count: warn }) : t('side.live', { version: vs.join(' / ') }), tone: warn ? 'warn' : 'ok' };
|
|
||||||
}
|
|
||||||
if (!o.read) return { group: o.storeOnly ? 'live' : 'draft', text: o.storeOnly ? t('side.storeOnly') : t('side.notRead'), tone: 'neutral' };
|
|
||||||
return { group: 'draft', text: warn ? t('side.warnings', { count: warn }) : t('side.notOnStore'), tone: warn ? 'warn' : 'neutral' };
|
|
||||||
}
|
|
||||||
export const SIDE_GROUPS: SideGroup[] = ['attention', 'progress', 'live', 'draft'];
|
|
||||||
|
|
|
||||||
|
|
@ -65,7 +65,7 @@ export function normalizeSettings(v: unknown): Settings {
|
||||||
lowReviews: pick(n.lowReviews, d.notify.lowReviews, isBool), crash: pick(n.crash, d.notify.crash, isBool),
|
lowReviews: pick(n.lowReviews, d.notify.lowReviews, isBool), crash: pick(n.crash, d.notify.crash, isBool),
|
||||||
quietHours: { enabled: pick(q.enabled, d.notify.quietHours.enabled, isBool), from: pick(q.from, d.notify.quietHours.from, isHm), to: pick(q.to, d.notify.quietHours.to, isHm) },
|
quietHours: { enabled: pick(q.enabled, d.notify.quietHours.enabled, isBool), from: pick(q.from, d.notify.quietHours.from, isHm), to: pick(q.to, d.notify.quietHours.to, isHm) },
|
||||||
},
|
},
|
||||||
channel: v.channel === 'dev' || v.channel === 'beta' ? v.channel : 'stable',
|
channel: v.channel === 'beta' ? 'beta' : 'stable',
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,94 +0,0 @@
|
||||||
// The "what's next" line of each app section (docs IA): one sentence and the sub view it opens, from state that is
|
|
||||||
// already read (status, live releases, attention, cached reads). Pure, so tests pin the rules; a section never starts
|
|
||||||
// a read to fill it.
|
|
||||||
import type { CatalogParity, ListingsResult, StoreRelease } from '../api';
|
|
||||||
import { t } from '../i18n';
|
|
||||||
import type { AppSection, AppTab } from '../nav';
|
|
||||||
import type { IconName } from '../ui/icons';
|
|
||||||
import { type Attention, isGameSummary } from './model';
|
|
||||||
import { share } from './format';
|
|
||||||
import type { ProjectSummary } from '../api';
|
|
||||||
|
|
||||||
export type NextTone = 'bad' | 'warn' | 'ok' | 'info' | 'neutral';
|
|
||||||
export interface SectionNext { text: string; tone: NextTone; tab: AppTab | null; icon: IconName }
|
|
||||||
|
|
||||||
export interface GamesNext { changes: number; blockers: number; apiOff: boolean }
|
|
||||||
export interface SectionInput {
|
|
||||||
project: boolean;
|
|
||||||
att: Attention[];
|
|
||||||
all: StoreRelease[];
|
|
||||||
next: string | null;
|
|
||||||
summary: ProjectSummary | null;
|
|
||||||
catalog: CatalogParity | null;
|
|
||||||
/** Unsaved edits of the section's editors. */
|
|
||||||
unsaved: number;
|
|
||||||
/** Cached reads (null: not read yet). */
|
|
||||||
listings: ListingsResult | null;
|
|
||||||
reviews: { reply?: unknown }[] | null;
|
|
||||||
games: GamesNext | null;
|
|
||||||
/** Blockers of the last store readiness read (validate), null when never read. */
|
|
||||||
readiness?: number | null;
|
|
||||||
}
|
|
||||||
|
|
||||||
const storeName = (s: 'ios' | 'android') => (s === 'ios' ? 'App Store' : 'Google Play');
|
|
||||||
|
|
||||||
/** Problems of a listings read: file problems plus required fields missing or over the limit. */
|
|
||||||
export function listingProblems(l: ListingsResult | null): number | null {
|
|
||||||
if (!l) return null;
|
|
||||||
let n = l.problems.length;
|
|
||||||
for (const loc of l.locales) for (const s of [loc.play, loc.apple]) for (const f of s?.fields ?? []) if (f.state === 'missing' || f.state === 'over') n++;
|
|
||||||
return n;
|
|
||||||
}
|
|
||||||
|
|
||||||
export function sectionNext(section: AppSection, i: SectionInput): SectionNext {
|
|
||||||
const bad = i.att.filter(a => a.tone === 'bad');
|
|
||||||
if (section === 'release') {
|
|
||||||
const rej = i.all.find(r => r.phase === 'rejected' || r.phase === 'halted');
|
|
||||||
if (rej) return { text: t(rej.phase === 'rejected' ? 'next.rejected' : 'next.halted', { version: rej.version ?? '', store: storeName(rej.store) }), tone: 'bad', tab: 'releases', icon: 'alertCircle' };
|
|
||||||
const checks = bad.filter(a => a.tab === 'checks').length + (i.readiness ?? 0);
|
|
||||||
if (checks) return { text: t('next.blockers', { count: checks }), tone: 'bad', tab: 'checks', icon: 'alertCircle' };
|
|
||||||
const rolling = i.all.find(r => r.phase === 'rollout' && r.fraction !== null && r.fraction < 1);
|
|
||||||
if (rolling) return { text: t('next.rollout', { share: share(rolling.fraction ?? 0), version: rolling.version ?? '' }), tone: 'info', tab: 'releases', icon: 'rocket' };
|
|
||||||
const approved = i.all.find(r => r.phase === 'approved');
|
|
||||||
if (approved) return { text: t('next.approved', { version: approved.version ?? '' }), tone: 'info', tab: 'releases', icon: 'rocket' };
|
|
||||||
const ready = i.all.find(r => r.phase === 'draft' || r.phase === 'testing');
|
|
||||||
if (ready) return { text: t('next.submit', { version: ready.version ?? '' }), tone: 'info', tab: 'releases', icon: 'send' };
|
|
||||||
const review = i.all.find(r => r.phase === 'review' || r.phase === 'sent');
|
|
||||||
if (review) return { text: review.managed ? t('next.managed', { version: review.version ?? '' }) : t('next.review', { version: review.version ?? '' }), tone: 'neutral', tab: 'releases', icon: 'clock' };
|
|
||||||
if (i.project && !i.next && !i.all.length) return { text: t('next.upload'), tone: 'neutral', tab: 'releases', icon: 'upload' };
|
|
||||||
const live = i.all.find(r => r.phase === 'live' || r.phase === 'released');
|
|
||||||
return live ? { text: t('next.live', { version: live.version ?? '' }), tone: 'ok', tab: null, icon: 'check' } : { text: t('next.notRead'), tone: 'neutral', tab: null, icon: 'clock' };
|
|
||||||
}
|
|
||||||
if (section === 'store') {
|
|
||||||
if (!i.project) return { text: t('next.storeLive'), tone: 'neutral', tab: null, icon: 'cloud' };
|
|
||||||
const n = listingProblems(i.listings);
|
|
||||||
if (n) return { text: t('next.listingProblems', { count: n }), tone: 'warn', tab: 'listings', icon: 'alert' };
|
|
||||||
if (i.unsaved) return { text: t('next.unsaved', { count: i.unsaved }), tone: 'warn', tab: null, icon: 'edit' };
|
|
||||||
return n === null ? { text: t('next.listingsUnread'), tone: 'neutral', tab: 'listings', icon: 'text' } : { text: t('next.storeOk'), tone: 'ok', tab: null, icon: 'check' };
|
|
||||||
}
|
|
||||||
if (section === 'revenue') {
|
|
||||||
const c = i.catalog;
|
|
||||||
if (c && c.checked === 'live' && !c.ok) return { text: t('next.catalogDiff', { count: c.missingIos.length + c.missingAndroid.length + c.onlyIos.length + c.onlyAndroid.length }), tone: 'warn', tab: 'catalog', icon: 'alert' };
|
|
||||||
const p = i.summary?.products ?? 0, s = i.summary?.subscriptions ?? 0;
|
|
||||||
if (!p && !s) return { text: t('next.noProducts'), tone: 'neutral', tab: 'catalog', icon: 'plus' };
|
|
||||||
return { text: t('next.products', { products: p, subs: s }), tone: 'ok', tab: null, icon: 'check' };
|
|
||||||
}
|
|
||||||
if (section === 'players') {
|
|
||||||
const open = i.reviews ? i.reviews.filter(r => !r.reply).length : null;
|
|
||||||
if (open) return { text: t('next.reviews', { count: open }), tone: 'warn', tab: 'reviews', icon: 'message' };
|
|
||||||
if (i.games?.apiOff) return { text: t('next.gamesApiOff'), tone: 'bad', tab: 'games', icon: 'alertCircle' };
|
|
||||||
if (i.games?.blockers) return { text: t('next.gamesBlockers', { count: i.games.blockers }), tone: 'bad', tab: 'games', icon: 'alertCircle' };
|
|
||||||
if (i.games?.changes) return { text: t('next.gamesSync', { count: i.games.changes }), tone: 'warn', tab: 'games', icon: 'upload' };
|
|
||||||
return open === null ? { text: t('next.reviewsUnread'), tone: 'neutral', tab: 'reviews', icon: 'message' } : { text: t('next.reviewsOk'), tone: 'ok', tab: null, icon: 'check' };
|
|
||||||
}
|
|
||||||
const crash = i.att.find(a => a.tab === 'health');
|
|
||||||
if (crash) return { text: crash.text, tone: crash.tone === 'bad' ? 'bad' : 'warn', tab: 'health', icon: 'activity' };
|
|
||||||
const problems = i.att.filter(a => a.tab === 'checks');
|
|
||||||
const fix = problems.filter(a => a.tone === 'bad').length + (i.readiness ?? 0);
|
|
||||||
if (fix) return { text: t('next.fixFirst', { count: fix }), tone: 'bad', tab: 'checks', icon: 'shield' };
|
|
||||||
if (problems.length) return { text: t('next.warnings', { count: problems.length }), tone: 'warn', tab: 'checks', icon: 'shield' };
|
|
||||||
return { text: t('next.healthOk'), tone: 'ok', tab: null, icon: 'check' };
|
|
||||||
}
|
|
||||||
|
|
||||||
/** A game: profile game, a games section in the config, or a Play game category. */
|
|
||||||
export const isGame = (s: ProjectSummary | null | undefined): boolean => isGameSummary(s);
|
|
||||||
|
|
@ -4,58 +4,31 @@ import { createContext, useContext } from 'react';
|
||||||
import type { Key } from './i18n';
|
import type { Key } from './i18n';
|
||||||
import type { IconName } from './ui/icons';
|
import type { IconName } from './ui/icons';
|
||||||
|
|
||||||
export const APP_TABS = ['releases', 'testflight', 'listings', 'art', 'appinfo', 'catalog', 'prices', 'reviews', 'games', 'health', 'growth', 'checks', 'tools'] as const;
|
export const APP_TABS = ['releases', 'catalog', 'prices', 'listings', 'art', 'health', 'reviews', 'testflight', 'growth', 'appinfo', 'checks', 'tools'] as const;
|
||||||
export type AppTab = (typeof APP_TABS)[number];
|
export type AppTab = (typeof APP_TABS)[number];
|
||||||
|
/** Tabs of a store-only app: store reads only (catalog, prices, app info and checks need the app folder; listings and
|
||||||
/** The five sections of an app, by job (docs IA): each holds sub views (the old tabs). The route keeps the sub id. */
|
* store art are the live ones; Growth shows the Product Page Optimization tests only). */
|
||||||
export const SECTIONS = ['release', 'store', 'revenue', 'players', 'health'] as const;
|
export const STORE_TABS: readonly AppTab[] = ['releases', 'listings', 'art', 'health', 'reviews', 'testflight', 'growth'];
|
||||||
export type AppSection = (typeof SECTIONS)[number];
|
export const tabsFor = (hasFolder: boolean): readonly AppTab[] => (hasFolder ? APP_TABS : STORE_TABS);
|
||||||
export const SECTION_TABS: Record<AppSection, readonly AppTab[]> = {
|
|
||||||
release: ['releases', 'testflight'], store: ['listings', 'art', 'appinfo'], revenue: ['catalog', 'prices'], players: ['reviews', 'games'], health: ['health', 'growth', 'checks', 'tools'],
|
|
||||||
};
|
|
||||||
export const sectionOf = (tab: AppTab): AppSection => SECTIONS.find(s => SECTION_TABS[s].includes(tab)) ?? 'release';
|
|
||||||
export const SECTION_KEY: Record<AppSection, Key> = { release: 'sec.release', store: 'sec.store', revenue: 'sec.revenue', players: 'sec.players', health: 'sec.health' };
|
|
||||||
export const SECTION_ICON: Record<AppSection, IconName> = { release: 'rocket', store: 'image', revenue: 'coins', players: 'users', health: 'activity' };
|
|
||||||
|
|
||||||
/** Sub views of a store-only app: store reads only (catalog, prices, app info, checks and tools need the app folder;
|
|
||||||
* listings and store art are the live ones; Growth shows the Product Page Optimization tests only). */
|
|
||||||
export const STORE_TABS: readonly AppTab[] = ['releases', 'testflight', 'listings', 'art', 'reviews', 'health', 'growth'];
|
|
||||||
/** The sub views an app has: the folder decides most; Game services only for games. */
|
|
||||||
export const tabsFor = (hasFolder: boolean, game = false): readonly AppTab[] => (hasFolder ? APP_TABS : STORE_TABS).filter(x => x !== 'games' || (game && hasFolder));
|
|
||||||
/** The sections an app has (a section with no sub view is left out: Revenue for a store-only app). */
|
|
||||||
export const sectionsFor = (hasFolder: boolean, game = false): AppSection[] => { const tabs = tabsFor(hasFolder, game); return SECTIONS.filter(s => SECTION_TABS[s].some(x => tabs.includes(x))); };
|
|
||||||
export const subsOf = (s: AppSection, hasFolder: boolean, game = false): AppTab[] => { const tabs = tabsFor(hasFolder, game); return SECTION_TABS[s].filter(x => tabs.includes(x)); };
|
|
||||||
export const TAB_KEY: Record<AppTab, Key> = {
|
export const TAB_KEY: Record<AppTab, Key> = {
|
||||||
releases: 'tab.releases', catalog: 'tab.catalog', prices: 'tab.prices', listings: 'tab.listings', art: 'tab.art', health: 'tab.health', reviews: 'tab.reviews',
|
releases: 'tab.releases', catalog: 'tab.catalog', prices: 'tab.prices', listings: 'tab.listings', art: 'tab.art', health: 'tab.health', reviews: 'tab.reviews',
|
||||||
testflight: 'tab.testflight', growth: 'tab.growth', appinfo: 'tab.appinfo', checks: 'tab.checks', tools: 'tab.tools', games: 'tab.games',
|
testflight: 'tab.testflight', growth: 'tab.growth', appinfo: 'tab.appinfo', checks: 'tab.checks', tools: 'tab.tools',
|
||||||
};
|
};
|
||||||
export const TAB_ICON: Record<AppTab, IconName> = {
|
export const TAB_ICON: Record<AppTab, IconName> = {
|
||||||
releases: 'rocket', catalog: 'tag', prices: 'coins', listings: 'text', art: 'grid', health: 'activity', reviews: 'message', testflight: 'plane', growth: 'chart',
|
releases: 'rocket', catalog: 'tag', prices: 'coins', listings: 'text', art: 'grid', health: 'activity', reviews: 'message', testflight: 'plane', growth: 'chart',
|
||||||
appinfo: 'clipboard', checks: 'shield', tools: 'sliders', games: 'sparkle',
|
appinfo: 'clipboard', checks: 'shield', tools: 'sliders',
|
||||||
};
|
};
|
||||||
|
|
||||||
/** A place in an app from a link: an old tab id ("prices"), a section ("revenue", its first sub view) or
|
|
||||||
* "section/sub" ("store/art"). Unknown: Release. */
|
|
||||||
export function placeOf(v: string | undefined | null): AppTab {
|
|
||||||
if (!v) return 'releases';
|
|
||||||
const [a, b] = v.split('/');
|
|
||||||
if (b && (SECTIONS as readonly string[]).includes(a!) && SECTION_TABS[a as AppSection].includes(b as AppTab)) return b as AppTab;
|
|
||||||
if (APP_TABS.includes(a as AppTab)) return a as AppTab;
|
|
||||||
if ((SECTIONS as readonly string[]).includes(a!)) return SECTION_TABS[a as AppSection][0]!;
|
|
||||||
return 'releases';
|
|
||||||
}
|
|
||||||
|
|
||||||
export const WORKSPACE = ['apps', 'accounts', 'ignored', 'dependencies', 'settings'] as const;
|
export const WORKSPACE = ['apps', 'accounts', 'ignored', 'dependencies', 'settings'] as const;
|
||||||
export type WorkspaceScreen = (typeof WORKSPACE)[number];
|
export type WorkspaceScreen = (typeof WORKSPACE)[number];
|
||||||
|
|
||||||
export type Route = { screen: 'portfolio' } | { screen: 'app'; appId: string; tab: AppTab } | { screen: WorkspaceScreen; section?: string };
|
export type Route = { screen: 'portfolio' } | { screen: 'app'; appId: string; tab: AppTab } | { screen: WorkspaceScreen; section?: string };
|
||||||
|
|
||||||
/** storebound://<screen> deep links and the dev-only start switch ("app:health" = first app, Health section;
|
/** storebound://<screen> deep links and the dev-only start switch ("app:health" = first app, Health tab;
|
||||||
* "app:store/art" = a sub view; "app:prices" = an old tab id; "app:health:2" = second app; "settings:refresh" = a Settings section). `apps` are the app keys in list order. */
|
* "app:health:2" = second app; "settings:refresh" = a Settings section). `apps` are the app keys in list order. */
|
||||||
export function parseStart(v: string, apps: string[]): Route | null {
|
export function parseStart(v: string, apps: string[]): Route | null {
|
||||||
const [screen, tab, n] = v.split(':');
|
const [screen, tab, n] = v.split(':');
|
||||||
const app = apps[Math.max(0, (Number(n) || 1) - 1)];
|
const app = apps[Math.max(0, (Number(n) || 1) - 1)];
|
||||||
if (screen === 'app' && app) return { screen: 'app', appId: app, tab: placeOf(tab) };
|
if (screen === 'app' && app) return { screen: 'app', appId: app, tab: APP_TABS.includes(tab as AppTab) ? tab as AppTab : 'releases' };
|
||||||
if (screen === 'portfolio') return { screen: 'portfolio' };
|
if (screen === 'portfolio') return { screen: 'portfolio' };
|
||||||
if (!(WORKSPACE as readonly string[]).includes(screen ?? '')) return null;
|
if (!(WORKSPACE as readonly string[]).includes(screen ?? '')) return null;
|
||||||
return tab ? { screen: screen as WorkspaceScreen, section: tab } : { screen: screen as WorkspaceScreen };
|
return tab ? { screen: screen as WorkspaceScreen, section: tab } : { screen: screen as WorkspaceScreen };
|
||||||
|
|
@ -68,7 +41,7 @@ export function parseRouteJson(v: string): Route | null {
|
||||||
if (!o || typeof o !== 'object') return null;
|
if (!o || typeof o !== 'object') return null;
|
||||||
const r = o as Record<string, unknown>;
|
const r = o as Record<string, unknown>;
|
||||||
if (r.screen === 'portfolio') return { screen: 'portfolio' };
|
if (r.screen === 'portfolio') return { screen: 'portfolio' };
|
||||||
if (r.screen === 'app') return typeof r.appId === 'string' && r.appId ? { screen: 'app', appId: r.appId, tab: placeOf(typeof r.tab === 'string' ? r.tab : null) } : null;
|
if (r.screen === 'app') return typeof r.appId === 'string' && r.appId ? { screen: 'app', appId: r.appId, tab: APP_TABS.includes(r.tab as AppTab) ? r.tab as AppTab : 'releases' } : null;
|
||||||
if (typeof r.screen === 'string' && (WORKSPACE as readonly string[]).includes(r.screen)) return typeof r.section === 'string' ? { screen: r.screen as WorkspaceScreen, section: r.section } : { screen: r.screen as WorkspaceScreen };
|
if (typeof r.screen === 'string' && (WORKSPACE as readonly string[]).includes(r.screen)) return typeof r.section === 'string' ? { screen: r.screen as WorkspaceScreen, section: r.section } : { screen: r.screen as WorkspaceScreen };
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -92,7 +92,6 @@ function AccountRow({ a, busy, setBusy, onError }: { a: Account; busy: string |
|
||||||
{used ? ` · ${t('acct.folders', { count: used })}` : ''}
|
{used ? ` · ${t('acct.folders', { count: used })}` : ''}
|
||||||
{a.kind === 'play' && (a.developerId ? <> · <span className="mono-id selectable" title={t('acct.devIdHint')}>{t('acct.devId', { id: a.developerId })}</span></> : <> · <span title={t('acct.devIdHint')}>{t('acct.noDevId')}</span></>)}
|
{a.kind === 'play' && (a.developerId ? <> · <span className="mono-id selectable" title={t('acct.devIdHint')}>{t('acct.devId', { id: a.developerId })}</span></> : <> · <span title={t('acct.devIdHint')}>{t('acct.noDevId')}</span></>)}
|
||||||
{check?.principal ? <> · <span className="mono-id selectable">{check.principal}</span></> : null}
|
{check?.principal ? <> · <span className="mono-id selectable">{check.principal}</span></> : null}
|
||||||
{a.kind === 'play' && check?.source ? ` · ${check.source === 'broker' ? t('acct.viaBroker') : t('acct.viaFile')}` : ''}
|
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div className="actions">
|
<div className="actions">
|
||||||
|
|
@ -123,22 +122,6 @@ function AccountRow({ a, busy, setBusy, onError }: { a: Account; busy: string |
|
||||||
</Notice>
|
</Notice>
|
||||||
</div>
|
</div>
|
||||||
)}
|
)}
|
||||||
{check?.grants && check.grants.length > 0 && (
|
|
||||||
<div className="acct-fix acct-grants">
|
|
||||||
<div className="small strong">{t('acct.grantsTitle')}</div>
|
|
||||||
<ul className="small">
|
|
||||||
{check.grants.map(g => (
|
|
||||||
<li key={g.packageName}>
|
|
||||||
<span className="mono-id selectable">{g.packageName}</span>{': '}
|
|
||||||
{!g.registered ? <span className="muted">{t('acct.notRegistered')}</span>
|
|
||||||
: g.missing.length ? <Chip tone="warn">{t('acct.grantsMissing', { list: g.missing.join(', ') })}</Chip>
|
|
||||||
: g.grants ? <Chip tone="ok">{t('acct.grantsOk')}</Chip> : <span className="muted">{t('acct.grantsNone')}</span>}
|
|
||||||
{g.grants && g.grants.length > 0 && <span className="muted mono-id" title={(g.enabledApis ?? []).join(', ')}>{` ${g.grants.join(', ')}`}</span>}
|
|
||||||
</li>
|
|
||||||
))}
|
|
||||||
</ul>
|
|
||||||
</div>
|
|
||||||
)}
|
|
||||||
{h?.error && <div className="acct-fix"><Notice tone="bad">{h.error}</Notice></div>}
|
{h?.error && <div className="acct-fix"><Notice tone="bad">{h.error}</Notice></div>}
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
|
|
|
||||||
|
|
@ -1,20 +1,16 @@
|
||||||
// One app across both stores: header (icon, studio, ids, store state, pairing), then five sections by job (Release,
|
// One app across both stores: header (icon, studio, ids, store state, pairing), then the tabs. A store-only app (no
|
||||||
// Store page, Revenue, Players, Health; docs IA), each with a header (what it is for, the one next step) and its sub views. A store-only app (no
|
|
||||||
// app folder) shows its store reads (releases, health, reviews, TestFlight) read-only, with "Link a folder" and
|
// app folder) shows its store reads (releases, health, reviews, TestFlight) read-only, with "Link a folder" and
|
||||||
// "Start an app folder here" to make it a full app.
|
// "Start an app folder here" to make it a full app.
|
||||||
import { useContextMenu, useMenuButton } from '../ui/ContextMenu';
|
import { useContextMenu, useMenuButton } from '../ui/ContextMenu';
|
||||||
import { appMenu, playUrlFor } from '../ui/app-menu';
|
import { appMenu, playUrlFor } from '../ui/app-menu';
|
||||||
import { useShowIgnored } from '../lib/show-ignored';
|
import { useShowIgnored } from '../lib/show-ignored';
|
||||||
import { useState } from 'react';
|
import { useState } from 'react';
|
||||||
import { GamesTab } from './tabs/Games';
|
|
||||||
import { SectionHead } from './SectionHead';
|
|
||||||
import { api, errorText } from '../api';
|
import { api, errorText } from '../api';
|
||||||
import { type Key, t } from '../i18n';
|
import { type Key, t } from '../i18n';
|
||||||
import { pairCandidates, type UnifiedApp, withLink, withPair, withStudio } from '../lib/identity';
|
import { pairCandidates, type UnifiedApp, withLink, withPair, withStudio } from '../lib/identity';
|
||||||
import { attention, storeNow } from '../lib/model';
|
import { attention, storeNow } from '../lib/model';
|
||||||
import { Hero, nextStep, Tabs } from '../ui/ds';
|
import { Hero, nextStep, Tabs } from '../ui/ds';
|
||||||
import { isGameSummary } from '../lib/model';
|
import { type AppTab, TAB_ICON, TAB_KEY, tabsFor, useNav } from '../nav';
|
||||||
import { type AppSection, type AppTab, SECTION_ICON, SECTION_KEY, SECTION_TABS, sectionOf, sectionsFor, subsOf, useNav } from '../nav';
|
|
||||||
import { useData } from '../store';
|
import { useData } from '../store';
|
||||||
import { Icon } from '../ui/icons';
|
import { Icon } from '../ui/icons';
|
||||||
import { ErrorBoundary } from '../ui/ErrorBoundary';
|
import { ErrorBoundary } from '../ui/ErrorBoundary';
|
||||||
|
|
@ -69,7 +65,7 @@ function AppControls({ app }: { app: UnifiedApp }) {
|
||||||
</select></label>
|
</select></label>
|
||||||
)}
|
)}
|
||||||
<span className="grow" />
|
<span className="grow" />
|
||||||
<button className="btn btn-sm btn-ghost" {...more(() => appMenu(app, d, nav, { showIgnored }), `app:${app.key}`)} aria-label={t('cm.more')} title={t('cm.more')}><Icon name="more" />{app.ignored || app.ignoredStores.length ? t('nav.ignored') : null}</button>
|
<button className="btn btn-sm btn-ghost" {...more(() => appMenu(app, d, nav, { showIgnored }))} aria-label={t('cm.more')} title={t('cm.more')}><Icon name="more" />{app.ignored || app.ignoredStores.length ? t('nav.ignored') : null}</button>
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
@ -111,15 +107,11 @@ export function AppView({ app, tab }: { app: UnifiedApp; tab: AppTab }) {
|
||||||
const ios = e?.app?.platforms.ios ?? (app.ios ? { bundleId: app.ios.app.bundleId, ascAppId: app.ios.app.id } : null);
|
const ios = e?.app?.platforms.ios ?? (app.ios ? { bundleId: app.ios.app.bundleId, ascAppId: app.ios.app.id } : null);
|
||||||
const android = e?.app?.platforms.android ?? (app.android ? { packageName: app.android.app.id } : null);
|
const android = e?.app?.platforms.android ?? (app.android ? { packageName: app.android.app.id } : null);
|
||||||
const name = (app.project && e?.app?.name) || app.name;
|
const name = (app.project && e?.app?.name) || app.name;
|
||||||
const game = isGameSummary(e?.summary);
|
const tabs = tabsFor(!!app.project);
|
||||||
const sections = sectionsFor(!!app.project, game);
|
|
||||||
const section = sectionOf(tab);
|
|
||||||
const ed = useEdits();
|
const ed = useEdits();
|
||||||
useUnsavedGuard();
|
useUnsavedGuard();
|
||||||
const studio = d.studios.find(s => s.id === app.studio) ?? null;
|
const studio = d.studios.find(s => s.id === app.studio) ?? null;
|
||||||
const setTab = (x: AppTab) => nav.go({ screen: 'app', appId: app.key, tab: x });
|
const setTab = (x: AppTab) => nav.go({ screen: 'app', appId: app.key, tab: x });
|
||||||
const setSection = (x: AppSection) => setTab(subsOf(x, !!app.project, game)[0] ?? SECTION_TABS[x][0]!);
|
|
||||||
const editCount = (x: AppTab) => (EDIT_TABS[x] ? ed.count(app.project?.id ?? app.target, EDIT_TABS[x]) : 0);
|
|
||||||
const all = l?.release.all ?? [];
|
const all = l?.release.all ?? [];
|
||||||
const iosNow = l ? storeNow(all, 'ios').now : null, androidNow = l ? storeNow(all, 'android').now : null;
|
const iosNow = l ? storeNow(all, 'ios').now : null, androidNow = l ? storeNow(all, 'android').now : null;
|
||||||
const att = attention(app.key, app.name, e, l);
|
const att = attention(app.key, app.name, e, l);
|
||||||
|
|
@ -130,7 +122,7 @@ export function AppView({ app, tab }: { app: UnifiedApp; tab: AppTab }) {
|
||||||
return (
|
return (
|
||||||
<div className="page ds-app">
|
<div className="page ds-app">
|
||||||
<Hero name={name} icon={d.iconFor(app)} projectId={app.project && !app.project.missing ? app.project.id : null}
|
<Hero name={name} icon={d.iconFor(app)} projectId={app.project && !app.project.missing ? app.project.id : null}
|
||||||
{...cm(() => appMenu(app, d, nav, { showIgnored }), `app:${app.key}`)}
|
{...cm(() => appMenu(app, d, nav, { showIgnored }))}
|
||||||
badges={<>
|
badges={<>
|
||||||
{e?.summary?.profile && app.project && <Chip tone="outline">{t(`profile.${e.summary.profile}` as 'profile.app')}</Chip>}
|
{e?.summary?.profile && app.project && <Chip tone="outline">{t(`profile.${e.summary.profile}` as 'profile.app')}</Chip>}
|
||||||
{!app.project && <StoreOnlyTag />}
|
{!app.project && <StoreOnlyTag />}
|
||||||
|
|
@ -145,20 +137,19 @@ export function AppView({ app, tab }: { app: UnifiedApp; tab: AppTab }) {
|
||||||
{android && <button className="btn btn-sm btn-ghost" onClick={() => open(playUrlFor(d, app))} title={t('app.consoleHint')}><Icon name="external" />Play Console</button>}
|
{android && <button className="btn btn-sm btn-ghost" onClick={() => open(playUrlFor(d, app))} title={t('app.consoleHint')}><Icon name="external" />Play Console</button>}
|
||||||
</>}
|
</>}
|
||||||
all={all} ios={!!ios} android={!!android} next={l?.release.next?.version ?? null}
|
all={all} ios={!!ios} android={!!android} next={l?.release.next?.version ?? null}
|
||||||
compact={section !== 'release' || tab !== 'releases'}
|
compact={tab !== 'releases'}
|
||||||
cta={nextStep({ project: !!app.project, att, all, next: l?.release.next?.version ?? null })} onCta={setTab} />
|
cta={nextStep({ project: !!app.project, att, all, next: l?.release.next?.version ?? null })} onCta={setTab} />
|
||||||
<AppControls app={app} />
|
<AppControls app={app} />
|
||||||
{!app.project && <StoreOnlyBanner app={app} />}
|
{!app.project && <StoreOnlyBanner app={app} />}
|
||||||
{app.project?.storeboundPin && <Notice tone="info" icon="info">{t('app.pinNotice', { pin: app.project.storeboundPin, app: d.info?.version ?? '' })}</Notice>}
|
{app.project?.storeboundPin && <Notice tone="info" icon="info">{t('app.pinNotice', { pin: app.project.storeboundPin, app: d.info?.version ?? '' })}</Notice>}
|
||||||
{app.project?.missing ? <FolderMissing project={app.project} /> : <>
|
{app.project?.missing ? <FolderMissing project={app.project} /> : <>
|
||||||
<div className="ds-app-sticky">
|
<div className="ds-app-sticky">
|
||||||
<Tabs label={t('app.sections', { name })} value={section} onChange={setSection} items={sections.map((x, i) => {
|
<Tabs label={t('app.sections', { name })} value={tab} onChange={setTab} items={tabs.map(x => {
|
||||||
const n = subsOf(x, !!app.project, game).reduce((a, s2) => a + editCount(s2), 0);
|
const n = EDIT_TABS[x] ? ed.count(app.project?.id ?? app.target, EDIT_TABS[x]) : 0;
|
||||||
return { id: x, label: t(SECTION_KEY[x]), icon: SECTION_ICON[x], hint: String(i + 1), count: att.filter(a => a.tab && sectionOf(a.tab) === x && a.tone === 'bad').length, dot: n > 0, dotTitle: n ? t('ed.unsaved', { count: n }) : undefined };
|
return { id: x, label: t(TAB_KEY[x]), icon: TAB_ICON[x], count: att.filter(a => a.tab === x && a.tone === 'bad').length, dot: n > 0, dotTitle: n ? t('ed.unsaved', { count: n }) : undefined };
|
||||||
})} />
|
})} />
|
||||||
</div>
|
</div>
|
||||||
<SectionHead app={app} section={section} tab={tab} subs={subsOf(section, !!app.project, game)} att={att} all={all} next={l?.release.next?.version ?? null} unsaved={subsOf(section, !!app.project, game).reduce((a, s2) => a + editCount(s2), 0)} editCount={editCount} onTab={setTab} />
|
<div role="tabpanel" id="tabpanel" aria-labelledby={`tab-${tab}`} className="stack" style={{ gap: 16 }}>
|
||||||
<div role="tabpanel" id="tabpanel" aria-labelledby={`tab-${section}`} className="stack" style={{ gap: 16 }}>
|
|
||||||
<ErrorBoundary key={tab} where={`tab ${tab}`}>
|
<ErrorBoundary key={tab} where={`tab ${tab}`}>
|
||||||
{tab === 'releases' && <ReleasesTab app={app} />}
|
{tab === 'releases' && <ReleasesTab app={app} />}
|
||||||
{tab === 'catalog' && app.project && <CatalogTab project={app.project} />}
|
{tab === 'catalog' && app.project && <CatalogTab project={app.project} />}
|
||||||
|
|
@ -169,7 +160,6 @@ export function AppView({ app, tab }: { app: UnifiedApp; tab: AppTab }) {
|
||||||
{tab === 'art' && !app.project && <LiveArt target={app.target} />}
|
{tab === 'art' && !app.project && <LiveArt target={app.target} />}
|
||||||
{tab === 'health' && <HealthTab app={app} />}
|
{tab === 'health' && <HealthTab app={app} />}
|
||||||
{tab === 'reviews' && <ReviewsTab app={app} />}
|
{tab === 'reviews' && <ReviewsTab app={app} />}
|
||||||
{tab === 'games' && app.project && <GamesTab project={app.project} />}
|
|
||||||
{tab === 'testflight' && <TestFlightTab app={app} />}
|
{tab === 'testflight' && <TestFlightTab app={app} />}
|
||||||
{tab === 'growth' && <GrowthTab app={app} />}
|
{tab === 'growth' && <GrowthTab app={app} />}
|
||||||
{tab === 'appinfo' && app.project && <AppInfoTab project={app.project} />}
|
{tab === 'appinfo' && app.project && <AppInfoTab project={app.project} />}
|
||||||
|
|
|
||||||
|
|
@ -30,7 +30,7 @@ export function Ignored() {
|
||||||
{apps.map(a => {
|
{apps.map(a => {
|
||||||
const s = d.studios.find(x => x.id === a.studio) ?? null;
|
const s = d.studios.find(x => x.id === a.studio) ?? null;
|
||||||
return (
|
return (
|
||||||
<div className="li" key={a.key} {...cm(() => appMenu(a, d, nav, { showIgnored: true }), `app:${a.key}`)}>
|
<div className="li" key={a.key} {...cm(() => appMenu(a, d, nav, { showIgnored: true }))}>
|
||||||
<AppIcon name={a.name} src={d.iconFor(a)} />
|
<AppIcon name={a.name} src={d.iconFor(a)} />
|
||||||
<div className="li-main">
|
<div className="li-main">
|
||||||
<span className="li-title row" style={{ gap: 8 }}>{a.name}{!a.project && <StoreOnlyTag />}</span>
|
<span className="li-title row" style={{ gap: 8 }}>{a.name}{!a.project && <StoreOnlyTag />}</span>
|
||||||
|
|
|
||||||
|
|
@ -24,7 +24,7 @@ import { useExports } from '../ui/Exports';
|
||||||
import { Icon, StoreGlyph } from '../ui/icons';
|
import { Icon, StoreGlyph } from '../ui/icons';
|
||||||
import { nextStep, Pipeline, tintStyle, useShots, useTint } from '../ui/ds';
|
import { nextStep, Pipeline, tintStyle, useShots, useTint } from '../ui/ds';
|
||||||
export { nextStep } from '../ui/ds';
|
export { nextStep } from '../ui/ds';
|
||||||
import { AppIcon, Card, Chip, Empty, Kpi, Notice, PhaseChip, phaseLabel, Seg, Skeleton, Sparkline, StudioMark } from '../ui/kit';
|
import { AppIcon, Card, Chip, Empty, Kpi, Notice, PhaseChip, Seg, Skeleton, Sparkline, StudioMark } from '../ui/kit';
|
||||||
|
|
||||||
/** Tag of one app's offline config check. */
|
/** Tag of one app's offline config check. */
|
||||||
export function checkState(e: Pick<AppStatus, 'errors' | 'check'> | undefined): { text: string; tone: Tone } {
|
export function checkState(e: Pick<AppStatus, 'errors' | 'check'> | undefined): { text: string; tone: Tone } {
|
||||||
|
|
@ -72,7 +72,7 @@ function NextCell({ e }: { e: AppStatus | undefined }) {
|
||||||
<span className="strong num">{n.version}</span>
|
<span className="strong num">{n.version}</span>
|
||||||
<div className="row small muted" style={{ gap: 10 }}>
|
<div className="row small muted" style={{ gap: 10 }}>
|
||||||
{n.ios && <span className="row" style={{ gap: 4 }}><StoreGlyph store="ios" className="ic13" />{t(`phase.${n.ios.phase}`)}</span>}
|
{n.ios && <span className="row" style={{ gap: 4 }}><StoreGlyph store="ios" className="ic13" />{t(`phase.${n.ios.phase}`)}</span>}
|
||||||
{n.android && <span className="row" style={{ gap: 4 }}><StoreGlyph store="android" className="ic13" />{phaseLabel(n.android).text}</span>}
|
{n.android && <span className="row" style={{ gap: 4 }}><StoreGlyph store="android" className="ic13" />{t(`phase.${n.android.phase}`)}</span>}
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
|
|
@ -153,7 +153,7 @@ function AppCard({ r, icon, health, studio }: { r: CardRow; icon: string | null;
|
||||||
const menu = useContextMenu();
|
const menu = useContextMenu();
|
||||||
const [showIgnored] = useShowIgnored();
|
const [showIgnored] = useShowIgnored();
|
||||||
return (
|
return (
|
||||||
<article className="pf-card" style={style} aria-label={name} {...menu(() => appMenu(app, d, nav, { showIgnored }), `app:${app.key}`)}>
|
<article className="pf-card" style={style} aria-label={name} {...menu(() => appMenu(app, d, nav, { showIgnored }))}>
|
||||||
<div className={`pf-shots${shots.length ? '' : ' empty'}`} aria-hidden="true">
|
<div className={`pf-shots${shots.length ? '' : ' empty'}`} aria-hidden="true">
|
||||||
{shots.length ? shots.map((s, i) => <img key={i} src={s} alt="" draggable={false} loading="lazy" />) : <>
|
{shots.length ? shots.map((s, i) => <img key={i} src={s} alt="" draggable={false} loading="lazy" />) : <>
|
||||||
<AppIcon name={app.name} src={icon} className="pf-hero-icon" />
|
<AppIcon name={app.name} src={icon} className="pf-hero-icon" />
|
||||||
|
|
@ -373,7 +373,7 @@ export function Portfolio() {
|
||||||
const ios = !!(app.ios || e?.app?.platforms.ios), android = !!(app.android || e?.app?.platforms.android);
|
const ios = !!(app.ios || e?.app?.platforms.ios), android = !!(app.android || e?.app?.platforms.android);
|
||||||
const sub = app.ios?.app.bundleId ?? e?.app?.platforms.ios?.bundleId ?? app.android?.app.id ?? e?.app?.platforms.android?.packageName ?? '';
|
const sub = app.ios?.app.bundleId ?? e?.app?.platforms.ios?.bundleId ?? app.android?.app.id ?? e?.app?.platforms.android?.packageName ?? '';
|
||||||
return (
|
return (
|
||||||
<tr key={app.key} className="clickable" onClick={() => open(app)} {...menu(() => appMenu(app, d, nav, { showIgnored }), `app:${app.key}`)}>
|
<tr key={app.key} className="clickable" onClick={() => open(app)} {...menu(() => appMenu(app, d, nav, { showIgnored }))}>
|
||||||
<td>
|
<td>
|
||||||
<div className="cell-app">
|
<div className="cell-app">
|
||||||
<AppIcon name={app.name} src={d.iconFor(app)} />
|
<AppIcon name={app.name} src={d.iconFor(app)} />
|
||||||
|
|
@ -456,7 +456,7 @@ export function Portfolio() {
|
||||||
<button className="link" aria-pressed={showIgnored} onClick={() => setShowIgnored(!showIgnored)}>{showIgnored ? t('ignored.hide', { count: ignoredApps.length }) : t('ignored.show', { count: ignoredApps.length })}</button>
|
<button className="link" aria-pressed={showIgnored} onClick={() => setShowIgnored(!showIgnored)}>{showIgnored ? t('ignored.hide', { count: ignoredApps.length }) : t('ignored.show', { count: ignoredApps.length })}</button>
|
||||||
{showIgnored && ignoredApps.map(a => (
|
{showIgnored && ignoredApps.map(a => (
|
||||||
<span key={a.key} className="row muted" style={{ gap: 4 }}>
|
<span key={a.key} className="row muted" style={{ gap: 4 }}>
|
||||||
<button className="link" onClick={() => open(a)} {...menu(() => appMenu(a, d, nav, { showIgnored }), `app:${a.key}`)}>{a.name}</button>
|
<button className="link" onClick={() => open(a)} {...menu(() => appMenu(a, d, nav, { showIgnored }))}>{a.name}</button>
|
||||||
<button className="btn btn-sm btn-ghost btn-icon" onClick={() => d.updateOverrides(o => withIgnored(o, a.ignoreKeys, false))} aria-label={t('ignored.restore')} title={t('ignored.restore')}><Icon name="eye" /></button>
|
<button className="btn btn-sm btn-ghost btn-icon" onClick={() => d.updateOverrides(o => withIgnored(o, a.ignoreKeys, false))} aria-label={t('ignored.restore')} title={t('ignored.restore')}><Icon name="eye" /></button>
|
||||||
</span>
|
</span>
|
||||||
))}
|
))}
|
||||||
|
|
|
||||||
|
|
@ -1,60 +0,0 @@
|
||||||
// The header of one app section (docs IA): the section's name, one line on what it is for, the single next step
|
|
||||||
// derived from state that is already read (lib/sections.ts), and the sub views as a segmented control (only when the
|
|
||||||
// section has more than one).
|
|
||||||
import type { ListingsResult, StoreRelease } from '../api';
|
|
||||||
import { t } from '../i18n';
|
|
||||||
import type { UnifiedApp } from '../lib/identity';
|
|
||||||
import type { Attention } from '../lib/model';
|
|
||||||
import { sectionNext } from '../lib/sections';
|
|
||||||
import { type AppSection, type AppTab, SECTION_ICON, SECTION_KEY, TAB_ICON, TAB_KEY } from '../nav';
|
|
||||||
import { useCachedRead, useData } from '../store';
|
|
||||||
import type { GameServicesStatus } from '../ui/GameServicesCard';
|
|
||||||
import { Icon } from '../ui/icons';
|
|
||||||
|
|
||||||
const PURPOSE: Record<AppSection, 'sec.release.for' | 'sec.store.for' | 'sec.revenue.for' | 'sec.players.for' | 'sec.health.for'> = {
|
|
||||||
release: 'sec.release.for', store: 'sec.store.for', revenue: 'sec.revenue.for', players: 'sec.players.for', health: 'sec.health.for',
|
|
||||||
};
|
|
||||||
|
|
||||||
export function SectionHead({ app, section, tab, subs, att, all, next, unsaved, editCount, onTab }: {
|
|
||||||
app: UnifiedApp; section: AppSection; tab: AppTab; subs: AppTab[]; att: Attention[]; all: StoreRelease[]; next: string | null; unsaved: number;
|
|
||||||
editCount: (t: AppTab) => number; onTab: (t: AppTab) => void;
|
|
||||||
}) {
|
|
||||||
const d = useData();
|
|
||||||
const e = d.statusFor(app);
|
|
||||||
const pid = app.project && !app.project.missing ? app.project.id : null;
|
|
||||||
// cached reads only: the header never starts a store call
|
|
||||||
const listings = useCachedRead<ListingsResult>(section === 'store' ? pid : null, 'project.listings');
|
|
||||||
const reviews = useCachedRead<{ reply?: unknown }[]>(section === 'players' ? app.target : null, 'reviews.list', { days: 30 });
|
|
||||||
const games = useCachedRead<GameServicesStatus>(section === 'players' && subs.includes('games') ? pid : null, 'games.status');
|
|
||||||
const validate = useCachedRead<{ findings?: { level: string }[] }>(section === 'health' || section === 'release' ? pid : null, 'validate');
|
|
||||||
const n = sectionNext(section, {
|
|
||||||
project: !!app.project, att, all, next, summary: e?.summary ?? null, catalog: (d.liveFor(app) ?? e)?.catalog ?? null, unsaved, listings,
|
|
||||||
reviews: Array.isArray(reviews) ? reviews : null, readiness: validate?.findings ? validate.findings.filter(f => f.level === 'blocker').length : null,
|
|
||||||
games: games ? { changes: (games.apple?.changes.length ?? 0) + (games.play?.changes.length ?? 0), blockers: games.findings.filter(f => f.level === 'error').length, apiOff: !!games.playApiDisabled } : null,
|
|
||||||
});
|
|
||||||
return (
|
|
||||||
<div className="sec-head" data-testid="section-head">
|
|
||||||
<div className="sec-head-t">
|
|
||||||
<h2 className="sec-head-name"><Icon name={SECTION_ICON[section]} />{t(SECTION_KEY[section])}</h2>
|
|
||||||
<p className="sec-head-for">{t(PURPOSE[section])}</p>
|
|
||||||
</div>
|
|
||||||
<div className={`sec-next tone-${n.tone}`} role="status" data-testid="section-next">
|
|
||||||
<Icon name={n.icon} />
|
|
||||||
<span className="sec-next-t">{n.text}</span>
|
|
||||||
{n.tab && n.tab !== tab && <button className="btn btn-sm" onClick={() => onTab(n.tab!)}>{t('next.open', { where: t(TAB_KEY[n.tab]) })}<Icon name="arrowRight" /></button>}
|
|
||||||
</div>
|
|
||||||
{subs.length > 1 && (
|
|
||||||
<div className="seg sec-subs" role="group" aria-label={t('sec.views', { section: t(SECTION_KEY[section]) })}>
|
|
||||||
{subs.map(x => {
|
|
||||||
const c = editCount(x);
|
|
||||||
return (
|
|
||||||
<button key={x} id={`sub-${x}`} type="button" aria-pressed={tab === x} aria-controls="tabpanel" onClick={() => onTab(x)}>
|
|
||||||
<Icon name={TAB_ICON[x]} />{t(TAB_KEY[x])}{c > 0 && <span className="ed-dot" title={t('ed.unsaved', { count: c })} />}
|
|
||||||
</button>
|
|
||||||
);
|
|
||||||
})}
|
|
||||||
</div>
|
|
||||||
)}
|
|
||||||
</div>
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
@ -257,8 +257,7 @@ export function Settings({ onTheme: _onTheme, section }: { onTheme: () => void;
|
||||||
<Section id="set-updates" title={t('set.updates')} icon="download" className="set-card">
|
<Section id="set-updates" title={t('set.updates')} icon="download" className="set-card">
|
||||||
<div className="form">
|
<div className="form">
|
||||||
<div className="field"><span className="legend">{t('set.channel')}</span>
|
<div className="field"><span className="legend">{t('set.channel')}</span>
|
||||||
<Seg value={s.channel} label={t('set.channel')} onChange={channel => set(x => ({ ...x, channel }))} options={[['stable', t('set.stable')], ['dev', t('set.dev')]]} /></div>
|
<Seg value={s.channel} label={t('set.channel')} onChange={channel => set(x => ({ ...x, channel }))} options={[['stable', t('set.stable')], ['beta', t('set.beta')]]} /></div>
|
||||||
{s.channel === 'stable' && /-dev\./.test(d.info?.version ?? '') && <p className="small muted">{t('set.devToStable', { version: d.info!.version })}</p>}
|
|
||||||
<Updates />
|
<Updates />
|
||||||
<p className="small muted">{t('set.updatesText')}</p>
|
<p className="small muted">{t('set.updatesText')}</p>
|
||||||
</div>
|
</div>
|
||||||
|
|
@ -280,7 +279,7 @@ export function Settings({ onTheme: _onTheme, section }: { onTheme: () => void;
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Settings > Updates: Check asks the channel now; Install runs after the host's native dialog (the signature is checked there). The host also checks and installs in the background (lib.rs auto_update). */
|
/** Settings > Updates: checks on click only; installs after the host's native dialog (the signature is checked there). */
|
||||||
function Updates() {
|
function Updates() {
|
||||||
const [info, setInfo] = useState<UpdateInfo | null>(null);
|
const [info, setInfo] = useState<UpdateInfo | null>(null);
|
||||||
const [busy, setBusy] = useState<'check' | 'install' | null>(null);
|
const [busy, setBusy] = useState<'check' | 'install' | null>(null);
|
||||||
|
|
@ -295,7 +294,7 @@ function Updates() {
|
||||||
setBusy('install'); setError(null);
|
setBusy('install'); setError(null);
|
||||||
try { await api.updateInstall(version); } catch (e) { setError(errorText(e)); } finally { setBusy(null); setGot(null); }
|
try { await api.updateInstall(version); } catch (e) { setError(errorText(e)); } finally { setBusy(null); setGot(null); }
|
||||||
};
|
};
|
||||||
const channel = info ? t(info.channel === 'beta' ? 'set.beta' : info.channel === 'dev' ? 'set.dev' : 'set.stable') : '';
|
const channel = info ? t(info.channel === 'beta' ? 'set.beta' : 'set.stable') : '';
|
||||||
return (
|
return (
|
||||||
<div className="stack" style={{ gap: 8 }}>
|
<div className="stack" style={{ gap: 8 }}>
|
||||||
{error && <Notice tone="bad">{error}</Notice>}
|
{error && <Notice tone="bad">{error}</Notice>}
|
||||||
|
|
|
||||||
|
|
@ -19,6 +19,7 @@ import { Bar, Chip, ErrorNotice, Notice, Skeleton } from '../../ui/kit';
|
||||||
import { EmptyState, Section } from '../../ui/ds';
|
import { EmptyState, Section } from '../../ui/ds';
|
||||||
import '../../styles/appinfo.css';
|
import '../../styles/appinfo.css';
|
||||||
import { WriteButton } from '../../ui/WriteButton';
|
import { WriteButton } from '../../ui/WriteButton';
|
||||||
|
import { GameServicesCard } from '../../ui/GameServicesCard';
|
||||||
import { ascUrl } from '../AppView';
|
import { ascUrl } from '../AppView';
|
||||||
|
|
||||||
const AREA: Record<DeclAsk['area'], Key> = { dataSafety: 'ai.aDataSafety', appPrivacy: 'ai.aAppPrivacy', appInfo: 'ai.aAppInfo', encryption: 'ai.aEncryption', review: 'ai.aReview' };
|
const AREA: Record<DeclAsk['area'], Key> = { dataSafety: 'ai.aDataSafety', appPrivacy: 'ai.aAppPrivacy', appInfo: 'ai.aAppInfo', encryption: 'ai.aEncryption', review: 'ai.aReview' };
|
||||||
|
|
@ -257,6 +258,7 @@ export function AppInfoTab({ project }: { project: Project }) {
|
||||||
</Section>
|
</Section>
|
||||||
</div>
|
</div>
|
||||||
)}
|
)}
|
||||||
|
<GameServicesCard project={project} />
|
||||||
<ConsoleSteps project={project} stores={d.stores} />
|
<ConsoleSteps project={project} stores={d.stores} />
|
||||||
|
|
||||||
<p className="ai-foot">{t('ai.foot', { when: ago(r.at) })}</p>
|
<p className="ai-foot">{t('ai.foot', { when: ago(r.at) })}</p>
|
||||||
|
|
|
||||||
|
|
@ -1,90 +0,0 @@
|
||||||
// Players > Game services: Game Center (App Store) and Play Games Services (Google Play) for a game, from
|
|
||||||
// `games status --json` (cli/games-status.ts). The two store panels (switches, ids, counts, sync writes with dry run +
|
|
||||||
// confirm) are the GameServicesCard; below it one row per leaderboard / achievement with its languages and each
|
|
||||||
// store's state against the config, the Game Center locale map with suggestions, and the Play API-disabled state with
|
|
||||||
// the enable link and the console plan.
|
|
||||||
import { Fragment } from 'react';
|
|
||||||
import type { Project } from '../../api';
|
|
||||||
import { t } from '../../i18n';
|
|
||||||
import { useRead } from '../../store';
|
|
||||||
import { ConsolePlanButton } from '../../ui/ConsolePlan';
|
|
||||||
import { EmptyState, Section } from '../../ui/ds';
|
|
||||||
import { type GameAction, type GameItemRow, GameServicesCard, type GameServicesStatus } from '../../ui/GameServicesCard';
|
|
||||||
import { Icon, StoreGlyph } from '../../ui/icons';
|
|
||||||
import { Chip, Notice } from '../../ui/kit';
|
|
||||||
import { OpenLink } from '../../ui/OpenLink';
|
|
||||||
|
|
||||||
const ACTION_TONE: Record<GameAction, 'ok' | 'warn' | 'info'> = { keep: 'ok', update: 'warn', create: 'info' };
|
|
||||||
const ACTION_KEY = { keep: 'games.keep', update: 'games.update', create: 'games.create' } as const;
|
|
||||||
|
|
||||||
function StoreState({ on, plan, read }: { on: boolean; plan: { action: GameAction; changed: string[] } | null; read: boolean }) {
|
|
||||||
if (!on) return <span className="muted small">{t('games.notOnStore')}</span>;
|
|
||||||
if (!plan) return <span className="muted small">{read ? t('games.notListed') : t('games.notRead')}</span>;
|
|
||||||
return <Chip tone={ACTION_TONE[plan.action]} title={plan.changed.length && plan.action !== 'keep' ? plan.changed.join(', ') : undefined}>{t(ACTION_KEY[plan.action])}</Chip>;
|
|
||||||
}
|
|
||||||
|
|
||||||
function ItemsTable({ rows, appleRead, playRead }: { rows: GameItemRow[]; appleRead: boolean; playRead: boolean }) {
|
|
||||||
return (
|
|
||||||
<div className="table-wrap">
|
|
||||||
<table className="table">
|
|
||||||
<thead><tr>
|
|
||||||
<th>{t('games.item')}</th><th>{t('games.name')}</th><th className="num">{t('games.points')}</th><th>{t('games.languages')}</th>
|
|
||||||
<th><span className="row" style={{ gap: 4 }}><StoreGlyph store="ios" className="ic13" />{t('gs.gameCenter')}</span></th>
|
|
||||||
<th><span className="row" style={{ gap: 4 }}><StoreGlyph store="android" className="ic13" />{t('gs.playGames')}</span></th>
|
|
||||||
</tr></thead>
|
|
||||||
<tbody>
|
|
||||||
{rows.map(r => {
|
|
||||||
const locs = r.apple?.locales.filter(l => l.action !== 'keep') ?? [];
|
|
||||||
return (
|
|
||||||
<tr key={`${r.kind}:${r.id}`}>
|
|
||||||
<td><span className="row" style={{ gap: 6 }}><Icon name={r.kind === 'leaderboard' ? 'chart' : 'sparkle'} className="ic13" /><span className="mono-id small">{r.id}</span></span>
|
|
||||||
<div className="small muted">{t(r.kind === 'leaderboard' ? 'games.leaderboard' : 'games.achievement')}{r.hidden ? ` · ${t('games.hidden')}` : ''}</div></td>
|
|
||||||
<td>{r.name}</td>
|
|
||||||
<td className="num">{r.points ?? '–'}</td>
|
|
||||||
<td className="small">{r.locales.join(', ')}{locs.length > 0 && <div className="small muted">{t('games.localeChanges', { list: locs.map(l => `${l.locale} ${t(ACTION_KEY[l.action])}`).join(', ') })}</div>}</td>
|
|
||||||
<td><StoreState on={r.ios} plan={r.apple} read={appleRead} /></td>
|
|
||||||
<td><StoreState on={r.android} plan={r.play} read={playRead} /></td>
|
|
||||||
</tr>
|
|
||||||
);
|
|
||||||
})}
|
|
||||||
</tbody>
|
|
||||||
</table>
|
|
||||||
</div>
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
export function GamesTab({ project }: { project: Project }) {
|
|
||||||
const r = useRead<GameServicesStatus>(project.id, 'games.status', { network: true, title: t('gs.title') });
|
|
||||||
const s = r.data;
|
|
||||||
const rows = s?.items ?? [];
|
|
||||||
const appleRead = !!s?.apple && !s.apple.error, playRead = !!s?.play && !s.play.error;
|
|
||||||
const map = s?.localeMap;
|
|
||||||
return (
|
|
||||||
<>
|
|
||||||
{s?.playApiDisabled && (
|
|
||||||
<Notice tone="bad" icon="alertCircle" action={<div className="actions">
|
|
||||||
<button className="btn btn-sm btn-primary" onClick={() => r.refresh()} disabled={r.loading}><Icon name="refresh" className={r.loading ? 'spin' : undefined} />{t('games.checkAgain')}</button>
|
|
||||||
<ConsolePlanButton project={project} form="play-games-services" label={t('gs.setup')} />
|
|
||||||
</div>}>
|
|
||||||
<b>{t('games.apiOffTitle')}</b> {t('games.apiOffText', { api: s.playApiDisabled.title })} <OpenLink url={s.playApiDisabled.url} />
|
|
||||||
</Notice>
|
|
||||||
)}
|
|
||||||
<GameServicesCard project={project} read={r} />
|
|
||||||
<Section title={t('games.itemsTitle')} icon="chart" sub={t('games.itemsSub')}
|
|
||||||
actions={<button className="btn btn-sm" onClick={() => r.refresh()} disabled={r.loading} aria-busy={r.loading}><Icon name="refresh" className={r.loading ? 'spin' : undefined} />{t('games.refresh')}</button>}>
|
|
||||||
{rows.length ? <ItemsTable rows={rows} appleRead={appleRead} playRead={playRead} />
|
|
||||||
: <EmptyState icon="sparkle">{s ? t('games.noItems') : t('games.notReadYet')}</EmptyState>}
|
|
||||||
<p className="small muted" style={{ marginTop: 10 }}>{t('games.images')}</p>
|
|
||||||
</Section>
|
|
||||||
{map && (Object.keys(map.configured).length > 0 || map.suggested.length > 0) && (
|
|
||||||
<Section title={t('games.localeMap')} icon="globe" sub={t('games.localeMapSub')}>
|
|
||||||
<dl className="kv">
|
|
||||||
{Object.entries(map.configured).map(([k, v]) => <Fragment key={`k${k}`}><dt>{k}</dt><dd><span className="mono-id small">{v}</span> <Chip tone="ok">{t('games.mapSet')}</Chip></dd></Fragment>)}
|
|
||||||
{map.suggested.map(x => <Fragment key={`s${x.id}`}><dt>{x.id}</dt><dd><span className="mono-id small">{x.from} → {x.to}</span> <Chip tone="warn">{t('games.mapSuggested')}</Chip></dd></Fragment>)}
|
|
||||||
</dl>
|
|
||||||
{map.suggested.length > 0 && <p className="small muted" style={{ marginTop: 8 }}>{t('games.mapHint', { entries: map.suggested.map(x => `${x.id}: '${x.to}'`).join(', ') })}</p>}
|
|
||||||
</Section>
|
|
||||||
)}
|
|
||||||
</>
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
@ -11,7 +11,6 @@ import { WriteButton } from '../../ui/WriteButton';
|
||||||
import { type Key, t } from '../../i18n';
|
import { type Key, t } from '../../i18n';
|
||||||
import { ago, date, share } from '../../lib/format';
|
import { ago, date, share } from '../../lib/format';
|
||||||
import { type Lane, STAGES, type TestFlightStatus, trainLanes, versionHistory } from '../../lib/model';
|
import { type Lane, STAGES, type TestFlightStatus, trainLanes, versionHistory } from '../../lib/model';
|
||||||
import { api } from '../../api';
|
|
||||||
import { useData, useRead, useWrite } from '../../store';
|
import { useData, useRead, useWrite } from '../../store';
|
||||||
import { Icon, StoreGlyph } from '../../ui/icons';
|
import { Icon, StoreGlyph } from '../../ui/icons';
|
||||||
import { RolloutBar } from '../../ui/charts';
|
import { RolloutBar } from '../../ui/charts';
|
||||||
|
|
@ -20,8 +19,6 @@ import { EmptyState, Section, StatusPill, tintStyle, useTint } from '../../ui/ds
|
||||||
import { AppleSubmitCard, PlayProductionCard } from './Submit';
|
import { AppleSubmitCard, PlayProductionCard } from './Submit';
|
||||||
import { useContextMenu } from '../../ui/ContextMenu';
|
import { useContextMenu } from '../../ui/ContextMenu';
|
||||||
import { releaseMenu } from '../../ui/app-menu';
|
import { releaseMenu } from '../../ui/app-menu';
|
||||||
import { consoleUrl } from '../../../../../cli/lib/console-links';
|
|
||||||
import { PUBLISH_PLAN_HINT } from '../../../../../cli/lib/play-publish';
|
|
||||||
import '../../styles/releases.css';
|
import '../../styles/releases.css';
|
||||||
|
|
||||||
const STAGE_KEY: Record<(typeof STAGES)[number], Key> = { build: 'stage.build', testing: 'stage.testing', review: 'stage.review', live: 'stage.live', rollout: 'stage.rollout' };
|
const STAGE_KEY: Record<(typeof STAGES)[number], Key> = { build: 'stage.build', testing: 'stage.testing', review: 'stage.review', live: 'stage.live', rollout: 'stage.rollout' };
|
||||||
|
|
@ -95,24 +92,11 @@ function LaneRow({ lane, version, st, app }: { lane: Lane; version: string; st:
|
||||||
)}
|
)}
|
||||||
</div>
|
</div>
|
||||||
)}
|
)}
|
||||||
{r && r.store === 'android' && r.managed && r.phase === 'review' && !!r.liveVersion && !r.pageStaleAt && <PublishHint st={st} />}
|
|
||||||
{r && app.project && <RolloutControls app={app} r={r} />}
|
{r && app.project && <RolloutControls app={app} r={r} />}
|
||||||
</article>
|
</article>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Managed publishing: the approved production release waits in Publishing overview ("Publish N changes"). */
|
|
||||||
function PublishHint({ st }: { st: AppStatus }) {
|
|
||||||
const a = st.app?.platforms.android;
|
|
||||||
const url = consoleUrl('play.publishing', { playDeveloperId: a?.developerId, playAppId: a?.appId });
|
|
||||||
return (
|
|
||||||
<div className="roll-ctl" data-hint="publish-changes">
|
|
||||||
<span className="small muted">{t('roll.publishReady', { cmd: PUBLISH_PLAN_HINT })}</span>
|
|
||||||
<button className="btn btn-sm" onClick={() => { api.openExternal(url).catch(() => {}); }}><Icon name="external" />{t('roll.publishOpen')}</button>
|
|
||||||
</div>
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
const SHARES = [1, 2, 5, 10, 20, 50];
|
const SHARES = [1, 2, 5, 10, 20, 50];
|
||||||
|
|
||||||
/** Rollout controls of one store release: Play staged rollout share / halt / resume / complete, iOS phased release
|
/** Rollout controls of one store release: Play staged rollout share / halt / resume / complete, iOS phased release
|
||||||
|
|
|
||||||
|
|
@ -750,21 +750,3 @@ export function useRead<T>(target: string, method: string, o: { network: boolean
|
||||||
|
|
||||||
return { ...s, loading: !o.skip && (s.loading || st.busy), justNow: st.justNow, pausedUntil: st.pausedUntil, refresh };
|
return { ...s, loading: !o.skip && (s.loading || st.busy), justNow: st.justNow, pausedUntil: st.pausedUntil, refresh };
|
||||||
}
|
}
|
||||||
|
|
||||||
/** The cached value of one read (and every later result of it), without ever starting a read: for summaries such as a
|
|
||||||
* section's "what's next" line that must not cost a store call. Null until the read ran once. */
|
|
||||||
export function useCachedRead<T>(target: string | null, method: string, args: Record<string, unknown> = {}): T | null {
|
|
||||||
const d = useData();
|
|
||||||
const argsKey = JSON.stringify(args);
|
|
||||||
const [v, set] = useState<T | null>(null);
|
|
||||||
useEffect(() => {
|
|
||||||
set(null);
|
|
||||||
if (!target) return;
|
|
||||||
let alive = true;
|
|
||||||
const a = JSON.parse(argsKey) as Record<string, unknown>;
|
|
||||||
api.cached<ToolResult>(method, target, a).then(c => { if (alive && c && c.value.data !== undefined && usable(method, c.value)) set(c.value.data as T); }, () => {});
|
|
||||||
const un = d.onRead(readKey(target, method, a), e => { if (e.kind === 'done' && usable(method, e.result)) set(e.result.data as T); });
|
|
||||||
return () => { alive = false; un(); };
|
|
||||||
}, [target, method, argsKey]); // eslint-disable-line react-hooks/exhaustive-deps
|
|
||||||
return v;
|
|
||||||
}
|
|
||||||
|
|
|
||||||
|
|
@ -24,5 +24,3 @@
|
||||||
.scr-accounts .acct-fix { padding: 0 16px 16px; }
|
.scr-accounts .acct-fix { padding: 0 16px 16px; }
|
||||||
.scr-accounts .acct-add { display: grid; grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); gap: 18px; align-items: start; }
|
.scr-accounts .acct-add { display: grid; grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); gap: 18px; align-items: start; }
|
||||||
.scr-accounts .acct-add .form { gap: 14px; }
|
.scr-accounts .acct-add .form { gap: 14px; }
|
||||||
.scr-accounts .acct-grants ul { margin: 4px 0 0; padding-left: 18px; display: grid; gap: 2px; }
|
|
||||||
.scr-accounts .acct-grants li { overflow-wrap: anywhere; }
|
|
||||||
|
|
|
||||||
|
|
@ -1,166 +0,0 @@
|
||||||
// One tray menu panel (tray-menu.html): the root menu or one submenu, drawn with the design system's menu look. The
|
|
||||||
// window around it belongs to Rust (menu_panel.rs); the panel only measures itself and reports what the owner does.
|
|
||||||
import { AppWindowIcon } from '@phosphor-icons/react/dist/csr/AppWindow';
|
|
||||||
import { ArrowsClockwiseIcon } from '@phosphor-icons/react/dist/csr/ArrowsClockwise';
|
|
||||||
import { BellSlashIcon } from '@phosphor-icons/react/dist/csr/BellSlash';
|
|
||||||
import { CaretRightIcon } from '@phosphor-icons/react/dist/csr/CaretRight';
|
|
||||||
import { DeviceMobileIcon } from '@phosphor-icons/react/dist/csr/DeviceMobile';
|
|
||||||
import { DownloadSimpleIcon } from '@phosphor-icons/react/dist/csr/DownloadSimple';
|
|
||||||
import { GearSixIcon } from '@phosphor-icons/react/dist/csr/GearSix';
|
|
||||||
import { PowerIcon } from '@phosphor-icons/react/dist/csr/Power';
|
|
||||||
import { PushPinIcon } from '@phosphor-icons/react/dist/csr/PushPin';
|
|
||||||
import { PushPinSlashIcon } from '@phosphor-icons/react/dist/csr/PushPinSlash';
|
|
||||||
import { SquaresFourIcon } from '@phosphor-icons/react/dist/csr/SquaresFour';
|
|
||||||
import { XIcon } from '@phosphor-icons/react/dist/csr/X';
|
|
||||||
import { type KeyboardEvent, type MouseEvent, type ReactNode, useEffect, useLayoutEffect, useMemo, useRef, useState } from 'react';
|
|
||||||
import { filterNodes, findPath, isEnabled, isTearOff, keepActive, type MenuNode, nextIndex, type Row, rows, split } from './model';
|
|
||||||
|
|
||||||
export interface MenuBridge {
|
|
||||||
ready(width: number, height: number): void;
|
|
||||||
openSub(key: string, top: number, focus: boolean): void;
|
|
||||||
pinSub(key: string, top: number): void;
|
|
||||||
closeSubs(): void;
|
|
||||||
close(refocusParent: boolean): void;
|
|
||||||
dismiss(): void;
|
|
||||||
pin(on: boolean): void;
|
|
||||||
select(id: string): void;
|
|
||||||
}
|
|
||||||
|
|
||||||
const WORDS = {
|
|
||||||
en: { title: 'storebound', pin: 'Pin (stays open)', unpin: 'Unpin', close: 'Close', gone: 'This menu is gone for now.', filter: 'Filter', none: 'Nothing matches', tearOff: 'Ctrl+click or middle-click: pin' },
|
|
||||||
tr: { title: 'storebound', pin: 'Sabitle (açık kalır)', unpin: 'Sabitlemeyi kaldır', close: 'Kapat', gone: 'Bu menü şu an yok.', filter: 'Süz', none: 'Eşleşen yok', tearOff: 'Ctrl+tık veya orta tık: sabitle' },
|
|
||||||
} satisfies Record<'en' | 'tr', Record<string, string>>;
|
|
||||||
export type MenuLang = keyof typeof WORDS;
|
|
||||||
|
|
||||||
const ICON: Record<string, ReactNode> = {
|
|
||||||
'tray-open': <AppWindowIcon />, 'tray-read': <ArrowsClockwiseIcon />, 'tray-mute': <BellSlashIcon />,
|
|
||||||
'tray-update': <DownloadSimpleIcon />, 'tray-settings': <GearSixIcon />, 'tray-quit': <PowerIcon />,
|
|
||||||
};
|
|
||||||
const iconOf = (n: Row): ReactNode => (n.kind === 'sub' ? <SquaresFourIcon /> : ICON[n.id] ?? (n.id.startsWith('tray-app:') ? <DeviceMobileIcon /> : null));
|
|
||||||
|
|
||||||
export function TrayMenu({ nodes, path, pinned, hasParent, focusFirst, bridge, lang = 'en', openKey }: {
|
|
||||||
nodes: MenuNode[]; path: string[]; pinned: boolean; hasParent: boolean; focusFirst?: boolean; bridge: MenuBridge; lang?: MenuLang;
|
|
||||||
/** The submenu shown as open (the dev demo; in the app Rust knows). */
|
|
||||||
openKey?: string;
|
|
||||||
}) {
|
|
||||||
const w = WORDS[lang];
|
|
||||||
const ref = useRef<HTMLDivElement>(null);
|
|
||||||
const [query, setQuery] = useState('');
|
|
||||||
const [active, setActive] = useState(-1);
|
|
||||||
const [open, setOpen] = useState<string | null>(openKey ?? null);
|
|
||||||
const hover = useRef<number | undefined>(undefined);
|
|
||||||
const found = useMemo(() => findPath(nodes, path), [nodes, path]);
|
|
||||||
const items = useMemo(() => (found ? filterNodes(found.items, query) : []), [found, query]);
|
|
||||||
const list = useMemo(() => rows(items), [items]);
|
|
||||||
const prev = useRef<Row[]>(list);
|
|
||||||
|
|
||||||
// a live update keeps the highlight on the same row
|
|
||||||
useEffect(() => {
|
|
||||||
setActive(a => keepActive(prev.current, list, a));
|
|
||||||
prev.current = list;
|
|
||||||
}, [list]);
|
|
||||||
useEffect(() => {
|
|
||||||
if (focusFirst) setActive(nextIndex(-1, 1, list.map(isEnabled)));
|
|
||||||
ref.current?.focus({ preventScroll: true });
|
|
||||||
// only on the first render
|
|
||||||
}, []);
|
|
||||||
useEffect(() => () => window.clearTimeout(hover.current), []);
|
|
||||||
|
|
||||||
// the window takes the panel's size (Rust places it inside the work area)
|
|
||||||
useLayoutEffect(() => {
|
|
||||||
const el = ref.current;
|
|
||||||
if (!el) return;
|
|
||||||
let last = '';
|
|
||||||
const report = () => {
|
|
||||||
const r = el.getBoundingClientRect();
|
|
||||||
const size = `${Math.ceil(r.width)}x${Math.ceil(r.height)}`;
|
|
||||||
if (size !== last) { last = size; bridge.ready(Math.ceil(r.width), Math.ceil(r.height)); }
|
|
||||||
};
|
|
||||||
report();
|
|
||||||
const ro = new ResizeObserver(report);
|
|
||||||
ro.observe(el);
|
|
||||||
return () => ro.disconnect();
|
|
||||||
}, [bridge]);
|
|
||||||
|
|
||||||
const rowTop = (i: number) => ref.current?.querySelector<HTMLElement>(`[data-i="${i}"]`)?.getBoundingClientRect().top ?? 0;
|
|
||||||
const openSub = (i: number, focus: boolean) => {
|
|
||||||
const n = list[i];
|
|
||||||
if (n?.kind !== 'sub') return;
|
|
||||||
setOpen(n.key);
|
|
||||||
bridge.openSub(n.key, rowTop(i), focus);
|
|
||||||
};
|
|
||||||
const pick = (i: number, e?: { button: number; ctrlKey: boolean; metaKey: boolean }) => {
|
|
||||||
const n = list[i];
|
|
||||||
if (!n || !isEnabled(n)) return;
|
|
||||||
if (n.kind === 'sub') {
|
|
||||||
if (e && isTearOff(e)) { bridge.pinSub(n.key, rowTop(i)); return; }
|
|
||||||
openSub(i, !e);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
bridge.select(n.id);
|
|
||||||
};
|
|
||||||
const back = () => (hasParent ? bridge.close(true) : pinned ? undefined : bridge.dismiss());
|
|
||||||
|
|
||||||
const onKey = (e: KeyboardEvent) => {
|
|
||||||
const k = e.key;
|
|
||||||
const en = list.map(isEnabled);
|
|
||||||
const stop = () => { e.preventDefault(); e.stopPropagation(); };
|
|
||||||
if (k === 'ArrowDown') { stop(); setActive(a => nextIndex(a, 1, en)); }
|
|
||||||
else if (k === 'ArrowUp') { stop(); setActive(a => nextIndex(a, -1, en)); }
|
|
||||||
else if (k === 'Home' || k === 'PageUp') { stop(); setActive(nextIndex(-1, 1, en)); }
|
|
||||||
else if (k === 'End' || k === 'PageDown') { stop(); setActive(nextIndex(-1, -1, en)); }
|
|
||||||
else if (k === 'Enter' || k === ' ') { stop(); if (active >= 0) pick(active); }
|
|
||||||
else if (k === 'ArrowRight') { stop(); if (list[active]?.kind === 'sub') openSub(active, true); }
|
|
||||||
else if (k === 'ArrowLeft') { stop(); if (hasParent) bridge.close(true); }
|
|
||||||
else if (k === 'Escape') { stop(); if (query) setQuery(''); else if (pinned) bridge.close(false); else back(); }
|
|
||||||
else if (k === 'Backspace') { stop(); setQuery(q => q.slice(0, -1)); }
|
|
||||||
else if (k.length === 1 && !e.ctrlKey && !e.metaKey && !e.altKey) { stop(); setQuery(q => q + k); setActive(0); }
|
|
||||||
};
|
|
||||||
|
|
||||||
// a pinned panel whose submenu is gone keeps a name: its key
|
|
||||||
const title = !found ? (path[path.length - 1] ?? w.title).replace(/-/g, ' ') : found.label == null ? w.title : split(found.label).text;
|
|
||||||
const onRowMove = (i: number, n: Row) => {
|
|
||||||
if (active !== i) setActive(isEnabled(n) ? i : -1);
|
|
||||||
window.clearTimeout(hover.current);
|
|
||||||
if (n.kind === 'sub') {
|
|
||||||
if (open !== n.key) hover.current = window.setTimeout(() => openSub(i, false), 120);
|
|
||||||
} else if (open) {
|
|
||||||
hover.current = window.setTimeout(() => { setOpen(null); bridge.closeSubs(); }, 200);
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
return (
|
|
||||||
<div ref={ref} className={`tm-panel${pinned ? ' pinned' : ''}`} role="menu" tabIndex={-1} onKeyDown={onKey} aria-label={title}
|
|
||||||
onContextMenu={e => e.preventDefault()}>
|
|
||||||
<div className="tm-head" data-tauri-drag-region={pinned ? '' : undefined}>
|
|
||||||
<span className="tm-title" data-tauri-drag-region={pinned ? '' : undefined}>{query ? <><span className="tm-q">{query}</span><span className="tm-caret" /></> : title}</span>
|
|
||||||
<button type="button" className={`tm-btn${pinned ? ' on' : ''}`} title={pinned ? w.unpin : w.pin} aria-label={pinned ? w.unpin : w.pin} aria-pressed={pinned}
|
|
||||||
onClick={() => bridge.pin(!pinned)}>{pinned ? <PushPinSlashIcon /> : <PushPinIcon />}</button>
|
|
||||||
{pinned && <button type="button" className="tm-btn" title={w.close} aria-label={w.close} onClick={() => bridge.close(false)}><XIcon /></button>}
|
|
||||||
</div>
|
|
||||||
{!found && <div className="tm-gone">{w.gone}</div>}
|
|
||||||
{found && !list.length && <div className="tm-gone">{query ? w.none : '—'}</div>}
|
|
||||||
{items.map((n, idx) => {
|
|
||||||
if (n.kind === 'sep') return <div key={`s${idx}`} className="ds-menu-sep" role="separator" />;
|
|
||||||
const i = list.indexOf(n);
|
|
||||||
const { text, value } = split(n.label);
|
|
||||||
const dis = !isEnabled(n);
|
|
||||||
return (
|
|
||||||
<div key={n.kind === 'sub' ? `sub:${n.key}` : n.id} data-i={i} role="menuitem" aria-disabled={dis || undefined}
|
|
||||||
aria-haspopup={n.kind === 'sub' ? 'menu' : undefined} aria-expanded={n.kind === 'sub' ? open === n.key : undefined}
|
|
||||||
title={n.kind === 'sub' ? w.tearOff : undefined}
|
|
||||||
className={`ds-menu-item tm-row${i === active ? ' active' : ''}${dis ? ' disabled' : ''}${n.kind === 'sub' && open === n.key ? ' open' : ''}`}
|
|
||||||
onPointerMove={() => onRowMove(i, n)}
|
|
||||||
onMouseDown={(e: MouseEvent) => { if (e.button === 1) e.preventDefault(); }}
|
|
||||||
onAuxClick={(e: MouseEvent) => { if (e.button === 1) pick(i, e); }}
|
|
||||||
onClick={(e: MouseEvent) => pick(i, e)}>
|
|
||||||
<span className="ds-menu-ic">{iconOf(n)}</span>
|
|
||||||
<span className="ds-menu-l">{text}</span>
|
|
||||||
{value && <span className="tm-value">{value}</span>}
|
|
||||||
{n.kind === 'sub' && <CaretRightIcon className="ds-menu-sub" />}
|
|
||||||
</div>
|
|
||||||
);
|
|
||||||
})}
|
|
||||||
</div>
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
@ -1,55 +0,0 @@
|
||||||
// Dev only (a plain browser, never in the release bundle): the tray menu panels on fixture data, as the tray would show
|
|
||||||
// them: the root menu with Apps open beside it and a pinned Apps panel, whose values change every few seconds the way a
|
|
||||||
// store read changes them (the panels update in place).
|
|
||||||
import { useEffect, useMemo, useState } from 'react';
|
|
||||||
import type { MenuNode } from './model';
|
|
||||||
import { type MenuBridge, type MenuLang, TrayMenu } from './TrayMenu';
|
|
||||||
|
|
||||||
const STATES = [
|
|
||||||
['App Store: In review · Play: Live', 'App Store: Ready for sale · Play: Live'],
|
|
||||||
['Play: Rolling out 20%', 'Play: Rolling out 50%', 'Play: Rolling out 100%'],
|
|
||||||
['App Store: Rejected', 'App Store: Rejected'],
|
|
||||||
['App Store: Waiting for review', 'App Store: In review'],
|
|
||||||
];
|
|
||||||
const NAMES = ['Star Dash', 'Puzzle Garden', 'Pocket Chef', 'Night Runner'];
|
|
||||||
|
|
||||||
/** The tree tray.rs builds (menu_model), with fixture apps. */
|
|
||||||
export function demoNodes(tick: number, lang: MenuLang): MenuNode[] {
|
|
||||||
const tr = lang === 'tr';
|
|
||||||
const item = (id: string, label: string, enabled = true): MenuNode => ({ kind: 'item', id, label, enabled });
|
|
||||||
return [
|
|
||||||
item('tray-open', tr ? 'storebound\'u aç' : 'Open storebound'),
|
|
||||||
item('tray-read', tr ? 'Mağazaları şimdi oku' : 'Read the stores now'),
|
|
||||||
{ kind: 'sep' },
|
|
||||||
{ kind: 'sub', key: 'apps', label: tr ? 'Uygulamalar' : 'Apps', items: NAMES.map((n, i) => item(`tray-app:k${i}`, `${n} · ${STATES[i]![tick % STATES[i]!.length]}`)) },
|
|
||||||
{ kind: 'sep' },
|
|
||||||
item('tray-mute', tr ? 'Bildirimleri 1 saat sustur' : 'Mute notifications for 1 hour'),
|
|
||||||
item('tray-update', tr ? 'Güncellemeleri denetle' : 'Check for updates'),
|
|
||||||
item('tray-settings', tr ? 'Ayarlar' : 'Settings'),
|
|
||||||
{ kind: 'sep' },
|
|
||||||
item('tray-quit', tr ? 'storebound\'dan çık' : 'Quit storebound'),
|
|
||||||
];
|
|
||||||
}
|
|
||||||
|
|
||||||
const log = (what: string) => (...a: unknown[]) => console.info('tray menu', what, ...a);
|
|
||||||
const demoBridge: MenuBridge = { ready: () => {}, openSub: log('openSub'), pinSub: log('pinSub'), closeSubs: () => {}, close: log('close'), dismiss: log('dismiss'), pin: log('pin'), select: log('select') };
|
|
||||||
|
|
||||||
export function Demo({ lang }: { lang: MenuLang }) {
|
|
||||||
const [tick, setTick] = useState(0);
|
|
||||||
const q = new URLSearchParams(location.search);
|
|
||||||
const still = q.has('still');
|
|
||||||
useEffect(() => {
|
|
||||||
if (still) return;
|
|
||||||
const t = window.setInterval(() => setTick(n => n + 1), 3000);
|
|
||||||
return () => window.clearInterval(t);
|
|
||||||
}, [still]);
|
|
||||||
const nodes = useMemo(() => demoNodes(tick, lang), [tick, lang]);
|
|
||||||
return (
|
|
||||||
<>
|
|
||||||
<div className="tm-demo-at" style={{ left: 24, top: 160 }}><TrayMenu nodes={nodes} path={[]} pinned={false} hasParent={false} bridge={demoBridge} lang={lang} openKey="apps" /></div>
|
|
||||||
<div className="tm-demo-at" style={{ left: 262, top: 262 }}><TrayMenu nodes={nodes} path={['apps']} pinned={false} hasParent focusFirst bridge={demoBridge} lang={lang} /></div>
|
|
||||||
<div className="tm-demo-at" style={{ left: 690, top: 24 }}><TrayMenu nodes={nodes} path={['apps']} pinned hasParent={false} bridge={demoBridge} lang={lang} /></div>
|
|
||||||
<div className="tm-demo-at" style={{ left: 690, top: 260 }}><TrayMenu nodes={nodes} path={['gone']} pinned hasParent={false} bridge={demoBridge} lang={lang} /></div>
|
|
||||||
</>
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
@ -1,70 +0,0 @@
|
||||||
// The tray menu panel window's entry (tray-menu.html; one window per panel, made by menu_panel.rs). Theme and language
|
|
||||||
// from the same prefs as the main window; the tree and every live update from Rust (`menu-model`). In a plain dev
|
|
||||||
// browser it shows a demo with fixture data instead (demo.tsx, never in the release bundle).
|
|
||||||
import { useEffect, useState } from 'react';
|
|
||||||
import { createRoot } from 'react-dom/client';
|
|
||||||
import { applyPrefs, loadPrefs, resolveLang } from '../prefs';
|
|
||||||
import { bridge, inTauri, menuState, onModel, onPanel } from './menu-api';
|
|
||||||
import type { MenuNode, PanelInfo } from './model';
|
|
||||||
import { type MenuLang, TrayMenu } from './TrayMenu';
|
|
||||||
import '../styles.css';
|
|
||||||
import '../design.css';
|
|
||||||
import './traymenu.css';
|
|
||||||
|
|
||||||
const sys = () => (typeof navigator !== 'undefined' ? navigator.language : 'en');
|
|
||||||
|
|
||||||
function prefs(): MenuLang {
|
|
||||||
const p = loadPrefs();
|
|
||||||
if (import.meta.env.DEV) {
|
|
||||||
const q = new URLSearchParams(location.search);
|
|
||||||
const th = q.get('theme'), lg = q.get('lang');
|
|
||||||
if (th === 'light' || th === 'dark') p.theme = th;
|
|
||||||
if (lg === 'en' || lg === 'tr') p.lang = lg;
|
|
||||||
}
|
|
||||||
applyPrefs(p, document.documentElement, sys());
|
|
||||||
return resolveLang(p.lang, sys());
|
|
||||||
}
|
|
||||||
|
|
||||||
/** One panel window: its state from Rust, the live tree, pin changes. */
|
|
||||||
function Panel({ lang }: { lang: MenuLang }) {
|
|
||||||
const [info, setInfo] = useState<PanelInfo | null>(null);
|
|
||||||
const [nodes, setNodes] = useState<MenuNode[]>([]);
|
|
||||||
const [pinned, setPinned] = useState(false);
|
|
||||||
const [focusTick, setFocusTick] = useState(0);
|
|
||||||
useEffect(() => {
|
|
||||||
let live = true;
|
|
||||||
const offs = [
|
|
||||||
onModel(setNodes),
|
|
||||||
onPanel(word => {
|
|
||||||
if (word === 'pinned') setPinned(true);
|
|
||||||
else if (word === 'unpinned') setPinned(false);
|
|
||||||
else if (word === 'focus') setFocusTick(n => n + 1);
|
|
||||||
}),
|
|
||||||
];
|
|
||||||
menuState().then((s: PanelInfo | null) => {
|
|
||||||
if (!live || !s) return;
|
|
||||||
setInfo(s);
|
|
||||||
setNodes(s.nodes);
|
|
||||||
setPinned(s.pinned);
|
|
||||||
}, () => {});
|
|
||||||
return () => { live = false; for (const off of offs) off(); };
|
|
||||||
}, []);
|
|
||||||
useEffect(() => { if (focusTick) document.querySelector<HTMLElement>('.tm-panel')?.focus(); }, [focusTick]);
|
|
||||||
if (!info) return null;
|
|
||||||
return <TrayMenu nodes={nodes} path={info.path} pinned={pinned} hasParent={info.hasParent && !pinned} focusFirst={info.focusFirst} bridge={bridge} lang={lang} />;
|
|
||||||
}
|
|
||||||
|
|
||||||
void (async () => {
|
|
||||||
let lang = prefs();
|
|
||||||
const root = createRoot(document.getElementById('menu')!);
|
|
||||||
if (!inTauri() && import.meta.env.DEV) {
|
|
||||||
const { Demo } = await import('./demo');
|
|
||||||
document.body.classList.add('tm-demo');
|
|
||||||
root.render(<Demo lang={lang} />);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
const render = () => root.render(<Panel key={lang} lang={lang} />);
|
|
||||||
render();
|
|
||||||
// theme or language changed in the main window (same origin: shared localStorage)
|
|
||||||
window.addEventListener('storage', () => { const l = prefs(); if (l !== lang) { lang = l; render(); } });
|
|
||||||
})();
|
|
||||||
|
|
@ -1,33 +0,0 @@
|
||||||
// The tray menu panels' host calls (the panel page's counterpart of src/api.ts, kept apart so the panel bundle stays
|
|
||||||
// small). Only `menu-*` windows may call these (capabilities/menu.json; every command re-checks the window in Rust).
|
|
||||||
import { invoke } from '@tauri-apps/api/core';
|
|
||||||
import { listen } from '@tauri-apps/api/event';
|
|
||||||
import type { MenuNode, PanelInfo } from './model';
|
|
||||||
import type { MenuBridge } from './TrayMenu';
|
|
||||||
|
|
||||||
export const inTauri = (): boolean => typeof window !== 'undefined' && '__TAURI_INTERNALS__' in window;
|
|
||||||
|
|
||||||
const call = (cmd: string, args?: Record<string, unknown>) => { invoke(cmd, args).catch(() => {}); };
|
|
||||||
|
|
||||||
function sub<T>(ev: string, fn: (p: T) => void): () => void {
|
|
||||||
const un = listen<T>(ev, e => fn(e.payload));
|
|
||||||
return () => { un.then(f => f()).catch(() => {}); };
|
|
||||||
}
|
|
||||||
|
|
||||||
/** This panel: its path into the tree, pinned or not, and the tree now. */
|
|
||||||
export const menuState = (): Promise<PanelInfo | null> => invoke<PanelInfo | null>('menu_state').catch(() => null);
|
|
||||||
/** Every change of the tree (a store read, mute, language): the panel updates in place. */
|
|
||||||
export const onModel = (fn: (nodes: MenuNode[]) => void) => sub<MenuNode[]>('menu-model', fn);
|
|
||||||
/** Rust about this panel: `pinned`, `unpinned`, `focus`. */
|
|
||||||
export const onPanel = (fn: (word: string) => void) => sub<string>('menu-panel', fn);
|
|
||||||
|
|
||||||
export const bridge: MenuBridge = {
|
|
||||||
ready: (width, height) => call('menu_ready', { width, height }),
|
|
||||||
openSub: (key, top, focus) => call('menu_open_sub', { key, top, focus }),
|
|
||||||
pinSub: (key, top) => call('menu_pin_sub', { key, top }),
|
|
||||||
closeSubs: () => call('menu_close_subs'),
|
|
||||||
close: refocusParent => call('menu_close', { refocusParent }),
|
|
||||||
dismiss: () => call('menu_dismiss'),
|
|
||||||
pin: pinned => call('menu_pin', { pinned }),
|
|
||||||
select: id => call('menu_select', { id }),
|
|
||||||
};
|
|
||||||
|
|
@ -1,75 +0,0 @@
|
||||||
// The tray menu panels' pure half (tested in tests/tray-menu.test.ts): the tree Rust sends (menu_panel.rs `Node`),
|
|
||||||
// walking it by stable submenu keys, splitting a row into its text and live value, type-to-filter, keyboard moves and
|
|
||||||
// keeping the highlighted row on the same item when a live update arrives.
|
|
||||||
|
|
||||||
export type MenuNode =
|
|
||||||
| { kind: 'item'; id: string; label: string; enabled: boolean }
|
|
||||||
| { kind: 'sep' }
|
|
||||||
| { kind: 'sub'; key: string; label: string; items: MenuNode[] };
|
|
||||||
export type Row = Exclude<MenuNode, { kind: 'sep' }>;
|
|
||||||
|
|
||||||
/** What menu_state returns for one panel window. */
|
|
||||||
export interface PanelInfo {
|
|
||||||
label: string;
|
|
||||||
path: string[];
|
|
||||||
pinned: boolean;
|
|
||||||
hasParent: boolean;
|
|
||||||
focusFirst: boolean;
|
|
||||||
nodes: MenuNode[];
|
|
||||||
}
|
|
||||||
|
|
||||||
/** "First · App Store: In review" -> { text: 'First', value: 'App Store: In review' } (the value is right-aligned). */
|
|
||||||
export function split(label: string): { text: string; value?: string } {
|
|
||||||
const at = label.indexOf('·');
|
|
||||||
if (at <= 0) return { text: label.trim() };
|
|
||||||
const value = label.slice(at + 1).trim();
|
|
||||||
return value ? { text: label.slice(0, at).trim(), value } : { text: label.slice(0, at).trim() };
|
|
||||||
}
|
|
||||||
|
|
||||||
/** The items at `path` (submenu keys) and the submenu's label, or null when that submenu is gone. */
|
|
||||||
export function findPath(nodes: readonly MenuNode[], path: readonly string[]): { items: MenuNode[]; label: string | null } | null {
|
|
||||||
let items = nodes as MenuNode[];
|
|
||||||
let label: string | null = null;
|
|
||||||
for (const key of path) {
|
|
||||||
const next = items.find((n): n is Extract<MenuNode, { kind: 'sub' }> => n.kind === 'sub' && n.key === key);
|
|
||||||
if (!next) return null;
|
|
||||||
items = next.items;
|
|
||||||
label = next.label;
|
|
||||||
}
|
|
||||||
return { items, label };
|
|
||||||
}
|
|
||||||
|
|
||||||
/** Type-to-filter: rows whose label holds every word; separators drop out while filtering. */
|
|
||||||
export function filterNodes(items: readonly MenuNode[], query: string): MenuNode[] {
|
|
||||||
const words = query.toLocaleLowerCase().split(/\s+/).filter(Boolean);
|
|
||||||
if (!words.length) return items as MenuNode[];
|
|
||||||
return items.filter(n => n.kind !== 'sep' && words.every(w => n.label.toLocaleLowerCase().includes(w)));
|
|
||||||
}
|
|
||||||
|
|
||||||
export const rows = (items: readonly MenuNode[]): Row[] => items.filter((n): n is Row => n.kind !== 'sep');
|
|
||||||
export const isEnabled = (n: Row): boolean => n.kind === 'sub' || n.enabled;
|
|
||||||
export const rowId = (n: Row): string => (n.kind === 'sub' ? `sub:${n.key}` : n.id);
|
|
||||||
|
|
||||||
/** The next enabled row from `current` in `dir`, wrapping; -1 when none. `current` -1 starts before the first. */
|
|
||||||
export function nextIndex(current: number, dir: 1 | -1, enabled: readonly boolean[]): number {
|
|
||||||
const n = enabled.length;
|
|
||||||
if (!n) return -1;
|
|
||||||
const from = current < 0 ? (dir > 0 ? -1 : n) : current;
|
|
||||||
for (let step = 1; step <= n; step += 1) {
|
|
||||||
const i = (((from + dir * step) % n) + n) % n;
|
|
||||||
if (enabled[i]) return i;
|
|
||||||
}
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
|
|
||||||
/** A live update must not move the highlight: the same id / key in the new rows, else the same place (clamped). */
|
|
||||||
export function keepActive(before: readonly Row[], after: readonly Row[], active: number): number {
|
|
||||||
if (active < 0 || !after.length) return -1;
|
|
||||||
const was = before[active];
|
|
||||||
if (!was) return Math.min(active, after.length - 1);
|
|
||||||
const found = after.findIndex(n => rowId(n) === rowId(was));
|
|
||||||
return found >= 0 ? found : Math.min(active, after.length - 1);
|
|
||||||
}
|
|
||||||
|
|
||||||
/** Ctrl / Cmd + click or a middle click on a submenu row tears it off as a pinned panel. */
|
|
||||||
export const isTearOff = (e: { button: number; ctrlKey: boolean; metaKey: boolean }): boolean => e.button === 1 || ((e.ctrlKey || e.metaKey) && e.button === 0);
|
|
||||||
|
|
@ -1,28 +0,0 @@
|
||||||
/* The tray menu panels (tray-menu.html): the design system's menu (.ds-menu-*) in its own small window. The window is
|
|
||||||
transparent and exactly as large as the panel (menu_panel.rs sizes it from what the panel measures). */
|
|
||||||
html:has(body.tm-page), body.tm-page { margin: 0; background: transparent; overflow: hidden; }
|
|
||||||
body.tm-page { font: var(--ds-t-body)/1.4 system-ui, -apple-system, "Segoe UI", sans-serif; color: var(--ink); }
|
|
||||||
|
|
||||||
.tm-panel { box-sizing: border-box; width: max-content; min-width: 230px; max-width: 380px; max-height: 860px; overflow: auto; padding: 4px 5px 5px;
|
|
||||||
border-radius: 12px; background: var(--ds-raised); border: 1px solid var(--ds-stroke-strong);
|
|
||||||
font-size: var(--ds-t-body); color: var(--ink); outline: none; user-select: none; cursor: default; }
|
|
||||||
.tm-panel.pinned { border-color: color-mix(in srgb, var(--accent) 45%, var(--ds-stroke-strong)); }
|
|
||||||
.tm-head { display: flex; align-items: center; gap: 2px; height: 28px; padding: 0 2px 0 9px; margin-bottom: 2px; }
|
|
||||||
.tm-panel.pinned .tm-head { cursor: grab; }
|
|
||||||
.tm-title { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: var(--ds-t-micro);
|
|
||||||
font-weight: 600; letter-spacing: .04em; text-transform: uppercase; color: var(--muted); }
|
|
||||||
.tm-q { text-transform: none; letter-spacing: 0; color: var(--ink); font-weight: 500; }
|
|
||||||
.tm-caret { display: inline-block; width: 1px; height: 11px; margin-left: 1px; vertical-align: -1px; background: var(--accent); }
|
|
||||||
.tm-btn { flex: none; width: 24px; height: 24px; display: grid; place-items: center; padding: 0; border: 0; border-radius: 6px;
|
|
||||||
background: transparent; color: var(--faint); cursor: pointer; }
|
|
||||||
.tm-btn svg { width: 14px; height: 14px; }
|
|
||||||
.tm-btn:hover, .tm-btn:focus-visible { background: var(--ds-inset); color: var(--ink); outline: none; }
|
|
||||||
.tm-btn.on { color: var(--accent); }
|
|
||||||
.tm-row.open:not(.active) { background: var(--ds-inset); }
|
|
||||||
.tm-value { max-width: 190px; overflow: hidden; text-overflow: ellipsis; margin-left: 18px; color: var(--muted);
|
|
||||||
font-size: var(--ds-t-micro); font-variant-numeric: tabular-nums; }
|
|
||||||
.tm-gone { padding: 8px 10px 10px; color: var(--muted); font-size: var(--ds-t-micro); }
|
|
||||||
|
|
||||||
/* the dev demo (a plain browser): several panels side by side on a desktop-like backdrop */
|
|
||||||
body.tm-page.tm-demo { overflow: auto; min-height: 100vh; background: linear-gradient(135deg, #3b4a6b, #1d2436); }
|
|
||||||
.tm-demo-at { position: absolute; }
|
|
||||||
|
|
@ -1,64 +1,31 @@
|
||||||
// Context menus (design system): the browser's own menu never shows. ContextMenuProvider (main.tsx) prevents every
|
// Context menus (design system): the browser's own menu never shows. ContextMenuProvider (main.tsx) prevents every
|
||||||
// native `contextmenu`, opens a small Cut / Copy / Paste / Select all menu on text fields and a Copy menu on selected
|
// native `contextmenu`, opens a small Cut / Copy / Paste / Select all menu on text fields and a Copy menu on selected
|
||||||
// text, and turns Shift+F10 / the Menu key into a context menu on the focused element. Screens attach menus with
|
// text, and turns Shift+F10 / the Menu key into a context menu on the focused element. Screens attach menus with
|
||||||
// `useContextMenu()`: `<div {...menu(() => [...entries], 'app:' + key)}>`. Keyboard: arrows, Home / End, Enter / Space,
|
// `useContextMenu()`: `<div {...menu(() => [...entries])}>`. Keyboard: arrows, Home / End, Enter / Space, Esc,
|
||||||
// Esc, ArrowRight / ArrowLeft for submenus, type-ahead. Logic (placement, moves, type-ahead) in menu-logic.ts.
|
// ArrowRight / ArrowLeft for submenus, type-ahead. Logic (placement, moves, type-ahead) in menu-logic.ts.
|
||||||
//
|
import { createContext, type KeyboardEvent as ReactKeyboardEvent, type MouseEvent as ReactMouseEvent, type ReactNode, useCallback, useContext, useEffect, useLayoutEffect, useId, useRef, useState } from 'react';
|
||||||
// Several menus at once (the same behaviour as the tray menu panels): a menu's pin button keeps it open as a floating
|
|
||||||
// panel; the pin button of a submenu, or Ctrl / Cmd / middle click on a submenu row, tears that submenu off as its own
|
|
||||||
// pinned panel. Pinned panels survive the next menu, can be dragged by their header, step aside so they never sit on
|
|
||||||
// each other, and update in place: they re-read their entries from the newest builder the screen registered (live
|
|
||||||
// sources, menu-stack.ts), so a read that changes a value never closes them. The panel stack is pure (menu-stack.ts).
|
|
||||||
import { createContext, type KeyboardEvent as ReactKeyboardEvent, type MouseEvent as ReactMouseEvent, type PointerEvent as ReactPointerEvent, type ReactNode, useCallback, useContext, useEffect, useId, useLayoutEffect, useReducer, useRef, useState } from 'react';
|
|
||||||
import { createPortal } from 'react-dom';
|
import { createPortal } from 'react-dom';
|
||||||
import { t } from '../i18n';
|
import { t } from '../i18n';
|
||||||
import { copyText } from '../lib/crash';
|
import { copyText } from '../lib/crash';
|
||||||
import { Icon } from './icons';
|
import { Icon } from './icons';
|
||||||
import { MOD } from './kit';
|
import { MOD } from './kit';
|
||||||
import { enabled, first, isEditable, isItem, last, type MenuEntry, type MenuInput, type MenuItem, move, placeAt, placeBeside, tidy, typeahead } from './menu-logic';
|
import { enabled, first, isEditable, isItem, last, type MenuEntry, type MenuInput, type MenuItem, move, placeAt, placeBeside, tidy, typeahead } from './menu-logic';
|
||||||
import { clampPos, closeMenu, closeUnpinned, LiveMenus, moveMenu, openMenu, pinMenu, type Pos, resolvePath, type StackEntry, tearOff, unpinMenu } from './menu-stack';
|
|
||||||
|
|
||||||
export type { MenuEntry, MenuInput, MenuItem } from './menu-logic';
|
export type { MenuEntry, MenuInput, MenuItem } from './menu-logic';
|
||||||
|
|
||||||
interface OpenOpts { from?: Element | null; keyboard?: boolean; source?: string | null }
|
interface Open { x: number; y: number; items: MenuEntry[]; from: Element | null; keyboard: boolean }
|
||||||
type OpenFn = (x: number, y: number, input: MenuInput, opts?: OpenOpts) => void;
|
type OpenFn = (x: number, y: number, input: MenuInput, opts?: { from?: Element | null; keyboard?: boolean }) => void;
|
||||||
const Ctx = createContext<OpenFn | null>(null);
|
const Ctx = createContext<OpenFn | null>(null);
|
||||||
|
|
||||||
/** Every screen's menu builders, newest first: what pinned panels re-read. */
|
|
||||||
const live = new LiveMenus();
|
|
||||||
|
|
||||||
/** Marks a native event a menu handled, so the global fallback leaves it alone. */
|
/** Marks a native event a menu handled, so the global fallback leaves it alone. */
|
||||||
const HANDLED = '__sbMenu';
|
const HANDLED = '__sbMenu';
|
||||||
/** Marks the contextmenu event Shift+F10 / the Menu key sent (the menu starts on its first item). */
|
/** Marks the contextmenu event Shift+F10 / the Menu key sent (the menu starts on its first item). */
|
||||||
const BY_KEY = '__sbKey';
|
const BY_KEY = '__sbKey';
|
||||||
|
|
||||||
/** One live source key per menu call of a component (`id` when given, else its call order in the render); the keys a
|
/** Props that attach a menu to an element: `<button {...menu(() => entries)}>`. Entries are built when it opens. */
|
||||||
* render no longer makes are dropped after it commits, all of them when the component unmounts. */
|
export function useContextMenu(): (build: () => MenuInput) => { onContextMenu: (e: ReactMouseEvent) => void } {
|
||||||
function useLiveKeys(): (id?: string) => string {
|
|
||||||
const hid = useId();
|
|
||||||
const seen = useRef(new Set<string>());
|
|
||||||
const n = useRef(0);
|
|
||||||
seen.current = new Set();
|
|
||||||
n.current = 0;
|
|
||||||
useEffect(() => { live.retain(hid, seen.current); });
|
|
||||||
useEffect(() => () => live.retain(hid), [hid]);
|
|
||||||
return useCallback((id?: string) => {
|
|
||||||
const k = `${hid}#${id ?? n.current++}`;
|
|
||||||
seen.current.add(k);
|
|
||||||
return k;
|
|
||||||
}, [hid]);
|
|
||||||
}
|
|
||||||
|
|
||||||
/** Props that attach a menu to an element: `<button {...menu(() => entries, id)}>`. Entries are built when it opens
|
|
||||||
* (and again for a pinned copy whenever the element re-renders). `id`: what the menu is about, unique in the component
|
|
||||||
* (an app key), so a pinned panel follows that thing even when rows reorder. */
|
|
||||||
export function useContextMenu(): (build: () => MenuInput, id?: string) => { onContextMenu: (e: ReactMouseEvent) => void } {
|
|
||||||
const open = useContext(Ctx);
|
const open = useContext(Ctx);
|
||||||
const key = useLiveKeys();
|
return useCallback((build: () => MenuInput) => ({
|
||||||
return useCallback((build: () => MenuInput, id?: string) => {
|
|
||||||
const source = key(id);
|
|
||||||
live.set(source, build);
|
|
||||||
return {
|
|
||||||
onContextMenu: (e: ReactMouseEvent) => {
|
onContextMenu: (e: ReactMouseEvent) => {
|
||||||
if ((e.nativeEvent as unknown as Record<string, unknown>)[HANDLED]) return;
|
if ((e.nativeEvent as unknown as Record<string, unknown>)[HANDLED]) return;
|
||||||
// a text field or a selection inside keeps the edit menu
|
// a text field or a selection inside keeps the edit menu
|
||||||
|
|
@ -67,28 +34,22 @@ export function useContextMenu(): (build: () => MenuInput, id?: string) => { onC
|
||||||
e.preventDefault();
|
e.preventDefault();
|
||||||
(e.nativeEvent as unknown as Record<string, unknown>)[HANDLED] = true;
|
(e.nativeEvent as unknown as Record<string, unknown>)[HANDLED] = true;
|
||||||
if (!open) return;
|
if (!open) return;
|
||||||
open(e.clientX, e.clientY, build(), { from: e.currentTarget as Element, keyboard: !!(e.nativeEvent as unknown as Record<string, unknown>)[BY_KEY], source });
|
open(e.clientX, e.clientY, build(), { from: e.currentTarget as Element, keyboard: !!(e.nativeEvent as unknown as Record<string, unknown>)[BY_KEY] });
|
||||||
},
|
},
|
||||||
};
|
}), [open]);
|
||||||
}, [open, key]);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Props for a "..." overflow button that opens the same menu under itself (click, Enter or Space). */
|
/** Props for a "..." overflow button that opens the same menu under itself (click, Enter or Space). */
|
||||||
export function useMenuButton(): (build: () => MenuInput, id?: string) => { onClick: (e: ReactMouseEvent) => void; 'aria-haspopup': 'menu' } {
|
export function useMenuButton(): (build: () => MenuInput) => { onClick: (e: ReactMouseEvent) => void; 'aria-haspopup': 'menu' } {
|
||||||
const open = useContext(Ctx);
|
const open = useContext(Ctx);
|
||||||
const key = useLiveKeys();
|
return useCallback((build: () => MenuInput) => ({
|
||||||
return useCallback((build: () => MenuInput, id?: string) => {
|
|
||||||
const source = key(id);
|
|
||||||
live.set(source, build);
|
|
||||||
return {
|
|
||||||
'aria-haspopup': 'menu' as const,
|
'aria-haspopup': 'menu' as const,
|
||||||
onClick: (e: ReactMouseEvent) => {
|
onClick: (e: ReactMouseEvent) => {
|
||||||
if (!open) return;
|
if (!open) return;
|
||||||
const r = (e.currentTarget as Element).getBoundingClientRect();
|
const r = (e.currentTarget as Element).getBoundingClientRect();
|
||||||
open(Math.round(r.left), Math.round(r.bottom + 4), build(), { from: e.currentTarget as Element, keyboard: e.detail === 0, source });
|
open(Math.round(r.left), Math.round(r.bottom + 4), build(), { from: e.currentTarget as Element, keyboard: e.detail === 0 });
|
||||||
},
|
},
|
||||||
};
|
}), [open]);
|
||||||
}, [open, key]);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Copies and says so in a toast-less way (the menu closes; failures are silent like the browser's own Copy). */
|
/** Copies and says so in a toast-less way (the menu closes; failures are silent like the browser's own Copy). */
|
||||||
|
|
@ -114,48 +75,19 @@ function editMenu(el: HTMLInputElement | HTMLTextAreaElement | HTMLElement): Men
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
|
|
||||||
/** What a panel was opened with (kept beside the pure stack entry). */
|
|
||||||
interface Extra { items: MenuEntry[]; from: Element | null; keyboard: boolean }
|
|
||||||
|
|
||||||
export function ContextMenuProvider({ children }: { children: ReactNode }) {
|
export function ContextMenuProvider({ children }: { children: ReactNode }) {
|
||||||
const [stack, setStack] = useState<StackEntry[]>([]);
|
const [state, setState] = useState<Open | null>(null);
|
||||||
const stackRef = useRef(stack);
|
|
||||||
stackRef.current = stack;
|
|
||||||
const extras = useRef(new Map<string, Extra>());
|
|
||||||
const seq = useRef(0);
|
|
||||||
const nextUid = () => `m${++seq.current}`;
|
|
||||||
|
|
||||||
const open = useCallback<OpenFn>((x, y, input, opts) => {
|
const open = useCallback<OpenFn>((x, y, input, opts) => {
|
||||||
const items = tidy(input);
|
const items = tidy(input);
|
||||||
if (!items.length) return;
|
if (!items.length) return;
|
||||||
const uid = nextUid();
|
setState({ x, y, items, from: opts?.from ?? (document.activeElement as Element | null), keyboard: !!opts?.keyboard });
|
||||||
extras.current.set(uid, { items, from: opts?.from ?? (document.activeElement as Element | null), keyboard: !!opts?.keyboard });
|
|
||||||
setStack(s => openMenu(s, { uid, source: opts?.source ?? null, path: [], pinned: false, x, y }));
|
|
||||||
}, []);
|
}, []);
|
||||||
/** Every unpinned menu closes; `restore` puts the focus back where the last one was opened. */
|
const close = useCallback((restore: boolean) => {
|
||||||
const closeTransient = useCallback((restore: boolean) => {
|
setState(s => {
|
||||||
const last = [...stackRef.current].reverse().find(e => !e.pinned);
|
if (restore && s?.from instanceof HTMLElement && s.from.isConnected) s.from.focus({ preventScroll: true });
|
||||||
if (!last) return;
|
return null;
|
||||||
const from = extras.current.get(last.uid)?.from;
|
});
|
||||||
if (restore && from instanceof HTMLElement && from.isConnected) from.focus({ preventScroll: true });
|
|
||||||
setStack(s => closeUnpinned(s));
|
|
||||||
}, []);
|
}, []);
|
||||||
const pin = useCallback((uid: string, pos: Pos) => setStack(s => pinMenu(s, uid, pos)), []);
|
|
||||||
/** A submenu at `path` of panel `uid` becomes its own pinned panel at `pos`. */
|
|
||||||
const tear = useCallback((uid: string, path: string[], pos: Pos, closeOthers: boolean) => {
|
|
||||||
const parent = stackRef.current.find(e => e.uid === uid);
|
|
||||||
const extra = extras.current.get(uid);
|
|
||||||
if (!parent || !extra) return;
|
|
||||||
const id = nextUid();
|
|
||||||
extras.current.set(id, { items: extra.items, from: null, keyboard: false });
|
|
||||||
setStack(s => tearOff(closeOthers ? closeUnpinned(s) : s, { uid: id, source: parent.source, path: [...parent.path, ...path], pinned: true, x: pos.x, y: pos.y }, pos));
|
|
||||||
}, []);
|
|
||||||
|
|
||||||
// what a closed panel was opened with is not kept
|
|
||||||
useEffect(() => {
|
|
||||||
const ids = new Set(stack.map(e => e.uid));
|
|
||||||
for (const k of [...extras.current.keys()]) if (!ids.has(k)) extras.current.delete(k);
|
|
||||||
}, [stack]);
|
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
// the fallback for everything no screen menu handled: never the browser's menu
|
// the fallback for everything no screen menu handled: never the browser's menu
|
||||||
|
|
@ -186,30 +118,15 @@ export function ContextMenuProvider({ children }: { children: ReactNode }) {
|
||||||
return () => { document.removeEventListener('contextmenu', onMenu); document.removeEventListener('keydown', onKey, true); };
|
return () => { document.removeEventListener('contextmenu', onMenu); document.removeEventListener('keydown', onKey, true); };
|
||||||
}, [open]);
|
}, [open]);
|
||||||
|
|
||||||
const hasTransient = stack.some(e => !e.pinned);
|
|
||||||
return (
|
return (
|
||||||
<Ctx.Provider value={open}>
|
<Ctx.Provider value={open}>
|
||||||
{children}
|
{children}
|
||||||
{stack.length > 0 && createPortal(<>
|
{state && createPortal(<MenuRoot key={`${state.x},${state.y}`} state={state} close={close} />, document.body)}
|
||||||
{hasTransient && <OutsideCloser close={closeTransient} />}
|
|
||||||
{stack.map(e => {
|
|
||||||
const extra = extras.current.get(e.uid);
|
|
||||||
if (!extra) return null;
|
|
||||||
return e.pinned
|
|
||||||
? <PinnedPanel key={e.uid} entry={e} extra={extra} closeTransient={closeTransient}
|
|
||||||
onClose={() => setStack(s => closeMenu(s, e.uid))} onUnpin={() => setStack(s => unpinMenu(s, e.uid))}
|
|
||||||
onMove={p => setStack(s => moveMenu(s, e.uid, p))} onTear={(path, p) => tear(e.uid, path, p, false)} />
|
|
||||||
: <MenuList key={e.uid} items={extra.items} at={{ x: e.x, y: e.y }} close={closeTransient} root keyboard={extra.keyboard} path={[]}
|
|
||||||
onPin={r => pin(e.uid, { x: r.left, y: r.top })} onTear={(path, p, others) => tear(e.uid, path, p, others)} />;
|
|
||||||
})}
|
|
||||||
</>, document.body)}
|
|
||||||
</Ctx.Provider>
|
</Ctx.Provider>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
/** While a normal menu is open: a click outside every menu, a scroll outside, blur or resize closes it (pinned panels
|
function MenuRoot({ state, close }: { state: Open; close: (restore: boolean) => void }) {
|
||||||
* stay). */
|
|
||||||
function OutsideCloser({ close }: { close: (restore: boolean) => void }) {
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
const outside = (e: Event) => { if (!(e.target as Element | null)?.closest?.('.ds-menu')) close(false); };
|
const outside = (e: Event) => { if (!(e.target as Element | null)?.closest?.('.ds-menu')) close(false); };
|
||||||
const scroll = (e: Event) => { if (!(e.target instanceof Element && e.target.closest('.ds-menu'))) close(false); };
|
const scroll = (e: Event) => { if (!(e.target instanceof Element && e.target.closest('.ds-menu'))) close(false); };
|
||||||
|
|
@ -225,43 +142,12 @@ function OutsideCloser({ close }: { close: (restore: boolean) => void }) {
|
||||||
window.removeEventListener('resize', blur);
|
window.removeEventListener('resize', blur);
|
||||||
};
|
};
|
||||||
}, [close]);
|
}, [close]);
|
||||||
return null;
|
return <MenuList items={state.items} at={{ x: state.x, y: state.y }} close={close} root keyboard={state.keyboard} />;
|
||||||
}
|
}
|
||||||
|
|
||||||
/** A pinned panel: its entries re-read from the live source on every change of the screen that registered it. */
|
type Anchor = { x: number; y: number } | { left: number; right: number; top: number };
|
||||||
function PinnedPanel({ entry, extra, closeTransient, onClose, onUnpin, onMove, onTear }: {
|
|
||||||
entry: StackEntry; extra: Extra; closeTransient: (restore: boolean) => void; onClose: () => void; onUnpin: () => void;
|
|
||||||
onMove: (p: Pos) => void; onTear: (path: string[], p: Pos) => void;
|
|
||||||
}) {
|
|
||||||
const [, bump] = useReducer((n: number) => n + 1, 0);
|
|
||||||
useEffect(() => (entry.source ? live.watch(entry.source, bump) : undefined), [entry.source]);
|
|
||||||
const root = entry.source ? live.get(entry.source) ?? null : extra.items;
|
|
||||||
const items = root ? resolvePath(root, entry.path) : null;
|
|
||||||
const title = entry.path.length ? entry.path[entry.path.length - 1]! : t('cm.menu');
|
|
||||||
return (
|
|
||||||
<MenuList items={items ?? []} gone={!items} at={{ fx: entry.x, fy: entry.y }} close={() => {}} root path={[]}
|
|
||||||
pinned={{ title, onClose, onUnpin, onMove }} done={() => closeTransient(false)} onTear={(path, p) => onTear(path, p)} />
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
type Anchor = { x: number; y: number } | { left: number; right: number; top: number } | { fx: number; fy: number };
|
function MenuList({ items, at, close, root, keyboard, onBack }: { items: MenuEntry[]; at: Anchor; close: (restore: boolean) => void; root?: boolean; keyboard?: boolean; onBack?: () => void }) {
|
||||||
|
|
||||||
interface PinnedHead { title: string; onClose: () => void; onUnpin: () => void; onMove: (p: Pos) => void }
|
|
||||||
|
|
||||||
function MenuList({ items, at, close, root, keyboard, onBack, path, onPin, onTear, pinned, gone, done }: {
|
|
||||||
items: MenuEntry[]; at: Anchor; close: (restore: boolean) => void; root?: boolean; keyboard?: boolean; onBack?: () => void;
|
|
||||||
/** Submenu labels from the panel's root to this list. */
|
|
||||||
path: string[];
|
|
||||||
/** The pin button of a normal (root) menu. */
|
|
||||||
onPin?: (rect: DOMRect) => void;
|
|
||||||
/** A submenu torn off: its path (from the panel root), where, and whether the normal menus close. */
|
|
||||||
onTear?: (path: string[], pos: Pos, closeOthers: boolean) => void;
|
|
||||||
/** This is a pinned panel's root list: header with title, unpin, close, drag. */
|
|
||||||
pinned?: PinnedHead;
|
|
||||||
gone?: boolean;
|
|
||||||
/** After a pick in a pinned panel (normal menus close; the panel stays). */
|
|
||||||
done?: () => void;
|
|
||||||
}) {
|
|
||||||
const uid = useId();
|
const uid = useId();
|
||||||
const ref = useRef<HTMLDivElement>(null);
|
const ref = useRef<HTMLDivElement>(null);
|
||||||
const [pos, setPos] = useState<{ left: number; top: number } | null>(null);
|
const [pos, setPos] = useState<{ left: number; top: number } | null>(null);
|
||||||
|
|
@ -269,33 +155,19 @@ function MenuList({ items, at, close, root, keyboard, onBack, path, onPin, onTea
|
||||||
const [sub, setSub] = useState<{ index: number; anchor: Anchor; focus: boolean } | null>(null);
|
const [sub, setSub] = useState<{ index: number; anchor: Anchor; focus: boolean } | null>(null);
|
||||||
const typed = useRef({ q: '', at: 0 });
|
const typed = useRef({ q: '', at: 0 });
|
||||||
const hoverTimer = useRef<number | undefined>(undefined);
|
const hoverTimer = useRef<number | undefined>(undefined);
|
||||||
const shown = useRef(false);
|
|
||||||
const drag = useRef<{ dx: number; dy: number } | null>(null);
|
|
||||||
const fixed = 'fx' in at ? at : null;
|
|
||||||
|
|
||||||
useLayoutEffect(() => {
|
useLayoutEffect(() => {
|
||||||
const el = ref.current;
|
const el = ref.current;
|
||||||
if (!el) return;
|
if (!el) return;
|
||||||
const box = { w: el.offsetWidth, h: el.offsetHeight }, view = { w: window.innerWidth, h: window.innerHeight };
|
const box = { w: el.offsetWidth, h: el.offsetHeight }, view = { w: window.innerWidth, h: window.innerHeight };
|
||||||
if ('fx' in at) { const p = clampPos({ x: at.fx, y: at.fy }, box, view); setPos({ left: p.x, top: p.y }); }
|
setPos('x' in at ? placeAt(at.x, at.y, box, view) : placeBeside(at, box, view));
|
||||||
else setPos('x' in at ? placeAt(at.x, at.y, box, view) : placeBeside(at, box, view));
|
}, [at]);
|
||||||
// a pinned panel follows its position (drag) and stays inside the window when it shrinks
|
|
||||||
}, ['fx' in at ? at.fx : 'x' in at ? at.x : at.left, 'fx' in at ? at.fy : 'x' in at ? at.y : at.top, items.length]);
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
if (!fixed) return;
|
if (!pos) return;
|
||||||
const onResize = () => { const el = ref.current; if (el) { const p = clampPos({ x: fixed.fx, y: fixed.fy }, { w: el.offsetWidth, h: el.offsetHeight }, { w: window.innerWidth, h: window.innerHeight }); setPos({ left: p.x, top: p.y }); } };
|
|
||||||
window.addEventListener('resize', onResize);
|
|
||||||
return () => window.removeEventListener('resize', onResize);
|
|
||||||
}, [fixed?.fx, fixed?.fy]);
|
|
||||||
useEffect(() => {
|
|
||||||
if (!pos || shown.current) return;
|
|
||||||
shown.current = true;
|
|
||||||
// a pinned panel never takes the focus by itself (it updates while the owner works elsewhere)
|
|
||||||
if (pinned) return;
|
|
||||||
ref.current?.focus({ preventScroll: true });
|
ref.current?.focus({ preventScroll: true });
|
||||||
// a submenu, or a menu opened from the keyboard, starts on its first item; a mouse-opened menu waits for a key
|
// a submenu, or a menu opened from the keyboard, starts on its first item; a mouse-opened menu waits for a key
|
||||||
if (!root || keyboard) setActive(first(items));
|
if (!root || keyboard) setActive(first(items));
|
||||||
}, [pos, root, keyboard, items, pinned]);
|
}, [pos, root, keyboard, items]);
|
||||||
useEffect(() => () => window.clearTimeout(hoverTimer.current), []);
|
useEffect(() => () => window.clearTimeout(hoverTimer.current), []);
|
||||||
|
|
||||||
const itemEl = (i: number) => ref.current?.querySelector<HTMLElement>(`[data-i="${i}"]`) ?? null;
|
const itemEl = (i: number) => ref.current?.querySelector<HTMLElement>(`[data-i="${i}"]`) ?? null;
|
||||||
|
|
@ -305,22 +177,11 @@ function MenuList({ items, at, close, root, keyboard, onBack, path, onPin, onTea
|
||||||
const r = el.getBoundingClientRect();
|
const r = el.getBoundingClientRect();
|
||||||
setSub({ index: i, anchor: { left: r.left, right: r.right, top: r.top }, focus });
|
setSub({ index: i, anchor: { left: r.left, right: r.right, top: r.top }, focus });
|
||||||
};
|
};
|
||||||
const tearAt = (i: number) => {
|
const choose = (i: number) => {
|
||||||
const e = items[i];
|
|
||||||
const el = itemEl(i);
|
|
||||||
if (!isItem(e) || !e.submenu || !el || !onTear) return;
|
|
||||||
const r = el.getBoundingClientRect();
|
|
||||||
onTear([...path, e.label], { x: Math.round(r.right + 6), y: Math.round(r.top - 30) }, false);
|
|
||||||
};
|
|
||||||
const choose = (i: number, ev?: { button: number; ctrlKey: boolean; metaKey: boolean }) => {
|
|
||||||
const e = items[i];
|
const e = items[i];
|
||||||
if (!enabled(e)) return;
|
if (!enabled(e)) return;
|
||||||
if (e.submenu) {
|
if (e.submenu) { openSub(i, true); return; }
|
||||||
if (ev && (ev.button === 1 || ev.ctrlKey || ev.metaKey)) { tearAt(i); return; }
|
close(true);
|
||||||
openSub(i, true);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
if (done) { setSub(null); done(); } else close(true);
|
|
||||||
// after the menu is gone, so the action sees the restored focus (paste, select all)
|
// after the menu is gone, so the action sees the restored focus (paste, select all)
|
||||||
window.setTimeout(() => e.onSelect?.(), 0);
|
window.setTimeout(() => e.onSelect?.(), 0);
|
||||||
};
|
};
|
||||||
|
|
@ -336,8 +197,8 @@ function MenuList({ items, at, close, root, keyboard, onBack, path, onPin, onTea
|
||||||
else if (k === 'Enter' || k === ' ') { stop(); if (active >= 0) choose(active); }
|
else if (k === 'Enter' || k === ' ') { stop(); if (active >= 0) choose(active); }
|
||||||
else if (k === 'ArrowRight') { stop(); const e = items[active]; if (enabled(e) && e.submenu) openSub(active, true); }
|
else if (k === 'ArrowRight') { stop(); const e = items[active]; if (enabled(e) && e.submenu) openSub(active, true); }
|
||||||
else if (k === 'ArrowLeft') { stop(); onBack?.(); }
|
else if (k === 'ArrowLeft') { stop(); onBack?.(); }
|
||||||
else if (k === 'Escape') { stop(); if (onBack) onBack(); else if (pinned) ref.current?.blur(); else close(true); }
|
else if (k === 'Escape') { stop(); if (onBack) onBack(); else close(true); }
|
||||||
else if (k === 'Tab') { stop(); if (!pinned) close(true); }
|
else if (k === 'Tab') { stop(); close(true); }
|
||||||
else if (k.length === 1 && !ev.ctrlKey && !ev.metaKey && !ev.altKey) {
|
else if (k.length === 1 && !ev.ctrlKey && !ev.metaKey && !ev.altKey) {
|
||||||
stop();
|
stop();
|
||||||
const now = Date.now();
|
const now = Date.now();
|
||||||
|
|
@ -350,44 +211,12 @@ function MenuList({ items, at, close, root, keyboard, onBack, path, onPin, onTea
|
||||||
|
|
||||||
useEffect(() => { if (active >= 0) itemEl(active)?.scrollIntoView({ block: 'nearest' }); }, [active]);
|
useEffect(() => { if (active >= 0) itemEl(active)?.scrollIntoView({ block: 'nearest' }); }, [active]);
|
||||||
|
|
||||||
// a pinned panel is dragged by its header
|
|
||||||
const onHeadDown = (e: ReactPointerEvent) => {
|
|
||||||
if (!pinned || e.button !== 0 || (e.target as Element).closest('button') || !pos) return;
|
|
||||||
drag.current = { dx: e.clientX - pos.left, dy: e.clientY - pos.top };
|
|
||||||
(e.currentTarget as Element).setPointerCapture(e.pointerId);
|
|
||||||
};
|
|
||||||
const onHeadMove = (e: ReactPointerEvent) => {
|
|
||||||
if (!drag.current || !pinned) return;
|
|
||||||
pinned.onMove({ x: Math.round(e.clientX - drag.current.dx), y: Math.round(e.clientY - drag.current.dy) });
|
|
||||||
};
|
|
||||||
const onHeadUp = () => { drag.current = null; };
|
|
||||||
|
|
||||||
// the header: a pinned panel's title, unpin and close; a normal menu's (or submenu's) pin button
|
|
||||||
const pinHere = () => {
|
|
||||||
if (pinned) return pinned.onUnpin();
|
|
||||||
const r = ref.current?.getBoundingClientRect();
|
|
||||||
if (!r) return;
|
|
||||||
if (path.length) onTear?.(path, { x: Math.round(r.left), y: Math.round(r.top) }, true);
|
|
||||||
else onPin?.(r);
|
|
||||||
};
|
|
||||||
const canPin = !!pinned || (path.length ? !!onTear : !!onPin);
|
|
||||||
const head = canPin && (
|
|
||||||
<div className={`ds-menu-head${pinned ? ' pinned' : ''}`} onPointerDown={onHeadDown} onPointerMove={onHeadMove} onPointerUp={onHeadUp} onPointerCancel={onHeadUp}>
|
|
||||||
<span className="ds-menu-title">{pinned ? pinned.title : path.length ? path[path.length - 1] : ''}</span>
|
|
||||||
<button type="button" className={`ds-menu-btn${pinned ? ' on' : ''}`} title={pinned ? t('cm.unpin') : t('cm.pin')} aria-label={pinned ? t('cm.unpin') : t('cm.pin')}
|
|
||||||
aria-pressed={!!pinned} onClick={pinHere}><Icon name={pinned ? 'pinOff' : 'pin'} /></button>
|
|
||||||
{pinned && <button type="button" className="ds-menu-btn" title={t('cm.closePanel')} aria-label={t('cm.closePanel')} onClick={pinned.onClose}><Icon name="x" /></button>}
|
|
||||||
</div>
|
|
||||||
);
|
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
<div ref={ref} className={`ds-menu${pos ? ' in' : ''}${pinned ? ' pinned' : ''}`} role="menu" tabIndex={-1} onKeyDown={onKey}
|
<div ref={ref} className={`ds-menu${pos ? ' in' : ''}`} role="menu" tabIndex={-1} onKeyDown={onKey}
|
||||||
style={pos ? { left: pos.left, top: pos.top } : { left: -9999, top: -9999 }}
|
style={pos ? { left: pos.left, top: pos.top } : { left: -9999, top: -9999 }}
|
||||||
aria-label={pinned?.title} aria-activedescendant={active >= 0 ? `${uid}-${active}` : undefined}
|
aria-activedescendant={active >= 0 ? `${uid}-${active}` : undefined}
|
||||||
onContextMenu={e => e.preventDefault()}>
|
onContextMenu={e => e.preventDefault()}>
|
||||||
{head}
|
|
||||||
{gone && <div className="ds-menu-gone">{t('cm.gone')}</div>}
|
|
||||||
{items.map((e, i) => {
|
{items.map((e, i) => {
|
||||||
if (!isItem(e)) return <div key={`s${i}`} className="ds-menu-sep" role="separator" />;
|
if (!isItem(e)) return <div key={`s${i}`} className="ds-menu-sep" role="separator" />;
|
||||||
const dis = !!e.disabled;
|
const dis = !!e.disabled;
|
||||||
|
|
@ -396,7 +225,7 @@ function MenuList({ items, at, close, root, keyboard, onBack, path, onPin, onTea
|
||||||
<div key={i} id={`${uid}-${i}`} data-i={i} role={checkable ? 'menuitemcheckbox' : 'menuitem'}
|
<div key={i} id={`${uid}-${i}`} data-i={i} role={checkable ? 'menuitemcheckbox' : 'menuitem'}
|
||||||
aria-checked={checkable ? e.checked : undefined} aria-disabled={dis || undefined}
|
aria-checked={checkable ? e.checked : undefined} aria-disabled={dis || undefined}
|
||||||
aria-haspopup={e.submenu ? 'menu' : undefined} aria-expanded={e.submenu ? sub?.index === i : undefined}
|
aria-haspopup={e.submenu ? 'menu' : undefined} aria-expanded={e.submenu ? sub?.index === i : undefined}
|
||||||
title={typeof e.disabled === 'string' ? e.disabled : e.submenu && onTear ? t('cm.tearOff') : undefined}
|
title={typeof e.disabled === 'string' ? e.disabled : undefined}
|
||||||
className={`ds-menu-item${i === active ? ' active' : ''}${e.danger ? ' danger' : ''}${dis ? ' disabled' : ''}`}
|
className={`ds-menu-item${i === active ? ' active' : ''}${e.danger ? ' danger' : ''}${dis ? ' disabled' : ''}`}
|
||||||
onPointerMove={() => {
|
onPointerMove={() => {
|
||||||
if (active !== i) setActive(dis ? -1 : i);
|
if (active !== i) setActive(dis ? -1 : i);
|
||||||
|
|
@ -404,9 +233,7 @@ function MenuList({ items, at, close, root, keyboard, onBack, path, onPin, onTea
|
||||||
if (!dis && e.submenu) { if (sub?.index !== i) hoverTimer.current = window.setTimeout(() => openSub(i, false), 120); }
|
if (!dis && e.submenu) { if (sub?.index !== i) hoverTimer.current = window.setTimeout(() => openSub(i, false), 120); }
|
||||||
else if (sub) hoverTimer.current = window.setTimeout(() => setSub(null), 200);
|
else if (sub) hoverTimer.current = window.setTimeout(() => setSub(null), 200);
|
||||||
}}
|
}}
|
||||||
onMouseDown={ev => { if (ev.button === 1) ev.preventDefault(); }}
|
onClick={() => choose(i)}>
|
||||||
onAuxClick={ev => { if (ev.button === 1) choose(i, ev); }}
|
|
||||||
onClick={ev => choose(i, ev)}>
|
|
||||||
<span className="ds-menu-ic">{checkable ? (e.checked ? <Icon name="check" /> : null) : e.icon ? <Icon name={e.icon} /> : null}</span>
|
<span className="ds-menu-ic">{checkable ? (e.checked ? <Icon name="check" /> : null) : e.icon ? <Icon name={e.icon} /> : null}</span>
|
||||||
<span className="ds-menu-l">{e.label}</span>
|
<span className="ds-menu-l">{e.label}</span>
|
||||||
{e.shortcut && <span className="ds-menu-k">{e.shortcut}</span>}
|
{e.shortcut && <span className="ds-menu-k">{e.shortcut}</span>}
|
||||||
|
|
@ -416,8 +243,7 @@ function MenuList({ items, at, close, root, keyboard, onBack, path, onPin, onTea
|
||||||
})}
|
})}
|
||||||
</div>
|
</div>
|
||||||
{sub && isItem(items[sub.index]) && (items[sub.index] as MenuItem).submenu && (
|
{sub && isItem(items[sub.index]) && (items[sub.index] as MenuItem).submenu && (
|
||||||
<MenuList key={sub.index} items={(items[sub.index] as MenuItem).submenu as MenuEntry[]} at={sub.anchor} close={close} done={done}
|
<MenuList key={sub.index} items={(items[sub.index] as MenuItem).submenu as MenuEntry[]} at={sub.anchor} close={close}
|
||||||
path={[...path, (items[sub.index] as MenuItem).label]} onTear={onTear}
|
|
||||||
onBack={() => { setSub(null); ref.current?.focus({ preventScroll: true }); }} />
|
onBack={() => { setSub(null); ref.current?.focus({ preventScroll: true }); }} />
|
||||||
)}
|
)}
|
||||||
</>
|
</>
|
||||||
|
|
|
||||||
|
|
@ -4,7 +4,7 @@
|
||||||
// (dry run -> native dialog -> apply) of `apple game-center` and `play games`; the PGS setup is a console plan.
|
// (dry run -> native dialog -> apply) of `apple game-center` and `play games`; the PGS setup is a console plan.
|
||||||
import type { Project } from '../api';
|
import type { Project } from '../api';
|
||||||
import { t } from '../i18n';
|
import { t } from '../i18n';
|
||||||
import { type ReadState, useRead, useWrite } from '../store';
|
import { useRead, useWrite } from '../store';
|
||||||
import { ConsolePlanButton } from './ConsolePlan';
|
import { ConsolePlanButton } from './ConsolePlan';
|
||||||
import { StoreGlyph } from './icons';
|
import { StoreGlyph } from './icons';
|
||||||
import { Card, Chip, ErrorNotice, Skeleton } from './kit';
|
import { Card, Chip, ErrorNotice, Skeleton } from './kit';
|
||||||
|
|
@ -18,23 +18,13 @@ export interface GameServicesStatus {
|
||||||
play: null | { appId: string | null; resource: string | null; config: Counts; changes: string[]; error?: string } & Counts;
|
play: null | { appId: string | null; resource: string | null; config: Counts; changes: string[]; error?: string } & Counts;
|
||||||
findings: Finding[];
|
findings: Finding[];
|
||||||
links: { label: string; url: string }[];
|
links: { label: string; url: string }[];
|
||||||
items?: GameItemRow[];
|
|
||||||
localeMap?: { configured: Record<string, string>; suggested: { id: string; from: string; to: string }[] };
|
|
||||||
playApiDisabled?: { service: string; title: string; url: string } | null;
|
|
||||||
}
|
|
||||||
export type GameAction = 'create' | 'update' | 'keep';
|
|
||||||
export interface GameItemRow {
|
|
||||||
kind: 'leaderboard' | 'achievement'; id: string; name: string; locales: string[]; points?: number; hidden?: boolean; ios: boolean; android: boolean;
|
|
||||||
apple: { action: GameAction; changed: string[]; locales: { locale: string; action: GameAction }[] } | null;
|
|
||||||
play: { action: GameAction; changed: string[] } | null;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
const tone = (l: Finding['level']) => (l === 'error' ? 'bad' : l === 'warn' ? 'warn' : 'ok');
|
const tone = (l: Finding['level']) => (l === 'error' ? 'bad' : l === 'warn' ? 'warn' : 'ok');
|
||||||
const yesNo = (v: boolean | null | undefined) => (v === null || v === undefined ? <Chip tone="neutral">{t('gs.unknown')}</Chip> : <Chip tone={v ? 'ok' : 'bad'}>{v ? t('gs.yes') : t('gs.no')}</Chip>);
|
const yesNo = (v: boolean | null | undefined) => (v === null || v === undefined ? <Chip tone="neutral">{t('gs.unknown')}</Chip> : <Chip tone={v ? 'ok' : 'bad'}>{v ? t('gs.yes') : t('gs.no')}</Chip>);
|
||||||
|
|
||||||
export function GameServicesCard({ project, read }: { project: Project; read?: ReadState<GameServicesStatus> }) {
|
export function GameServicesCard({ project }: { project: Project }) {
|
||||||
const own = useRead<GameServicesStatus>(project.id, 'games.status', { network: true, title: t('gs.title'), skip: !!read });
|
const r = useRead<GameServicesStatus>(project.id, 'games.status', { network: true, title: t('gs.title') });
|
||||||
const r = read ?? own;
|
|
||||||
const w = useWrite(project.id);
|
const w = useWrite(project.id);
|
||||||
if (!r.data) return r.error ? <ErrorNotice error={r.error} tone="warn" /> : <Card title={t('gs.title')} icon="sparkle"><Skeleton lines={3} block /></Card>;
|
if (!r.data) return r.error ? <ErrorNotice error={r.error} tone="warn" /> : <Card title={t('gs.title')} icon="sparkle"><Skeleton lines={3} block /></Card>;
|
||||||
const s = r.data;
|
const s = r.data;
|
||||||
|
|
|
||||||
|
|
@ -5,8 +5,7 @@ import { t } from '../i18n';
|
||||||
import { copyText } from '../lib/crash';
|
import { copyText } from '../lib/crash';
|
||||||
import { withIgnored, withSideIgnored, withUnpair, type UnifiedApp } from '../lib/identity';
|
import { withIgnored, withSideIgnored, withUnpair, type UnifiedApp } from '../lib/identity';
|
||||||
import { setShowIgnored } from '../lib/show-ignored';
|
import { setShowIgnored } from '../lib/show-ignored';
|
||||||
import { type AppTab, type Nav, SECTION_ICON, SECTION_KEY, sectionsFor, subsOf, TAB_ICON, TAB_KEY } from '../nav';
|
import { type AppTab, type Nav, TAB_ICON, TAB_KEY, tabsFor } from '../nav';
|
||||||
import { isGameSummary } from '../lib/model';
|
|
||||||
import type { Data } from '../store';
|
import type { Data } from '../store';
|
||||||
import type { MenuInput, MenuItem } from './menu-logic';
|
import type { MenuInput, MenuItem } from './menu-logic';
|
||||||
import { pickConsoleId, playAppUrl } from '../../../../cli/lib/console-links';
|
import { pickConsoleId, playAppUrl } from '../../../../cli/lib/console-links';
|
||||||
|
|
@ -37,12 +36,7 @@ export function appMenu(app: UnifiedApp, d: Data, nav: Nav, opts: { showIgnored:
|
||||||
const storeName = (k: 'ios' | 'android') => (k === 'ios' ? 'App Store' : 'Google Play');
|
const storeName = (k: 'ios' | 'android') => (k === 'ios' ? 'App Store' : 'Google Play');
|
||||||
return [
|
return [
|
||||||
{ label: t('cm.open'), icon: 'arrowRight', onSelect: () => go('releases') },
|
{ label: t('cm.open'), icon: 'arrowRight', onSelect: () => go('releases') },
|
||||||
{ label: t('cm.openTab'), icon: 'grid', submenu: sectionsFor(!!p, isGameSummary(d.statusFor(app)?.summary)).map((sec, i) => {
|
{ label: t('cm.openTab'), icon: 'grid', submenu: tabsFor(!!p).map(tab => ({ label: t(TAB_KEY[tab]), icon: TAB_ICON[tab], onSelect: () => go(tab) })) },
|
||||||
const subs = subsOf(sec, !!p, isGameSummary(d.statusFor(app)?.summary));
|
|
||||||
return subs.length > 1
|
|
||||||
? { label: t(SECTION_KEY[sec]), icon: SECTION_ICON[sec], shortcut: String(i + 1), submenu: subs.map(tab => ({ label: t(TAB_KEY[tab]), icon: TAB_ICON[tab], onSelect: () => go(tab) })) }
|
|
||||||
: { label: t(SECTION_KEY[sec]), icon: SECTION_ICON[sec], shortcut: String(i + 1), onSelect: () => go(subs[0]!) };
|
|
||||||
}) },
|
|
||||||
'sep',
|
'sep',
|
||||||
(ios || android) && { label: t('cm.openConsole'), icon: 'external', submenu: [
|
(ios || android) && { label: t('cm.openConsole'), icon: 'external', submenu: [
|
||||||
ios && { label: 'App Store Connect', icon: 'external', onSelect: () => openUrl(d, ASC_APP(ios.id)) },
|
ios && { label: 'App Store Connect', icon: 'external', onSelect: () => openUrl(d, ASC_APP(ios.id)) },
|
||||||
|
|
|
||||||
|
|
@ -275,7 +275,7 @@ export function Toolbar({ label, children }: { label: string; children: ReactNod
|
||||||
return <div className="ds-toolbar" role="toolbar" aria-label={label}>{children}</div>;
|
return <div className="ds-toolbar" role="toolbar" aria-label={label}>{children}</div>;
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface TabItem<T extends string> { id: T; label: string; icon?: IconName; count?: number | null; dot?: boolean; dotTitle?: string; /** A keyboard hint shown in the tab ("1"). */ hint?: string }
|
export interface TabItem<T extends string> { id: T; label: string; icon?: IconName; count?: number | null; dot?: boolean; dotTitle?: string }
|
||||||
|
|
||||||
/** Pill tabs with icons and counts; arrows / Home / End move between them (roving tabindex). One row always: tabs that
|
/** Pill tabs with icons and counts; arrows / Home / End move between them (roving tabindex). One row always: tabs that
|
||||||
* do not fit go into a "More" menu at the end, the active tab always stays in the row. */
|
* do not fit go into a "More" menu at the end, the active tab always stays in the row. */
|
||||||
|
|
@ -323,12 +323,11 @@ export function Tabs<T extends string>({ items, value, onChange, label, panelId
|
||||||
return (
|
return (
|
||||||
<div className="ds-tabs" ref={row} role="tablist" aria-label={label} onKeyDown={onKey}>
|
<div className="ds-tabs" ref={row} role="tablist" aria-label={label} onKeyDown={onKey}>
|
||||||
{items.map((x, i) => (
|
{items.map((x, i) => (
|
||||||
<button key={x.id} ref={el => { refs.current[i] = el; }} role="tab" id={`tab-${x.id}`} aria-selected={value === x.id} aria-controls={panelId} aria-keyshortcuts={x.hint}
|
<button key={x.id} ref={el => { refs.current[i] = el; }} role="tab" id={`tab-${x.id}`} aria-selected={value === x.id} aria-controls={panelId}
|
||||||
tabIndex={value === x.id ? 0 : -1} className="ds-tab" onClick={() => onChange(x.id)} hidden={!visible(i)}>
|
tabIndex={value === x.id ? 0 : -1} className="ds-tab" onClick={() => onChange(x.id)} hidden={!visible(i)}>
|
||||||
{x.icon && <Icon name={x.icon} weight={value === x.id ? 'fill' : 'regular'} />}{x.label}
|
{x.icon && <Icon name={x.icon} weight={value === x.id ? 'fill' : 'regular'} />}{x.label}
|
||||||
{x.count != null && x.count > 0 && <span className="ds-tab-n num">{x.count}</span>}
|
{x.count != null && x.count > 0 && <span className="ds-tab-n num">{x.count}</span>}
|
||||||
{x.dot && <span className="ed-dot" title={x.dotTitle} />}
|
{x.dot && <span className="ed-dot" title={x.dotTitle} />}
|
||||||
{x.hint && <kbd className="ds-tab-k" aria-hidden="true">{x.hint}</kbd>}
|
|
||||||
</button>
|
</button>
|
||||||
))}
|
))}
|
||||||
{hidden.length > 0 && (
|
{hidden.length > 0 && (
|
||||||
|
|
|
||||||
|
|
@ -55,8 +55,6 @@ import { PauseIcon } from '@phosphor-icons/react/dist/csr/Pause';
|
||||||
import { PencilSimpleIcon } from '@phosphor-icons/react/dist/csr/PencilSimple';
|
import { PencilSimpleIcon } from '@phosphor-icons/react/dist/csr/PencilSimple';
|
||||||
import { PlayIcon } from '@phosphor-icons/react/dist/csr/Play';
|
import { PlayIcon } from '@phosphor-icons/react/dist/csr/Play';
|
||||||
import { PlusIcon } from '@phosphor-icons/react/dist/csr/Plus';
|
import { PlusIcon } from '@phosphor-icons/react/dist/csr/Plus';
|
||||||
import { PushPinIcon } from '@phosphor-icons/react/dist/csr/PushPin';
|
|
||||||
import { PushPinSlashIcon } from '@phosphor-icons/react/dist/csr/PushPinSlash';
|
|
||||||
import { PulseIcon } from '@phosphor-icons/react/dist/csr/Pulse';
|
import { PulseIcon } from '@phosphor-icons/react/dist/csr/Pulse';
|
||||||
import { QuestionIcon } from '@phosphor-icons/react/dist/csr/Question';
|
import { QuestionIcon } from '@phosphor-icons/react/dist/csr/Question';
|
||||||
import { RocketLaunchIcon } from '@phosphor-icons/react/dist/csr/RocketLaunch';
|
import { RocketLaunchIcon } from '@phosphor-icons/react/dist/csr/RocketLaunch';
|
||||||
|
|
@ -91,7 +89,7 @@ const ICONS = {
|
||||||
more: DotsThreeIcon, gauge: GaugeIcon, eye: EyeIcon, eyeOff: EyeSlashIcon, link: LinkIcon, unlink: LinkBreakIcon, bell: BellIcon, filter: FunnelIcon, play: PlayIcon,
|
more: DotsThreeIcon, gauge: GaugeIcon, eye: EyeIcon, eyeOff: EyeSlashIcon, link: LinkIcon, unlink: LinkBreakIcon, bell: BellIcon, filter: FunnelIcon, play: PlayIcon,
|
||||||
send: PaperPlaneRightIcon, edit: PencilSimpleIcon, upload: UploadSimpleIcon, sliders: SlidersHorizontalIcon,
|
send: PaperPlaneRightIcon, edit: PencilSimpleIcon, upload: UploadSimpleIcon, sliders: SlidersHorizontalIcon,
|
||||||
rotate: ArrowCounterClockwiseIcon, cloud: CloudIcon, coins: CoinsIcon, chart: TrendUpIcon, flask: FlaskIcon, grid: GridFourIcon,
|
rotate: ArrowCounterClockwiseIcon, cloud: CloudIcon, coins: CoinsIcon, chart: TrendUpIcon, flask: FlaskIcon, grid: GridFourIcon,
|
||||||
clipboard: ClipboardTextIcon, share: ExportIcon, lock: LockIcon, question: QuestionIcon, pin: PushPinIcon, pinOff: PushPinSlashIcon,
|
clipboard: ClipboardTextIcon, share: ExportIcon, lock: LockIcon, question: QuestionIcon,
|
||||||
} satisfies Record<string, PhosphorIcon>;
|
} satisfies Record<string, PhosphorIcon>;
|
||||||
|
|
||||||
export type IconName = keyof typeof ICONS;
|
export type IconName = keyof typeof ICONS;
|
||||||
|
|
|
||||||
|
|
@ -25,7 +25,7 @@ export function phaseLabel(r: StoreRelease | null | undefined): { text: string;
|
||||||
const stale = r.pageStaleAt ? ` · ${t('phase.pageStale', { when: ago(r.pageStaleAt) })}` : '';
|
const stale = r.pageStaleAt ? ` · ${t('phase.pageStale', { when: ago(r.pageStaleAt) })}` : '';
|
||||||
if (r.store === 'android' && r.phase === 'released') return { text: t('phase.pageUnknown') + stale, tone: 'neutral' };
|
if (r.store === 'android' && r.phase === 'released') return { text: t('phase.pageUnknown') + stale, tone: 'neutral' };
|
||||||
if (r.store === 'android' && (r.phase === 'review' || r.phase === 'sent'))
|
if (r.store === 'android' && (r.phase === 'review' || r.phase === 'sent'))
|
||||||
return { text: (r.managed ? t('phase.reviewManaged') : r.liveVersion ? t('phase.reviewLive', { version: r.liveVersion }) : t('phase.playPending')) + stale, tone: 'warn' };
|
return { text: (r.managed ? t('phase.reviewManaged') : r.liveVersion ? t('phase.reviewLive', { version: r.liveVersion }) : t('phase.review')) + stale, tone: 'warn' };
|
||||||
if (r.store === 'android' && r.phase === 'live' && stale) return { text: t('phase.live') + stale, tone: 'ok' };
|
if (r.store === 'android' && r.phase === 'live' && stale) return { text: t('phase.live') + stale, tone: 'ok' };
|
||||||
if (r.phase === 'testing' && r.track) return { text: `${t('phase.testing')} · ${r.track}`, tone: 'info' };
|
if (r.phase === 'testing' && r.track) return { text: `${t('phase.testing')} · ${r.track}`, tone: 'info' };
|
||||||
return { text: t(`phase.${r.phase}`), tone: PHASE_TONE[r.phase] };
|
return { text: t(`phase.${r.phase}`), tone: PHASE_TONE[r.phase] };
|
||||||
|
|
|
||||||
|
|
@ -1,140 +0,0 @@
|
||||||
// The in-app context menus' panel stack without React or the DOM (tested in tests/menu-stack.test.ts): several menus
|
|
||||||
// open at once, a submenu chain per menu, pinned panels that survive the next menu, step aside so they never sit on
|
|
||||||
// each other and stay inside the window; plus the live sources pinned panels re-read their entries from.
|
|
||||||
import type { MenuEntry, MenuInput, MenuItem } from './menu-logic';
|
|
||||||
import { tidy } from './menu-logic';
|
|
||||||
|
|
||||||
export interface Pos { x: number; y: number }
|
|
||||||
|
|
||||||
/** One open panel: a root menu, or a submenu torn off (pinned) at `path` (submenu labels from the root). */
|
|
||||||
export interface StackEntry {
|
|
||||||
uid: string;
|
|
||||||
/** The live source of its entries (`liveKey`), or null for a menu built once (the edit menu). */
|
|
||||||
source: string | null;
|
|
||||||
path: readonly string[];
|
|
||||||
pinned: boolean;
|
|
||||||
x: number;
|
|
||||||
y: number;
|
|
||||||
}
|
|
||||||
|
|
||||||
/** Pinned panels step this far (CSS px) until no other pinned panel sits there. */
|
|
||||||
export const OFFSET_STEP = 24;
|
|
||||||
|
|
||||||
const same = (a: Pick<StackEntry, 'source' | 'path'>, b: Pick<StackEntry, 'source' | 'path'>) =>
|
|
||||||
a.source !== null && a.source === b.source && a.path.length === b.path.length && a.path.every((p, i) => p === b.path[i]);
|
|
||||||
|
|
||||||
/** Opening a menu closes only the unpinned ones. */
|
|
||||||
export function openMenu(list: readonly StackEntry[], entry: StackEntry): StackEntry[] {
|
|
||||||
return [...list.filter(e => e.pinned), entry];
|
|
||||||
}
|
|
||||||
|
|
||||||
/** Outside click, Esc, a pick, scroll, blur: every unpinned panel closes (the same list when there is none). */
|
|
||||||
export function closeUnpinned(list: readonly StackEntry[]): StackEntry[] {
|
|
||||||
return list.some(e => !e.pinned) ? list.filter(e => e.pinned) : (list as StackEntry[]);
|
|
||||||
}
|
|
||||||
|
|
||||||
export function closeMenu(list: readonly StackEntry[], uid: string): StackEntry[] {
|
|
||||||
return list.some(e => e.uid === uid) ? list.filter(e => e.uid !== uid) : (list as StackEntry[]);
|
|
||||||
}
|
|
||||||
|
|
||||||
/** A free spot: steps down-right until no taken spot is within a step of it. */
|
|
||||||
export function autoOffset(taken: readonly Pos[], pos: Pos, step = OFFSET_STEP): Pos {
|
|
||||||
let next = { ...pos };
|
|
||||||
for (let k = 0; k < 200 && taken.some(t => Math.abs(t.x - next.x) < step && Math.abs(t.y - next.y) < step); k++) next = { x: next.x + step, y: next.y + step };
|
|
||||||
return next;
|
|
||||||
}
|
|
||||||
|
|
||||||
const taken = (list: readonly StackEntry[], skip?: string): Pos[] => list.filter(e => e.pinned && e.uid !== skip).map(e => ({ x: e.x, y: e.y }));
|
|
||||||
|
|
||||||
/** Pins an open panel where it is (moved off other pinned panels). A pinned copy of the same panel is replaced. */
|
|
||||||
export function pinMenu(list: readonly StackEntry[], uid: string, pos: Pos): StackEntry[] {
|
|
||||||
const entry = list.find(e => e.uid === uid);
|
|
||||||
if (!entry || entry.pinned) return list as StackEntry[];
|
|
||||||
const rest = list.filter(e => !(e.pinned && same(e, entry)));
|
|
||||||
const at = autoOffset(taken(rest, uid), pos);
|
|
||||||
return rest.map(e => (e.uid === uid ? { ...e, pinned: true, x: at.x, y: at.y } : e));
|
|
||||||
}
|
|
||||||
|
|
||||||
/** A submenu torn off its menu (pin button on a submenu, Ctrl / middle click on its row): a new pinned panel. The menu
|
|
||||||
* it came from stays open. */
|
|
||||||
export function tearOff(list: readonly StackEntry[], entry: StackEntry, pos: Pos): StackEntry[] {
|
|
||||||
const rest = list.filter(e => !(e.pinned && same(e, entry)));
|
|
||||||
const at = autoOffset(taken(rest), pos);
|
|
||||||
return [...rest, { ...entry, pinned: true, x: at.x, y: at.y }];
|
|
||||||
}
|
|
||||||
|
|
||||||
/** Unpin: a root menu becomes a normal menu again (it closes with the next one); a torn-off submenu closes. */
|
|
||||||
export function unpinMenu(list: readonly StackEntry[], uid: string): StackEntry[] {
|
|
||||||
const entry = list.find(e => e.uid === uid);
|
|
||||||
if (!entry?.pinned) return list as StackEntry[];
|
|
||||||
if (entry.path.length > 0) return closeMenu(list, uid);
|
|
||||||
return list.map(e => (e.uid === uid ? { ...e, pinned: false } : e));
|
|
||||||
}
|
|
||||||
|
|
||||||
export function moveMenu(list: readonly StackEntry[], uid: string, pos: Pos): StackEntry[] {
|
|
||||||
return list.map(e => (e.uid === uid ? { ...e, x: pos.x, y: pos.y } : e));
|
|
||||||
}
|
|
||||||
|
|
||||||
/** Keeps a panel of `size` inside `box` (the window), `margin` from its edges. */
|
|
||||||
export function clampPos(pos: Pos, size: { w: number; h: number }, box: { w: number; h: number }, margin = 8): Pos {
|
|
||||||
return { x: Math.max(margin, Math.min(pos.x, box.w - size.w - margin)), y: Math.max(margin, Math.min(pos.y, box.h - size.h - margin)) };
|
|
||||||
}
|
|
||||||
|
|
||||||
/** The entries at `path` (submenu labels) inside a menu, or null when that submenu is gone. */
|
|
||||||
export function resolvePath(items: readonly MenuEntry[], path: readonly string[]): MenuEntry[] | null {
|
|
||||||
let cur = items as MenuEntry[];
|
|
||||||
for (const label of path) {
|
|
||||||
const next = cur.find((e): e is MenuItem => e !== 'sep' && e.label === label && !!e.submenu);
|
|
||||||
if (!next) return null;
|
|
||||||
cur = next.submenu as MenuEntry[];
|
|
||||||
}
|
|
||||||
return cur;
|
|
||||||
}
|
|
||||||
|
|
||||||
// ---- live sources ----
|
|
||||||
|
|
||||||
/**
|
|
||||||
* The menus' live sources: every `useContextMenu` / `useMenuButton` call registers the builder it got on each render,
|
|
||||||
* so a pinned panel re-reads its entries from the newest builder (fresh data, fresh actions) and updates in place. A
|
|
||||||
* source that is gone (its row unmounted) gives null: the panel says so instead of closing.
|
|
||||||
*/
|
|
||||||
export class LiveMenus {
|
|
||||||
private builders = new Map<string, () => MenuInput>();
|
|
||||||
private subs = new Map<string, Set<() => void>>();
|
|
||||||
private pending = new Set<string>();
|
|
||||||
constructor(private schedule: (fn: () => void) => void = fn => queueMicrotask(fn)) {}
|
|
||||||
|
|
||||||
/** Registers (or replaces) the builder of `key`; its watchers hear about it once per batch. */
|
|
||||||
set(key: string, build: () => MenuInput): void {
|
|
||||||
this.builders.set(key, build);
|
|
||||||
this.ping(key);
|
|
||||||
}
|
|
||||||
delete(key: string): void {
|
|
||||||
if (this.builders.delete(key)) this.ping(key);
|
|
||||||
}
|
|
||||||
/** Keeps only the keys of one hook (`prefix#...`) that its last render registered; `keep` empty drops them all. */
|
|
||||||
retain(prefix: string, keep: ReadonlySet<string> = new Set()): void {
|
|
||||||
for (const k of [...this.builders.keys()]) if (k.startsWith(`${prefix}#`) && !keep.has(k)) this.delete(k);
|
|
||||||
}
|
|
||||||
/** The entries of `key` now (tidied), or null when it is gone. */
|
|
||||||
get(key: string): MenuEntry[] | null {
|
|
||||||
const b = this.builders.get(key);
|
|
||||||
if (!b) return null;
|
|
||||||
try { return tidy(b()); } catch { return null; }
|
|
||||||
}
|
|
||||||
has(key: string): boolean { return this.builders.has(key); }
|
|
||||||
watch(key: string, fn: () => void): () => void {
|
|
||||||
let s = this.subs.get(key);
|
|
||||||
if (!s) { s = new Set(); this.subs.set(key, s); }
|
|
||||||
s.add(fn);
|
|
||||||
return () => { s.delete(fn); if (!s.size) this.subs.delete(key); };
|
|
||||||
}
|
|
||||||
private ping(key: string): void {
|
|
||||||
if (!this.subs.has(key) || this.pending.has(key)) return;
|
|
||||||
this.pending.add(key);
|
|
||||||
this.schedule(() => {
|
|
||||||
this.pending.delete(key);
|
|
||||||
for (const fn of [...(this.subs.get(key) ?? [])]) fn();
|
|
||||||
});
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
@ -1,150 +0,0 @@
|
||||||
// The in-app context menus' panel stack (ui/menu-stack.ts): several menus open, pinned panels that survive the next
|
|
||||||
// menu and never sit on each other, tear-offs, live sources that a pinned panel re-reads, and the wiring in
|
|
||||||
// ContextMenu.tsx that keeps it that way.
|
|
||||||
import { describe, expect, test } from 'bun:test';
|
|
||||||
import { readFileSync } from 'node:fs';
|
|
||||||
import { join } from 'node:path';
|
|
||||||
import type { MenuEntry, MenuInput } from '../src/ui/menu-logic';
|
|
||||||
import { autoOffset, clampPos, closeMenu, closeUnpinned, LiveMenus, moveMenu, OFFSET_STEP, openMenu, pinMenu, resolvePath, type StackEntry, tearOff, unpinMenu } from '../src/ui/menu-stack';
|
|
||||||
|
|
||||||
const e = (uid: string, extra: Partial<StackEntry> = {}): StackEntry => ({ uid, source: `src-${uid}`, path: [], pinned: false, x: 10, y: 10, ...extra });
|
|
||||||
const uids = (l: readonly StackEntry[]) => l.map(x => `${x.uid}${x.pinned ? '*' : ''}`);
|
|
||||||
|
|
||||||
describe('menu stack', () => {
|
|
||||||
test('opening a menu closes only the unpinned ones', () => {
|
|
||||||
let l = openMenu([], e('a'));
|
|
||||||
l = pinMenu(l, 'a', { x: 100, y: 100 });
|
|
||||||
l = openMenu(l, e('b'));
|
|
||||||
l = openMenu(l, e('c'));
|
|
||||||
expect(uids(l)).toEqual(['a*', 'c']);
|
|
||||||
l = closeUnpinned(l);
|
|
||||||
expect(uids(l)).toEqual(['a*']);
|
|
||||||
expect(closeUnpinned(l)).toBe(l); // nothing to close: the same list (no re-render)
|
|
||||||
});
|
|
||||||
|
|
||||||
test('a pinned panel steps aside from other pinned panels', () => {
|
|
||||||
let l = [e('a', { pinned: true, x: 100, y: 100 }), e('b')];
|
|
||||||
l = pinMenu(l, 'b', { x: 104, y: 98 });
|
|
||||||
const b = l.find(x => x.uid === 'b')!;
|
|
||||||
expect(b.pinned).toBe(true);
|
|
||||||
expect(Math.abs(b.x - 100) >= OFFSET_STEP || Math.abs(b.y - 100) >= OFFSET_STEP).toBe(true);
|
|
||||||
expect(autoOffset([{ x: 0, y: 0 }, { x: 24, y: 24 }], { x: 0, y: 0 })).toEqual({ x: 48, y: 48 });
|
|
||||||
expect(autoOffset([], { x: 5, y: 5 })).toEqual({ x: 5, y: 5 });
|
|
||||||
});
|
|
||||||
|
|
||||||
test('pinning the same panel again replaces the old pinned copy', () => {
|
|
||||||
let l = [e('a', { pinned: true, source: 's', path: ['Copy'] }), e('b', { source: 's', path: ['Copy'] })];
|
|
||||||
l = pinMenu(l, 'b', { x: 300, y: 300 });
|
|
||||||
expect(uids(l)).toEqual(['b*']);
|
|
||||||
// a menu without a live source (the edit menu) is never "the same" as another
|
|
||||||
l = [e('a', { pinned: true, source: null }), e('b', { source: null })];
|
|
||||||
expect(uids(pinMenu(l, 'b', { x: 300, y: 300 }))).toEqual(['a*', 'b*']);
|
|
||||||
});
|
|
||||||
|
|
||||||
test('a torn-off submenu is its own pinned panel and the menu it came from stays open', () => {
|
|
||||||
let l = openMenu([], e('a'));
|
|
||||||
l = tearOff(l, e('t', { path: ['Open tab'] }), { x: 50, y: 50 });
|
|
||||||
expect(uids(l)).toEqual(['a', 't*']);
|
|
||||||
// the same submenu torn off again: one copy
|
|
||||||
l = tearOff(l, e('t2', { path: ['Open tab'], source: 'src-t' }), { x: 50, y: 50 });
|
|
||||||
expect(uids(l)).toEqual(['a', 't2*']);
|
|
||||||
});
|
|
||||||
|
|
||||||
test('unpin: a root menu becomes a normal menu again, a torn-off submenu closes', () => {
|
|
||||||
let l = [e('a', { pinned: true }), e('t', { pinned: true, path: ['Copy'] })];
|
|
||||||
l = unpinMenu(l, 'a');
|
|
||||||
expect(uids(l)).toEqual(['a', 't*']);
|
|
||||||
l = unpinMenu(l, 't');
|
|
||||||
expect(uids(l)).toEqual(['a']);
|
|
||||||
expect(uids(closeMenu(l, 'a'))).toEqual([]);
|
|
||||||
expect(closeMenu(l, 'zz')).toBe(l);
|
|
||||||
});
|
|
||||||
|
|
||||||
test('a moved panel keeps the move; positions stay inside the window', () => {
|
|
||||||
const l = moveMenu([e('a', { pinned: true })], 'a', { x: 400, y: 20 });
|
|
||||||
expect(l[0]).toMatchObject({ x: 400, y: 20 });
|
|
||||||
expect(clampPos({ x: 1900, y: -40 }, { w: 240, h: 300 }, { w: 1280, h: 800 })).toEqual({ x: 1280 - 240 - 8, y: 8 });
|
|
||||||
expect(clampPos({ x: 100, y: 100 }, { w: 240, h: 300 }, { w: 1280, h: 800 })).toEqual({ x: 100, y: 100 });
|
|
||||||
});
|
|
||||||
|
|
||||||
test('resolvePath walks submenu labels; a gone submenu gives null', () => {
|
|
||||||
const items: MenuEntry[] = [{ label: 'Open' }, 'sep', { label: 'Copy', submenu: [{ label: 'Name' }, { label: 'More', submenu: [{ label: 'Deep' }] }] }];
|
|
||||||
expect(resolvePath(items, [])).toBe(items);
|
|
||||||
expect(resolvePath(items, ['Copy', 'More'])!.map(x => (x === 'sep' ? '-' : x.label))).toEqual(['Deep']);
|
|
||||||
expect(resolvePath(items, ['Open'])).toBeNull(); // not a submenu
|
|
||||||
expect(resolvePath(items, ['Gone'])).toBeNull();
|
|
||||||
});
|
|
||||||
});
|
|
||||||
|
|
||||||
describe('live sources', () => {
|
|
||||||
const sync = () => {
|
|
||||||
const queue: (() => void)[] = [];
|
|
||||||
return { live: new LiveMenus(fn => queue.push(fn)), flush: () => { while (queue.length) queue.shift()!(); } };
|
|
||||||
};
|
|
||||||
|
|
||||||
test('a pinned panel hears once per batch and re-reads the newest builder', () => {
|
|
||||||
const { live, flush } = sync();
|
|
||||||
let value = 1;
|
|
||||||
const build = (): MenuInput => [{ label: `Rollout ${value}%` }, false];
|
|
||||||
live.set('h#0', build);
|
|
||||||
let heard = 0;
|
|
||||||
const off = live.watch('h#0', () => heard++);
|
|
||||||
value = 20;
|
|
||||||
live.set('h#0', build);
|
|
||||||
live.set('h#0', build);
|
|
||||||
expect(heard).toBe(0);
|
|
||||||
flush();
|
|
||||||
expect(heard).toBe(1);
|
|
||||||
expect(live.get('h#0')!.map(x => (x === 'sep' ? '-' : x.label))).toEqual(['Rollout 20%']);
|
|
||||||
off();
|
|
||||||
live.set('h#0', build);
|
|
||||||
flush();
|
|
||||||
expect(heard).toBe(1);
|
|
||||||
});
|
|
||||||
|
|
||||||
test('keys a render no longer makes are dropped and their panels hear it (gone, not closed)', () => {
|
|
||||||
const { live, flush } = sync();
|
|
||||||
live.set('h#0', () => [{ label: 'A' }]);
|
|
||||||
live.set('h#app:k1', () => [{ label: 'B' }]);
|
|
||||||
live.set('other#0', () => [{ label: 'C' }]);
|
|
||||||
let heard = 0;
|
|
||||||
live.watch('h#app:k1', () => heard++);
|
|
||||||
live.retain('h', new Set(['h#0']));
|
|
||||||
flush();
|
|
||||||
expect(heard).toBe(1);
|
|
||||||
expect(live.get('h#app:k1')).toBeNull();
|
|
||||||
expect(live.has('h#0') && live.has('other#0')).toBe(true);
|
|
||||||
live.retain('h');
|
|
||||||
expect(live.has('h#0')).toBe(false);
|
|
||||||
expect(live.has('other#0')).toBe(true);
|
|
||||||
});
|
|
||||||
|
|
||||||
test('a builder that throws reads as gone', () => {
|
|
||||||
const { live } = sync();
|
|
||||||
live.set('x#0', () => { throw new Error('boom'); });
|
|
||||||
expect(live.get('x#0')).toBeNull();
|
|
||||||
expect(live.get('missing')).toBeNull();
|
|
||||||
});
|
|
||||||
});
|
|
||||||
|
|
||||||
describe('wiring', () => {
|
|
||||||
const s = readFileSync(join(import.meta.dir, '../src/ui/ContextMenu.tsx'), 'utf8');
|
|
||||||
test('menus register live sources and pinned panels re-read them', () => {
|
|
||||||
expect(s).toMatch(/live\.set\(source, build\)/);
|
|
||||||
expect(s).toMatch(/live\.watch\(entry\.source, bump\)/);
|
|
||||||
expect(s).toMatch(/resolvePath\(root, entry\.path\)/);
|
|
||||||
});
|
|
||||||
test('an outside click closes only the normal menus; a pick in a pinned panel keeps it', () => {
|
|
||||||
expect(s).toMatch(/closeUnpinned\(s\)/);
|
|
||||||
expect(s).toMatch(/done=\{\(\) => closeTransient\(false\)\}/);
|
|
||||||
expect(s).toMatch(/ev\.button === 1 \|\| ev\.ctrlKey \|\| ev\.metaKey/);
|
|
||||||
});
|
|
||||||
test('the app menus carry the app key, so a pinned panel follows the app when rows reorder', () => {
|
|
||||||
for (const f of ['src/App.tsx', 'src/screens/AppView.tsx', 'src/screens/Ignored.tsx', 'src/screens/Portfolio.tsx']) {
|
|
||||||
const src = readFileSync(join(import.meta.dir, '..', f), 'utf8');
|
|
||||||
const lines = src.split('\n').filter(l => l.includes('=> appMenu('));
|
|
||||||
expect(lines.length, f).toBeGreaterThan(0);
|
|
||||||
for (const l of lines) expect(l, f).toMatch(/`app:\$\{/);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
});
|
|
||||||