Compare commits
160
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
da78bff316 | ||
|
|
4dcc5176e2 | ||
|
|
df395776b4 | ||
|
|
49dec686f1 | ||
|
|
ba48e95993 | ||
|
|
a8db61f79f | ||
|
|
f5d3c43b6c | ||
|
|
502b9dfd83 | ||
|
|
024edbf546 | ||
|
|
ba5b1ffe7d | ||
|
|
1b5e6a37f5 | ||
|
|
52d94058cf | ||
|
|
e6388fe294 | ||
|
|
78b1a2ff6f | ||
|
|
4323babfb9 | ||
|
|
d250333290 | ||
|
|
4c9af57a97 | ||
|
|
afd14719ef | ||
|
|
7c26268e38 | ||
|
|
fda6e0f74e | ||
|
|
14731f2229 | ||
|
|
6bb3f2af27 | ||
|
|
27c6dacc60 | ||
|
|
3e132069c0 | ||
|
|
e080059f37 | ||
|
|
75951f9040 | ||
|
|
06bb896a00 | ||
|
|
3449338b3e | ||
|
|
75d55e861b | ||
|
|
e91b5fe10e | ||
|
|
1ab7514741 | ||
|
|
2b1f4ee5bc | ||
|
|
b71f9c95c6 | ||
|
|
c0e8334f03 | ||
|
|
3e69c715e9 | ||
|
|
a0d1c565d0 | ||
|
|
a932b1999a | ||
|
|
64af736c6e | ||
|
|
c088b4c0e6 | ||
|
|
ea07fb5087 | ||
|
|
e39714a6e0 | ||
|
|
39589b40f3 | ||
|
|
c1661e48fa | ||
|
|
c96c47dd0d | ||
|
|
103c6f4624 | ||
|
|
7f2e93d389 | ||
|
|
ce8ed89fdc | ||
|
|
359c79a440 | ||
|
|
206a3e933a | ||
|
|
d5aa18e3ab | ||
|
|
862a128102 | ||
|
|
c0a9b2da6b | ||
|
|
ed87b700d9 | ||
|
|
f62c5d5778 | ||
|
|
cccd78fd43 | ||
|
|
e06600afe1 | ||
|
|
f3722ae859 | ||
|
|
4a9823890b | ||
|
|
e80b170fd1 | ||
|
|
76929a8763 | ||
|
|
146ba4d2ff | ||
|
|
25fa0f6ef9 | ||
|
|
b77720c3da | ||
|
|
6edfe70020 | ||
|
|
d9e7f77402 | ||
|
|
568f218fe9 | ||
|
|
23649f1255 | ||
|
|
343de27cad | ||
|
|
3b6de2fdac | ||
|
|
f5ee3c0d0e | ||
|
|
08abf5aec8 | ||
|
|
e393c45f50 | ||
|
|
fdec3ed7f2 | ||
|
|
cf80729a5c | ||
|
|
738067cfc6 | ||
|
|
2bed70d335 | ||
|
|
c7aa4b9b19 | ||
|
|
81777ddfe1 | ||
|
|
eb4b88a028 | ||
|
|
e3883e0fce | ||
|
|
98c80f36cb | ||
|
|
ad1cbcf792 | ||
|
|
492b57c60d | ||
|
|
0c45bde832 | ||
|
|
082b8fc879 | ||
|
|
c6c2e88df5 | ||
|
|
dc0d524989 | ||
|
|
22d46a7922 | ||
|
|
be2c202543 | ||
|
|
6363939654 | ||
|
|
af244bba75 | ||
|
|
af1c0ee184 | ||
|
|
96a97a2f86 | ||
|
|
6aa77552b8 | ||
|
|
52e0cfaa83 | ||
|
|
bd8c79e0e6 | ||
|
|
4d4a76214a | ||
|
|
8d11a62e14 | ||
|
|
bf05751eca | ||
|
|
2bdb2eb4cb | ||
|
|
4fe9c87010 | ||
|
|
b69099a862 | ||
|
|
dea1f7afc0 | ||
|
|
7da91bd803 | ||
|
|
2a0c409180 | ||
|
|
9363629ea2 | ||
|
|
74d8e3119b | ||
|
|
73b1d1e3a7 | ||
|
|
ef5d06eea3 | ||
|
|
7f17940d34 | ||
|
|
f5e7fb4746 | ||
|
|
bbe91a24d8 | ||
|
|
f7d40460f5 | ||
|
|
d2f56817b3 | ||
|
|
33e16e85b3 | ||
|
|
f23b215efa | ||
|
|
821760131c | ||
|
|
edb4624796 | ||
|
|
d4420905e6 | ||
|
|
53a80adb57 | ||
|
|
e078a2cc10 | ||
|
|
c921f11521 | ||
|
|
0e2671891f | ||
|
|
6f25035341 | ||
|
|
f111b3c9af | ||
|
|
8b1c9fa610 | ||
|
|
8658ec05c3 | ||
|
|
2e7915d086 | ||
|
|
84c906fe33 | ||
|
|
464951edf4 | ||
|
|
6df160a7bf | ||
|
|
60076a48d0 | ||
|
|
a475531b2b | ||
|
|
34574178a9 | ||
|
|
070a1ea012 | ||
|
|
bbcbdad55a | ||
|
|
a9e0b893be | ||
|
|
68ce13f081 | ||
|
|
70620d4b43 | ||
|
|
4e455ae42e | ||
|
|
30fd22a5c5 | ||
|
|
da2d7a7d4f | ||
|
|
50b4e2c16c | ||
|
|
230d147ec1 | ||
|
|
9fefd14944 | ||
|
|
53823f5466 | ||
|
|
f2f498425b | ||
|
|
5fc90feef9 | ||
|
|
6460d0569c | ||
|
|
b38621861b | ||
|
|
1a8fa5cd4c | ||
|
|
2e8244dc67 | ||
|
|
e9d419f84c | ||
|
|
e0b1c50155 | ||
|
|
14b6849f6e | ||
|
|
22371f8156 | ||
|
|
58a716c734 | ||
|
|
6d63c34b2c | ||
|
|
4c671fbf3a | ||
|
|
9d84f9153a |
+42
-2
@@ -132,11 +132,27 @@ jobs:
|
|||||||
if: ${{ github.event_name == 'push' && github.ref == 'refs/heads/lotus' }}
|
if: ${{ github.event_name == 'push' && github.ref == 'refs/heads/lotus' }}
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
steps:
|
steps:
|
||||||
|
# [matrix #9] Debounce: a Tauri build takes ~30 min on the shared runner,
|
||||||
|
# so at most one bump per DEBOUNCE_MIN. Commits that land inside the
|
||||||
|
# window are picked up by cinny-desktop's nightly catch-up workflow (or a
|
||||||
|
# manual dispatch of it) — the desktop cadence no longer tracks every web
|
||||||
|
# commit. The bump is also skipped when nothing changed.
|
||||||
- name: Bump cinny submodule
|
- name: Bump cinny submodule
|
||||||
env:
|
env:
|
||||||
TOKEN: ${{ secrets.RELEASE_TOKEN }}
|
TOKEN: ${{ secrets.RELEASE_TOKEN }}
|
||||||
|
DEBOUNCE_MIN: '60'
|
||||||
run: |
|
run: |
|
||||||
CINNY_SHA="${{ github.sha }}"
|
CINNY_SHA="${{ github.sha }}"
|
||||||
|
LAST=$(curl -fsSL -H "Authorization: token $TOKEN" \
|
||||||
|
"https://code.lotusguild.org/api/v1/repos/LotusGuild/cinny-desktop/commits?sha=main&limit=1&stat=false&verification=false&files=false" \
|
||||||
|
| python3 -c 'import sys,json; c=json.load(sys.stdin); print(c[0]["commit"]["committer"]["date"] if c else "")' 2>/dev/null || true)
|
||||||
|
if [ -n "$LAST" ]; then
|
||||||
|
AGE=$(python3 -c "import sys,datetime; d=datetime.datetime.fromisoformat(sys.argv[1].replace('Z','+00:00')); print(int((datetime.datetime.now(datetime.timezone.utc)-d).total_seconds()//60))" "$LAST")
|
||||||
|
if [ "$AGE" -lt "$DEBOUNCE_MIN" ]; then
|
||||||
|
echo "Last desktop bump was ${AGE} min ago (< ${DEBOUNCE_MIN}); skipping — the nightly catch-up will pick this up."
|
||||||
|
exit 0
|
||||||
|
fi
|
||||||
|
fi
|
||||||
git clone "https://x-access-token:$TOKEN@code.lotusguild.org/LotusGuild/cinny-desktop.git" desktop
|
git clone "https://x-access-token:$TOKEN@code.lotusguild.org/LotusGuild/cinny-desktop.git" desktop
|
||||||
cd desktop
|
cd desktop
|
||||||
git config user.email "ci@lotusguild.org"
|
git config user.email "ci@lotusguild.org"
|
||||||
@@ -238,6 +254,8 @@ jobs:
|
|||||||
# as m.room.encrypted. Skips itself unless the E2E_* secrets
|
# as m.room.encrypted. Skips itself unless the E2E_* secrets
|
||||||
# below are set (create them under repo → Settings → Actions
|
# below are set (create them under repo → Settings → Actions
|
||||||
# → Secrets; they are empty until then).
|
# → Secrets; they are empty until then).
|
||||||
|
# local tier — (#220) regression suite against a Synapse this job starts
|
||||||
|
# itself; skips itself if that homeserver isn't reachable.
|
||||||
# dist/ is rebuilt in-job because actions/upload-artifact@v4 does not work
|
# dist/ is rebuilt in-job because actions/upload-artifact@v4 does not work
|
||||||
# on this Gitea runner (see LOTUS_REFERENCE.md → CI/CD), so `needs: build` only gates on the
|
# on this Gitea runner (see LOTUS_REFERENCE.md → CI/CD), so `needs: build` only gates on the
|
||||||
# main job having passed, not on its artifact.
|
# main job having passed, not on its artifact.
|
||||||
@@ -273,8 +291,11 @@ jobs:
|
|||||||
sleep $((attempt * 15))
|
sleep $((attempt * 15))
|
||||||
done
|
done
|
||||||
|
|
||||||
- name: Install Playwright Chromium
|
# [Gitea #221] WebKit too — Playwright's Safari/iOS proxy for the tagged
|
||||||
run: npx playwright install --with-deps chromium
|
# subset (see playwright.config.ts projects). `--with-deps` pulls the
|
||||||
|
# GTK/GStreamer libraries WebKit needs on the runner.
|
||||||
|
- name: Install Playwright browsers
|
||||||
|
run: npx playwright install --with-deps chromium webkit
|
||||||
|
|
||||||
- name: Build
|
- name: Build
|
||||||
run: npm run build
|
run: npm run build
|
||||||
@@ -282,6 +303,21 @@ jobs:
|
|||||||
NODE_OPTIONS: '--max_old_space_size=6144'
|
NODE_OPTIONS: '--max_old_space_size=6144'
|
||||||
VITE_APP_VERSION: ${{ github.sha }}
|
VITE_APP_VERSION: ${{ github.sha }}
|
||||||
|
|
||||||
|
# ── #220 — tier 3: a throwaway Synapse the job starts itself (SQLite,
|
||||||
|
# open registration, no rate limits; scripts/dev-homeserver.sh). The
|
||||||
|
# regression spec (e2e/local-homeserver.spec.ts) registers its own users
|
||||||
|
# and rooms through the CS API and drives the built client against it —
|
||||||
|
# no prod secrets involved. If the homeserver fails to come up the spec
|
||||||
|
# skips itself and the step below still reports why.
|
||||||
|
- name: Start local homeserver
|
||||||
|
id: local_hs
|
||||||
|
continue-on-error: true
|
||||||
|
run: |
|
||||||
|
python3 -m venv --help >/dev/null 2>&1 || { (command -v sudo >/dev/null && sudo -n true 2>/dev/null && sudo apt-get update -qq && sudo apt-get install -y -qq python3-venv) || (apt-get update -qq && apt-get install -y -qq python3-venv); }
|
||||||
|
scripts/dev-homeserver.sh start
|
||||||
|
python3 scripts/dev-seed.py 20 > .dev-homeserver/seed.json
|
||||||
|
echo "E2E_LOCAL_HS=http://localhost:8008" >> "$GITHUB_ENV"
|
||||||
|
|
||||||
- name: Playwright smoke test
|
- name: Playwright smoke test
|
||||||
run: npm run test:e2e
|
run: npm run test:e2e
|
||||||
env:
|
env:
|
||||||
@@ -289,3 +325,7 @@ jobs:
|
|||||||
E2E_HOMESERVER: ${{ secrets.E2E_HOMESERVER }}
|
E2E_HOMESERVER: ${{ secrets.E2E_HOMESERVER }}
|
||||||
E2E_USER: ${{ secrets.E2E_USER }}
|
E2E_USER: ${{ secrets.E2E_USER }}
|
||||||
E2E_PASSWORD: ${{ secrets.E2E_PASSWORD }}
|
E2E_PASSWORD: ${{ secrets.E2E_PASSWORD }}
|
||||||
|
|
||||||
|
- name: Stop local homeserver
|
||||||
|
if: always()
|
||||||
|
run: scripts/dev-homeserver.sh stop || true
|
||||||
|
|||||||
+20
-9
@@ -349,15 +349,16 @@ so a stock EC config is byte-for-byte upstream behavior.
|
|||||||
|
|
||||||
**Active (cinny drives them today):**
|
**Active (cinny drives them today):**
|
||||||
|
|
||||||
| # | Feature | Mechanism | Replaces (old hack) |
|
| # | Feature | Mechanism | Replaces (old hack) |
|
||||||
| --- | --------------------------------- | --------------------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------- |
|
| ---- | ----------------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------- |
|
||||||
| A7 | **Denoise in-source** | ML noise suppression runs inside EC as a LiveKit `TrackProcessor<Audio>` (flag `lotusDenoiseSource=1`); re-applied on every (re)publish | the build-time `getUserMedia` monkeypatch injected into `index.html` — **removed**. Fixes mic-dead-after-reconnect. |
|
| A7 | **Denoise in-source** | ML noise suppression runs inside EC as a LiveKit `TrackProcessor<Audio>` (flag `lotusDenoiseSource=1`); re-applied on every (re)publish | the build-time `getUserMedia` monkeypatch injected into `index.html` — **removed**. Fixes mic-dead-after-reconnect. |
|
||||||
| #2 | **Speaking / mute events** | EC emits `io.lotus.call_state` (throttled); cinny reads speaker + mute state from it (flag `lotusCallState=1`) | scraping EC's DOM for `[data-lk-speaking]` (kept only as fallback) |
|
| #2 | **Speaking / mute events** | EC emits `io.lotus.call_state` (throttled); cinny reads speaker + mute state from it (flag `lotusCallState=1`) | scraping EC's DOM for `[data-lk-speaking]` (kept only as fallback) |
|
||||||
| A5 | **Focus participant** | host sends `io.lotus.focus_participant` to pin a tile, coexisting with / overriding the screenshare spotlight | the `.click()`-the-tile DOM hack in `CallControl.ts` — **removed** |
|
| A5 | **Focus participant** | host sends `io.lotus.focus_participant` to pin a tile, coexisting with / overriding the screenshare spotlight | the `.click()`-the-tile DOM hack in `CallControl.ts` — **removed** |
|
||||||
| #6 | **In-call avatar decorations** | host pushes `io.lotus.decorations` (per-user APNG URLs); the fork renders them on EC's video-tile avatars | previously impossible — decorations only showed on our pre-join lobby roster |
|
| #6 | **In-call avatar decorations** | host pushes `io.lotus.decorations` (per-user APNG URLs); the fork renders them on EC's video-tile avatars | previously impossible — decorations only showed on our pre-join lobby roster |
|
||||||
| #5 | **Native transparent background** | flag `lotusTransparent=1` makes EC's surface transparent so the host wallpaper shows through | the injected `background:none !important` CSS |
|
| #5 | **Native transparent background** | flag `lotusTransparent=1` makes EC's surface transparent so the host wallpaper shows through | the injected `background:none !important` CSS |
|
||||||
|
| P6-2 | **Deafen / screenshare-audio mute** | host sends `io.lotus.set_deafen {deafened, screenshareAudioMuted}`; both become the `muted` prop of EC's audio elements (server stops sending), so they hold across re-renders, late joiners and a sharer stopping + re-sharing (fixed in `0.25.0-lotus.4`) | the iframe-DOM `.muted` hack (kept only as a transitional fallback) and `setVolume(0, ScreenShareAudio)`, which EC's own volume controls reset on every new share |
|
||||||
|
|
||||||
**Now wired (cinny drives them — ⚠️ awaiting live verification):**
|
**Now wired (cinny drives them — verified end-to-end on the local calls stack, 2026-09-18):**
|
||||||
|
|
||||||
| # | Capability | Widget action | cinny surface |
|
| # | Capability | Widget action | cinny surface |
|
||||||
| ----- | -------------------- | ------------------------------------------------------------------------------------ | ------------------------------------------------------------------- |
|
| ----- | -------------------- | ------------------------------------------------------------------------------------ | ------------------------------------------------------------------- |
|
||||||
@@ -365,7 +366,9 @@ so a stock EC config is byte-for-byte upstream behavior.
|
|||||||
| P5-31 | **Quality controls** | `io.lotus.set_quality` — sets audio/screenshare encoding bitrate/framerate | Call Quality Controls (user settings + room-admin caps) — see below |
|
| P5-31 | **Quality controls** | `io.lotus.set_quality` — sets audio/screenshare encoding bitrate/framerate | Call Quality Controls (user settings + room-admin caps) — see below |
|
||||||
|
|
||||||
> Both were dormant capabilities; cinny now drives them (armed via
|
> Both were dormant capabilities; cinny now drives them (armed via
|
||||||
> `lotusAudioInject=1`). The **only** EC item still open is the P5-31
|
> `lotusAudioInject=1`). Verified headless with two clients: a clip publishes as
|
||||||
|
> an extra `AUDIO/UNKNOWN` track on the SFU and is refused while muted; a room
|
||||||
|
> cap set mid-call re-sends `io.lotus.set_quality` with the clamped values. The **only** EC item still open is the P5-31
|
||||||
> **server-side** quality guard (a `voice-limit-guard`-style sidecar reading
|
> **server-side** quality guard (a `voice-limit-guard`-style sidecar reading
|
||||||
> `io.lotus.room_quality`) for hard enforcement across all Matrix clients — the
|
> `io.lotus.room_quality`) for hard enforcement across all Matrix clients — the
|
||||||
> client cap is best-effort.
|
> client cap is best-effort.
|
||||||
@@ -1179,6 +1182,14 @@ Links you paste, send, edit, or merely _see_ lose ad/analytics identifiers — `
|
|||||||
|
|
||||||
The syncable subset of Lotus settings (theme, composer toolbar order, notification/quiet-hour preferences, call keys, privacy toggles, …) is mirrored to the `io.lotus.settings` account-data event on the user's own homeserver and applied on every other device. Device-bound keys stay local (`DEVICE_LOCAL_KEYS` in `src/app/utils/settingsSync.ts`: page zoom, media auto-load, animation pause, glassmorphism, noise-suppression tier/model, bitrates, volumes, notification permission, developer tools, PTT mode, camera-on-join, drawer state). Conflicts are last-write-wins on an `updatedAt` stamp forced monotonic per device; a per-account `lastSyncedAt` marker in localStorage stops a device from echoing a snapshot it just applied. **Settings → General → Sync** has the toggle (itself device-local), **Push now** (make this device win everywhere) and **Clear synced copy**. Hook: `src/app/hooks/useSettingsSync.ts`, mounted from `ClientNonUIFeatures`.
|
The syncable subset of Lotus settings (theme, composer toolbar order, notification/quiet-hour preferences, call keys, privacy toggles, …) is mirrored to the `io.lotus.settings` account-data event on the user's own homeserver and applied on every other device. Device-bound keys stay local (`DEVICE_LOCAL_KEYS` in `src/app/utils/settingsSync.ts`: page zoom, media auto-load, animation pause, glassmorphism, noise-suppression tier/model, bitrates, volumes, notification permission, developer tools, PTT mode, camera-on-join, drawer state). Conflicts are last-write-wins on an `updatedAt` stamp forced monotonic per device; a per-account `lastSyncedAt` marker in localStorage stops a device from echoing a snapshot it just applied. **Settings → General → Sync** has the toggle (itself device-local), **Push now** (make this device win everywhere) and **Clear synced copy**. Hook: `src/app/hooks/useSettingsSync.ts`, mounted from `ClientNonUIFeatures`.
|
||||||
|
|
||||||
|
### Push to Deafen: off switch + typing-safe
|
||||||
|
|
||||||
|
**Settings → Calls → Push to Deafen** now has a switch (off = no key toggles deafen; the call-bar headphone button remains). Root cause of the "I went deaf while typing" reports: Cinny's type-anywhere-to-focus-the-composer and the deafen key both listen on `window`, so with the default `M` the first letter of a message typed after clicking the timeline toggled deafen and was swallowed (`mom` → `om`). Rules now: a typable key (letter/digit/Space/…) only toggles deafen in the call view — on any screen with a composer, typing wins; and such keys are never bound system-wide on desktop (`isSafeGlobalToggleKey`: F-keys, numpad, lock/navigation cluster qualify), so the letter `m` typed in Discord or a game can't deafen you either. The tile explains this and suggests an F-key/Numpad key for an everywhere binding.
|
||||||
|
|
||||||
|
### Forwarded messages show their provenance
|
||||||
|
|
||||||
|
A forwarded message used to arrive as if the forwarder had written it. `buildForwardContent` now stamps `io.lotus.forwarded` (`sender`, `origin_server_ts`, `room_id`, `event_id`; forwarding a forward keeps the _original_ stamp) and the timeline (main + threads) renders a reply-style line above the message — **↪ Forwarded from bob in Other Room · 9:05 PM** — which is a button that jumps to the original when you are in the source room; if you are not, it shows only the sender and time (the source room's name is deliberately not shared). Other Matrix clients ignore the key and see the plain content. Component: `src/app/components/message/ForwardedHeader.tsx`.
|
||||||
|
|
||||||
### Copy Lotus Link — direct permalinks (Gitea #130)
|
### Copy Lotus Link — direct permalinks (Gitea #130)
|
||||||
|
|
||||||
`matrix.to` cannot be pointed at this deployment (its Cinny adapter is hard-coded to `app.cinny.in`; `web-instance[]` only works for Element), so every **Copy Link** (message ⋯ menu, space header menu, sidebar space-tab menu) has a **Copy Lotus Link** beside it that yields `https://chat.lotusguild.org/home/<room>/<event>?viaServers=…` (spaces: `/<space>/`). Helpers in `src/app/plugins/lotus-permalink.ts` (unit-tested). Lotus links pasted into a room render and click like matrix.to links (`toMatrixToHref` in the HTML parser rewrites them into the existing mention pipeline). Supporting fixes: `/home/<room>` for a room you are already in but that lives under a space or in Direct now redirects to its own route instead of a preview card (this is also the form matrix.to → "Continue in Cinny" produces); `?via=a,b` is accepted as an alias of `?viaServers=` (the matrix.to Cinny adapter emits `via`); and a deep link opened while logged out is honoured after an **OIDC/SSO** login too — the OIDC callback reloads at the app root, which previously discarded the stored path (`takeAfterLoginPath` is now consumed by the index route as well as the password flow). matrix.to stays the default, interoperable link and the Share Room QR is unchanged.
|
`matrix.to` cannot be pointed at this deployment (its Cinny adapter is hard-coded to `app.cinny.in`; `web-instance[]` only works for Element), so every **Copy Link** (message ⋯ menu, space header menu, sidebar space-tab menu) has a **Copy Lotus Link** beside it that yields `https://chat.lotusguild.org/home/<room>/<event>?viaServers=…` (spaces: `/<space>/`). Helpers in `src/app/plugins/lotus-permalink.ts` (unit-tested). Lotus links pasted into a room render and click like matrix.to links (`toMatrixToHref` in the HTML parser rewrites them into the existing mention pipeline). Supporting fixes: `/home/<room>` for a room you are already in but that lives under a space or in Direct now redirects to its own route instead of a preview card (this is also the form matrix.to → "Continue in Cinny" produces); `?via=a,b` is accepted as an alias of `?viaServers=` (the matrix.to Cinny adapter emits `via`); and a deep link opened while logged out is honoured after an **OIDC/SSO** login too — the OIDC callback reloads at the app root, which previously discarded the stored path (`takeAfterLoginPath` is now consumed by the index route as well as the password flow). matrix.to stays the default, interoperable link and the Share Room QR is unchanged.
|
||||||
|
|||||||
+1
-1
@@ -79,7 +79,7 @@ Fork = `LotusGuild/element-call` (branch `lotus`, upstream base **v0.25.0** sinc
|
|||||||
|
|
||||||
**Toolchain (upstream-driven, accepted 2026-09):** Node ≥ 22.13 (`.node-version` = 24) and **pnpm 11**, installed directly (`npm i -g pnpm@<packageManager version>`, currently 11.21.0) — **not** via `corepack enable`: `matrix-js-sdk` is a git dependency pnpm builds from source, and its own devEngines pins pnpm 11.9.0; a corepack-shimmed pnpm refuses to switch for that nested install and `pnpm install` fails (fork CI run #1854). pnpm 10 rejects the lockfile and Node 20 cannot build. Lint is **oxlint + oxfmt** (upstream dropped eslint/prettier in v0.25.0): `pnpm lint` (tsc + oxlint + knip) and `pnpm format:check` / `pnpm format`. `matrix-js-sdk` is pinned to a `matrix-org/matrix-js-sdk#develop` commit in the lockfile, as upstream ships it. Fork CI (`.gitea/workflows/ci.yml`) hard-gates lint + format + `pnpm test:unit` before build, with `concurrency: cancel-in-progress`.
|
**Toolchain (upstream-driven, accepted 2026-09):** Node ≥ 22.13 (`.node-version` = 24) and **pnpm 11**, installed directly (`npm i -g pnpm@<packageManager version>`, currently 11.21.0) — **not** via `corepack enable`: `matrix-js-sdk` is a git dependency pnpm builds from source, and its own devEngines pins pnpm 11.9.0; a corepack-shimmed pnpm refuses to switch for that nested install and `pnpm install` fails (fork CI run #1854). pnpm 10 rejects the lockfile and Node 20 cannot build. Lint is **oxlint + oxfmt** (upstream dropped eslint/prettier in v0.25.0): `pnpm lint` (tsc + oxlint + knip) and `pnpm format:check` / `pnpm format`. `matrix-js-sdk` is pinned to a `matrix-org/matrix-js-sdk#develop` commit in the lockfile, as upstream ships it. Fork CI (`.gitea/workflows/ci.yml`) hard-gates lint + format + `pnpm test:unit` before build, with `concurrency: cancel-in-progress`.
|
||||||
|
|
||||||
**Publish a new version (CI on tag push; needs the `NPM_PUBLISH_TOKEN` org secret):** the published version is derived from the git tag — bump `embedded/web/package.json` (currently `0.25.0-lotus.3`, published by CI; the secret is `NPM_PUBLISH_TOKEN`, names starting `GITEA_` are reserved), push `lotus`, then `git push lotus v0.25.0-lotus.1`; the `publish` job builds and publishes to the Gitea registry. Always push (never delete) the annotated `vX.Y.Z-lotus.N` tag for every published version. Then in cinny bump the `@lotusguild/element-call-embedded` pin (currently `0.25.0-lotus.3`) → `npm install` → build. Manual fallback: `pnpm run build:embedded && cd embedded/web && npm version <ver> --no-git-tag-version && npm publish`.
|
**Publish a new version (CI on tag push; needs the `NPM_PUBLISH_TOKEN` org secret):** the published version is derived from the git tag — bump `embedded/web/package.json` (currently `0.25.0-lotus.12`, published by CI; the secret is `NPM_PUBLISH_TOKEN`, names starting `GITEA_` are reserved), push `lotus`, then `git push lotus v0.25.0-lotus.1`; the `publish` job builds and publishes to the Gitea registry. Always push (never delete) the annotated `vX.Y.Z-lotus.N` tag for every published version. Then in cinny bump the `@lotusguild/element-call-embedded` pin (currently `0.25.0-lotus.12`) → `npm install` → build. Manual fallback: `pnpm run build:embedded && cd embedded/web && npm version <ver> --no-git-tag-version && npm publish`.
|
||||||
|
|
||||||
**`io.lotus.*` widget actions** (add new toWidget actions to the enum + `LOTUS_TO_WIDGET_ACTIONS` in `src/lotus/lotusActions.ts`; only send AFTER call-join or a 10s timeout fires):
|
**`io.lotus.*` widget actions** (add new toWidget actions to the enum + `LOTUS_TO_WIDGET_ACTIONS` in `src/lotus/lotusActions.ts`; only send AFTER call-join or a 10s timeout fires):
|
||||||
|
|
||||||
|
|||||||
+12
-5
@@ -19,6 +19,8 @@ python3 scripts/dev-seed.py 400 # alice + bob, "Busy Room": 400 messages, an
|
|||||||
npm start # Vite on :5173
|
npm start # Vite on :5173
|
||||||
```
|
```
|
||||||
|
|
||||||
|
**Calls too:** `scripts/dev-homeserver.sh calls` adds a LiveKit SFU, a JWT issuer, the real `voice-limit-guard` from the `matrix` checkout and an https well-known — real two-party calls in headless Chromium with fake mic/camera (`--use-fake-device-for-media-stream`, `--use-file-for-fake-audio-capture=<tone.wav>` to trigger speaking detection, `--auto-select-desktop-capture-source="Entire screen"` for screenshare; `ignoreHTTPSErrors: true`). This is how #29, #161, #173/#174 and the guard's live-revoke bug were found and fixed on 2026-09-18.
|
||||||
|
|
||||||
Log in at `http://127.0.0.1:5173/login/http%3A%2F%2Flocalhost%3A8008/` as `alice` / `password123` (bob is the second participant; both can also be driven over the client API with their tokens). Playwright is installed (`npm run test:e2e:install`), so a scripted reproduction is `node` + `chromium.launch()` against `:5173` — this is how Gitea #163 was reproduced and its fix verified in both plain and encrypted rooms. `scripts/dev-homeserver.sh reset` wipes the database; `stop` shuts it down.
|
Log in at `http://127.0.0.1:5173/login/http%3A%2F%2Flocalhost%3A8008/` as `alice` / `password123` (bob is the second participant; both can also be driven over the client API with their tokens). Playwright is installed (`npm run test:e2e:install`), so a scripted reproduction is `node` + `chromium.launch()` against `:5173` — this is how Gitea #163 was reproduced and its fix verified in both plain and encrypted rooms. `scripts/dev-homeserver.sh reset` wipes the database; `stop` shuts it down.
|
||||||
|
|
||||||
## Automated coverage map — what the unit tests already pin (2026-07)
|
## Automated coverage map — what the unit tests already pin (2026-07)
|
||||||
@@ -47,12 +49,17 @@ Everything else in the guide (calls, screen readers, desktop/Tauri, chat backgro
|
|||||||
|
|
||||||
## Playwright smoke test (Gitea #90) — `npm run test:e2e`
|
## Playwright smoke test (Gitea #90) — `npm run test:e2e`
|
||||||
|
|
||||||
Browser-level smoke tests under `e2e/` (config: `playwright.config.ts`). They boot the **built** `dist/` through `vite preview` on port 4173, so run `npm run build` first (one-time: `npm run test:e2e:install` downloads the pinned Chromium). Two tiers:
|
Browser-level smoke tests under `e2e/` (config: `playwright.config.ts`). They boot the **built** `dist/` through `vite preview` on port 4173, so run `npm run build` first (one-time: `npm run test:e2e:install` downloads the pinned Chromium). Three tiers:
|
||||||
|
|
||||||
| Tier | File | When it runs | What it proves |
|
| Tier | File | When it runs | What it proves |
|
||||||
| :------------------------ | :-------------------------- | :----------------------------------------------------------------- | :--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
|
| :-------------------------------- | :----------------------------- | :------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | :------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
|
||||||
| **Boot** (always) | `e2e/boot.spec.ts` | every CI run (`e2e` job in `.gitea/workflows/ci.yml`) and locally | login page renders with `#root` populated and **no** `pageerror` / unexpected `console.error` (allowlist in `e2e/helpers.ts`: the README's avatar-thumbnail 404, the login page's `POST /register` 401 probe, offline discovery), `sw.js` is served and registers, bundled Element Call mounts in a frame with every `/public/element-call/` asset returning 200 |
|
| **Boot** (always) | `e2e/boot.spec.ts` | every CI run (`e2e` job in `.gitea/workflows/ci.yml`) and locally | login page renders with `#root` populated and **no** `pageerror` / unexpected `console.error` (allowlist in `e2e/helpers.ts`: the README's avatar-thumbnail 404, the login page's `POST /register` 401 probe, offline discovery), `sw.js` is served and registers, bundled Element Call mounts in a frame with every `/public/element-call/` asset returning 200 |
|
||||||
| **E2EE composer** (gated) | `e2e/e2ee-composer.spec.ts` | only when `E2E_HOMESERVER`, `E2E_USER`, `E2E_PASSWORD` are all set | password login → `/home/create/` with the End-to-End Encryption switch on (asserts `createRoom` carries `m.room.encryption`) → text message renders → attach a generated JPEG with "Compress image before uploading" ticked, image renders → every `PUT …/rooms/*/send/*` was `m.room.encrypted` with `ciphertext` and no plaintext `body` / `url` / `file` / `mxc://` |
|
| **E2EE composer** (gated) | `e2e/e2ee-composer.spec.ts` | only when `E2E_HOMESERVER`, `E2E_USER`, `E2E_PASSWORD` are all set | password login → `/home/create/` with the End-to-End Encryption switch on (asserts `createRoom` carries `m.room.encryption`) → text message renders → attach a generated JPEG with "Compress image before uploading" ticked, image renders → every `PUT …/rooms/*/send/*` was `m.room.encrypted` with `ciphertext` and no plaintext `body` / `url` / `file` / `mxc://` |
|
||||||
|
| **Local homeserver** (Gitea #220) | `e2e/local-homeserver.spec.ts` | when a Synapse answers at `E2E_LOCAL_HS` (default `http://localhost:8008`); the CI `e2e` job starts one with `scripts/dev-homeserver.sh start` + `dev-seed.py`, locally run the same two commands | registers its own `e2e_alice_*`/`e2e_bob_*` users and rooms over the CS API, then drives the built client: login + send/receive, own message scrolls into view (#212), `/kick` failure toast (#216), upload 413 sentence (#213), forward provenance header, thread panel + drawer at 1400 px (#218), timeline image → gallery lightbox (#219), clock-skew banner via `page.clock` (#158), status save under the presence rate limit (#226), long-press action sheet on a Pixel 7 emulation (#166). Helpers in `e2e/localHs.ts`; add a test here whenever a fix was reproduced with a scratch Playwright script |
|
||||||
|
|
||||||
|
**Accessibility gate** (Gitea #222): `e2e/a11y.spec.ts` runs `@axe-core/playwright` (WCAG 2.x A/AA tags) over the login page, room timeline + composer, message options menu, thread panel, user settings and room settings, and fails on any **critical/serious** finding except `color-contrast` (reported in the log, not gated — generated avatar colours and portal false positives). It also keeps accessibility-tree snapshots (`e2e/a11y.spec.ts-snapshots/*.aria.yml`) of the composer, message menu, thread panel and settings nav, so a lost name/role/live-region shows as a diff; update them deliberately with `npx playwright test e2e/a11y --update-snapshots` and keep dynamic bits as regexes. A real NVDA/VoiceOver pass is still manual.
|
||||||
|
|
||||||
|
**Browsers** (Gitea #221): everything runs under Chromium; the tests tagged `@webkit` (boot, login + send/receive, thread panel, lightbox) also run under Playwright's WebKit as desktop Safari, and those tagged `@ios` under the `iPhone 14` descriptor — the closest CI gets to Safari/iOS. It catches WebKit-only breakage (CSS, `dvh`, IndexedDB, media decode) but does not emulate the on-screen keyboard or Home-Screen install; a real iPhone pass (#166/#199) stays manual. Locally: `npx playwright install --with-deps webkit` once, then `npx playwright test --project=webkit --project=iphone`. WebKit words handled fetch failures as page errors (`TypeError: Load failed`, `due to access control checks`), so the allowlist in `e2e/helpers.ts` applies to page errors too.
|
||||||
|
|
||||||
**CI secrets** (Gitea → repo → Settings → Actions → Secrets; the `e2e` job forwards them via `env:`; until they exist the E2EE tier reports `skipped`, the boot tier still runs):
|
**CI secrets** (Gitea → repo → Settings → Actions → Secrets; the `e2e` job forwards them via `env:`; until they exist the E2EE tier reports `skipped`, the boot tier still runs):
|
||||||
|
|
||||||
|
|||||||
@@ -196,7 +196,7 @@ The dev server defaults to **port 8080** (`vite.config.js`); if 8080 is already
|
|||||||
### 🔱 Element Call fork ("Lotus Call") — LIVE
|
### 🔱 Element Call fork ("Lotus Call") — LIVE
|
||||||
|
|
||||||
Voice/video channels embed **Element Call**, which is now our **self-built fork**
|
Voice/video channels embed **Element Call**, which is now our **self-built fork**
|
||||||
(`@lotusguild/element-call-embedded` `0.25.0-lotus.3`, upstream base v0.25.0, source at
|
(`@lotusguild/element-call-embedded` `0.25.0-lotus.12`, upstream base v0.25.0, source at
|
||||||
`LotusGuild/element-call`), published to our private Gitea npm registry and served
|
`LotusGuild/element-call`), published to our private Gitea npm registry and served
|
||||||
same-origin. We no longer depend on the upstream prebuilt bundle, so in-call
|
same-origin. We no longer depend on the upstream prebuilt bundle, so in-call
|
||||||
behavior is editable source instead of fragile DOM/widget hacks.
|
behavior is editable source instead of fragile DOM/widget hacks.
|
||||||
|
|||||||
@@ -1,6 +1,10 @@
|
|||||||
# more info: https://caddyserver.com/docs/caddyfile/patterns#single-page-apps-spas
|
# more info: https://caddyserver.com/docs/caddyfile/patterns#single-page-apps-spas
|
||||||
cinny.domain.tld {
|
cinny.domain.tld {
|
||||||
root * /path/to/cinny/dist
|
root * /path/to/cinny/dist
|
||||||
|
# [Gitea #155] PWA share target: the service worker answers this POST; if it
|
||||||
|
# isn't controlling the page yet, land on /share instead of a 405.
|
||||||
|
redir /share-target /share 303
|
||||||
|
|
||||||
try_files {path} /index.html
|
try_files {path} /index.html
|
||||||
file_server
|
file_server
|
||||||
|
|
||||||
|
|||||||
@@ -26,6 +26,13 @@ server {
|
|||||||
add_header Strict-Transport-Security "max-age=63072000; includeSubDomains" always;
|
add_header Strict-Transport-Security "max-age=63072000; includeSubDomains" always;
|
||||||
add_header Permissions-Policy "accelerometer=(), autoplay=(self), camera=(self), display-capture=(self), encrypted-media=(self), fullscreen=(self), geolocation=(self), gyroscope=(), magnetometer=(), microphone=(self), midi=(), payment=(), usb=()" always;
|
add_header Permissions-Policy "accelerometer=(), autoplay=(self), camera=(self), display-capture=(self), encrypted-media=(self), fullscreen=(self), geolocation=(self), gyroscope=(), magnetometer=(), microphone=(self), midi=(), payment=(), usb=()" always;
|
||||||
|
|
||||||
|
# [Gitea #155] PWA share target. The service worker normally answers this
|
||||||
|
# POST itself; if it isn't controlling the page yet, land on /share
|
||||||
|
# (the shared files are lost, but nothing 405s).
|
||||||
|
location = /share-target {
|
||||||
|
return 303 /share;
|
||||||
|
}
|
||||||
|
|
||||||
location / {
|
location / {
|
||||||
root /opt/cinny/dist/;
|
root /opt/cinny/dist/;
|
||||||
|
|
||||||
|
|||||||
@@ -0,0 +1,125 @@
|
|||||||
|
import { test, expect, Page } from '@playwright/test';
|
||||||
|
import AxeBuilder from '@axe-core/playwright';
|
||||||
|
import {
|
||||||
|
createRoom,
|
||||||
|
hsReachable,
|
||||||
|
loginUI,
|
||||||
|
openRoom,
|
||||||
|
ensureUser,
|
||||||
|
sendText,
|
||||||
|
uniq,
|
||||||
|
TestUser,
|
||||||
|
} from './localHs';
|
||||||
|
|
||||||
|
// [Gitea #222] Machine-checkable accessibility on every push. Two parts:
|
||||||
|
// 1. axe-core over the main surfaces, failing on critical/serious findings.
|
||||||
|
// Colour-contrast is reported but not gated: several hits are generated
|
||||||
|
// avatar colours and portal false positives (see the issue for the list).
|
||||||
|
// 2. Accessibility-tree snapshots of the composer, message menu, thread
|
||||||
|
// panel and settings nav, so a lost name/role/live-region shows up as a
|
||||||
|
// diff. Update deliberately with `npx playwright test e2e/a11y --update-snapshots`.
|
||||||
|
// A real screen-reader pass still needs a human.
|
||||||
|
|
||||||
|
const TAGS = ['wcag2a', 'wcag2aa', 'wcag21a', 'wcag21aa'];
|
||||||
|
|
||||||
|
async function auditPage(page: Page, label: string) {
|
||||||
|
const results = await new AxeBuilder({ page }).withTags(TAGS).analyze();
|
||||||
|
const describe = (v: (typeof results.violations)[number]) =>
|
||||||
|
`[${v.impact}] ${v.id}: ${v.help}\n${v.nodes
|
||||||
|
.slice(0, 5)
|
||||||
|
.map((n) => ` ${n.html.replace(/\s+/g, ' ').slice(0, 140)}`)
|
||||||
|
.join('\n')}`;
|
||||||
|
const contrast = results.violations.filter((v) => v.id === 'color-contrast');
|
||||||
|
if (contrast.length) {
|
||||||
|
// eslint-disable-next-line no-console
|
||||||
|
console.log(`axe ${label}: contrast (not gated)\n${contrast.map(describe).join('\n')}`);
|
||||||
|
}
|
||||||
|
const gated = results.violations.filter(
|
||||||
|
(v) => v.id !== 'color-contrast' && (v.impact === 'critical' || v.impact === 'serious'),
|
||||||
|
);
|
||||||
|
expect(gated.map(describe), `axe ${label}: critical/serious findings`).toEqual([]);
|
||||||
|
}
|
||||||
|
|
||||||
|
test.describe('accessibility', () => {
|
||||||
|
test('login page passes axe @webkit', async ({ page }) => {
|
||||||
|
await page.goto('/');
|
||||||
|
await expect(page.getByLabel('Username or email')).toBeVisible();
|
||||||
|
await auditPage(page, 'login');
|
||||||
|
});
|
||||||
|
|
||||||
|
test.describe('signed in', () => {
|
||||||
|
let alice: TestUser;
|
||||||
|
let room: string;
|
||||||
|
|
||||||
|
test.beforeAll(async () => {
|
||||||
|
test.skip(!(await hsReachable()), 'no local homeserver');
|
||||||
|
alice = await ensureUser(uniq('e2e_a11y_'));
|
||||||
|
room = await createRoom(alice, 'A11y Room');
|
||||||
|
const root = await sendText(alice, room, 'thread root for a11y');
|
||||||
|
await sendText(alice, room, 'a reply', {
|
||||||
|
'm.relates_to': {
|
||||||
|
rel_type: 'm.thread',
|
||||||
|
event_id: root,
|
||||||
|
is_falling_back: true,
|
||||||
|
'm.in_reply_to': { event_id: root },
|
||||||
|
},
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
test.beforeEach(async ({ page }) => {
|
||||||
|
await page.setViewportSize({ width: 1400, height: 850 });
|
||||||
|
await loginUI(page, alice);
|
||||||
|
await openRoom(page, room);
|
||||||
|
await expect(page.getByText('thread root for a11y')).toBeVisible();
|
||||||
|
});
|
||||||
|
|
||||||
|
test('room timeline + composer', async ({ page }) => {
|
||||||
|
await auditPage(page, 'room');
|
||||||
|
await expect(page.locator('[data-slate-editor]').first()).toMatchAriaSnapshot({
|
||||||
|
name: 'composer-editor.aria.yml',
|
||||||
|
});
|
||||||
|
await expect(page.getByRole('button', { name: 'Send message' })).toMatchAriaSnapshot({
|
||||||
|
name: 'composer-send.aria.yml',
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
test('message options menu', async ({ page }) => {
|
||||||
|
const msg = page.locator('[data-message-item]', { hasText: 'thread root for a11y' });
|
||||||
|
await msg.hover();
|
||||||
|
await msg.getByRole('button', { name: 'More options' }).click();
|
||||||
|
const menu = page.locator('[data-message-menu]').first();
|
||||||
|
await expect(menu).toBeVisible();
|
||||||
|
await auditPage(page, 'message menu');
|
||||||
|
await expect(menu).toMatchAriaSnapshot({ name: 'message-menu.aria.yml' });
|
||||||
|
});
|
||||||
|
|
||||||
|
test('thread panel', async ({ page }) => {
|
||||||
|
await page
|
||||||
|
.locator('[data-message-item]', { hasText: 'thread root for a11y' })
|
||||||
|
.getByText(/1 reply/)
|
||||||
|
.click();
|
||||||
|
await expect(page.locator('[data-slate-editor]')).toHaveCount(2);
|
||||||
|
await auditPage(page, 'thread panel');
|
||||||
|
await expect(page.getByRole('complementary').first()).toMatchAriaSnapshot({
|
||||||
|
name: 'thread-panel.aria.yml',
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
test('user settings', async ({ page }) => {
|
||||||
|
await page.getByRole('button', { name: 'User Settings' }).click();
|
||||||
|
const dialog = page.getByRole('dialog').first();
|
||||||
|
await expect(dialog).toBeVisible();
|
||||||
|
await auditPage(page, 'settings');
|
||||||
|
await expect(dialog.getByRole('navigation').first()).toMatchAriaSnapshot({
|
||||||
|
name: 'settings-nav.aria.yml',
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
test('room settings', async ({ page }) => {
|
||||||
|
await page.getByRole('button', { name: 'More Options' }).first().click();
|
||||||
|
await page.getByText('Room Settings', { exact: true }).click();
|
||||||
|
await expect(page.getByRole('dialog').first()).toBeVisible();
|
||||||
|
await auditPage(page, 'room settings');
|
||||||
|
});
|
||||||
|
});
|
||||||
|
});
|
||||||
@@ -0,0 +1,2 @@
|
|||||||
|
- textbox "Send a message...":
|
||||||
|
- paragraph: Send a message...
|
||||||
@@ -0,0 +1,2 @@
|
|||||||
|
- button "Send message":
|
||||||
|
- img
|
||||||
@@ -0,0 +1,39 @@
|
|||||||
|
- button "Add Reaction":
|
||||||
|
- text: ''
|
||||||
|
- img
|
||||||
|
- button "Reply":
|
||||||
|
- text: ''
|
||||||
|
- img
|
||||||
|
- button "Forward":
|
||||||
|
- text: ''
|
||||||
|
- img
|
||||||
|
- button "Bookmark Message":
|
||||||
|
- text: ''
|
||||||
|
- img
|
||||||
|
- button "Remind Me":
|
||||||
|
- text: ''
|
||||||
|
- img
|
||||||
|
- button "Edit Message":
|
||||||
|
- text: ''
|
||||||
|
- img
|
||||||
|
- button "Read Receipts":
|
||||||
|
- text: ''
|
||||||
|
- img
|
||||||
|
- button "Copy Text":
|
||||||
|
- text: ''
|
||||||
|
- img
|
||||||
|
- button "Translate":
|
||||||
|
- text: ''
|
||||||
|
- img
|
||||||
|
- button "Copy Link":
|
||||||
|
- text: ''
|
||||||
|
- img
|
||||||
|
- button "Copy Lotus Link":
|
||||||
|
- text: ''
|
||||||
|
- img
|
||||||
|
- button "Pin Message":
|
||||||
|
- text: ''
|
||||||
|
- img
|
||||||
|
- button "Delete":
|
||||||
|
- text: ''
|
||||||
|
- img
|
||||||
@@ -0,0 +1,22 @@
|
|||||||
|
- navigation "Settings sections":
|
||||||
|
- button "General" [pressed]:
|
||||||
|
- img
|
||||||
|
- paragraph: General
|
||||||
|
- button "Account":
|
||||||
|
- img
|
||||||
|
- paragraph: Account
|
||||||
|
- button "Notifications":
|
||||||
|
- img
|
||||||
|
- paragraph: Notifications
|
||||||
|
- button "Devices":
|
||||||
|
- img
|
||||||
|
- paragraph: Devices
|
||||||
|
- button "Emojis & Stickers":
|
||||||
|
- img
|
||||||
|
- paragraph: Emojis & Stickers
|
||||||
|
- button "Developer Tools":
|
||||||
|
- img
|
||||||
|
- paragraph: Developer Tools
|
||||||
|
- button "About":
|
||||||
|
- img
|
||||||
|
- paragraph: About
|
||||||
@@ -0,0 +1,31 @@
|
|||||||
|
- complementary "Thread":
|
||||||
|
- paragraph: Thread
|
||||||
|
- paragraph: /A11y Room · started by e2e_a11y_\w+, .+/
|
||||||
|
- button "Thread notifications":
|
||||||
|
- img
|
||||||
|
- button "Close thread":
|
||||||
|
- img
|
||||||
|
- log "Thread timeline":
|
||||||
|
- article:
|
||||||
|
- button /e2e_a11y_\w+, open profile/:
|
||||||
|
- img
|
||||||
|
- button /e2e_a11y_\w+/
|
||||||
|
- time: /\d+:\d+ (AM|PM)/
|
||||||
|
- text: thread root for a11y
|
||||||
|
- paragraph: 1 reply
|
||||||
|
- article:
|
||||||
|
- button /e2e_a11y_\w+, open profile/:
|
||||||
|
- img
|
||||||
|
- button /e2e_a11y_\w+/
|
||||||
|
- time: /\d+:\d+ (AM|PM)/
|
||||||
|
- text: a reply
|
||||||
|
- button "More actions":
|
||||||
|
- img
|
||||||
|
- textbox "Send a message...":
|
||||||
|
- paragraph: Send a message...
|
||||||
|
- button "Insert sticker":
|
||||||
|
- img
|
||||||
|
- button "Insert emoji":
|
||||||
|
- img
|
||||||
|
- button "Send message":
|
||||||
|
- img
|
||||||
+2
-2
@@ -5,7 +5,7 @@ import { collectConsole } from './helpers';
|
|||||||
// `vite preview` (see playwright.config.ts webServer). No homeserver needed.
|
// `vite preview` (see playwright.config.ts webServer). No homeserver needed.
|
||||||
|
|
||||||
test.describe('boot', () => {
|
test.describe('boot', () => {
|
||||||
test('client boots to the login screen without errors', async ({ page }) => {
|
test('client boots to the login screen without errors @webkit @ios', async ({ page }) => {
|
||||||
const consoleLog = collectConsole(page);
|
const consoleLog = collectConsole(page);
|
||||||
|
|
||||||
await page.goto('/');
|
await page.goto('/');
|
||||||
@@ -24,7 +24,7 @@ test.describe('boot', () => {
|
|||||||
expect(consoleLog.unexpected(), 'unexpected console/page errors during boot').toEqual([]);
|
expect(consoleLog.unexpected(), 'unexpected console/page errors during boot').toEqual([]);
|
||||||
});
|
});
|
||||||
|
|
||||||
test('service worker script is served and registers', async ({ page }) => {
|
test('service worker script is served and registers @webkit @ios', async ({ page }) => {
|
||||||
const swResponse = await page.request.get('/sw.js');
|
const swResponse = await page.request.get('/sw.js');
|
||||||
expect(swResponse.status(), 'GET /sw.js').toBe(200);
|
expect(swResponse.status(), 'GET /sw.js').toBe(200);
|
||||||
expect(swResponse.headers()['content-type'] ?? '').toMatch(/javascript/);
|
expect(swResponse.headers()['content-type'] ?? '').toMatch(/javascript/);
|
||||||
|
|||||||
+14
-1
@@ -14,6 +14,15 @@ const BENIGN_CONSOLE_PATTERNS: RegExp[] = [
|
|||||||
// Homeserver discovery pings can fail on a runner with no outbound network.
|
// Homeserver discovery pings can fail on a runner with no outbound network.
|
||||||
/\/\.well-known\/matrix\/client/i,
|
/\/\.well-known\/matrix\/client/i,
|
||||||
/Failed to fetch|NetworkError|ERR_NAME_NOT_RESOLVED|ERR_INTERNET_DISCONNECTED/i,
|
/Failed to fetch|NetworkError|ERR_NAME_NOT_RESOLVED|ERR_INTERNET_DISCONNECTED/i,
|
||||||
|
// Tier 3 (local homeserver named "localhost"): the client's well-known
|
||||||
|
// autodiscovery probes https://localhost/, which is either not listening
|
||||||
|
// (CI) or a self-signed dev server (local calls stack).
|
||||||
|
/ERR_CONNECTION_REFUSED|ERR_CERT_AUTHORITY_INVALID|ERR_SSL_PROTOCOL_ERROR/i,
|
||||||
|
// WebKit's spellings of the same discovery failures (#221).
|
||||||
|
/Unacceptable TLS certificate|Could not connect to|Connection refused|TypeError: Load failed/i,
|
||||||
|
// Also a fetch cut short by our own navigation (e.g. the crypto wasm while
|
||||||
|
// the test moves from /home to a room) — WebKit words that the same way.
|
||||||
|
/due to access control checks/i,
|
||||||
// React devtools hint in production bundles.
|
// React devtools hint in production bundles.
|
||||||
/Download the React DevTools/i,
|
/Download the React DevTools/i,
|
||||||
];
|
];
|
||||||
@@ -41,8 +50,12 @@ export function collectConsole(page: Page): ConsoleCollector {
|
|||||||
return {
|
return {
|
||||||
errors,
|
errors,
|
||||||
pageErrors,
|
pageErrors,
|
||||||
|
// WebKit surfaces handled fetch failures (well-known probes) as page
|
||||||
|
// errors rather than console lines, so the allowlist applies to both.
|
||||||
unexpected: () => [
|
unexpected: () => [
|
||||||
...pageErrors.map((m) => `pageerror: ${m}`),
|
...pageErrors
|
||||||
|
.filter((m) => !BENIGN_CONSOLE_PATTERNS.some((re) => re.test(m)))
|
||||||
|
.map((m) => `pageerror: ${m}`),
|
||||||
...errors.filter((m) => !BENIGN_CONSOLE_PATTERNS.some((re) => re.test(m))),
|
...errors.filter((m) => !BENIGN_CONSOLE_PATTERNS.some((re) => re.test(m))),
|
||||||
],
|
],
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -0,0 +1,335 @@
|
|||||||
|
import { test, expect, devices } from '@playwright/test';
|
||||||
|
import {
|
||||||
|
HS,
|
||||||
|
api,
|
||||||
|
createRoom,
|
||||||
|
enc,
|
||||||
|
ensureUser,
|
||||||
|
hsReachable,
|
||||||
|
joinRoom,
|
||||||
|
loginUI,
|
||||||
|
openRoom,
|
||||||
|
sendText,
|
||||||
|
uniq,
|
||||||
|
TestUser,
|
||||||
|
} from './localHs';
|
||||||
|
import { collectConsole } from './helpers';
|
||||||
|
|
||||||
|
// Tier 3 — regression suite against the job's own Synapse (Gitea #220).
|
||||||
|
// Each test seeds what it needs through the CS API and drives the built
|
||||||
|
// client; nothing here touches a real deployment.
|
||||||
|
test.describe('local homeserver regression', () => {
|
||||||
|
let alice: TestUser;
|
||||||
|
let bob: TestUser;
|
||||||
|
|
||||||
|
test.beforeAll(async () => {
|
||||||
|
test.skip(!(await hsReachable()), `no local homeserver at ${HS} (set E2E_LOCAL_HS)`);
|
||||||
|
alice = await ensureUser(uniq('e2e_alice_'));
|
||||||
|
bob = await ensureUser(uniq('e2e_bob_'));
|
||||||
|
});
|
||||||
|
|
||||||
|
test('logs in, opens a room, sends and receives @webkit @ios', async ({ page }) => {
|
||||||
|
const console_ = collectConsole(page);
|
||||||
|
const room = await createRoom(alice, 'Regression Room', { invite: [bob.userId] });
|
||||||
|
await joinRoom(bob, room);
|
||||||
|
await sendText(bob, room, 'hello from bob');
|
||||||
|
await loginUI(page, alice);
|
||||||
|
await openRoom(page, room);
|
||||||
|
await expect(page.getByText('hello from bob')).toBeVisible();
|
||||||
|
await page.locator('[data-slate-editor]').first().click();
|
||||||
|
await page.keyboard.type('hello from alice');
|
||||||
|
await page.keyboard.press('Enter');
|
||||||
|
await expect(page.getByText('hello from alice')).toBeVisible();
|
||||||
|
await expect
|
||||||
|
.poll(
|
||||||
|
async () =>
|
||||||
|
(
|
||||||
|
await api<{ chunk: { content: { body: string } }[] }>(
|
||||||
|
'GET',
|
||||||
|
`/_matrix/client/v3/rooms/${enc(room)}/messages?dir=b&limit=1`,
|
||||||
|
bob.token,
|
||||||
|
)
|
||||||
|
).chunk[0]?.content.body,
|
||||||
|
)
|
||||||
|
.toBe('hello from alice');
|
||||||
|
expect(console_.unexpected()).toEqual([]);
|
||||||
|
});
|
||||||
|
|
||||||
|
test('your own message scrolls into view even after scrolling up (#212)', async ({ page }) => {
|
||||||
|
const room = await createRoom(alice, 'Scroll Room');
|
||||||
|
await Array.from({ length: 40 }).reduce<Promise<unknown>>(
|
||||||
|
(chain, _, i) => chain.then(() => sendText(alice, room, `filler ${i}`)),
|
||||||
|
Promise.resolve(),
|
||||||
|
);
|
||||||
|
await loginUI(page, alice);
|
||||||
|
await openRoom(page, room);
|
||||||
|
await page.mouse.move(600, 350);
|
||||||
|
await page.mouse.wheel(0, -600);
|
||||||
|
await expect(page.getByRole('button', { name: /Jump to Latest/ })).toBeVisible();
|
||||||
|
await page.locator('[data-slate-editor]').first().click();
|
||||||
|
await page.keyboard.type('sent while scrolled up');
|
||||||
|
await page.keyboard.press('Enter');
|
||||||
|
await expect(page.getByText('sent while scrolled up')).toBeInViewport();
|
||||||
|
await expect(page.getByRole('button', { name: /Jump to Latest/ })).toHaveCount(0);
|
||||||
|
});
|
||||||
|
|
||||||
|
test('/kick failure is reported, not swallowed (#216)', async ({ page }) => {
|
||||||
|
const room = await createRoom(alice, 'Kick Room', { invite: [bob.userId] });
|
||||||
|
await joinRoom(bob, room);
|
||||||
|
await loginUI(page, bob);
|
||||||
|
await openRoom(page, room);
|
||||||
|
const editor = page.locator('[data-slate-editor]').first();
|
||||||
|
await editor.click();
|
||||||
|
await page.keyboard.type('/kick', { delay: 40 });
|
||||||
|
await page.keyboard.press('Tab'); // accept the command chip
|
||||||
|
await page.keyboard.type(` ${alice.userId}`, { delay: 20 });
|
||||||
|
await page.keyboard.press('Enter');
|
||||||
|
await expect(page.getByText(/Could not kick .*You cannot kick/)).toBeVisible();
|
||||||
|
});
|
||||||
|
|
||||||
|
test('upload failure shows a plain sentence, never the raw MatrixError (#213)', async ({
|
||||||
|
page,
|
||||||
|
}) => {
|
||||||
|
const room = await createRoom(alice, 'Upload Room');
|
||||||
|
await loginUI(page, alice);
|
||||||
|
await openRoom(page, room);
|
||||||
|
await page.route(/\/_matrix\/media\/v3\/upload/, (route) =>
|
||||||
|
route.fulfill({
|
||||||
|
status: 413,
|
||||||
|
contentType: 'application/json',
|
||||||
|
body: JSON.stringify({ errcode: 'M_TOO_LARGE', error: 'nope' }),
|
||||||
|
}),
|
||||||
|
);
|
||||||
|
const chooser = page.waitForEvent('filechooser');
|
||||||
|
await page.getByRole('button', { name: 'Attach file' }).first().click();
|
||||||
|
await (
|
||||||
|
await chooser
|
||||||
|
).setFiles({
|
||||||
|
name: 'pic.png',
|
||||||
|
mimeType: 'image/png',
|
||||||
|
buffer: Buffer.from(
|
||||||
|
'iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAYAAAAfFcSJAAAADUlEQVR42mNkYPhfDwAChwGA60e6kgAAAABJRU5ErkJggg==',
|
||||||
|
'base64',
|
||||||
|
),
|
||||||
|
});
|
||||||
|
const send = page.getByRole('button', { name: /^Send$/ });
|
||||||
|
if (await send.count()) await send.first().click();
|
||||||
|
else await page.getByRole('button', { name: 'Send message' }).click();
|
||||||
|
await expect(page.getByText(/This file is larger than the server allows/)).toBeVisible();
|
||||||
|
await expect(page.getByText(/MatrixError|_matrix\/media/)).toHaveCount(0);
|
||||||
|
});
|
||||||
|
|
||||||
|
test('forwarded message carries its provenance header', async ({ page }) => {
|
||||||
|
const src = await createRoom(bob, 'Source Room', { invite: [alice.userId] });
|
||||||
|
const dst = await createRoom(alice, 'Destination Room');
|
||||||
|
await joinRoom(alice, src);
|
||||||
|
await sendText(bob, src, 'the original message');
|
||||||
|
await loginUI(page, alice);
|
||||||
|
await openRoom(page, src);
|
||||||
|
const msg = page.locator('[data-message-item]', { hasText: 'the original message' }).first();
|
||||||
|
await msg.hover();
|
||||||
|
await msg.getByRole('button', { name: 'More options' }).click();
|
||||||
|
await page.getByText('Forward', { exact: true }).click();
|
||||||
|
const search = page.getByPlaceholder('Search rooms…');
|
||||||
|
await search.fill('Destination Room');
|
||||||
|
await page.locator('button', { hasText: 'Destination Room' }).first().click();
|
||||||
|
await page.getByRole('button', { name: /^Send to 1 room/ }).click();
|
||||||
|
await expect(page.getByText(/Forwarded to/)).toBeVisible();
|
||||||
|
await openRoom(page, dst);
|
||||||
|
await expect(page.getByText(/Forwarded from .* in Source Room/)).toBeVisible();
|
||||||
|
await expect(page.getByText('the original message')).toBeVisible();
|
||||||
|
});
|
||||||
|
|
||||||
|
test('thread panel: opens from the chip and yields the member drawer at 1400px (#218) @webkit', async ({
|
||||||
|
browser,
|
||||||
|
}) => {
|
||||||
|
const ctx = await browser.newContext({ viewport: { width: 1400, height: 850 } });
|
||||||
|
const page = await ctx.newPage();
|
||||||
|
const room = await createRoom(alice, 'Thread Room');
|
||||||
|
const root = await sendText(alice, room, 'thread root');
|
||||||
|
await sendText(alice, room, 'a reply', {
|
||||||
|
'm.relates_to': {
|
||||||
|
rel_type: 'm.thread',
|
||||||
|
event_id: root,
|
||||||
|
is_falling_back: true,
|
||||||
|
'm.in_reply_to': { event_id: root },
|
||||||
|
},
|
||||||
|
});
|
||||||
|
await loginUI(page, alice);
|
||||||
|
await openRoom(page, room);
|
||||||
|
await page
|
||||||
|
.locator('[data-message-item]', { hasText: 'thread root' })
|
||||||
|
.getByText(/1 reply/)
|
||||||
|
.click();
|
||||||
|
await expect(page.locator('[data-slate-editor]')).toHaveCount(2);
|
||||||
|
const widths = await page
|
||||||
|
.locator('[data-slate-editor]')
|
||||||
|
.evaluateAll((els) => els.map((e) => e.getBoundingClientRect().width));
|
||||||
|
expect(Math.min(...widths)).toBeGreaterThan(120);
|
||||||
|
await ctx.close();
|
||||||
|
});
|
||||||
|
|
||||||
|
test('a thread I started keeps its unread replies while I view the room (#217)', async ({
|
||||||
|
page,
|
||||||
|
}) => {
|
||||||
|
const room = await createRoom(alice, 'Thread Unread Room', { invite: [bob.userId] });
|
||||||
|
await joinRoom(bob, room);
|
||||||
|
const inThread = (root: string) => ({
|
||||||
|
'm.relates_to': {
|
||||||
|
rel_type: 'm.thread',
|
||||||
|
event_id: root,
|
||||||
|
is_falling_back: true,
|
||||||
|
'm.in_reply_to': { event_id: root },
|
||||||
|
},
|
||||||
|
});
|
||||||
|
const root = await sendText(alice, room, 'my thread root');
|
||||||
|
await loginUI(page, alice);
|
||||||
|
await openRoom(page, room);
|
||||||
|
// While the room is open and at the bottom: a thread reply, then a newer
|
||||||
|
// main-timeline message. Neither may clear the thread without opening it.
|
||||||
|
await sendText(bob, room, 'reply in your thread', inThread(root));
|
||||||
|
await sendText(bob, room, 'newer main message');
|
||||||
|
await expect(page.getByText('newer main message')).toBeVisible();
|
||||||
|
const chip = page
|
||||||
|
.locator('[data-message-item]', { hasText: 'my thread root' })
|
||||||
|
.getByRole('button', { name: /1 reply/ });
|
||||||
|
const threadUnread = async () => {
|
||||||
|
// not_types varies so Synapse's sync response cache can't serve a stale answer.
|
||||||
|
const filter = {
|
||||||
|
room: {
|
||||||
|
rooms: [room],
|
||||||
|
timeline: { limit: 1, unread_thread_notifications: true, not_types: [uniq('x.')] },
|
||||||
|
},
|
||||||
|
};
|
||||||
|
const sync = await api<{
|
||||||
|
rooms: {
|
||||||
|
join: Record<string, { unread_thread_notifications?: Record<string, unknown> }>;
|
||||||
|
};
|
||||||
|
}>(
|
||||||
|
'GET',
|
||||||
|
`/_matrix/client/v3/sync?timeout=0&filter=${enc(JSON.stringify(filter))}`,
|
||||||
|
alice.token,
|
||||||
|
);
|
||||||
|
return root in (sync.rooms.join[room]?.unread_thread_notifications ?? {});
|
||||||
|
};
|
||||||
|
await page.waitForTimeout(2000); // let any receipt the room view would send go out
|
||||||
|
expect(await threadUnread()).toBe(true);
|
||||||
|
await expect(chip).toHaveAccessibleName(/unread replies/);
|
||||||
|
await chip.click();
|
||||||
|
await expect.poll(threadUnread).toBe(false);
|
||||||
|
});
|
||||||
|
|
||||||
|
test('timeline image opens the gallery lightbox (#219) @webkit', async ({ page }) => {
|
||||||
|
const room = await createRoom(alice, 'Lightbox Room');
|
||||||
|
const png = Buffer.from(
|
||||||
|
'iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAYAAAAfFcSJAAAADUlEQVR42mNkYPhfDwAChwGA60e6kgAAAABJRU5ErkJggg==',
|
||||||
|
'base64',
|
||||||
|
);
|
||||||
|
const up = await fetch(`${HS}/_matrix/media/v3/upload?filename=a.png`, {
|
||||||
|
method: 'POST',
|
||||||
|
headers: { Authorization: `Bearer ${alice.token}`, 'Content-Type': 'image/png' },
|
||||||
|
body: png,
|
||||||
|
}).then((r) => r.json() as Promise<{ content_uri: string }>);
|
||||||
|
await api(
|
||||||
|
'PUT',
|
||||||
|
`/_matrix/client/v3/rooms/${enc(room)}/send/m.room.message/img1`,
|
||||||
|
alice.token,
|
||||||
|
{
|
||||||
|
msgtype: 'm.image',
|
||||||
|
body: 'a.png',
|
||||||
|
url: up.content_uri,
|
||||||
|
info: { mimetype: 'image/png', size: png.length, w: 1, h: 1 },
|
||||||
|
},
|
||||||
|
);
|
||||||
|
await loginUI(page, alice);
|
||||||
|
await openRoom(page, room);
|
||||||
|
await page.locator('[data-message-item] img[alt="a.png"]').click();
|
||||||
|
const viewer = page.getByRole('dialog', { name: 'Media viewer' });
|
||||||
|
await expect(viewer).toBeVisible();
|
||||||
|
await expect(viewer.getByText('1 / 1')).toBeVisible();
|
||||||
|
await page.keyboard.press('Escape');
|
||||||
|
await expect(viewer).toHaveCount(0);
|
||||||
|
});
|
||||||
|
|
||||||
|
test('warns when the local clock is far off the server (#158)', async ({ page }) => {
|
||||||
|
const room = await createRoom(alice, 'Skew Room', { invite: [bob.userId] });
|
||||||
|
await joinRoom(bob, room);
|
||||||
|
await page.clock.install({ time: Date.now() + 14 * 60 * 1000 });
|
||||||
|
await loginUI(page, alice);
|
||||||
|
await openRoom(page, room);
|
||||||
|
for (let i = 0; i < 4; i += 1) {
|
||||||
|
// eslint-disable-next-line no-await-in-loop
|
||||||
|
await sendText(bob, room, `tick ${i}`);
|
||||||
|
// eslint-disable-next-line no-await-in-loop
|
||||||
|
await page.waitForTimeout(500);
|
||||||
|
}
|
||||||
|
await expect(page.getByText(/clock is .*14 minutes ahead of the server/)).toBeVisible();
|
||||||
|
await page.getByRole('button', { name: 'Dismiss for 24 h' }).click();
|
||||||
|
await expect(page.getByText(/clock is .*ahead of the server/)).toHaveCount(0);
|
||||||
|
});
|
||||||
|
|
||||||
|
test('status save survives the presence rate limit (#226)', async ({ page }) => {
|
||||||
|
let lastOk = 0;
|
||||||
|
await page.route(/\/presence\/[^/]+\/status/, (route) => {
|
||||||
|
const now = Date.now();
|
||||||
|
if (now - lastOk < 10_000) {
|
||||||
|
return route.fulfill({
|
||||||
|
status: 429,
|
||||||
|
contentType: 'application/json',
|
||||||
|
body: JSON.stringify({
|
||||||
|
errcode: 'M_LIMIT_EXCEEDED',
|
||||||
|
error: 'Too Many Requests',
|
||||||
|
retry_after_ms: 10_000 - (now - lastOk),
|
||||||
|
}),
|
||||||
|
});
|
||||||
|
}
|
||||||
|
lastOk = now;
|
||||||
|
return route.continue();
|
||||||
|
});
|
||||||
|
await loginUI(page, alice);
|
||||||
|
await page
|
||||||
|
.locator('button', { hasText: new RegExp(`^${alice.localpart[0]}$`) })
|
||||||
|
.first()
|
||||||
|
.click();
|
||||||
|
await page.getByText('Account', { exact: true }).first().click();
|
||||||
|
const input = page.getByLabel('Status message');
|
||||||
|
const status = uniq('status ');
|
||||||
|
await input.fill(status);
|
||||||
|
await input.locator('xpath=ancestor::form[1]').getByRole('button', { name: 'Save' }).click();
|
||||||
|
await expect(page.getByText(/Failed to save status/)).toHaveCount(0);
|
||||||
|
await expect
|
||||||
|
.poll(
|
||||||
|
async () =>
|
||||||
|
(
|
||||||
|
await api<{ status_msg?: string }>(
|
||||||
|
'GET',
|
||||||
|
`/_matrix/client/v3/presence/${enc(alice.userId)}/status`,
|
||||||
|
alice.token,
|
||||||
|
)
|
||||||
|
).status_msg,
|
||||||
|
{ timeout: 30_000 },
|
||||||
|
)
|
||||||
|
.toBe(status);
|
||||||
|
});
|
||||||
|
|
||||||
|
test('touch: long-press opens the message action sheet (#166)', async ({ browser }) => {
|
||||||
|
const ctx = await browser.newContext({ ...devices['Pixel 7'] });
|
||||||
|
const page = await ctx.newPage();
|
||||||
|
const room = await createRoom(alice, 'Touch Room');
|
||||||
|
await sendText(alice, room, 'press and hold me');
|
||||||
|
await loginUI(page, alice);
|
||||||
|
await openRoom(page, room);
|
||||||
|
const msg = page.locator('[data-message-item]', { hasText: 'press and hold me' });
|
||||||
|
const box = (await msg.boundingBox())!;
|
||||||
|
const cdp = await ctx.newCDPSession(page);
|
||||||
|
const x = box.x + 100;
|
||||||
|
const y = box.y + box.height / 2;
|
||||||
|
await cdp.send('Input.dispatchTouchEvent', { type: 'touchStart', touchPoints: [{ x, y }] });
|
||||||
|
await page.waitForTimeout(700);
|
||||||
|
await cdp.send('Input.dispatchTouchEvent', { type: 'touchEnd', touchPoints: [] });
|
||||||
|
const sheet = page.getByRole('dialog', { name: 'Message actions' });
|
||||||
|
await expect(sheet).toBeVisible();
|
||||||
|
await expect(sheet.getByText('Reply', { exact: true })).toBeVisible();
|
||||||
|
await ctx.close();
|
||||||
|
});
|
||||||
|
});
|
||||||
+114
@@ -0,0 +1,114 @@
|
|||||||
|
import { Page, expect } from '@playwright/test';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Tier 3 (Gitea #220): regression tests against a throwaway Synapse the job
|
||||||
|
* starts itself (`scripts/dev-homeserver.sh start`). No prod secrets. Set
|
||||||
|
* E2E_LOCAL_HS (default http://localhost:8008) — the spec skips when the
|
||||||
|
* server isn't reachable.
|
||||||
|
*/
|
||||||
|
export const HS = process.env.E2E_LOCAL_HS || 'http://localhost:8008';
|
||||||
|
export const PASSWORD = 'password123';
|
||||||
|
export const enc = encodeURIComponent;
|
||||||
|
|
||||||
|
export async function hsReachable(): Promise<boolean> {
|
||||||
|
try {
|
||||||
|
const res = await fetch(`${HS}/_matrix/client/versions`);
|
||||||
|
return res.ok;
|
||||||
|
} catch {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
export async function api<T = Record<string, unknown>>(
|
||||||
|
method: string,
|
||||||
|
path: string,
|
||||||
|
token?: string,
|
||||||
|
body?: unknown,
|
||||||
|
): Promise<T> {
|
||||||
|
const res = await fetch(`${HS}${path}`, {
|
||||||
|
method,
|
||||||
|
headers: {
|
||||||
|
'Content-Type': 'application/json',
|
||||||
|
...(token ? { Authorization: `Bearer ${token}` } : {}),
|
||||||
|
},
|
||||||
|
body: body === undefined ? undefined : JSON.stringify(body),
|
||||||
|
});
|
||||||
|
return (await res.json()) as T;
|
||||||
|
}
|
||||||
|
|
||||||
|
export type TestUser = { localpart: string; userId: string; token: string };
|
||||||
|
|
||||||
|
/** Registers (open registration) or logs in a test user. */
|
||||||
|
export async function ensureUser(localpart: string): Promise<TestUser> {
|
||||||
|
const reg = await api<{ user_id?: string; access_token?: string }>(
|
||||||
|
'POST',
|
||||||
|
'/_matrix/client/v3/register',
|
||||||
|
undefined,
|
||||||
|
{ username: localpart, password: PASSWORD, auth: { type: 'm.login.dummy' } },
|
||||||
|
);
|
||||||
|
if (reg.access_token && reg.user_id) {
|
||||||
|
return { localpart, userId: reg.user_id, token: reg.access_token };
|
||||||
|
}
|
||||||
|
const login = await api<{ user_id: string; access_token: string }>(
|
||||||
|
'POST',
|
||||||
|
'/_matrix/client/v3/login',
|
||||||
|
undefined,
|
||||||
|
{
|
||||||
|
type: 'm.login.password',
|
||||||
|
identifier: { type: 'm.id.user', user: localpart },
|
||||||
|
password: PASSWORD,
|
||||||
|
},
|
||||||
|
);
|
||||||
|
return { localpart, userId: login.user_id, token: login.access_token };
|
||||||
|
}
|
||||||
|
|
||||||
|
export async function createRoom(
|
||||||
|
owner: TestUser,
|
||||||
|
name: string,
|
||||||
|
opts: { invite?: string[]; preset?: string } = {},
|
||||||
|
): Promise<string> {
|
||||||
|
const res = await api<{ room_id: string }>('POST', '/_matrix/client/v3/createRoom', owner.token, {
|
||||||
|
name,
|
||||||
|
preset: opts.preset ?? 'public_chat',
|
||||||
|
invite: opts.invite,
|
||||||
|
});
|
||||||
|
return res.room_id;
|
||||||
|
}
|
||||||
|
|
||||||
|
export async function joinRoom(user: TestUser, roomId: string): Promise<void> {
|
||||||
|
await api('POST', `/_matrix/client/v3/rooms/${enc(roomId)}/join`, user.token, {});
|
||||||
|
}
|
||||||
|
|
||||||
|
let txn = 0;
|
||||||
|
export async function sendText(
|
||||||
|
user: TestUser,
|
||||||
|
roomId: string,
|
||||||
|
body: string,
|
||||||
|
extra: Record<string, unknown> = {},
|
||||||
|
): Promise<string> {
|
||||||
|
txn += 1;
|
||||||
|
const res = await api<{ event_id: string }>(
|
||||||
|
'PUT',
|
||||||
|
`/_matrix/client/v3/rooms/${enc(roomId)}/send/m.room.message/e2e${Date.now()}_${txn}`,
|
||||||
|
user.token,
|
||||||
|
{ msgtype: 'm.text', body, ...extra },
|
||||||
|
);
|
||||||
|
return res.event_id;
|
||||||
|
}
|
||||||
|
|
||||||
|
/** Password login through the UI against the local homeserver. */
|
||||||
|
export async function loginUI(page: Page, user: TestUser): Promise<void> {
|
||||||
|
await page.goto(`/login/${enc(HS)}/`);
|
||||||
|
await page.getByLabel('Username or email').fill(user.localpart);
|
||||||
|
await page.getByLabel('Password', { exact: true }).fill(PASSWORD);
|
||||||
|
await page.getByRole('button', { name: 'Login' }).click();
|
||||||
|
await page.waitForURL(/\/home/, { timeout: 60_000 });
|
||||||
|
}
|
||||||
|
|
||||||
|
export async function openRoom(page: Page, roomId: string): Promise<void> {
|
||||||
|
await page.goto(`/home/${enc(roomId)}`);
|
||||||
|
await expect(page.locator('[data-slate-editor]').first()).toBeVisible({ timeout: 30_000 });
|
||||||
|
}
|
||||||
|
|
||||||
|
export const uniq = (prefix: string): string =>
|
||||||
|
`${prefix}${Date.now().toString(36)}${Math.random().toString(36).slice(2, 6)}`;
|
||||||
@@ -27,9 +27,6 @@
|
|||||||
<meta name="theme-color" content="#000000" />
|
<meta name="theme-color" content="#000000" />
|
||||||
<meta name="color-scheme" content="dark light" />
|
<meta name="color-scheme" content="dark light" />
|
||||||
|
|
||||||
<link rel="preconnect" href="https://fonts.googleapis.com" crossorigin />
|
|
||||||
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin />
|
|
||||||
<link href="https://fonts.googleapis.com/css2?family=VT323&display=swap" rel="stylesheet" />
|
|
||||||
<link rel="stylesheet" href="/fonts/custom-fonts.css" />
|
<link rel="stylesheet" href="/fonts/custom-fonts.css" />
|
||||||
<link id="favicon" rel="shortcut icon" href="./public/favicon.ico" />
|
<link id="favicon" rel="shortcut icon" href="./public/favicon.ico" />
|
||||||
|
|
||||||
|
|||||||
Generated
+22
-7
@@ -80,7 +80,8 @@
|
|||||||
"workbox-precaching": "7.4.1"
|
"workbox-precaching": "7.4.1"
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@lotusguild/element-call-embedded": "0.25.0-lotus.3",
|
"@axe-core/playwright": "4.13.0",
|
||||||
|
"@lotusguild/element-call-embedded": "0.25.0-lotus.21",
|
||||||
"@playwright/test": "1.63.0",
|
"@playwright/test": "1.63.0",
|
||||||
"@rollup/plugin-inject": "5.0.5",
|
"@rollup/plugin-inject": "5.0.5",
|
||||||
"@rollup/plugin-wasm": "6.2.2",
|
"@rollup/plugin-wasm": "6.2.2",
|
||||||
@@ -172,6 +173,19 @@
|
|||||||
"@babel/runtime": "^7.0.0"
|
"@babel/runtime": "^7.0.0"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
"node_modules/@axe-core/playwright": {
|
||||||
|
"version": "4.13.0",
|
||||||
|
"resolved": "https://registry.npmjs.org/@axe-core/playwright/-/playwright-4.13.0.tgz",
|
||||||
|
"integrity": "sha512-6YLx+kxXu5GJceG4ozFg+33a2EMTdjYwWGloJ3sb9Kta5pp+ZNS53uxGVog5JetIY8s++P5UrtX+cri+u0VAVg==",
|
||||||
|
"dev": true,
|
||||||
|
"license": "MPL-2.0",
|
||||||
|
"dependencies": {
|
||||||
|
"axe-core": "~4.13.0"
|
||||||
|
},
|
||||||
|
"peerDependencies": {
|
||||||
|
"playwright-core": ">= 1.0.0"
|
||||||
|
}
|
||||||
|
},
|
||||||
"node_modules/@babel/code-frame": {
|
"node_modules/@babel/code-frame": {
|
||||||
"version": "7.29.0",
|
"version": "7.29.0",
|
||||||
"resolved": "https://registry.npmjs.org/@babel/code-frame/-/code-frame-7.29.0.tgz",
|
"resolved": "https://registry.npmjs.org/@babel/code-frame/-/code-frame-7.29.0.tgz",
|
||||||
@@ -2681,9 +2695,9 @@
|
|||||||
"integrity": "sha512-dfLbk+PwWvFzSxwk3n5ySL0hfBog779o8h68wK/7/APo/7cgyWp5jcXockbxdk5kFRkbeXWm4Fbi9FrdN381sA=="
|
"integrity": "sha512-dfLbk+PwWvFzSxwk3n5ySL0hfBog779o8h68wK/7/APo/7cgyWp5jcXockbxdk5kFRkbeXWm4Fbi9FrdN381sA=="
|
||||||
},
|
},
|
||||||
"node_modules/@lotusguild/element-call-embedded": {
|
"node_modules/@lotusguild/element-call-embedded": {
|
||||||
"version": "0.25.0-lotus.3",
|
"version": "0.25.0-lotus.21",
|
||||||
"resolved": "https://code.lotusguild.org/api/packages/LotusGuild/npm/%40lotusguild%2Felement-call-embedded/-/0.25.0-lotus.3/element-call-embedded-0.25.0-lotus.3.tgz",
|
"resolved": "https://code.lotusguild.org/api/packages/LotusGuild/npm/%40lotusguild%2Felement-call-embedded/-/0.25.0-lotus.21/element-call-embedded-0.25.0-lotus.21.tgz",
|
||||||
"integrity": "sha512-UjOi8DXosVjBeVb5SiPNFApJSI9gggpU67xAUn0EWevD3oj9wQFhtjdMkxGbhnQ7B9r6QEUivDGWsBpsfKe0/w==",
|
"integrity": "sha512-Phtjop2qdKRrCLqAhzipRaJaVnU3MjK9CV4QwHkwU/Xlj8oguZBfjOlV7zTqOTzAr57OteOfLcyxLsmv5+u9tg==",
|
||||||
"dev": true
|
"dev": true
|
||||||
},
|
},
|
||||||
"node_modules/@matrix-org/matrix-sdk-crypto-wasm": {
|
"node_modules/@matrix-org/matrix-sdk-crypto-wasm": {
|
||||||
@@ -4847,10 +4861,11 @@
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
"node_modules/axe-core": {
|
"node_modules/axe-core": {
|
||||||
"version": "4.10.2",
|
"version": "4.13.0",
|
||||||
"resolved": "https://registry.npmjs.org/axe-core/-/axe-core-4.10.2.tgz",
|
"resolved": "https://registry.npmjs.org/axe-core/-/axe-core-4.13.0.tgz",
|
||||||
"integrity": "sha512-RE3mdQ7P3FRSe7eqCWoeQ/Z9QXrtniSjp1wUjt5nRC3WIpz5rSCve6o3fsZ2aCpJtrZjSZgjwXAoTO5k4tEI0w==",
|
"integrity": "sha512-UzGt8zg7Ny8djbYMhxl2zuEevVa7r2gJjYY5Lwr1xM7+XU2nd6CkIWFTVcCIbAP63vSz71NaVyyuSk9lHKcy0A==",
|
||||||
"dev": true,
|
"dev": true,
|
||||||
|
"license": "MPL-2.0",
|
||||||
"engines": {
|
"engines": {
|
||||||
"node": ">=4"
|
"node": ">=4"
|
||||||
}
|
}
|
||||||
|
|||||||
+4
-3
@@ -12,13 +12,13 @@
|
|||||||
"build": "vite build",
|
"build": "vite build",
|
||||||
"preview": "vite preview",
|
"preview": "vite preview",
|
||||||
"lint": "npm run check:eslint && npm run check:prettier",
|
"lint": "npm run check:eslint && npm run check:prettier",
|
||||||
"check:eslint": "eslint src/* --max-warnings 68",
|
"check:eslint": "eslint src/* --max-warnings 36",
|
||||||
"check:prettier": "prettier --check .",
|
"check:prettier": "prettier --check .",
|
||||||
"fix:prettier": "prettier --write .",
|
"fix:prettier": "prettier --write .",
|
||||||
"typecheck": "tsc --noEmit",
|
"typecheck": "tsc --noEmit",
|
||||||
"test": "node --import tsx --test $(find src -name '*.test.ts')",
|
"test": "node --import tsx --test $(find src -name '*.test.ts')",
|
||||||
"test:e2e": "playwright test",
|
"test:e2e": "playwright test",
|
||||||
"test:e2e:install": "playwright install chromium",
|
"test:e2e:install": "playwright install chromium webkit",
|
||||||
"prepare": "husky",
|
"prepare": "husky",
|
||||||
"commit": "git-cz",
|
"commit": "git-cz",
|
||||||
"postinstall": "node scripts/patch-folds.mjs",
|
"postinstall": "node scripts/patch-folds.mjs",
|
||||||
@@ -107,7 +107,8 @@
|
|||||||
"workbox-precaching": "7.4.1"
|
"workbox-precaching": "7.4.1"
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@lotusguild/element-call-embedded": "0.25.0-lotus.3",
|
"@axe-core/playwright": "4.13.0",
|
||||||
|
"@lotusguild/element-call-embedded": "0.25.0-lotus.21",
|
||||||
"@playwright/test": "1.63.0",
|
"@playwright/test": "1.63.0",
|
||||||
"@rollup/plugin-inject": "5.0.5",
|
"@rollup/plugin-inject": "5.0.5",
|
||||||
"@rollup/plugin-wasm": "6.2.2",
|
"@rollup/plugin-wasm": "6.2.2",
|
||||||
|
|||||||
+10
-1
@@ -25,7 +25,16 @@ export default defineConfig({
|
|||||||
trace: 'retain-on-failure',
|
trace: 'retain-on-failure',
|
||||||
...devices['Desktop Chrome'],
|
...devices['Desktop Chrome'],
|
||||||
},
|
},
|
||||||
projects: [{ name: 'chromium', use: { ...devices['Desktop Chrome'] } }],
|
projects: [
|
||||||
|
{ name: 'chromium', use: { ...devices['Desktop Chrome'] } },
|
||||||
|
// [Gitea #221] WebKit as the Safari/iOS proxy. It runs the subset tagged
|
||||||
|
// @webkit / @ios (boot, composer round-trip, thread panel, lightbox): it
|
||||||
|
// catches WebKit-only breakage (CSS, dvh, IndexedDB, media decode) that
|
||||||
|
// Chromium emulation can't, but does not emulate the iOS keyboard or the
|
||||||
|
// Home-Screen install flow.
|
||||||
|
{ name: 'webkit', use: { ...devices['Desktop Safari'] }, grep: /@webkit/ },
|
||||||
|
{ name: 'iphone', use: { ...devices['iPhone 14'] }, grep: /@ios/ },
|
||||||
|
],
|
||||||
webServer: {
|
webServer: {
|
||||||
command: `npx vite preview --port ${PORT} --strictPort`,
|
command: `npx vite preview --port ${PORT} --strictPort`,
|
||||||
url: BASE_URL,
|
url: BASE_URL,
|
||||||
|
|||||||
@@ -1,11 +0,0 @@
|
|||||||
<!DOCTYPE html>
|
|
||||||
<html lang=en>
|
|
||||||
<meta charset=utf-8>
|
|
||||||
<meta name=viewport content="initial-scale=1, minimum-scale=1, width=device-width">
|
|
||||||
<title>Error 404 (Not Found)!!1</title>
|
|
||||||
<style>
|
|
||||||
*{margin:0;padding:0}html,code{font:15px/22px arial,sans-serif}html{background:#fff;color:#222;padding:15px}body{margin:7% auto 0;max-width:390px;min-height:180px;padding:30px 0 15px}* > body{background:url(//www.google.com/images/errors/robot.png) 100% 5px no-repeat;padding-right:205px}p{margin:11px 0 22px;overflow:hidden}ins{color:#777;text-decoration:none}a img{border:0}@media screen and (max-width:772px){body{background:none;margin-top:0;max-width:none;padding-right:0}}#logo{background:url(//www.google.com/images/branding/googlelogo/1x/googlelogo_color_150x54dp.png) no-repeat;margin-left:-5px}@media only screen and (min-resolution:192dpi){#logo{background:url(//www.google.com/images/branding/googlelogo/2x/googlelogo_color_150x54dp.png) no-repeat 0% 0%/100% 100%;-moz-border-image:url(//www.google.com/images/branding/googlelogo/2x/googlelogo_color_150x54dp.png) 0}}@media only screen and (-webkit-min-device-pixel-ratio:2){#logo{background:url(//www.google.com/images/branding/googlelogo/2x/googlelogo_color_150x54dp.png) no-repeat;-webkit-background-size:100% 100%}}#logo{display:inline-block;height:54px;width:150px}
|
|
||||||
</style>
|
|
||||||
<a href=//www.google.com/><span id=logo aria-label=Google></span></a>
|
|
||||||
<p><b>404.</b> <ins>That’s an error.</ins>
|
|
||||||
<p>The requested URL <code>/s/jetbrainsmono/v18/tDbY2o-flEEny0FZhsfKu5WU4xD-IQ.woff2</code> was not found on this server. <ins>That’s all we know.</ins>
|
|
||||||
@@ -1,11 +0,0 @@
|
|||||||
<!DOCTYPE html>
|
|
||||||
<html lang=en>
|
|
||||||
<meta charset=utf-8>
|
|
||||||
<meta name=viewport content="initial-scale=1, minimum-scale=1, width=device-width">
|
|
||||||
<title>Error 404 (Not Found)!!1</title>
|
|
||||||
<style>
|
|
||||||
*{margin:0;padding:0}html,code{font:15px/22px arial,sans-serif}html{background:#fff;color:#222;padding:15px}body{margin:7% auto 0;max-width:390px;min-height:180px;padding:30px 0 15px}* > body{background:url(//www.google.com/images/errors/robot.png) 100% 5px no-repeat;padding-right:205px}p{margin:11px 0 22px;overflow:hidden}ins{color:#777;text-decoration:none}a img{border:0}@media screen and (max-width:772px){body{background:none;margin-top:0;max-width:none;padding-right:0}}#logo{background:url(//www.google.com/images/branding/googlelogo/1x/googlelogo_color_150x54dp.png) no-repeat;margin-left:-5px}@media only screen and (min-resolution:192dpi){#logo{background:url(//www.google.com/images/branding/googlelogo/2x/googlelogo_color_150x54dp.png) no-repeat 0% 0%/100% 100%;-moz-border-image:url(//www.google.com/images/branding/googlelogo/2x/googlelogo_color_150x54dp.png) 0}}@media only screen and (-webkit-min-device-pixel-ratio:2){#logo{background:url(//www.google.com/images/branding/googlelogo/2x/googlelogo_color_150x54dp.png) no-repeat;-webkit-background-size:100% 100%}}#logo{display:inline-block;height:54px;width:150px}
|
|
||||||
</style>
|
|
||||||
<a href=//www.google.com/><span id=logo aria-label=Google></span></a>
|
|
||||||
<p><b>404.</b> <ins>That’s an error.</ins>
|
|
||||||
<p>The requested URL <code>/s/jetbrainsmono/v18/tDbY2o-flEEny0FZhsfKu5WU4xD-IQ.woff2</code> was not found on this server. <ins>That’s all we know.</ins>
|
|
||||||
@@ -1,11 +0,0 @@
|
|||||||
<!DOCTYPE html>
|
|
||||||
<html lang=en>
|
|
||||||
<meta charset=utf-8>
|
|
||||||
<meta name=viewport content="initial-scale=1, minimum-scale=1, width=device-width">
|
|
||||||
<title>Error 404 (Not Found)!!1</title>
|
|
||||||
<style>
|
|
||||||
*{margin:0;padding:0}html,code{font:15px/22px arial,sans-serif}html{background:#fff;color:#222;padding:15px}body{margin:7% auto 0;max-width:390px;min-height:180px;padding:30px 0 15px}* > body{background:url(//www.google.com/images/errors/robot.png) 100% 5px no-repeat;padding-right:205px}p{margin:11px 0 22px;overflow:hidden}ins{color:#777;text-decoration:none}a img{border:0}@media screen and (max-width:772px){body{background:none;margin-top:0;max-width:none;padding-right:0}}#logo{background:url(//www.google.com/images/branding/googlelogo/1x/googlelogo_color_150x54dp.png) no-repeat;margin-left:-5px}@media only screen and (min-resolution:192dpi){#logo{background:url(//www.google.com/images/branding/googlelogo/2x/googlelogo_color_150x54dp.png) no-repeat 0% 0%/100% 100%;-moz-border-image:url(//www.google.com/images/branding/googlelogo/2x/googlelogo_color_150x54dp.png) 0}}@media only screen and (-webkit-min-device-pixel-ratio:2){#logo{background:url(//www.google.com/images/branding/googlelogo/2x/googlelogo_color_150x54dp.png) no-repeat;-webkit-background-size:100% 100%}}#logo{display:inline-block;height:54px;width:150px}
|
|
||||||
</style>
|
|
||||||
<a href=//www.google.com/><span id=logo aria-label=Google></span></a>
|
|
||||||
<p><b>404.</b> <ins>That’s an error.</ins>
|
|
||||||
<p>The requested URL <code>/s/jetbrainsmono/v18/tDbY2o-flEEny0FZhsfKu5WU4xD-IQ.woff2</code> was not found on this server. <ins>That’s all we know.</ins>
|
|
||||||
Binary file not shown.
Binary file not shown.
@@ -49,3 +49,25 @@
|
|||||||
U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329,
|
U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329,
|
||||||
U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
|
U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
|
||||||
}
|
}
|
||||||
|
/* VT323 (OFL) for the Lotus Terminal theme — was Google Fonts (Gitea #214) */
|
||||||
|
@font-face {
|
||||||
|
font-family: 'VT323';
|
||||||
|
font-style: normal;
|
||||||
|
font-weight: 400;
|
||||||
|
font-display: swap;
|
||||||
|
src: url('/fonts/VT323-latin-ext.woff2') format('woff2');
|
||||||
|
unicode-range:
|
||||||
|
U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304, U+0308, U+0329,
|
||||||
|
U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C0, U+2113, U+2C60-2C7F,
|
||||||
|
U+A720-A7FF;
|
||||||
|
}
|
||||||
|
@font-face {
|
||||||
|
font-family: 'VT323';
|
||||||
|
font-style: normal;
|
||||||
|
font-weight: 400;
|
||||||
|
font-display: swap;
|
||||||
|
src: url('/fonts/VT323-latin.woff2') format('woff2');
|
||||||
|
unicode-range:
|
||||||
|
U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329,
|
||||||
|
U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
|
||||||
|
}
|
||||||
|
|||||||
@@ -69,6 +69,22 @@
|
|||||||
}
|
}
|
||||||
],
|
],
|
||||||
"categories": ["social", "communication", "productivity"],
|
"categories": ["social", "communication", "productivity"],
|
||||||
|
"share_target": {
|
||||||
|
"action": "./share-target",
|
||||||
|
"method": "POST",
|
||||||
|
"enctype": "multipart/form-data",
|
||||||
|
"params": {
|
||||||
|
"title": "title",
|
||||||
|
"text": "text",
|
||||||
|
"url": "url",
|
||||||
|
"files": [
|
||||||
|
{
|
||||||
|
"name": "files",
|
||||||
|
"accept": ["image/*", "video/*", "audio/*", "application/pdf", "text/plain"]
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
},
|
||||||
"shortcuts": [
|
"shortcuts": [
|
||||||
{
|
{
|
||||||
"name": "New Message",
|
"name": "New Message",
|
||||||
|
|||||||
Binary file not shown.
|
Before Width: | Height: | Size: 7.7 KiB After Width: | Height: | Size: 13 KiB |
Binary file not shown.
|
Before Width: | Height: | Size: 37 KiB After Width: | Height: | Size: 61 KiB |
|
Before Width: | Height: | Size: 19 KiB After Width: | Height: | Size: 19 KiB |
@@ -4,9 +4,19 @@
|
|||||||
# SQLite, media served. Everything lives in .dev-homeserver/ (gitignored).
|
# SQLite, media served. Everything lives in .dev-homeserver/ (gitignored).
|
||||||
#
|
#
|
||||||
# scripts/dev-homeserver.sh start # install (first run) + start on :8008
|
# scripts/dev-homeserver.sh start # install (first run) + start on :8008
|
||||||
|
# scripts/dev-homeserver.sh calls # + LiveKit SFU, JWT issuer, voice-limit guard, https well-known
|
||||||
# scripts/dev-homeserver.sh stop
|
# scripts/dev-homeserver.sh stop
|
||||||
# scripts/dev-homeserver.sh reset # wipe the database and media
|
# scripts/dev-homeserver.sh reset # wipe the database and media
|
||||||
# python3 scripts/dev-seed.py 400 # alice/bob + "Busy Room" with images
|
# python3 scripts/dev-seed.py 400 # alice/bob + "Busy Room" with images (+ "Voice Lounge" call room)
|
||||||
|
#
|
||||||
|
# Calls: `calls` downloads livekit-server (v1.13.7 release binary) into
|
||||||
|
# .dev-homeserver/, runs it on :7880 with key devkey, a minimal lk-jwt-service
|
||||||
|
# clone (scripts/dev-lk-jwt.py, :8071), the real voice-limit-guard from the
|
||||||
|
# sibling matrix repo in front of it (:8070, needs ../matrix checked out and an
|
||||||
|
# admin user — dev-seed makes alice one), and a self-signed https server on
|
||||||
|
# :443 serving /.well-known/matrix/client with the LiveKit focus (the client
|
||||||
|
# autodiscovers the server NAME, not :8008). Drive it with Playwright using
|
||||||
|
# --use-fake-device-for-media-stream and ignoreHTTPSErrors.
|
||||||
#
|
#
|
||||||
# Then `npm start` and log in at http://127.0.0.1:5173/login/http%3A%2F%2Flocalhost%3A8008/
|
# Then `npm start` and log in at http://127.0.0.1:5173/login/http%3A%2F%2Flocalhost%3A8008/
|
||||||
# as alice / password123.
|
# as alice / password123.
|
||||||
@@ -23,7 +33,7 @@ install() {
|
|||||||
python3 -m venv --without-pip "$VENV"
|
python3 -m venv --without-pip "$VENV"
|
||||||
curl -sS https://bootstrap.pypa.io/get-pip.py -o "$DIR/get-pip.py"
|
curl -sS https://bootstrap.pypa.io/get-pip.py -o "$DIR/get-pip.py"
|
||||||
"$VENV/bin/python" "$DIR/get-pip.py" -q
|
"$VENV/bin/python" "$DIR/get-pip.py" -q
|
||||||
"$VENV/bin/pip" install -q matrix-synapse
|
"$VENV/bin/pip" install -q "matrix-synapse[url-preview]"
|
||||||
fi
|
fi
|
||||||
if [ ! -f "$CFG" ]; then
|
if [ ! -f "$CFG" ]; then
|
||||||
(cd "$DIR" && "$VENV/bin/python" -m synapse.app.homeserver \
|
(cd "$DIR" && "$VENV/bin/python" -m synapse.app.homeserver \
|
||||||
@@ -32,7 +42,7 @@ install() {
|
|||||||
python3 - "$CFG" <<'PY'
|
python3 - "$CFG" <<'PY'
|
||||||
import sys, re
|
import sys, re
|
||||||
p = sys.argv[1]; s = open(p).read()
|
p = sys.argv[1]; s = open(p).read()
|
||||||
s = s.replace(" - client\n", " - client\n - media\n", 1)
|
s = s.replace(" - client\n", " - client\n - media\n - federation\n", 1)
|
||||||
s += """
|
s += """
|
||||||
enable_registration: true
|
enable_registration: true
|
||||||
enable_registration_without_verification: true
|
enable_registration_without_verification: true
|
||||||
@@ -43,6 +53,20 @@ rc_joins: { local: { per_second: 1000, burst_count: 10000 }, remote: { per_secon
|
|||||||
rc_presence: { per_user: { per_second: 1000, burst_count: 10000 } }
|
rc_presence: { per_user: { per_second: 1000, burst_count: 10000 } }
|
||||||
max_upload_size: 50M
|
max_upload_size: 50M
|
||||||
suppress_key_server_warning: true
|
suppress_key_server_warning: true
|
||||||
|
# URL previews (embed facades use the homeserver's cached thumbnail)
|
||||||
|
url_preview_enabled: true
|
||||||
|
url_preview_ip_range_blacklist: ['127.0.0.0/8', '10.0.0.0/8', '172.16.0.0/12', '192.168.0.0/16', '100.64.0.0/10', '169.254.0.0/16', '::1/128', 'fe80::/10', 'fc00::/7']
|
||||||
|
# scheduled messages (MSC4140 delayed events) + MatrixRTC transports (MSC4143) + room summaries (MSC3266)
|
||||||
|
max_event_delay_duration: 24h
|
||||||
|
experimental_features:
|
||||||
|
msc4140_enabled: true
|
||||||
|
msc4143_enabled: true
|
||||||
|
msc3266_enabled: true
|
||||||
|
msc4133_enabled: true
|
||||||
|
matrix_rtc:
|
||||||
|
transports:
|
||||||
|
- type: livekit
|
||||||
|
livekit_service_url: http://127.0.0.1:8070
|
||||||
"""
|
"""
|
||||||
open(p, "w").write(s)
|
open(p, "w").write(s)
|
||||||
PY
|
PY
|
||||||
@@ -65,10 +89,50 @@ start() {
|
|||||||
|
|
||||||
stop() {
|
stop() {
|
||||||
if [ -f "$PIDFILE" ]; then kill "$(cat "$PIDFILE")" 2>/dev/null || true; rm -f "$PIDFILE"; echo stopped; fi
|
if [ -f "$PIDFILE" ]; then kill "$(cat "$PIDFILE")" 2>/dev/null || true; rm -f "$PIDFILE"; echo stopped; fi
|
||||||
|
for f in "$DIR"/calls-*.pid; do [ -f "$f" ] && { kill "$(cat "$f")" 2>/dev/null || true; rm -f "$f"; }; done
|
||||||
|
}
|
||||||
|
|
||||||
|
calls() {
|
||||||
|
start
|
||||||
|
local LK="$DIR/livekit-server"
|
||||||
|
if [ ! -x "$LK" ]; then
|
||||||
|
curl -sL "https://github.com/livekit/livekit/releases/download/v1.13.7/livekit_1.13.7_linux_amd64.tar.gz" | tar xz -C "$DIR" livekit-server
|
||||||
|
fi
|
||||||
|
cat > "$DIR/livekit.yaml" <<'YAML'
|
||||||
|
port: 7880
|
||||||
|
bind_addresses: ["127.0.0.1"]
|
||||||
|
rtc:
|
||||||
|
tcp_port: 7881
|
||||||
|
port_range_start: 50000
|
||||||
|
port_range_end: 50100
|
||||||
|
use_external_ip: false
|
||||||
|
node_ip: 127.0.0.1
|
||||||
|
keys:
|
||||||
|
devkey: devsecretdevsecretdevsecretdevsecret
|
||||||
|
room:
|
||||||
|
auto_create: true
|
||||||
|
YAML
|
||||||
|
local bg
|
||||||
|
bg() { local name="$1"; shift; ( setsid nohup "$@" > "$DIR/calls-$name.log" 2>&1 < /dev/null & echo $! > "$DIR/calls-$name.pid" ); }
|
||||||
|
bg livekit "$LK" --config "$DIR/livekit.yaml"
|
||||||
|
bg jwt env PORT=8071 LIVEKIT_KEY=devkey LIVEKIT_SECRET=devsecretdevsecretdevsecretdevsecret LIVEKIT_URL=ws://127.0.0.1:7880 SYNAPSE_API=http://127.0.0.1:8008 python3 "$ROOT/scripts/dev-lk-jwt.py"
|
||||||
|
if [ ! -f "$DIR/wk.crt" ]; then openssl req -x509 -newkey rsa:2048 -nodes -keyout "$DIR/wk.key" -out "$DIR/wk.crt" -days 365 -subj "/CN=localhost" 2>/dev/null; fi
|
||||||
|
bg wellknown env CERT="$DIR/wk.crt" KEY="$DIR/wk.key" python3 "$ROOT/scripts/dev-wellknown.py"
|
||||||
|
local GUARD="$ROOT/../matrix/livekit/voice-limit-guard.py"
|
||||||
|
local TOKEN_FILE="$DIR/admin.token"
|
||||||
|
if [ -f "$GUARD" ] && [ -f "$TOKEN_FILE" ]; then
|
||||||
|
bg guard env GUARD_BIND_HOST=127.0.0.1 GUARD_BIND_PORT=8070 GUARD_UPSTREAM=http://127.0.0.1:8071 LIVEKIT_API=http://127.0.0.1:7880 LIVEKIT_KEY=devkey LIVEKIT_SECRET=devsecretdevsecretdevsecretdevsecret SYNAPSE_API=http://127.0.0.1:8008 MATRIX_TOKEN="$(cat "$TOKEN_FILE")" python3 "$GUARD"
|
||||||
|
else
|
||||||
|
echo "voice-limit-guard not started (need ../matrix checkout and $TOKEN_FILE from dev-seed.py); pointing the focus straight at the issuer"
|
||||||
|
bg guard env PORT=8070 LIVEKIT_KEY=devkey LIVEKIT_SECRET=devsecretdevsecretdevsecretdevsecret LIVEKIT_URL=ws://127.0.0.1:7880 SYNAPSE_API=http://127.0.0.1:8008 python3 "$ROOT/scripts/dev-lk-jwt.py"
|
||||||
|
fi
|
||||||
|
sleep 2
|
||||||
|
echo "calls stack up: livekit :7880, jwt :8071, guard :8070, well-known https://localhost/.well-known/matrix/client"
|
||||||
}
|
}
|
||||||
|
|
||||||
case "${1:-}" in
|
case "${1:-}" in
|
||||||
start) start ;;
|
start) start ;;
|
||||||
|
calls) calls ;;
|
||||||
stop) stop ;;
|
stop) stop ;;
|
||||||
reset) stop; rm -f "$DIR"/homeserver.db* ; rm -rf "$DIR/media_store"; echo "database wiped"; ;;
|
reset) stop; rm -f "$DIR"/homeserver.db* ; rm -rf "$DIR/media_store"; echo "database wiped"; ;;
|
||||||
*) echo "usage: $0 start|stop|reset" >&2; exit 2 ;;
|
*) echo "usage: $0 start|stop|reset" >&2; exit 2 ;;
|
||||||
|
|||||||
@@ -0,0 +1,52 @@
|
|||||||
|
#!/usr/bin/env python3
|
||||||
|
"""Minimal lk-jwt-service clone for local testing.
|
||||||
|
POST /sfu/get {room, openid_token{access_token, matrix_server_name}, device_id}
|
||||||
|
-> validates the OpenID token against Synapse (federation openid/userinfo),
|
||||||
|
mints a LiveKit JWT for identity "<user_id>:<device_id>" and returns {url, jwt}.
|
||||||
|
"""
|
||||||
|
import base64, hashlib, hmac, json, os, time, urllib.parse, urllib.request
|
||||||
|
from http.server import BaseHTTPRequestHandler, ThreadingHTTPServer
|
||||||
|
|
||||||
|
PORT = int(os.environ.get("PORT", "8071"))
|
||||||
|
LK_KEY = os.environ.get("LIVEKIT_KEY", "devkey")
|
||||||
|
LK_SECRET = os.environ.get("LIVEKIT_SECRET", "devsecretdevsecretdevsecretdevsecret")
|
||||||
|
LK_URL = os.environ.get("LIVEKIT_URL", "ws://127.0.0.1:7880")
|
||||||
|
SYNAPSE = os.environ.get("SYNAPSE_API", "http://127.0.0.1:8008")
|
||||||
|
|
||||||
|
def b64(b): return base64.urlsafe_b64encode(b).rstrip(b"=").decode()
|
||||||
|
def jwt(payload):
|
||||||
|
h = b64(json.dumps({"alg": "HS256", "typ": "JWT"}).encode()); p = b64(json.dumps(payload).encode())
|
||||||
|
sig = b64(hmac.new(LK_SECRET.encode(), f"{h}.{p}".encode(), hashlib.sha256).digest())
|
||||||
|
return f"{h}.{p}.{sig}"
|
||||||
|
|
||||||
|
def userinfo(access_token):
|
||||||
|
q = urllib.parse.urlencode({"access_token": access_token})
|
||||||
|
with urllib.request.urlopen(f"{SYNAPSE}/_matrix/federation/v1/openid/userinfo?{q}", timeout=5) as r:
|
||||||
|
return json.load(r)["sub"]
|
||||||
|
|
||||||
|
class H(BaseHTTPRequestHandler):
|
||||||
|
def _cors(self):
|
||||||
|
self.send_header("Access-Control-Allow-Origin", "*")
|
||||||
|
self.send_header("Access-Control-Allow-Headers", "*")
|
||||||
|
self.send_header("Access-Control-Allow-Methods", "POST, OPTIONS")
|
||||||
|
def do_OPTIONS(self):
|
||||||
|
self.send_response(204); self._cors(); self.end_headers()
|
||||||
|
def do_POST(self):
|
||||||
|
n = int(self.headers.get("Content-Length") or 0)
|
||||||
|
data = json.loads(self.rfile.read(n) or b"{}")
|
||||||
|
room = data.get("room") or data.get("room_id") or ""
|
||||||
|
oid = data.get("openid_token") or {}
|
||||||
|
try:
|
||||||
|
user = userinfo(oid.get("access_token", ""))
|
||||||
|
except Exception as e: # noqa
|
||||||
|
self.send_response(401); self._cors(); self.end_headers(); self.wfile.write(json.dumps({"errcode": "M_LOOKUP_FAILED", "error": str(e)}).encode()); return
|
||||||
|
identity = f"{user}:{data.get('device_id', '')}"
|
||||||
|
now = int(time.time())
|
||||||
|
token = jwt({"iss": LK_KEY, "sub": identity, "name": user, "nbf": now - 10, "exp": now + 3600,
|
||||||
|
"video": {"room": room, "roomJoin": True, "roomCreate": True, "canPublish": True, "canSubscribe": True, "canPublishData": True}})
|
||||||
|
body = json.dumps({"url": LK_URL, "jwt": token}).encode()
|
||||||
|
self.send_response(200); self._cors(); self.send_header("Content-Type", "application/json"); self.send_header("Content-Length", str(len(body))); self.end_headers(); self.wfile.write(body)
|
||||||
|
print(f"issued {identity} room={room}", flush=True)
|
||||||
|
def log_message(self, *a): pass
|
||||||
|
|
||||||
|
ThreadingHTTPServer(("127.0.0.1", PORT), H).serve_forever()
|
||||||
+24
-5
@@ -1,11 +1,15 @@
|
|||||||
#!/usr/bin/env python3
|
#!/usr/bin/env python3
|
||||||
"""Seed the local dev homeserver (scripts/dev-homeserver.sh) with two users
|
"""Seed the local dev homeserver (scripts/dev-homeserver.sh) with two users,
|
||||||
and a busy unencrypted room: alice + bob, "Busy Room", N messages, one image
|
a busy unencrypted room and a voice room: alice + bob, "Busy Room" (N
|
||||||
every 10th message. Idempotent for the users; every run creates a new room.
|
messages, one image every 10th), "Voice Lounge" (org.matrix.msc3417.call with
|
||||||
|
the call-member power level Lotus applies). Makes alice a server admin (the
|
||||||
|
voice-limit guard reads room state through the admin API) and writes her
|
||||||
|
token to .dev-homeserver/admin.token for `dev-homeserver.sh calls`.
|
||||||
|
Idempotent for the users; every run creates new rooms.
|
||||||
|
|
||||||
python3 scripts/dev-seed.py [N=400]
|
python3 scripts/dev-seed.py [N=400]
|
||||||
"""
|
"""
|
||||||
import json, struct, sys, time, urllib.error, urllib.parse, urllib.request, zlib
|
import json, os, sqlite3, struct, sys, time, urllib.error, urllib.parse, urllib.request, zlib
|
||||||
|
|
||||||
HS = "http://127.0.0.1:8008"
|
HS = "http://127.0.0.1:8008"
|
||||||
PASSWORD = "password123"
|
PASSWORD = "password123"
|
||||||
@@ -56,7 +60,22 @@ def main():
|
|||||||
content = {"msgtype": "m.text", "body": f"message #{i}"}
|
content = {"msgtype": "m.text", "body": f"message #{i}"}
|
||||||
txn += 1
|
txn += 1
|
||||||
req("PUT", f"/_matrix/client/v3/rooms/{urllib.parse.quote(room)}/send/m.room.message/{txn}", content, tok)
|
req("PUT", f"/_matrix/client/v3/rooms/{urllib.parse.quote(room)}/send/m.room.message/{txn}", content, tok)
|
||||||
print(json.dumps({"room": room, "alice": alice["user_id"], "bob": bob["user_id"], "count": n}))
|
voice = req("POST", "/_matrix/client/v3/createRoom", {
|
||||||
|
"name": "Voice Lounge", "preset": "public_chat",
|
||||||
|
"creation_content": {"type": "org.matrix.msc3417.call"},
|
||||||
|
"initial_state": [{"type": "org.matrix.msc3401.call", "state_key": "", "content": {}}],
|
||||||
|
"power_level_content_override": {"events": {"org.matrix.msc3401.call.member": 0}},
|
||||||
|
}, ta)["room_id"]
|
||||||
|
req("POST", f"/_matrix/client/v3/join/{urllib.parse.quote(voice)}", {}, tb)
|
||||||
|
# admin flag for the guard (takes effect for tokens issued after a Synapse restart-free
|
||||||
|
# cache miss; the guard only needs it for the admin state API)
|
||||||
|
here = os.path.dirname(os.path.abspath(__file__))
|
||||||
|
db = os.path.join(here, "..", ".dev-homeserver", "homeserver.db")
|
||||||
|
if os.path.exists(db):
|
||||||
|
c = sqlite3.connect(db); c.execute("UPDATE users SET admin=1 WHERE name=?", (alice["user_id"],)); c.commit(); c.close()
|
||||||
|
with open(os.path.join(here, "..", ".dev-homeserver", "admin.token"), "w") as f:
|
||||||
|
f.write(ta)
|
||||||
|
print(json.dumps({"room": room, "voice_room": voice, "alice": alice["user_id"], "bob": bob["user_id"], "count": n}))
|
||||||
|
|
||||||
|
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
|
|||||||
@@ -0,0 +1,15 @@
|
|||||||
|
#!/usr/bin/env python3
|
||||||
|
"""Self-signed https server on :443 serving the client well-known with the
|
||||||
|
LiveKit focus for the local calls stack (see scripts/dev-homeserver.sh calls)."""
|
||||||
|
import http.server, os, ssl, json
|
||||||
|
BODY = json.dumps({"m.homeserver": {"base_url": "http://localhost:8008"}, "org.matrix.msc4143.rtc_foci": [{"type": "livekit", "livekit_service_url": "http://127.0.0.1:8070"}]}).encode()
|
||||||
|
class H(http.server.BaseHTTPRequestHandler):
|
||||||
|
def do_GET(self):
|
||||||
|
if self.path.startswith('/.well-known/matrix/client'):
|
||||||
|
self.send_response(200); self.send_header('Content-Type','application/json'); self.send_header('Access-Control-Allow-Origin','*'); self.send_header('Content-Length',str(len(BODY))); self.end_headers(); self.wfile.write(BODY)
|
||||||
|
else:
|
||||||
|
self.send_response(404); self.end_headers()
|
||||||
|
def log_message(self,*a): pass
|
||||||
|
srv = http.server.ThreadingHTTPServer(('127.0.0.1', 443), H)
|
||||||
|
ctx = ssl.SSLContext(ssl.PROTOCOL_TLS_SERVER); ctx.load_cert_chain(os.environ.get('CERT', 'wk.crt'), os.environ.get('KEY', 'wk.key')); srv.socket = ctx.wrap_socket(srv.socket, server_side=True)
|
||||||
|
srv.serve_forever()
|
||||||
@@ -0,0 +1,48 @@
|
|||||||
|
#!/usr/bin/env python3
|
||||||
|
"""Build static picker thumbnails for avatar decorations.
|
||||||
|
|
||||||
|
The decorations are animated APNGs (~1 MB each). The settings picker shows
|
||||||
|
static WebP thumbnails instead and only loads the animated file on hover,
|
||||||
|
focus or selection, so browsing the catalog costs a few MB, not hundreds.
|
||||||
|
|
||||||
|
Usage: python3 scripts/makeDecorationThumbs.py <dir-of-slug.png> <out-dir>
|
||||||
|
Then upload <out-dir>/*.webp to `${DECORATION_CDN}/thumbs/`.
|
||||||
|
A missing thumbnail is harmless: the picker falls back to the full PNG.
|
||||||
|
|
||||||
|
Requires Pillow (pip install pillow).
|
||||||
|
"""
|
||||||
|
import sys
|
||||||
|
from pathlib import Path
|
||||||
|
|
||||||
|
from PIL import Image, ImageSequence
|
||||||
|
|
||||||
|
SIZE = 144 # 2x the 72px picker cell
|
||||||
|
|
||||||
|
|
||||||
|
def best_frame(im: Image.Image) -> Image.Image:
|
||||||
|
# Many animations start (or loop through) an empty frame, so pick the frame
|
||||||
|
# with the most visible pixels rather than frame 0.
|
||||||
|
best, best_score = None, -1
|
||||||
|
frames = list(ImageSequence.Iterator(im))
|
||||||
|
step = max(1, len(frames) // 24)
|
||||||
|
for frame in frames[::step]:
|
||||||
|
rgba = frame.convert('RGBA')
|
||||||
|
score = sum(rgba.getchannel('A').histogram()[33:])
|
||||||
|
if score > best_score:
|
||||||
|
best, best_score = rgba, score
|
||||||
|
return best
|
||||||
|
|
||||||
|
|
||||||
|
def main(src: str, out: str) -> None:
|
||||||
|
out_dir = Path(out)
|
||||||
|
out_dir.mkdir(parents=True, exist_ok=True)
|
||||||
|
for png in sorted(Path(src).glob('*.png')):
|
||||||
|
with Image.open(png) as im:
|
||||||
|
thumb = best_frame(im).resize((SIZE, SIZE), Image.LANCZOS)
|
||||||
|
thumb.save(out_dir / f'{png.stem}.webp', 'WEBP', quality=82, method=6)
|
||||||
|
|
||||||
|
|
||||||
|
if __name__ == '__main__':
|
||||||
|
if len(sys.argv) != 3:
|
||||||
|
sys.exit(__doc__)
|
||||||
|
main(sys.argv[1], sys.argv[2])
|
||||||
@@ -26,6 +26,7 @@ import {
|
|||||||
RoomEvent,
|
RoomEvent,
|
||||||
} from 'matrix-js-sdk';
|
} from 'matrix-js-sdk';
|
||||||
import { IRTCNotificationContent, RTCNotificationType } from 'matrix-js-sdk/lib/matrixrtc/types';
|
import { IRTCNotificationContent, RTCNotificationType } from 'matrix-js-sdk/lib/matrixrtc/types';
|
||||||
|
import { MatrixRTCSessionEvent } from 'matrix-js-sdk/lib/matrixrtc/MatrixRTCSession';
|
||||||
import { CryptoBackend } from 'matrix-js-sdk/lib/common-crypto/CryptoBackend';
|
import { CryptoBackend } from 'matrix-js-sdk/lib/common-crypto/CryptoBackend';
|
||||||
import {
|
import {
|
||||||
CallEmbedContextProvider,
|
CallEmbedContextProvider,
|
||||||
@@ -33,18 +34,27 @@ import {
|
|||||||
useCallHangupEvent,
|
useCallHangupEvent,
|
||||||
useCallJoined,
|
useCallJoined,
|
||||||
useCallThemeSync,
|
useCallThemeSync,
|
||||||
useCallMemberSoundSync,
|
|
||||||
useCallStart,
|
useCallStart,
|
||||||
} from '../hooks/useCallEmbed';
|
} from '../hooks/useCallEmbed';
|
||||||
import { callChatAtom, callEmbedAtom } from '../state/callEmbed';
|
import { callChatAtom, callEmbedAtom } from '../state/callEmbed';
|
||||||
import { toastQueueAtom } from '../state/toast';
|
import { toastQueueAtom } from '../state/toast';
|
||||||
import { CallEmbed, useCallControlState } from '../plugins/call';
|
import { CallEmbed, useCallControlState } from '../plugins/call';
|
||||||
|
import { hangupCallAndWait } from '../plugins/call/hangup';
|
||||||
import { useSelectedRoom } from '../hooks/router/useSelectedRoom';
|
import { useSelectedRoom } from '../hooks/router/useSelectedRoom';
|
||||||
import { ScreenSize, useScreenSizeContext } from '../hooks/useScreenSize';
|
import { ScreenSize, useScreenSizeContext } from '../hooks/useScreenSize';
|
||||||
import { useMatrixClient } from '../hooks/useMatrixClient';
|
import { useMatrixClient } from '../hooks/useMatrixClient';
|
||||||
import { previewRingtone, startRingtone, unlockRingtoneAudio } from '../utils/ringtones';
|
import { previewRingtone, startRingtone, unlockRingtoneAudio } from '../utils/ringtones';
|
||||||
import { useCallMembersChange, useCallSession } from '../hooks/useCall';
|
import { useCallMembersChange, useCallSession } from '../hooks/useCall';
|
||||||
import { useCallJoinLeaveSounds } from '../hooks/useCallJoinLeaveSounds';
|
import { useCallJoinLeaveSounds } from '../hooks/useCallJoinLeaveSounds';
|
||||||
|
import { useCallPolicyRevokedToast } from '../hooks/useCallPolicyRevokedToast';
|
||||||
|
import { useCallEndedToast } from '../hooks/useCallEndedToast';
|
||||||
|
import { useCallRejoin } from '../hooks/useCallRejoin';
|
||||||
|
import { usePttHaptics } from '../hooks/usePttHaptics';
|
||||||
|
import { useScreenshareNotices } from '../hooks/useScreenshareNotices';
|
||||||
|
import { useCallAnnouncements } from '../hooks/useCallAnnouncements';
|
||||||
|
import { useMutedTalkWarning } from '../hooks/useMutedTalkWarning';
|
||||||
|
import { callAnnouncementAtom } from '../state/callAnnouncement';
|
||||||
|
import { SrOnly } from '../features/call-status/styles.css';
|
||||||
import { useCallHotkeys } from '../hooks/useCallHotkeys';
|
import { useCallHotkeys } from '../hooks/useCallHotkeys';
|
||||||
import { useAfkAutoMute } from '../hooks/useAfkAutoMute';
|
import { useAfkAutoMute } from '../hooks/useAfkAutoMute';
|
||||||
import { useCallQuality } from '../hooks/useCallQuality';
|
import { useCallQuality } from '../hooks/useCallQuality';
|
||||||
@@ -68,6 +78,7 @@ import { getPowersLevelFromMatrixEvent } from '../hooks/usePowerLevels';
|
|||||||
import { getRoomCreatorsForRoomId } from '../hooks/useRoomCreators';
|
import { getRoomCreatorsForRoomId } from '../hooks/useRoomCreators';
|
||||||
import { getRoomPermissionsAPI } from '../hooks/useRoomPermissions';
|
import { getRoomPermissionsAPI } from '../hooks/useRoomPermissions';
|
||||||
import { useLivekitSupport } from '../hooks/useLivekitSupport';
|
import { useLivekitSupport } from '../hooks/useLivekitSupport';
|
||||||
|
import { useRoomCallPolicy } from '../hooks/useRoomCallPolicy';
|
||||||
import { useNotificationsQuiet } from '../hooks/useNotificationsQuiet';
|
import { useNotificationsQuiet } from '../hooks/useNotificationsQuiet';
|
||||||
import { CallAvatarAnimation } from '../styles/Animations.css';
|
import { CallAvatarAnimation } from '../styles/Animations.css';
|
||||||
import { webRTCSupported } from '../utils/rtc';
|
import { webRTCSupported } from '../utils/rtc';
|
||||||
@@ -112,6 +123,10 @@ function IncomingCall({ dm, info, onIgnore, onAnswer, onReject }: IncomingCallPr
|
|||||||
const rtcSupported = webRTCSupported();
|
const rtcSupported = webRTCSupported();
|
||||||
const canAnswer = livekitSupported && rtcSupported;
|
const canAnswer = livekitSupported && rtcSupported;
|
||||||
const { room } = info;
|
const { room } = info;
|
||||||
|
// [Gitea #135] Answer follows cameraOnJoin: say so, and offer the audio-only
|
||||||
|
// alternative, rather than putting the user on video without warning.
|
||||||
|
const [cameraOnJoinPref] = useSetting(settingsAtom, 'cameraOnJoin');
|
||||||
|
const willAnswerWithCamera = info.intent === 'video' && !!cameraOnJoinPref;
|
||||||
|
|
||||||
const [ringtoneVolume] = useSetting(settingsAtom, 'ringtoneVolume');
|
const [ringtoneVolume] = useSetting(settingsAtom, 'ringtoneVolume');
|
||||||
const [ringtoneId] = useSetting(settingsAtom, 'ringtoneId');
|
const [ringtoneId] = useSetting(settingsAtom, 'ringtoneId');
|
||||||
@@ -166,7 +181,15 @@ function IncomingCall({ dm, info, onIgnore, onAnswer, onReject }: IncomingCallPr
|
|||||||
escapeDeactivates: false,
|
escapeDeactivates: false,
|
||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
<Dialog style={{ maxWidth: toRem(324) }}>
|
<Dialog
|
||||||
|
style={{ maxWidth: toRem(324) }}
|
||||||
|
// #187: the overlay had no role or name, so a screen reader landed
|
||||||
|
// on an unlabelled button with no hint that a call was ringing.
|
||||||
|
// Match the in-call banner (role="alert" + label).
|
||||||
|
role="alertdialog"
|
||||||
|
aria-modal="true"
|
||||||
|
aria-label={`Incoming ${info.intent === 'video' ? 'video' : 'voice'} call from ${getMemberName(info.room, info.sender) ?? info.sender}`}
|
||||||
|
>
|
||||||
<Box style={{ padding: config.space.S400 }} direction="Column" gap="700">
|
<Box style={{ padding: config.space.S400 }} direction="Column" gap="700">
|
||||||
<Text size="T200" align="Center">
|
<Text size="T200" align="Center">
|
||||||
{getMemberName(info.room, info.sender)}
|
{getMemberName(info.room, info.sender)}
|
||||||
@@ -217,6 +240,11 @@ function IncomingCall({ dm, info, onIgnore, onAnswer, onReject }: IncomingCallPr
|
|||||||
</Text>
|
</Text>
|
||||||
)}
|
)}
|
||||||
<Box direction="Column" gap="300">
|
<Box direction="Column" gap="300">
|
||||||
|
{willAnswerWithCamera && (
|
||||||
|
<Text size="T200" align="Center" priority="300">
|
||||||
|
Answering turns your camera on.
|
||||||
|
</Text>
|
||||||
|
)}
|
||||||
<Button
|
<Button
|
||||||
style={{ flexGrow: 1 }}
|
style={{ flexGrow: 1 }}
|
||||||
variant="Success"
|
variant="Success"
|
||||||
@@ -233,9 +261,25 @@ function IncomingCall({ dm, info, onIgnore, onAnswer, onReject }: IncomingCallPr
|
|||||||
disabled={!canAnswer}
|
disabled={!canAnswer}
|
||||||
>
|
>
|
||||||
<Text as="span" size="B400">
|
<Text as="span" size="B400">
|
||||||
Answer
|
{willAnswerWithCamera ? 'Answer with camera' : 'Answer'}
|
||||||
</Text>
|
</Text>
|
||||||
</Button>
|
</Button>
|
||||||
|
{willAnswerWithCamera && (
|
||||||
|
<Button
|
||||||
|
style={{ flexGrow: 1 }}
|
||||||
|
variant="Success"
|
||||||
|
fill="Soft"
|
||||||
|
size="400"
|
||||||
|
radii="400"
|
||||||
|
onClick={() => onAnswer(room, false)}
|
||||||
|
before={<Icon size="200" src={Icons.Phone} filled />}
|
||||||
|
disabled={!canAnswer}
|
||||||
|
>
|
||||||
|
<Text as="span" size="B400">
|
||||||
|
Answer without camera
|
||||||
|
</Text>
|
||||||
|
</Button>
|
||||||
|
)}
|
||||||
<Button
|
<Button
|
||||||
style={{ flexGrow: 1 }}
|
style={{ flexGrow: 1 }}
|
||||||
variant={dm ? 'Critical' : 'Secondary'}
|
variant={dm ? 'Critical' : 'Secondary'}
|
||||||
@@ -277,6 +321,8 @@ function IncomingCallBanner({ dm, info, onIgnore, onAnswer, onReject }: Incoming
|
|||||||
const useAuthentication = useMediaAuthentication();
|
const useAuthentication = useMediaAuthentication();
|
||||||
const { room } = info;
|
const { room } = info;
|
||||||
const isVideo = info.intent === 'video';
|
const isVideo = info.intent === 'video';
|
||||||
|
const [cameraOnJoinPref] = useSetting(settingsAtom, 'cameraOnJoin');
|
||||||
|
const bannerCameraOn = isVideo && !!cameraOnJoinPref;
|
||||||
|
|
||||||
const [ringtoneVolume] = useSetting(settingsAtom, 'ringtoneVolume');
|
const [ringtoneVolume] = useSetting(settingsAtom, 'ringtoneVolume');
|
||||||
const [ringtoneId] = useSetting(settingsAtom, 'ringtoneId');
|
const [ringtoneId] = useSetting(settingsAtom, 'ringtoneId');
|
||||||
@@ -375,7 +421,7 @@ function IncomingCallBanner({ dm, info, onIgnore, onAnswer, onReject }: Incoming
|
|||||||
</Text>
|
</Text>
|
||||||
</Box>
|
</Box>
|
||||||
</Box>
|
</Box>
|
||||||
<Box gap="200">
|
<Box gap="200" wrap="Wrap">
|
||||||
<Button
|
<Button
|
||||||
style={{ flexGrow: 1 }}
|
style={{ flexGrow: 1 }}
|
||||||
variant="Success"
|
variant="Success"
|
||||||
@@ -384,11 +430,27 @@ function IncomingCallBanner({ dm, info, onIgnore, onAnswer, onReject }: Incoming
|
|||||||
radii="300"
|
radii="300"
|
||||||
onClick={() => onAnswer(room, isVideo)}
|
onClick={() => onAnswer(room, isVideo)}
|
||||||
before={<Icon size="100" src={isVideo ? Icons.VideoCamera : Icons.Phone} filled />}
|
before={<Icon size="100" src={isVideo ? Icons.VideoCamera : Icons.Phone} filled />}
|
||||||
|
title={bannerCameraOn ? 'Answering turns your camera on' : undefined}
|
||||||
>
|
>
|
||||||
<Text as="span" size="B300">
|
<Text as="span" size="B300">
|
||||||
Answer
|
{bannerCameraOn ? 'Answer with camera' : 'Answer'}
|
||||||
</Text>
|
</Text>
|
||||||
</Button>
|
</Button>
|
||||||
|
{bannerCameraOn && (
|
||||||
|
<Button
|
||||||
|
style={{ flexGrow: 1 }}
|
||||||
|
variant="Success"
|
||||||
|
fill="Soft"
|
||||||
|
size="300"
|
||||||
|
radii="300"
|
||||||
|
onClick={() => onAnswer(room, false)}
|
||||||
|
before={<Icon size="100" src={Icons.Phone} filled />}
|
||||||
|
>
|
||||||
|
<Text as="span" size="B300">
|
||||||
|
Answer without camera
|
||||||
|
</Text>
|
||||||
|
</Button>
|
||||||
|
)}
|
||||||
<Button
|
<Button
|
||||||
style={{ flexGrow: 1 }}
|
style={{ flexGrow: 1 }}
|
||||||
variant={dm ? 'Critical' : 'Secondary'}
|
variant={dm ? 'Critical' : 'Secondary'}
|
||||||
@@ -421,6 +483,7 @@ function IncomingCallListener({ callEmbed, joined }: IncomingCallListenerProps)
|
|||||||
const [callInfo, setCallInfo] = useState<IncomingCallInfo>();
|
const [callInfo, setCallInfo] = useState<IncomingCallInfo>();
|
||||||
const dm = callInfo ? directs.has(callInfo.room.roomId) : false;
|
const dm = callInfo ? directs.has(callInfo.room.roomId) : false;
|
||||||
const startCall = useCallStart(dm);
|
const startCall = useCallStart(dm);
|
||||||
|
const setCallEmbed = useSetAtom(callEmbedAtom);
|
||||||
const { microphone, sound } = useCallPreferences();
|
const { microphone, sound } = useCallPreferences();
|
||||||
const [cameraOnJoin] = useSetting(settingsAtom, 'cameraOnJoin');
|
const [cameraOnJoin] = useSetting(settingsAtom, 'cameraOnJoin');
|
||||||
|
|
||||||
@@ -559,6 +622,50 @@ function IncomingCallListener({ callEmbed, joined }: IncomingCallListenerProps)
|
|||||||
setCallInfo(undefined);
|
setCallInfo(undefined);
|
||||||
}, []);
|
}, []);
|
||||||
|
|
||||||
|
// [Gitea #161] Stop ringing here when the call was handled ELSEWHERE:
|
||||||
|
// - answered on another of our devices (our own m.call.member appears),
|
||||||
|
// - declined on another of our devices (our own RTCDecline for this ring),
|
||||||
|
// - the caller hung up before we picked up (nobody left in the session).
|
||||||
|
// Without this every other device kept ringing for the full lifetime.
|
||||||
|
useEffect(() => {
|
||||||
|
if (!callInfo) return undefined;
|
||||||
|
const { room, refEventId } = callInfo;
|
||||||
|
const myUserId = mx.getSafeUserId();
|
||||||
|
const dismiss = () =>
|
||||||
|
setCallInfo((current) => (current?.refEventId === refEventId ? undefined : current));
|
||||||
|
|
||||||
|
const session = mx.matrixRTC.getRoomSession(room);
|
||||||
|
const checkMemberships = () => {
|
||||||
|
const { memberships } = session;
|
||||||
|
if (memberships.some((m) => m.sender === myUserId))
|
||||||
|
dismiss(); // answered elsewhere
|
||||||
|
else if (memberships.length === 0) dismiss(); // caller gone
|
||||||
|
};
|
||||||
|
const onTimeline: EventTimelineSetHandlerMap[RoomEvent.Timeline] = (
|
||||||
|
event,
|
||||||
|
eventRoom,
|
||||||
|
_s,
|
||||||
|
_r,
|
||||||
|
data,
|
||||||
|
) => {
|
||||||
|
if (eventRoom?.roomId !== room.roomId || !data.liveEvent) return;
|
||||||
|
if (event.getType() === EventType.RTCDecline && event.getSender() === myUserId) {
|
||||||
|
const related = event.getRelation()?.event_id;
|
||||||
|
if (!related || related === refEventId) dismiss(); // declined elsewhere
|
||||||
|
}
|
||||||
|
};
|
||||||
|
session.on(MatrixRTCSessionEvent.MembershipsChanged, checkMemberships);
|
||||||
|
mx.on(RoomEvent.Timeline, onTimeline);
|
||||||
|
// The caller's membership may not have arrived yet when the ring starts —
|
||||||
|
// only treat "empty" as hung-up after it has had a moment to sync.
|
||||||
|
const settle = setTimeout(checkMemberships, 5000);
|
||||||
|
return () => {
|
||||||
|
session.off(MatrixRTCSessionEvent.MembershipsChanged, checkMemberships);
|
||||||
|
mx.removeListener(RoomEvent.Timeline, onTimeline);
|
||||||
|
clearTimeout(settle);
|
||||||
|
};
|
||||||
|
}, [mx, callInfo]);
|
||||||
|
|
||||||
const handleReject = useCallback(
|
const handleReject = useCallback(
|
||||||
(room: Room, eventId: string) => {
|
(room: Room, eventId: string) => {
|
||||||
// Best-effort: the local UI dismisses regardless (below), but a failed
|
// Best-effort: the local UI dismisses regardless (below), but a failed
|
||||||
@@ -578,16 +685,26 @@ function IncomingCallListener({ callEmbed, joined }: IncomingCallListenerProps)
|
|||||||
);
|
);
|
||||||
|
|
||||||
const handleAnswer = useCallback(
|
const handleAnswer = useCallback(
|
||||||
(room: Room, video: boolean) => {
|
async (room: Room, video: boolean) => {
|
||||||
|
setCallInfo(undefined);
|
||||||
|
// [Gitea #195] Answering from the in-call banner is the one call-to-call
|
||||||
|
// switch path. Disposing the current embed alone leaves our ghost
|
||||||
|
// `m.call.member` in the old room for ~17 s (until the delayed leave
|
||||||
|
// expires) — hang up explicitly and wait for the membership to clear.
|
||||||
|
if (callEmbed?.joined) {
|
||||||
|
await hangupCallAndWait(mx, callEmbed);
|
||||||
|
// Dispose it ourselves now: its HangupCall echo would otherwise land
|
||||||
|
// after startCall() and clear the NEW embed from the atom.
|
||||||
|
setCallEmbed(undefined);
|
||||||
|
}
|
||||||
// Honour cameraOnJoin and the persisted mic/sound preferences instead of
|
// Honour cameraOnJoin and the persisted mic/sound preferences instead of
|
||||||
// forcing camera+mic+sound on — every other join path does this, and
|
// forcing camera+mic+sound on — every other join path does this, and
|
||||||
// Answer was skipping it, publishing the camera with no prescreen.
|
// Answer was skipping it, publishing the camera with no prescreen.
|
||||||
// (PTT's forceAudioOff is applied downstream inside useCallStart.)
|
// (PTT's forceAudioOff is applied downstream inside useCallStart.)
|
||||||
startCall(room, { microphone, video: cameraOnJoin && video, sound });
|
startCall(room, { microphone, video: cameraOnJoin && video, sound });
|
||||||
setCallInfo(undefined);
|
|
||||||
navigateRoom(room.roomId);
|
navigateRoom(room.roomId);
|
||||||
},
|
},
|
||||||
[startCall, navigateRoom, microphone, sound, cameraOnJoin],
|
[startCall, navigateRoom, microphone, sound, cameraOnJoin, callEmbed, mx, setCallEmbed],
|
||||||
);
|
);
|
||||||
|
|
||||||
if (!callInfo) return null;
|
if (!callInfo) return null;
|
||||||
@@ -619,6 +736,16 @@ function IncomingCallListener({ callEmbed, joined }: IncomingCallListenerProps)
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// [Gitea #168] Lives outside the embed so "Call ended" is still announced.
|
||||||
|
function CallAnnouncementRegion() {
|
||||||
|
const announcement = useAtomValue(callAnnouncementAtom);
|
||||||
|
return (
|
||||||
|
<span className={SrOnly} role="status" aria-live="polite" aria-atomic="true">
|
||||||
|
{announcement}
|
||||||
|
</span>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
function CallUtils({ embed, joined }: { embed: CallEmbed; joined: boolean }) {
|
function CallUtils({ embed, joined }: { embed: CallEmbed; joined: boolean }) {
|
||||||
const setCallEmbed = useSetAtom(callEmbedAtom);
|
const setCallEmbed = useSetAtom(callEmbedAtom);
|
||||||
|
|
||||||
@@ -628,8 +755,19 @@ function CallUtils({ embed, joined }: { embed: CallEmbed; joined: boolean }) {
|
|||||||
// the mobile in-call chat. Both are gated on `joined`.
|
// the mobile in-call chat. Both are gated on `joined`.
|
||||||
useCallHotkeys(embed, joined);
|
useCallHotkeys(embed, joined);
|
||||||
useAfkAutoMute(joined ? embed : undefined);
|
useAfkAutoMute(joined ? embed : undefined);
|
||||||
useCallMemberSoundSync(embed);
|
|
||||||
useCallJoinLeaveSounds(embed);
|
useCallJoinLeaveSounds(embed);
|
||||||
|
useCallPolicyRevokedToast(embed, joined);
|
||||||
|
useCallEndedToast(embed);
|
||||||
|
useScreenshareNotices(embed);
|
||||||
|
// [Gitea #43] The in-frame screenshare button follows the same room policy
|
||||||
|
// as the host bar's (hidden where the server would refuse the share).
|
||||||
|
const { allowScreenshare } = useRoomCallPolicy(embed.room);
|
||||||
|
useEffect(() => {
|
||||||
|
embed.control.setFrameScreenshareAllowed(allowScreenshare);
|
||||||
|
}, [embed, allowScreenshare]);
|
||||||
|
usePttHaptics();
|
||||||
|
useCallAnnouncements(embed, joined);
|
||||||
|
useMutedTalkWarning(embed, joined);
|
||||||
useCallThemeSync(embed);
|
useCallThemeSync(embed);
|
||||||
useCallQuality(embed);
|
useCallQuality(embed);
|
||||||
useCallHangupEvent(
|
useCallHangupEvent(
|
||||||
@@ -724,6 +862,12 @@ function PipMuteOverlay({ callEmbed }: { callEmbed: CallEmbed }) {
|
|||||||
type CallEmbedProviderProps = {
|
type CallEmbedProviderProps = {
|
||||||
children?: ReactNode;
|
children?: ReactNode;
|
||||||
};
|
};
|
||||||
|
/** [Gitea #118] Heartbeat + rejoin after a crash/restart; needs the embed container mounted. */
|
||||||
|
function CallRejoin({ callEmbed, joined }: { callEmbed?: CallEmbed; joined: boolean }) {
|
||||||
|
useCallRejoin(callEmbed, joined);
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
export function CallEmbedProvider({ children }: CallEmbedProviderProps) {
|
export function CallEmbedProvider({ children }: CallEmbedProviderProps) {
|
||||||
const callEmbed = useAtomValue(callEmbedAtom);
|
const callEmbed = useAtomValue(callEmbedAtom);
|
||||||
const callEmbedRef = useRef<HTMLDivElement>(null) as React.RefObject<HTMLDivElement>;
|
const callEmbedRef = useRef<HTMLDivElement>(null) as React.RefObject<HTMLDivElement>;
|
||||||
@@ -1173,8 +1317,10 @@ export function CallEmbedProvider({ children }: CallEmbedProviderProps) {
|
|||||||
return (
|
return (
|
||||||
<CallEmbedContextProvider value={callEmbed}>
|
<CallEmbedContextProvider value={callEmbed}>
|
||||||
{callEmbed && <CallUtils embed={callEmbed} joined={joined} />}
|
{callEmbed && <CallUtils embed={callEmbed} joined={joined} />}
|
||||||
|
<CallAnnouncementRegion />
|
||||||
<CallEmbedRefContextProvider value={callEmbedRef}>
|
<CallEmbedRefContextProvider value={callEmbedRef}>
|
||||||
<IncomingCallListener callEmbed={callEmbed} joined={joined} />
|
<IncomingCallListener callEmbed={callEmbed} joined={joined} />
|
||||||
|
<CallRejoin callEmbed={callEmbed} joined={joined} />
|
||||||
{children}
|
{children}
|
||||||
</CallEmbedRefContextProvider>
|
</CallEmbedRefContextProvider>
|
||||||
<div
|
<div
|
||||||
@@ -1186,7 +1332,15 @@ export function CallEmbedProvider({ children }: CallEmbedProviderProps) {
|
|||||||
left: 0,
|
left: 0,
|
||||||
width: '100%',
|
width: '100%',
|
||||||
height: '50%',
|
height: '50%',
|
||||||
...(callVisible && !pipMode ? wallpaperStyle : {}),
|
// [Gitea #224] The fork renders EC transparent (lotusTransparent) so the
|
||||||
|
// wallpaper shows through the full-size embed; in PiP the thing behind
|
||||||
|
// the frame is whatever room you navigated to, so give it an opaque
|
||||||
|
// surface instead of letting the timeline bleed through the tiles.
|
||||||
|
...(pipMode
|
||||||
|
? { background: color.Surface.Container }
|
||||||
|
: callVisible
|
||||||
|
? wallpaperStyle
|
||||||
|
: {}),
|
||||||
}}
|
}}
|
||||||
ref={callEmbedRef}
|
ref={callEmbedRef}
|
||||||
>
|
>
|
||||||
|
|||||||
@@ -0,0 +1,114 @@
|
|||||||
|
import React, { useCallback, useEffect, useState } from 'react';
|
||||||
|
import FocusTrap from 'focus-trap-react';
|
||||||
|
import {
|
||||||
|
Box,
|
||||||
|
Button,
|
||||||
|
Checkbox,
|
||||||
|
Dialog,
|
||||||
|
Header,
|
||||||
|
Overlay,
|
||||||
|
OverlayBackdrop,
|
||||||
|
OverlayCenter,
|
||||||
|
Text,
|
||||||
|
config,
|
||||||
|
} from 'folds';
|
||||||
|
import { invokeTauri, isTauri, tauriInvoke, useTauriEvent } from '../hooks/useTauri';
|
||||||
|
import { useModalStyle } from '../hooks/useModalStyle';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* cinny-desktop #5: the first time the window is closed, ask whether Lotus Chat
|
||||||
|
* should keep running in the tray (calls, messages, notifications) or quit —
|
||||||
|
* and, in the same moment, whether it should start when you sign in. Asked
|
||||||
|
* once; changeable in Settings → General. The native side sends
|
||||||
|
* `lotus-close-requested` only while the choice is still "ask", and never
|
||||||
|
* during a call (a call always goes to the tray).
|
||||||
|
*/
|
||||||
|
export function CloseBehaviorPrompt() {
|
||||||
|
const [open, setOpen] = useState(false);
|
||||||
|
const [launchOnLogin, setLaunchOnLogin] = useState(false);
|
||||||
|
const modalStyle = useModalStyle(420);
|
||||||
|
|
||||||
|
// Tells the native side we're listening (see get_close_behavior).
|
||||||
|
useEffect(() => {
|
||||||
|
if (!isTauri()) return;
|
||||||
|
tauriInvoke()?.('get_close_behavior').catch(() => undefined);
|
||||||
|
}, []);
|
||||||
|
|
||||||
|
useTauriEvent('lotus-close-requested', () => setOpen(true));
|
||||||
|
|
||||||
|
const choose = useCallback(
|
||||||
|
(value: 'tray' | 'quit') => {
|
||||||
|
if (launchOnLogin) invokeTauri('plugin:autostart|enable');
|
||||||
|
setOpen(false);
|
||||||
|
invokeTauri('resolve_close_request', { value });
|
||||||
|
},
|
||||||
|
[launchOnLogin],
|
||||||
|
);
|
||||||
|
|
||||||
|
if (!open) return null;
|
||||||
|
return (
|
||||||
|
<Overlay open backdrop={<OverlayBackdrop />}>
|
||||||
|
<OverlayCenter>
|
||||||
|
<FocusTrap
|
||||||
|
focusTrapOptions={{
|
||||||
|
initialFocus: '#close-behavior-keep',
|
||||||
|
// Dismissing without choosing keeps the window open; the next close
|
||||||
|
// asks again.
|
||||||
|
onDeactivate: () => setOpen(false),
|
||||||
|
clickOutsideDeactivates: true,
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
<Dialog
|
||||||
|
variant="Surface"
|
||||||
|
role="dialog"
|
||||||
|
aria-modal="true"
|
||||||
|
aria-labelledby="close-behavior-title"
|
||||||
|
aria-describedby="close-behavior-body"
|
||||||
|
style={modalStyle}
|
||||||
|
>
|
||||||
|
<Header
|
||||||
|
style={{
|
||||||
|
padding: `0 ${config.space.S400}`,
|
||||||
|
borderBottomWidth: config.borderWidth.B300,
|
||||||
|
}}
|
||||||
|
variant="Surface"
|
||||||
|
size="500"
|
||||||
|
>
|
||||||
|
<Text as="h2" size="H4" id="close-behavior-title">
|
||||||
|
Keep Lotus Chat running?
|
||||||
|
</Text>
|
||||||
|
</Header>
|
||||||
|
<Box style={{ padding: config.space.S400 }} direction="Column" gap="400">
|
||||||
|
<Text priority="400" id="close-behavior-body">
|
||||||
|
Lotus Chat can keep running in the system tray when you close this window, so
|
||||||
|
messages, notifications and calls still reach you. Open it again from the tray icon.
|
||||||
|
</Text>
|
||||||
|
<Box as="label" alignItems="Center" gap="200" style={{ cursor: 'pointer' }}>
|
||||||
|
<Checkbox
|
||||||
|
size="300"
|
||||||
|
variant="Primary"
|
||||||
|
checked={launchOnLogin}
|
||||||
|
onClick={(e: React.MouseEvent<HTMLInputElement>) =>
|
||||||
|
setLaunchOnLogin(e.currentTarget.checked)
|
||||||
|
}
|
||||||
|
/>
|
||||||
|
<Text size="T300">Start Lotus Chat when I sign in to my computer</Text>
|
||||||
|
</Box>
|
||||||
|
<Box direction="Column" gap="200">
|
||||||
|
<Button id="close-behavior-keep" variant="Primary" onClick={() => choose('tray')}>
|
||||||
|
<Text size="B400">Keep running in the tray</Text>
|
||||||
|
</Button>
|
||||||
|
<Button variant="Secondary" fill="Soft" onClick={() => choose('quit')}>
|
||||||
|
<Text size="B400">Quit when I close the window</Text>
|
||||||
|
</Button>
|
||||||
|
</Box>
|
||||||
|
<Text size="T200" priority="300">
|
||||||
|
You can change this in Settings → General.
|
||||||
|
</Text>
|
||||||
|
</Box>
|
||||||
|
</Dialog>
|
||||||
|
</FocusTrap>
|
||||||
|
</OverlayCenter>
|
||||||
|
</Overlay>
|
||||||
|
);
|
||||||
|
}
|
||||||
@@ -0,0 +1,168 @@
|
|||||||
|
import React, { useCallback, useEffect, useRef, useState } from 'react';
|
||||||
|
import FocusTrap from 'focus-trap-react';
|
||||||
|
import {
|
||||||
|
Box,
|
||||||
|
Button,
|
||||||
|
Dialog,
|
||||||
|
Header,
|
||||||
|
Icon,
|
||||||
|
Icons,
|
||||||
|
Overlay,
|
||||||
|
OverlayBackdrop,
|
||||||
|
OverlayCenter,
|
||||||
|
Text,
|
||||||
|
config,
|
||||||
|
} from 'folds';
|
||||||
|
import {
|
||||||
|
EventStatus,
|
||||||
|
HttpApiEvent,
|
||||||
|
HttpApiEventHandlerMap,
|
||||||
|
MatrixEvent,
|
||||||
|
Room,
|
||||||
|
RoomEvent,
|
||||||
|
RoomEventHandlerMap,
|
||||||
|
} from 'matrix-js-sdk';
|
||||||
|
import { useMatrixClient } from '../hooks/useMatrixClient';
|
||||||
|
import { useModalStyle } from '../hooks/useModalStyle';
|
||||||
|
import { failedForConsent, safeConsentUri } from '../utils/consent';
|
||||||
|
|
||||||
|
// After "Later", don't re-open for every background retry; the next send the
|
||||||
|
// user makes after this window explains again.
|
||||||
|
const SNOOZE_MS = 10_000;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* A homeserver with a consent requirement (e.g. Synapse's user_consent) blocks
|
||||||
|
* sending until its terms are accepted, answering 403 M_CONSENT_NOT_GIVEN with a `consent_uri`. Without
|
||||||
|
* this the message just shows "Failed to send". The SDK emits
|
||||||
|
* HttpApiEvent.NoConsent for every such response; we explain why, link to the
|
||||||
|
* acceptance page, and offer to resend what was blocked once accepted.
|
||||||
|
*/
|
||||||
|
export function ConsentRequiredPrompt() {
|
||||||
|
const mx = useMatrixClient();
|
||||||
|
const [consentUri, setConsentUri] = useState<string>();
|
||||||
|
const [open, setOpen] = useState(false);
|
||||||
|
const [opened, setOpened] = useState(false);
|
||||||
|
const [blockedCount, setBlockedCount] = useState(0);
|
||||||
|
const snoozedUntil = useRef(0);
|
||||||
|
const blocked = useRef(new Map<MatrixEvent, Room>());
|
||||||
|
const modalStyle = useModalStyle(440);
|
||||||
|
const server = mx.getDomain() ?? 'Your homeserver';
|
||||||
|
|
||||||
|
useEffect(() => {
|
||||||
|
const onNoConsent: HttpApiEventHandlerMap[HttpApiEvent.NoConsent] = (_message, uri) => {
|
||||||
|
const safe = safeConsentUri(uri);
|
||||||
|
if (safe) setConsentUri(safe);
|
||||||
|
if (Date.now() >= snoozedUntil.current) setOpen(true);
|
||||||
|
};
|
||||||
|
const onLocalEcho: RoomEventHandlerMap[RoomEvent.LocalEchoUpdated] = (event, room) => {
|
||||||
|
if (failedForConsent(event)) blocked.current.set(event, room);
|
||||||
|
else if (!blocked.current.delete(event)) return;
|
||||||
|
setBlockedCount(blocked.current.size);
|
||||||
|
};
|
||||||
|
mx.on(HttpApiEvent.NoConsent, onNoConsent);
|
||||||
|
mx.on(RoomEvent.LocalEchoUpdated, onLocalEcho);
|
||||||
|
return () => {
|
||||||
|
mx.removeListener(HttpApiEvent.NoConsent, onNoConsent);
|
||||||
|
mx.removeListener(RoomEvent.LocalEchoUpdated, onLocalEcho);
|
||||||
|
};
|
||||||
|
}, [mx]);
|
||||||
|
|
||||||
|
const review = useCallback(() => {
|
||||||
|
if (!consentUri) return;
|
||||||
|
window.open(consentUri, '_blank', 'noopener,noreferrer');
|
||||||
|
setOpened(true);
|
||||||
|
}, [consentUri]);
|
||||||
|
|
||||||
|
const retry = useCallback(() => {
|
||||||
|
setOpen(false);
|
||||||
|
setOpened(false);
|
||||||
|
const pending = Array.from(blocked.current.entries());
|
||||||
|
blocked.current.clear();
|
||||||
|
setBlockedCount(0);
|
||||||
|
pending.forEach(([event, room]) => {
|
||||||
|
if (event.status === EventStatus.NOT_SENT) mx.resendEvent(event, room);
|
||||||
|
});
|
||||||
|
}, [mx]);
|
||||||
|
|
||||||
|
const later = useCallback(() => {
|
||||||
|
snoozedUntil.current = Date.now() + SNOOZE_MS;
|
||||||
|
setOpen(false);
|
||||||
|
}, []);
|
||||||
|
|
||||||
|
if (!open) return null;
|
||||||
|
return (
|
||||||
|
<Overlay open backdrop={<OverlayBackdrop />}>
|
||||||
|
<OverlayCenter>
|
||||||
|
<FocusTrap
|
||||||
|
focusTrapOptions={{
|
||||||
|
initialFocus: '#consent-review',
|
||||||
|
fallbackFocus: '#consent-later',
|
||||||
|
onDeactivate: later,
|
||||||
|
clickOutsideDeactivates: true,
|
||||||
|
escapeDeactivates: true,
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
<Dialog
|
||||||
|
variant="Surface"
|
||||||
|
role="alertdialog"
|
||||||
|
aria-modal="true"
|
||||||
|
aria-labelledby="consent-title"
|
||||||
|
aria-describedby="consent-body"
|
||||||
|
style={modalStyle}
|
||||||
|
>
|
||||||
|
<Header
|
||||||
|
style={{
|
||||||
|
padding: `0 ${config.space.S400}`,
|
||||||
|
borderBottomWidth: config.borderWidth.B300,
|
||||||
|
}}
|
||||||
|
variant="Surface"
|
||||||
|
size="500"
|
||||||
|
>
|
||||||
|
<Text as="h2" size="H4" id="consent-title">
|
||||||
|
Accept the terms to keep chatting
|
||||||
|
</Text>
|
||||||
|
</Header>
|
||||||
|
<Box style={{ padding: config.space.S400 }} direction="Column" gap="400">
|
||||||
|
<Box id="consent-body" direction="Column" gap="200">
|
||||||
|
<Text priority="400">
|
||||||
|
Your message wasn't sent. <b>{server}</b> requires you to review and accept
|
||||||
|
its terms of service before you can send messages.
|
||||||
|
</Text>
|
||||||
|
<Text priority="400">
|
||||||
|
{consentUri
|
||||||
|
? 'Nothing you sent is lost: accept the terms, then come back here and retry.'
|
||||||
|
: 'Your homeserver didn’t include a link to its terms. Contact its administrator, or accept them in another Matrix app, then retry.'}
|
||||||
|
</Text>
|
||||||
|
</Box>
|
||||||
|
<Box direction="Column" gap="200">
|
||||||
|
{consentUri && (
|
||||||
|
<Button
|
||||||
|
id="consent-review"
|
||||||
|
variant={opened ? 'Secondary' : 'Primary'}
|
||||||
|
fill={opened ? 'Soft' : 'Solid'}
|
||||||
|
onClick={review}
|
||||||
|
after={<Icon size="100" src={Icons.External} />}
|
||||||
|
>
|
||||||
|
<Text size="B400">Review and accept</Text>
|
||||||
|
</Button>
|
||||||
|
)}
|
||||||
|
<Button
|
||||||
|
variant={opened ? 'Primary' : 'Secondary'}
|
||||||
|
fill={opened ? 'Solid' : 'Soft'}
|
||||||
|
onClick={retry}
|
||||||
|
>
|
||||||
|
<Text size="B400">
|
||||||
|
{blockedCount > 0 ? "I've accepted — retry sending" : "I've accepted"}
|
||||||
|
</Text>
|
||||||
|
</Button>
|
||||||
|
<Button id="consent-later" variant="Secondary" fill="None" onClick={later}>
|
||||||
|
<Text size="B400">Later</Text>
|
||||||
|
</Button>
|
||||||
|
</Box>
|
||||||
|
</Box>
|
||||||
|
</Dialog>
|
||||||
|
</FocusTrap>
|
||||||
|
</OverlayCenter>
|
||||||
|
</Overlay>
|
||||||
|
);
|
||||||
|
}
|
||||||
@@ -8,7 +8,6 @@ import {
|
|||||||
import React, { CSSProperties, useCallback, useEffect, useRef, useState } from 'react';
|
import React, { CSSProperties, useCallback, useEffect, useRef, useState } from 'react';
|
||||||
import { useTranslation } from 'react-i18next';
|
import { useTranslation } from 'react-i18next';
|
||||||
import { VerificationMethod } from 'matrix-js-sdk/lib/types';
|
import { VerificationMethod } from 'matrix-js-sdk/lib/types';
|
||||||
import QRCode from 'qrcode';
|
|
||||||
import {
|
import {
|
||||||
Box,
|
Box,
|
||||||
Button,
|
Button,
|
||||||
@@ -221,12 +220,16 @@ function QrCodeImage({ data }: { data: Uint8ClampedArray }) {
|
|||||||
const canvas = canvasRef.current;
|
const canvas = canvasRef.current;
|
||||||
if (!canvas) return;
|
if (!canvas) return;
|
||||||
// Byte-mode so the raw verification bytes round-trip (a string value would
|
// Byte-mode so the raw verification bytes round-trip (a string value would
|
||||||
// mangle high bytes via UTF-8).
|
// mangle high bytes via UTF-8). The QR library is loaded on demand.
|
||||||
QRCode.toCanvas(canvas, [{ data: new Uint8Array(data), mode: 'byte' }], {
|
import('qrcode')
|
||||||
width: 220,
|
.then(({ default: QRCode }) =>
|
||||||
margin: 2,
|
QRCode.toCanvas(canvas, [{ data: new Uint8Array(data), mode: 'byte' }], {
|
||||||
color: { dark: '#000000', light: '#ffffff' },
|
width: 220,
|
||||||
}).catch(() => undefined);
|
margin: 2,
|
||||||
|
color: { dark: '#000000', light: '#ffffff' },
|
||||||
|
}),
|
||||||
|
)
|
||||||
|
.catch(() => undefined);
|
||||||
}, [data]);
|
}, [data]);
|
||||||
return (
|
return (
|
||||||
<Box justifyContent="Center">
|
<Box justifyContent="Center">
|
||||||
@@ -365,15 +368,23 @@ export function DeviceVerification({ request, onExit }: DeviceVerificationProps)
|
|||||||
<OverlayCenter>
|
<OverlayCenter>
|
||||||
<FocusTrap
|
<FocusTrap
|
||||||
focusTrapOptions={{
|
focusTrapOptions={{
|
||||||
initialFocus: false,
|
fallbackFocus: '#deviceverification-dialog-1',
|
||||||
clickOutsideDeactivates: false,
|
clickOutsideDeactivates: false,
|
||||||
escapeDeactivates: false,
|
escapeDeactivates: false,
|
||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
<Dialog variant="Surface" style={modalStyle}>
|
<Dialog
|
||||||
|
id="deviceverification-dialog-1"
|
||||||
|
role="dialog"
|
||||||
|
aria-modal="true"
|
||||||
|
aria-labelledby="deviceverification-dialog-1-title"
|
||||||
|
tabIndex={-1}
|
||||||
|
variant="Surface"
|
||||||
|
style={modalStyle}
|
||||||
|
>
|
||||||
<Header style={DialogHeaderStyles} variant="Surface" size="500">
|
<Header style={DialogHeaderStyles} variant="Surface" size="500">
|
||||||
<Box grow="Yes">
|
<Box grow="Yes">
|
||||||
<Text as="h2" size="H4">
|
<Text id="deviceverification-dialog-1-title" as="h2" size="H4">
|
||||||
Device Verification
|
Device Verification
|
||||||
</Text>
|
</Text>
|
||||||
</Box>
|
</Box>
|
||||||
|
|||||||
@@ -19,7 +19,7 @@ import { useSaveFile } from '../hooks/useSaveFile';
|
|||||||
import { useModalStyle } from '../hooks/useModalStyle';
|
import { useModalStyle } from '../hooks/useModalStyle';
|
||||||
import { PasswordInput } from './password-input';
|
import { PasswordInput } from './password-input';
|
||||||
import { ContainerColor } from '../styles/ContainerColor.css';
|
import { ContainerColor } from '../styles/ContainerColor.css';
|
||||||
import { copyToClipboard } from '../utils/dom';
|
import { useSensitiveCopy } from '../hooks/useSensitiveCopy';
|
||||||
import { AsyncStatus, useAsyncCallback } from '../hooks/useAsyncCallback';
|
import { AsyncStatus, useAsyncCallback } from '../hooks/useAsyncCallback';
|
||||||
import { clearSecretStorageKeys } from '../../client/secretStorageKeys';
|
import { clearSecretStorageKeys } from '../../client/secretStorageKeys';
|
||||||
import { ActionUIA, ActionUIAFlowsLoader } from './ActionUIA';
|
import { ActionUIA, ActionUIAFlowsLoader } from './ActionUIA';
|
||||||
@@ -232,9 +232,8 @@ function RecoveryKeyDisplay({ recoveryKey }: RecoveryKeyDisplayProps) {
|
|||||||
const [show, setShow] = useState(false);
|
const [show, setShow] = useState(false);
|
||||||
const saveFile = useSaveFile();
|
const saveFile = useSaveFile();
|
||||||
|
|
||||||
const handleCopy = () => {
|
// [Gitea #156] The key leaves the clipboard again after 60 s, visibly.
|
||||||
copyToClipboard(recoveryKey);
|
const { copy: handleCopy, secondsLeft } = useSensitiveCopy(recoveryKey);
|
||||||
};
|
|
||||||
|
|
||||||
const handleDownload = () => {
|
const handleDownload = () => {
|
||||||
const blob = new Blob([recoveryKey], {
|
const blob = new Blob([recoveryKey], {
|
||||||
@@ -272,8 +271,10 @@ function RecoveryKeyDisplay({ recoveryKey }: RecoveryKeyDisplayProps) {
|
|||||||
</Box>
|
</Box>
|
||||||
</Box>
|
</Box>
|
||||||
<Box direction="Column" gap="200">
|
<Box direction="Column" gap="200">
|
||||||
<Button onClick={handleCopy}>
|
<Button onClick={handleCopy} aria-live="polite">
|
||||||
<Text size="B400">Copy</Text>
|
<Text size="B400">
|
||||||
|
{secondsLeft !== null ? `Copied · clears in ${secondsLeft} s` : 'Copy'}
|
||||||
|
</Text>
|
||||||
</Button>
|
</Button>
|
||||||
<Button onClick={handleDownload} fill="Soft">
|
<Button onClick={handleDownload} fill="Soft">
|
||||||
<Text size="B400">Download</Text>
|
<Text size="B400">Download</Text>
|
||||||
@@ -292,7 +293,15 @@ export const DeviceVerificationSetup = forwardRef<HTMLDivElement, DeviceVerifica
|
|||||||
const modalStyle = useModalStyle(480);
|
const modalStyle = useModalStyle(480);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<Dialog ref={ref} style={modalStyle}>
|
<Dialog
|
||||||
|
id="deviceverificationsetup-dialog-1"
|
||||||
|
role="dialog"
|
||||||
|
aria-modal="true"
|
||||||
|
aria-labelledby="deviceverificationsetup-dialog-1-title"
|
||||||
|
tabIndex={-1}
|
||||||
|
ref={ref}
|
||||||
|
style={modalStyle}
|
||||||
|
>
|
||||||
<Header
|
<Header
|
||||||
style={{
|
style={{
|
||||||
padding: `0 ${config.space.S200} 0 ${config.space.S400}`,
|
padding: `0 ${config.space.S200} 0 ${config.space.S400}`,
|
||||||
@@ -302,7 +311,7 @@ export const DeviceVerificationSetup = forwardRef<HTMLDivElement, DeviceVerifica
|
|||||||
size="500"
|
size="500"
|
||||||
>
|
>
|
||||||
<Box grow="Yes">
|
<Box grow="Yes">
|
||||||
<Text as="h2" size="H4">
|
<Text id="deviceverificationsetup-dialog-1-title" as="h2" size="H4">
|
||||||
Setup Device Verification
|
Setup Device Verification
|
||||||
</Text>
|
</Text>
|
||||||
</Box>
|
</Box>
|
||||||
@@ -330,7 +339,15 @@ export const DeviceVerificationReset = forwardRef<HTMLDivElement, DeviceVerifica
|
|||||||
const modalStyle = useModalStyle(480);
|
const modalStyle = useModalStyle(480);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<Dialog ref={ref} style={modalStyle}>
|
<Dialog
|
||||||
|
id="deviceverificationsetup-dialog-2"
|
||||||
|
role="dialog"
|
||||||
|
aria-modal="true"
|
||||||
|
aria-labelledby="deviceverificationsetup-dialog-2-title"
|
||||||
|
tabIndex={-1}
|
||||||
|
ref={ref}
|
||||||
|
style={modalStyle}
|
||||||
|
>
|
||||||
<Header
|
<Header
|
||||||
style={{
|
style={{
|
||||||
padding: `0 ${config.space.S200} 0 ${config.space.S400}`,
|
padding: `0 ${config.space.S200} 0 ${config.space.S400}`,
|
||||||
@@ -340,7 +357,7 @@ export const DeviceVerificationReset = forwardRef<HTMLDivElement, DeviceVerifica
|
|||||||
size="500"
|
size="500"
|
||||||
>
|
>
|
||||||
<Box grow="Yes">
|
<Box grow="Yes">
|
||||||
<Text as="h2" size="H4">
|
<Text id="deviceverificationsetup-dialog-2-title" as="h2" size="H4">
|
||||||
Reset Device Verification
|
Reset Device Verification
|
||||||
</Text>
|
</Text>
|
||||||
</Box>
|
</Box>
|
||||||
|
|||||||
@@ -4,6 +4,8 @@ import { useAtom } from 'jotai';
|
|||||||
import { Grid, SearchBar, SearchContext, SearchContextManager } from '@giphy/react-components';
|
import { Grid, SearchBar, SearchContext, SearchContextManager } from '@giphy/react-components';
|
||||||
import { IGif } from '@giphy/js-types';
|
import { IGif } from '@giphy/js-types';
|
||||||
import { Box, color, config } from 'folds';
|
import { Box, color, config } from 'folds';
|
||||||
|
import { TapToSendBar } from './tap-to-send/TapToSendBar';
|
||||||
|
import { useRecentTouch } from '../hooks/useRecentTouch';
|
||||||
import { useElementSizeObserver } from '../hooks/useElementSizeObserver';
|
import { useElementSizeObserver } from '../hooks/useElementSizeObserver';
|
||||||
import { useSetting } from '../state/hooks/settings';
|
import { useSetting } from '../state/hooks/settings';
|
||||||
import { settingsAtom } from '../state/settings';
|
import { settingsAtom } from '../state/settings';
|
||||||
@@ -120,13 +122,31 @@ function GifPickerInner({ onSelect, requestClose, lotusTerminal }: GifPickerInne
|
|||||||
|
|
||||||
const sendGif = useCallback(
|
const sendGif = useCallback(
|
||||||
(gif: RecentGif) => {
|
(gif: RecentGif) => {
|
||||||
setRecents((prev) => addRecentGif(prev, gif));
|
const { url, width, height, previewUrl } = gif;
|
||||||
|
setRecents((prev) => addRecentGif(prev, { url, width, height, previewUrl }));
|
||||||
onSelect(gif.url, gif.width, gif.height);
|
onSelect(gif.url, gif.width, gif.height);
|
||||||
requestClose();
|
requestClose();
|
||||||
},
|
},
|
||||||
[onSelect, requestClose, setRecents],
|
[onSelect, requestClose, setRecents],
|
||||||
);
|
);
|
||||||
|
|
||||||
|
// [Gitea #147] Touch: first tap parks the GIF in a preview bar, second tap
|
||||||
|
// (or Send) sends. Mouse/keyboard/screen reader: one step, as before.
|
||||||
|
const containerRef = useRef<HTMLDivElement>(null);
|
||||||
|
const { wasTouch } = useRecentTouch(containerRef);
|
||||||
|
const [pending, setPending] = useState<(RecentGif & { title?: string }) | undefined>();
|
||||||
|
const pick = useCallback(
|
||||||
|
(gif: RecentGif & { title?: string }) => {
|
||||||
|
if (wasTouch() && pending?.url !== gif.url) {
|
||||||
|
setPending(gif);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
setPending(undefined);
|
||||||
|
sendGif(gif);
|
||||||
|
},
|
||||||
|
[wasTouch, pending, sendGif],
|
||||||
|
);
|
||||||
|
|
||||||
const handleClick = useCallback(
|
const handleClick = useCallback(
|
||||||
(gif: IGif, e: React.SyntheticEvent) => {
|
(gif: IGif, e: React.SyntheticEvent) => {
|
||||||
e.preventDefault();
|
e.preventDefault();
|
||||||
@@ -135,14 +155,15 @@ function GifPickerInner({ onSelect, requestClose, lotusTerminal }: GifPickerInne
|
|||||||
gif.images.fixed_width_small_still?.url ??
|
gif.images.fixed_width_small_still?.url ??
|
||||||
gif.images.downsized_still?.url ??
|
gif.images.downsized_still?.url ??
|
||||||
gif.images.original_still?.url;
|
gif.images.original_still?.url;
|
||||||
sendGif({
|
pick({
|
||||||
url: r.url,
|
url: r.url,
|
||||||
width: Number(r.width) || 200,
|
width: Number(r.width) || 200,
|
||||||
height: Number(r.height) || 200,
|
height: Number(r.height) || 200,
|
||||||
previewUrl,
|
previewUrl,
|
||||||
|
title: gif.title,
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
[sendGif],
|
[pick],
|
||||||
);
|
);
|
||||||
|
|
||||||
const showRecents = recents.length > 0 && !(term ?? '').trim();
|
const showRecents = recents.length > 0 && !(term ?? '').trim();
|
||||||
@@ -150,7 +171,6 @@ function GifPickerInner({ onSelect, requestClose, lotusTerminal }: GifPickerInne
|
|||||||
// The container is min(312px, 100vw-16); feed the Grid the live pixel width
|
// The container is min(312px, 100vw-16); feed the Grid the live pixel width
|
||||||
// (minus the inner 8px padding on each side) so it doesn't overflow a phone
|
// (minus the inner 8px padding on each side) so it doesn't overflow a phone
|
||||||
// narrower than 312px with a fixed 296px grid.
|
// narrower than 312px with a fixed 296px grid.
|
||||||
const containerRef = useRef<HTMLDivElement>(null);
|
|
||||||
const [gridWidth, setGridWidth] = useState(PICKER_WIDTH - 16);
|
const [gridWidth, setGridWidth] = useState(PICKER_WIDTH - 16);
|
||||||
useElementSizeObserver(
|
useElementSizeObserver(
|
||||||
useCallback(() => containerRef.current, []),
|
useCallback(() => containerRef.current, []),
|
||||||
@@ -180,11 +200,22 @@ function GifPickerInner({ onSelect, requestClose, lotusTerminal }: GifPickerInne
|
|||||||
<SearchBar />
|
<SearchBar />
|
||||||
</div>
|
</div>
|
||||||
</Box>
|
</Box>
|
||||||
|
{pending && (
|
||||||
|
<TapToSendBar
|
||||||
|
previewUrl={pending.previewUrl ?? pending.url}
|
||||||
|
label={pending.title || 'GIF'}
|
||||||
|
onSend={() => {
|
||||||
|
setPending(undefined);
|
||||||
|
sendGif(pending);
|
||||||
|
}}
|
||||||
|
onCancel={() => setPending(undefined)}
|
||||||
|
/>
|
||||||
|
)}
|
||||||
<div
|
<div
|
||||||
style={{ overflowY: 'auto', overflowX: 'hidden', maxHeight: '340px', padding: '0 8px 8px' }}
|
style={{ overflowY: 'auto', overflowX: 'hidden', maxHeight: '340px', padding: '0 8px 8px' }}
|
||||||
>
|
>
|
||||||
{showRecents && (
|
{showRecents && (
|
||||||
<RecentGifs recents={recents} lotusTerminal={lotusTerminal} onPick={sendGif} />
|
<RecentGifs recents={recents} lotusTerminal={lotusTerminal} onPick={pick} />
|
||||||
)}
|
)}
|
||||||
<Grid
|
<Grid
|
||||||
key={searchKey}
|
key={searchKey}
|
||||||
|
|||||||
@@ -30,7 +30,7 @@ export const ImageOverlay = as<'div', ImageOverlayProps>(
|
|||||||
<Modal
|
<Modal
|
||||||
className={ModalWide}
|
className={ModalWide}
|
||||||
size="500"
|
size="500"
|
||||||
onContextMenu={(evt: any) => evt.stopPropagation()}
|
onContextMenu={(evt: React.MouseEvent) => evt.stopPropagation()}
|
||||||
>
|
>
|
||||||
{renderViewer({
|
{renderViewer({
|
||||||
src,
|
src,
|
||||||
|
|||||||
@@ -1,7 +1,10 @@
|
|||||||
import React, { forwardRef, useCallback } from 'react';
|
import React, { forwardRef, useCallback } from 'react';
|
||||||
import { Dialog, Header, config, Box, Text, Button, Spinner, color } from 'folds';
|
import { Dialog, Header, config, Box, Text, Button, Spinner, color } from 'folds';
|
||||||
|
import { useAtom } from 'jotai';
|
||||||
import { AsyncStatus, useAsyncCallback } from '../hooks/useAsyncCallback';
|
import { AsyncStatus, useAsyncCallback } from '../hooks/useAsyncCallback';
|
||||||
import { logoutClient } from '../../client/initMatrix';
|
import { logoutClient } from '../../client/initMatrix';
|
||||||
|
import { callEmbedAtom } from '../state/callEmbed';
|
||||||
|
import { hangupCallAndWait } from '../plugins/call/hangup';
|
||||||
import { useMatrixClient } from '../hooks/useMatrixClient';
|
import { useMatrixClient } from '../hooks/useMatrixClient';
|
||||||
import { useModalStyle } from '../hooks/useModalStyle';
|
import { useModalStyle } from '../hooks/useModalStyle';
|
||||||
import { useCrossSigningActive } from '../hooks/useCrossSigning';
|
import { useCrossSigningActive } from '../hooks/useCrossSigning';
|
||||||
@@ -11,6 +14,11 @@ import {
|
|||||||
VerificationStatus,
|
VerificationStatus,
|
||||||
} from '../hooks/useDeviceVerificationStatus';
|
} from '../hooks/useDeviceVerificationStatus';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Ask Element Call to hang up and wait (bounded) until our own MatrixRTC
|
||||||
|
* membership has actually been removed from the room, so the leave reaches
|
||||||
|
* the homeserver before the client is stopped and the token is revoked.
|
||||||
|
*/
|
||||||
type LogoutDialogProps = {
|
type LogoutDialogProps = {
|
||||||
handleClose: () => void;
|
handleClose: () => void;
|
||||||
};
|
};
|
||||||
@@ -26,16 +34,34 @@ export const LogoutDialog = forwardRef<HTMLDivElement, LogoutDialogProps>(
|
|||||||
mx.getDeviceId() ?? undefined,
|
mx.getDeviceId() ?? undefined,
|
||||||
);
|
);
|
||||||
|
|
||||||
|
const [callEmbed, setCallEmbed] = useAtom(callEmbedAtom);
|
||||||
|
|
||||||
const [logoutState, logout] = useAsyncCallback<void, Error, []>(
|
const [logoutState, logout] = useAsyncCallback<void, Error, []>(
|
||||||
useCallback(async () => {
|
useCallback(async () => {
|
||||||
|
// [Gitea #29] Logging out mid-call must hang up first, or the MatrixRTC
|
||||||
|
// membership (expires: 4 h) stays behind as a ghost participant and
|
||||||
|
// everyone else sees you "in call" until it times out.
|
||||||
|
if (callEmbed && callEmbed.joined && !callEmbed.disposed) {
|
||||||
|
await hangupCallAndWait(mx, callEmbed);
|
||||||
|
setCallEmbed(undefined);
|
||||||
|
}
|
||||||
await logoutClient(mx);
|
await logoutClient(mx);
|
||||||
}, [mx]),
|
}, [mx, callEmbed, setCallEmbed]),
|
||||||
);
|
);
|
||||||
|
|
||||||
const ongoingLogout = logoutState.status === AsyncStatus.Loading;
|
const ongoingLogout = logoutState.status === AsyncStatus.Loading;
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<Dialog variant="Surface" ref={ref} style={modalStyle}>
|
<Dialog
|
||||||
|
id="logoutdialog-dialog-1"
|
||||||
|
role="dialog"
|
||||||
|
aria-modal="true"
|
||||||
|
aria-labelledby="logoutdialog-dialog-1-title"
|
||||||
|
tabIndex={-1}
|
||||||
|
variant="Surface"
|
||||||
|
ref={ref}
|
||||||
|
style={modalStyle}
|
||||||
|
>
|
||||||
<Header
|
<Header
|
||||||
style={{
|
style={{
|
||||||
padding: `0 ${config.space.S200} 0 ${config.space.S400}`,
|
padding: `0 ${config.space.S200} 0 ${config.space.S400}`,
|
||||||
@@ -45,7 +71,7 @@ export const LogoutDialog = forwardRef<HTMLDivElement, LogoutDialogProps>(
|
|||||||
size="500"
|
size="500"
|
||||||
>
|
>
|
||||||
<Box grow="Yes">
|
<Box grow="Yes">
|
||||||
<Text as="h2" size="H4">
|
<Text id="logoutdialog-dialog-1-title" as="h2" size="H4">
|
||||||
Logout
|
Logout
|
||||||
</Text>
|
</Text>
|
||||||
</Box>
|
</Box>
|
||||||
|
|||||||
@@ -24,6 +24,8 @@ export function Modal500({ requestClose, children }: Modal500Props) {
|
|||||||
<Modal
|
<Modal
|
||||||
size="500"
|
size="500"
|
||||||
variant="Background"
|
variant="Background"
|
||||||
|
role="dialog"
|
||||||
|
aria-modal="true"
|
||||||
// On mobile expand to fill the viewport. On desktop fall back to the
|
// On mobile expand to fill the viewport. On desktop fall back to the
|
||||||
// folds `size="500"` width (~50rem) — overriding maxWidth here would
|
// folds `size="500"` width (~50rem) — overriding maxWidth here would
|
||||||
// squish the two-pane settings layout.
|
// squish the two-pane settings layout.
|
||||||
|
|||||||
@@ -1,6 +1,5 @@
|
|||||||
import React, { useEffect, useRef, useState } from 'react';
|
import React, { useEffect, useRef, useState } from 'react';
|
||||||
import { Box, Button, color, config, Text } from 'folds';
|
import { Box, Button, color, config, Text } from 'folds';
|
||||||
import jsQR from 'jsqr';
|
|
||||||
|
|
||||||
type QrScannerProps = {
|
type QrScannerProps = {
|
||||||
onScan: (bytes: Uint8ClampedArray) => void;
|
onScan: (bytes: Uint8ClampedArray) => void;
|
||||||
@@ -10,6 +9,7 @@ type QrScannerProps = {
|
|||||||
// Camera QR scanner. Decodes frames with jsQR and hands back the raw byte
|
// Camera QR scanner. Decodes frames with jsQR and hands back the raw byte
|
||||||
// segment (`result.binaryData`) — Matrix QR verification needs the raw bytes,
|
// segment (`result.binaryData`) — Matrix QR verification needs the raw bytes,
|
||||||
// not a decoded string, so the string-only `BarcodeDetector` can't be used.
|
// not a decoded string, so the string-only `BarcodeDetector` can't be used.
|
||||||
|
// jsQR is loaded on demand: it is large and only needed while scanning.
|
||||||
export function QrScanner({ onScan, onCancel }: QrScannerProps) {
|
export function QrScanner({ onScan, onCancel }: QrScannerProps) {
|
||||||
const videoRef = useRef<HTMLVideoElement>(null);
|
const videoRef = useRef<HTMLVideoElement>(null);
|
||||||
const [error, setError] = useState<string>();
|
const [error, setError] = useState<string>();
|
||||||
@@ -20,15 +20,22 @@ export function QrScanner({ onScan, onCancel }: QrScannerProps) {
|
|||||||
let raf = 0;
|
let raf = 0;
|
||||||
const canvas = document.createElement('canvas');
|
const canvas = document.createElement('canvas');
|
||||||
const ctx = canvas.getContext('2d', { willReadFrequently: true });
|
const ctx = canvas.getContext('2d', { willReadFrequently: true });
|
||||||
|
let decode: typeof import('jsqr').default | undefined;
|
||||||
|
|
||||||
const tick = () => {
|
const tick = () => {
|
||||||
const video = videoRef.current;
|
const video = videoRef.current;
|
||||||
if (!doneRef.current && video && ctx && video.readyState === video.HAVE_ENOUGH_DATA) {
|
if (
|
||||||
|
decode &&
|
||||||
|
!doneRef.current &&
|
||||||
|
video &&
|
||||||
|
ctx &&
|
||||||
|
video.readyState === video.HAVE_ENOUGH_DATA
|
||||||
|
) {
|
||||||
canvas.width = video.videoWidth;
|
canvas.width = video.videoWidth;
|
||||||
canvas.height = video.videoHeight;
|
canvas.height = video.videoHeight;
|
||||||
ctx.drawImage(video, 0, 0, canvas.width, canvas.height);
|
ctx.drawImage(video, 0, 0, canvas.width, canvas.height);
|
||||||
const image = ctx.getImageData(0, 0, canvas.width, canvas.height);
|
const image = ctx.getImageData(0, 0, canvas.width, canvas.height);
|
||||||
const result = jsQR(image.data, image.width, image.height);
|
const result = decode(image.data, image.width, image.height);
|
||||||
if (result && result.binaryData.length > 0) {
|
if (result && result.binaryData.length > 0) {
|
||||||
doneRef.current = true;
|
doneRef.current = true;
|
||||||
onScan(new Uint8ClampedArray(result.binaryData));
|
onScan(new Uint8ClampedArray(result.binaryData));
|
||||||
@@ -40,9 +47,12 @@ export function QrScanner({ onScan, onCancel }: QrScannerProps) {
|
|||||||
|
|
||||||
(async () => {
|
(async () => {
|
||||||
try {
|
try {
|
||||||
stream = await navigator.mediaDevices.getUserMedia({
|
const [lib, media] = await Promise.all([
|
||||||
video: { facingMode: 'environment' },
|
import('jsqr'),
|
||||||
});
|
navigator.mediaDevices.getUserMedia({ video: { facingMode: 'environment' } }),
|
||||||
|
]);
|
||||||
|
decode = lib.default;
|
||||||
|
stream = media;
|
||||||
if (videoRef.current) {
|
if (videoRef.current) {
|
||||||
videoRef.current.srcObject = stream;
|
videoRef.current.srcObject = stream;
|
||||||
await videoRef.current.play();
|
await videoRef.current.play();
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
import React from 'react';
|
import React from 'react';
|
||||||
import { MsgType } from 'matrix-js-sdk';
|
import { MatrixEvent, MsgType } from 'matrix-js-sdk';
|
||||||
import { HTMLReactParserOptions } from 'html-react-parser';
|
import { HTMLReactParserOptions } from 'html-react-parser';
|
||||||
import { Opts } from 'linkifyjs';
|
import { Opts } from 'linkifyjs';
|
||||||
import { config, Text } from 'folds';
|
import { config, Text } from 'folds';
|
||||||
@@ -26,6 +26,8 @@ import {
|
|||||||
VerificationRequestContent,
|
VerificationRequestContent,
|
||||||
VideoContent,
|
VideoContent,
|
||||||
} from './message';
|
} from './message';
|
||||||
|
import { DiffToken } from '../utils/wordDiff';
|
||||||
|
import { EditDiffContext } from './message/content/EditDiffContext';
|
||||||
import { UrlPreviewCard, UrlPreviewHolder } from './url-preview';
|
import { UrlPreviewCard, UrlPreviewHolder } from './url-preview';
|
||||||
import { Image, MediaControl, Video } from './media';
|
import { Image, MediaControl, Video } from './media';
|
||||||
import { ImageViewer } from './image-viewer';
|
import { ImageViewer } from './image-viewer';
|
||||||
@@ -70,8 +72,21 @@ type RenderMessageContentProps = {
|
|||||||
linkifyOpts: Opts;
|
linkifyOpts: Opts;
|
||||||
outlineAttachment?: boolean;
|
outlineAttachment?: boolean;
|
||||||
eventId?: string;
|
eventId?: string;
|
||||||
|
/** [Gitea #219] Open the room's shared media lightbox at this event. */
|
||||||
|
onOpenImageViewer?: () => void;
|
||||||
|
/** [Gitea #159] The event, for the undecryptable placeholder's reason + retry. */
|
||||||
|
mEvent?: MatrixEvent;
|
||||||
|
/** [Gitea #144] Word diff of the last edit, shown on "(edited)" hover. */
|
||||||
|
editDiff?: DiffToken[];
|
||||||
};
|
};
|
||||||
export function RenderMessageContent({
|
export function RenderMessageContent({ editDiff, ...props }: RenderMessageContentProps) {
|
||||||
|
return (
|
||||||
|
<EditDiffContext.Provider value={editDiff}>
|
||||||
|
<RenderMessageContentBody {...props} />
|
||||||
|
</EditDiffContext.Provider>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
function RenderMessageContentBody({
|
||||||
displayName,
|
displayName,
|
||||||
msgType,
|
msgType,
|
||||||
ts,
|
ts,
|
||||||
@@ -85,7 +100,9 @@ export function RenderMessageContent({
|
|||||||
linkifyOpts,
|
linkifyOpts,
|
||||||
outlineAttachment,
|
outlineAttachment,
|
||||||
eventId,
|
eventId,
|
||||||
}: RenderMessageContentProps) {
|
onOpenImageViewer,
|
||||||
|
mEvent,
|
||||||
|
}: Omit<RenderMessageContentProps, 'editDiff'>) {
|
||||||
const renderUrlsPreview = (urls: string[]) => {
|
const renderUrlsPreview = (urls: string[]) => {
|
||||||
// Cap previews per message so a link-dump doesn't spawn dozens of preview
|
// Cap previews per message so a link-dump doesn't spawn dozens of preview
|
||||||
// fetches + iframes at once. De-dupe first: a message linking the same URL
|
// fetches + iframes at once. De-dupe first: a message linking the same URL
|
||||||
@@ -241,6 +258,7 @@ export function RenderMessageContent({
|
|||||||
autoPlay={mediaAutoLoad}
|
autoPlay={mediaAutoLoad}
|
||||||
renderImage={(p) => <Image {...p} loading="lazy" />}
|
renderImage={(p) => <Image {...p} loading="lazy" />}
|
||||||
renderViewer={(p) => <ImageViewer {...p} />}
|
renderViewer={(p) => <ImageViewer {...p} />}
|
||||||
|
onOpenViewer={onOpenImageViewer}
|
||||||
/>
|
/>
|
||||||
)}
|
)}
|
||||||
outlined={outlineAttachment}
|
outlined={outlineAttachment}
|
||||||
@@ -342,7 +360,7 @@ export function RenderMessageContent({
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (msgType === 'm.bad.encrypted') {
|
if (msgType === 'm.bad.encrypted') {
|
||||||
return <MBadEncrypted />;
|
return <MBadEncrypted mEvent={mEvent} />;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (msgType === 'm.key.verification.request') {
|
if (msgType === 'm.key.verification.request') {
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
import { useTauriCallPower } from '../hooks/useTauriCallPower';
|
import { useTauriCallPower } from '../hooks/useTauriCallPower';
|
||||||
import { useTauriJumpList } from '../hooks/useTauriJumpList';
|
import { useTauriJumpList } from '../hooks/useTauriJumpList';
|
||||||
import { useTauriThumbbar } from '../hooks/useTauriThumbbar';
|
import { useTauriThumbbar } from '../hooks/useTauriThumbbar';
|
||||||
|
import { useTauriTaskbarProgress } from '../hooks/useTauriTaskbarProgress';
|
||||||
import { useTauriSmtc } from '../hooks/useTauriSmtc';
|
import { useTauriSmtc } from '../hooks/useTauriSmtc';
|
||||||
import { useTauriNetwork } from '../hooks/useTauriNetwork';
|
import { useTauriNetwork } from '../hooks/useTauriNetwork';
|
||||||
import { useTauriToastActions } from '../hooks/useTauriToastActions';
|
import { useTauriToastActions } from '../hooks/useTauriToastActions';
|
||||||
@@ -18,6 +19,7 @@ export function TauriDesktopFeatures(): null {
|
|||||||
useTauriCallPower(); // P5-46 no-sleep during calls
|
useTauriCallPower(); // P5-46 no-sleep during calls
|
||||||
useTauriJumpList(); // P5-36 Windows jump list of recent rooms
|
useTauriJumpList(); // P5-36 Windows jump list of recent rooms
|
||||||
useTauriThumbbar(); // P5-44 taskbar thumbnail toolbar (mute/deafen/end)
|
useTauriThumbbar(); // P5-44 taskbar thumbnail toolbar (mute/deafen/end)
|
||||||
|
useTauriTaskbarProgress(); // cinny-desktop #10 upload progress on the taskbar button
|
||||||
useTauriSmtc(); // P5-43 system media transport controls
|
useTauriSmtc(); // P5-43 system media transport controls
|
||||||
useTauriNetwork(); // P5-49 network-change awareness → sync retry
|
useTauriNetwork(); // P5-49 network-change awareness → sync retry
|
||||||
useTauriToastActions(); // P5-41/35 rich toast click → open room, quick reply → send
|
useTauriToastActions(); // P5-41/35 rich toast click → open room, quick reply → send
|
||||||
|
|||||||
@@ -71,7 +71,15 @@ function UserRoomProfileContextMenu({ state }: { state: UserRoomProfileState })
|
|||||||
<Overlay open backdrop={<OverlayBackdrop />}>
|
<Overlay open backdrop={<OverlayBackdrop />}>
|
||||||
<OverlayCenter>
|
<OverlayCenter>
|
||||||
<FocusTrap focusTrapOptions={focusTrapOptions}>
|
<FocusTrap focusTrapOptions={focusTrapOptions}>
|
||||||
<Modal size="500" style={MOBILE_FULLSCREEN}>
|
<Modal
|
||||||
|
id="user-profile-dialog"
|
||||||
|
role="dialog"
|
||||||
|
aria-modal="true"
|
||||||
|
aria-label="User profile"
|
||||||
|
tabIndex={-1}
|
||||||
|
size="500"
|
||||||
|
style={MOBILE_FULLSCREEN}
|
||||||
|
>
|
||||||
{/* Full-screen covers the backdrop (no tap-to-dismiss) and the
|
{/* Full-screen covers the backdrop (no tap-to-dismiss) and the
|
||||||
profile has no self-close, so provide an explicit close. */}
|
profile has no self-close, so provide an explicit close. */}
|
||||||
<Header size="600" style={{ flexShrink: 0, paddingRight: config.space.S200 }}>
|
<Header size="600" style={{ flexShrink: 0, paddingRight: config.space.S200 }}>
|
||||||
|
|||||||
@@ -383,7 +383,7 @@ export function VoiceMessageRecorder({ onSend, onError }: VoiceRecorderProps) {
|
|||||||
audio.pause();
|
audio.pause();
|
||||||
setPreviewPlaying(false);
|
setPreviewPlaying(false);
|
||||||
} else {
|
} else {
|
||||||
audio.play();
|
audio.play().catch(() => setPreviewPlaying(false));
|
||||||
setPreviewPlaying(true);
|
setPreviewPlaying(true);
|
||||||
}
|
}
|
||||||
}}
|
}}
|
||||||
|
|||||||
@@ -0,0 +1,100 @@
|
|||||||
|
import React, { ReactNode, useCallback, useRef, useState } from 'react';
|
||||||
|
import FocusTrap from 'focus-trap-react';
|
||||||
|
import { Box, Overlay, OverlayBackdrop, config, color, toRem } from 'folds';
|
||||||
|
import { stopPropagation } from '../../utils/keyboard';
|
||||||
|
|
||||||
|
type ActionSheetProps = {
|
||||||
|
open: boolean;
|
||||||
|
onClose: () => void;
|
||||||
|
'aria-label'?: string;
|
||||||
|
children: ReactNode;
|
||||||
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* [Gitea #166] A bottom sheet for touch screens: slides up from the bottom,
|
||||||
|
* swipe-down or backdrop tap dismisses. Content is whatever the caller
|
||||||
|
* renders (quick reactions + a folds Menu, for message actions).
|
||||||
|
*/
|
||||||
|
export function ActionSheet({
|
||||||
|
open,
|
||||||
|
onClose,
|
||||||
|
children,
|
||||||
|
'aria-label': ariaLabel,
|
||||||
|
}: ActionSheetProps) {
|
||||||
|
const [dragY, setDragY] = useState(0);
|
||||||
|
const startY = useRef<number | null>(null);
|
||||||
|
// The long-press that opened us ends with a touchend/click that lands
|
||||||
|
// "outside" the sheet — ignore outside clicks for the first moments.
|
||||||
|
const openedAt = useRef(Date.now());
|
||||||
|
|
||||||
|
const onTouchStart = useCallback((evt: React.TouchEvent) => {
|
||||||
|
startY.current = evt.touches[0]?.clientY ?? null;
|
||||||
|
}, []);
|
||||||
|
const onTouchMove = useCallback((evt: React.TouchEvent) => {
|
||||||
|
if (startY.current === null) return;
|
||||||
|
const dy = (evt.touches[0]?.clientY ?? startY.current) - startY.current;
|
||||||
|
setDragY(Math.max(0, dy));
|
||||||
|
}, []);
|
||||||
|
const onTouchEnd = useCallback(() => {
|
||||||
|
const dismiss = dragY > 80;
|
||||||
|
startY.current = null;
|
||||||
|
setDragY(0);
|
||||||
|
if (dismiss) onClose();
|
||||||
|
}, [dragY, onClose]);
|
||||||
|
|
||||||
|
if (!open) return null;
|
||||||
|
return (
|
||||||
|
<Overlay open backdrop={<OverlayBackdrop />}>
|
||||||
|
<FocusTrap
|
||||||
|
focusTrapOptions={{
|
||||||
|
initialFocus: false,
|
||||||
|
onDeactivate: onClose,
|
||||||
|
clickOutsideDeactivates: () => Date.now() - openedAt.current > 600,
|
||||||
|
escapeDeactivates: stopPropagation,
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
<Box
|
||||||
|
role="dialog"
|
||||||
|
aria-modal
|
||||||
|
aria-label={ariaLabel}
|
||||||
|
direction="Column"
|
||||||
|
style={{
|
||||||
|
position: 'fixed',
|
||||||
|
left: 0,
|
||||||
|
right: 0,
|
||||||
|
bottom: 0,
|
||||||
|
maxHeight: '75vh',
|
||||||
|
background: color.Surface.Container,
|
||||||
|
color: color.Surface.OnContainer,
|
||||||
|
borderTopLeftRadius: toRem(16),
|
||||||
|
borderTopRightRadius: toRem(16),
|
||||||
|
boxShadow: '0 -8px 32px rgba(0,0,0,0.35)',
|
||||||
|
paddingBottom: 'env(safe-area-inset-bottom)',
|
||||||
|
transform: dragY ? `translateY(${dragY}px)` : undefined,
|
||||||
|
transition: dragY ? undefined : 'transform 120ms ease-out',
|
||||||
|
overflow: 'hidden',
|
||||||
|
}}
|
||||||
|
onTouchStart={onTouchStart}
|
||||||
|
onTouchMove={onTouchMove}
|
||||||
|
onTouchEnd={onTouchEnd}
|
||||||
|
onTouchCancel={onTouchEnd}
|
||||||
|
>
|
||||||
|
<Box justifyContent="Center" shrink="No" style={{ padding: config.space.S200 }}>
|
||||||
|
<div
|
||||||
|
aria-hidden
|
||||||
|
style={{
|
||||||
|
width: toRem(36),
|
||||||
|
height: toRem(4),
|
||||||
|
borderRadius: toRem(2),
|
||||||
|
background: color.Surface.ContainerLine,
|
||||||
|
}}
|
||||||
|
/>
|
||||||
|
</Box>
|
||||||
|
<Box direction="Column" style={{ overflowY: 'auto' }}>
|
||||||
|
{children}
|
||||||
|
</Box>
|
||||||
|
</Box>
|
||||||
|
</FocusTrap>
|
||||||
|
</Overlay>
|
||||||
|
);
|
||||||
|
}
|
||||||
@@ -0,0 +1 @@
|
|||||||
|
export * from './ActionSheet';
|
||||||
@@ -67,7 +67,9 @@ export const EditorTextarea = style([
|
|||||||
export const EditorPlaceholderContainer = style([
|
export const EditorPlaceholderContainer = style([
|
||||||
DefaultReset,
|
DefaultReset,
|
||||||
{
|
{
|
||||||
opacity: config.opacity.Placeholder,
|
// [Gitea #222] folds' Placeholder opacity (0.5) lands at ~2.3:1 on the
|
||||||
|
// composer surface; P300 keeps it visibly secondary at AA contrast.
|
||||||
|
opacity: config.opacity.P300,
|
||||||
pointerEvents: 'none',
|
pointerEvents: 'none',
|
||||||
userSelect: 'none',
|
userSelect: 'none',
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -23,7 +23,13 @@ import { CustomElement } from './slate';
|
|||||||
import * as css from './Editor.css';
|
import * as css from './Editor.css';
|
||||||
import { toggleKeyboardShortcut } from './keyboard';
|
import { toggleKeyboardShortcut } from './keyboard';
|
||||||
|
|
||||||
const initialValue: CustomElement[] = [
|
// One FRESH value per editor instance. slate-react keys its node→path weak
|
||||||
|
// maps by node object identity, so a module-level constant shared by every
|
||||||
|
// <Slate> (main composer + thread composer + message editor) makes the second
|
||||||
|
// mount hijack the first editor's nodes and the first editor throws "Unable to
|
||||||
|
// find the path for Slate node" on its next render — the app-wide crash when
|
||||||
|
// opening a thread on a pristine composer (Gitea #165 / #184).
|
||||||
|
const createInitialValue = (): CustomElement[] => [
|
||||||
{
|
{
|
||||||
type: BlockType.Paragraph,
|
type: BlockType.Paragraph,
|
||||||
children: [{ text: '' }],
|
children: [{ text: '' }],
|
||||||
@@ -92,6 +98,7 @@ export const CustomEditor = forwardRef<HTMLDivElement, CustomEditorProps>(
|
|||||||
},
|
},
|
||||||
ref,
|
ref,
|
||||||
) => {
|
) => {
|
||||||
|
const [initialValue] = useState(createInitialValue);
|
||||||
const renderElement = useCallback(
|
const renderElement = useCallback(
|
||||||
(props: RenderElementProps) => <RenderElement {...props} />,
|
(props: RenderElementProps) => <RenderElement {...props} />,
|
||||||
[],
|
[],
|
||||||
|
|||||||
@@ -12,6 +12,7 @@ import { AutocompleteMenu } from './AutocompleteMenu';
|
|||||||
import { getMxIdServer, isRoomAlias } from '../../../utils/matrix';
|
import { getMxIdServer, isRoomAlias } from '../../../utils/matrix';
|
||||||
import { UseAsyncSearchOptions, useAsyncSearch } from '../../../hooks/useAsyncSearch';
|
import { UseAsyncSearchOptions, useAsyncSearch } from '../../../hooks/useAsyncSearch';
|
||||||
import { onTabPress } from '../../../utils/keyboard';
|
import { onTabPress } from '../../../utils/keyboard';
|
||||||
|
import { useAutocompleteEnter } from '../../../hooks/useAutocompleteEnter';
|
||||||
import { useKeyDown } from '../../../hooks/useKeyDown';
|
import { useKeyDown } from '../../../hooks/useKeyDown';
|
||||||
import { mDirectAtom } from '../../../state/mDirectList';
|
import { mDirectAtom } from '../../../state/mDirectList';
|
||||||
import { allRoomsAtom } from '../../../state/room-list/roomList';
|
import { allRoomsAtom } from '../../../state/room-list/roomList';
|
||||||
@@ -126,19 +127,21 @@ export function RoomMentionAutocomplete({
|
|||||||
requestClose();
|
requestClose();
|
||||||
};
|
};
|
||||||
|
|
||||||
useKeyDown(window, (evt: KeyboardEvent) => {
|
const pickTop = () => {
|
||||||
onTabPress(evt, () => {
|
if (autoCompleteRoomIds.length === 0) {
|
||||||
if (autoCompleteRoomIds.length === 0) {
|
const alias = roomAliasFromQueryText(mx, query.text);
|
||||||
const alias = roomAliasFromQueryText(mx, query.text);
|
handleAutocomplete(alias, alias);
|
||||||
handleAutocomplete(alias, alias);
|
return;
|
||||||
return;
|
}
|
||||||
}
|
const rId = autoCompleteRoomIds[0];
|
||||||
const rId = autoCompleteRoomIds[0];
|
const r = mx.getRoom(rId);
|
||||||
const r = mx.getRoom(rId);
|
const name = r?.name ?? rId;
|
||||||
const name = r?.name ?? rId;
|
handleAutocomplete(r?.getCanonicalAlias() ?? rId, name);
|
||||||
handleAutocomplete(r?.getCanonicalAlias() ?? rId, name);
|
};
|
||||||
});
|
|
||||||
});
|
useKeyDown(window, (evt: KeyboardEvent) => onTabPress(evt, pickTop));
|
||||||
|
// Same rule as people: a fully typed #alias:server sends as typed.
|
||||||
|
useAutocompleteEnter(!query.text.includes(':'), pickTop);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<AutocompleteMenu headerContent={<Text size="L400">Rooms</Text>} requestClose={requestClose}>
|
<AutocompleteMenu headerContent={<Text size="L400">Rooms</Text>} requestClose={requestClose}>
|
||||||
|
|||||||
@@ -13,6 +13,7 @@ import {
|
|||||||
useAsyncSearch,
|
useAsyncSearch,
|
||||||
} from '../../../hooks/useAsyncSearch';
|
} from '../../../hooks/useAsyncSearch';
|
||||||
import { onTabPress } from '../../../utils/keyboard';
|
import { onTabPress } from '../../../utils/keyboard';
|
||||||
|
import { useAutocompleteEnter } from '../../../hooks/useAutocompleteEnter';
|
||||||
import { createMentionElement, moveCursor, replaceWithElement } from '../utils';
|
import { createMentionElement, moveCursor, replaceWithElement } from '../utils';
|
||||||
import { useKeyDown } from '../../../hooks/useKeyDown';
|
import { useKeyDown } from '../../../hooks/useKeyDown';
|
||||||
import { getMxIdLocalPart, getMxIdServer, isUserId } from '../../../utils/matrix';
|
import { getMxIdLocalPart, getMxIdServer, isUserId } from '../../../utils/matrix';
|
||||||
@@ -124,21 +125,24 @@ export function UserMentionAutocomplete({
|
|||||||
requestClose();
|
requestClose();
|
||||||
};
|
};
|
||||||
|
|
||||||
useKeyDown(window, (evt: KeyboardEvent) => {
|
const pickTop = () => {
|
||||||
onTabPress(evt, () => {
|
if (query.text === 'room') {
|
||||||
if (query.text === 'room') {
|
handleAutocomplete(roomAliasOrId, '@room');
|
||||||
handleAutocomplete(roomAliasOrId, '@room');
|
return;
|
||||||
return;
|
}
|
||||||
}
|
if (autoCompleteMembers.length === 0) {
|
||||||
if (autoCompleteMembers.length === 0) {
|
const userId = userIdFromQueryText(mx, query.text);
|
||||||
const userId = userIdFromQueryText(mx, query.text);
|
handleAutocomplete(userId, userId);
|
||||||
handleAutocomplete(userId, userId);
|
return;
|
||||||
return;
|
}
|
||||||
}
|
const roomMember = autoCompleteMembers[0];
|
||||||
const roomMember = autoCompleteMembers[0];
|
handleAutocomplete(roomMember.userId, getMemberName(room, roomMember.userId));
|
||||||
handleAutocomplete(roomMember.userId, roomMember.name);
|
};
|
||||||
});
|
|
||||||
});
|
useKeyDown(window, (evt: KeyboardEvent) => onTabPress(evt, pickTop));
|
||||||
|
// Enter picks while a partial name is being typed ("hey @bo"). Once a full
|
||||||
|
// user ID has been typed ("/kick @alice:server"), Enter sends as typed.
|
||||||
|
useAutocompleteEnter(!query.text.includes(':'), pickTop);
|
||||||
|
|
||||||
const getName = (member: RoomMember) => getMemberName(room, member.userId);
|
const getName = (member: RoomMember) => getMemberName(room, member.userId);
|
||||||
|
|
||||||
|
|||||||
@@ -65,3 +65,46 @@ test('no math conversion inside a code block', () => {
|
|||||||
test('a message with no math is unchanged', () => {
|
test('a message with no math is unchanged', () => {
|
||||||
assert.equal(toMatrixCustomHTML(txt('just hello'), OPTS), 'just hello');
|
assert.equal(toMatrixCustomHTML(txt('just hello'), OPTS), 'just hello');
|
||||||
});
|
});
|
||||||
|
|
||||||
|
// Gitea #184 O3 — markdown mode: fences and backtick spans typed as plain
|
||||||
|
// paragraphs are literal too (the block markdown parser only sees the fence
|
||||||
|
// after the lines are joined, so math must be skipped while serialising them).
|
||||||
|
const MD_OPTS = { ...OPTS, allowInlineMarkdown: true, allowBlockMarkdown: true };
|
||||||
|
|
||||||
|
test('markdown: no math conversion inside a typed ``` fence', () => {
|
||||||
|
const paragraphs = [
|
||||||
|
el(BlockType.Paragraph, [txt('```')]),
|
||||||
|
el(BlockType.Paragraph, [txt('$x$ literal')]),
|
||||||
|
el(BlockType.Paragraph, [txt('```')]),
|
||||||
|
el(BlockType.Paragraph, [txt('after $y$')]),
|
||||||
|
];
|
||||||
|
const out = toMatrixCustomHTML(paragraphs, MD_OPTS);
|
||||||
|
assert.ok(out.includes('<pre'), 'fence became a code block');
|
||||||
|
assert.ok(out.includes('$x$ literal'), 'code block content stays literal');
|
||||||
|
assert.ok(out.includes('data-mx-maths="y"'), 'math after the fence still converts');
|
||||||
|
});
|
||||||
|
|
||||||
|
test('markdown: no math conversion inside a backtick span, math outside still converts', () => {
|
||||||
|
const out = toMatrixCustomHTML(el(BlockType.Paragraph, [txt('use `$x$` and $y$')]), MD_OPTS);
|
||||||
|
assert.ok(/<code[^>]*>\$x\$<\/code>/.test(out), 'backtick span stays literal');
|
||||||
|
assert.ok(out.includes('data-mx-maths="y"'));
|
||||||
|
});
|
||||||
|
|
||||||
|
test('[#107] a code block language becomes class="language-…"', () => {
|
||||||
|
const block = {
|
||||||
|
...(el(BlockType.CodeBlock, [el(BlockType.CodeLine, [txt('let a = 1;')])]) as object),
|
||||||
|
lang: 'js',
|
||||||
|
} as unknown as Descendant;
|
||||||
|
assert.equal(
|
||||||
|
toMatrixCustomHTML(block, OPTS),
|
||||||
|
'<pre><code class="language-js">let a = 1;\n</code></pre>',
|
||||||
|
);
|
||||||
|
});
|
||||||
|
|
||||||
|
test('[#107] an unsafe language value is dropped', () => {
|
||||||
|
const block = {
|
||||||
|
...(el(BlockType.CodeBlock, [el(BlockType.CodeLine, [txt('x')])]) as object),
|
||||||
|
lang: 'js" onclick="x',
|
||||||
|
} as unknown as Descendant;
|
||||||
|
assert.equal(toMatrixCustomHTML(block, OPTS), '<pre><code>x\n</code></pre>');
|
||||||
|
});
|
||||||
|
|||||||
@@ -36,6 +36,18 @@ const textToCustomHtml = (node: Text, opts: OutputOptions): string => {
|
|||||||
// applied inside inline code. Non-math text recurses with allowMath off so it
|
// applied inside inline code. Non-math text recurses with allowMath off so it
|
||||||
// still gets the normal marks + inline-markdown treatment.
|
// still gets the normal marks + inline-markdown treatment.
|
||||||
if (opts.allowMath && !node.code) {
|
if (opts.allowMath && !node.code) {
|
||||||
|
// Markdown inline code spans (`…`) are literal too: apply math only to the
|
||||||
|
// text between them (Gitea #184 O3 — `$x$` inside backticks stayed math).
|
||||||
|
if (opts.allowInlineMarkdown && /`[^`]*`/.test(node.text)) {
|
||||||
|
return node.text
|
||||||
|
.split(/(`+[^`]*`+)/)
|
||||||
|
.map((part) =>
|
||||||
|
part.startsWith('`')
|
||||||
|
? textToCustomHtml({ ...node, text: part }, { ...opts, allowMath: false })
|
||||||
|
: textToCustomHtml({ ...node, text: part }, opts),
|
||||||
|
)
|
||||||
|
.join('');
|
||||||
|
}
|
||||||
const segments = splitMathSegments(node.text);
|
const segments = splitMathSegments(node.text);
|
||||||
if (segments.some((seg) => seg.type !== 'text')) {
|
if (segments.some((seg) => seg.type !== 'text')) {
|
||||||
return segments
|
return segments
|
||||||
@@ -74,7 +86,10 @@ const elementToCustomHtml = (node: CustomElement, children: string): string => {
|
|||||||
case BlockType.CodeLine:
|
case BlockType.CodeLine:
|
||||||
return `${children}\n`;
|
return `${children}\n`;
|
||||||
case BlockType.CodeBlock:
|
case BlockType.CodeBlock:
|
||||||
return `<pre><code>${children}</code></pre>`;
|
// [Gitea #107] Only a plain identifier is ever put in the class.
|
||||||
|
return node.lang && /^[a-z0-9+#-]{1,20}$/.test(node.lang)
|
||||||
|
? `<pre><code class="language-${node.lang}">${children}</code></pre>`
|
||||||
|
: `<pre><code>${children}</code></pre>`;
|
||||||
case BlockType.QuoteLine:
|
case BlockType.QuoteLine:
|
||||||
return `${children}<br/>`;
|
return `${children}<br/>`;
|
||||||
case BlockType.BlockQuote:
|
case BlockType.BlockQuote:
|
||||||
@@ -128,12 +143,20 @@ export const toMatrixCustomHTML = (
|
|||||||
opts: OutputOptions,
|
opts: OutputOptions,
|
||||||
): string => {
|
): string => {
|
||||||
let markdownLines = '';
|
let markdownLines = '';
|
||||||
|
// Inside a markdown ``` fence every line is literal: no `$…$` math conversion
|
||||||
|
// (the fence is only recognised by parseBlockMD after the lines are joined,
|
||||||
|
// which is too late — Gitea #184 O3).
|
||||||
|
let inFence = false;
|
||||||
const parseNode = (n: Descendant, index: number, targetNodes: Descendant[]) => {
|
const parseNode = (n: Descendant, index: number, targetNodes: Descendant[]) => {
|
||||||
if (opts.allowBlockMarkdown && 'type' in n && n.type === BlockType.Paragraph) {
|
if (opts.allowBlockMarkdown && 'type' in n && n.type === BlockType.Paragraph) {
|
||||||
|
const isFenceLine = /^\s*```/.test(toPlainText(n, false));
|
||||||
|
const literal = inFence || isFenceLine;
|
||||||
|
if (isFenceLine) inFence = !inFence;
|
||||||
const line = toMatrixCustomHTML(n, {
|
const line = toMatrixCustomHTML(n, {
|
||||||
...opts,
|
...opts,
|
||||||
allowInlineMarkdown: false,
|
allowInlineMarkdown: false,
|
||||||
allowBlockMarkdown: false,
|
allowBlockMarkdown: false,
|
||||||
|
allowMath: opts.allowMath && !literal,
|
||||||
})
|
})
|
||||||
.replace(/<br\/>$/, '\n')
|
.replace(/<br\/>$/, '\n')
|
||||||
.replace(/^(\\*)>/, '$1>');
|
.replace(/^(\\*)>/, '$1>');
|
||||||
|
|||||||
Vendored
+2
@@ -64,6 +64,8 @@ export type CodeLineElement = {
|
|||||||
};
|
};
|
||||||
export type CodeBlockElement = {
|
export type CodeBlockElement = {
|
||||||
type: BlockType.CodeBlock;
|
type: BlockType.CodeBlock;
|
||||||
|
/** [Gitea #107] Optional language → `<code class="language-…">`. */
|
||||||
|
lang?: string;
|
||||||
children: CodeLineElement[];
|
children: CodeLineElement[];
|
||||||
};
|
};
|
||||||
export type QuoteLineElement = {
|
export type QuoteLineElement = {
|
||||||
|
|||||||
@@ -31,6 +31,8 @@ import { useThrottle } from '../../hooks/useThrottle';
|
|||||||
import { addRecentEmoji } from '../../plugins/recent-emoji';
|
import { addRecentEmoji } from '../../plugins/recent-emoji';
|
||||||
import { addRecentSticker, recentStickersAtom } from '../../state/recentStickers';
|
import { addRecentSticker, recentStickersAtom } from '../../state/recentStickers';
|
||||||
import { useMediaAuthentication } from '../../hooks/useMediaAuthentication';
|
import { useMediaAuthentication } from '../../hooks/useMediaAuthentication';
|
||||||
|
import { useRecentTouch } from '../../hooks/useRecentTouch';
|
||||||
|
import { TapToSendBar } from '../tap-to-send/TapToSendBar';
|
||||||
import { ImagePack, ImageUsage, PackImageReader } from '../../plugins/custom-emoji';
|
import { ImagePack, ImageUsage, PackImageReader } from '../../plugins/custom-emoji';
|
||||||
import { getEmoticonSearchStr } from '../../plugins/utils';
|
import { getEmoticonSearchStr } from '../../plugins/utils';
|
||||||
import {
|
import {
|
||||||
@@ -52,7 +54,7 @@ import {
|
|||||||
EmojiGroup,
|
EmojiGroup,
|
||||||
EmojiBoardLayout,
|
EmojiBoardLayout,
|
||||||
} from './components';
|
} from './components';
|
||||||
import { EmojiBoardTab, EmojiType } from './types';
|
import { EmojiBoardTab, EmojiItemInfo, EmojiType } from './types';
|
||||||
import { VirtualTile } from '../virtualizer';
|
import { VirtualTile } from '../virtualizer';
|
||||||
|
|
||||||
const RECENT_GROUP_ID = 'recent_group';
|
const RECENT_GROUP_ID = 'recent_group';
|
||||||
@@ -518,10 +520,27 @@ export function EmojiBoard({
|
|||||||
});
|
});
|
||||||
const vItems = virtualizer.getVirtualItems();
|
const vItems = virtualizer.getVirtualItems();
|
||||||
|
|
||||||
|
// [Gitea #147] Touch: first tap on a sticker parks it in a preview bar,
|
||||||
|
// second tap (or the bar's Send) sends. Mouse/keyboard/screen reader: one step.
|
||||||
|
const { wasTouch } = useRecentTouch(contentScrollRef);
|
||||||
|
const [pendingSticker, setPendingSticker] = useState<EmojiItemInfo | undefined>();
|
||||||
|
const stickerUseAuthentication = useMediaAuthentication();
|
||||||
|
const sendSticker = (info: EmojiItemInfo, close: boolean) => {
|
||||||
|
onStickerSelect?.(info.data, info.shortcode, info.label);
|
||||||
|
setRecentStickers((prev) =>
|
||||||
|
addRecentSticker(prev, { url: info.data, shortcode: info.shortcode, body: info.label }),
|
||||||
|
);
|
||||||
|
setPendingSticker(undefined);
|
||||||
|
if (close) requestClose();
|
||||||
|
};
|
||||||
|
|
||||||
const handleGroupItemClick: MouseEventHandler = (evt) => {
|
const handleGroupItemClick: MouseEventHandler = (evt) => {
|
||||||
const targetEl = targetFromEvent(evt.nativeEvent, 'button');
|
const targetEl = targetFromEvent(evt.nativeEvent, 'button');
|
||||||
const emojiInfo = targetEl && getEmojiItemInfo(targetEl);
|
const emojiInfo = targetEl && getEmojiItemInfo(targetEl);
|
||||||
if (!emojiInfo) return;
|
if (!emojiInfo) {
|
||||||
|
if (pendingSticker) setPendingSticker(undefined);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
if (emojiInfo.type === EmojiType.Emoji) {
|
if (emojiInfo.type === EmojiType.Emoji) {
|
||||||
onEmojiSelect?.(emojiInfo.data, emojiInfo.shortcode);
|
onEmojiSelect?.(emojiInfo.data, emojiInfo.shortcode);
|
||||||
@@ -533,14 +552,12 @@ export function EmojiBoard({
|
|||||||
onCustomEmojiSelect?.(emojiInfo.data, emojiInfo.shortcode);
|
onCustomEmojiSelect?.(emojiInfo.data, emojiInfo.shortcode);
|
||||||
}
|
}
|
||||||
if (emojiInfo.type === EmojiType.Sticker) {
|
if (emojiInfo.type === EmojiType.Sticker) {
|
||||||
onStickerSelect?.(emojiInfo.data, emojiInfo.shortcode, emojiInfo.label);
|
if (wasTouch() && pendingSticker?.data !== emojiInfo.data) {
|
||||||
setRecentStickers((prev) =>
|
setPendingSticker(emojiInfo);
|
||||||
addRecentSticker(prev, {
|
return;
|
||||||
url: emojiInfo.data,
|
}
|
||||||
shortcode: emojiInfo.shortcode,
|
sendSticker(emojiInfo, !evt.altKey && !evt.shiftKey);
|
||||||
body: emojiInfo.label,
|
return;
|
||||||
}),
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
if (!evt.altKey && !evt.shiftKey) requestClose();
|
if (!evt.altKey && !evt.shiftKey) requestClose();
|
||||||
};
|
};
|
||||||
@@ -670,7 +687,18 @@ export function EmojiBoard({
|
|||||||
{tab === EmojiBoardTab.Sticker && groups.length === 0 && <NoStickerPacks />}
|
{tab === EmojiBoardTab.Sticker && groups.length === 0 && <NoStickerPacks />}
|
||||||
</EmojiGroupHolder>
|
</EmojiGroupHolder>
|
||||||
</Box>
|
</Box>
|
||||||
<Preview previewAtom={previewAtom} />
|
{pendingSticker && tab === EmojiBoardTab.Sticker ? (
|
||||||
|
<TapToSendBar
|
||||||
|
previewUrl={
|
||||||
|
mxcUrlToHttp(mx, pendingSticker.data, stickerUseAuthentication) ?? undefined
|
||||||
|
}
|
||||||
|
label={pendingSticker.label}
|
||||||
|
onSend={() => sendSticker(pendingSticker, true)}
|
||||||
|
onCancel={() => setPendingSticker(undefined)}
|
||||||
|
/>
|
||||||
|
) : (
|
||||||
|
<Preview previewAtom={previewAtom} />
|
||||||
|
)}
|
||||||
</EmojiBoardLayout>
|
</EmojiBoardLayout>
|
||||||
</FocusTrap>
|
</FocusTrap>
|
||||||
);
|
);
|
||||||
|
|||||||
@@ -24,32 +24,19 @@ import { useSpaceOptionally } from '../../hooks/useSpace';
|
|||||||
import { getMouseEventCords } from '../../utils/dom';
|
import { getMouseEventCords } from '../../utils/dom';
|
||||||
import { useSetting } from '../../state/hooks/settings';
|
import { useSetting } from '../../state/hooks/settings';
|
||||||
import { settingsAtom } from '../../state/settings';
|
import { settingsAtom } from '../../state/settings';
|
||||||
import { today, yesterday, timeHourMinute, timeMon, timeDay, timeYear } from '../../utils/time';
|
import { TimestampPrefs, formatTimestamp } from '../../utils/formatTimestamp';
|
||||||
|
import { useTimestampFormatter } from '../../hooks/useTimestampFormatter';
|
||||||
|
|
||||||
function formatReadTs(ts: number, hour24Clock: boolean): string {
|
const formatReadTs = (ts: number, prefs: TimestampPrefs): string => formatTimestamp(ts, prefs);
|
||||||
const timeStr = timeHourMinute(ts, hour24Clock);
|
|
||||||
if (today(ts)) return `Today at ${timeStr}`;
|
|
||||||
if (yesterday(ts)) return `Yesterday at ${timeStr}`;
|
|
||||||
const sameYear = timeYear(ts) === timeYear(Date.now());
|
|
||||||
return sameYear
|
|
||||||
? `${timeMon(ts)} ${timeDay(ts)} at ${timeStr}`
|
|
||||||
: `${timeMon(ts)} ${timeDay(ts)} ${timeYear(ts)} at ${timeStr}`;
|
|
||||||
}
|
|
||||||
|
|
||||||
type EventReaderItemProps = {
|
type EventReaderItemProps = {
|
||||||
room: Room;
|
room: Room;
|
||||||
readerId: string;
|
readerId: string;
|
||||||
hour24Clock: boolean;
|
prefs: TimestampPrefs;
|
||||||
lotusTerminal: boolean;
|
lotusTerminal: boolean;
|
||||||
onSelect: React.MouseEventHandler<HTMLButtonElement>;
|
onSelect: React.MouseEventHandler<HTMLButtonElement>;
|
||||||
};
|
};
|
||||||
function EventReaderItem({
|
function EventReaderItem({ room, readerId, prefs, lotusTerminal, onSelect }: EventReaderItemProps) {
|
||||||
room,
|
|
||||||
readerId,
|
|
||||||
hour24Clock,
|
|
||||||
lotusTerminal,
|
|
||||||
onSelect,
|
|
||||||
}: EventReaderItemProps) {
|
|
||||||
const { name, avatarUrl } = useMemberAvatar(room, readerId, 100, 100);
|
const { name, avatarUrl } = useMemberAvatar(room, readerId, 100, 100);
|
||||||
const receiptTs = room.getReadReceiptForUserId(readerId)?.data.ts;
|
const receiptTs = room.getReadReceiptForUserId(readerId)?.data.ts;
|
||||||
|
|
||||||
@@ -86,7 +73,7 @@ function EventReaderItem({
|
|||||||
: undefined
|
: undefined
|
||||||
}
|
}
|
||||||
>
|
>
|
||||||
{formatReadTs(receiptTs, hour24Clock)}
|
{formatReadTs(receiptTs, prefs)}
|
||||||
</Text>
|
</Text>
|
||||||
)}
|
)}
|
||||||
</Box>
|
</Box>
|
||||||
@@ -106,7 +93,7 @@ export const EventReaders = as<'div', EventReadersProps>(
|
|||||||
const latestEventReaders = useRoomEventReaders(room, eventId).filter((id) => id !== myUserId);
|
const latestEventReaders = useRoomEventReaders(room, eventId).filter((id) => id !== myUserId);
|
||||||
const openProfile = useOpenUserRoomProfile();
|
const openProfile = useOpenUserRoomProfile();
|
||||||
const space = useSpaceOptionally();
|
const space = useSpaceOptionally();
|
||||||
const [hour24Clock] = useSetting(settingsAtom, 'hour24Clock');
|
const { prefs } = useTimestampFormatter();
|
||||||
const [lotusTerminal] = useSetting(settingsAtom, 'lotusTerminal');
|
const [lotusTerminal] = useSetting(settingsAtom, 'lotusTerminal');
|
||||||
|
|
||||||
return (
|
return (
|
||||||
@@ -157,7 +144,7 @@ export const EventReaders = as<'div', EventReadersProps>(
|
|||||||
key={readerId}
|
key={readerId}
|
||||||
room={room}
|
room={room}
|
||||||
readerId={readerId}
|
readerId={readerId}
|
||||||
hour24Clock={hour24Clock}
|
prefs={prefs}
|
||||||
lotusTerminal={lotusTerminal}
|
lotusTerminal={lotusTerminal}
|
||||||
onSelect={(event) => {
|
onSelect={(event) => {
|
||||||
openProfile(
|
openProfile(
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
import React from 'react';
|
import React, { useEffect, useRef } from 'react';
|
||||||
import { useTranslation } from 'react-i18next';
|
import { useTranslation } from 'react-i18next';
|
||||||
import classNames from 'classnames';
|
import classNames from 'classnames';
|
||||||
import { Box, Chip, Header, Icon, IconButton, Icons, Text, as } from 'folds';
|
import { Box, Chip, Header, Icon, IconButton, Icons, Text, as } from 'folds';
|
||||||
@@ -27,12 +27,37 @@ export const ImageViewer = as<'div', ImageViewerProps>(
|
|||||||
saveFile(fileContent, alt);
|
saveFile(fileContent, alt);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
// [Gitea #164] Same keyboard model as the gallery lightbox: + / = zoom
|
||||||
|
// in, - zoom out, 0 reset; double-click toggles 1× ↔ 2×. The root takes
|
||||||
|
// focus on open so those keys (and Escape, handled by the modal) work
|
||||||
|
// immediately instead of only after clicking inside the viewer.
|
||||||
|
const rootRef = useRef<HTMLDivElement>(null);
|
||||||
|
useEffect(() => {
|
||||||
|
rootRef.current?.focus({ preventScroll: true });
|
||||||
|
}, []);
|
||||||
|
const handleKeyDown = (evt: React.KeyboardEvent) => {
|
||||||
|
if (evt.key === '+' || evt.key === '=') zoomIn();
|
||||||
|
else if (evt.key === '-') zoomOut();
|
||||||
|
else if (evt.key === '0') setZoom(1);
|
||||||
|
else return;
|
||||||
|
evt.preventDefault();
|
||||||
|
};
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<Box
|
<Box
|
||||||
className={classNames(css.ImageViewer, className)}
|
className={classNames(css.ImageViewer, className)}
|
||||||
direction="Column"
|
direction="Column"
|
||||||
|
role="dialog"
|
||||||
|
aria-modal
|
||||||
|
aria-label={alt || 'Image viewer'}
|
||||||
|
tabIndex={-1}
|
||||||
|
onKeyDown={handleKeyDown}
|
||||||
{...props}
|
{...props}
|
||||||
ref={ref}
|
ref={(node: HTMLDivElement | null) => {
|
||||||
|
rootRef.current = node;
|
||||||
|
if (typeof ref === 'function') ref(node);
|
||||||
|
else if (ref) (ref as React.MutableRefObject<HTMLDivElement | null>).current = node;
|
||||||
|
}}
|
||||||
>
|
>
|
||||||
<Header className={css.ImageViewerHeader} size="400">
|
<Header className={css.ImageViewerHeader} size="400">
|
||||||
<Box grow="Yes" alignItems="Center" gap="200">
|
<Box grow="Yes" alignItems="Center" gap="200">
|
||||||
@@ -116,6 +141,7 @@ export const ImageViewer = as<'div', ImageViewerProps>(
|
|||||||
alt={alt}
|
alt={alt}
|
||||||
onMouseDown={onMouseDown}
|
onMouseDown={onMouseDown}
|
||||||
onTouchStart={onTouchStart}
|
onTouchStart={onTouchStart}
|
||||||
|
onDoubleClick={() => setZoom(zoom === 1 ? 2 : 1)}
|
||||||
/>
|
/>
|
||||||
</Box>
|
</Box>
|
||||||
</Box>
|
</Box>
|
||||||
|
|||||||
@@ -33,6 +33,7 @@ import {
|
|||||||
import { Room } from 'matrix-js-sdk';
|
import { Room } from 'matrix-js-sdk';
|
||||||
import { isKeyHotkey } from 'is-hotkey';
|
import { isKeyHotkey } from 'is-hotkey';
|
||||||
import FocusTrap from 'focus-trap-react';
|
import FocusTrap from 'focus-trap-react';
|
||||||
|
import { QRCodeSVG } from 'qrcode.react';
|
||||||
import { stopPropagation } from '../../utils/keyboard';
|
import { stopPropagation } from '../../utils/keyboard';
|
||||||
import { useDirectUsers } from '../../hooks/useDirectUsers';
|
import { useDirectUsers } from '../../hooks/useDirectUsers';
|
||||||
import {
|
import {
|
||||||
@@ -188,14 +189,21 @@ export function InviteUserPrompt({ room, requestClose }: InviteUserProps) {
|
|||||||
escapeDeactivates: stopPropagation,
|
escapeDeactivates: stopPropagation,
|
||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
<Dialog style={modalStyle}>
|
<Dialog
|
||||||
|
id="inviteuserprompt-dialog-1"
|
||||||
|
role="dialog"
|
||||||
|
aria-modal="true"
|
||||||
|
aria-labelledby="inviteuserprompt-dialog-1-title"
|
||||||
|
tabIndex={-1}
|
||||||
|
style={modalStyle}
|
||||||
|
>
|
||||||
<Box grow="Yes" direction="Column">
|
<Box grow="Yes" direction="Column">
|
||||||
<Header
|
<Header
|
||||||
size="500"
|
size="500"
|
||||||
style={{ padding: `0 ${config.space.S200} 0 ${config.space.S400}` }}
|
style={{ padding: `0 ${config.space.S200} 0 ${config.space.S400}` }}
|
||||||
>
|
>
|
||||||
<Box grow="Yes">
|
<Box grow="Yes">
|
||||||
<Text size="H4" truncate>
|
<Text id="inviteuserprompt-dialog-1-title" size="H4" truncate>
|
||||||
{t('Organisms.InviteUser.invite')}
|
{t('Organisms.InviteUser.invite')}
|
||||||
</Text>
|
</Text>
|
||||||
</Box>
|
</Box>
|
||||||
@@ -237,13 +245,25 @@ export function InviteUserPrompt({ room, requestClose }: InviteUserProps) {
|
|||||||
borderBottom: `1px solid ${color.Surface.ContainerLine}`,
|
borderBottom: `1px solid ${color.Surface.ContainerLine}`,
|
||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
<img
|
{/* Generated locally (qrcode.react) like RoomShareInvite — the
|
||||||
src={`https://api.qrserver.com/v1/create-qr-code/?size=180x180&data=${encodeURIComponent(inviteUrl)}`}
|
old api.qrserver.com <img> leaked the room link to a third
|
||||||
alt="QR code for room invite link"
|
party and is blocked by the prod CSP img-src anyway
|
||||||
width={180}
|
(Gitea #192). White quiet-zone so it scans on any theme. */}
|
||||||
height={180}
|
<Box
|
||||||
style={{ display: 'block', borderRadius: config.radii.R300 }}
|
style={{
|
||||||
/>
|
padding: config.space.S200,
|
||||||
|
background: '#ffffff',
|
||||||
|
borderRadius: config.radii.R300,
|
||||||
|
lineHeight: 0,
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
<QRCodeSVG
|
||||||
|
value={inviteUrl}
|
||||||
|
size={164}
|
||||||
|
level="M"
|
||||||
|
title="QR code for room invite link"
|
||||||
|
/>
|
||||||
|
</Box>
|
||||||
<Text
|
<Text
|
||||||
size="T200"
|
size="T200"
|
||||||
style={{ opacity: 0.6, wordBreak: 'break-all', textAlign: 'center' }}
|
style={{ opacity: 0.6, wordBreak: 'break-all', textAlign: 'center' }}
|
||||||
|
|||||||
@@ -67,13 +67,21 @@ export function JoinAddressPrompt({ onOpen, onCancel }: JoinAddressProps) {
|
|||||||
<OverlayCenter>
|
<OverlayCenter>
|
||||||
<FocusTrap
|
<FocusTrap
|
||||||
focusTrapOptions={{
|
focusTrapOptions={{
|
||||||
initialFocus: false,
|
fallbackFocus: '#joinaddressprompt-dialog-1',
|
||||||
onDeactivate: onCancel,
|
onDeactivate: onCancel,
|
||||||
clickOutsideDeactivates: true,
|
clickOutsideDeactivates: true,
|
||||||
escapeDeactivates: stopPropagation,
|
escapeDeactivates: stopPropagation,
|
||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
<Dialog variant="Surface" style={modalStyle}>
|
<Dialog
|
||||||
|
id="joinaddressprompt-dialog-1"
|
||||||
|
role="dialog"
|
||||||
|
aria-modal="true"
|
||||||
|
aria-labelledby="joinaddressprompt-dialog-1-title"
|
||||||
|
tabIndex={-1}
|
||||||
|
variant="Surface"
|
||||||
|
style={modalStyle}
|
||||||
|
>
|
||||||
<Header
|
<Header
|
||||||
style={{
|
style={{
|
||||||
padding: `0 ${config.space.S200} 0 ${config.space.S400}`,
|
padding: `0 ${config.space.S200} 0 ${config.space.S400}`,
|
||||||
@@ -82,7 +90,7 @@ export function JoinAddressPrompt({ onOpen, onCancel }: JoinAddressProps) {
|
|||||||
size="500"
|
size="500"
|
||||||
>
|
>
|
||||||
<Box grow="Yes">
|
<Box grow="Yes">
|
||||||
<Text as="h2" size="H4">
|
<Text id="joinaddressprompt-dialog-1-title" as="h2" size="H4">
|
||||||
Join with Address
|
Join with Address
|
||||||
</Text>
|
</Text>
|
||||||
</Box>
|
</Box>
|
||||||
|
|||||||
@@ -52,13 +52,21 @@ export function LeaveRoomPrompt({ roomId, onDone, onCancel }: LeaveRoomPromptPro
|
|||||||
<OverlayCenter>
|
<OverlayCenter>
|
||||||
<FocusTrap
|
<FocusTrap
|
||||||
focusTrapOptions={{
|
focusTrapOptions={{
|
||||||
initialFocus: false,
|
fallbackFocus: '#leaveroomprompt-dialog',
|
||||||
onDeactivate: onCancel,
|
onDeactivate: onCancel,
|
||||||
clickOutsideDeactivates: true,
|
clickOutsideDeactivates: true,
|
||||||
escapeDeactivates: stopPropagation,
|
escapeDeactivates: stopPropagation,
|
||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
<Dialog variant="Surface" aria-labelledby="leave-room-dialog-title" style={modalStyle}>
|
<Dialog
|
||||||
|
id="leaveroomprompt-dialog"
|
||||||
|
role="dialog"
|
||||||
|
aria-modal="true"
|
||||||
|
tabIndex={-1}
|
||||||
|
variant="Surface"
|
||||||
|
aria-labelledby="leave-room-dialog-title"
|
||||||
|
style={modalStyle}
|
||||||
|
>
|
||||||
<Header
|
<Header
|
||||||
style={{
|
style={{
|
||||||
padding: `0 ${config.space.S200} 0 ${config.space.S400}`,
|
padding: `0 ${config.space.S200} 0 ${config.space.S400}`,
|
||||||
|
|||||||
@@ -52,13 +52,21 @@ export function LeaveSpacePrompt({ roomId, onDone, onCancel }: LeaveSpacePromptP
|
|||||||
<OverlayCenter>
|
<OverlayCenter>
|
||||||
<FocusTrap
|
<FocusTrap
|
||||||
focusTrapOptions={{
|
focusTrapOptions={{
|
||||||
initialFocus: false,
|
fallbackFocus: '#leavespaceprompt-dialog-1',
|
||||||
onDeactivate: onCancel,
|
onDeactivate: onCancel,
|
||||||
clickOutsideDeactivates: true,
|
clickOutsideDeactivates: true,
|
||||||
escapeDeactivates: stopPropagation,
|
escapeDeactivates: stopPropagation,
|
||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
<Dialog variant="Surface" style={modalStyle}>
|
<Dialog
|
||||||
|
id="leavespaceprompt-dialog-1"
|
||||||
|
role="dialog"
|
||||||
|
aria-modal="true"
|
||||||
|
aria-labelledby="leavespaceprompt-dialog-1-title"
|
||||||
|
tabIndex={-1}
|
||||||
|
variant="Surface"
|
||||||
|
style={modalStyle}
|
||||||
|
>
|
||||||
<Header
|
<Header
|
||||||
style={{
|
style={{
|
||||||
padding: `0 ${config.space.S200} 0 ${config.space.S400}`,
|
padding: `0 ${config.space.S200} 0 ${config.space.S400}`,
|
||||||
@@ -68,7 +76,7 @@ export function LeaveSpacePrompt({ roomId, onDone, onCancel }: LeaveSpacePromptP
|
|||||||
size="500"
|
size="500"
|
||||||
>
|
>
|
||||||
<Box grow="Yes">
|
<Box grow="Yes">
|
||||||
<Text as="h2" size="H4">
|
<Text id="leavespaceprompt-dialog-1-title" as="h2" size="H4">
|
||||||
Leave Space
|
Leave Space
|
||||||
</Text>
|
</Text>
|
||||||
</Box>
|
</Box>
|
||||||
|
|||||||
@@ -0,0 +1,67 @@
|
|||||||
|
import React, { MouseEventHandler } from 'react';
|
||||||
|
import { Box, Icon, Icons, Text, as, toRem } from 'folds';
|
||||||
|
import { MatrixClient } from 'matrix-js-sdk';
|
||||||
|
import classNames from 'classnames';
|
||||||
|
import * as css from './Reply.css';
|
||||||
|
import { ForwardedMeta } from '../../features/room/message/forwardContent';
|
||||||
|
import { getMemberDisplayName } from '../../utils/room';
|
||||||
|
import { getMxIdLocalPart } from '../../utils/matrix';
|
||||||
|
import { formatTimestamp } from '../../utils/formatTimestamp';
|
||||||
|
|
||||||
|
type ForwardedHeaderProps = {
|
||||||
|
mx: MatrixClient;
|
||||||
|
meta: ForwardedMeta;
|
||||||
|
hour24Clock: boolean;
|
||||||
|
dateFormatString: string;
|
||||||
|
/** Present when the viewer can open the original (they are in the source room). */
|
||||||
|
onJump?: MouseEventHandler;
|
||||||
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* "↪ Forwarded · from <sender> in <room> · <time>" — the provenance line above
|
||||||
|
* a forwarded message (Gitea: forwards used to look like the forwarder's own
|
||||||
|
* words). Renders in the same visual slot and style as a reply quote so it
|
||||||
|
* reads as message context, not as content.
|
||||||
|
*/
|
||||||
|
export const ForwardedHeader = as<'div', ForwardedHeaderProps>(
|
||||||
|
({ mx, meta, hour24Clock, dateFormatString, onJump, className, ...props }, ref) => {
|
||||||
|
const sourceRoom = meta.room_id ? mx.getRoom(meta.room_id) : null;
|
||||||
|
const senderName =
|
||||||
|
(sourceRoom && getMemberDisplayName(sourceRoom, meta.sender)) ??
|
||||||
|
mx.getUser(meta.sender)?.displayName ??
|
||||||
|
getMxIdLocalPart(meta.sender) ??
|
||||||
|
meta.sender;
|
||||||
|
const ts = meta.origin_server_ts;
|
||||||
|
const when = formatTimestamp(ts, { hour24Clock, dateFormatString });
|
||||||
|
const canJump = !!sourceRoom && !!onJump;
|
||||||
|
|
||||||
|
return (
|
||||||
|
<Box
|
||||||
|
as={canJump ? 'button' : 'div'}
|
||||||
|
className={classNames(css.Reply, className)}
|
||||||
|
alignItems="Center"
|
||||||
|
gap="100"
|
||||||
|
onClick={canJump ? onJump : undefined}
|
||||||
|
title={canJump ? 'Jump to the original message' : undefined}
|
||||||
|
aria-label={`Forwarded from ${senderName}${sourceRoom ? ` in ${sourceRoom.name}` : ''}, ${when}`}
|
||||||
|
{...props}
|
||||||
|
ref={ref}
|
||||||
|
>
|
||||||
|
<Box alignItems="Center" gap="100" shrink="No" style={{ maxWidth: toRem(420) }}>
|
||||||
|
<Icon size="100" src={Icons.ArrowGoRight} />
|
||||||
|
<Text size="T300" priority="300" truncate>
|
||||||
|
Forwarded from <b>{senderName}</b>
|
||||||
|
{sourceRoom ? (
|
||||||
|
<>
|
||||||
|
{' in '}
|
||||||
|
<b>{sourceRoom.name}</b>
|
||||||
|
</>
|
||||||
|
) : null}
|
||||||
|
{' · '}
|
||||||
|
{when}
|
||||||
|
</Text>
|
||||||
|
</Box>
|
||||||
|
</Box>
|
||||||
|
);
|
||||||
|
},
|
||||||
|
);
|
||||||
@@ -1,7 +1,11 @@
|
|||||||
import React, { CSSProperties, ReactNode, useEffect, useRef, useState } from 'react';
|
import React, { CSSProperties, ReactNode, useEffect, useRef, useState } from 'react';
|
||||||
import { useTranslation } from 'react-i18next';
|
import { useTranslation } from 'react-i18next';
|
||||||
import { Box, Button, config, Icon, Icons, Text, color, toRem } from 'folds';
|
import { Box, Button, config, Icon, Icons, Text, color, toRem } from 'folds';
|
||||||
import { IContent } from 'matrix-js-sdk';
|
import { IContent, MatrixEvent } from 'matrix-js-sdk';
|
||||||
|
import { useSetAtom } from 'jotai';
|
||||||
|
import { useMatrixClient } from '../../hooks/useMatrixClient';
|
||||||
|
import { settingsRequestAtom } from '../../state/settingsRequest';
|
||||||
|
import { describeDecryptionFailure } from '../../utils/decryptionReason';
|
||||||
import { JUMBO_EMOJI_REG, URL_REG } from '../../utils/regex';
|
import { JUMBO_EMOJI_REG, URL_REG } from '../../utils/regex';
|
||||||
import { trimReplyFromBody } from '../../utils/room';
|
import { trimReplyFromBody } from '../../utils/room';
|
||||||
import { MessageTextBody } from './layout';
|
import { MessageTextBody } from './layout';
|
||||||
@@ -42,14 +46,31 @@ type CollapsibleBodyProps = {
|
|||||||
eventId?: string;
|
eventId?: string;
|
||||||
children: ReactNode;
|
children: ReactNode;
|
||||||
};
|
};
|
||||||
|
// [Gitea #152] Messages the user expanded this session. The timeline unmounts
|
||||||
|
// rows as they scroll away, so component state alone forgot the choice;
|
||||||
|
// module-scoped (never persisted) survives remounts and clears on reload.
|
||||||
|
const expandedMessages = new Set<string>();
|
||||||
|
|
||||||
function CollapsibleBody({ eventId, children }: CollapsibleBodyProps) {
|
function CollapsibleBody({ eventId, children }: CollapsibleBodyProps) {
|
||||||
const bodyRef = useRef<HTMLDivElement>(null);
|
const bodyRef = useRef<HTMLDivElement>(null);
|
||||||
const [needsCollapse, setNeedsCollapse] = useState(false);
|
const [needsCollapse, setNeedsCollapse] = useState(false);
|
||||||
const [collapsed, setCollapsed] = useState(true);
|
const [collapsed, setCollapsedState] = useState(
|
||||||
|
() => !(eventId && expandedMessages.has(eventId)),
|
||||||
|
);
|
||||||
|
const setCollapsed = (next: boolean | ((c: boolean) => boolean)) => {
|
||||||
|
setCollapsedState((c) => {
|
||||||
|
const value = typeof next === 'function' ? next(c) : next;
|
||||||
|
if (eventId) {
|
||||||
|
if (value) expandedMessages.delete(eventId);
|
||||||
|
else expandedMessages.add(eventId);
|
||||||
|
}
|
||||||
|
return value;
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
// Reset collapsed state when the event changes (new message)
|
// Reset collapsed state when the event changes (new message)
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
setCollapsed(true);
|
setCollapsedState(!(eventId && expandedMessages.has(eventId)));
|
||||||
setNeedsCollapse(false);
|
setNeedsCollapse(false);
|
||||||
}, [eventId]);
|
}, [eventId]);
|
||||||
|
|
||||||
@@ -120,11 +141,59 @@ function CollapsibleBody({ eventId, children }: CollapsibleBodyProps) {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
export function MBadEncrypted() {
|
type MBadEncryptedProps = {
|
||||||
|
mEvent?: MatrixEvent;
|
||||||
|
};
|
||||||
|
/**
|
||||||
|
* [Gitea #159] The undecryptable placeholder says WHY and offers the one
|
||||||
|
* action that fixes it (set up key backup / verify this session / retry).
|
||||||
|
* The raw SDK code stays in the tooltip for support.
|
||||||
|
*/
|
||||||
|
export function MBadEncrypted({ mEvent }: MBadEncryptedProps) {
|
||||||
|
const mx = useMatrixClient();
|
||||||
|
const requestSettings = useSetAtom(settingsRequestAtom);
|
||||||
|
const [retrying, setRetrying] = useState(false);
|
||||||
|
const code = mEvent?.decryptionFailureReason ?? null;
|
||||||
|
const reason = describeDecryptionFailure(code);
|
||||||
|
|
||||||
|
const handleAction = async () => {
|
||||||
|
if (reason.action === 'setup-backup' || reason.action === 'verify-session') {
|
||||||
|
requestSettings('devices');
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (reason.action === 'retry' && mEvent) {
|
||||||
|
setRetrying(true);
|
||||||
|
try {
|
||||||
|
await mx.decryptEventIfNeeded(mEvent, { forceRedecryptIfUntrusted: true });
|
||||||
|
} catch {
|
||||||
|
// still undecryptable — the placeholder re-renders with the current reason
|
||||||
|
} finally {
|
||||||
|
setRetrying(false);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<Text>
|
<Box direction="Column" gap="100" alignItems="Start">
|
||||||
<MessageBadEncryptedContent />
|
<Text>
|
||||||
</Text>
|
<MessageBadEncryptedContent title={code ?? undefined} />
|
||||||
|
</Text>
|
||||||
|
<Text size="T200" priority="300">
|
||||||
|
{reason.text}
|
||||||
|
</Text>
|
||||||
|
{reason.action !== 'none' && (
|
||||||
|
<Button
|
||||||
|
size="300"
|
||||||
|
variant="Secondary"
|
||||||
|
fill="Soft"
|
||||||
|
radii="300"
|
||||||
|
onClick={handleAction}
|
||||||
|
disabled={retrying}
|
||||||
|
>
|
||||||
|
<Text size="B300">{retrying ? 'Retrying…' : reason.actionLabel}</Text>
|
||||||
|
</Button>
|
||||||
|
)}
|
||||||
|
</Box>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -13,13 +13,21 @@ export const Reaction = as<
|
|||||||
mx: MatrixClient;
|
mx: MatrixClient;
|
||||||
count: number;
|
count: number;
|
||||||
reaction: string;
|
reaction: string;
|
||||||
|
/** Custom-emoji shortcode from the reaction event, used for its label. */
|
||||||
|
shortcode?: string;
|
||||||
useAuthentication?: boolean;
|
useAuthentication?: boolean;
|
||||||
}
|
}
|
||||||
>(({ className, mx, count, reaction, useAuthentication, ...props }, ref) => {
|
>(({ className, mx, count, reaction, shortcode, useAuthentication, ...props }, ref) => {
|
||||||
const shortcode = reaction.startsWith('mxc://')
|
// Name a unicode reaction by the emoji itself: screen readers speak it by its
|
||||||
? 'custom emoji'
|
// proper name ("party popper"). Don't use getShortcodeFor here — it returns
|
||||||
: (getShortcodeFor(getHexcodeForEmoji(reaction)) ?? reaction);
|
// undefined until the lazy emoji data loads, so the same button would flip
|
||||||
const label = `${shortcode} reaction, ${count} ${count === 1 ? 'person' : 'people'}`;
|
// between "🎉 reaction" and "tada reaction" depending on timing (#179).
|
||||||
|
const name = reaction.startsWith('mxc://')
|
||||||
|
? shortcode
|
||||||
|
? `:${shortcode}:`
|
||||||
|
: 'custom emoji'
|
||||||
|
: reaction;
|
||||||
|
const label = `${name} reaction, ${count} ${count === 1 ? 'person' : 'people'}`;
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<Box
|
<Box
|
||||||
|
|||||||
@@ -8,6 +8,7 @@ import { getMxIdLocalPart } from '../../utils/matrix';
|
|||||||
import { LinePlaceholder } from './placeholder';
|
import { LinePlaceholder } from './placeholder';
|
||||||
import { randomNumberBetween } from '../../utils/common';
|
import { randomNumberBetween } from '../../utils/common';
|
||||||
import * as css from './Reply.css';
|
import * as css from './Reply.css';
|
||||||
|
import { ReplyMediaThumb, hasReplyMedia } from './ReplyMediaThumb';
|
||||||
import { MessageBadEncryptedContent, MessageDeletedContent, MessageFailedContent } from './content';
|
import { MessageBadEncryptedContent, MessageDeletedContent, MessageFailedContent } from './content';
|
||||||
import { scaleSystemEmoji } from '../../plugins/react-custom-html-parser';
|
import { scaleSystemEmoji } from '../../plugins/react-custom-html-parser';
|
||||||
import { useRoomEvent } from '../../hooks/useRoomEvent';
|
import { useRoomEvent } from '../../hooks/useRoomEvent';
|
||||||
@@ -143,9 +144,12 @@ export const Reply = as<'div', ReplyProps>(
|
|||||||
<i>Original message not available</i>
|
<i>Original message not available</i>
|
||||||
</Text>
|
</Text>
|
||||||
) : (
|
) : (
|
||||||
<Text size="T300" truncate>
|
<Box alignItems="Center" gap="200" style={{ minWidth: 0 }}>
|
||||||
{badEncryption ? <MessageBadEncryptedContent /> : bodyJSX}
|
{hasReplyMedia(replyEvent) && <ReplyMediaThumb mEvent={replyEvent} />}
|
||||||
</Text>
|
<Text size="T300" truncate>
|
||||||
|
{badEncryption ? <MessageBadEncryptedContent /> : bodyJSX}
|
||||||
|
</Text>
|
||||||
|
</Box>
|
||||||
)}
|
)}
|
||||||
</ReplyLayout>
|
</ReplyLayout>
|
||||||
</Box>
|
</Box>
|
||||||
|
|||||||
@@ -0,0 +1,75 @@
|
|||||||
|
import React from 'react';
|
||||||
|
import { Icon, Icons, config, toRem } from 'folds';
|
||||||
|
import { MatrixEvent, MsgType } from 'matrix-js-sdk';
|
||||||
|
import { useMatrixClient } from '../../hooks/useMatrixClient';
|
||||||
|
import { useMediaAuthentication } from '../../hooks/useMediaAuthentication';
|
||||||
|
import { useDecryptedMediaUrl } from '../../hooks/useDecryptedMediaUrl';
|
||||||
|
import { getThumbMxc } from '../../utils/mediaThumb';
|
||||||
|
import { MessageEvent } from '../../../types/matrix/room';
|
||||||
|
|
||||||
|
const SIZE = 36;
|
||||||
|
|
||||||
|
/** Whether a reply quote for this event should carry a thumbnail. */
|
||||||
|
export const hasReplyMedia = (mEvent: MatrixEvent | null | undefined): boolean => {
|
||||||
|
if (!mEvent || mEvent.isRedacted()) return false;
|
||||||
|
if (mEvent.getType() === MessageEvent.Sticker) return true;
|
||||||
|
const msgtype = mEvent.getContent().msgtype;
|
||||||
|
return msgtype === MsgType.Image || msgtype === MsgType.Video;
|
||||||
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* [Gitea #151] 36 px thumbnail in a reply quote for an image/video/sticker.
|
||||||
|
* Uses the event's own thumbnail (decrypting it for E2EE media), never the
|
||||||
|
* full-size file.
|
||||||
|
*/
|
||||||
|
export function ReplyMediaThumb({ mEvent }: { mEvent: MatrixEvent }) {
|
||||||
|
const mx = useMatrixClient();
|
||||||
|
const useAuthentication = useMediaAuthentication();
|
||||||
|
const content = mEvent.getContent();
|
||||||
|
const isVideo = content.msgtype === MsgType.Video;
|
||||||
|
const thumbMxc = getThumbMxc(mEvent);
|
||||||
|
const info = content.info as Record<string, unknown> | undefined;
|
||||||
|
const encInfo = content.file
|
||||||
|
? ((info?.thumbnail_file as typeof content.file | undefined) ?? content.file)
|
||||||
|
: undefined;
|
||||||
|
const mimeType =
|
||||||
|
(info?.thumbnail_info as { mimetype?: string } | undefined)?.mimetype ??
|
||||||
|
(info?.mimetype as string | undefined);
|
||||||
|
const media = useDecryptedMediaUrl(mx, thumbMxc, encInfo, useAuthentication, mimeType);
|
||||||
|
|
||||||
|
return (
|
||||||
|
<span
|
||||||
|
aria-hidden
|
||||||
|
style={{
|
||||||
|
position: 'relative',
|
||||||
|
display: 'inline-flex',
|
||||||
|
alignItems: 'center',
|
||||||
|
justifyContent: 'center',
|
||||||
|
width: toRem(SIZE),
|
||||||
|
height: toRem(SIZE),
|
||||||
|
flexShrink: 0,
|
||||||
|
borderRadius: config.radii.R300,
|
||||||
|
overflow: 'hidden',
|
||||||
|
background: 'rgba(127, 127, 127, 0.15)',
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
{media.status === 'ok' ? (
|
||||||
|
<img
|
||||||
|
src={media.url}
|
||||||
|
alt=""
|
||||||
|
style={{ width: '100%', height: '100%', objectFit: 'cover', display: 'block' }}
|
||||||
|
/>
|
||||||
|
) : (
|
||||||
|
<Icon size="100" src={isVideo ? Icons.Play : Icons.Photo} />
|
||||||
|
)}
|
||||||
|
{isVideo && media.status === 'ok' && (
|
||||||
|
<Icon
|
||||||
|
size="50"
|
||||||
|
src={Icons.Play}
|
||||||
|
filled
|
||||||
|
style={{ position: 'absolute', color: 'white', filter: 'drop-shadow(0 0 2px black)' }}
|
||||||
|
/>
|
||||||
|
)}
|
||||||
|
</span>
|
||||||
|
);
|
||||||
|
}
|
||||||
@@ -1,6 +1,6 @@
|
|||||||
import React, { ComponentProps } from 'react';
|
import React, { ComponentProps } from 'react';
|
||||||
import { Text, as } from 'folds';
|
import { Text, as } from 'folds';
|
||||||
import { timeDayMonYear, timeHourMinute, today, yesterday } from '../../utils/time';
|
import { formatTimestamp } from '../../utils/formatTimestamp';
|
||||||
|
|
||||||
export type TimeProps = {
|
export type TimeProps = {
|
||||||
compact?: boolean;
|
compact?: boolean;
|
||||||
@@ -12,8 +12,8 @@ export type TimeProps = {
|
|||||||
/**
|
/**
|
||||||
* Renders a formatted timestamp, supporting compact and full display modes.
|
* Renders a formatted timestamp, supporting compact and full display modes.
|
||||||
*
|
*
|
||||||
* Displays the time in hour:minute format if the message is from today, yesterday, or if `compact` is true.
|
* `compact` always shows the clock time; otherwise the shared `formatTimestamp`
|
||||||
* For older messages, it shows the date and time.
|
* rules apply (today → time, yesterday/this week → day word + time, else date + time).
|
||||||
*
|
*
|
||||||
* @param {number} ts - The timestamp to display.
|
* @param {number} ts - The timestamp to display.
|
||||||
* @param {boolean} [compact=false] - If true, always show only the time.
|
* @param {boolean} [compact=false] - If true, always show only the time.
|
||||||
@@ -23,18 +23,7 @@ export type TimeProps = {
|
|||||||
*/
|
*/
|
||||||
export const Time = as<'span', TimeProps & ComponentProps<typeof Text>>(
|
export const Time = as<'span', TimeProps & ComponentProps<typeof Text>>(
|
||||||
({ compact, hour24Clock, dateFormatString, ts, ...props }, ref) => {
|
({ compact, hour24Clock, dateFormatString, ts, ...props }, ref) => {
|
||||||
const formattedTime = timeHourMinute(ts, hour24Clock);
|
const time = formatTimestamp(ts, { hour24Clock, dateFormatString }, compact ? 'time' : 'auto');
|
||||||
|
|
||||||
let time = '';
|
|
||||||
if (compact) {
|
|
||||||
time = formattedTime;
|
|
||||||
} else if (today(ts)) {
|
|
||||||
time = formattedTime;
|
|
||||||
} else if (yesterday(ts)) {
|
|
||||||
time = `Yesterday ${formattedTime}`;
|
|
||||||
} else {
|
|
||||||
time = `${timeDayMonYear(ts, dateFormatString)} ${formattedTime}`;
|
|
||||||
}
|
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<Text as="time" style={{ flexShrink: 0 }} size="T200" priority="300" {...props} ref={ref}>
|
<Text as="time" style={{ flexShrink: 0 }} size="T200" priority="300" {...props} ref={ref}>
|
||||||
|
|||||||
@@ -0,0 +1,6 @@
|
|||||||
|
import { createContext, useContext } from 'react';
|
||||||
|
import { DiffToken } from '../../../utils/wordDiff';
|
||||||
|
|
||||||
|
/** [Gitea #144] Word diff of the message's last edit, for the "(edited)" hover. */
|
||||||
|
export const EditDiffContext = createContext<DiffToken[] | undefined>(undefined);
|
||||||
|
export const useEditDiff = () => useContext(EditDiffContext);
|
||||||
@@ -1,5 +1,20 @@
|
|||||||
import { Box, Icon, Icons, Text, as, color, config } from 'folds';
|
import {
|
||||||
import React from 'react';
|
Box,
|
||||||
|
Icon,
|
||||||
|
Icons,
|
||||||
|
PopOut,
|
||||||
|
RectCords,
|
||||||
|
Text,
|
||||||
|
Tooltip,
|
||||||
|
TooltipProvider,
|
||||||
|
as,
|
||||||
|
color,
|
||||||
|
config,
|
||||||
|
} from 'folds';
|
||||||
|
import React, { useEffect, useState } from 'react';
|
||||||
|
import { useLongPress } from '../../../hooks/useLongPress';
|
||||||
|
import { DiffToken, countChanges } from '../../../utils/wordDiff';
|
||||||
|
import { useEditDiff } from './EditDiffContext';
|
||||||
|
|
||||||
const warningStyle = { color: color.Warning.Main, opacity: config.opacity.P300 };
|
const warningStyle = { color: color.Warning.Main, opacity: config.opacity.P300 };
|
||||||
const criticalStyle = { color: color.Critical.Main, opacity: config.opacity.P300 };
|
const criticalStyle = { color: color.Critical.Main, opacity: config.opacity.P300 };
|
||||||
@@ -66,29 +81,157 @@ export const MessageVerificationRequestContent = as<'div', { children?: never }>
|
|||||||
),
|
),
|
||||||
);
|
);
|
||||||
|
|
||||||
|
const editDiffStyle: React.CSSProperties = {
|
||||||
|
maxWidth: '40ch',
|
||||||
|
whiteSpace: 'pre-wrap',
|
||||||
|
overflowWrap: 'anywhere',
|
||||||
|
maxHeight: '12lh',
|
||||||
|
overflow: 'hidden',
|
||||||
|
};
|
||||||
|
|
||||||
|
/** The last edit as a word diff: removed words struck, added words bold. */
|
||||||
|
export function EditDiffBody({ tokens, hint }: { tokens: DiffToken[]; hint: string }) {
|
||||||
|
const { added, removed } = countChanges(tokens);
|
||||||
|
return (
|
||||||
|
<Box direction="Column" gap="100" style={editDiffStyle}>
|
||||||
|
<Text size="T200" priority="300">
|
||||||
|
Last edit
|
||||||
|
{added > 0 && ` · +${added}`}
|
||||||
|
{removed > 0 && ` · −${removed}`}
|
||||||
|
</Text>
|
||||||
|
<Text as="span" size="T300" dir="auto">
|
||||||
|
{tokens.map((t, i) => {
|
||||||
|
if (t.op === 'add')
|
||||||
|
return (
|
||||||
|
<ins key={i} style={{ textDecoration: 'none', fontWeight: 'bold' }}>
|
||||||
|
{t.text}
|
||||||
|
</ins>
|
||||||
|
);
|
||||||
|
if (t.op === 'del')
|
||||||
|
return (
|
||||||
|
<del key={i} style={{ opacity: config.opacity.P300 }}>
|
||||||
|
{t.text}
|
||||||
|
</del>
|
||||||
|
);
|
||||||
|
return <React.Fragment key={i}>{t.text}</React.Fragment>;
|
||||||
|
})}
|
||||||
|
</Text>
|
||||||
|
<Text size="T200" priority="300">
|
||||||
|
{hint}
|
||||||
|
</Text>
|
||||||
|
</Box>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
const editedButtonStyle: React.CSSProperties = {
|
||||||
|
cursor: 'pointer',
|
||||||
|
background: 'none',
|
||||||
|
border: 'none',
|
||||||
|
padding: 0,
|
||||||
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* "(edited)" label. With an edit-history handler it is a button that opens
|
||||||
|
* the viewer; when the surrounding message also provides a last-edit diff
|
||||||
|
* (see `EditDiffContext`) hover/focus shows it as a tooltip and a touch
|
||||||
|
* long-press shows it as a popout. [Gitea #144]
|
||||||
|
*/
|
||||||
export const MessageEditedContent = as<
|
export const MessageEditedContent = as<
|
||||||
'span',
|
'span',
|
||||||
{ children?: never; onEditHistoryClick?: () => void }
|
{ children?: never; onEditHistoryClick?: () => void }
|
||||||
>(({ onEditHistoryClick, ...props }, ref) =>
|
>(({ onEditHistoryClick, ...props }, ref) => {
|
||||||
onEditHistoryClick ? (
|
const diff = useEditDiff();
|
||||||
|
const [pressAnchor, setPressAnchor] = useState<RectCords | undefined>();
|
||||||
|
const { coarse, handlers, suppressContextMenu } = useLongPress((x, y) => {
|
||||||
|
if (diff) setPressAnchor({ x, y, width: 1, height: 1 });
|
||||||
|
});
|
||||||
|
|
||||||
|
useEffect(() => {
|
||||||
|
if (!pressAnchor) return undefined;
|
||||||
|
const close = () => setPressAnchor(undefined);
|
||||||
|
const t = window.setTimeout(close, 6000);
|
||||||
|
window.addEventListener('touchstart', close, { passive: true });
|
||||||
|
window.addEventListener('scroll', close, { passive: true, capture: true });
|
||||||
|
return () => {
|
||||||
|
window.clearTimeout(t);
|
||||||
|
window.removeEventListener('touchstart', close);
|
||||||
|
window.removeEventListener('scroll', close, { capture: true });
|
||||||
|
};
|
||||||
|
}, [pressAnchor]);
|
||||||
|
|
||||||
|
if (!onEditHistoryClick) {
|
||||||
|
return (
|
||||||
|
<Text as="span" size="T200" priority="300" {...props} ref={ref}>
|
||||||
|
{' (edited)'}
|
||||||
|
</Text>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
const button = (tipRef?: React.RefCallback<HTMLElement>) => (
|
||||||
|
<button
|
||||||
|
ref={tipRef}
|
||||||
|
type="button"
|
||||||
|
onClick={() => {
|
||||||
|
if (suppressContextMenu.current) return;
|
||||||
|
onEditHistoryClick();
|
||||||
|
}}
|
||||||
|
onContextMenu={(evt) => {
|
||||||
|
if (suppressContextMenu.current) evt.preventDefault();
|
||||||
|
}}
|
||||||
|
{...handlers}
|
||||||
|
// Keep the message's own long-press (action sheet) from firing too.
|
||||||
|
onTouchStart={(evt) => {
|
||||||
|
evt.stopPropagation();
|
||||||
|
handlers.onTouchStart?.(evt);
|
||||||
|
}}
|
||||||
|
aria-label={diff ? 'View edit history — hover for the last change' : 'View edit history'}
|
||||||
|
style={editedButtonStyle}
|
||||||
|
>
|
||||||
|
<Text as="span" size="T200" priority="300">
|
||||||
|
{' (edited)'}
|
||||||
|
</Text>
|
||||||
|
</button>
|
||||||
|
);
|
||||||
|
|
||||||
|
return (
|
||||||
<span ref={ref} {...(props as React.HTMLAttributes<HTMLSpanElement>)}>
|
<span ref={ref} {...(props as React.HTMLAttributes<HTMLSpanElement>)}>
|
||||||
<button
|
{diff ? (
|
||||||
type="button"
|
<TooltipProvider
|
||||||
onClick={onEditHistoryClick}
|
position="Top"
|
||||||
aria-label="View edit history"
|
align="Start"
|
||||||
style={{ cursor: 'pointer', background: 'none', border: 'none', padding: 0 }}
|
delay={300}
|
||||||
>
|
tooltip={
|
||||||
<Text as="span" size="T200" priority="300">
|
<Tooltip>
|
||||||
{' (edited)'}
|
<EditDiffBody
|
||||||
</Text>
|
tokens={diff}
|
||||||
</button>
|
hint={coarse ? 'Tap for full history' : 'Click for full history'}
|
||||||
|
/>
|
||||||
|
</Tooltip>
|
||||||
|
}
|
||||||
|
>
|
||||||
|
{(tipRef) => button(tipRef)}
|
||||||
|
</TooltipProvider>
|
||||||
|
) : (
|
||||||
|
button()
|
||||||
|
)}
|
||||||
|
{diff && pressAnchor && (
|
||||||
|
<PopOut
|
||||||
|
anchor={pressAnchor}
|
||||||
|
position="Top"
|
||||||
|
align="Start"
|
||||||
|
content={
|
||||||
|
<Tooltip>
|
||||||
|
<EditDiffBody
|
||||||
|
tokens={diff}
|
||||||
|
hint={coarse ? 'Tap for full history' : 'Click for full history'}
|
||||||
|
/>
|
||||||
|
</Tooltip>
|
||||||
|
}
|
||||||
|
/>
|
||||||
|
)}
|
||||||
</span>
|
</span>
|
||||||
) : (
|
);
|
||||||
<Text as="span" size="T200" priority="300" {...props} ref={ref}>
|
});
|
||||||
{' (edited)'}
|
|
||||||
</Text>
|
|
||||||
),
|
|
||||||
);
|
|
||||||
|
|
||||||
type TranslatedStatus = 'downloading' | 'translating' | 'done' | 'error';
|
type TranslatedStatus = 'downloading' | 'translating' | 'done' | 'error';
|
||||||
|
|
||||||
|
|||||||
@@ -105,16 +105,21 @@ export function ReadTextFile({ body, mimeType, url, encInfo, renderViewer }: Rea
|
|||||||
<OverlayCenter>
|
<OverlayCenter>
|
||||||
<FocusTrap
|
<FocusTrap
|
||||||
focusTrapOptions={{
|
focusTrapOptions={{
|
||||||
initialFocus: false,
|
fallbackFocus: '#file-viewer-2-dialog',
|
||||||
onDeactivate: () => setTextViewer(false),
|
onDeactivate: () => setTextViewer(false),
|
||||||
clickOutsideDeactivates: true,
|
clickOutsideDeactivates: true,
|
||||||
escapeDeactivates: stopPropagation,
|
escapeDeactivates: stopPropagation,
|
||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
<Modal
|
<Modal
|
||||||
|
id="file-viewer-2-dialog"
|
||||||
|
role="dialog"
|
||||||
|
aria-modal="true"
|
||||||
|
aria-label={`File: ${body}`}
|
||||||
|
tabIndex={-1}
|
||||||
className={ModalWide}
|
className={ModalWide}
|
||||||
size="500"
|
size="500"
|
||||||
onContextMenu={(evt: any) => evt.stopPropagation()}
|
onContextMenu={(evt: React.MouseEvent) => evt.stopPropagation()}
|
||||||
>
|
>
|
||||||
{renderViewer({
|
{renderViewer({
|
||||||
name: body,
|
name: body,
|
||||||
@@ -194,16 +199,21 @@ export function ReadPdfFile({ body, mimeType, url, encInfo, renderViewer }: Read
|
|||||||
<OverlayCenter>
|
<OverlayCenter>
|
||||||
<FocusTrap
|
<FocusTrap
|
||||||
focusTrapOptions={{
|
focusTrapOptions={{
|
||||||
initialFocus: false,
|
fallbackFocus: '#file-viewer-1-dialog',
|
||||||
onDeactivate: () => setPdfViewer(false),
|
onDeactivate: () => setPdfViewer(false),
|
||||||
clickOutsideDeactivates: true,
|
clickOutsideDeactivates: true,
|
||||||
escapeDeactivates: stopPropagation,
|
escapeDeactivates: stopPropagation,
|
||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
<Modal
|
<Modal
|
||||||
|
id="file-viewer-1-dialog"
|
||||||
|
role="dialog"
|
||||||
|
aria-modal="true"
|
||||||
|
aria-label={`File: ${body}`}
|
||||||
|
tabIndex={-1}
|
||||||
className={ModalWide}
|
className={ModalWide}
|
||||||
size="500"
|
size="500"
|
||||||
onContextMenu={(evt: any) => evt.stopPropagation()}
|
onContextMenu={(evt: React.MouseEvent) => evt.stopPropagation()}
|
||||||
>
|
>
|
||||||
{renderViewer({
|
{renderViewer({
|
||||||
name: body,
|
name: body,
|
||||||
|
|||||||
@@ -47,6 +47,9 @@ type RenderImageProps = {
|
|||||||
onError: () => void;
|
onError: () => void;
|
||||||
onClick: () => void;
|
onClick: () => void;
|
||||||
tabIndex: number;
|
tabIndex: number;
|
||||||
|
role: 'button';
|
||||||
|
'aria-label': string;
|
||||||
|
onKeyDown: (evt: React.KeyboardEvent<HTMLElement>) => void;
|
||||||
};
|
};
|
||||||
export type ImageContentProps = {
|
export type ImageContentProps = {
|
||||||
body: string;
|
body: string;
|
||||||
@@ -59,6 +62,9 @@ export type ImageContentProps = {
|
|||||||
spoilerReason?: string;
|
spoilerReason?: string;
|
||||||
renderViewer: (props: RenderViewerProps) => ReactNode;
|
renderViewer: (props: RenderViewerProps) => ReactNode;
|
||||||
renderImage: (props: RenderImageProps) => ReactNode;
|
renderImage: (props: RenderImageProps) => ReactNode;
|
||||||
|
// [Gitea #219] When given, a click opens THIS instead of the built-in
|
||||||
|
// viewer — the room timeline hands it to the shared media lightbox.
|
||||||
|
onOpenViewer?: () => void;
|
||||||
};
|
};
|
||||||
export const ImageContent = as<'div', ImageContentProps>(
|
export const ImageContent = as<'div', ImageContentProps>(
|
||||||
(
|
(
|
||||||
@@ -74,6 +80,7 @@ export const ImageContent = as<'div', ImageContentProps>(
|
|||||||
spoilerReason,
|
spoilerReason,
|
||||||
renderViewer,
|
renderViewer,
|
||||||
renderImage,
|
renderImage,
|
||||||
|
onOpenViewer,
|
||||||
...props
|
...props
|
||||||
},
|
},
|
||||||
ref,
|
ref,
|
||||||
@@ -139,7 +146,7 @@ export const ImageContent = as<'div', ImageContentProps>(
|
|||||||
<Modal
|
<Modal
|
||||||
className={ModalWide}
|
className={ModalWide}
|
||||||
size="500"
|
size="500"
|
||||||
onContextMenu={(evt: any) => evt.stopPropagation()}
|
onContextMenu={(evt: React.MouseEvent) => evt.stopPropagation()}
|
||||||
>
|
>
|
||||||
{renderViewer({
|
{renderViewer({
|
||||||
src: srcState.data,
|
src: srcState.data,
|
||||||
@@ -182,8 +189,17 @@ export const ImageContent = as<'div', ImageContentProps>(
|
|||||||
src: srcState.data,
|
src: srcState.data,
|
||||||
onLoad: handleLoad,
|
onLoad: handleLoad,
|
||||||
onError: handleError,
|
onError: handleError,
|
||||||
onClick: () => setViewer(true),
|
onClick: () => (onOpenViewer ? onOpenViewer() : setViewer(true)),
|
||||||
tabIndex: 0,
|
tabIndex: 0,
|
||||||
|
// [Gitea #164] Keyboard users could Tab to the image but not open it.
|
||||||
|
role: 'button',
|
||||||
|
'aria-label': `View image: ${body}`,
|
||||||
|
onKeyDown: (evt) => {
|
||||||
|
if (evt.key !== 'Enter' && evt.key !== ' ') return;
|
||||||
|
evt.preventDefault();
|
||||||
|
if (onOpenViewer) onOpenViewer();
|
||||||
|
else setViewer(true);
|
||||||
|
},
|
||||||
})}
|
})}
|
||||||
</Box>
|
</Box>
|
||||||
)}
|
)}
|
||||||
|
|||||||
@@ -1,10 +1,9 @@
|
|||||||
/* eslint-disable @typescript-eslint/no-explicit-any */
|
|
||||||
import React, { KeyboardEvent, useCallback, useEffect, useMemo, useState } from 'react';
|
import React, { KeyboardEvent, useCallback, useEffect, useMemo, useState } from 'react';
|
||||||
import { Box, Chip, color, config, Icon, Icons, Text, toRem } from 'folds';
|
import { Box, Chip, color, config, Icon, Icons, Text, toRem } from 'folds';
|
||||||
import { RelationsEvent } from 'matrix-js-sdk/lib/models/relations';
|
import { RelationsEvent } from 'matrix-js-sdk/lib/models/relations';
|
||||||
import { MatrixEvent, Room, RoomEvent, PollEvent } from 'matrix-js-sdk';
|
import { MatrixEvent, Room, RoomEvent, PollEvent } from 'matrix-js-sdk';
|
||||||
import { useMatrixClient } from '../../../hooks/useMatrixClient';
|
import { useMatrixClient } from '../../../hooks/useMatrixClient';
|
||||||
import { getMemberName } from '../../../utils/room';
|
import { getMemberName, sendRoomEvent } from '../../../utils/room';
|
||||||
import {
|
import {
|
||||||
ParsedPoll,
|
ParsedPoll,
|
||||||
PollResponse,
|
PollResponse,
|
||||||
@@ -43,7 +42,7 @@ function computePollState(
|
|||||||
const validIds = new Set(parsed.answers.map((a) => a.id));
|
const validIds = new Set(parsed.answers.map((a) => a.id));
|
||||||
|
|
||||||
const getRels = (type: string): MatrixEvent[] =>
|
const getRels = (type: string): MatrixEvent[] =>
|
||||||
relations.getChildEventsForEvent(eventId, 'm.reference', type as any)?.getRelations() ?? [];
|
relations.getChildEventsForEvent(eventId, 'm.reference', type)?.getRelations() ?? [];
|
||||||
|
|
||||||
const endEvents = [...getRels('m.poll.end'), ...getRels('org.matrix.msc3381.poll.end')];
|
const endEvents = [...getRels('m.poll.end'), ...getRels('org.matrix.msc3381.poll.end')];
|
||||||
const respEvents = [
|
const respEvents = [
|
||||||
@@ -127,18 +126,10 @@ export function PollContent({
|
|||||||
if (!eventId || !parsed) return undefined;
|
if (!eventId || !parsed) return undefined;
|
||||||
const relations = room.getUnfilteredTimelineSet().relations;
|
const relations = room.getUnfilteredTimelineSet().relations;
|
||||||
const relObjs = [
|
const relObjs = [
|
||||||
relations.getChildEventsForEvent(eventId, 'm.reference', 'm.poll.response' as any),
|
relations.getChildEventsForEvent(eventId, 'm.reference', 'm.poll.response'),
|
||||||
relations.getChildEventsForEvent(
|
relations.getChildEventsForEvent(eventId, 'm.reference', 'org.matrix.msc3381.poll.response'),
|
||||||
eventId,
|
relations.getChildEventsForEvent(eventId, 'm.reference', 'm.poll.end'),
|
||||||
'm.reference',
|
relations.getChildEventsForEvent(eventId, 'm.reference', 'org.matrix.msc3381.poll.end'),
|
||||||
'org.matrix.msc3381.poll.response' as any,
|
|
||||||
),
|
|
||||||
relations.getChildEventsForEvent(eventId, 'm.reference', 'm.poll.end' as any),
|
|
||||||
relations.getChildEventsForEvent(
|
|
||||||
eventId,
|
|
||||||
'm.reference',
|
|
||||||
'org.matrix.msc3381.poll.end' as any,
|
|
||||||
),
|
|
||||||
];
|
];
|
||||||
relObjs.forEach((r) => {
|
relObjs.forEach((r) => {
|
||||||
r?.on(RelationsEvent.Add, refresh);
|
r?.on(RelationsEvent.Add, refresh);
|
||||||
@@ -228,7 +219,7 @@ export function PollContent({
|
|||||||
setPending(next);
|
setPending(next);
|
||||||
// Send the STABLE m.poll.response (matches Lotus's stable m.poll.start; the reader
|
// Send the STABLE m.poll.response (matches Lotus's stable m.poll.start; the reader
|
||||||
// accepts both namespaces).
|
// accepts both namespaces).
|
||||||
mx.sendEvent(roomId, 'm.poll.response' as any, {
|
sendRoomEvent(mx, roomId, null, 'm.poll.response', {
|
||||||
'm.relates_to': { rel_type: 'm.reference', event_id: eventId },
|
'm.relates_to': { rel_type: 'm.reference', event_id: eventId },
|
||||||
'm.selections': Array.from(next),
|
'm.selections': Array.from(next),
|
||||||
}).catch(() => setPending(null));
|
}).catch(() => setPending(null));
|
||||||
@@ -237,7 +228,7 @@ export function PollContent({
|
|||||||
const handleEndPoll = () => {
|
const handleEndPoll = () => {
|
||||||
if (!roomId || !eventId || ending) return;
|
if (!roomId || !eventId || ending) return;
|
||||||
setEnding(true);
|
setEnding(true);
|
||||||
mx.sendEvent(roomId, 'm.poll.end' as any, {
|
sendRoomEvent(mx, roomId, null, 'm.poll.end', {
|
||||||
'm.relates_to': { rel_type: 'm.reference', event_id: eventId },
|
'm.relates_to': { rel_type: 'm.reference', event_id: eventId },
|
||||||
'm.poll.end': {},
|
'm.poll.end': {},
|
||||||
'm.text': 'The poll has ended.',
|
'm.text': 'The poll has ended.',
|
||||||
|
|||||||
@@ -8,3 +8,4 @@ export * from './Time';
|
|||||||
export * from './MsgTypeRenderers';
|
export * from './MsgTypeRenderers';
|
||||||
export * from './FileHeader';
|
export * from './FileHeader';
|
||||||
export * from './RenderBody';
|
export * from './RenderBody';
|
||||||
|
export * from './ForwardedHeader';
|
||||||
|
|||||||
@@ -9,16 +9,35 @@ export const NavItem = as<
|
|||||||
{
|
{
|
||||||
highlight?: boolean;
|
highlight?: boolean;
|
||||||
} & css.RoomSelectorVariants
|
} & css.RoomSelectorVariants
|
||||||
>(({ as: AsNavItem = 'div', className, highlight, variant, radii, children, ...props }, ref) => (
|
>(
|
||||||
<AsNavItem
|
(
|
||||||
className={classNames(css.NavItem({ variant, radii }), className)}
|
{
|
||||||
data-highlight={highlight}
|
as: AsNavItem = 'div',
|
||||||
{...props}
|
className,
|
||||||
ref={ref}
|
highlight,
|
||||||
>
|
variant,
|
||||||
{children}
|
radii,
|
||||||
</AsNavItem>
|
children,
|
||||||
));
|
'aria-selected': selected,
|
||||||
|
...props
|
||||||
|
},
|
||||||
|
ref,
|
||||||
|
) => (
|
||||||
|
// [Gitea #222] Callers pass `aria-selected`, but that attribute is only
|
||||||
|
// valid on option/tab/row roles; on a plain div axe flags it as critical.
|
||||||
|
// Keep the prop for callers and styling, expose the state as aria-current.
|
||||||
|
<AsNavItem
|
||||||
|
className={classNames(css.NavItem({ variant, radii }), className)}
|
||||||
|
data-highlight={highlight}
|
||||||
|
data-selected={selected === true || selected === 'true' ? true : undefined}
|
||||||
|
aria-current={selected === true || selected === 'true' ? 'page' : undefined}
|
||||||
|
{...props}
|
||||||
|
ref={ref}
|
||||||
|
>
|
||||||
|
{children}
|
||||||
|
</AsNavItem>
|
||||||
|
),
|
||||||
|
);
|
||||||
|
|
||||||
export const NavLink = forwardRef<HTMLAnchorElement, ComponentProps<typeof Link>>(
|
export const NavLink = forwardRef<HTMLAnchorElement, ComponentProps<typeof Link>>(
|
||||||
({ className, ...props }, ref) => (
|
({ className, ...props }, ref) => (
|
||||||
|
|||||||
@@ -69,7 +69,7 @@ const NavItemBase = style({
|
|||||||
[`&:has(.${NavLink}:active)`]: {
|
[`&:has(.${NavLink}:active)`]: {
|
||||||
backgroundColor: ContainerActive,
|
backgroundColor: ContainerActive,
|
||||||
},
|
},
|
||||||
'&[aria-selected=true]': {
|
'&[data-selected=true]': {
|
||||||
backgroundColor: ContainerActive,
|
backgroundColor: ContainerActive,
|
||||||
},
|
},
|
||||||
[`&:has(.${NavLink}:focus-visible)`]: {
|
[`&:has(.${NavLink}:focus-visible)`]: {
|
||||||
|
|||||||
@@ -76,13 +76,22 @@ export function ReadReceiptAvatars({
|
|||||||
<OverlayCenter>
|
<OverlayCenter>
|
||||||
<FocusTrap
|
<FocusTrap
|
||||||
focusTrapOptions={{
|
focusTrapOptions={{
|
||||||
initialFocus: false,
|
fallbackFocus: '#readreceipt-seenby-dialog',
|
||||||
onDeactivate: () => setOpen(false),
|
onDeactivate: () => setOpen(false),
|
||||||
clickOutsideDeactivates: true,
|
clickOutsideDeactivates: true,
|
||||||
escapeDeactivates: stopPropagation,
|
escapeDeactivates: stopPropagation,
|
||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
<Modal variant="Surface" size="300" style={modalStyle}>
|
<Modal
|
||||||
|
id="readreceipt-seenby-dialog"
|
||||||
|
role="dialog"
|
||||||
|
aria-modal="true"
|
||||||
|
aria-label="Seen by"
|
||||||
|
tabIndex={-1}
|
||||||
|
variant="Surface"
|
||||||
|
size="300"
|
||||||
|
style={modalStyle}
|
||||||
|
>
|
||||||
<EventReaders room={room} eventId={eventId} requestClose={() => setOpen(false)} />
|
<EventReaders room={room} eventId={eventId} requestClose={() => setOpen(false)} />
|
||||||
</Modal>
|
</Modal>
|
||||||
</FocusTrap>
|
</FocusTrap>
|
||||||
|
|||||||
@@ -105,13 +105,20 @@ function ErrorDialog({
|
|||||||
<OverlayCenter>
|
<OverlayCenter>
|
||||||
<FocusTrap
|
<FocusTrap
|
||||||
focusTrapOptions={{
|
focusTrapOptions={{
|
||||||
initialFocus: false,
|
fallbackFocus: '#roomcard-error-dialog',
|
||||||
clickOutsideDeactivates: true,
|
clickOutsideDeactivates: true,
|
||||||
onDeactivate: closeError,
|
onDeactivate: closeError,
|
||||||
escapeDeactivates: stopPropagation,
|
escapeDeactivates: stopPropagation,
|
||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
<Dialog variant="Surface">
|
<Dialog
|
||||||
|
id="roomcard-error-dialog"
|
||||||
|
role="dialog"
|
||||||
|
aria-modal="true"
|
||||||
|
aria-label={title}
|
||||||
|
tabIndex={-1}
|
||||||
|
variant="Surface"
|
||||||
|
>
|
||||||
<Box style={{ padding: config.space.S400 }} direction="Column" gap="400">
|
<Box style={{ padding: config.space.S400 }} direction="Column" gap="400">
|
||||||
<Box direction="Column" gap="100">
|
<Box direction="Column" gap="100">
|
||||||
<Text>{title}</Text>
|
<Text>{title}</Text>
|
||||||
|
|||||||
@@ -19,15 +19,13 @@ import { getMemberDisplayName, getStateEvent } from '../../utils/room';
|
|||||||
import { useMatrixClient } from '../../hooks/useMatrixClient';
|
import { useMatrixClient } from '../../hooks/useMatrixClient';
|
||||||
import { getMxIdLocalPart, mxcUrlToHttp } from '../../utils/matrix';
|
import { getMxIdLocalPart, mxcUrlToHttp } from '../../utils/matrix';
|
||||||
import { AsyncStatus, useAsyncCallback } from '../../hooks/useAsyncCallback';
|
import { AsyncStatus, useAsyncCallback } from '../../hooks/useAsyncCallback';
|
||||||
import { timeDayMonthYear, timeHourMinute } from '../../utils/time';
|
import { useTimestampFormatter } from '../../hooks/useTimestampFormatter';
|
||||||
import { useRoomNavigate } from '../../hooks/useRoomNavigate';
|
import { useRoomNavigate } from '../../hooks/useRoomNavigate';
|
||||||
import { RoomAvatar } from '../room-avatar';
|
import { RoomAvatar } from '../room-avatar';
|
||||||
import { nameInitials } from '../../utils/common';
|
import { nameInitials } from '../../utils/common';
|
||||||
import { useRoomAvatar, useLocalRoomName, useRoomTopic } from '../../hooks/useRoomMeta';
|
import { useRoomAvatar, useLocalRoomName, useRoomTopic } from '../../hooks/useRoomMeta';
|
||||||
import { mDirectAtom } from '../../state/mDirectList';
|
import { mDirectAtom } from '../../state/mDirectList';
|
||||||
import { useMediaAuthentication } from '../../hooks/useMediaAuthentication';
|
import { useMediaAuthentication } from '../../hooks/useMediaAuthentication';
|
||||||
import { useSetting } from '../../state/hooks/settings';
|
|
||||||
import { settingsAtom } from '../../state/settings';
|
|
||||||
import { InviteUserPrompt } from '../invite-user-prompt';
|
import { InviteUserPrompt } from '../invite-user-prompt';
|
||||||
import { RoomTopicViewer } from '../room-topic-viewer';
|
import { RoomTopicViewer } from '../room-topic-viewer';
|
||||||
import { stopPropagation } from '../../utils/keyboard';
|
import { stopPropagation } from '../../utils/keyboard';
|
||||||
@@ -68,7 +66,7 @@ export const RoomIntro = as<'div', RoomIntroProps>(({ room, ...props }, ref) =>
|
|||||||
useCallback(async (roomId: string) => mx.joinRoom(roomId), [mx]),
|
useCallback(async (roomId: string) => mx.joinRoom(roomId), [mx]),
|
||||||
);
|
);
|
||||||
|
|
||||||
const [hour24Clock] = useSetting(settingsAtom, 'hour24Clock');
|
const { format } = useTimestampFormatter();
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<Box direction="Column" grow="Yes" gap="500" {...props} ref={ref}>
|
<Box direction="Column" grow="Yes" gap="500" {...props} ref={ref}>
|
||||||
@@ -135,7 +133,7 @@ export const RoomIntro = as<'div', RoomIntroProps>(({ room, ...props }, ref) =>
|
|||||||
<Text size="T200" priority="300">
|
<Text size="T200" priority="300">
|
||||||
{'Created by '}
|
{'Created by '}
|
||||||
<b>@{creatorName}</b>
|
<b>@{creatorName}</b>
|
||||||
{` on ${timeDayMonthYear(ts)} ${timeHourMinute(ts, hour24Clock)}`}
|
{` on ${format(ts, 'dateTime')}`}
|
||||||
</Text>
|
</Text>
|
||||||
)}
|
)}
|
||||||
</Box>
|
</Box>
|
||||||
|
|||||||
@@ -26,6 +26,10 @@ export const RoomTopicViewer = as<
|
|||||||
|
|
||||||
return (
|
return (
|
||||||
<Modal
|
<Modal
|
||||||
|
id="roomtopicviewer-dialog"
|
||||||
|
role="dialog"
|
||||||
|
aria-modal="true"
|
||||||
|
tabIndex={-1}
|
||||||
size="300"
|
size="300"
|
||||||
flexHeight
|
flexHeight
|
||||||
className={classNames(css.ModalFlex, className)}
|
className={classNames(css.ModalFlex, className)}
|
||||||
|
|||||||
@@ -1,21 +1,49 @@
|
|||||||
import React, { useEffect, useMemo, useState } from 'react';
|
import React, { Suspense, useEffect, useMemo, useState } from 'react';
|
||||||
import { useAtomValue } from 'jotai';
|
import { useAtomValue } from 'jotai';
|
||||||
import { settingsAtom } from '../../state/settings';
|
import { settingsAtom } from '../../state/settings';
|
||||||
import { useReducedMotion } from '../../hooks/useReducedMotion';
|
import { useReducedMotion } from '../../hooks/useReducedMotion';
|
||||||
import { zIndices } from '../../styles/zIndex';
|
import { zIndices } from '../../styles/zIndex';
|
||||||
import { SeasonTheme } from './types';
|
import { SeasonTheme, SeasonalOverlayProps } from './types';
|
||||||
import { resolveSeasonTheme } from './seasonSchedule';
|
import { resolveSeasonTheme } from './seasonSchedule';
|
||||||
import { HalloweenOverlay } from './themes/Halloween';
|
|
||||||
import { ChristmasOverlay } from './themes/Christmas';
|
// [Gitea #167] Each overlay (its particles + keyframes) is its own chunk,
|
||||||
import { NewYearOverlay } from './themes/NewYear';
|
// fetched only when that season is active or previewed in Settings — the
|
||||||
import { AutumnOverlay } from './themes/Autumn';
|
// date/override decision stays in the main bundle.
|
||||||
import { AprilFoolsOverlay } from './themes/AprilFools';
|
const lazyOverlay = (load: () => Promise<{ default: React.ComponentType<SeasonalOverlayProps> }>) =>
|
||||||
import { LunarNewYearOverlay } from './themes/LunarNewYear';
|
React.lazy(load);
|
||||||
import { ValentinesOverlay } from './themes/Valentines';
|
const HalloweenOverlay = lazyOverlay(() =>
|
||||||
import { StPatricksOverlay } from './themes/StPatricks';
|
import('./themes/Halloween').then((m) => ({ default: m.HalloweenOverlay })),
|
||||||
import { EarthDayOverlay } from './themes/EarthDay';
|
);
|
||||||
import { DeepSpaceOverlay } from './themes/DeepSpace';
|
const ChristmasOverlay = lazyOverlay(() =>
|
||||||
import { ArcadeOverlay } from './themes/Arcade';
|
import('./themes/Christmas').then((m) => ({ default: m.ChristmasOverlay })),
|
||||||
|
);
|
||||||
|
const NewYearOverlay = lazyOverlay(() =>
|
||||||
|
import('./themes/NewYear').then((m) => ({ default: m.NewYearOverlay })),
|
||||||
|
);
|
||||||
|
const AutumnOverlay = lazyOverlay(() =>
|
||||||
|
import('./themes/Autumn').then((m) => ({ default: m.AutumnOverlay })),
|
||||||
|
);
|
||||||
|
const AprilFoolsOverlay = lazyOverlay(() =>
|
||||||
|
import('./themes/AprilFools').then((m) => ({ default: m.AprilFoolsOverlay })),
|
||||||
|
);
|
||||||
|
const LunarNewYearOverlay = lazyOverlay(() =>
|
||||||
|
import('./themes/LunarNewYear').then((m) => ({ default: m.LunarNewYearOverlay })),
|
||||||
|
);
|
||||||
|
const ValentinesOverlay = lazyOverlay(() =>
|
||||||
|
import('./themes/Valentines').then((m) => ({ default: m.ValentinesOverlay })),
|
||||||
|
);
|
||||||
|
const StPatricksOverlay = lazyOverlay(() =>
|
||||||
|
import('./themes/StPatricks').then((m) => ({ default: m.StPatricksOverlay })),
|
||||||
|
);
|
||||||
|
const EarthDayOverlay = lazyOverlay(() =>
|
||||||
|
import('./themes/EarthDay').then((m) => ({ default: m.EarthDayOverlay })),
|
||||||
|
);
|
||||||
|
const DeepSpaceOverlay = lazyOverlay(() =>
|
||||||
|
import('./themes/DeepSpace').then((m) => ({ default: m.DeepSpaceOverlay })),
|
||||||
|
);
|
||||||
|
const ArcadeOverlay = lazyOverlay(() =>
|
||||||
|
import('./themes/Arcade').then((m) => ({ default: m.ArcadeOverlay })),
|
||||||
|
);
|
||||||
|
|
||||||
// SeasonTheme + the date-window logic now live in leaf modules (single source
|
// SeasonTheme + the date-window logic now live in leaf modules (single source
|
||||||
// of truth, shared with the settings UI). Re-exported here for existing
|
// of truth, shared with the settings UI). Re-exported here for existing
|
||||||
@@ -24,16 +52,20 @@ export type { SeasonTheme };
|
|||||||
|
|
||||||
// ─── Overlay content map (shared between SeasonalOverlay and SeasonalPreview) ──
|
// ─── Overlay content map (shared between SeasonalOverlay and SeasonalPreview) ──
|
||||||
|
|
||||||
function buildOverlayContent(theme: SeasonTheme, reduced: boolean): React.ReactNode {
|
function buildOverlayContent(
|
||||||
|
theme: SeasonTheme,
|
||||||
|
reduced: boolean,
|
||||||
|
preview = false,
|
||||||
|
): React.ReactNode {
|
||||||
switch (theme) {
|
switch (theme) {
|
||||||
case 'halloween':
|
case 'halloween':
|
||||||
return <HalloweenOverlay reduced={reduced} />;
|
return <HalloweenOverlay reduced={reduced} preview={preview} />;
|
||||||
case 'christmas':
|
case 'christmas':
|
||||||
return <ChristmasOverlay reduced={reduced} />;
|
return <ChristmasOverlay reduced={reduced} />;
|
||||||
case 'newyear':
|
case 'newyear':
|
||||||
return <NewYearOverlay reduced={reduced} />;
|
return <NewYearOverlay reduced={reduced} />;
|
||||||
case 'autumn':
|
case 'autumn':
|
||||||
return <AutumnOverlay reduced={reduced} />;
|
return <AutumnOverlay reduced={reduced} preview={preview} />;
|
||||||
case 'aprilfools':
|
case 'aprilfools':
|
||||||
return <AprilFoolsOverlay reduced={reduced} />;
|
return <AprilFoolsOverlay reduced={reduced} />;
|
||||||
case 'lunar':
|
case 'lunar':
|
||||||
@@ -69,7 +101,7 @@ function SeasonalOverlay({ theme, reduced }: { theme: SeasonTheme; reduced: bool
|
|||||||
overflow: 'hidden',
|
overflow: 'hidden',
|
||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
{buildOverlayContent(theme, reduced)}
|
<Suspense fallback={null}>{buildOverlayContent(theme, reduced)}</Suspense>
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
@@ -94,7 +126,7 @@ export function SeasonalPreview({ theme }: { theme: SeasonTheme }) {
|
|||||||
containerType: 'inline-size',
|
containerType: 'inline-size',
|
||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
{buildOverlayContent(theme, true)}
|
<Suspense fallback={null}>{buildOverlayContent(theme, true, true)}</Suspense>
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,35 +1,23 @@
|
|||||||
import { keyframes } from '@vanilla-extract/css';
|
import { keyframes, style } from '@vanilla-extract/css';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Autumn overlay keyframes. Every animation touches ONLY `transform` and
|
* Autumn overlay keyframes. Every animation touches ONLY `transform` and
|
||||||
* `opacity` so the compositor can run them on the GPU without triggering
|
* `opacity` so the compositor can run them without layout or paint.
|
||||||
* layout or paint. keyframes() returns the generated animation-name string,
|
|
||||||
* which is applied inline in Autumn.tsx.
|
|
||||||
*
|
|
||||||
* Motion philosophy: warm, slow, cozy. Leaves tumble and rotate as they fall
|
|
||||||
* with a per-leaf sway decoupled on a wrapper; sun shafts breathe; dust motes
|
|
||||||
* drift up through the light; the whole frame has a barely-there warm pulse.
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* A leaf falls from above to below the viewport while continuously rotating.
|
* A leaf falls from above to below the viewport while slowly turning. One tall
|
||||||
* A single tall translateY serves every leaf — per-leaf duration/delay/scale
|
* translateY serves every leaf; per-leaf duration/delay/size give parallax.
|
||||||
* create the parallax variety. Horizontal travel is intentionally small here
|
|
||||||
* because the real lateral motion comes from the sway wrapper below.
|
|
||||||
*/
|
*/
|
||||||
export const animLeafFall = keyframes({
|
export const animLeafFall = keyframes({
|
||||||
'0%': { transform: 'translate3d(0, -12vh, 0) rotate(-30deg)', opacity: '0' },
|
'0%': { transform: 'translate3d(0, -12vh, 0) rotate(-30deg)', opacity: '0' },
|
||||||
'8%': { opacity: '1' },
|
'6%': { opacity: '1' },
|
||||||
'50%': { transform: 'translate3d(10px, 50vh, 0) rotate(200deg)' },
|
'50%': { transform: 'translate3d(10px, 50vh, 0) rotate(160deg)' },
|
||||||
'92%': { opacity: '0.85' },
|
'94%': { opacity: '0.9' },
|
||||||
'100%': { transform: 'translate3d(-6px, 114vh, 0) rotate(430deg)', opacity: '0' },
|
'100%': { transform: 'translate3d(-6px, 114vh, 0) rotate(340deg)', opacity: '0' },
|
||||||
});
|
});
|
||||||
|
|
||||||
/**
|
/** Lateral sway on the leaf's wrapper so the descent reads as wind. */
|
||||||
* Lateral sway applied to a leaf's wrapper so the descent reads as wind
|
|
||||||
* catching the blade. Decoupled from the fall so the two compose into an
|
|
||||||
* organic, non-repeating-looking path.
|
|
||||||
*/
|
|
||||||
export const animLeafSway = keyframes({
|
export const animLeafSway = keyframes({
|
||||||
'0%': { transform: 'translate3d(0, 0, 0)' },
|
'0%': { transform: 'translate3d(0, 0, 0)' },
|
||||||
'50%': { transform: 'translate3d(34px, 0, 0)' },
|
'50%': { transform: 'translate3d(34px, 0, 0)' },
|
||||||
@@ -37,55 +25,40 @@ export const animLeafSway = keyframes({
|
|||||||
});
|
});
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* A second flutter on the leaf's inner shape: a gentle skew/scale wobble that
|
* Soft flutter on the blade. [#237] Gentler than before (scaleX 0.82 made
|
||||||
* mimics the blade catching air as it spins. Cheap, transform-only.
|
* leaves flatten into slivers mid-flip).
|
||||||
*/
|
*/
|
||||||
export const animLeafFlutter = keyframes({
|
export const animLeafFlutter = keyframes({
|
||||||
'0%': { transform: 'rotate(-8deg) scaleX(1)' },
|
'0%': { transform: 'rotate(-10deg) scaleX(1)' },
|
||||||
'50%': { transform: 'rotate(8deg) scaleX(0.82)' },
|
'50%': { transform: 'rotate(10deg) scaleX(0.92)' },
|
||||||
'100%': { transform: 'rotate(-8deg) scaleX(1)' },
|
'100%': { transform: 'rotate(-10deg) scaleX(1)' },
|
||||||
});
|
});
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Low-sun light shaft: a long soft beam slowly slides and breathes. Uses
|
* [#237] A gust: the leaf enters from the left, is blown across and up while
|
||||||
* translateX + opacity (never background-position) so it stays on the
|
* spinning, and leaves on the right in ~6 s (14 % of a 42 s cycle). The rest
|
||||||
* compositor. Scale on Y makes the beam subtly elongate as it brightens.
|
* of the cycle it waits off-screen, invisible.
|
||||||
*/
|
*/
|
||||||
export const animSunShaft = keyframes({
|
export const animGust = keyframes({
|
||||||
'0%': { transform: 'translate3d(-4%, 0, 0) scaleY(1)', opacity: '0.4' },
|
'0%': { transform: 'translate3d(-12vw, 0, 0) rotate(0deg)', opacity: '0' },
|
||||||
'50%': { transform: 'translate3d(4%, 0, 0) scaleY(1.06)', opacity: '0.75' },
|
'1%': { opacity: '1' },
|
||||||
'100%': { transform: 'translate3d(-4%, 0, 0) scaleY(1)', opacity: '0.4' },
|
// Fast in, then carried steadily across and up (linear timing: an eased
|
||||||
|
// curve would apply per segment and stop the leaves mid-air).
|
||||||
|
'3.5%': { transform: 'translate3d(22vw, -3vh, 0) rotate(200deg)' },
|
||||||
|
'8%': { transform: 'translate3d(62vw, -12vh, 0) rotate(420deg)' },
|
||||||
|
'12.5%': { opacity: '1' },
|
||||||
|
'14%': { transform: 'translate3d(112vw, -24vh, 0) rotate(700deg)', opacity: '0' },
|
||||||
|
'100%': { transform: 'translate3d(112vw, -24vh, 0) rotate(700deg)', opacity: '0' },
|
||||||
});
|
});
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Dust / pollen mote: a tiny speck drifts upward through the light, swaying,
|
* Leaf blade. On the dark themes the crimson/russet leaves sank into the
|
||||||
* pulsing softly in brightness as it catches the sun. transform + opacity.
|
* background, so they are lifted there.
|
||||||
*/
|
*/
|
||||||
export const animMoteDrift = keyframes({
|
export const leafBlade = style({
|
||||||
'0%': { transform: 'translate3d(0, 0, 0) scale(0.7)', opacity: '0' },
|
selectors: {
|
||||||
'15%': { opacity: '0.85' },
|
'body.dark-theme &, body.butter-theme &': {
|
||||||
'40%': { transform: 'translate3d(16px, -30vh, 0) scale(1)' },
|
filter: 'brightness(1.6) saturate(1.2)',
|
||||||
'70%': { transform: 'translate3d(-12px, -58vh, 0) scale(0.85)', opacity: '0.6' },
|
},
|
||||||
'90%': { opacity: '0.2' },
|
},
|
||||||
'100%': { transform: 'translate3d(10px, -84vh, 0) scale(0.6)', opacity: '0' },
|
|
||||||
});
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Independent twinkle for motes — a brightness flicker layered on the drift so
|
|
||||||
* specks shimmer as if turning in the light. Opacity only.
|
|
||||||
*/
|
|
||||||
export const animMoteTwinkle = keyframes({
|
|
||||||
'0%': { opacity: '0.5' },
|
|
||||||
'50%': { opacity: '1' },
|
|
||||||
'100%': { opacity: '0.5' },
|
|
||||||
});
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Barely-there breathing of the warm vignette frame so the static tint feels
|
|
||||||
* alive without any distracting motion. Opacity only.
|
|
||||||
*/
|
|
||||||
export const animEmberPulse = keyframes({
|
|
||||||
'0%': { opacity: '0.82' },
|
|
||||||
'50%': { opacity: '1' },
|
|
||||||
'100%': { opacity: '0.82' },
|
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -1,97 +1,108 @@
|
|||||||
import React, { useMemo } from 'react';
|
import React, { useMemo } from 'react';
|
||||||
import { SeasonalOverlayProps } from '../types';
|
import { SeasonalOverlayProps } from '../types';
|
||||||
import {
|
import { animGust, animLeafFall, animLeafFlutter, animLeafSway, leafBlade } from './Autumn.css';
|
||||||
animLeafFall,
|
|
||||||
animLeafSway,
|
|
||||||
animLeafFlutter,
|
|
||||||
animSunShaft,
|
|
||||||
animMoteDrift,
|
|
||||||
animMoteTwinkle,
|
|
||||||
animEmberPulse,
|
|
||||||
} from './Autumn.css';
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* AutumnOverlay — warm falling leaves.
|
* AutumnOverlay — falling leaves over the app as it is.
|
||||||
*
|
*
|
||||||
* A full-screen, pointer-events:none ambient decoration. The parent supplies a
|
* A full-screen, pointer-events:none ambient decoration. The parent supplies a
|
||||||
* fixed inset:0 overflow:hidden pointer-events:none container at the correct
|
* fixed inset:0 overflow:hidden pointer-events:none container at the correct
|
||||||
* z-index, so this component only returns absolutely-positioned aria-hidden
|
* z-index, so this component only returns absolutely-positioned aria-hidden
|
||||||
* children and never sets position:fixed / z-index / pointer-events.
|
* children and never sets position:fixed / z-index / pointer-events.
|
||||||
*
|
*
|
||||||
* Composition (back to front):
|
* [#237] Deliberately no full-screen tint, light shafts or vignette: they
|
||||||
* 1. amber -> rust ambient gradient wash (cozy low-sun atmosphere)
|
* turned the user's theme beige (muddy brown on dark) and lowered contrast
|
||||||
* 2. soft angled sun shafts breathing high across the scene
|
* everywhere. The leaves carry the season on their own.
|
||||||
* 3. drifting pollen / dust motes catching the light
|
|
||||||
* 4. maple & oak leaf silhouettes tumbling and rotating as they fall
|
|
||||||
* 5. a warm low-saturation vignette that frames + protects text contrast
|
|
||||||
*
|
*
|
||||||
* All motion is transform/opacity only (compositor-friendly). When `reduced`
|
* Composition:
|
||||||
* is true we render a static-but-gorgeous scene: a handful of leaves at rest,
|
* 1. maple / oak / aspen leaves drifting down with sway and a soft flutter
|
||||||
* still sun shafts, and the warm vignette — no `animation` anywhere. The
|
* 2. every ~42 s a gust: a small group of leaves blows across the screen
|
||||||
* settings preview always passes reduced=true, so the still form stands alone.
|
* All motion is transform/opacity only. When `reduced` is true: a few leaves
|
||||||
|
* at rest in empty parts of the layout, no animation, no gust. The settings
|
||||||
|
* preview always passes reduced=true, so the still form stands alone.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
// Warm autumn palette in oklch. Kept low-saturation enough to never fight the
|
// [#237] A real autumn palette: [body, tip highlight, vein]. The previous
|
||||||
// chat text underneath. Each leaf picks a tone for variety.
|
// muted tans read as beige smudges on the light theme.
|
||||||
const LEAF_TONES = [
|
const LEAF_TONES: [string, string, string][] = [
|
||||||
'oklch(0.75 0.15 70)', // amber
|
['oklch(0.56 0.19 30)', 'oklch(0.68 0.17 45)', 'oklch(0.38 0.12 28)'], // crimson
|
||||||
'oklch(0.55 0.16 40)', // rust
|
['oklch(0.68 0.17 52)', 'oklch(0.8 0.15 75)', 'oklch(0.45 0.12 45)'], // pumpkin orange
|
||||||
'oklch(0.82 0.13 85)', // warm gold
|
['oklch(0.76 0.15 80)', 'oklch(0.85 0.13 92)', 'oklch(0.52 0.1 65)'], // gold
|
||||||
'oklch(0.62 0.16 55)', // burnt orange
|
['oklch(0.5 0.1 50)', 'oklch(0.62 0.11 60)', 'oklch(0.34 0.06 45)'], // russet brown
|
||||||
'oklch(0.5 0.14 35)', // deep ember
|
['oklch(0.62 0.18 40)', 'oklch(0.74 0.16 60)', 'oklch(0.42 0.12 35)'], // burnt orange
|
||||||
];
|
];
|
||||||
|
|
||||||
// Two leaf silhouettes as inline SVG path data (no external assets, CSP-safe).
|
type LeafKind = 'maple' | 'oak' | 'aspen';
|
||||||
// `maple` = classic five-lobed maple; `oak` = rounded-lobe oak blade.
|
|
||||||
const MAPLE_PATH =
|
|
||||||
'M50 4 L57 30 L78 18 L66 40 L92 40 L70 52 L84 74 L58 62 L56 92 L50 70 ' +
|
|
||||||
'L44 92 L42 62 L16 74 L30 52 L8 40 L34 40 L22 18 L43 30 Z';
|
|
||||||
const OAK_PATH =
|
|
||||||
'M50 4 C58 14 56 22 64 24 C74 22 74 32 68 36 C78 38 76 48 68 50 ' +
|
|
||||||
'C78 54 74 64 66 64 C70 74 60 78 54 72 C54 84 50 96 50 96 ' +
|
|
||||||
'C50 96 46 84 46 72 C40 78 30 74 34 64 C26 64 22 54 32 50 ' +
|
|
||||||
'C24 48 22 38 32 36 C26 32 26 22 36 24 C44 22 42 14 50 4 Z';
|
|
||||||
|
|
||||||
/** Build a CSS-ready data-URI of a single tinted leaf silhouette. */
|
// Leaf silhouettes (viewBox 0 0 100 100, stem at the bottom). The maple is the
|
||||||
function leafDataUri(kind: 'maple' | 'oak', fill: string): string {
|
// flag-style silhouette on purpose: its bold lobes stay recognisable at 30 px,
|
||||||
const path = kind === 'maple' ? MAPLE_PATH : OAK_PATH;
|
// where the previous star-like outline read as a splat.
|
||||||
// A faint vein line gives the blade depth without extra DOM nodes.
|
const LEAF_SHAPES: Record<LeafKind, { body: string; veins: string }> = {
|
||||||
|
maple: {
|
||||||
|
body:
|
||||||
|
'M50 5 L54 20 L62 14 L60 30 L74 22 L70 36 L86 34 L78 46 L90 52 L74 56 L78 66 ' +
|
||||||
|
'L60 62 L56 72 L52 64 L52 94 L48 94 L48 64 L44 72 L40 62 L22 66 L26 56 L10 52 ' +
|
||||||
|
'L22 46 L14 34 L30 36 L26 22 L40 30 L38 14 L46 20 Z',
|
||||||
|
veins: 'M50 66 L50 14 M50 58 L80 40 M50 58 L20 40 M50 64 L70 60 M50 64 L30 60',
|
||||||
|
},
|
||||||
|
oak: {
|
||||||
|
body:
|
||||||
|
'M50 4 C58 14 56 22 64 24 C74 22 74 32 68 36 C78 38 76 48 68 50 ' +
|
||||||
|
'C78 54 74 64 66 64 C70 74 60 78 54 72 C54 80 52 86 52 96 L48 96 ' +
|
||||||
|
'C48 86 46 80 46 72 C40 78 30 74 34 64 C26 64 22 54 32 50 ' +
|
||||||
|
'C24 48 22 38 32 36 C26 32 26 22 36 24 C44 22 42 14 50 4 Z',
|
||||||
|
veins:
|
||||||
|
'M50 76 L50 12 M50 34 L64 28 M50 34 L36 28 M50 50 L66 44 M50 50 L34 44 M50 64 L62 60 M50 64 L38 60',
|
||||||
|
},
|
||||||
|
aspen: {
|
||||||
|
body: 'M50 8 C74 22 80 54 52 84 L52 96 L48 96 L48 84 C20 54 26 22 50 8 Z',
|
||||||
|
veins: 'M50 84 L50 16 M50 40 L64 32 M50 40 L36 32 M50 58 L66 50 M50 58 L34 50',
|
||||||
|
},
|
||||||
|
};
|
||||||
|
|
||||||
|
/** Build a CSS-ready data-URI of one leaf: gradient body, darker veins. */
|
||||||
|
function leafDataUri(kind: LeafKind, [body, tip, vein]: [string, string, string]): string {
|
||||||
|
const shape = LEAF_SHAPES[kind];
|
||||||
const svg =
|
const svg =
|
||||||
`<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 100 100'>` +
|
`<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 100 100'>` +
|
||||||
`<path d='${path}' fill='${fill}' fill-opacity='0.92'/>` +
|
`<defs><linearGradient id='g' x1='0' y1='1' x2='0.4' y2='0'>` +
|
||||||
`<path d='M50 96 L50 24' stroke='oklch(0.42 0.12 38)' stroke-opacity='0.35' ` +
|
`<stop offset='0' stop-color='${body}'/><stop offset='1' stop-color='${tip}'/>` +
|
||||||
`stroke-width='2.5' fill='none' stroke-linecap='round'/>` +
|
`</linearGradient></defs>` +
|
||||||
|
`<path d='${shape.body}' fill='url(#g)'/>` +
|
||||||
|
`<path d='${shape.veins}' stroke='${vein}' stroke-opacity='0.7' stroke-width='2' ` +
|
||||||
|
`fill='none' stroke-linecap='round'/>` +
|
||||||
`</svg>`;
|
`</svg>`;
|
||||||
return `url("data:image/svg+xml,${encodeURIComponent(svg)}")`;
|
return `url("data:image/svg+xml,${encodeURIComponent(svg)}")`;
|
||||||
}
|
}
|
||||||
|
|
||||||
type Leaf = {
|
type Leaf = {
|
||||||
kind: 'maple' | 'oak';
|
|
||||||
uri: string;
|
uri: string;
|
||||||
left: number; // vw column
|
left: number;
|
||||||
size: number; // px
|
size: number;
|
||||||
duration: number; // s — fall time
|
duration: number; // s — fall time
|
||||||
delay: number; // s
|
delay: number; // s
|
||||||
swayDuration: number; // s — wrapper sway
|
swayDuration: number;
|
||||||
flutterDuration: number; // s — inner flutter
|
flutterDuration: number;
|
||||||
tilt: number; // deg — resting rotation (used for static scene)
|
|
||||||
opacity: number;
|
opacity: number;
|
||||||
};
|
};
|
||||||
|
|
||||||
type Mote = {
|
type GustLeaf = {
|
||||||
left: number;
|
uri: string;
|
||||||
bottom: number;
|
top: number; // % of height where it enters
|
||||||
size: number;
|
size: number;
|
||||||
duration: number;
|
delay: number; // s within the gust
|
||||||
delay: number;
|
|
||||||
twinkle: number;
|
|
||||||
opacity: number;
|
opacity: number;
|
||||||
};
|
};
|
||||||
|
|
||||||
// A few hand-placed leaves at rest for the reduced/static scene — arranged so
|
/** Seconds between gusts, and when the first one comes after load. */
|
||||||
// they read as "settled" near edges and corners, never over the busy center.
|
const GUST_PERIOD = 42;
|
||||||
|
const GUST_FIRST = 8;
|
||||||
|
|
||||||
|
// Leaves at rest for the reduced/static scene, in areas that are empty in the
|
||||||
|
// layout (middle of the left icon rail, the space under the member list),
|
||||||
|
// partly off-edge — never on the sidebar, members, composer or controls.
|
||||||
const RESTING_LEAVES: ReadonlyArray<{
|
const RESTING_LEAVES: ReadonlyArray<{
|
||||||
kind: 'maple' | 'oak';
|
kind: LeafKind;
|
||||||
left: number;
|
left: number;
|
||||||
top: number;
|
top: number;
|
||||||
size: number;
|
size: number;
|
||||||
@@ -99,212 +110,198 @@ const RESTING_LEAVES: ReadonlyArray<{
|
|||||||
tone: number;
|
tone: number;
|
||||||
opacity: number;
|
opacity: number;
|
||||||
}> = [
|
}> = [
|
||||||
{ kind: 'maple', left: 6, top: 14, size: 46, tilt: -22, tone: 0, opacity: 0.4 },
|
{ kind: 'maple', left: 0.5, top: 44, size: 60, tilt: 24, tone: 0, opacity: 0.62 },
|
||||||
{ kind: 'oak', left: 88, top: 22, size: 38, tilt: 28, tone: 1, opacity: 0.34 },
|
{ kind: 'aspen', left: 1.5, top: 54, size: 44, tilt: -30, tone: 2, opacity: 0.6 },
|
||||||
{ kind: 'maple', left: 16, top: 78, size: 54, tilt: 16, tone: 3, opacity: 0.42 },
|
{ kind: 'oak', left: 99, top: 62, size: 54, tilt: 160, tone: 3, opacity: 0.6 },
|
||||||
{ kind: 'oak', left: 80, top: 82, size: 44, tilt: -34, tone: 4, opacity: 0.36 },
|
{ kind: 'maple', left: 97.5, top: 72, size: 46, tilt: 200, tone: 4, opacity: 0.6 },
|
||||||
{ kind: 'maple', left: 50, top: 90, size: 40, tilt: 8, tone: 2, opacity: 0.32 },
|
|
||||||
{ kind: 'oak', left: 70, top: 8, size: 32, tilt: -12, tone: 2, opacity: 0.3 },
|
|
||||||
];
|
];
|
||||||
|
|
||||||
export function AutumnOverlay({ reduced }: SeasonalOverlayProps) {
|
// Composition for the Settings swatch (sizes are % of the tile width).
|
||||||
// Deterministic pseudo-random field, computed ONCE. No per-frame state.
|
const PREVIEW_LEAVES: ReadonlyArray<{
|
||||||
const { leaves, motes } = useMemo(() => {
|
kind: LeafKind;
|
||||||
const LEAF_COUNT = 16;
|
left: number;
|
||||||
const MOTE_COUNT = 12;
|
top: number;
|
||||||
|
size: number;
|
||||||
|
tilt: number;
|
||||||
|
tone: number;
|
||||||
|
}> = [
|
||||||
|
{ kind: 'maple', left: 30, top: 38, size: 42, tilt: -18, tone: 0 },
|
||||||
|
{ kind: 'oak', left: 70, top: 30, size: 30, tilt: 34, tone: 3 },
|
||||||
|
{ kind: 'aspen', left: 62, top: 70, size: 30, tilt: -60, tone: 2 },
|
||||||
|
{ kind: 'maple', left: 86, top: 80, size: 24, tilt: 20, tone: 1 },
|
||||||
|
{ kind: 'maple', left: 12, top: 82, size: 20, tilt: 40, tone: 4 },
|
||||||
|
];
|
||||||
|
|
||||||
const builtLeaves: Leaf[] = Array.from({ length: LEAF_COUNT }, (_, i) => {
|
export function AutumnOverlay({ reduced, preview }: SeasonalOverlayProps) {
|
||||||
const kind: 'maple' | 'oak' = i % 3 === 0 ? 'oak' : 'maple';
|
// Deterministic field, computed ONCE. No per-frame state.
|
||||||
const tone = LEAF_TONES[i % LEAF_TONES.length];
|
const { leaves, gust } = useMemo(() => {
|
||||||
const sizeBucket = i % 4; // 0..3 → depth bucket for parallax
|
const kinds = ['maple', 'oak', 'maple', 'aspen'] as const;
|
||||||
const size = 22 + sizeBucket * 9; // 22..49 px
|
const builtLeaves: Leaf[] = Array.from({ length: 12 }, (_, i) => {
|
||||||
|
const depth = i % 4; // 0..3 → parallax bucket
|
||||||
return {
|
return {
|
||||||
kind,
|
uri: leafDataUri(kinds[i % 4], LEAF_TONES[i % LEAF_TONES.length]),
|
||||||
uri: leafDataUri(kind, tone),
|
left: (i * 8.3 + 4) % 100,
|
||||||
left: (i * 6.13 + 4) % 100,
|
size: 28 + depth * 8, // 28..52 px
|
||||||
size,
|
// Nearer leaves fall a touch faster; all slow and calm.
|
||||||
// Larger (nearer) leaves fall a touch faster; all slow + cozy.
|
duration: 16 - depth * 1.6 + (i % 3) * 1.3,
|
||||||
duration: 16 - sizeBucket * 1.6 + (i % 3) * 1.3,
|
delay: -((i * 1.37) % 16), // negative → already mid-fall on load
|
||||||
delay: -((i * 1.37) % 16), // negative → staggered, already mid-fall
|
|
||||||
swayDuration: 5 + (i % 5) * 0.8,
|
swayDuration: 5 + (i % 5) * 0.8,
|
||||||
flutterDuration: 1.6 + (i % 4) * 0.45,
|
flutterDuration: 2 + (i % 4) * 0.5,
|
||||||
tilt: ((i * 53) % 70) - 35,
|
// Nearer → bolder. Small, moving and semi-transparent, so text under a
|
||||||
opacity: 0.34 + sizeBucket * 0.08, // nearer → slightly bolder
|
// passing leaf stays readable.
|
||||||
|
opacity: 0.58 + depth * 0.05,
|
||||||
};
|
};
|
||||||
});
|
});
|
||||||
|
const builtGust: GustLeaf[] = Array.from({ length: 5 }, (_, i) => ({
|
||||||
const builtMotes: Mote[] = Array.from({ length: MOTE_COUNT }, (_, i) => ({
|
uri: leafDataUri(kinds[(i + 1) % 4], LEAF_TONES[(i * 2) % LEAF_TONES.length]),
|
||||||
left: (i * 8.7 + 5) % 100,
|
top: 30 + ((i * 13) % 40),
|
||||||
bottom: (i * 4.3) % 30, // start in lower third, drift up
|
size: 30 + (i % 3) * 10,
|
||||||
size: 2 + (i % 3),
|
delay: GUST_FIRST + i * 0.35,
|
||||||
duration: 16 + (i % 6) * 2.4,
|
opacity: 0.7,
|
||||||
delay: -((i * 2.1) % 16),
|
|
||||||
twinkle: 2.2 + (i % 4) * 0.6,
|
|
||||||
opacity: 0.4 + (i % 3) * 0.12,
|
|
||||||
}));
|
}));
|
||||||
|
return { leaves: builtLeaves, gust: builtGust };
|
||||||
return { leaves: builtLeaves, motes: builtMotes };
|
|
||||||
}, []);
|
}, []);
|
||||||
|
|
||||||
return (
|
if (preview) {
|
||||||
<>
|
// The Settings swatch: a warm backdrop (fine inside the tile, unlike over
|
||||||
{/* 1. Ambient amber → rust atmospheric wash. Layered oklch gradients give
|
// the app) with a few leaves arranged across it.
|
||||||
depth: a warm low-sun glow from the upper-left, a rust pool at the
|
return (
|
||||||
base, and a faint gold core. Kept very low opacity. */}
|
<>
|
||||||
<div
|
|
||||||
aria-hidden="true"
|
|
||||||
style={{
|
|
||||||
position: 'absolute',
|
|
||||||
inset: 0,
|
|
||||||
backgroundImage: [
|
|
||||||
'radial-gradient(120% 90% at 18% 8%, oklch(0.82 0.13 85 / 0.16) 0%, transparent 55%)',
|
|
||||||
'radial-gradient(130% 100% at 50% 118%, oklch(0.55 0.16 40 / 0.18) 0%, transparent 60%)',
|
|
||||||
'linear-gradient(180deg, oklch(0.75 0.15 70 / 0.07) 0%, transparent 40%, oklch(0.5 0.14 35 / 0.08) 100%)',
|
|
||||||
].join(','),
|
|
||||||
contain: 'layout paint style',
|
|
||||||
}}
|
|
||||||
/>
|
|
||||||
|
|
||||||
{/* 2. Soft angled low-sun light shafts. Two long beams skewed to suggest
|
|
||||||
late-afternoon light raking across the room. */}
|
|
||||||
{[
|
|
||||||
{ left: -8, rotate: 18, w: 38, opacity: 0.5, dur: 17, delay: 0 },
|
|
||||||
{ left: 46, rotate: 14, w: 30, opacity: 0.38, dur: 22, delay: -6 },
|
|
||||||
{ left: 78, rotate: 22, w: 26, opacity: 0.32, dur: 19, delay: -11 },
|
|
||||||
].map((shaft, i) => (
|
|
||||||
<div
|
<div
|
||||||
key={`shaft-${i}`}
|
|
||||||
aria-hidden="true"
|
aria-hidden="true"
|
||||||
style={{
|
style={{
|
||||||
position: 'absolute',
|
position: 'absolute',
|
||||||
top: '-30%',
|
inset: 0,
|
||||||
left: `${shaft.left}%`,
|
background:
|
||||||
width: `${shaft.w}vw`,
|
'linear-gradient(160deg, oklch(0.42 0.09 55) 0%, oklch(0.32 0.08 40) 60%, oklch(0.24 0.06 35) 100%)',
|
||||||
height: '160%',
|
|
||||||
transformOrigin: 'top center',
|
|
||||||
transform: `rotate(${shaft.rotate}deg)`,
|
|
||||||
backgroundImage:
|
|
||||||
'linear-gradient(90deg, transparent 0%, oklch(0.85 0.12 82 / 0.5) 50%, transparent 100%)',
|
|
||||||
filter: 'blur(14px)',
|
|
||||||
mixBlendMode: 'screen',
|
|
||||||
opacity: reduced ? shaft.opacity * 0.85 : undefined,
|
|
||||||
willChange: reduced ? undefined : 'transform, opacity',
|
|
||||||
contain: 'layout paint style',
|
|
||||||
animation: reduced
|
|
||||||
? 'none'
|
|
||||||
: `${animSunShaft} ${shaft.dur}s ease-in-out ${shaft.delay}s infinite`,
|
|
||||||
}}
|
}}
|
||||||
/>
|
/>
|
||||||
))}
|
{PREVIEW_LEAVES.map((leaf, i) => (
|
||||||
|
|
||||||
{/* 3. Drifting pollen / dust motes catching the light. Static scene omits
|
|
||||||
them — stillness reads cleaner at rest. */}
|
|
||||||
{!reduced &&
|
|
||||||
motes.map((m, i) => (
|
|
||||||
<div
|
<div
|
||||||
key={`mote-${i}`}
|
key={`pv-${i}`}
|
||||||
aria-hidden="true"
|
aria-hidden="true"
|
||||||
style={{
|
style={{
|
||||||
position: 'absolute',
|
position: 'absolute',
|
||||||
left: `${m.left}%`,
|
left: `${leaf.left}%`,
|
||||||
bottom: `${m.bottom}%`,
|
top: `${leaf.top}%`,
|
||||||
width: `${m.size}px`,
|
width: `${leaf.size}%`,
|
||||||
height: `${m.size}px`,
|
aspectRatio: '1',
|
||||||
|
backgroundImage: leafDataUri(leaf.kind, LEAF_TONES[leaf.tone]),
|
||||||
|
backgroundSize: 'contain',
|
||||||
|
backgroundRepeat: 'no-repeat',
|
||||||
|
transform: `translate(-50%, -50%) rotate(${leaf.tilt}deg)`,
|
||||||
|
filter: 'brightness(1.25)',
|
||||||
|
}}
|
||||||
|
/>
|
||||||
|
))}
|
||||||
|
</>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (reduced) {
|
||||||
|
// Phones have no icon rail and the timeline runs edge to edge, so the
|
||||||
|
// resting leaves tuck further off-edge and smaller there.
|
||||||
|
const narrow = typeof window !== 'undefined' && window.matchMedia('(max-width: 750px)').matches;
|
||||||
|
return (
|
||||||
|
<>
|
||||||
|
{RESTING_LEAVES.map((leaf, i) => (
|
||||||
|
<div
|
||||||
|
key={`rest-${i}`}
|
||||||
|
aria-hidden="true"
|
||||||
|
className={leafBlade}
|
||||||
|
style={{
|
||||||
|
position: 'absolute',
|
||||||
|
left: narrow ? `${leaf.left < 50 ? -2 : 102}%` : `${leaf.left}%`,
|
||||||
|
top: `${leaf.top}%`,
|
||||||
|
width: `${narrow ? leaf.size * 0.8 : leaf.size}px`,
|
||||||
|
height: `${narrow ? leaf.size * 0.8 : leaf.size}px`,
|
||||||
|
backgroundImage: leafDataUri(leaf.kind, LEAF_TONES[leaf.tone]),
|
||||||
|
backgroundSize: 'contain',
|
||||||
|
backgroundRepeat: 'no-repeat',
|
||||||
|
transform: `translate(-50%, -50%) rotate(${leaf.tilt}deg)`,
|
||||||
|
opacity: leaf.opacity,
|
||||||
|
}}
|
||||||
|
/>
|
||||||
|
))}
|
||||||
|
</>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
return (
|
||||||
|
<>
|
||||||
|
{leaves.map((leaf, i) => (
|
||||||
|
// Sway wrapper: horizontal wind, decoupled from the fall. No `paint`
|
||||||
|
// containment: it would clip the leaf to this box at the top of the
|
||||||
|
// screen, so it would never be drawn once falling (#237).
|
||||||
|
<div
|
||||||
|
key={`leaf-${i}`}
|
||||||
|
aria-hidden="true"
|
||||||
|
style={{
|
||||||
|
position: 'absolute',
|
||||||
|
top: 0,
|
||||||
|
left: `${leaf.left}%`,
|
||||||
|
width: `${leaf.size}px`,
|
||||||
|
height: `${leaf.size}px`,
|
||||||
|
willChange: 'transform',
|
||||||
|
animation: `${animLeafSway} ${leaf.swayDuration}s ease-in-out ${leaf.delay}s infinite`,
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
{/* Fall wrapper: vertical descent + tumble. */}
|
||||||
|
<div
|
||||||
|
style={{
|
||||||
|
width: '100%',
|
||||||
|
height: '100%',
|
||||||
willChange: 'transform, opacity',
|
willChange: 'transform, opacity',
|
||||||
animation: `${animMoteDrift} ${m.duration}s linear ${m.delay}s infinite`,
|
animation: `${animLeafFall} ${leaf.duration}s linear ${leaf.delay}s infinite`,
|
||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
|
{/* The leaf itself, with a soft flutter. */}
|
||||||
<div
|
<div
|
||||||
|
className={leafBlade}
|
||||||
style={{
|
style={{
|
||||||
width: '100%',
|
width: '100%',
|
||||||
height: '100%',
|
height: '100%',
|
||||||
borderRadius: '50%',
|
backgroundImage: leaf.uri,
|
||||||
background:
|
backgroundSize: 'contain',
|
||||||
'radial-gradient(circle, oklch(0.88 0.1 85 / 0.95) 0%, oklch(0.78 0.12 70 / 0.4) 60%, transparent 100%)',
|
backgroundRepeat: 'no-repeat',
|
||||||
opacity: m.opacity,
|
opacity: leaf.opacity,
|
||||||
animation: `${animMoteTwinkle} ${m.twinkle}s ease-in-out infinite`,
|
animation: `${animLeafFlutter} ${leaf.flutterDuration}s ease-in-out infinite`,
|
||||||
}}
|
}}
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
))}
|
</div>
|
||||||
|
))}
|
||||||
|
|
||||||
{/* 4. Falling / resting maple & oak leaves. */}
|
{/* Gust: a handful of leaves blown across the screen together, then a
|
||||||
{reduced
|
long calm. Off-screen (and invisible) the rest of the cycle. */}
|
||||||
? RESTING_LEAVES.map((leaf, i) => (
|
{gust.map((leaf, i) => (
|
||||||
<div
|
<div
|
||||||
key={`rest-${i}`}
|
key={`gust-${i}`}
|
||||||
aria-hidden="true"
|
aria-hidden="true"
|
||||||
style={{
|
style={{
|
||||||
position: 'absolute',
|
position: 'absolute',
|
||||||
left: `${leaf.left}%`,
|
top: `${leaf.top}%`,
|
||||||
top: `${leaf.top}%`,
|
left: 0,
|
||||||
width: `${leaf.size}px`,
|
width: `${leaf.size}px`,
|
||||||
height: `${leaf.size}px`,
|
height: `${leaf.size}px`,
|
||||||
backgroundImage: leafDataUri(leaf.kind, LEAF_TONES[leaf.tone]),
|
opacity: 0,
|
||||||
backgroundSize: 'contain',
|
willChange: 'transform, opacity',
|
||||||
backgroundRepeat: 'no-repeat',
|
animation: `${animGust} ${GUST_PERIOD}s linear ${leaf.delay}s infinite`,
|
||||||
transform: `translate(-50%, -50%) rotate(${leaf.tilt}deg)`,
|
}}
|
||||||
opacity: leaf.opacity,
|
>
|
||||||
filter: 'drop-shadow(0 2px 3px oklch(0.3 0.08 40 / 0.35))',
|
<div
|
||||||
}}
|
className={leafBlade}
|
||||||
/>
|
style={{
|
||||||
))
|
width: '100%',
|
||||||
: leaves.map((leaf, i) => (
|
height: '100%',
|
||||||
// Sway wrapper: horizontal wind motion, decoupled from the fall.
|
backgroundImage: leaf.uri,
|
||||||
<div
|
backgroundSize: 'contain',
|
||||||
key={`leaf-${i}`}
|
backgroundRepeat: 'no-repeat',
|
||||||
aria-hidden="true"
|
opacity: leaf.opacity,
|
||||||
style={{
|
}}
|
||||||
position: 'absolute',
|
/>
|
||||||
top: 0,
|
</div>
|
||||||
left: `${leaf.left}%`,
|
))}
|
||||||
width: `${leaf.size}px`,
|
|
||||||
height: `${leaf.size}px`,
|
|
||||||
willChange: 'transform',
|
|
||||||
contain: 'layout paint style',
|
|
||||||
animation: `${animLeafSway} ${leaf.swayDuration}s ease-in-out ${leaf.delay}s infinite`,
|
|
||||||
}}
|
|
||||||
>
|
|
||||||
{/* Fall wrapper: vertical descent + tumble rotation. */}
|
|
||||||
<div
|
|
||||||
style={{
|
|
||||||
width: '100%',
|
|
||||||
height: '100%',
|
|
||||||
willChange: 'transform, opacity',
|
|
||||||
animation: `${animLeafFall} ${leaf.duration}s linear ${leaf.delay}s infinite`,
|
|
||||||
}}
|
|
||||||
>
|
|
||||||
{/* Inner blade: the actual silhouette + flutter wobble. */}
|
|
||||||
<div
|
|
||||||
style={{
|
|
||||||
width: '100%',
|
|
||||||
height: '100%',
|
|
||||||
backgroundImage: leaf.uri,
|
|
||||||
backgroundSize: 'contain',
|
|
||||||
backgroundRepeat: 'no-repeat',
|
|
||||||
opacity: leaf.opacity,
|
|
||||||
filter: 'drop-shadow(0 1px 2px oklch(0.3 0.08 40 / 0.3))',
|
|
||||||
animation: `${animLeafFlutter} ${leaf.flutterDuration}s ease-in-out infinite`,
|
|
||||||
}}
|
|
||||||
/>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
))}
|
|
||||||
|
|
||||||
{/* 5. Warm low-saturation vignette. Frames the scene and gently darkens
|
|
||||||
edges — protecting central chat text contrast. Breathes faintly. */}
|
|
||||||
<div
|
|
||||||
aria-hidden="true"
|
|
||||||
style={{
|
|
||||||
position: 'absolute',
|
|
||||||
inset: 0,
|
|
||||||
backgroundImage:
|
|
||||||
'radial-gradient(120% 110% at 50% 45%, transparent 52%, oklch(0.38 0.07 45 / 0.14) 82%, oklch(0.3 0.06 40 / 0.22) 100%)',
|
|
||||||
contain: 'layout paint style',
|
|
||||||
opacity: reduced ? 1 : undefined,
|
|
||||||
animation: reduced ? 'none' : `${animEmberPulse} 9s ease-in-out infinite`,
|
|
||||||
}}
|
|
||||||
/>
|
|
||||||
</>
|
</>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,56 +1,146 @@
|
|||||||
import { keyframes } from '@vanilla-extract/css';
|
import { keyframes, style } from '@vanilla-extract/css';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Halloween overlay keyframes. Every animation touches ONLY `transform` and
|
* Halloween overlay styles. Motion is transform/opacity only.
|
||||||
* `opacity` so the compositor can run them on the GPU without layout/paint.
|
*
|
||||||
* keyframes() returns the generated animation-name string, applied inline.
|
* [#239] Colours come from two custom properties set on the overlay root so
|
||||||
|
* the bats/spider stay dark silhouettes on light themes and turn to a pale
|
||||||
|
* dusk-violet on dark themes (a black bat on a black theme is invisible).
|
||||||
*/
|
*/
|
||||||
|
export const halloweenRoot = style({
|
||||||
/** Slow breathing of the sickly moon-glow vignette. */
|
position: 'absolute',
|
||||||
export const animMoonPulse = keyframes({
|
inset: 0,
|
||||||
'0%': { transform: 'scale(1)', opacity: '0.55' },
|
vars: {
|
||||||
'50%': { transform: 'scale(1.06)', opacity: '0.8' },
|
'--hw-ink': 'oklch(0.24 0.04 300)',
|
||||||
'100%': { transform: 'scale(1)', opacity: '0.55' },
|
'--hw-web': 'oklch(0.42 0.02 290 / 0.42)',
|
||||||
|
'--hw-eye': 'oklch(0.72 0.18 55)',
|
||||||
|
},
|
||||||
|
selectors: {
|
||||||
|
'body.dark-theme &, body.butter-theme &': {
|
||||||
|
vars: {
|
||||||
|
'--hw-ink': 'oklch(0.72 0.06 300)',
|
||||||
|
'--hw-web': 'oklch(0.85 0.02 290 / 0.36)',
|
||||||
|
'--hw-eye': 'oklch(0.8 0.17 60)',
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
/** Low fog band: drifts sideways while gently rising and swelling. */
|
/** A bat group crosses the top of the screen in ~9 s, then a long calm. */
|
||||||
export const animFogDrift = keyframes({
|
export const animBatFlight = keyframes({
|
||||||
'0%': { transform: 'translate3d(-12%, 6%, 0) scale(1.1)', opacity: '0' },
|
'0%': { transform: 'translate3d(-10vw, 0, 0)', opacity: '0' },
|
||||||
'15%': { opacity: '0.5' },
|
'1%': { opacity: '1' },
|
||||||
'50%': { transform: 'translate3d(6%, -2%, 0) scale(1.25)', opacity: '0.65' },
|
'29%': { opacity: '1' },
|
||||||
'85%': { opacity: '0.45' },
|
'30%': { transform: 'translate3d(110vw, -6vh, 0)', opacity: '0' },
|
||||||
'100%': { transform: 'translate3d(18%, 4%, 0) scale(1.1)', opacity: '0' },
|
'100%': { transform: 'translate3d(110vw, -6vh, 0)', opacity: '0' },
|
||||||
});
|
});
|
||||||
|
|
||||||
/** A bat flaps slowly across the sky in a shallow arc. */
|
/** Up-and-down bobbing on each bat, so the group doesn't move as one block. */
|
||||||
export const animBatGlide = keyframes({
|
export const animBatBob = keyframes({
|
||||||
'0%': { transform: 'translate3d(-12vw, 8vh, 0) scale(0.9)', opacity: '0' },
|
'0%': { transform: 'translate3d(0, 0, 0)' },
|
||||||
'10%': { opacity: '0.7' },
|
'50%': { transform: 'translate3d(0, 14px, 0)' },
|
||||||
'45%': { transform: 'translate3d(45vw, -4vh, 0) scale(1)' },
|
'100%': { transform: 'translate3d(0, 0, 0)' },
|
||||||
'80%': { transform: 'translate3d(85vw, 6vh, 0) scale(0.95)', opacity: '0.6' },
|
|
||||||
'100%': { transform: 'translate3d(112vw, 2vh, 0) scale(0.9)', opacity: '0' },
|
|
||||||
});
|
});
|
||||||
|
|
||||||
/** The bat's wings beat — fast vertical squash of the wing element. */
|
/** Wing beat: the silhouette squashes vertically around the body. */
|
||||||
export const animWingFlap = keyframes({
|
export const animBatFlap = keyframes({
|
||||||
'0%': { transform: 'scaleY(1) scaleX(1)' },
|
'0%': { transform: 'scaleY(1)' },
|
||||||
'50%': { transform: 'scaleY(0.35) scaleX(1.08)' },
|
'50%': { transform: 'scaleY(0.62)' },
|
||||||
'100%': { transform: 'scaleY(1) scaleX(1)' },
|
'100%': { transform: 'scaleY(1)' },
|
||||||
});
|
});
|
||||||
|
|
||||||
/** Will-o'-wisp ember: floats upward, swaying, pulsing in brightness. */
|
/** The spider bobs on its thread (thread and spider move together). */
|
||||||
export const animEmberFloat = keyframes({
|
export const animSpiderBob = keyframes({
|
||||||
'0%': { transform: 'translate3d(0, 0, 0) scale(0.7)', opacity: '0' },
|
'0%': { transform: 'translate3d(0, 0, 0)' },
|
||||||
'12%': { opacity: '0.85' },
|
'50%': { transform: 'translate3d(0, 18px, 0)' },
|
||||||
'35%': { transform: 'translate3d(14px, -28vh, 0) scale(1)' },
|
'100%': { transform: 'translate3d(0, 0, 0)' },
|
||||||
'65%': { transform: 'translate3d(-12px, -55vh, 0) scale(0.9)', opacity: '0.7' },
|
|
||||||
'90%': { opacity: '0.25' },
|
|
||||||
'100%': { transform: 'translate3d(8px, -82vh, 0) scale(0.6)', opacity: '0' },
|
|
||||||
});
|
});
|
||||||
|
|
||||||
/** Soft twinkle for embers — independent opacity flicker layered on top. */
|
/** A slow sway of the spider itself on the end of the thread. */
|
||||||
export const animEmberTwinkle = keyframes({
|
export const animSpiderSway = keyframes({
|
||||||
'0%': { opacity: '0.6' },
|
'0%': { transform: 'rotate(-6deg)' },
|
||||||
'50%': { opacity: '1' },
|
'50%': { transform: 'rotate(6deg)' },
|
||||||
'100%': { opacity: '0.6' },
|
'100%': { transform: 'rotate(-6deg)' },
|
||||||
|
});
|
||||||
|
|
||||||
|
/**
|
||||||
|
* A small ghost rises from the lower part of the screen, drifting sideways,
|
||||||
|
* and fades out — ~8 s in a 50 s cycle.
|
||||||
|
*/
|
||||||
|
export const animGhost = keyframes({
|
||||||
|
'0%': { transform: 'translate3d(0, 0, 0) scale(0.9)', opacity: '0' },
|
||||||
|
'3%': { opacity: '0.8' },
|
||||||
|
'8%': { transform: 'translate3d(6vw, -20vh, 0) scale(1)' },
|
||||||
|
'13%': { opacity: '0.75' },
|
||||||
|
'16%': { transform: 'translate3d(-2vw, -42vh, 0) scale(1.05)', opacity: '0' },
|
||||||
|
'100%': { transform: 'translate3d(-2vw, -42vh, 0) scale(1.05)', opacity: '0' },
|
||||||
|
});
|
||||||
|
|
||||||
|
/** The ghost's tail wisps, a gentle wobble. */
|
||||||
|
export const animGhostWobble = keyframes({
|
||||||
|
'0%': { transform: 'rotate(-4deg)' },
|
||||||
|
'50%': { transform: 'rotate(4deg)' },
|
||||||
|
'100%': { transform: 'rotate(-4deg)' },
|
||||||
|
});
|
||||||
|
|
||||||
|
/** [#239] Will-o'-the-wisp: a slow wandering loop (paired with a pulse). */
|
||||||
|
export const animWispWander = keyframes({
|
||||||
|
'0%': { transform: 'translate3d(0, 0, 0)' },
|
||||||
|
'25%': { transform: 'translate3d(40px, -30px, 0)' },
|
||||||
|
'50%': { transform: 'translate3d(-10px, -60px, 0)' },
|
||||||
|
'75%': { transform: 'translate3d(-45px, -20px, 0)' },
|
||||||
|
'100%': { transform: 'translate3d(0, 0, 0)' },
|
||||||
|
});
|
||||||
|
|
||||||
|
/** Soft breathing glow of a wisp. */
|
||||||
|
export const animWispPulse = keyframes({
|
||||||
|
'0%': { opacity: '0.35', transform: 'scale(0.85)' },
|
||||||
|
'50%': { opacity: '0.9', transform: 'scale(1.1)' },
|
||||||
|
'100%': { opacity: '0.35', transform: 'scale(0.85)' },
|
||||||
|
});
|
||||||
|
|
||||||
|
/** A witch on a broom crosses high up, right to left, in ~11 s of 60 s. */
|
||||||
|
export const animWitch = keyframes({
|
||||||
|
'0%': { transform: 'translate3d(0, 0, 0) rotate(-4deg)', opacity: '0' },
|
||||||
|
'1%': { opacity: '1' },
|
||||||
|
'9%': { transform: 'translate3d(-60vw, -3vh, 0) rotate(3deg)' },
|
||||||
|
'17.5%': { opacity: '1' },
|
||||||
|
'18%': { transform: 'translate3d(-118vw, 2vh, 0) rotate(-3deg)', opacity: '0' },
|
||||||
|
'100%': { transform: 'translate3d(-118vw, 2vh, 0) rotate(-3deg)', opacity: '0' },
|
||||||
|
});
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The big spider: bobs for most of the cycle, then climbs up its thread,
|
||||||
|
* pauses, and drops back with a little bounce (24 s cycle).
|
||||||
|
*/
|
||||||
|
export const animSpiderClimb = keyframes({
|
||||||
|
'0%': { transform: 'translate3d(0, 0, 0)' },
|
||||||
|
'20%': { transform: 'translate3d(0, 14px, 0)' },
|
||||||
|
'40%': { transform: 'translate3d(0, 0, 0)' },
|
||||||
|
'55%': { transform: 'translate3d(0, -22vh, 0)' },
|
||||||
|
'68%': { transform: 'translate3d(0, -22vh, 0)' },
|
||||||
|
'71%': { transform: 'translate3d(0, 24px, 0)' },
|
||||||
|
'74%': { transform: 'translate3d(0, -8px, 0)' },
|
||||||
|
'77%': { transform: 'translate3d(0, 6px, 0)' },
|
||||||
|
'80%': { transform: 'translate3d(0, 0, 0)' },
|
||||||
|
'100%': { transform: 'translate3d(0, 0, 0)' },
|
||||||
|
});
|
||||||
|
|
||||||
|
/** Jack-o'-lantern candle flicker (opacity of the glow behind the face). */
|
||||||
|
export const animCandle = keyframes({
|
||||||
|
'0%': { opacity: '0.75' },
|
||||||
|
'20%': { opacity: '1' },
|
||||||
|
'35%': { opacity: '0.6' },
|
||||||
|
'55%': { opacity: '0.95' },
|
||||||
|
'70%': { opacity: '0.7' },
|
||||||
|
'100%': { opacity: '0.75' },
|
||||||
|
});
|
||||||
|
|
||||||
|
/** The swarm crosses faster than the regular bats: ~7 s of a 60 s cycle. */
|
||||||
|
export const animSwarmFlight = keyframes({
|
||||||
|
'0%': { transform: 'translate3d(-10vw, 0, 0)', opacity: '0' },
|
||||||
|
'0.5%': { opacity: '1' },
|
||||||
|
'11.5%': { opacity: '1' },
|
||||||
|
'12%': { transform: 'translate3d(110vw, -8vh, 0)', opacity: '0' },
|
||||||
|
'100%': { transform: 'translate3d(110vw, -8vh, 0)', opacity: '0' },
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -1,267 +1,486 @@
|
|||||||
import React, { useMemo } from 'react';
|
import React from 'react';
|
||||||
import { SeasonalOverlayProps } from '../types';
|
import { SeasonalOverlayProps } from '../types';
|
||||||
import {
|
import {
|
||||||
animMoonPulse,
|
animBatBob,
|
||||||
animFogDrift,
|
animBatFlap,
|
||||||
animBatGlide,
|
animBatFlight,
|
||||||
animWingFlap,
|
animCandle,
|
||||||
animEmberFloat,
|
animGhost,
|
||||||
animEmberTwinkle,
|
animGhostWobble,
|
||||||
|
animSpiderBob,
|
||||||
|
animSpiderClimb,
|
||||||
|
animSpiderSway,
|
||||||
|
animSwarmFlight,
|
||||||
|
animWispPulse,
|
||||||
|
animWispWander,
|
||||||
|
animWitch,
|
||||||
|
halloweenRoot,
|
||||||
} from './Halloween.css';
|
} from './Halloween.css';
|
||||||
|
|
||||||
// ─── Palette (oklch) ──────────────────────────────────────────────────────────
|
/**
|
||||||
// Deep haunted indigo, sickly toxic-green moon glow, warm ember orange.
|
* HalloweenOverlay — cobwebs, a dangling spider and bats, over the app as is.
|
||||||
const PURPLE_DEEP = 'oklch(0.20 0.12 300)';
|
*
|
||||||
const PURPLE_FAINT = 'oklch(0.28 0.10 300 / 0.45)';
|
* The parent supplies a fixed inset:0 overflow:hidden pointer-events:none
|
||||||
const TOXIC_GREEN = 'oklch(0.80 0.18 150)';
|
* container; everything here is aria-hidden and absolutely positioned.
|
||||||
const TOXIC_GREEN_SOFT = 'oklch(0.72 0.16 150 / 0.35)';
|
*
|
||||||
const EMBER_ORANGE = 'oklch(0.70 0.18 50)';
|
* [#239] No full-screen purple wash or blurred "moon": they tinted the whole
|
||||||
const FOG_TINT = 'oklch(0.45 0.06 280 / 0.32)';
|
* app and the moon glow sat over the member list, making it unreadable.
|
||||||
|
* Colours are theme-aware via --hw-ink / --hw-web (see Halloween.css.ts).
|
||||||
|
*
|
||||||
|
* Composition:
|
||||||
|
* 1. cobwebs in the two top corners (thin threads, readable in both themes)
|
||||||
|
* 2. a spider on a thread in the empty space under the member list, bobbing
|
||||||
|
* 3. every 30 s a small group of bats flaps across the top of the screen
|
||||||
|
* `reduced`: webs and the spider at rest, no bats flying.
|
||||||
|
* `preview`: a night-sky swatch for Settings.
|
||||||
|
*/
|
||||||
|
|
||||||
// A corner cobweb, drawn once as an inline SVG data-URI (CSP-safe, no assets).
|
/** Corner web (corner at 0,0): radial threads + sagging catch-rings. */
|
||||||
// strokeWidth kept hairline so it reads as gossamer thread, not a cage.
|
function webPath(size = 100): string {
|
||||||
const cobwebUri = (() => {
|
const angles = [0, 16, 32, 48, 64, 80, 90].map((a) => (a * Math.PI) / 180);
|
||||||
const svg =
|
const spokes = angles
|
||||||
`<svg xmlns='http://www.w3.org/2000/svg' width='180' height='180' viewBox='0 0 180 180'>` +
|
.map((a) => `M0 0 L${(Math.cos(a) * size).toFixed(1)} ${(Math.sin(a) * size).toFixed(1)}`)
|
||||||
`<g fill='none' stroke='rgba(196,176,224,0.32)' stroke-width='0.8'>` +
|
.join(' ');
|
||||||
// radial threads
|
const rings = [0.28, 0.48, 0.68, 0.88].map((f) => {
|
||||||
`<line x1='0' y1='0' x2='180' y2='180'/>` +
|
const r = f * size;
|
||||||
`<line x1='0' y1='0' x2='180' y2='90'/>` +
|
const pts = angles.map((a) => [Math.cos(a) * r, Math.sin(a) * r]);
|
||||||
`<line x1='0' y1='0' x2='90' y2='180'/>` +
|
let d = `M${pts[0][0].toFixed(1)} ${pts[0][1].toFixed(1)}`;
|
||||||
`<line x1='0' y1='0' x2='180' y2='40'/>` +
|
for (let i = 1; i < pts.length; i += 1) {
|
||||||
`<line x1='0' y1='0' x2='40' y2='180'/>` +
|
const [x0, y0] = pts[i - 1];
|
||||||
// concentric catch-threads (gentle sag via quadratic curves)
|
const [x1, y1] = pts[i];
|
||||||
`<path d='M40 0 Q22 22 0 40'/>` +
|
// Control point pulled toward the corner so each segment sags.
|
||||||
`<path d='M85 0 Q48 48 0 85'/>` +
|
const cx = ((x0 + x1) / 2) * 0.86;
|
||||||
`<path d='M130 0 Q74 74 0 130'/>` +
|
const cy = ((y0 + y1) / 2) * 0.86;
|
||||||
`<path d='M180 0 Q104 104 0 180'/>` +
|
d += ` Q${cx.toFixed(1)} ${cy.toFixed(1)} ${x1.toFixed(1)} ${y1.toFixed(1)}`;
|
||||||
`<path d='M180 60 Q120 120 60 180'/>` +
|
}
|
||||||
`</g></svg>`;
|
return d;
|
||||||
return `url("data:image/svg+xml;utf8,${encodeURIComponent(svg)}")`;
|
});
|
||||||
})();
|
return `${spokes} ${rings.join(' ')}`;
|
||||||
|
}
|
||||||
|
const WEB = webPath();
|
||||||
|
|
||||||
// A single silhouetted bat, inline SVG. Wings are separate so the wrapper can
|
function Cobweb({ corner, size }: { corner: 'left' | 'right'; size: number }) {
|
||||||
// glide while an inner element flaps independently — we re-use one body shape.
|
|
||||||
function BatSilhouette() {
|
|
||||||
return (
|
return (
|
||||||
<svg
|
<svg
|
||||||
width="46"
|
|
||||||
height="22"
|
|
||||||
viewBox="0 0 46 22"
|
|
||||||
aria-hidden="true"
|
aria-hidden="true"
|
||||||
style={{ display: 'block', overflow: 'visible' }}
|
viewBox="0 0 100 100"
|
||||||
|
width={size}
|
||||||
|
height={size}
|
||||||
|
style={{
|
||||||
|
position: 'absolute',
|
||||||
|
top: 0,
|
||||||
|
[corner]: 0,
|
||||||
|
transform: corner === 'right' ? 'scaleX(-1)' : undefined,
|
||||||
|
overflow: 'visible',
|
||||||
|
}}
|
||||||
>
|
>
|
||||||
<path
|
<path
|
||||||
fill="oklch(0.12 0.04 300 / 0.85)"
|
d={WEB}
|
||||||
d="M23 6c1.6 0 2.7 1.3 3 3 .9-1.4 2.4-2.6 4.2-2.6-.5 1-.4 2.1.2 2.9 2-2.4 5.4-4 8.6-3.7-1.5 1-2.3 2.6-2.4 4.3 1.3-.8 3-1 4.4-.4-2.2.8-3.9 2.5-5.2 4.5-2 3-4.8 5-8.3 4.4-1.9-.3-3.4-1.6-4.5-3.2-1.1 1.6-2.6 2.9-4.5 3.2-3.5.6-6.3-1.4-8.3-4.4-1.3-2-3-3.7-5.2-4.5 1.4-.6 3.1-.4 4.4.4-.1-1.7-.9-3.3-2.4-4.3 3.2-.3 6.6 1.3 8.6 3.7.6-.8.7-1.9.2-2.9 1.8 0 3.3 1.2 4.2 2.6.3-1.7 1.4-3 3-3z"
|
fill="none"
|
||||||
|
stroke="var(--hw-web)"
|
||||||
|
strokeWidth={0.9}
|
||||||
|
strokeLinecap="round"
|
||||||
|
vectorEffect="non-scaling-stroke"
|
||||||
/>
|
/>
|
||||||
</svg>
|
</svg>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
export function HalloweenOverlay({ reduced }: SeasonalOverlayProps) {
|
// Classic bat silhouette, wings spread (viewBox 0 0 100 50).
|
||||||
// Deterministic per-mount generation — never per-frame React state.
|
const BAT_PATH =
|
||||||
const embers = useMemo(
|
'M50 18 L46 10 L45 17 C40 17 36 19 33 23 C28 15 18 11 4 14 C12 18 14 23 12 29 ' +
|
||||||
() =>
|
'C7 27 3 28 0 31 C10 31 17 35 21 42 C25 36 31 34 37 36 C41 41 46 43 50 46 ' +
|
||||||
Array.from({ length: 12 }, (_, i) => {
|
'C54 43 59 41 63 36 C69 34 75 36 79 42 C83 35 90 31 100 31 C97 28 93 27 88 29 ' +
|
||||||
const green = i % 3 === 0; // ~1/3 toxic-green wisps, rest warm embers
|
'C86 23 88 18 96 14 C82 11 72 15 67 23 C64 19 60 17 55 17 L54 10 Z';
|
||||||
return {
|
|
||||||
left: (i * 6151 + 113) % 100,
|
|
||||||
bottom: (i * 3137 + 47) % 28, // start near floor
|
|
||||||
size: 3 + (i % 4),
|
|
||||||
duration: 11 + (i % 6) * 2.2,
|
|
||||||
delay: (i * 0.83) % 11,
|
|
||||||
twinkle: 2.4 + (i % 5) * 0.6,
|
|
||||||
color: green ? TOXIC_GREEN : EMBER_ORANGE,
|
|
||||||
};
|
|
||||||
}),
|
|
||||||
[],
|
|
||||||
);
|
|
||||||
|
|
||||||
const bats = useMemo(
|
|
||||||
() =>
|
|
||||||
Array.from({ length: 3 }, (_, i) => ({
|
|
||||||
top: 8 + i * 13,
|
|
||||||
duration: 22 + i * 7,
|
|
||||||
delay: i * 6.5,
|
|
||||||
flap: 0.5 + i * 0.12,
|
|
||||||
scale: 0.7 + i * 0.18,
|
|
||||||
})),
|
|
||||||
[],
|
|
||||||
);
|
|
||||||
|
|
||||||
const fogBands = useMemo(
|
|
||||||
() =>
|
|
||||||
Array.from({ length: 3 }, (_, i) => ({
|
|
||||||
bottom: -6 + i * 9,
|
|
||||||
duration: 26 + i * 8,
|
|
||||||
delay: i * 5,
|
|
||||||
height: 130 + i * 30,
|
|
||||||
})),
|
|
||||||
[],
|
|
||||||
);
|
|
||||||
|
|
||||||
|
function Bat({ width, flap }: { width: number; flap?: number }) {
|
||||||
return (
|
return (
|
||||||
<>
|
<svg
|
||||||
{/* ── Sky: layered indigo→black gradient with toxic-green moon vignette ── */}
|
aria-hidden="true"
|
||||||
|
viewBox="0 0 100 50"
|
||||||
|
width={width}
|
||||||
|
height={width / 2}
|
||||||
|
style={{
|
||||||
|
display: 'block',
|
||||||
|
transformOrigin: '50% 60%',
|
||||||
|
animation: flap ? `${animBatFlap} ${flap}s ease-in-out infinite` : undefined,
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
<path d={BAT_PATH} fill="var(--hw-ink)" />
|
||||||
|
</svg>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
function Spider({ size }: { size: number }) {
|
||||||
|
const legs = [-1, 1]
|
||||||
|
.flatMap((side) =>
|
||||||
|
[0, 1, 2, 3].map((i) => {
|
||||||
|
const y = 38 + i * 7;
|
||||||
|
const kx = 50 + side * (16 + i * 2);
|
||||||
|
const fx = 50 + side * (30 + (i === 1 || i === 2 ? 6 : 0));
|
||||||
|
const fy = y + (i < 2 ? -8 : 10);
|
||||||
|
return `M${50 + side * 7} ${y} Q${kx} ${y - 12} ${fx} ${fy}`;
|
||||||
|
}),
|
||||||
|
)
|
||||||
|
.join(' ');
|
||||||
|
return (
|
||||||
|
<svg
|
||||||
|
aria-hidden="true"
|
||||||
|
viewBox="0 0 100 100"
|
||||||
|
width={size}
|
||||||
|
height={size}
|
||||||
|
style={{ display: 'block' }}
|
||||||
|
>
|
||||||
|
<path d={legs} fill="none" stroke="var(--hw-ink)" strokeWidth={4} strokeLinecap="round" />
|
||||||
|
<ellipse cx="50" cy="52" rx="13" ry="16" fill="var(--hw-ink)" />
|
||||||
|
<circle cx="50" cy="33" r="8" fill="var(--hw-ink)" />
|
||||||
|
<circle cx="47" cy="32" r="1.8" fill="var(--hw-eye)" />
|
||||||
|
<circle cx="53" cy="32" r="1.8" fill="var(--hw-eye)" />
|
||||||
|
</svg>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
/** Spider hanging from the top edge; thread and body move together. */
|
||||||
|
function HangingSpider({
|
||||||
|
left,
|
||||||
|
length,
|
||||||
|
animate,
|
||||||
|
size = 30,
|
||||||
|
climb = false,
|
||||||
|
}: {
|
||||||
|
left: string;
|
||||||
|
length: string;
|
||||||
|
animate: boolean;
|
||||||
|
size?: number;
|
||||||
|
climb?: boolean;
|
||||||
|
}) {
|
||||||
|
let motion: string | undefined;
|
||||||
|
if (animate) {
|
||||||
|
motion = climb
|
||||||
|
? `${animSpiderClimb} 24s ease-in-out 6s infinite`
|
||||||
|
: `${animSpiderBob} 7s ease-in-out infinite`;
|
||||||
|
}
|
||||||
|
return (
|
||||||
|
<div
|
||||||
|
aria-hidden="true"
|
||||||
|
style={{ position: 'absolute', top: 0, left, width: size, animation: motion }}
|
||||||
|
>
|
||||||
<div
|
<div
|
||||||
aria-hidden="true"
|
|
||||||
style={{
|
style={{
|
||||||
position: 'absolute',
|
marginLeft: size / 2 - 0.5,
|
||||||
inset: 0,
|
width: 1,
|
||||||
contain: 'layout paint style',
|
height: length,
|
||||||
backgroundColor: 'transparent',
|
background: 'var(--hw-web)',
|
||||||
backgroundImage: [
|
|
||||||
// sickly moon glow, upper-right
|
|
||||||
`radial-gradient(38vmax 38vmax at 78% 14%, ${TOXIC_GREEN_SOFT} 0%, transparent 58%)`,
|
|
||||||
// cold counter-glow lower-left for depth
|
|
||||||
`radial-gradient(46vmax 46vmax at 12% 92%, ${PURPLE_FAINT} 0%, transparent 60%)`,
|
|
||||||
// overall indigo→black wash, darker toward edges (vignette)
|
|
||||||
`radial-gradient(120% 120% at 50% 30%, transparent 32%, ${PURPLE_DEEP} 100%)`,
|
|
||||||
`linear-gradient(180deg, ${PURPLE_DEEP} 0%, transparent 45%)`,
|
|
||||||
].join(', '),
|
|
||||||
opacity: 0.5,
|
|
||||||
}}
|
}}
|
||||||
/>
|
/>
|
||||||
|
|
||||||
{/* ── Moon disc + breathing halo (the only backdrop-filter, kept cheap) ── */}
|
|
||||||
<div
|
<div
|
||||||
aria-hidden="true"
|
|
||||||
style={{
|
style={{
|
||||||
position: 'absolute',
|
marginTop: -size * 0.13,
|
||||||
top: '8%',
|
transformOrigin: '50% 0',
|
||||||
right: '12%',
|
animation: animate ? `${animSpiderSway} 5s ease-in-out infinite` : undefined,
|
||||||
width: '160px',
|
|
||||||
height: '160px',
|
|
||||||
borderRadius: '50%',
|
|
||||||
willChange: 'transform, opacity',
|
|
||||||
backgroundImage: `radial-gradient(circle at 42% 40%, ${TOXIC_GREEN} 0%, oklch(0.55 0.14 150 / 0.5) 38%, transparent 72%)`,
|
|
||||||
filter: 'blur(2px)',
|
|
||||||
backdropFilter: 'saturate(1.15)',
|
|
||||||
animation: reduced ? 'none' : `${animMoonPulse} 9s ease-in-out infinite`,
|
|
||||||
}}
|
|
||||||
/>
|
|
||||||
|
|
||||||
{/* ── Low drifting fog bands ── */}
|
|
||||||
<div
|
|
||||||
aria-hidden="true"
|
|
||||||
style={{
|
|
||||||
position: 'absolute',
|
|
||||||
inset: 0,
|
|
||||||
contain: 'layout paint style',
|
|
||||||
overflow: 'hidden',
|
|
||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
{fogBands.map((f, i) => (
|
<Spider size={size} />
|
||||||
<div
|
|
||||||
key={i}
|
|
||||||
aria-hidden="true"
|
|
||||||
style={{
|
|
||||||
position: 'absolute',
|
|
||||||
left: '-15%',
|
|
||||||
right: '-15%',
|
|
||||||
bottom: `${f.bottom}%`,
|
|
||||||
height: `${f.height}px`,
|
|
||||||
backgroundImage: `radial-gradient(60% 100% at 50% 100%, ${FOG_TINT} 0%, transparent 75%)`,
|
|
||||||
filter: 'blur(14px)',
|
|
||||||
willChange: reduced ? undefined : 'transform, opacity',
|
|
||||||
opacity: reduced ? 0.5 : undefined,
|
|
||||||
transform: reduced ? 'translate3d(2%, 0, 0) scale(1.18)' : undefined,
|
|
||||||
animation: reduced
|
|
||||||
? 'none'
|
|
||||||
: `${animFogDrift} ${f.duration}s ease-in-out ${f.delay}s infinite`,
|
|
||||||
}}
|
|
||||||
/>
|
|
||||||
))}
|
|
||||||
</div>
|
</div>
|
||||||
|
</div>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
{/* ── Will-o'-wisps / floating embers ── */}
|
/** Small jack-o'-lantern hanging on a short thread, candle flickering. */
|
||||||
{embers.map((e, i) => (
|
function HangingLantern({ right, length, size }: { right: number; length: number; size: number }) {
|
||||||
|
return (
|
||||||
|
<div aria-hidden="true" style={{ position: 'absolute', top: 0, right, width: size }}>
|
||||||
|
<div
|
||||||
|
style={{
|
||||||
|
marginLeft: size / 2 - 0.5,
|
||||||
|
width: 1,
|
||||||
|
height: length,
|
||||||
|
background: 'var(--hw-web)',
|
||||||
|
}}
|
||||||
|
/>
|
||||||
|
<svg viewBox="0 0 60 56" width={size} height={size * 0.93} style={{ display: 'block' }}>
|
||||||
|
<path
|
||||||
|
d="M30 2 C31 6 33 8 36 9"
|
||||||
|
stroke="oklch(0.45 0.08 140)"
|
||||||
|
strokeWidth="3"
|
||||||
|
fill="none"
|
||||||
|
strokeLinecap="round"
|
||||||
|
/>
|
||||||
|
<path
|
||||||
|
d="M30 10 C18 8 4 16 4 32 C4 46 16 54 30 54 C44 54 56 46 56 32 C56 16 42 8 30 10 Z"
|
||||||
|
fill="oklch(0.66 0.17 50)"
|
||||||
|
/>
|
||||||
|
<path
|
||||||
|
d="M30 11 C24 20 24 44 30 53 M30 11 C36 20 36 44 30 53"
|
||||||
|
stroke="oklch(0.55 0.15 45)"
|
||||||
|
strokeWidth="1.5"
|
||||||
|
fill="none"
|
||||||
|
/>
|
||||||
|
<g style={{ animation: `${animCandle} 1.6s ease-in-out infinite` }}>
|
||||||
|
<path d="M14 26 L22 22 L22 30 Z M46 26 L38 22 L38 30 Z" fill="oklch(0.93 0.14 95)" />
|
||||||
|
<path
|
||||||
|
d="M14 38 C20 46 40 46 46 38 L41 41 L37 38 L33 42 L30 38 L27 42 L23 38 L19 41 Z"
|
||||||
|
fill="oklch(0.93 0.14 95)"
|
||||||
|
/>
|
||||||
|
</g>
|
||||||
|
</svg>
|
||||||
|
</div>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Witch on a broom, flying left (viewBox 0 0 120 60).
|
||||||
|
const WITCH_PATH = [
|
||||||
|
'M4 42 L80 37 L80 40 L4 45 Z', // broom handle
|
||||||
|
'M80 34 C88 32 98 28 108 24 C104 32 106 38 116 46 C104 44 92 42 80 42 Z', // bristles
|
||||||
|
'M32 20 C36 17 50 16 58 19 L55 21 C50 19 40 20 35 22 Z', // hat brim
|
||||||
|
'M40 19 L64 2 L52 19 Z', // hat cone, leaning back
|
||||||
|
'M39 25 A5 5 0 1 0 49 25 A5 5 0 1 0 39 25 Z', // head
|
||||||
|
'M39 24 L34 26 L39 27 Z', // nose
|
||||||
|
'M40 29 C44 28 52 28 56 30 C64 30 72 28 80 24 C76 30 70 34 62 38 L44 38 C40 36 38 32 40 29 Z', // cloak
|
||||||
|
'M42 31 L32 37 L34 39 L44 34 Z', // arm on the broom
|
||||||
|
'M48 38 L44 50 L38 52 L38 54 L47 53 L52 39 Z', // leg and boot
|
||||||
|
].join(' ');
|
||||||
|
|
||||||
|
function Witch({ width }: { width: number }) {
|
||||||
|
return (
|
||||||
|
<svg
|
||||||
|
aria-hidden="true"
|
||||||
|
viewBox="0 0 120 60"
|
||||||
|
width={width}
|
||||||
|
height={width / 2}
|
||||||
|
style={{ display: 'block' }}
|
||||||
|
>
|
||||||
|
<path d={WITCH_PATH} fill="var(--hw-ink)" />
|
||||||
|
</svg>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
const WISPS = [
|
||||||
|
{ left: 12, top: 62, size: 30, hue: 'oklch(0.82 0.19 145)', wander: 26, pulse: 3.2, delay: -3 },
|
||||||
|
{ left: 34, top: 80, size: 24, hue: 'oklch(0.8 0.16 60)', wander: 31, pulse: 2.6, delay: -11 },
|
||||||
|
{ left: 55, top: 48, size: 28, hue: 'oklch(0.82 0.19 145)', wander: 28, pulse: 3.8, delay: -7 },
|
||||||
|
{ left: 72, top: 72, size: 34, hue: 'oklch(0.8 0.16 60)', wander: 34, pulse: 2.9, delay: -19 },
|
||||||
|
{ left: 88, top: 55, size: 24, hue: 'oklch(0.82 0.19 145)', wander: 24, pulse: 3.4, delay: -5 },
|
||||||
|
{ left: 46, top: 30, size: 22, hue: 'oklch(0.8 0.16 60)', wander: 29, pulse: 2.4, delay: -15 },
|
||||||
|
];
|
||||||
|
|
||||||
|
const BAT_PERIOD = 20; // s between flights
|
||||||
|
const BAT_FIRST = 5; // s after load
|
||||||
|
const BATS = [
|
||||||
|
{ top: 9, width: 64, offset: 0, bob: 1.3, flap: 0.3 },
|
||||||
|
{ top: 16, width: 46, offset: 0.5, bob: 1.1, flap: 0.26 },
|
||||||
|
{ top: 6, width: 38, offset: 0.9, bob: 1.5, flap: 0.24 },
|
||||||
|
{ top: 20, width: 54, offset: 1.4, bob: 1.2, flap: 0.28 },
|
||||||
|
];
|
||||||
|
|
||||||
|
// Every 60 s a bigger, faster swarm of small bats, offset from the regular group.
|
||||||
|
const SWARM_PERIOD = 60;
|
||||||
|
const SWARM_FIRST = 38;
|
||||||
|
const SWARM = Array.from({ length: 8 }, (_, i) => ({
|
||||||
|
top: 4 + ((i * 7) % 22),
|
||||||
|
width: 22 + (i % 3) * 8,
|
||||||
|
offset: (i * 0.23) % 1.4,
|
||||||
|
bob: 0.9 + (i % 3) * 0.25,
|
||||||
|
flap: 0.18 + (i % 3) * 0.03,
|
||||||
|
}));
|
||||||
|
|
||||||
|
const WITCH_PERIOD = 60;
|
||||||
|
const WITCH_FIRST = 22;
|
||||||
|
|
||||||
|
const GHOST_PERIOD = 50;
|
||||||
|
const GHOST_FIRST = 16;
|
||||||
|
|
||||||
|
/** A small, friendly ghost: pale body with an ink outline (shows on light). */
|
||||||
|
function Ghost({ size }: { size: number }) {
|
||||||
|
return (
|
||||||
|
<svg
|
||||||
|
aria-hidden="true"
|
||||||
|
viewBox="0 0 60 72"
|
||||||
|
width={size}
|
||||||
|
height={size * 1.2}
|
||||||
|
style={{ display: 'block' }}
|
||||||
|
>
|
||||||
|
<path
|
||||||
|
d="M30 4 C14 4 6 16 6 32 L6 62 L13 55 L20 63 L27 55 L34 63 L41 55 L48 63 L54 56 L54 32 C54 16 46 4 30 4 Z"
|
||||||
|
fill="oklch(0.98 0.01 290 / 0.55)"
|
||||||
|
stroke="var(--hw-ink)"
|
||||||
|
strokeWidth={2}
|
||||||
|
strokeLinejoin="round"
|
||||||
|
/>
|
||||||
|
<ellipse cx="22" cy="28" rx="3.5" ry="5" fill="var(--hw-ink)" />
|
||||||
|
<ellipse cx="38" cy="28" rx="3.5" ry="5" fill="var(--hw-ink)" />
|
||||||
|
<ellipse cx="30" cy="41" rx="4" ry="3" fill="var(--hw-ink)" opacity="0.8" />
|
||||||
|
</svg>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
export function HalloweenOverlay({ reduced, preview }: SeasonalOverlayProps) {
|
||||||
|
// Phones: smaller webs, and a shorter thread so the spider hangs near the top.
|
||||||
|
const narrow = typeof window !== 'undefined' && window.matchMedia('(max-width: 750px)').matches;
|
||||||
|
if (preview) {
|
||||||
|
return (
|
||||||
|
<div className={halloweenRoot} aria-hidden="true">
|
||||||
<div
|
<div
|
||||||
key={i}
|
|
||||||
aria-hidden="true"
|
|
||||||
style={{
|
style={{
|
||||||
position: 'absolute',
|
position: 'absolute',
|
||||||
left: `${e.left}%`,
|
inset: 0,
|
||||||
bottom: `${e.bottom}%`,
|
background:
|
||||||
willChange: reduced ? undefined : 'transform, opacity',
|
'linear-gradient(180deg, oklch(0.22 0.08 300) 0%, oklch(0.16 0.06 290) 70%, oklch(0.12 0.04 280) 100%)',
|
||||||
transform: reduced ? 'scale(0.9)' : undefined,
|
|
||||||
opacity: reduced ? 0.4 : undefined,
|
|
||||||
animation: reduced
|
|
||||||
? 'none'
|
|
||||||
: `${animEmberFloat} ${e.duration}s ease-in ${e.delay}s infinite`,
|
|
||||||
}}
|
}}
|
||||||
>
|
/>
|
||||||
<div
|
{/* Crescent moon */}
|
||||||
aria-hidden="true"
|
<div
|
||||||
style={{
|
style={{
|
||||||
width: `${e.size}px`,
|
position: 'absolute',
|
||||||
height: `${e.size}px`,
|
right: '14%',
|
||||||
borderRadius: '50%',
|
top: '14%',
|
||||||
backgroundColor: e.color,
|
width: '30%',
|
||||||
boxShadow: `0 0 ${e.size * 2.5}px ${e.color}`,
|
aspectRatio: '1',
|
||||||
animation: reduced
|
borderRadius: '50%',
|
||||||
? 'none'
|
boxShadow: 'inset -9px 4px 0 0 oklch(0.93 0.06 95), 0 0 18px oklch(0.9 0.08 95 / 0.35)',
|
||||||
: `${animEmberTwinkle} ${e.twinkle}s ease-in-out infinite`,
|
}}
|
||||||
}}
|
/>
|
||||||
/>
|
{/* The big bat crosses the moon, the classic silhouette. */}
|
||||||
|
<div style={{ position: 'absolute', left: '52%', top: '22%', width: '34%' }}>
|
||||||
|
<svg viewBox="0 0 100 50" style={{ width: '100%' }}>
|
||||||
|
<path d={BAT_PATH} fill="oklch(0.1 0.02 300)" />
|
||||||
|
</svg>
|
||||||
</div>
|
</div>
|
||||||
))}
|
<div style={{ position: 'absolute', left: '26%', top: '56%', width: '20%' }}>
|
||||||
|
<svg viewBox="0 0 100 50" style={{ width: '100%' }}>
|
||||||
|
<path d={BAT_PATH} fill="oklch(0.1 0.02 300)" />
|
||||||
|
</svg>
|
||||||
|
</div>
|
||||||
|
<svg
|
||||||
|
viewBox="0 0 100 100"
|
||||||
|
style={{ position: 'absolute', left: 0, top: 0, width: '42%', overflow: 'visible' }}
|
||||||
|
>
|
||||||
|
<path d={WEB} fill="none" stroke="oklch(0.85 0.02 290 / 0.6)" strokeWidth={1.2} />
|
||||||
|
</svg>
|
||||||
|
</div>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
{/* ── Silhouetted bats gliding across (skip entirely when reduced) ── */}
|
return (
|
||||||
|
<div className={halloweenRoot} aria-hidden="true">
|
||||||
|
<Cobweb corner="left" size={narrow ? 64 : 88} />
|
||||||
|
<Cobweb corner="right" size={narrow ? 76 : 108} />
|
||||||
|
{/* In the empty space under the member list on desktop; near the right
|
||||||
|
edge on narrow screens. */}
|
||||||
|
<HangingSpider
|
||||||
|
left="calc(100% - 64px)"
|
||||||
|
length={narrow ? '22vh' : '50vh'}
|
||||||
|
animate={!reduced}
|
||||||
|
climb
|
||||||
|
/>
|
||||||
|
{/* A second, smaller spider on the left web. */}
|
||||||
|
<HangingSpider
|
||||||
|
left={narrow ? '30px' : '46px'}
|
||||||
|
length={narrow ? '9vh' : '13vh'}
|
||||||
|
animate={!reduced}
|
||||||
|
size={20}
|
||||||
|
/>
|
||||||
|
{!narrow && <HangingLantern right={126} length={30} size={26} />}
|
||||||
|
|
||||||
|
{/* Will-o'-the-wisps: soft glows wandering slowly, always present while
|
||||||
|
animating. Not in the still scene: static glows would sit on text. */}
|
||||||
{!reduced &&
|
{!reduced &&
|
||||||
bats.map((b, i) => (
|
WISPS.map((w, i) => (
|
||||||
<div
|
<div
|
||||||
key={i}
|
key={`wisp-${i}`}
|
||||||
aria-hidden="true"
|
|
||||||
style={{
|
style={{
|
||||||
position: 'absolute',
|
position: 'absolute',
|
||||||
top: `${b.top}%`,
|
left: `${w.left}%`,
|
||||||
left: 0,
|
top: `${w.top}%`,
|
||||||
willChange: 'transform, opacity',
|
animation: `${animWispWander} ${w.wander}s ease-in-out ${w.delay}s infinite`,
|
||||||
animation: `${animBatGlide} ${b.duration}s linear ${b.delay}s infinite`,
|
|
||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
<div
|
<div
|
||||||
aria-hidden="true"
|
|
||||||
style={{
|
style={{
|
||||||
transform: `scale(${b.scale})`,
|
width: w.size,
|
||||||
animation: `${animWingFlap} ${b.flap}s ease-in-out infinite`,
|
height: w.size,
|
||||||
|
borderRadius: '50%',
|
||||||
|
background: `radial-gradient(circle, oklch(0.97 0.05 100) 0%, ${w.hue} 22%, ${w.hue.replace(')', ' / 0.35)')} 48%, transparent 72%)`,
|
||||||
|
animation: `${animWispPulse} ${w.pulse}s ease-in-out ${w.delay}s infinite`,
|
||||||
}}
|
}}
|
||||||
>
|
/>
|
||||||
<BatSilhouette />
|
</div>
|
||||||
|
))}
|
||||||
|
|
||||||
|
{!reduced &&
|
||||||
|
BATS.map((bat, i) => (
|
||||||
|
<div
|
||||||
|
key={`bat-${i}`}
|
||||||
|
style={{
|
||||||
|
position: 'absolute',
|
||||||
|
left: 0,
|
||||||
|
top: `${bat.top}%`,
|
||||||
|
opacity: 0,
|
||||||
|
willChange: 'transform, opacity',
|
||||||
|
animation: `${animBatFlight} ${BAT_PERIOD}s linear ${BAT_FIRST + bat.offset}s infinite`,
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
<div style={{ animation: `${animBatBob} ${bat.bob}s ease-in-out infinite` }}>
|
||||||
|
<Bat width={bat.width} flap={bat.flap} />
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
))}
|
))}
|
||||||
|
|
||||||
{/* ── Cobwebs tucked into two corners (top-left, top-right mirrored) ── */}
|
{!reduced &&
|
||||||
<div
|
SWARM.map((bat, i) => (
|
||||||
aria-hidden="true"
|
<div
|
||||||
style={{
|
key={`swarm-${i}`}
|
||||||
position: 'absolute',
|
style={{
|
||||||
top: 0,
|
position: 'absolute',
|
||||||
left: 0,
|
left: 0,
|
||||||
width: '180px',
|
top: `${bat.top}%`,
|
||||||
height: '180px',
|
opacity: 0,
|
||||||
backgroundImage: cobwebUri,
|
willChange: 'transform, opacity',
|
||||||
backgroundRepeat: 'no-repeat',
|
animation: `${animSwarmFlight} ${SWARM_PERIOD}s linear ${SWARM_FIRST + bat.offset}s infinite`,
|
||||||
opacity: 0.7,
|
}}
|
||||||
}}
|
>
|
||||||
/>
|
<div style={{ animation: `${animBatBob} ${bat.bob}s ease-in-out infinite` }}>
|
||||||
<div
|
<Bat width={bat.width} flap={bat.flap} />
|
||||||
aria-hidden="true"
|
</div>
|
||||||
style={{
|
</div>
|
||||||
position: 'absolute',
|
))}
|
||||||
top: 0,
|
|
||||||
right: 0,
|
{!reduced && (
|
||||||
width: '180px',
|
<div
|
||||||
height: '180px',
|
style={{
|
||||||
backgroundImage: cobwebUri,
|
position: 'absolute',
|
||||||
backgroundRepeat: 'no-repeat',
|
right: '-14vw',
|
||||||
transform: 'scaleX(-1)',
|
top: narrow ? '11%' : '12%',
|
||||||
opacity: 0.7,
|
opacity: 0,
|
||||||
}}
|
willChange: 'transform, opacity',
|
||||||
/>
|
animation: `${animWitch} ${WITCH_PERIOD}s linear ${WITCH_FIRST}s infinite`,
|
||||||
</>
|
}}
|
||||||
|
>
|
||||||
|
<Witch width={narrow ? 84 : 120} />
|
||||||
|
</div>
|
||||||
|
)}
|
||||||
|
|
||||||
|
{!reduced && (
|
||||||
|
<div
|
||||||
|
style={{
|
||||||
|
position: 'absolute',
|
||||||
|
left: '18%',
|
||||||
|
top: '78%',
|
||||||
|
opacity: 0,
|
||||||
|
willChange: 'transform, opacity',
|
||||||
|
animation: `${animGhost} ${GHOST_PERIOD}s linear ${GHOST_FIRST}s infinite`,
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
<div
|
||||||
|
style={{
|
||||||
|
transformOrigin: '50% 20%',
|
||||||
|
animation: `${animGhostWobble} 2.4s ease-in-out infinite`,
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
<Ghost size={narrow ? 34 : 44} />
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
)}
|
||||||
|
</div>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -21,4 +21,9 @@ export type SeasonTheme =
|
|||||||
// passes reduced=true, so the static form has to stand on its own.
|
// passes reduced=true, so the static form has to stand on its own.
|
||||||
export type SeasonalOverlayProps = {
|
export type SeasonalOverlayProps = {
|
||||||
reduced: boolean;
|
reduced: boolean;
|
||||||
|
/**
|
||||||
|
* Rendering in the small Settings swatch rather than over the app. Optional:
|
||||||
|
* a theme may draw a composition made for the tile (always also `reduced`).
|
||||||
|
*/
|
||||||
|
preview?: boolean;
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
import React, { ReactNode } from 'react';
|
import React, { ReactNode, useEffect, useId, useRef } from 'react';
|
||||||
import { Box, Text } from 'folds';
|
import { Box, Text } from 'folds';
|
||||||
import { BreakWord } from '../../styles/Text.css';
|
import { BreakWord } from '../../styles/Text.css';
|
||||||
|
|
||||||
@@ -10,12 +10,35 @@ type SettingTileProps = {
|
|||||||
children?: ReactNode;
|
children?: ReactNode;
|
||||||
};
|
};
|
||||||
export function SettingTile({ title, description, before, after, children }: SettingTileProps) {
|
export function SettingTile({ title, description, before, after, children }: SettingTileProps) {
|
||||||
|
const titleId = useId();
|
||||||
|
const afterRef = useRef<HTMLDivElement>(null);
|
||||||
|
|
||||||
|
// [Gitea #185] The control in `after` is almost always an icon-only Switch
|
||||||
|
// (or a bare select/input) whose only visible label is this tile's title.
|
||||||
|
// Point it at the title so screen readers announce "Show Notifications,
|
||||||
|
// switch, on" instead of "switch, on". Explicit labels are left alone.
|
||||||
|
useEffect(() => {
|
||||||
|
if (!title || !afterRef.current) return;
|
||||||
|
afterRef.current
|
||||||
|
.querySelectorAll<HTMLElement>('[role="switch"], input, select, textarea, [role="combobox"]')
|
||||||
|
.forEach((el) => {
|
||||||
|
if (el.hasAttribute('aria-label') || el.hasAttribute('aria-labelledby')) return;
|
||||||
|
if (
|
||||||
|
el.tagName === 'INPUT' &&
|
||||||
|
el.id &&
|
||||||
|
afterRef.current?.querySelector(`label[for="${el.id}"]`)
|
||||||
|
)
|
||||||
|
return;
|
||||||
|
el.setAttribute('aria-labelledby', titleId);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<Box alignItems="Center" gap="300">
|
<Box alignItems="Center" gap="300">
|
||||||
{before && <Box shrink="No">{before}</Box>}
|
{before && <Box shrink="No">{before}</Box>}
|
||||||
<Box grow="Yes" direction="Column" gap="100">
|
<Box grow="Yes" direction="Column" gap="100">
|
||||||
{title && (
|
{title && (
|
||||||
<Text className={BreakWord} size="T300">
|
<Text id={titleId} className={BreakWord} size="T300">
|
||||||
{title}
|
{title}
|
||||||
</Text>
|
</Text>
|
||||||
)}
|
)}
|
||||||
@@ -26,7 +49,11 @@ export function SettingTile({ title, description, before, after, children }: Set
|
|||||||
)}
|
)}
|
||||||
{children}
|
{children}
|
||||||
</Box>
|
</Box>
|
||||||
{after && <Box shrink="No">{after}</Box>}
|
{after && (
|
||||||
|
<Box shrink="No" ref={afterRef}>
|
||||||
|
{after}
|
||||||
|
</Box>
|
||||||
|
)}
|
||||||
</Box>
|
</Box>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,133 @@
|
|||||||
|
import React, { MouseEvent, ReactNode, useState } from 'react';
|
||||||
|
import FocusTrap from 'focus-trap-react';
|
||||||
|
import {
|
||||||
|
Box,
|
||||||
|
Button,
|
||||||
|
Dialog,
|
||||||
|
Header,
|
||||||
|
Icon,
|
||||||
|
IconButton,
|
||||||
|
Icons,
|
||||||
|
Overlay,
|
||||||
|
OverlayBackdrop,
|
||||||
|
OverlayCenter,
|
||||||
|
Text,
|
||||||
|
color,
|
||||||
|
config,
|
||||||
|
} from 'folds';
|
||||||
|
import { stopPropagation } from '../../utils/keyboard';
|
||||||
|
import { LinkSafety } from '../../utils/linkSafety';
|
||||||
|
|
||||||
|
type SuspiciousLinkProps = {
|
||||||
|
href: string;
|
||||||
|
safety: LinkSafety;
|
||||||
|
anchorProps: Record<string, unknown>;
|
||||||
|
children: ReactNode;
|
||||||
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* [Gitea #122] A link whose visible text names a different site than its
|
||||||
|
* destination (or whose destination is a punycode host) opens a small
|
||||||
|
* confirm instead of navigating straight away. Honest links never see this.
|
||||||
|
*/
|
||||||
|
export function SuspiciousLink({ href, safety, anchorProps, children }: SuspiciousLinkProps) {
|
||||||
|
const [open, setOpen] = useState(false);
|
||||||
|
|
||||||
|
const handleClick = (evt: MouseEvent) => {
|
||||||
|
evt.preventDefault();
|
||||||
|
evt.stopPropagation();
|
||||||
|
setOpen(true);
|
||||||
|
};
|
||||||
|
const proceed = () => {
|
||||||
|
setOpen(false);
|
||||||
|
window.open(href, '_blank', 'noopener,noreferrer');
|
||||||
|
};
|
||||||
|
|
||||||
|
return (
|
||||||
|
<>
|
||||||
|
<a
|
||||||
|
{...anchorProps}
|
||||||
|
href={href}
|
||||||
|
onClick={handleClick}
|
||||||
|
data-lotus-suspicious-link
|
||||||
|
title={`Goes to ${safety.realHost}`}
|
||||||
|
>
|
||||||
|
{children}
|
||||||
|
</a>
|
||||||
|
{open && (
|
||||||
|
<Overlay open backdrop={<OverlayBackdrop />}>
|
||||||
|
<OverlayCenter>
|
||||||
|
<FocusTrap
|
||||||
|
focusTrapOptions={{
|
||||||
|
fallbackFocus: '#suspiciouslink-dialog-1',
|
||||||
|
onDeactivate: () => setOpen(false),
|
||||||
|
clickOutsideDeactivates: true,
|
||||||
|
escapeDeactivates: stopPropagation,
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
<Dialog
|
||||||
|
id="suspiciouslink-dialog-1"
|
||||||
|
role="dialog"
|
||||||
|
aria-modal="true"
|
||||||
|
aria-labelledby="suspiciouslink-dialog-1-title"
|
||||||
|
tabIndex={-1}
|
||||||
|
variant="Surface"
|
||||||
|
style={{ maxWidth: 440 }}
|
||||||
|
>
|
||||||
|
<Header
|
||||||
|
style={{
|
||||||
|
padding: `0 ${config.space.S200} 0 ${config.space.S400}`,
|
||||||
|
borderBottomWidth: config.borderWidth.B300,
|
||||||
|
}}
|
||||||
|
variant="Surface"
|
||||||
|
size="500"
|
||||||
|
>
|
||||||
|
<Box grow="Yes">
|
||||||
|
<Text id="suspiciouslink-dialog-1-title" as="h2" size="H4">
|
||||||
|
This link doesn't go where it says
|
||||||
|
</Text>
|
||||||
|
</Box>
|
||||||
|
<IconButton
|
||||||
|
size="300"
|
||||||
|
onClick={() => setOpen(false)}
|
||||||
|
radii="300"
|
||||||
|
aria-label="Close"
|
||||||
|
>
|
||||||
|
<Icon src={Icons.Cross} />
|
||||||
|
</IconButton>
|
||||||
|
</Header>
|
||||||
|
<Box style={{ padding: config.space.S400 }} direction="Column" gap="400">
|
||||||
|
<Text>
|
||||||
|
{safety.shownHost ? (
|
||||||
|
<>
|
||||||
|
It shows <b>{safety.shownHost}</b> but goes to{' '}
|
||||||
|
<b style={{ color: color.Critical.Main }}>{safety.realHost}</b>.
|
||||||
|
</>
|
||||||
|
) : (
|
||||||
|
<>
|
||||||
|
It goes to <b style={{ color: color.Critical.Main }}>{safety.realHost}</b>.
|
||||||
|
</>
|
||||||
|
)}
|
||||||
|
{safety.punycode &&
|
||||||
|
' The destination uses look-alike (internationalised) characters in its name.'}
|
||||||
|
</Text>
|
||||||
|
<Text size="T200" priority="300" style={{ wordBreak: 'break-all' }}>
|
||||||
|
{href}
|
||||||
|
</Text>
|
||||||
|
<Box gap="200" justifyContent="End">
|
||||||
|
<Button variant="Secondary" fill="Soft" onClick={() => setOpen(false)}>
|
||||||
|
<Text size="B400">Cancel</Text>
|
||||||
|
</Button>
|
||||||
|
<Button variant="Critical" onClick={proceed}>
|
||||||
|
<Text size="B400">Open anyway</Text>
|
||||||
|
</Button>
|
||||||
|
</Box>
|
||||||
|
</Box>
|
||||||
|
</Dialog>
|
||||||
|
</FocusTrap>
|
||||||
|
</OverlayCenter>
|
||||||
|
</Overlay>
|
||||||
|
)}
|
||||||
|
</>
|
||||||
|
);
|
||||||
|
}
|
||||||
@@ -0,0 +1 @@
|
|||||||
|
export * from './SuspiciousLink';
|
||||||
@@ -0,0 +1,75 @@
|
|||||||
|
import React, { useEffect, useRef } from 'react';
|
||||||
|
import { Box, Button, Icon, IconButton, Icons, Text, color, config, toRem } from 'folds';
|
||||||
|
|
||||||
|
type TapToSendBarProps = {
|
||||||
|
previewUrl?: string;
|
||||||
|
label: string;
|
||||||
|
onSend: () => void;
|
||||||
|
onCancel: () => void;
|
||||||
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* [Gitea #147] Fat-finger guard for touch screens: the first tap on a sticker
|
||||||
|
* or GIF parks it here with a preview; "Send" (or a second tap on the same
|
||||||
|
* item) sends it.
|
||||||
|
*/
|
||||||
|
export function TapToSendBar({ previewUrl, label, onSend, onCancel }: TapToSendBarProps) {
|
||||||
|
const liveRef = useRef<HTMLDivElement>(null);
|
||||||
|
useEffect(() => {
|
||||||
|
liveRef.current?.focus?.();
|
||||||
|
}, [label]);
|
||||||
|
|
||||||
|
return (
|
||||||
|
<Box
|
||||||
|
ref={liveRef}
|
||||||
|
role="status"
|
||||||
|
aria-live="polite"
|
||||||
|
tabIndex={-1}
|
||||||
|
shrink="No"
|
||||||
|
alignItems="Center"
|
||||||
|
gap="300"
|
||||||
|
style={{
|
||||||
|
margin: `0 ${config.space.S300} ${config.space.S200}`,
|
||||||
|
padding: config.space.S200,
|
||||||
|
borderRadius: config.radii.R400,
|
||||||
|
backgroundColor: color.SurfaceVariant.Container,
|
||||||
|
color: color.SurfaceVariant.OnContainer,
|
||||||
|
outline: 'none',
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
{previewUrl && (
|
||||||
|
<img
|
||||||
|
src={previewUrl}
|
||||||
|
alt=""
|
||||||
|
style={{
|
||||||
|
width: toRem(40),
|
||||||
|
height: toRem(40),
|
||||||
|
objectFit: 'contain',
|
||||||
|
borderRadius: config.radii.R300,
|
||||||
|
flexShrink: 0,
|
||||||
|
}}
|
||||||
|
/>
|
||||||
|
)}
|
||||||
|
<Box grow="Yes" direction="Column" style={{ minWidth: 0 }}>
|
||||||
|
<Text size="T200" priority="300">
|
||||||
|
Tap again to send
|
||||||
|
</Text>
|
||||||
|
<Text size="T300" truncate>
|
||||||
|
{label}
|
||||||
|
</Text>
|
||||||
|
</Box>
|
||||||
|
<Button size="300" variant="Primary" fill="Solid" radii="300" onClick={onSend}>
|
||||||
|
<Text size="B300">Send</Text>
|
||||||
|
</Button>
|
||||||
|
<IconButton
|
||||||
|
size="300"
|
||||||
|
variant="SurfaceVariant"
|
||||||
|
radii="300"
|
||||||
|
onClick={onCancel}
|
||||||
|
aria-label="Cancel"
|
||||||
|
>
|
||||||
|
<Icon size="100" src={Icons.Cross} />
|
||||||
|
</IconButton>
|
||||||
|
</Box>
|
||||||
|
);
|
||||||
|
}
|
||||||
@@ -15,10 +15,16 @@ function DummyErrorDialog({
|
|||||||
onCancel: () => void;
|
onCancel: () => void;
|
||||||
}) {
|
}) {
|
||||||
return (
|
return (
|
||||||
<Dialog>
|
<Dialog
|
||||||
|
id="dummystage-dialog-1"
|
||||||
|
role="dialog"
|
||||||
|
aria-modal="true"
|
||||||
|
aria-labelledby="dummystage-dialog-1-title"
|
||||||
|
tabIndex={-1}
|
||||||
|
>
|
||||||
<Box style={{ padding: config.space.S400 }} direction="Column" gap="400">
|
<Box style={{ padding: config.space.S400 }} direction="Column" gap="400">
|
||||||
<Box direction="Column" gap="100">
|
<Box direction="Column" gap="100">
|
||||||
<Text as="h2" size="H4">
|
<Text id="dummystage-dialog-1-title" as="h2" size="H4">
|
||||||
{title}
|
{title}
|
||||||
</Text>
|
</Text>
|
||||||
<Text>{message}</Text>
|
<Text>{message}</Text>
|
||||||
|
|||||||
@@ -28,7 +28,13 @@ function EmailErrorDialog({
|
|||||||
};
|
};
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<Dialog>
|
<Dialog
|
||||||
|
id="emailstage-dialog-1"
|
||||||
|
role="dialog"
|
||||||
|
aria-modal="true"
|
||||||
|
aria-labelledby="emailstage-dialog-1-title"
|
||||||
|
tabIndex={-1}
|
||||||
|
>
|
||||||
<Box
|
<Box
|
||||||
as="form"
|
as="form"
|
||||||
onSubmit={handleFormSubmit}
|
onSubmit={handleFormSubmit}
|
||||||
@@ -37,7 +43,7 @@ function EmailErrorDialog({
|
|||||||
gap="400"
|
gap="400"
|
||||||
>
|
>
|
||||||
<Box direction="Column" gap="100">
|
<Box direction="Column" gap="100">
|
||||||
<Text as="h2" size="H4">
|
<Text id="emailstage-dialog-1-title" as="h2" size="H4">
|
||||||
{title}
|
{title}
|
||||||
</Text>
|
</Text>
|
||||||
<Text>{message}</Text>
|
<Text>{message}</Text>
|
||||||
@@ -145,10 +151,16 @@ export function EmailStageDialog({
|
|||||||
|
|
||||||
if (emailTokenState.status === AsyncStatus.Success) {
|
if (emailTokenState.status === AsyncStatus.Success) {
|
||||||
return (
|
return (
|
||||||
<Dialog>
|
<Dialog
|
||||||
|
id="emailstage-dialog-2"
|
||||||
|
role="dialog"
|
||||||
|
aria-modal="true"
|
||||||
|
aria-labelledby="emailstage-dialog-2-title"
|
||||||
|
tabIndex={-1}
|
||||||
|
>
|
||||||
<Box style={{ padding: config.space.S400 }} direction="Column" gap="400">
|
<Box style={{ padding: config.space.S400 }} direction="Column" gap="400">
|
||||||
<Box direction="Column" gap="100">
|
<Box direction="Column" gap="100">
|
||||||
<Text as="h2" size="H4">
|
<Text id="emailstage-dialog-2-title" as="h2" size="H4">
|
||||||
Verification Request Sent
|
Verification Request Sent
|
||||||
</Text>
|
</Text>
|
||||||
<Text>{`Please check your email "${emailTokenState.data.email}" and validate before continuing further.`}</Text>
|
<Text>{`Please check your email "${emailTokenState.data.email}" and validate before continuing further.`}</Text>
|
||||||
|
|||||||
@@ -36,7 +36,13 @@ export function PasswordStage({
|
|||||||
};
|
};
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<Dialog>
|
<Dialog
|
||||||
|
id="passwordstage-dialog-1"
|
||||||
|
role="dialog"
|
||||||
|
aria-modal="true"
|
||||||
|
aria-labelledby="passwordstage-dialog-1-title"
|
||||||
|
tabIndex={-1}
|
||||||
|
>
|
||||||
<Header
|
<Header
|
||||||
style={{
|
style={{
|
||||||
padding: `0 ${config.space.S200} 0 ${config.space.S400}`,
|
padding: `0 ${config.space.S200} 0 ${config.space.S400}`,
|
||||||
@@ -45,7 +51,7 @@ export function PasswordStage({
|
|||||||
size="500"
|
size="500"
|
||||||
>
|
>
|
||||||
<Box grow="Yes">
|
<Box grow="Yes">
|
||||||
<Text as="h2" size="H4">
|
<Text id="passwordstage-dialog-1-title" as="h2" size="H4">
|
||||||
{t('Organisms.PasswordStage.account_password')}
|
{t('Organisms.PasswordStage.account_password')}
|
||||||
</Text>
|
</Text>
|
||||||
</Box>
|
</Box>
|
||||||
|
|||||||
@@ -14,10 +14,18 @@ function ReCaptchaErrorDialog({
|
|||||||
onCancel: () => void;
|
onCancel: () => void;
|
||||||
}) {
|
}) {
|
||||||
return (
|
return (
|
||||||
<Dialog>
|
<Dialog
|
||||||
|
id="recaptchastage-dialog-1"
|
||||||
|
role="dialog"
|
||||||
|
aria-modal="true"
|
||||||
|
aria-labelledby="recaptchastage-dialog-1-title"
|
||||||
|
tabIndex={-1}
|
||||||
|
>
|
||||||
<Box style={{ padding: config.space.S400 }} direction="Column" gap="400">
|
<Box style={{ padding: config.space.S400 }} direction="Column" gap="400">
|
||||||
<Box direction="Column" gap="100">
|
<Box direction="Column" gap="100">
|
||||||
<Text size="H4">{title}</Text>
|
<Text id="recaptchastage-dialog-1-title" size="H4">
|
||||||
|
{title}
|
||||||
|
</Text>
|
||||||
<Text>{message}</Text>
|
<Text>{message}</Text>
|
||||||
</Box>
|
</Box>
|
||||||
<Button variant="Critical" fill="None" outlined onClick={onCancel}>
|
<Button variant="Critical" fill="None" outlined onClick={onCancel}>
|
||||||
|
|||||||
@@ -26,7 +26,13 @@ function RegistrationTokenErrorDialog({
|
|||||||
};
|
};
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<Dialog>
|
<Dialog
|
||||||
|
id="registrationtokenstage-dialog-1"
|
||||||
|
role="dialog"
|
||||||
|
aria-modal="true"
|
||||||
|
aria-labelledby="registrationtokenstage-dialog-1-title"
|
||||||
|
tabIndex={-1}
|
||||||
|
>
|
||||||
<Box
|
<Box
|
||||||
as="form"
|
as="form"
|
||||||
onSubmit={handleFormSubmit}
|
onSubmit={handleFormSubmit}
|
||||||
@@ -35,7 +41,7 @@ function RegistrationTokenErrorDialog({
|
|||||||
gap="400"
|
gap="400"
|
||||||
>
|
>
|
||||||
<Box direction="Column" gap="100">
|
<Box direction="Column" gap="100">
|
||||||
<Text as="h2" size="H4">
|
<Text id="registrationtokenstage-dialog-1-title" as="h2" size="H4">
|
||||||
{title}
|
{title}
|
||||||
</Text>
|
</Text>
|
||||||
<Text>{message}</Text>
|
<Text>{message}</Text>
|
||||||
|
|||||||
@@ -45,7 +45,13 @@ export function SSOStage({
|
|||||||
}, [ssoWindow, handleSubmit, ssoRedirectURL]);
|
}, [ssoWindow, handleSubmit, ssoRedirectURL]);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<Dialog>
|
<Dialog
|
||||||
|
id="ssostage-dialog-1"
|
||||||
|
role="dialog"
|
||||||
|
aria-modal="true"
|
||||||
|
aria-labelledby="ssostage-dialog-1-title"
|
||||||
|
tabIndex={-1}
|
||||||
|
>
|
||||||
<Header
|
<Header
|
||||||
style={{
|
style={{
|
||||||
padding: `0 ${config.space.S200} 0 ${config.space.S400}`,
|
padding: `0 ${config.space.S200} 0 ${config.space.S400}`,
|
||||||
@@ -54,7 +60,7 @@ export function SSOStage({
|
|||||||
size="500"
|
size="500"
|
||||||
>
|
>
|
||||||
<Box grow="Yes">
|
<Box grow="Yes">
|
||||||
<Text as="h2" size="H4">
|
<Text id="ssostage-dialog-1-title" as="h2" size="H4">
|
||||||
SSO Login
|
SSO Login
|
||||||
</Text>
|
</Text>
|
||||||
</Box>
|
</Box>
|
||||||
|
|||||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user