diff --git a/.changeset/add_option_to_filter_user_pronouns_based_on_the_pronouns_language.md b/.changeset/add_option_to_filter_user_pronouns_based_on_the_pronouns_language.md new file mode 100644 index 000000000..390e3a434 --- /dev/null +++ b/.changeset/add_option_to_filter_user_pronouns_based_on_the_pronouns_language.md @@ -0,0 +1,5 @@ +--- +sable: minor +--- + +Add option to filter user pronouns based on the pronouns language diff --git a/.changeset/hide_delete_modal_after_message_deletion.md b/.changeset/hide_delete_modal_after_message_deletion.md new file mode 100644 index 000000000..d62f7a38d --- /dev/null +++ b/.changeset/hide_delete_modal_after_message_deletion.md @@ -0,0 +1,5 @@ +--- +sable: patch +--- + +Hide delete modal after successfully deleting a message. diff --git a/.changeset/notification_pull_unread_background_badge.md b/.changeset/notification_pull_unread_background_badge.md new file mode 100644 index 000000000..0559d03a9 --- /dev/null +++ b/.changeset/notification_pull_unread_background_badge.md @@ -0,0 +1,5 @@ +--- +sable: patch +--- + +Adds a new message pill and background app highlighted unread count. diff --git a/.changeset/room_font_and_color_toggles.md b/.changeset/room_font_and_color_toggles.md new file mode 100644 index 000000000..5130aebf7 --- /dev/null +++ b/.changeset/room_font_and_color_toggles.md @@ -0,0 +1,5 @@ +--- +sable: patch +--- + +Added two toggles in Settings > Appearance > Identity for disabling rendering room/space fonts and colors. diff --git a/.github/actions/prepare-tofu/action.yml b/.github/actions/prepare-tofu/action.yml new file mode 100644 index 000000000..409a50ee4 --- /dev/null +++ b/.github/actions/prepare-tofu/action.yml @@ -0,0 +1,36 @@ +name: Prepare OpenTofu Deployment +description: Prepares OpenTofu in infra/web. + +inputs: + opentofu-version: + description: The OpenTofu version to install. + required: false + default: '1.11.5' + +runs: + using: composite + steps: + - name: Setup app and build + uses: ./.github/actions/setup + with: + build: 'true' + + - name: Setup OpenTofu + uses: opentofu/setup-opentofu@9d84900f3238fab8cd84ce47d658d25dd008be2f # v1.0.8 + with: + tofu_version: ${{ inputs.opentofu-version }} + + - name: Check formatting + shell: bash + working-directory: ${{ github.workspace }}/infra/web + run: tofu fmt -check + + - name: Initialize OpenTofu + shell: bash + working-directory: ${{ github.workspace }}/infra/web + run: tofu init -input=false -reconfigure + + - name: Validate configuration + shell: bash + working-directory: ${{ github.workspace }}/infra/web + run: tofu validate -no-color diff --git a/.github/actions/setup/action.yml b/.github/actions/setup/action.yml new file mode 100644 index 000000000..b4aa12459 --- /dev/null +++ b/.github/actions/setup/action.yml @@ -0,0 +1,40 @@ +name: Setup App +description: Sets up Node.js, installs dependencies, and optionally builds the app. + +inputs: + install-command: + description: Command used to install dependencies. + required: false + default: npm ci + build: + description: Whether to build the app after installing dependencies. + required: false + default: 'false' + build-command: + description: Command used when build is enabled. + required: false + default: npm run build + +runs: + using: composite + steps: + - name: Setup node + uses: actions/setup-node@53b83947a5a98c8d113130e565377fae1a50d02f # v6.3.0 + with: + node-version-file: '.node-version' + cache: 'npm' + + - name: Install dependencies + shell: bash + working-directory: ${{ github.workspace }} + run: ${INPUTS_INSTALL_COMMAND} + env: + INPUTS_INSTALL_COMMAND: ${{ inputs.install-command }} + + - name: Build app + if: ${{ inputs.build == 'true' }} + shell: bash + working-directory: ${{ github.workspace }} + run: ${INPUTS_BUILD_COMMAND} + env: + INPUTS_BUILD_COMMAND: ${{ inputs.build-command }} diff --git a/.github/workflows/cloudflare-web-deploy.yml b/.github/workflows/cloudflare-web-deploy.yml new file mode 100644 index 000000000..819851b05 --- /dev/null +++ b/.github/workflows/cloudflare-web-deploy.yml @@ -0,0 +1,80 @@ +name: Cloudflare Infra + +on: + pull_request: + paths: + - 'infra/web/**' + - '.github/workflows/cloudflare-web-deploy.yml' + - '.github/actions/prepare-tofu/**' + - '.github/actions/setup/**' + push: + tags: + - 'sable/v*' + workflow_dispatch: + +env: + CLOUDFLARE_API_TOKEN: ${{ secrets.TF_CLOUDFLARE_API_TOKEN }} + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + TF_VAR_workers_message: ${{ github.event_name == 'pull_request' && github.event.pull_request.title || github.event.head_commit.message || github.sha }} + TF_VAR_account_id: ${{ secrets.TF_VAR_ACCOUNT_ID }} + TF_VAR_zone_id: ${{ secrets.TF_VAR_ZONE_ID }} + TF_HTTP_ADDRESS: ${{ secrets.TF_HTTP_ADDRESS }} + TF_HTTP_LOCK_ADDRESS: ${{ secrets.TF_HTTP_LOCK_ADDRESS }} + TF_HTTP_UNLOCK_ADDRESS: ${{ secrets.TF_HTTP_UNLOCK_ADDRESS }} + TF_HTTP_USERNAME: ${{ secrets.TF_HTTP_USERNAME }} + TF_HTTP_PASSWORD: ${{ secrets.TF_HTTP_PASSWORD }} + TF_HTTP_LOCK_METHOD: 'POST' + TF_HTTP_UNLOCK_METHOD: 'DELETE' + TF_HTTP_RETRY_WAIT_MIN: '5' + +concurrency: + group: cloudflare-infra + cancel-in-progress: false + +jobs: + plan: + if: github.event_name == 'pull_request' && github.event.pull_request.head.repo.full_name == github.repository + runs-on: ubuntu-latest + permissions: + contents: read + pull-requests: write + defaults: + run: + working-directory: infra/web + steps: + - name: Checkout repository + uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2 + with: + persist-credentials: false + + - name: Prepare OpenTofu deployment + uses: ./.github/actions/prepare-tofu + + - name: Comment PR plan + uses: dflook/tofu-plan@3f5dc358343fb58cd60f83b019e810315aa8258f # v2.2.3 + with: + path: infra/web + label: production + + apply: + if: (github.event_name == 'push' && startsWith(github.ref, 'refs/tags/sable/v')) || github.event_name == 'workflow_dispatch' + runs-on: ubuntu-latest + permissions: + contents: read + defaults: + run: + working-directory: infra/web + steps: + - name: Checkout repository + uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2 + with: + persist-credentials: false + + - name: Prepare OpenTofu deployment + uses: ./.github/actions/prepare-tofu + + - name: Plan infrastructure + run: tofu plan -input=false -no-color + + - name: Apply infrastructure + run: tofu apply -input=false -auto-approve diff --git a/.github/workflows/docker-publish.yml b/.github/workflows/docker-publish.yml index 7183dccd9..c25e47d94 100644 --- a/.github/workflows/docker-publish.yml +++ b/.github/workflows/docker-publish.yml @@ -4,7 +4,7 @@ on: push: branches: [dev] tags: - - '*.*.*' + - 'sable/v*' env: REGISTRY: ghcr.io @@ -33,6 +33,18 @@ jobs: username: ${{ github.actor }} password: ${{ secrets.GITHUB_TOKEN }} + - name: Resolve release tag value + id: release_tag + shell: bash + run: | + if [[ "${GITHUB_REF}" == refs/tags/sable/v* ]]; then + echo "value=${GITHUB_REF#refs/tags/sable/}" >> "$GITHUB_OUTPUT" + echo "is_release=true" >> "$GITHUB_OUTPUT" + else + echo "value=" >> "$GITHUB_OUTPUT" + echo "is_release=false" >> "$GITHUB_OUTPUT" + fi + - name: Extract metadata id: meta uses: docker/metadata-action@c299e40c65443455700f0fdfc63efafe5b349051 # v5.10.0 @@ -46,9 +58,9 @@ jobs: type=raw,value=latest,enable=${{ github.ref == 'refs/heads/dev' }} # git tags: semver breakdown - type=semver,pattern={{version}} - type=semver,pattern={{major}}.{{minor}} - type=semver,pattern={{major}},enable=${{ !startsWith(github.ref, 'refs/tags/0.') }} + type=semver,pattern={{version}},value=${{ steps.release_tag.outputs.value }},enable=${{ steps.release_tag.outputs.is_release == 'true' }} + type=semver,pattern={{major}}.{{minor}},value=${{ steps.release_tag.outputs.value }},enable=${{ steps.release_tag.outputs.is_release == 'true' }} + type=semver,pattern={{major}},value=${{ steps.release_tag.outputs.value }},enable=${{ steps.release_tag.outputs.is_release == 'true' && !startsWith(steps.release_tag.outputs.value, 'v0.') }} - name: Set up QEMU uses: docker/setup-qemu-action@c7c53464625b32c7a7e944ae62b3e17d2b600130 # v3.7.0 diff --git a/.github/workflows/quality-checks.yml b/.github/workflows/quality-checks.yml index fb8e582cf..9a37398e6 100644 --- a/.github/workflows/quality-checks.yml +++ b/.github/workflows/quality-checks.yml @@ -15,13 +15,10 @@ jobs: uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2 with: persist-credentials: false - - name: Setup node - uses: actions/setup-node@6044e13b5dc448c55e2357c09f80417699197238 # v6.2.0 - with: - node-version-file: '.node-version' - cache: 'npm' - - name: Install dependencies - run: npm ci + + - name: Setup app + uses: ./.github/actions/setup + - name: Check formatting run: npm run fmt:check @@ -35,13 +32,10 @@ jobs: uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2 with: persist-credentials: false - - name: Setup node - uses: actions/setup-node@6044e13b5dc448c55e2357c09f80417699197238 # v6.2.0 - with: - node-version-file: '.node-version' - cache: 'npm' - - name: Install dependencies - run: npm ci + + - name: Setup app + uses: ./.github/actions/setup + - name: Run ESLint run: npm run lint @@ -55,13 +49,10 @@ jobs: uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2 with: persist-credentials: false - - name: Setup node - uses: actions/setup-node@6044e13b5dc448c55e2357c09f80417699197238 # v6.2.0 - with: - node-version-file: '.node-version' - cache: 'npm' - - name: Install dependencies - run: npm ci + + - name: Setup app + uses: ./.github/actions/setup + - name: Run TypeScript typecheck run: npm run typecheck -- --pretty false @@ -75,12 +66,11 @@ jobs: uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2 with: persist-credentials: false - - name: Setup node - uses: actions/setup-node@6044e13b5dc448c55e2357c09f80417699197238 # v6.2.0 + + - name: Setup app + uses: ./.github/actions/setup with: - node-version-file: '.node-version' - cache: 'npm' - - name: Install dependencies - run: npm ci --ignore-scripts + install-command: npm ci --ignore-scripts + - name: Run Knip run: npm run knip diff --git a/.gitignore b/.gitignore index d08837374..1c1104414 100644 --- a/.gitignore +++ b/.gitignore @@ -6,4 +6,15 @@ devAssets .DS_Store .idea -.env \ No newline at end of file +.env + +.wrangler +.dev.vars* +.terraform/ +*.tfstate +*.tfstate.* +*.tfvars +!*.tfvars.example +*.tfbackend +!*.tfbackend.example +crash.log diff --git a/CHANGELOG.md b/CHANGELOG.md index 497fbc5cd..be2cf9671 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,21 @@ # Sable Client Changelog +## 1.3.3 - 3/4/2026 + +- Fix unread counts and dot badges for muted rooms ([#118](https://github.com/7w1/sable/pull/118)) - [Evie Gauthier](https://github.com/Just-Insane) +- /raw, /rawmsg, /rawacc, /delacc, /setext, /delext for modifying arbitrary data in various places. Do not use them if you don't know what they mean. It can break things. Locked behind developer tools settings. ([#120](https://github.com/7w1/sable/pull/120)) +- Quick reactions by typing +:emoji and hitting tab ([#132](https://github.com/7w1/sable/pull/132)) - [mini-bomba](https://github.com/mini-bomba) +- Add support for [MSC4140](https://github.com/matrix-org/matrix-spec-proposals/pull/4140) scheduled messages on homeservers that support it ([#113](https://github.com/7w1/sable/pull/113)) +- Add /discardsession command to force discard e2ee session in current room ([#119](https://github.com/7w1/sable/issues/119), [#123](https://github.com/7w1/sable/pull/123)) +- Fix consistency of nicknames in dm rooms ([#122](https://github.com/7w1/sable/pull/122)) - [Rose](https://github.com/dozro) +- Message sending improvements, color change instead of "Sending..." message. ([#128](https://github.com/7w1/sable/pull/128)) - [Evie Gauthier](https://github.com/Just-Insane) +- Fix view source scroll bar. ([#125](https://github.com/7w1/sable/pull/125)) +- Added back Cinny Light theme as an option ([#80](https://github.com/7w1/sable/issues/80), [#126](https://github.com/7w1/sable/pull/126)) +- Fix auto capitalization in login screen ([#131](https://github.com/7w1/sable/pull/131)) - [Rose](https://github.com/dozro) +- Automated deployments with Cloudflare Workers IaC ([#116](https://github.com/7w1/sable/pull/116)) - [haz](https://github.com/hazre) +- Notification delivery, account switching, and unread count toggle fixes ([#127](https://github.com/7w1/sable/pull/127)) - [Evie Gauthier](https://github.com/Just-Insane) +- More sliding sync fixes: cache emoji packs and fix edit message rendering ([#134](https://github.com/7w1/sable/pull/134)) - [Evie Gauthier](https://github.com/Just-Insane) + ## 1.3.2 - 3/3/2026 - Content toggles in push notifications ([#88](https://github.com/7w1/sable/pull/88)) - [Evie Gauthier](https://github.com/Just-Insane) diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 62a493253..d18fd73cb 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -7,7 +7,7 @@ All types of contributions are encouraged and valued. Please make sure to read t > And if you like the project, but just don't have time to contribute, that's fine. There are other easy ways to support the project and show your appreciation, which we would also be very happy about: > > - Star the project -> - Talk abot it! +> - Talk about it! > - Refer this project in your project's readme > - Mention the project at local meetups and tell your friends/colleagues @@ -44,6 +44,68 @@ Also, we use [ESLint](https://eslint.org/) for clean and stylistically consisten - `npm run typecheck` - `npm run knip` +## Release notes and versioning (Knope) + +We use [Knope](https://knope.tech/) with the Knope GitHub Bot to manage change documentation and releases. The workflow configuration lives in [`knope.toml`](./knope.toml). + +If you have used [Changesets](https://github.com/changesets/changesets) before, Knope should feel very similar. The main difference is scope: Changesets is typically used for JavaScript repositories because it relies on `package.json`, while Knope is multi-language. + +If you prefer, you can install the Knope CLI yourself using the [official installation guide](https://knope.tech/installation/). This repo also exposes the CLI through npm scripts, so you can run `npm run knope -- ` (for example: `npm run knope -- document-change`). Otherwise, this repo installs Knope for you via `postinstall`, so running `npm i` is enough. + +### Documenting a change + +A changeset is a Markdown file (usually in `.changeset/`) that captures intent to change: the semver bump (`major`, `minor`, `patch`) and the user-facing release note text. Knope later combines all pending changesets to decide version bumps and generate changelog entries. + +For user-facing pull requests, add one before requesting review. + +CLI paths: + +- `npm run document-change` +- `npm run knope -- document-change` +- `knope document-change` (if Knope is installed locally) + +All commands open an interactive prompt; fill in the package, change type, and short summary, then commit the generated change file in your PR. + +Alternatively, you can document the change manually by creating a change file: + +1. Create a file named `.changeset/fix-room-timeline-pagination.md` (or another descriptive file name). +2. Copy and paste this Markdown into the file: + +```md +--- +sable: patch +--- + +Short user-facing summary of the change. +``` + +3. Replace `patch` with one of: `major`, `minor`, `patch`, `docs`, or `note`. +4. Edit the summary so it describes user-facing impact (not maintainer-only details). + +In this repo, the `internal` label skips Knope's documentation check (`[bot.checks].skip_labels`). + +Further reading: + +- https://github.com/knope-dev/changesets?tab=readme-ov-file#what-is-a-changeset +- https://github.com/changesets/changesets/blob/main/docs/detailed-explanation.md + +### Release flow (GitHub Bot) + +Releases are driven by Knope Bot (`[bot.releases].enabled = true`): + +- The bot keeps an up-to-date release PR from `knope/release`. +- Merging that bot release PR publishes the GitHub release. + +### Local validation and dry-run (optional) + +Maintainers can preview behavior without changing files: + +- `npm run knope -- release --dry-run` + +You can also validate the local Knope config with: + +- `npm run knope -- --validate` + **For any query or design discussion, join our [Matrix room](https://matrix.to/#/#sable:sable.moe).** ## Helpful links diff --git a/Dockerfile b/Dockerfile index 3d2c1f603..863b2ba7e 100644 --- a/Dockerfile +++ b/Dockerfile @@ -7,7 +7,7 @@ ARG VITE_BUILD_HASH ENV VITE_BUILD_HASH=$VITE_BUILD_HASH COPY .npmrc package.json package-lock.json /src/ -RUN npm ci +RUN npm ci --ignore-scripts COPY . /src/ ENV NODE_OPTIONS=--max_old_space_size=4096 RUN npm run build diff --git a/README.md b/README.md index 70be124b4..e29839ce6 100644 --- a/README.md +++ b/README.md @@ -77,3 +77,7 @@ To build the app: ```sh npm run build # Compiles the app into the dist/ directory ``` + +## Deployment and infrastructure +Deployment workflows and infrastructure details live in +[`infra/README.md`](infra/README.md). diff --git a/infra/README.md b/infra/README.md new file mode 100644 index 000000000..b1b0452da --- /dev/null +++ b/infra/README.md @@ -0,0 +1,104 @@ +# Infrastructure + +`infra/web` manages the Cloudflare Worker, immutable Worker versions, the live +production deployment, and the production custom domain. + +Prerequisites: + +- OpenTofu `1.11.x` installed locally +- Node.js/npm installed locally so you can build `dist/` before Worker uploads +- A Cloudflare account with the target zone already onboarded to Cloudflare +- A GitLab project to store the OpenTofu state +- A GitLab access token that can read and write that project's OpenTofu state + +Required GitHub repository secrets: + +- `TF_CLOUDFLARE_API_TOKEN` +- `TF_VAR_ACCOUNT_ID` +- `TF_VAR_ZONE_ID` +- `TF_HTTP_ADDRESS` +- `TF_HTTP_LOCK_ADDRESS` +- `TF_HTTP_UNLOCK_ADDRESS` +- `TF_HTTP_USERNAME` +- `TF_HTTP_PASSWORD` + +The workflows map those secrets onto the actual runtime environment variable names +that Cloudflare and OpenTofu expect. + +Cloudflare API token permissions: + +- `Account > Workers Scripts > Edit` +- Scope the token to the specific Cloudflare account that owns the Worker. +- Scope the token to the specific zone that serves `app.sable.moe`. +- Do not grant Pages or DNS edit permissions here. The Worker script upload and + custom-domain attach endpoints used by this repo accept Workers Scripts Write, and + Cloudflare creates the DNS record for the Worker custom domain automatically. + +GitLab access token permissions: + +- `api` + +Helpful reference links: + +- Create the main Cloudflare API token: + https://developers.cloudflare.com/fundamentals/api/get-started/create-token/ +- Find your account ID and zone ID: + https://developers.cloudflare.com/fundamentals/account/find-account-and-zone-ids/ +- GitLab-managed OpenTofu state: + https://docs.gitlab.com/user/infrastructure/iac/terraform_state/ + +Local setup: + +1. Copy `terraform.tfvars.example` to `terraform.tfvars` and fill in shared values. +2. Copy `gitlab.http.tfbackend.example` to `gitlab.http.tfbackend` and fill in the + GitLab project ID, state name, and username. +3. Run `npm ci` from the repo root. +4. Export the GitLab access token as the backend password. +5. Export the Cloudflare API token for OpenTofu. +6. Run `npm run build` before `tofu plan` or `tofu apply`, because + `cloudflare_worker_version` uploads the built `dist/` assets. +7. Initialize the backend. + +Local OpenTofu production flow from the repo root: + +```bash +npm run build +export TF_HTTP_PASSWORD="" +export CLOUDFLARE_API_TOKEN="" +tofu -chdir=infra/web init -reconfigure -backend-config="../gitlab.http.tfbackend" +tofu -chdir=infra/web validate +tofu -chdir=infra/web plan -var-file="../terraform.tfvars" +tofu -chdir=infra/web apply -var-file="../terraform.tfvars" +``` + +Optional local OpenTofu deployment message: + +```bash +export TF_VAR_workers_message="$(git log -1 --pretty=%s)" +tofu -chdir=infra/web apply -var-file="../terraform.tfvars" +``` + +If you already created local state before switching to GitLab state, use +`tofu -chdir=infra/web init -reconfigure -migrate-state -backend-config="../gitlab.http.tfbackend"` +once instead. + +Preview builds: + +- `infra/web/main.tf` enables preview URL capability with `subdomain.previews_enabled = true`. +- Previews are handled by Cloudflare Workers Builds, not GitHub Actions. +- Connect the repo once in Cloudflare Workers Builds. +- Set the Cloudflare Builds deploy command to `npx wrangler versions upload`. +- This disables automatic deployments while still allowing Cloudflare to build PRs/branches and save them as preview versions. +- That keeps Cloudflare from promoting `dev` commits to production. Production stays on the OpenTofu/GitHub Actions path in this repo. + +```bash +npx wrangler versions upload +``` + +Production deploys: + +- `.github/workflows/cloudflare-web-deploy.yml` comments PR plans for `infra/web` changes. +- That PR plan job only runs for same-repo PRs, not fork PRs, because it needs repo secrets. +- The same workflow applies production on pushes to `dev` or manual dispatch. +- `tofu apply` uploads `dist/` through `cloudflare_worker_version` and promotes it with `cloudflare_workers_deployment`. +- Production lives on `app.sable.moe`. diff --git a/infra/gitlab.http.tfbackend.example b/infra/gitlab.http.tfbackend.example new file mode 100644 index 000000000..0128a474f --- /dev/null +++ b/infra/gitlab.http.tfbackend.example @@ -0,0 +1,7 @@ +address = "https://gitlab.com/api/v4/projects/replace-with-gitlab-project-id/terraform/state/replace-with-gitlab-state-name" +lock_address = "https://gitlab.com/api/v4/projects/replace-with-gitlab-project-id/terraform/state/replace-with-gitlab-state-name/lock" +unlock_address = "https://gitlab.com/api/v4/projects/replace-with-gitlab-project-id/terraform/state/replace-with-gitlab-state-name/lock" +username = "replace-with-gitlab-username" +lock_method = "POST" +unlock_method = "DELETE" +retry_wait_min = 5 diff --git a/infra/terraform.tfvars.example b/infra/terraform.tfvars.example new file mode 100644 index 000000000..a054c1771 --- /dev/null +++ b/infra/terraform.tfvars.example @@ -0,0 +1,4 @@ +account_id = "replace-with-cloudflare-account-id" +zone_id = "replace-with-cloudflare-zone-id" +worker_name = "sable" +custom_domain = "app.sable.moe" diff --git a/infra/web/.terraform.lock.hcl b/infra/web/.terraform.lock.hcl new file mode 100644 index 000000000..016626158 --- /dev/null +++ b/infra/web/.terraform.lock.hcl @@ -0,0 +1,19 @@ +# This file is maintained automatically by "tofu init". +# Manual edits may be lost in future updates. + +provider "registry.opentofu.org/cloudflare/cloudflare" { + version = "5.18.0" + constraints = "~> 5.0" + hashes = [ + "h1:ny17Q/ce8iuHxppA/yIuRpCkVDtqhE+LDynWtv9/qwI=", + "zh:47e7bdfd8eddd2685f383269c0b6936ef62edd6d8383c8d7757b0cce0a689737", + "zh:aa23eb6aa128667883cabc449ceca4072d0181f574cd727e08ebd6d69a4bfd48", + "zh:c3da673e05d3bd933c82e2b6ba0f85aa23c5e24fadd3932f7c066314feeb65a3", + "zh:c59f07c017fc78b79e80554a0737c9db2a2e681c3e46ff637942d28d1f1a3924", + "zh:d559074612835a37fa684d8d7d0cf68911487b71f4067acc59069cb00bb8baf0", + "zh:e12290a4eda757c183a4258230245dd170f0def389c37eb771db144ce3b382dd", + "zh:ed47e484432ba1bbbb4802061f395ebd253ae8e20be9b72552d3d830fd2ca268", + "zh:f35e08d468408697b3e7c4a7f548b874141ac8f8d395ab8edded322201cc7047", + "zh:f809ab383cca0a5f83072981c64208cbd7fa67e986a86ee02dd2c82333221e32", + ] +} diff --git a/infra/web/backend.tf b/infra/web/backend.tf new file mode 100644 index 000000000..1736bf13b --- /dev/null +++ b/infra/web/backend.tf @@ -0,0 +1,3 @@ +terraform { + backend "http" {} +} diff --git a/infra/web/main.tf b/infra/web/main.tf new file mode 100644 index 000000000..6091baafc --- /dev/null +++ b/infra/web/main.tf @@ -0,0 +1,47 @@ +resource "cloudflare_worker" "site" { + account_id = var.account_id + name = var.worker_name + + subdomain = { + enabled = true + previews_enabled = true + } +} + +resource "cloudflare_worker_version" "site" { + account_id = var.account_id + compatibility_date = "2026-03-03" + worker_id = cloudflare_worker.site.id + + assets = { + directory = abspath("${path.module}/../../dist") + config = { + not_found_handling = "single-page-application" + } + } +} + +resource "cloudflare_workers_deployment" "site" { + account_id = var.account_id + script_name = cloudflare_worker.site.name + strategy = "percentage" + + annotations = var.workers_message == null ? null : { + workers_message = var.workers_message + } + + versions = [{ + percentage = 100 + version_id = cloudflare_worker_version.site.id + }] +} + +resource "cloudflare_workers_custom_domain" "site" { + account_id = var.account_id + environment = "production" + hostname = var.custom_domain + service = cloudflare_worker.site.name + zone_id = var.zone_id + + depends_on = [cloudflare_workers_deployment.site] +} diff --git a/infra/web/outputs.tf b/infra/web/outputs.tf new file mode 100644 index 000000000..e6b48bd00 --- /dev/null +++ b/infra/web/outputs.tf @@ -0,0 +1,9 @@ +output "custom_domain" { + description = "Custom domain attached to the Worker" + value = cloudflare_workers_custom_domain.site.hostname +} + +output "worker_name" { + description = "Cloudflare Worker name" + value = cloudflare_worker.site.name +} diff --git a/infra/web/providers.tf b/infra/web/providers.tf new file mode 100644 index 000000000..e862769b5 --- /dev/null +++ b/infra/web/providers.tf @@ -0,0 +1,3 @@ +provider "cloudflare" { + # API token will be read from CLOUDFLARE_API_TOKEN environment variable +} diff --git a/infra/web/terraform.tf b/infra/web/terraform.tf new file mode 100644 index 000000000..741fd99b5 --- /dev/null +++ b/infra/web/terraform.tf @@ -0,0 +1,10 @@ +terraform { + required_version = "~> 1.11.0" + + required_providers { + cloudflare = { + source = "cloudflare/cloudflare" + version = "~> 5.0" + } + } +} diff --git a/infra/web/variables.tf b/infra/web/variables.tf new file mode 100644 index 000000000..3569c9822 --- /dev/null +++ b/infra/web/variables.tf @@ -0,0 +1,29 @@ +variable "account_id" { + description = "Cloudflare Account ID" + type = string + sensitive = true +} + +variable "custom_domain" { + description = "Custom domain attached to the Worker" + type = string + default = "app.sable.moe" +} + +variable "worker_name" { + description = "Cloudflare Worker name" + type = string + default = "sable" +} + +variable "workers_message" { + description = "Optional short message attached to Worker deployments" + type = string + default = null +} + +variable "zone_id" { + description = "Cloudflare Zone ID" + type = string + sensitive = true +} diff --git a/knip.json b/knip.json index 108c62ecd..8fec7f863 100644 --- a/knip.json +++ b/knip.json @@ -6,6 +6,7 @@ "type": true }, "ignoreDependencies": ["buffer", "@element-hq/element-call-embedded", "workbox-precaching"], + "ignoreBinaries": ["knope"], "rules": { "exports": "off", "types": "off", diff --git a/knope.toml b/knope.toml new file mode 100644 index 000000000..d0d8bfc8d --- /dev/null +++ b/knope.toml @@ -0,0 +1,47 @@ + +[packages.sable] +versioned_files = ["package.json", "package-lock.json"] +changelog = "CHANGELOG.md" +extra_changelog_sections = [ + { name = "Documentation", types = ["docs"] }, + { name = "Notes", types = ["note"] } +] +# assets = "marker for GitHub bot" // TODO: add this later once we have assets + +[changes] +ignore_conventional_commits = true + +[[workflows]] +name = "release" +help_text = "Prepare and create a new release (update changelog, bump version, create release)" + +[[workflows.steps]] +type = "PrepareRelease" + +[[workflows.steps]] +type = "Command" +command = 'git commit -m "chore: prepare release $version"' + +[[workflows.steps]] +type = "Command" +command = "git push" + +[[workflows.steps]] +type = "Release" + +[[workflows]] +name = "document-change" +help_text = "Create a new change file to be included in the next release" + +[[workflows.steps]] +type = "CreateChangeFile" + +[github] +owner = "7w1" +repo = "sable" + +[bot.releases] +enabled = true + +[bot.checks] +skip_labels = ["internal"] diff --git a/netlify.toml b/netlify.toml deleted file mode 100644 index a87103032..000000000 --- a/netlify.toml +++ /dev/null @@ -1,36 +0,0 @@ -[[redirects]] - from = "/config.json" - to = "/config.json" - status = 200 - -[[redirects]] - from = "/manifest.json" - to = "/manifest.json" - status = 200 - -[[redirects]] - from = "/sw.js" - to = "/sw.js" - status = 200 - - -[[redirects]] - from = "/pdf.worker.min.js" - to = "/pdf.worker.min.js" - status = 200 - -[[redirects]] - from = "/public/*" - to = "/public/:splat" - status = 200 - -[[redirects]] - from = "/assets/*" - to = "/assets/:splat" - status = 200 - -[[redirects]] - from = "/*" - to = "/index.html" - status = 200 - force = true \ No newline at end of file diff --git a/package-lock.json b/package-lock.json index c214abfbd..811f037dc 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,13 @@ { "name": "sable", - "version": "1.3.2", + "version": "1.3.3", "lockfileVersion": 2, "requires": true, "packages": { "": { "name": "sable", - "version": "1.3.2", + "version": "1.3.3", + "hasInstallScript": true, "license": "AGPL-3.0-only", "dependencies": { "@atlaskit/pragmatic-drag-and-drop": "^1.7.7", @@ -69,6 +70,7 @@ "ua-parser-js": "^1.0.41" }, "devDependencies": { + "@cloudflare/vite-plugin": "^1.26.0", "@element-hq/element-call-embedded": "0.16.3", "@esbuild-plugins/node-globals-polyfill": "^0.2.3", "@eslint/compat": "2.0.2", @@ -99,7 +101,8 @@ "vite-plugin-pwa": "^1.2.0", "vite-plugin-static-copy": "^3.2.0", "vite-plugin-svgr": "4.5.0", - "vite-plugin-top-level-await": "^1.6.0" + "vite-plugin-top-level-await": "^1.6.0", + "wrangler": "^4.70.0" }, "engines": { "node": "24.x", @@ -1754,6 +1757,159 @@ "node": ">=6.9.0" } }, + "node_modules/@cloudflare/kv-asset-handler": { + "version": "0.4.2", + "resolved": "https://registry.npmjs.org/@cloudflare/kv-asset-handler/-/kv-asset-handler-0.4.2.tgz", + "integrity": "sha512-SIOD2DxrRRwQ+jgzlXCqoEFiKOFqaPjhnNTGKXSRLvp1HiOvapLaFG2kEr9dYQTYe8rKrd9uvDUzmAITeNyaHQ==", + "dev": true, + "license": "MIT OR Apache-2.0", + "engines": { + "node": ">=18.0.0" + } + }, + "node_modules/@cloudflare/unenv-preset": { + "version": "2.14.0", + "resolved": "https://registry.npmjs.org/@cloudflare/unenv-preset/-/unenv-preset-2.14.0.tgz", + "integrity": "sha512-XKAkWhi1nBdNsSEoNG9nkcbyvfUrSjSf+VYVPfOto3gLTZVc3F4g6RASCMh6IixBKCG2yDgZKQIHGKtjcnLnKg==", + "dev": true, + "license": "MIT OR Apache-2.0", + "peerDependencies": { + "unenv": "2.0.0-rc.24", + "workerd": "^1.20260218.0" + }, + "peerDependenciesMeta": { + "workerd": { + "optional": true + } + } + }, + "node_modules/@cloudflare/vite-plugin": { + "version": "1.26.0", + "resolved": "https://registry.npmjs.org/@cloudflare/vite-plugin/-/vite-plugin-1.26.0.tgz", + "integrity": "sha512-F5jSOj9JeWMp9iQa2x+Ocjz++SCfK6Phcca/YLkaddPw5ie7W1VvEWudQ/gxYtRd47mQ/PfCLkE9QGyy6OGEng==", + "dev": true, + "license": "MIT", + "dependencies": { + "@cloudflare/unenv-preset": "2.14.0", + "miniflare": "4.20260301.1", + "unenv": "2.0.0-rc.24", + "wrangler": "4.70.0", + "ws": "8.18.0" + }, + "peerDependencies": { + "vite": "^6.1.0 || ^7.0.0", + "wrangler": "^4.70.0" + } + }, + "node_modules/@cloudflare/workerd-darwin-64": { + "version": "1.20260301.1", + "resolved": "https://registry.npmjs.org/@cloudflare/workerd-darwin-64/-/workerd-darwin-64-1.20260301.1.tgz", + "integrity": "sha512-+kJvwociLrvy1JV9BAvoSVsMEIYD982CpFmo/yMEvBwxDIjltYsLTE8DLi0mCkGsQ8Ygidv2fD9wavzXeiY7OQ==", + "cpu": [ + "x64" + ], + "dev": true, + "license": "Apache-2.0", + "optional": true, + "os": [ + "darwin" + ], + "engines": { + "node": ">=16" + } + }, + "node_modules/@cloudflare/workerd-darwin-arm64": { + "version": "1.20260301.1", + "resolved": "https://registry.npmjs.org/@cloudflare/workerd-darwin-arm64/-/workerd-darwin-arm64-1.20260301.1.tgz", + "integrity": "sha512-PPIetY3e67YBr9O4UhILK8nbm5TqUDl14qx4rwFNrRSBOvlzuczzbd4BqgpAtbGVFxKp1PWpjAnBvGU/OI/tLQ==", + "cpu": [ + "arm64" + ], + "dev": true, + "license": "Apache-2.0", + "optional": true, + "os": [ + "darwin" + ], + "engines": { + "node": ">=16" + } + }, + "node_modules/@cloudflare/workerd-linux-64": { + "version": "1.20260301.1", + "resolved": "https://registry.npmjs.org/@cloudflare/workerd-linux-64/-/workerd-linux-64-1.20260301.1.tgz", + "integrity": "sha512-Gu5vaVTZuYl3cHa+u5CDzSVDBvSkfNyuAHi6Mdfut7TTUdcb3V5CIcR/mXRSyMXzEy9YxEWIfdKMxOMBjupvYQ==", + "cpu": [ + "x64" + ], + "dev": true, + "license": "Apache-2.0", + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": ">=16" + } + }, + "node_modules/@cloudflare/workerd-linux-arm64": { + "version": "1.20260301.1", + "resolved": "https://registry.npmjs.org/@cloudflare/workerd-linux-arm64/-/workerd-linux-arm64-1.20260301.1.tgz", + "integrity": "sha512-igL1pkyCXW6GiGpjdOAvqMi87UW0LMc/+yIQe/CSzuZJm5GzXoAMrwVTkCFnikk6JVGELrM5x0tGYlxa0sk5Iw==", + "cpu": [ + "arm64" + ], + "dev": true, + "license": "Apache-2.0", + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": ">=16" + } + }, + "node_modules/@cloudflare/workerd-windows-64": { + "version": "1.20260301.1", + "resolved": "https://registry.npmjs.org/@cloudflare/workerd-windows-64/-/workerd-windows-64-1.20260301.1.tgz", + "integrity": "sha512-Q0wMJ4kcujXILwQKQFc1jaYamVsNvjuECzvRrTI8OxGFMx2yq9aOsswViE4X1gaS2YQQ5u0JGwuGi5WdT1Lt7A==", + "cpu": [ + "x64" + ], + "dev": true, + "license": "Apache-2.0", + "optional": true, + "os": [ + "win32" + ], + "engines": { + "node": ">=16" + } + }, + "node_modules/@cspotcode/source-map-support": { + "version": "0.8.1", + "resolved": "https://registry.npmjs.org/@cspotcode/source-map-support/-/source-map-support-0.8.1.tgz", + "integrity": "sha512-IchNf6dN4tHoMFIn/7OE8LWZ19Y6q/67Bmf6vnGREv8RSbBVb9LPJxEcnwrcwX6ixSvaiGoomAUvu4YSxXrVgw==", + "dev": true, + "license": "MIT", + "dependencies": { + "@jridgewell/trace-mapping": "0.3.9" + }, + "engines": { + "node": ">=12" + } + }, + "node_modules/@cspotcode/source-map-support/node_modules/@jridgewell/trace-mapping": { + "version": "0.3.9", + "resolved": "https://registry.npmjs.org/@jridgewell/trace-mapping/-/trace-mapping-0.3.9.tgz", + "integrity": "sha512-3Belt6tdc8bPgAtbcmdtNJlirVoTmEb5e2gC94PnkwEW9jI6CAHUeoG85tjWP5WquqfavoMtMwiG4P926ZKKuQ==", + "dev": true, + "license": "MIT", + "dependencies": { + "@jridgewell/resolve-uri": "^3.0.3", + "@jridgewell/sourcemap-codec": "^1.4.10" + } + }, "node_modules/@element-hq/element-call-embedded": { "version": "0.16.3", "resolved": "https://registry.npmjs.org/@element-hq/element-call-embedded/-/element-call-embedded-0.16.3.tgz", @@ -2558,6 +2714,496 @@ "url": "https://github.com/sponsors/nzakas" } }, + "node_modules/@img/colour": { + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/@img/colour/-/colour-1.1.0.tgz", + "integrity": "sha512-Td76q7j57o/tLVdgS746cYARfSyxk8iEfRxewL9h4OMzYhbW4TAcppl0mT4eyqXddh6L/jwoM75mo7ixa/pCeQ==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=18" + } + }, + "node_modules/@img/sharp-darwin-arm64": { + "version": "0.34.5", + "resolved": "https://registry.npmjs.org/@img/sharp-darwin-arm64/-/sharp-darwin-arm64-0.34.5.tgz", + "integrity": "sha512-imtQ3WMJXbMY4fxb/Ndp6HBTNVtWCUI0WdobyheGf5+ad6xX8VIDO8u2xE4qc/fr08CKG/7dDseFtn6M6g/r3w==", + "cpu": [ + "arm64" + ], + "dev": true, + "license": "Apache-2.0", + "optional": true, + "os": [ + "darwin" + ], + "engines": { + "node": "^18.17.0 || ^20.3.0 || >=21.0.0" + }, + "funding": { + "url": "https://opencollective.com/libvips" + }, + "optionalDependencies": { + "@img/sharp-libvips-darwin-arm64": "1.2.4" + } + }, + "node_modules/@img/sharp-darwin-x64": { + "version": "0.34.5", + "resolved": "https://registry.npmjs.org/@img/sharp-darwin-x64/-/sharp-darwin-x64-0.34.5.tgz", + "integrity": "sha512-YNEFAF/4KQ/PeW0N+r+aVVsoIY0/qxxikF2SWdp+NRkmMB7y9LBZAVqQ4yhGCm/H3H270OSykqmQMKLBhBJDEw==", + "cpu": [ + "x64" + ], + "dev": true, + "license": "Apache-2.0", + "optional": true, + "os": [ + "darwin" + ], + "engines": { + "node": "^18.17.0 || ^20.3.0 || >=21.0.0" + }, + "funding": { + "url": "https://opencollective.com/libvips" + }, + "optionalDependencies": { + "@img/sharp-libvips-darwin-x64": "1.2.4" + } + }, + "node_modules/@img/sharp-libvips-darwin-arm64": { + "version": "1.2.4", + "resolved": "https://registry.npmjs.org/@img/sharp-libvips-darwin-arm64/-/sharp-libvips-darwin-arm64-1.2.4.tgz", + "integrity": "sha512-zqjjo7RatFfFoP0MkQ51jfuFZBnVE2pRiaydKJ1G/rHZvnsrHAOcQALIi9sA5co5xenQdTugCvtb1cuf78Vf4g==", + "cpu": [ + "arm64" + ], + "dev": true, + "license": "LGPL-3.0-or-later", + "optional": true, + "os": [ + "darwin" + ], + "funding": { + "url": "https://opencollective.com/libvips" + } + }, + "node_modules/@img/sharp-libvips-darwin-x64": { + "version": "1.2.4", + "resolved": "https://registry.npmjs.org/@img/sharp-libvips-darwin-x64/-/sharp-libvips-darwin-x64-1.2.4.tgz", + "integrity": "sha512-1IOd5xfVhlGwX+zXv2N93k0yMONvUlANylbJw1eTah8K/Jtpi15KC+WSiaX/nBmbm2HxRM1gZ0nSdjSsrZbGKg==", + "cpu": [ + "x64" + ], + "dev": true, + "license": "LGPL-3.0-or-later", + "optional": true, + "os": [ + "darwin" + ], + "funding": { + "url": "https://opencollective.com/libvips" + } + }, + "node_modules/@img/sharp-libvips-linux-arm": { + "version": "1.2.4", + "resolved": "https://registry.npmjs.org/@img/sharp-libvips-linux-arm/-/sharp-libvips-linux-arm-1.2.4.tgz", + "integrity": "sha512-bFI7xcKFELdiNCVov8e44Ia4u2byA+l3XtsAj+Q8tfCwO6BQ8iDojYdvoPMqsKDkuoOo+X6HZA0s0q11ANMQ8A==", + "cpu": [ + "arm" + ], + "dev": true, + "license": "LGPL-3.0-or-later", + "optional": true, + "os": [ + "linux" + ], + "funding": { + "url": "https://opencollective.com/libvips" + } + }, + "node_modules/@img/sharp-libvips-linux-arm64": { + "version": "1.2.4", + "resolved": "https://registry.npmjs.org/@img/sharp-libvips-linux-arm64/-/sharp-libvips-linux-arm64-1.2.4.tgz", + "integrity": "sha512-excjX8DfsIcJ10x1Kzr4RcWe1edC9PquDRRPx3YVCvQv+U5p7Yin2s32ftzikXojb1PIFc/9Mt28/y+iRklkrw==", + "cpu": [ + "arm64" + ], + "dev": true, + "license": "LGPL-3.0-or-later", + "optional": true, + "os": [ + "linux" + ], + "funding": { + "url": "https://opencollective.com/libvips" + } + }, + "node_modules/@img/sharp-libvips-linux-ppc64": { + "version": "1.2.4", + "resolved": "https://registry.npmjs.org/@img/sharp-libvips-linux-ppc64/-/sharp-libvips-linux-ppc64-1.2.4.tgz", + "integrity": "sha512-FMuvGijLDYG6lW+b/UvyilUWu5Ayu+3r2d1S8notiGCIyYU/76eig1UfMmkZ7vwgOrzKzlQbFSuQfgm7GYUPpA==", + "cpu": [ + "ppc64" + ], + "dev": true, + "license": "LGPL-3.0-or-later", + "optional": true, + "os": [ + "linux" + ], + "funding": { + "url": "https://opencollective.com/libvips" + } + }, + "node_modules/@img/sharp-libvips-linux-riscv64": { + "version": "1.2.4", + "resolved": "https://registry.npmjs.org/@img/sharp-libvips-linux-riscv64/-/sharp-libvips-linux-riscv64-1.2.4.tgz", + "integrity": "sha512-oVDbcR4zUC0ce82teubSm+x6ETixtKZBh/qbREIOcI3cULzDyb18Sr/Wcyx7NRQeQzOiHTNbZFF1UwPS2scyGA==", + "cpu": [ + "riscv64" + ], + "dev": true, + "license": "LGPL-3.0-or-later", + "optional": true, + "os": [ + "linux" + ], + "funding": { + "url": "https://opencollective.com/libvips" + } + }, + "node_modules/@img/sharp-libvips-linux-s390x": { + "version": "1.2.4", + "resolved": "https://registry.npmjs.org/@img/sharp-libvips-linux-s390x/-/sharp-libvips-linux-s390x-1.2.4.tgz", + "integrity": "sha512-qmp9VrzgPgMoGZyPvrQHqk02uyjA0/QrTO26Tqk6l4ZV0MPWIW6LTkqOIov+J1yEu7MbFQaDpwdwJKhbJvuRxQ==", + "cpu": [ + "s390x" + ], + "dev": true, + "license": "LGPL-3.0-or-later", + "optional": true, + "os": [ + "linux" + ], + "funding": { + "url": "https://opencollective.com/libvips" + } + }, + "node_modules/@img/sharp-libvips-linux-x64": { + "version": "1.2.4", + "resolved": "https://registry.npmjs.org/@img/sharp-libvips-linux-x64/-/sharp-libvips-linux-x64-1.2.4.tgz", + "integrity": "sha512-tJxiiLsmHc9Ax1bz3oaOYBURTXGIRDODBqhveVHonrHJ9/+k89qbLl0bcJns+e4t4rvaNBxaEZsFtSfAdquPrw==", + "cpu": [ + "x64" + ], + "dev": true, + "license": "LGPL-3.0-or-later", + "optional": true, + "os": [ + "linux" + ], + "funding": { + "url": "https://opencollective.com/libvips" + } + }, + "node_modules/@img/sharp-libvips-linuxmusl-arm64": { + "version": "1.2.4", + "resolved": "https://registry.npmjs.org/@img/sharp-libvips-linuxmusl-arm64/-/sharp-libvips-linuxmusl-arm64-1.2.4.tgz", + "integrity": "sha512-FVQHuwx1IIuNow9QAbYUzJ+En8KcVm9Lk5+uGUQJHaZmMECZmOlix9HnH7n1TRkXMS0pGxIJokIVB9SuqZGGXw==", + "cpu": [ + "arm64" + ], + "dev": true, + "license": "LGPL-3.0-or-later", + "optional": true, + "os": [ + "linux" + ], + "funding": { + "url": "https://opencollective.com/libvips" + } + }, + "node_modules/@img/sharp-libvips-linuxmusl-x64": { + "version": "1.2.4", + "resolved": "https://registry.npmjs.org/@img/sharp-libvips-linuxmusl-x64/-/sharp-libvips-linuxmusl-x64-1.2.4.tgz", + "integrity": "sha512-+LpyBk7L44ZIXwz/VYfglaX/okxezESc6UxDSoyo2Ks6Jxc4Y7sGjpgU9s4PMgqgjj1gZCylTieNamqA1MF7Dg==", + "cpu": [ + "x64" + ], + "dev": true, + "license": "LGPL-3.0-or-later", + "optional": true, + "os": [ + "linux" + ], + "funding": { + "url": "https://opencollective.com/libvips" + } + }, + "node_modules/@img/sharp-linux-arm": { + "version": "0.34.5", + "resolved": "https://registry.npmjs.org/@img/sharp-linux-arm/-/sharp-linux-arm-0.34.5.tgz", + "integrity": "sha512-9dLqsvwtg1uuXBGZKsxem9595+ujv0sJ6Vi8wcTANSFpwV/GONat5eCkzQo/1O6zRIkh0m/8+5BjrRr7jDUSZw==", + "cpu": [ + "arm" + ], + "dev": true, + "license": "Apache-2.0", + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": "^18.17.0 || ^20.3.0 || >=21.0.0" + }, + "funding": { + "url": "https://opencollective.com/libvips" + }, + "optionalDependencies": { + "@img/sharp-libvips-linux-arm": "1.2.4" + } + }, + "node_modules/@img/sharp-linux-arm64": { + "version": "0.34.5", + "resolved": "https://registry.npmjs.org/@img/sharp-linux-arm64/-/sharp-linux-arm64-0.34.5.tgz", + "integrity": "sha512-bKQzaJRY/bkPOXyKx5EVup7qkaojECG6NLYswgktOZjaXecSAeCWiZwwiFf3/Y+O1HrauiE3FVsGxFg8c24rZg==", + "cpu": [ + "arm64" + ], + "dev": true, + "license": "Apache-2.0", + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": "^18.17.0 || ^20.3.0 || >=21.0.0" + }, + "funding": { + "url": "https://opencollective.com/libvips" + }, + "optionalDependencies": { + "@img/sharp-libvips-linux-arm64": "1.2.4" + } + }, + "node_modules/@img/sharp-linux-ppc64": { + "version": "0.34.5", + "resolved": "https://registry.npmjs.org/@img/sharp-linux-ppc64/-/sharp-linux-ppc64-0.34.5.tgz", + "integrity": "sha512-7zznwNaqW6YtsfrGGDA6BRkISKAAE1Jo0QdpNYXNMHu2+0dTrPflTLNkpc8l7MUP5M16ZJcUvysVWWrMefZquA==", + "cpu": [ + "ppc64" + ], + "dev": true, + "license": "Apache-2.0", + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": "^18.17.0 || ^20.3.0 || >=21.0.0" + }, + "funding": { + "url": "https://opencollective.com/libvips" + }, + "optionalDependencies": { + "@img/sharp-libvips-linux-ppc64": "1.2.4" + } + }, + "node_modules/@img/sharp-linux-riscv64": { + "version": "0.34.5", + "resolved": "https://registry.npmjs.org/@img/sharp-linux-riscv64/-/sharp-linux-riscv64-0.34.5.tgz", + "integrity": "sha512-51gJuLPTKa7piYPaVs8GmByo7/U7/7TZOq+cnXJIHZKavIRHAP77e3N2HEl3dgiqdD/w0yUfiJnII77PuDDFdw==", + "cpu": [ + "riscv64" + ], + "dev": true, + "license": "Apache-2.0", + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": "^18.17.0 || ^20.3.0 || >=21.0.0" + }, + "funding": { + "url": "https://opencollective.com/libvips" + }, + "optionalDependencies": { + "@img/sharp-libvips-linux-riscv64": "1.2.4" + } + }, + "node_modules/@img/sharp-linux-s390x": { + "version": "0.34.5", + "resolved": "https://registry.npmjs.org/@img/sharp-linux-s390x/-/sharp-linux-s390x-0.34.5.tgz", + "integrity": "sha512-nQtCk0PdKfho3eC5MrbQoigJ2gd1CgddUMkabUj+rBevs8tZ2cULOx46E7oyX+04WGfABgIwmMC0VqieTiR4jg==", + "cpu": [ + "s390x" + ], + "dev": true, + "license": "Apache-2.0", + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": "^18.17.0 || ^20.3.0 || >=21.0.0" + }, + "funding": { + "url": "https://opencollective.com/libvips" + }, + "optionalDependencies": { + "@img/sharp-libvips-linux-s390x": "1.2.4" + } + }, + "node_modules/@img/sharp-linux-x64": { + "version": "0.34.5", + "resolved": "https://registry.npmjs.org/@img/sharp-linux-x64/-/sharp-linux-x64-0.34.5.tgz", + "integrity": "sha512-MEzd8HPKxVxVenwAa+JRPwEC7QFjoPWuS5NZnBt6B3pu7EG2Ge0id1oLHZpPJdn3OQK+BQDiw9zStiHBTJQQQQ==", + "cpu": [ + "x64" + ], + "dev": true, + "license": "Apache-2.0", + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": "^18.17.0 || ^20.3.0 || >=21.0.0" + }, + "funding": { + "url": "https://opencollective.com/libvips" + }, + "optionalDependencies": { + "@img/sharp-libvips-linux-x64": "1.2.4" + } + }, + "node_modules/@img/sharp-linuxmusl-arm64": { + "version": "0.34.5", + "resolved": "https://registry.npmjs.org/@img/sharp-linuxmusl-arm64/-/sharp-linuxmusl-arm64-0.34.5.tgz", + "integrity": "sha512-fprJR6GtRsMt6Kyfq44IsChVZeGN97gTD331weR1ex1c1rypDEABN6Tm2xa1wE6lYb5DdEnk03NZPqA7Id21yg==", + "cpu": [ + "arm64" + ], + "dev": true, + "license": "Apache-2.0", + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": "^18.17.0 || ^20.3.0 || >=21.0.0" + }, + "funding": { + "url": "https://opencollective.com/libvips" + }, + "optionalDependencies": { + "@img/sharp-libvips-linuxmusl-arm64": "1.2.4" + } + }, + "node_modules/@img/sharp-linuxmusl-x64": { + "version": "0.34.5", + "resolved": "https://registry.npmjs.org/@img/sharp-linuxmusl-x64/-/sharp-linuxmusl-x64-0.34.5.tgz", + "integrity": "sha512-Jg8wNT1MUzIvhBFxViqrEhWDGzqymo3sV7z7ZsaWbZNDLXRJZoRGrjulp60YYtV4wfY8VIKcWidjojlLcWrd8Q==", + "cpu": [ + "x64" + ], + "dev": true, + "license": "Apache-2.0", + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": "^18.17.0 || ^20.3.0 || >=21.0.0" + }, + "funding": { + "url": "https://opencollective.com/libvips" + }, + "optionalDependencies": { + "@img/sharp-libvips-linuxmusl-x64": "1.2.4" + } + }, + "node_modules/@img/sharp-wasm32": { + "version": "0.34.5", + "resolved": "https://registry.npmjs.org/@img/sharp-wasm32/-/sharp-wasm32-0.34.5.tgz", + "integrity": "sha512-OdWTEiVkY2PHwqkbBI8frFxQQFekHaSSkUIJkwzclWZe64O1X4UlUjqqqLaPbUpMOQk6FBu/HtlGXNblIs0huw==", + "cpu": [ + "wasm32" + ], + "dev": true, + "license": "Apache-2.0 AND LGPL-3.0-or-later AND MIT", + "optional": true, + "dependencies": { + "@emnapi/runtime": "^1.7.0" + }, + "engines": { + "node": "^18.17.0 || ^20.3.0 || >=21.0.0" + }, + "funding": { + "url": "https://opencollective.com/libvips" + } + }, + "node_modules/@img/sharp-win32-arm64": { + "version": "0.34.5", + "resolved": "https://registry.npmjs.org/@img/sharp-win32-arm64/-/sharp-win32-arm64-0.34.5.tgz", + "integrity": "sha512-WQ3AgWCWYSb2yt+IG8mnC6Jdk9Whs7O0gxphblsLvdhSpSTtmu69ZG1Gkb6NuvxsNACwiPV6cNSZNzt0KPsw7g==", + "cpu": [ + "arm64" + ], + "dev": true, + "license": "Apache-2.0 AND LGPL-3.0-or-later", + "optional": true, + "os": [ + "win32" + ], + "engines": { + "node": "^18.17.0 || ^20.3.0 || >=21.0.0" + }, + "funding": { + "url": "https://opencollective.com/libvips" + } + }, + "node_modules/@img/sharp-win32-ia32": { + "version": "0.34.5", + "resolved": "https://registry.npmjs.org/@img/sharp-win32-ia32/-/sharp-win32-ia32-0.34.5.tgz", + "integrity": "sha512-FV9m/7NmeCmSHDD5j4+4pNI8Cp3aW+JvLoXcTUo0IqyjSfAZJ8dIUmijx1qaJsIiU+Hosw6xM5KijAWRJCSgNg==", + "cpu": [ + "ia32" + ], + "dev": true, + "license": "Apache-2.0 AND LGPL-3.0-or-later", + "optional": true, + "os": [ + "win32" + ], + "engines": { + "node": "^18.17.0 || ^20.3.0 || >=21.0.0" + }, + "funding": { + "url": "https://opencollective.com/libvips" + } + }, + "node_modules/@img/sharp-win32-x64": { + "version": "0.34.5", + "resolved": "https://registry.npmjs.org/@img/sharp-win32-x64/-/sharp-win32-x64-0.34.5.tgz", + "integrity": "sha512-+29YMsqY2/9eFEiW93eqWnuLcWcufowXewwSNIT6UwZdUUCrM3oFjMWH/Z6/TMmb4hlFenmfAVbpWeup2jryCw==", + "cpu": [ + "x64" + ], + "dev": true, + "license": "Apache-2.0 AND LGPL-3.0-or-later", + "optional": true, + "os": [ + "win32" + ], + "engines": { + "node": "^18.17.0 || ^20.3.0 || >=21.0.0" + }, + "funding": { + "url": "https://opencollective.com/libvips" + } + }, "node_modules/@internationalized/date": { "version": "3.11.0", "resolved": "https://registry.npmjs.org/@internationalized/date/-/date-3.11.0.tgz", @@ -3315,6 +3961,48 @@ "url": "https://opencollective.com/pkgr" } }, + "node_modules/@poppinss/colors": { + "version": "4.1.6", + "resolved": "https://registry.npmjs.org/@poppinss/colors/-/colors-4.1.6.tgz", + "integrity": "sha512-H9xkIdFswbS8n1d6vmRd8+c10t2Qe+rZITbbDHHkQixH5+2x1FDGmi/0K+WgWiqQFKPSlIYB7jlH6Kpfn6Fleg==", + "dev": true, + "license": "MIT", + "dependencies": { + "kleur": "^4.1.5" + } + }, + "node_modules/@poppinss/dumper": { + "version": "0.6.5", + "resolved": "https://registry.npmjs.org/@poppinss/dumper/-/dumper-0.6.5.tgz", + "integrity": "sha512-NBdYIb90J7LfOI32dOewKI1r7wnkiH6m920puQ3qHUeZkxNkQiFnXVWoE6YtFSv6QOiPPf7ys6i+HWWecDz7sw==", + "dev": true, + "license": "MIT", + "dependencies": { + "@poppinss/colors": "^4.1.5", + "@sindresorhus/is": "^7.0.2", + "supports-color": "^10.0.0" + } + }, + "node_modules/@poppinss/dumper/node_modules/supports-color": { + "version": "10.2.2", + "resolved": "https://registry.npmjs.org/supports-color/-/supports-color-10.2.2.tgz", + "integrity": "sha512-SS+jx45GF1QjgEXQx4NJZV9ImqmO2NPz5FNsIHrsDjh2YsHnawpan7SNQ1o8NuhrbHZy9AZhIoCUiCeaW/C80g==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=18" + }, + "funding": { + "url": "https://github.com/chalk/supports-color?sponsor=1" + } + }, + "node_modules/@poppinss/exception": { + "version": "1.2.3", + "resolved": "https://registry.npmjs.org/@poppinss/exception/-/exception-1.2.3.tgz", + "integrity": "sha512-dCED+QRChTVatE9ibtoaxc+WkdzOSjYTKi/+uacHWIsfodVfpsueo3+DKpgU5Px8qXjgmXkSvhXvSCz3fnP9lw==", + "dev": true, + "license": "MIT" + }, "node_modules/@react-aria/breadcrumbs": { "version": "3.5.31", "resolved": "https://registry.npmjs.org/@react-aria/breadcrumbs/-/breadcrumbs-3.5.31.tgz", @@ -5581,6 +6269,26 @@ "dev": true, "license": "MIT" }, + "node_modules/@sindresorhus/is": { + "version": "7.2.0", + "resolved": "https://registry.npmjs.org/@sindresorhus/is/-/is-7.2.0.tgz", + "integrity": "sha512-P1Cz1dWaFfR4IR+U13mqqiGsLFf1KbayybWwdd2vfctdV6hDpUkgCY0nKOLLTMSoRd/jJNjtbqzf13K8DCCXQw==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=18" + }, + "funding": { + "url": "https://github.com/sindresorhus/is?sponsor=1" + } + }, + "node_modules/@speed-highlight/core": { + "version": "1.2.14", + "resolved": "https://registry.npmjs.org/@speed-highlight/core/-/core-1.2.14.tgz", + "integrity": "sha512-G4ewlBNhUtlLvrJTb88d2mdy2KRijzs4UhnlrOSRT4bmjh/IqNElZa3zkrZ+TC47TwtlDWzVLFADljF1Ijp5hA==", + "dev": true, + "license": "CC0-1.0" + }, "node_modules/@stylistic/eslint-plugin": { "version": "5.9.0", "resolved": "https://registry.npmjs.org/@stylistic/eslint-plugin/-/eslint-plugin-5.9.0.tgz", @@ -8357,6 +9065,13 @@ "resolved": "https://registry.npmjs.org/bind-event-listener/-/bind-event-listener-3.0.0.tgz", "integrity": "sha512-PJvH288AWQhKs2v9zyfYdPzlPqf5bXbGMmhmUIY9x4dAUGIWgomO771oBQNwJnMQSnUIXhKu6sgzpBRXTlvb8Q==" }, + "node_modules/blake3-wasm": { + "version": "2.1.5", + "resolved": "https://registry.npmjs.org/blake3-wasm/-/blake3-wasm-2.1.5.tgz", + "integrity": "sha512-F1+K8EbfOZE49dtoPtmxUQrpXaBIl3ICvasLh+nJta0xkz+9kF/7uet9fLnwKqhDrmj6g+6K3Tw9yQPUg2ka5g==", + "dev": true, + "license": "MIT" + }, "node_modules/blurhash": { "version": "2.0.5", "resolved": "https://registry.npmjs.org/blurhash/-/blurhash-2.0.5.tgz", @@ -8728,6 +9443,20 @@ "resolved": "https://registry.npmjs.org/convert-source-map/-/convert-source-map-2.0.0.tgz", "integrity": "sha512-Kvp459HrV2FEJ1CAsi1Ku+MY3kasH19TFykTz2xWmMeq6bk2NU3XXvfJ+Q61m0xktWwt+1HSYf3JZsTms3aRJg==" }, + "node_modules/cookie": { + "version": "1.1.1", + "resolved": "https://registry.npmjs.org/cookie/-/cookie-1.1.1.tgz", + "integrity": "sha512-ei8Aos7ja0weRpFzJnEA9UHJ/7XQmqglbRwnf2ATjcB9Wq874VKH9kfjjirM6UhU2/E5fFYadylyhFldcqSidQ==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=18" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/express" + } + }, "node_modules/core-js-compat": { "version": "3.48.0", "resolved": "https://registry.npmjs.org/core-js-compat/-/core-js-compat-3.48.0.tgz", @@ -8971,6 +9700,16 @@ "url": "https://github.com/sponsors/ljharb" } }, + "node_modules/detect-libc": { + "version": "2.1.2", + "resolved": "https://registry.npmjs.org/detect-libc/-/detect-libc-2.1.2.tgz", + "integrity": "sha512-Btj2BOOO83o3WyH59e8MgXsxEQVcarkUOpEYrubB0urwnN10yQ364rsiByU11nZlqWYZm05i/of7io4mzihBtQ==", + "dev": true, + "license": "Apache-2.0", + "engines": { + "node": ">=8" + } + }, "node_modules/direction": { "version": "1.0.4", "resolved": "https://registry.npmjs.org/direction/-/direction-1.0.4.tgz", @@ -9157,6 +9896,16 @@ "is-arrayish": "^0.2.1" } }, + "node_modules/error-stack-parser-es": { + "version": "1.0.5", + "resolved": "https://registry.npmjs.org/error-stack-parser-es/-/error-stack-parser-es-1.0.5.tgz", + "integrity": "sha512-5qucVt2XcuGMcEGgWI7i+yZpmpByQ8J1lHhcL7PwqCwu9FPP3VUXzT4ltHe5i2z9dePwEHcDVOAfSnHsOlCXRA==", + "dev": true, + "license": "MIT", + "funding": { + "url": "https://github.com/sponsors/antfu" + } + }, "node_modules/es-abstract": { "version": "1.24.1", "resolved": "https://registry.npmjs.org/es-abstract/-/es-abstract-1.24.1.tgz", @@ -11766,6 +12515,16 @@ "json-buffer": "3.0.1" } }, + "node_modules/kleur": { + "version": "4.1.5", + "resolved": "https://registry.npmjs.org/kleur/-/kleur-4.1.5.tgz", + "integrity": "sha512-o+NO+8WrRiQEE4/7nwRJhN1HWpVmJm511pBHUxPLtp0BUISzlBplORYSmTclCnJvQq2tKu/sgl3xVpkc7ZWuQQ==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=6" + } + }, "node_modules/knip": { "version": "5.85.0", "resolved": "https://registry.npmjs.org/knip/-/knip-5.85.0.tgz", @@ -12109,6 +12868,27 @@ "millify": "bin/millify" } }, + "node_modules/miniflare": { + "version": "4.20260301.1", + "resolved": "https://registry.npmjs.org/miniflare/-/miniflare-4.20260301.1.tgz", + "integrity": "sha512-fqkHx0QMKswRH9uqQQQOU/RoaS3Wjckxy3CUX3YGJr0ZIMu7ObvI+NovdYi6RIsSPthNtq+3TPmRNxjeRiasog==", + "dev": true, + "license": "MIT", + "dependencies": { + "@cspotcode/source-map-support": "0.8.1", + "sharp": "^0.34.5", + "undici": "7.18.2", + "workerd": "1.20260301.1", + "ws": "8.18.0", + "youch": "4.1.0-beta.10" + }, + "bin": { + "miniflare": "bootstrap.js" + }, + "engines": { + "node": ">=18.0.0" + } + }, "node_modules/minimatch": { "version": "3.1.5", "resolved": "https://registry.npmjs.org/minimatch/-/minimatch-3.1.5.tgz", @@ -12613,6 +13393,13 @@ "node": "20 || >=22" } }, + "node_modules/path-to-regexp": { + "version": "6.3.0", + "resolved": "https://registry.npmjs.org/path-to-regexp/-/path-to-regexp-6.3.0.tgz", + "integrity": "sha512-Yhpw4T9C6hPpgPeA28us07OJeqZ5EzQTkbfwuhsUg0c237RomFoETJgmp2sa3F/41gfLE6G5cqcYwznmeEeOlQ==", + "dev": true, + "license": "MIT" + }, "node_modules/path-type": { "version": "4.0.0", "resolved": "https://registry.npmjs.org/path-type/-/path-type-4.0.0.tgz", @@ -13527,6 +14314,51 @@ "node": ">= 0.4" } }, + "node_modules/sharp": { + "version": "0.34.5", + "resolved": "https://registry.npmjs.org/sharp/-/sharp-0.34.5.tgz", + "integrity": "sha512-Ou9I5Ft9WNcCbXrU9cMgPBcCK8LiwLqcbywW3t4oDV37n1pzpuNLsYiAV8eODnjbtQlSDwZ2cUEeQz4E54Hltg==", + "dev": true, + "hasInstallScript": true, + "license": "Apache-2.0", + "dependencies": { + "@img/colour": "^1.0.0", + "detect-libc": "^2.1.2", + "semver": "^7.7.3" + }, + "engines": { + "node": "^18.17.0 || ^20.3.0 || >=21.0.0" + }, + "funding": { + "url": "https://opencollective.com/libvips" + }, + "optionalDependencies": { + "@img/sharp-darwin-arm64": "0.34.5", + "@img/sharp-darwin-x64": "0.34.5", + "@img/sharp-libvips-darwin-arm64": "1.2.4", + "@img/sharp-libvips-darwin-x64": "1.2.4", + "@img/sharp-libvips-linux-arm": "1.2.4", + "@img/sharp-libvips-linux-arm64": "1.2.4", + "@img/sharp-libvips-linux-ppc64": "1.2.4", + "@img/sharp-libvips-linux-riscv64": "1.2.4", + "@img/sharp-libvips-linux-s390x": "1.2.4", + "@img/sharp-libvips-linux-x64": "1.2.4", + "@img/sharp-libvips-linuxmusl-arm64": "1.2.4", + "@img/sharp-libvips-linuxmusl-x64": "1.2.4", + "@img/sharp-linux-arm": "0.34.5", + "@img/sharp-linux-arm64": "0.34.5", + "@img/sharp-linux-ppc64": "0.34.5", + "@img/sharp-linux-riscv64": "0.34.5", + "@img/sharp-linux-s390x": "0.34.5", + "@img/sharp-linux-x64": "0.34.5", + "@img/sharp-linuxmusl-arm64": "0.34.5", + "@img/sharp-linuxmusl-x64": "0.34.5", + "@img/sharp-wasm32": "0.34.5", + "@img/sharp-win32-arm64": "0.34.5", + "@img/sharp-win32-ia32": "0.34.5", + "@img/sharp-win32-x64": "0.34.5" + } + }, "node_modules/shebang-command": { "version": "2.0.0", "resolved": "https://registry.npmjs.org/shebang-command/-/shebang-command-2.0.0.tgz", @@ -14426,12 +15258,32 @@ "url": "https://github.com/sponsors/ljharb" } }, + "node_modules/undici": { + "version": "7.18.2", + "resolved": "https://registry.npmjs.org/undici/-/undici-7.18.2.tgz", + "integrity": "sha512-y+8YjDFzWdQlSE9N5nzKMT3g4a5UBX1HKowfdXh0uvAnTaqqwqB92Jt4UXBAeKekDs5IaDKyJFR4X1gYVCgXcw==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=20.18.1" + } + }, "node_modules/undici-types": { "version": "7.16.0", "resolved": "https://registry.npmjs.org/undici-types/-/undici-types-7.16.0.tgz", "integrity": "sha512-Zz+aZWSj8LE6zoxD+xrjh4VfkIG8Ya6LvYkZqtUQGJPZjYl53ypCaUwWqo7eI0x66KBGeRo+mlBEkMSeSZ38Nw==", "license": "MIT" }, + "node_modules/unenv": { + "version": "2.0.0-rc.24", + "resolved": "https://registry.npmjs.org/unenv/-/unenv-2.0.0-rc.24.tgz", + "integrity": "sha512-i7qRCmY42zmCwnYlh9H2SvLEypEFGye5iRmEMKjcGi7zk9UquigRjFtTLz0TYqr0ZGLZhaMHl/foy1bZR+Cwlw==", + "dev": true, + "license": "MIT", + "dependencies": { + "pathe": "^2.0.3" + } + }, "node_modules/unhomoglyph": { "version": "1.0.6", "resolved": "https://registry.npmjs.org/unhomoglyph/-/unhomoglyph-1.0.6.tgz", @@ -15679,6 +16531,62 @@ "workbox-core": "7.4.0" } }, + "node_modules/workerd": { + "version": "1.20260301.1", + "resolved": "https://registry.npmjs.org/workerd/-/workerd-1.20260301.1.tgz", + "integrity": "sha512-oterQ1IFd3h7PjCfT4znSFOkJCvNQ6YMOyZ40YsnO3nrSpgB4TbJVYWFOnyJAw71/RQuupfVqZZWKvsy8GO3fw==", + "dev": true, + "hasInstallScript": true, + "license": "Apache-2.0", + "bin": { + "workerd": "bin/workerd" + }, + "engines": { + "node": ">=16" + }, + "optionalDependencies": { + "@cloudflare/workerd-darwin-64": "1.20260301.1", + "@cloudflare/workerd-darwin-arm64": "1.20260301.1", + "@cloudflare/workerd-linux-64": "1.20260301.1", + "@cloudflare/workerd-linux-arm64": "1.20260301.1", + "@cloudflare/workerd-windows-64": "1.20260301.1" + } + }, + "node_modules/wrangler": { + "version": "4.70.0", + "resolved": "https://registry.npmjs.org/wrangler/-/wrangler-4.70.0.tgz", + "integrity": "sha512-PNDZ9o4e+B5x+1bUbz62Hmwz6G9lw+I9pnYe/AguLddJFjfIyt2cmFOUOb3eOZSoXsrhcEPUg2YidYIbVwUkfw==", + "dev": true, + "license": "MIT OR Apache-2.0", + "dependencies": { + "@cloudflare/kv-asset-handler": "0.4.2", + "@cloudflare/unenv-preset": "2.14.0", + "blake3-wasm": "2.1.5", + "esbuild": "0.27.3", + "miniflare": "4.20260301.1", + "path-to-regexp": "6.3.0", + "unenv": "2.0.0-rc.24", + "workerd": "1.20260301.1" + }, + "bin": { + "wrangler": "bin/wrangler.js", + "wrangler2": "bin/wrangler.js" + }, + "engines": { + "node": ">=20.0.0" + }, + "optionalDependencies": { + "fsevents": "~2.3.2" + }, + "peerDependencies": { + "@cloudflare/workers-types": "^4.20260226.1" + }, + "peerDependenciesMeta": { + "@cloudflare/workers-types": { + "optional": true + } + } + }, "node_modules/wrap-ansi": { "version": "7.0.0", "resolved": "https://registry.npmjs.org/wrap-ansi/-/wrap-ansi-7.0.0.tgz", @@ -15695,6 +16603,28 @@ "url": "https://github.com/chalk/wrap-ansi?sponsor=1" } }, + "node_modules/ws": { + "version": "8.18.0", + "resolved": "https://registry.npmjs.org/ws/-/ws-8.18.0.tgz", + "integrity": "sha512-8VbfWfHLbbwu3+N6OKsOMpBdT4kXPDDB9cJk2bJ6mh9ucxdlnNvH1e+roYkKmN9Nxw2yjz7VzeO9oOz2zJ04Pw==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=10.0.0" + }, + "peerDependencies": { + "bufferutil": "^4.0.1", + "utf-8-validate": ">=5.0.2" + }, + "peerDependenciesMeta": { + "bufferutil": { + "optional": true + }, + "utf-8-validate": { + "optional": true + } + } + }, "node_modules/y18n": { "version": "5.0.8", "resolved": "https://registry.npmjs.org/y18n/-/y18n-5.0.8.tgz", @@ -15759,6 +16689,31 @@ "url": "https://github.com/sponsors/sindresorhus" } }, + "node_modules/youch": { + "version": "4.1.0-beta.10", + "resolved": "https://registry.npmjs.org/youch/-/youch-4.1.0-beta.10.tgz", + "integrity": "sha512-rLfVLB4FgQneDr0dv1oddCVZmKjcJ6yX6mS4pU82Mq/Dt9a3cLZQ62pDBL4AUO+uVrCvtWz3ZFUL2HFAFJ/BXQ==", + "dev": true, + "license": "MIT", + "dependencies": { + "@poppinss/colors": "^4.1.5", + "@poppinss/dumper": "^0.6.4", + "@speed-highlight/core": "^1.2.7", + "cookie": "^1.0.2", + "youch-core": "^0.3.3" + } + }, + "node_modules/youch-core": { + "version": "0.3.3", + "resolved": "https://registry.npmjs.org/youch-core/-/youch-core-0.3.3.tgz", + "integrity": "sha512-ho7XuGjLaJ2hWHoK8yFnsUGy2Y5uDpqSTq1FkHLK4/oqKtyUU1AFbOOxY4IpC9f0fTLjwYbslUz0Po5BpD1wrA==", + "dev": true, + "license": "MIT", + "dependencies": { + "@poppinss/exception": "^1.2.2", + "error-stack-parser-es": "^1.0.5" + } + }, "node_modules/zod": { "version": "4.3.6", "resolved": "https://registry.npmjs.org/zod/-/zod-4.3.6.tgz", @@ -16828,6 +17783,87 @@ "@babel/helper-validator-identifier": "^7.28.5" } }, + "@cloudflare/kv-asset-handler": { + "version": "0.4.2", + "resolved": "https://registry.npmjs.org/@cloudflare/kv-asset-handler/-/kv-asset-handler-0.4.2.tgz", + "integrity": "sha512-SIOD2DxrRRwQ+jgzlXCqoEFiKOFqaPjhnNTGKXSRLvp1HiOvapLaFG2kEr9dYQTYe8rKrd9uvDUzmAITeNyaHQ==", + "dev": true + }, + "@cloudflare/unenv-preset": { + "version": "2.14.0", + "resolved": "https://registry.npmjs.org/@cloudflare/unenv-preset/-/unenv-preset-2.14.0.tgz", + "integrity": "sha512-XKAkWhi1nBdNsSEoNG9nkcbyvfUrSjSf+VYVPfOto3gLTZVc3F4g6RASCMh6IixBKCG2yDgZKQIHGKtjcnLnKg==", + "dev": true + }, + "@cloudflare/vite-plugin": { + "version": "1.26.0", + "resolved": "https://registry.npmjs.org/@cloudflare/vite-plugin/-/vite-plugin-1.26.0.tgz", + "integrity": "sha512-F5jSOj9JeWMp9iQa2x+Ocjz++SCfK6Phcca/YLkaddPw5ie7W1VvEWudQ/gxYtRd47mQ/PfCLkE9QGyy6OGEng==", + "dev": true, + "requires": { + "@cloudflare/unenv-preset": "2.14.0", + "miniflare": "4.20260301.1", + "unenv": "2.0.0-rc.24", + "wrangler": "4.70.0", + "ws": "8.18.0" + } + }, + "@cloudflare/workerd-darwin-64": { + "version": "1.20260301.1", + "resolved": "https://registry.npmjs.org/@cloudflare/workerd-darwin-64/-/workerd-darwin-64-1.20260301.1.tgz", + "integrity": "sha512-+kJvwociLrvy1JV9BAvoSVsMEIYD982CpFmo/yMEvBwxDIjltYsLTE8DLi0mCkGsQ8Ygidv2fD9wavzXeiY7OQ==", + "dev": true, + "optional": true + }, + "@cloudflare/workerd-darwin-arm64": { + "version": "1.20260301.1", + "resolved": "https://registry.npmjs.org/@cloudflare/workerd-darwin-arm64/-/workerd-darwin-arm64-1.20260301.1.tgz", + "integrity": "sha512-PPIetY3e67YBr9O4UhILK8nbm5TqUDl14qx4rwFNrRSBOvlzuczzbd4BqgpAtbGVFxKp1PWpjAnBvGU/OI/tLQ==", + "dev": true, + "optional": true + }, + "@cloudflare/workerd-linux-64": { + "version": "1.20260301.1", + "resolved": "https://registry.npmjs.org/@cloudflare/workerd-linux-64/-/workerd-linux-64-1.20260301.1.tgz", + "integrity": "sha512-Gu5vaVTZuYl3cHa+u5CDzSVDBvSkfNyuAHi6Mdfut7TTUdcb3V5CIcR/mXRSyMXzEy9YxEWIfdKMxOMBjupvYQ==", + "dev": true, + "optional": true + }, + "@cloudflare/workerd-linux-arm64": { + "version": "1.20260301.1", + "resolved": "https://registry.npmjs.org/@cloudflare/workerd-linux-arm64/-/workerd-linux-arm64-1.20260301.1.tgz", + "integrity": "sha512-igL1pkyCXW6GiGpjdOAvqMi87UW0LMc/+yIQe/CSzuZJm5GzXoAMrwVTkCFnikk6JVGELrM5x0tGYlxa0sk5Iw==", + "dev": true, + "optional": true + }, + "@cloudflare/workerd-windows-64": { + "version": "1.20260301.1", + "resolved": "https://registry.npmjs.org/@cloudflare/workerd-windows-64/-/workerd-windows-64-1.20260301.1.tgz", + "integrity": "sha512-Q0wMJ4kcujXILwQKQFc1jaYamVsNvjuECzvRrTI8OxGFMx2yq9aOsswViE4X1gaS2YQQ5u0JGwuGi5WdT1Lt7A==", + "dev": true, + "optional": true + }, + "@cspotcode/source-map-support": { + "version": "0.8.1", + "resolved": "https://registry.npmjs.org/@cspotcode/source-map-support/-/source-map-support-0.8.1.tgz", + "integrity": "sha512-IchNf6dN4tHoMFIn/7OE8LWZ19Y6q/67Bmf6vnGREv8RSbBVb9LPJxEcnwrcwX6ixSvaiGoomAUvu4YSxXrVgw==", + "dev": true, + "requires": { + "@jridgewell/trace-mapping": "0.3.9" + }, + "dependencies": { + "@jridgewell/trace-mapping": { + "version": "0.3.9", + "resolved": "https://registry.npmjs.org/@jridgewell/trace-mapping/-/trace-mapping-0.3.9.tgz", + "integrity": "sha512-3Belt6tdc8bPgAtbcmdtNJlirVoTmEb5e2gC94PnkwEW9jI6CAHUeoG85tjWP5WquqfavoMtMwiG4P926ZKKuQ==", + "dev": true, + "requires": { + "@jridgewell/resolve-uri": "^3.0.3", + "@jridgewell/sourcemap-codec": "^1.4.10" + } + } + } + }, "@element-hq/element-call-embedded": { "version": "0.16.3", "resolved": "https://registry.npmjs.org/@element-hq/element-call-embedded/-/element-call-embedded-0.16.3.tgz", @@ -17259,6 +18295,213 @@ "integrity": "sha512-bV0Tgo9K4hfPCek+aMAn81RppFKv2ySDQeMoSZuvTASywNTnVJCArCZE2FWqpvIatKu7VMRLWlR1EazvVhDyhQ==", "dev": true }, + "@img/colour": { + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/@img/colour/-/colour-1.1.0.tgz", + "integrity": "sha512-Td76q7j57o/tLVdgS746cYARfSyxk8iEfRxewL9h4OMzYhbW4TAcppl0mT4eyqXddh6L/jwoM75mo7ixa/pCeQ==", + "dev": true + }, + "@img/sharp-darwin-arm64": { + "version": "0.34.5", + "resolved": "https://registry.npmjs.org/@img/sharp-darwin-arm64/-/sharp-darwin-arm64-0.34.5.tgz", + "integrity": "sha512-imtQ3WMJXbMY4fxb/Ndp6HBTNVtWCUI0WdobyheGf5+ad6xX8VIDO8u2xE4qc/fr08CKG/7dDseFtn6M6g/r3w==", + "dev": true, + "optional": true, + "requires": { + "@img/sharp-libvips-darwin-arm64": "1.2.4" + } + }, + "@img/sharp-darwin-x64": { + "version": "0.34.5", + "resolved": "https://registry.npmjs.org/@img/sharp-darwin-x64/-/sharp-darwin-x64-0.34.5.tgz", + "integrity": "sha512-YNEFAF/4KQ/PeW0N+r+aVVsoIY0/qxxikF2SWdp+NRkmMB7y9LBZAVqQ4yhGCm/H3H270OSykqmQMKLBhBJDEw==", + "dev": true, + "optional": true, + "requires": { + "@img/sharp-libvips-darwin-x64": "1.2.4" + } + }, + "@img/sharp-libvips-darwin-arm64": { + "version": "1.2.4", + "resolved": "https://registry.npmjs.org/@img/sharp-libvips-darwin-arm64/-/sharp-libvips-darwin-arm64-1.2.4.tgz", + "integrity": "sha512-zqjjo7RatFfFoP0MkQ51jfuFZBnVE2pRiaydKJ1G/rHZvnsrHAOcQALIi9sA5co5xenQdTugCvtb1cuf78Vf4g==", + "dev": true, + "optional": true + }, + "@img/sharp-libvips-darwin-x64": { + "version": "1.2.4", + "resolved": "https://registry.npmjs.org/@img/sharp-libvips-darwin-x64/-/sharp-libvips-darwin-x64-1.2.4.tgz", + "integrity": "sha512-1IOd5xfVhlGwX+zXv2N93k0yMONvUlANylbJw1eTah8K/Jtpi15KC+WSiaX/nBmbm2HxRM1gZ0nSdjSsrZbGKg==", + "dev": true, + "optional": true + }, + "@img/sharp-libvips-linux-arm": { + "version": "1.2.4", + "resolved": "https://registry.npmjs.org/@img/sharp-libvips-linux-arm/-/sharp-libvips-linux-arm-1.2.4.tgz", + "integrity": "sha512-bFI7xcKFELdiNCVov8e44Ia4u2byA+l3XtsAj+Q8tfCwO6BQ8iDojYdvoPMqsKDkuoOo+X6HZA0s0q11ANMQ8A==", + "dev": true, + "optional": true + }, + "@img/sharp-libvips-linux-arm64": { + "version": "1.2.4", + "resolved": "https://registry.npmjs.org/@img/sharp-libvips-linux-arm64/-/sharp-libvips-linux-arm64-1.2.4.tgz", + "integrity": "sha512-excjX8DfsIcJ10x1Kzr4RcWe1edC9PquDRRPx3YVCvQv+U5p7Yin2s32ftzikXojb1PIFc/9Mt28/y+iRklkrw==", + "dev": true, + "optional": true + }, + "@img/sharp-libvips-linux-ppc64": { + "version": "1.2.4", + "resolved": "https://registry.npmjs.org/@img/sharp-libvips-linux-ppc64/-/sharp-libvips-linux-ppc64-1.2.4.tgz", + "integrity": "sha512-FMuvGijLDYG6lW+b/UvyilUWu5Ayu+3r2d1S8notiGCIyYU/76eig1UfMmkZ7vwgOrzKzlQbFSuQfgm7GYUPpA==", + "dev": true, + "optional": true + }, + "@img/sharp-libvips-linux-riscv64": { + "version": "1.2.4", + "resolved": "https://registry.npmjs.org/@img/sharp-libvips-linux-riscv64/-/sharp-libvips-linux-riscv64-1.2.4.tgz", + "integrity": "sha512-oVDbcR4zUC0ce82teubSm+x6ETixtKZBh/qbREIOcI3cULzDyb18Sr/Wcyx7NRQeQzOiHTNbZFF1UwPS2scyGA==", + "dev": true, + "optional": true + }, + "@img/sharp-libvips-linux-s390x": { + "version": "1.2.4", + "resolved": "https://registry.npmjs.org/@img/sharp-libvips-linux-s390x/-/sharp-libvips-linux-s390x-1.2.4.tgz", + "integrity": "sha512-qmp9VrzgPgMoGZyPvrQHqk02uyjA0/QrTO26Tqk6l4ZV0MPWIW6LTkqOIov+J1yEu7MbFQaDpwdwJKhbJvuRxQ==", + "dev": true, + "optional": true + }, + "@img/sharp-libvips-linux-x64": { + "version": "1.2.4", + "resolved": "https://registry.npmjs.org/@img/sharp-libvips-linux-x64/-/sharp-libvips-linux-x64-1.2.4.tgz", + "integrity": "sha512-tJxiiLsmHc9Ax1bz3oaOYBURTXGIRDODBqhveVHonrHJ9/+k89qbLl0bcJns+e4t4rvaNBxaEZsFtSfAdquPrw==", + "dev": true, + "optional": true + }, + "@img/sharp-libvips-linuxmusl-arm64": { + "version": "1.2.4", + "resolved": "https://registry.npmjs.org/@img/sharp-libvips-linuxmusl-arm64/-/sharp-libvips-linuxmusl-arm64-1.2.4.tgz", + "integrity": "sha512-FVQHuwx1IIuNow9QAbYUzJ+En8KcVm9Lk5+uGUQJHaZmMECZmOlix9HnH7n1TRkXMS0pGxIJokIVB9SuqZGGXw==", + "dev": true, + "optional": true + }, + "@img/sharp-libvips-linuxmusl-x64": { + "version": "1.2.4", + "resolved": "https://registry.npmjs.org/@img/sharp-libvips-linuxmusl-x64/-/sharp-libvips-linuxmusl-x64-1.2.4.tgz", + "integrity": "sha512-+LpyBk7L44ZIXwz/VYfglaX/okxezESc6UxDSoyo2Ks6Jxc4Y7sGjpgU9s4PMgqgjj1gZCylTieNamqA1MF7Dg==", + "dev": true, + "optional": true + }, + "@img/sharp-linux-arm": { + "version": "0.34.5", + "resolved": "https://registry.npmjs.org/@img/sharp-linux-arm/-/sharp-linux-arm-0.34.5.tgz", + "integrity": "sha512-9dLqsvwtg1uuXBGZKsxem9595+ujv0sJ6Vi8wcTANSFpwV/GONat5eCkzQo/1O6zRIkh0m/8+5BjrRr7jDUSZw==", + "dev": true, + "optional": true, + "requires": { + "@img/sharp-libvips-linux-arm": "1.2.4" + } + }, + "@img/sharp-linux-arm64": { + "version": "0.34.5", + "resolved": "https://registry.npmjs.org/@img/sharp-linux-arm64/-/sharp-linux-arm64-0.34.5.tgz", + "integrity": "sha512-bKQzaJRY/bkPOXyKx5EVup7qkaojECG6NLYswgktOZjaXecSAeCWiZwwiFf3/Y+O1HrauiE3FVsGxFg8c24rZg==", + "dev": true, + "optional": true, + "requires": { + "@img/sharp-libvips-linux-arm64": "1.2.4" + } + }, + "@img/sharp-linux-ppc64": { + "version": "0.34.5", + "resolved": "https://registry.npmjs.org/@img/sharp-linux-ppc64/-/sharp-linux-ppc64-0.34.5.tgz", + "integrity": "sha512-7zznwNaqW6YtsfrGGDA6BRkISKAAE1Jo0QdpNYXNMHu2+0dTrPflTLNkpc8l7MUP5M16ZJcUvysVWWrMefZquA==", + "dev": true, + "optional": true, + "requires": { + "@img/sharp-libvips-linux-ppc64": "1.2.4" + } + }, + "@img/sharp-linux-riscv64": { + "version": "0.34.5", + "resolved": "https://registry.npmjs.org/@img/sharp-linux-riscv64/-/sharp-linux-riscv64-0.34.5.tgz", + "integrity": "sha512-51gJuLPTKa7piYPaVs8GmByo7/U7/7TZOq+cnXJIHZKavIRHAP77e3N2HEl3dgiqdD/w0yUfiJnII77PuDDFdw==", + "dev": true, + "optional": true, + "requires": { + "@img/sharp-libvips-linux-riscv64": "1.2.4" + } + }, + "@img/sharp-linux-s390x": { + "version": "0.34.5", + "resolved": "https://registry.npmjs.org/@img/sharp-linux-s390x/-/sharp-linux-s390x-0.34.5.tgz", + "integrity": "sha512-nQtCk0PdKfho3eC5MrbQoigJ2gd1CgddUMkabUj+rBevs8tZ2cULOx46E7oyX+04WGfABgIwmMC0VqieTiR4jg==", + "dev": true, + "optional": true, + "requires": { + "@img/sharp-libvips-linux-s390x": "1.2.4" + } + }, + "@img/sharp-linux-x64": { + "version": "0.34.5", + "resolved": "https://registry.npmjs.org/@img/sharp-linux-x64/-/sharp-linux-x64-0.34.5.tgz", + "integrity": "sha512-MEzd8HPKxVxVenwAa+JRPwEC7QFjoPWuS5NZnBt6B3pu7EG2Ge0id1oLHZpPJdn3OQK+BQDiw9zStiHBTJQQQQ==", + "dev": true, + "optional": true, + "requires": { + "@img/sharp-libvips-linux-x64": "1.2.4" + } + }, + "@img/sharp-linuxmusl-arm64": { + "version": "0.34.5", + "resolved": "https://registry.npmjs.org/@img/sharp-linuxmusl-arm64/-/sharp-linuxmusl-arm64-0.34.5.tgz", + "integrity": "sha512-fprJR6GtRsMt6Kyfq44IsChVZeGN97gTD331weR1ex1c1rypDEABN6Tm2xa1wE6lYb5DdEnk03NZPqA7Id21yg==", + "dev": true, + "optional": true, + "requires": { + "@img/sharp-libvips-linuxmusl-arm64": "1.2.4" + } + }, + "@img/sharp-linuxmusl-x64": { + "version": "0.34.5", + "resolved": "https://registry.npmjs.org/@img/sharp-linuxmusl-x64/-/sharp-linuxmusl-x64-0.34.5.tgz", + "integrity": "sha512-Jg8wNT1MUzIvhBFxViqrEhWDGzqymo3sV7z7ZsaWbZNDLXRJZoRGrjulp60YYtV4wfY8VIKcWidjojlLcWrd8Q==", + "dev": true, + "optional": true, + "requires": { + "@img/sharp-libvips-linuxmusl-x64": "1.2.4" + } + }, + "@img/sharp-wasm32": { + "version": "0.34.5", + "resolved": "https://registry.npmjs.org/@img/sharp-wasm32/-/sharp-wasm32-0.34.5.tgz", + "integrity": "sha512-OdWTEiVkY2PHwqkbBI8frFxQQFekHaSSkUIJkwzclWZe64O1X4UlUjqqqLaPbUpMOQk6FBu/HtlGXNblIs0huw==", + "dev": true, + "optional": true, + "requires": { + "@emnapi/runtime": "^1.7.0" + } + }, + "@img/sharp-win32-arm64": { + "version": "0.34.5", + "resolved": "https://registry.npmjs.org/@img/sharp-win32-arm64/-/sharp-win32-arm64-0.34.5.tgz", + "integrity": "sha512-WQ3AgWCWYSb2yt+IG8mnC6Jdk9Whs7O0gxphblsLvdhSpSTtmu69ZG1Gkb6NuvxsNACwiPV6cNSZNzt0KPsw7g==", + "dev": true, + "optional": true + }, + "@img/sharp-win32-ia32": { + "version": "0.34.5", + "resolved": "https://registry.npmjs.org/@img/sharp-win32-ia32/-/sharp-win32-ia32-0.34.5.tgz", + "integrity": "sha512-FV9m/7NmeCmSHDD5j4+4pNI8Cp3aW+JvLoXcTUo0IqyjSfAZJ8dIUmijx1qaJsIiU+Hosw6xM5KijAWRJCSgNg==", + "dev": true, + "optional": true + }, + "@img/sharp-win32-x64": { + "version": "0.34.5", + "resolved": "https://registry.npmjs.org/@img/sharp-win32-x64/-/sharp-win32-x64-0.34.5.tgz", + "integrity": "sha512-+29YMsqY2/9eFEiW93eqWnuLcWcufowXewwSNIT6UwZdUUCrM3oFjMWH/Z6/TMmb4hlFenmfAVbpWeup2jryCw==", + "dev": true, + "optional": true + }, "@internationalized/date": { "version": "3.11.0", "resolved": "https://registry.npmjs.org/@internationalized/date/-/date-3.11.0.tgz", @@ -17660,6 +18903,40 @@ "integrity": "sha512-QNqXyfVS2wm9hweSYD2O7F0G06uurj9kZ96TRQE5Y9hU7+tgdZwIkbAKc5Ocy1HxEY2kuDQa6cQ1WRs/O5LFKA==", "dev": true }, + "@poppinss/colors": { + "version": "4.1.6", + "resolved": "https://registry.npmjs.org/@poppinss/colors/-/colors-4.1.6.tgz", + "integrity": "sha512-H9xkIdFswbS8n1d6vmRd8+c10t2Qe+rZITbbDHHkQixH5+2x1FDGmi/0K+WgWiqQFKPSlIYB7jlH6Kpfn6Fleg==", + "dev": true, + "requires": { + "kleur": "^4.1.5" + } + }, + "@poppinss/dumper": { + "version": "0.6.5", + "resolved": "https://registry.npmjs.org/@poppinss/dumper/-/dumper-0.6.5.tgz", + "integrity": "sha512-NBdYIb90J7LfOI32dOewKI1r7wnkiH6m920puQ3qHUeZkxNkQiFnXVWoE6YtFSv6QOiPPf7ys6i+HWWecDz7sw==", + "dev": true, + "requires": { + "@poppinss/colors": "^4.1.5", + "@sindresorhus/is": "^7.0.2", + "supports-color": "^10.0.0" + }, + "dependencies": { + "supports-color": { + "version": "10.2.2", + "resolved": "https://registry.npmjs.org/supports-color/-/supports-color-10.2.2.tgz", + "integrity": "sha512-SS+jx45GF1QjgEXQx4NJZV9ImqmO2NPz5FNsIHrsDjh2YsHnawpan7SNQ1o8NuhrbHZy9AZhIoCUiCeaW/C80g==", + "dev": true + } + } + }, + "@poppinss/exception": { + "version": "1.2.3", + "resolved": "https://registry.npmjs.org/@poppinss/exception/-/exception-1.2.3.tgz", + "integrity": "sha512-dCED+QRChTVatE9ibtoaxc+WkdzOSjYTKi/+uacHWIsfodVfpsueo3+DKpgU5Px8qXjgmXkSvhXvSCz3fnP9lw==", + "dev": true + }, "@react-aria/breadcrumbs": { "version": "3.5.31", "resolved": "https://registry.npmjs.org/@react-aria/breadcrumbs/-/breadcrumbs-3.5.31.tgz", @@ -19190,6 +20467,18 @@ "integrity": "sha512-zt6OdqaDoOnJ1ZYsCYGt9YmWzDXl4vQdKTyJev62gFhRGKdx7mcT54V9KIjg+d2wi9EXsPvAPKe7i7WjfVWB8g==", "dev": true }, + "@sindresorhus/is": { + "version": "7.2.0", + "resolved": "https://registry.npmjs.org/@sindresorhus/is/-/is-7.2.0.tgz", + "integrity": "sha512-P1Cz1dWaFfR4IR+U13mqqiGsLFf1KbayybWwdd2vfctdV6hDpUkgCY0nKOLLTMSoRd/jJNjtbqzf13K8DCCXQw==", + "dev": true + }, + "@speed-highlight/core": { + "version": "1.2.14", + "resolved": "https://registry.npmjs.org/@speed-highlight/core/-/core-1.2.14.tgz", + "integrity": "sha512-G4ewlBNhUtlLvrJTb88d2mdy2KRijzs4UhnlrOSRT4bmjh/IqNElZa3zkrZ+TC47TwtlDWzVLFADljF1Ijp5hA==", + "dev": true + }, "@stylistic/eslint-plugin": { "version": "5.9.0", "resolved": "https://registry.npmjs.org/@stylistic/eslint-plugin/-/eslint-plugin-5.9.0.tgz", @@ -20695,6 +21984,12 @@ "resolved": "https://registry.npmjs.org/bind-event-listener/-/bind-event-listener-3.0.0.tgz", "integrity": "sha512-PJvH288AWQhKs2v9zyfYdPzlPqf5bXbGMmhmUIY9x4dAUGIWgomO771oBQNwJnMQSnUIXhKu6sgzpBRXTlvb8Q==" }, + "blake3-wasm": { + "version": "2.1.5", + "resolved": "https://registry.npmjs.org/blake3-wasm/-/blake3-wasm-2.1.5.tgz", + "integrity": "sha512-F1+K8EbfOZE49dtoPtmxUQrpXaBIl3ICvasLh+nJta0xkz+9kF/7uet9fLnwKqhDrmj6g+6K3Tw9yQPUg2ka5g==", + "dev": true + }, "blurhash": { "version": "2.0.5", "resolved": "https://registry.npmjs.org/blurhash/-/blurhash-2.0.5.tgz", @@ -20934,6 +22229,12 @@ "resolved": "https://registry.npmjs.org/convert-source-map/-/convert-source-map-2.0.0.tgz", "integrity": "sha512-Kvp459HrV2FEJ1CAsi1Ku+MY3kasH19TFykTz2xWmMeq6bk2NU3XXvfJ+Q61m0xktWwt+1HSYf3JZsTms3aRJg==" }, + "cookie": { + "version": "1.1.1", + "resolved": "https://registry.npmjs.org/cookie/-/cookie-1.1.1.tgz", + "integrity": "sha512-ei8Aos7ja0weRpFzJnEA9UHJ/7XQmqglbRwnf2ATjcB9Wq874VKH9kfjjirM6UhU2/E5fFYadylyhFldcqSidQ==", + "dev": true + }, "core-js-compat": { "version": "3.48.0", "resolved": "https://registry.npmjs.org/core-js-compat/-/core-js-compat-3.48.0.tgz", @@ -21082,6 +22383,12 @@ "object-keys": "^1.1.1" } }, + "detect-libc": { + "version": "2.1.2", + "resolved": "https://registry.npmjs.org/detect-libc/-/detect-libc-2.1.2.tgz", + "integrity": "sha512-Btj2BOOO83o3WyH59e8MgXsxEQVcarkUOpEYrubB0urwnN10yQ364rsiByU11nZlqWYZm05i/of7io4mzihBtQ==", + "dev": true + }, "direction": { "version": "1.0.4", "resolved": "https://registry.npmjs.org/direction/-/direction-1.0.4.tgz", @@ -21202,6 +22509,12 @@ "is-arrayish": "^0.2.1" } }, + "error-stack-parser-es": { + "version": "1.0.5", + "resolved": "https://registry.npmjs.org/error-stack-parser-es/-/error-stack-parser-es-1.0.5.tgz", + "integrity": "sha512-5qucVt2XcuGMcEGgWI7i+yZpmpByQ8J1lHhcL7PwqCwu9FPP3VUXzT4ltHe5i2z9dePwEHcDVOAfSnHsOlCXRA==", + "dev": true + }, "es-abstract": { "version": "1.24.1", "resolved": "https://registry.npmjs.org/es-abstract/-/es-abstract-1.24.1.tgz", @@ -22897,6 +24210,12 @@ "json-buffer": "3.0.1" } }, + "kleur": { + "version": "4.1.5", + "resolved": "https://registry.npmjs.org/kleur/-/kleur-4.1.5.tgz", + "integrity": "sha512-o+NO+8WrRiQEE4/7nwRJhN1HWpVmJm511pBHUxPLtp0BUISzlBplORYSmTclCnJvQq2tKu/sgl3xVpkc7ZWuQQ==", + "dev": true + }, "knip": { "version": "5.85.0", "resolved": "https://registry.npmjs.org/knip/-/knip-5.85.0.tgz", @@ -23134,6 +24453,20 @@ "yargs": "^17.0.1" } }, + "miniflare": { + "version": "4.20260301.1", + "resolved": "https://registry.npmjs.org/miniflare/-/miniflare-4.20260301.1.tgz", + "integrity": "sha512-fqkHx0QMKswRH9uqQQQOU/RoaS3Wjckxy3CUX3YGJr0ZIMu7ObvI+NovdYi6RIsSPthNtq+3TPmRNxjeRiasog==", + "dev": true, + "requires": { + "@cspotcode/source-map-support": "0.8.1", + "sharp": "^0.34.5", + "undici": "7.18.2", + "workerd": "1.20260301.1", + "ws": "8.18.0", + "youch": "4.1.0-beta.10" + } + }, "minimatch": { "version": "3.1.5", "resolved": "https://registry.npmjs.org/minimatch/-/minimatch-3.1.5.tgz", @@ -23473,6 +24806,12 @@ } } }, + "path-to-regexp": { + "version": "6.3.0", + "resolved": "https://registry.npmjs.org/path-to-regexp/-/path-to-regexp-6.3.0.tgz", + "integrity": "sha512-Yhpw4T9C6hPpgPeA28us07OJeqZ5EzQTkbfwuhsUg0c237RomFoETJgmp2sa3F/41gfLE6G5cqcYwznmeEeOlQ==", + "dev": true + }, "path-type": { "version": "4.0.0", "resolved": "https://registry.npmjs.org/path-type/-/path-type-4.0.0.tgz", @@ -24053,6 +25392,41 @@ "es-object-atoms": "^1.0.0" } }, + "sharp": { + "version": "0.34.5", + "resolved": "https://registry.npmjs.org/sharp/-/sharp-0.34.5.tgz", + "integrity": "sha512-Ou9I5Ft9WNcCbXrU9cMgPBcCK8LiwLqcbywW3t4oDV37n1pzpuNLsYiAV8eODnjbtQlSDwZ2cUEeQz4E54Hltg==", + "dev": true, + "requires": { + "@img/colour": "^1.0.0", + "@img/sharp-darwin-arm64": "0.34.5", + "@img/sharp-darwin-x64": "0.34.5", + "@img/sharp-libvips-darwin-arm64": "1.2.4", + "@img/sharp-libvips-darwin-x64": "1.2.4", + "@img/sharp-libvips-linux-arm": "1.2.4", + "@img/sharp-libvips-linux-arm64": "1.2.4", + "@img/sharp-libvips-linux-ppc64": "1.2.4", + "@img/sharp-libvips-linux-riscv64": "1.2.4", + "@img/sharp-libvips-linux-s390x": "1.2.4", + "@img/sharp-libvips-linux-x64": "1.2.4", + "@img/sharp-libvips-linuxmusl-arm64": "1.2.4", + "@img/sharp-libvips-linuxmusl-x64": "1.2.4", + "@img/sharp-linux-arm": "0.34.5", + "@img/sharp-linux-arm64": "0.34.5", + "@img/sharp-linux-ppc64": "0.34.5", + "@img/sharp-linux-riscv64": "0.34.5", + "@img/sharp-linux-s390x": "0.34.5", + "@img/sharp-linux-x64": "0.34.5", + "@img/sharp-linuxmusl-arm64": "0.34.5", + "@img/sharp-linuxmusl-x64": "0.34.5", + "@img/sharp-wasm32": "0.34.5", + "@img/sharp-win32-arm64": "0.34.5", + "@img/sharp-win32-ia32": "0.34.5", + "@img/sharp-win32-x64": "0.34.5", + "detect-libc": "^2.1.2", + "semver": "^7.7.3" + } + }, "shebang-command": { "version": "2.0.0", "resolved": "https://registry.npmjs.org/shebang-command/-/shebang-command-2.0.0.tgz", @@ -24651,11 +26025,26 @@ "which-boxed-primitive": "^1.1.1" } }, + "undici": { + "version": "7.18.2", + "resolved": "https://registry.npmjs.org/undici/-/undici-7.18.2.tgz", + "integrity": "sha512-y+8YjDFzWdQlSE9N5nzKMT3g4a5UBX1HKowfdXh0uvAnTaqqwqB92Jt4UXBAeKekDs5IaDKyJFR4X1gYVCgXcw==", + "dev": true + }, "undici-types": { "version": "7.16.0", "resolved": "https://registry.npmjs.org/undici-types/-/undici-types-7.16.0.tgz", "integrity": "sha512-Zz+aZWSj8LE6zoxD+xrjh4VfkIG8Ya6LvYkZqtUQGJPZjYl53ypCaUwWqo7eI0x66KBGeRo+mlBEkMSeSZ38Nw==" }, + "unenv": { + "version": "2.0.0-rc.24", + "resolved": "https://registry.npmjs.org/unenv/-/unenv-2.0.0-rc.24.tgz", + "integrity": "sha512-i7qRCmY42zmCwnYlh9H2SvLEypEFGye5iRmEMKjcGi7zk9UquigRjFtTLz0TYqr0ZGLZhaMHl/foy1bZR+Cwlw==", + "dev": true, + "requires": { + "pathe": "^2.0.3" + } + }, "unhomoglyph": { "version": "1.0.6", "resolved": "https://registry.npmjs.org/unhomoglyph/-/unhomoglyph-1.0.6.tgz", @@ -25360,6 +26749,36 @@ "workbox-core": "7.4.0" } }, + "workerd": { + "version": "1.20260301.1", + "resolved": "https://registry.npmjs.org/workerd/-/workerd-1.20260301.1.tgz", + "integrity": "sha512-oterQ1IFd3h7PjCfT4znSFOkJCvNQ6YMOyZ40YsnO3nrSpgB4TbJVYWFOnyJAw71/RQuupfVqZZWKvsy8GO3fw==", + "dev": true, + "requires": { + "@cloudflare/workerd-darwin-64": "1.20260301.1", + "@cloudflare/workerd-darwin-arm64": "1.20260301.1", + "@cloudflare/workerd-linux-64": "1.20260301.1", + "@cloudflare/workerd-linux-arm64": "1.20260301.1", + "@cloudflare/workerd-windows-64": "1.20260301.1" + } + }, + "wrangler": { + "version": "4.70.0", + "resolved": "https://registry.npmjs.org/wrangler/-/wrangler-4.70.0.tgz", + "integrity": "sha512-PNDZ9o4e+B5x+1bUbz62Hmwz6G9lw+I9pnYe/AguLddJFjfIyt2cmFOUOb3eOZSoXsrhcEPUg2YidYIbVwUkfw==", + "dev": true, + "requires": { + "@cloudflare/kv-asset-handler": "0.4.2", + "@cloudflare/unenv-preset": "2.14.0", + "blake3-wasm": "2.1.5", + "esbuild": "0.27.3", + "fsevents": "~2.3.2", + "miniflare": "4.20260301.1", + "path-to-regexp": "6.3.0", + "unenv": "2.0.0-rc.24", + "workerd": "1.20260301.1" + } + }, "wrap-ansi": { "version": "7.0.0", "resolved": "https://registry.npmjs.org/wrap-ansi/-/wrap-ansi-7.0.0.tgz", @@ -25370,6 +26789,12 @@ "strip-ansi": "^6.0.0" } }, + "ws": { + "version": "8.18.0", + "resolved": "https://registry.npmjs.org/ws/-/ws-8.18.0.tgz", + "integrity": "sha512-8VbfWfHLbbwu3+N6OKsOMpBdT4kXPDDB9cJk2bJ6mh9ucxdlnNvH1e+roYkKmN9Nxw2yjz7VzeO9oOz2zJ04Pw==", + "dev": true + }, "y18n": { "version": "5.0.8", "resolved": "https://registry.npmjs.org/y18n/-/y18n-5.0.8.tgz", @@ -25409,6 +26834,29 @@ "resolved": "https://registry.npmjs.org/yocto-queue/-/yocto-queue-0.1.0.tgz", "integrity": "sha512-rVksvsnNCdJ/ohGc6xgPwyN8eheCxsiLM8mxuE/t/mOVqJewPuO1miLpTHQiRgTKCLexL4MeAFVagts7HmNZ2Q==" }, + "youch": { + "version": "4.1.0-beta.10", + "resolved": "https://registry.npmjs.org/youch/-/youch-4.1.0-beta.10.tgz", + "integrity": "sha512-rLfVLB4FgQneDr0dv1oddCVZmKjcJ6yX6mS4pU82Mq/Dt9a3cLZQ62pDBL4AUO+uVrCvtWz3ZFUL2HFAFJ/BXQ==", + "dev": true, + "requires": { + "@poppinss/colors": "^4.1.5", + "@poppinss/dumper": "^0.6.4", + "@speed-highlight/core": "^1.2.7", + "cookie": "^1.0.2", + "youch-core": "^0.3.3" + } + }, + "youch-core": { + "version": "0.3.3", + "resolved": "https://registry.npmjs.org/youch-core/-/youch-core-0.3.3.tgz", + "integrity": "sha512-ho7XuGjLaJ2hWHoK8yFnsUGy2Y5uDpqSTq1FkHLK4/oqKtyUU1AFbOOxY4IpC9f0fTLjwYbslUz0Po5BpD1wrA==", + "dev": true, + "requires": { + "@poppinss/exception": "^1.2.2", + "error-stack-parser-es": "^1.0.5" + } + }, "zod": { "version": "4.3.6", "resolved": "https://registry.npmjs.org/zod/-/zod-4.3.6.tgz", diff --git a/package.json b/package.json index 0cd4acde3..7be46b1a8 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "sable", - "version": "1.3.2", + "version": "1.3.3", "description": "Yet another matrix client fork", "type": "module", "packageManager": "npm@11.11.0", @@ -17,7 +17,10 @@ "fmt": "prettier --write .", "fmt:check": "prettier --check .", "typecheck": "tsc", - "knip": "knip" + "knip": "knip", + "knope": "knope", + "document-change": "knope document-change", + "postinstall": "node scripts/install-knope.js" }, "keywords": [], "author": "7w1", @@ -83,6 +86,7 @@ "ua-parser-js": "^1.0.41" }, "devDependencies": { + "@cloudflare/vite-plugin": "^1.26.0", "@element-hq/element-call-embedded": "0.16.3", "@esbuild-plugins/node-globals-polyfill": "^0.2.3", "@eslint/compat": "2.0.2", @@ -113,6 +117,7 @@ "vite-plugin-pwa": "^1.2.0", "vite-plugin-static-copy": "^3.2.0", "vite-plugin-svgr": "4.5.0", - "vite-plugin-top-level-await": "^1.6.0" + "vite-plugin-top-level-await": "^1.6.0", + "wrangler": "^4.70.0" } } diff --git a/scripts/install-knope.js b/scripts/install-knope.js new file mode 100644 index 000000000..5557c42c6 --- /dev/null +++ b/scripts/install-knope.js @@ -0,0 +1,191 @@ +#!/usr/bin/env node +import { spawnSync } from 'node:child_process'; +import process from 'node:process'; +import { chmodSync, existsSync, mkdirSync, realpathSync, writeFileSync } from 'node:fs'; +import { join, dirname, resolve, sep } from 'node:path'; +import { fileURLToPath } from 'node:url'; +import { Buffer } from 'node:buffer'; +import { gunzipSync } from 'node:zlib'; +import { PrefixedLogger, createTextHelpers } from './utils/console-style.js'; + +const __dirname = dirname(fileURLToPath(import.meta.url)); + +const VERSION = '0.22.3'; +const TARGETS = { + 'linux-x64': 'x86_64-unknown-linux-musl', + 'linux-arm64': 'aarch64-unknown-linux-musl', + 'darwin-x64': 'x86_64-apple-darwin', + 'darwin-arm64': 'aarch64-apple-darwin', + 'win32-x64': 'x86_64-pc-windows-msvc', +}; + +function parseKnopeVersion(output) { + const version = output?.trim().replace(/^knope\s+/, ''); + return version || null; +} + +function getKnopeVersion(command) { + const result = spawnSync(command, ['--version'], { encoding: 'utf8' }); + if (result.status !== 0) { + return null; + } + return parseKnopeVersion(result.stdout); +} + +function readNullTerminatedString(buffer) { + const nulIndex = buffer.indexOf(0); + const end = nulIndex === -1 ? buffer.length : nulIndex; + return buffer.toString('utf8', 0, end); +} + +function getTarBasename(entryName) { + const segments = entryName.split('/').filter(Boolean); + return segments.at(-1) ?? ''; +} + +function extractRegularFileFromTar(tarBuffer, expectedBasename) { + let offset = 0; + const regularEntries = []; + + while (offset + 512 <= tarBuffer.length) { + const header = tarBuffer.subarray(offset, offset + 512); + if (header.every((byte) => byte === 0)) { + break; + } + + const name = readNullTerminatedString(header.subarray(0, 100)); + const prefix = readNullTerminatedString(header.subarray(345, 500)); + const fullName = prefix ? `${prefix}/${name}` : name; + const sizeOctal = readNullTerminatedString(header.subarray(124, 136)).trim(); + const size = sizeOctal ? Number.parseInt(sizeOctal, 8) : 0; + const typeflag = header[156]; + const isRegular = typeflag === 0 || typeflag === 48; + + if (!Number.isFinite(size) || size < 0) { + throw new Error(`Invalid tar entry size for ${fullName || ''}`); + } + + const dataStart = offset + 512; + const dataEnd = dataStart + size; + if (dataEnd > tarBuffer.length) { + throw new Error('Corrupt tarball: entry exceeds archive size'); + } + + if (isRegular && fullName) { + regularEntries.push(fullName); + if (getTarBasename(fullName) === expectedBasename) { + return Buffer.from(tarBuffer.subarray(dataStart, dataEnd)); + } + } + + const alignedSize = Math.ceil(size / 512) * 512; + offset = dataStart + alignedSize; + } + + throw new Error( + `Expected "${expectedBasename}" in tarball; found: ${regularEntries.join(', ') || 'none'}` + ); +} + +function getSystemKnopePath() { + const which = spawnSync(process.platform === 'win32' ? 'where' : 'which', ['knope'], { + encoding: 'utf8', + }); + if (which.status !== 0) { + return null; + } + return ( + which.stdout + .split(/\r?\n/) + .map((line) => line.trim()) + .find(Boolean) ?? null + ); +} + +function isPathWithin(candidatePath, rootPath) { + const toComparablePath = (value) => { + const resolved = resolve(value); + return process.platform === 'win32' ? resolved.toLowerCase() : resolved; + }; + const candidate = toComparablePath(candidatePath); + const root = toComparablePath(rootPath); + return candidate === root || candidate.startsWith(`${root}${sep}`); +} + +const logger = new PrefixedLogger('[postinstall:knope]'); +const { dim, red, green } = createTextHelpers({ useColor: logger.useColor }); + +const target = TARGETS[`${process.platform}-${process.arch}`]; +if (!target) { + const supported = Object.keys(TARGETS).join(', '); + logger.error( + `${dim('Unsupported platform: ')}${red(`${process.platform}-${process.arch}`)}${dim('. Supported targets: ')}${supported}` + ); + process.exit(1); +} + +const bin = join( + __dirname, + `../node_modules/.bin/knope${process.platform === 'win32' ? '.exe' : ''}` +); +const localBinDir = join(__dirname, '../node_modules/.bin'); +mkdirSync(dirname(bin), { recursive: true }); + +if (existsSync(bin)) { + const installed = getKnopeVersion(bin); + if (installed === VERSION) { + logger.info(`${dim('knope ')}${green(`v${VERSION}`)}${dim(' already installed')}`); + process.exit(0); + } + logger.info( + `${dim('Updating knope ')}${red(`v${installed ?? 'unknown'}`)}${dim(' -> ')}${green(`v${VERSION}`)}` + ); +} + +const systemKnopePath = getSystemKnopePath(); +if (systemKnopePath) { + const resolvedPath = (() => { + try { + return realpathSync(systemKnopePath); + } catch { + return systemKnopePath; + } + })(); + + if (!isPathWithin(resolvedPath, localBinDir)) { + const installed = getKnopeVersion(systemKnopePath); + if (installed === VERSION) { + logger.info( + `${dim('Using system knope ')}${green(`v${installed}`)}${dim(', skipping download')}` + ); + process.exit(0); + } + if (installed) { + logger.info( + `${dim('Found system knope ')}${red(`v${installed}`)}${dim('; installing pinned ')}${green(`v${VERSION}`)}${dim('. Consider updating your system knope.')}` + ); + } + } +} + +const url = `https://github.com/knope-dev/knope/releases/download/knope%2Fv${VERSION}/knope-${target}.tgz`; +logger.info( + `${dim('Downloading knope ')}${green(`v${VERSION}`)}${dim(' for ')}${target}${dim('...')}` +); +const response = await fetch(url); +if (!response.ok) { + throw new Error(`Failed to download knope: ${response.status} ${response.statusText}`); +} +const gzipBytes = Buffer.from(await response.arrayBuffer()); +const tarBytes = gunzipSync(gzipBytes); +const expectedBinaryName = process.platform === 'win32' ? 'knope.exe' : 'knope'; +const knopeBinary = extractRegularFileFromTar(tarBytes, expectedBinaryName); +writeFileSync(bin, knopeBinary); +chmodSync(bin, 0o755); +const installed = getKnopeVersion(bin); +if (installed !== VERSION) { + throw new Error( + `Installed knope version mismatch: expected ${VERSION}, got ${installed ?? 'unknown'}` + ); +} +logger.info(`${dim('Installed knope ')}${green(`v${installed}`)}`); diff --git a/scripts/normalize-imports.js b/scripts/normalize-imports.js index dd803af3c..74f9c4a91 100644 --- a/scripts/normalize-imports.js +++ b/scripts/normalize-imports.js @@ -5,6 +5,7 @@ import fs from 'node:fs/promises'; import path from 'node:path'; import process from 'node:process'; import ts from 'typescript'; +import { createTextHelpers } from './utils/console-style.js'; const DEFAULT_ROOTS = ['src']; const SKIP_DIRS = new Set(['.git', '.hg', '.svn', 'node_modules', 'dist', 'coverage']); @@ -13,23 +14,6 @@ const MATRIX_IMPORT_BOUNDARY_FILES = new Set([ path.normalize('src/types/matrix-sdk.ts'), path.normalize('src/types/matrix-sdk-events.d.ts'), ]); -const ANSI = { - reset: '\x1b[0m', - red: '\x1b[31m', - green: '\x1b[32m', - dim: '\x1b[2m', -}; - -function shouldUseColor() { - if (process.env.NO_COLOR !== undefined) return false; - if (process.env.FORCE_COLOR && process.env.FORCE_COLOR !== '0') return true; - return Boolean(process.stdout.isTTY); -} - -function styleText(text, color, enabled) { - if (!enabled) return text; - return `${color}${text}${ANSI.reset}`; -} function toPosix(inputPath) { return inputPath.split(path.sep).join('/'); @@ -251,7 +235,7 @@ async function main() { const projectRoot = process.cwd(); const { write, roots } = parseArgs(process.argv.slice(2)); const aliases = await loadAliasMap(path.join(projectRoot, 'vite.config.ts'), projectRoot); - const useColor = shouldUseColor(); + const { dim, red, green } = createTextHelpers(); if (aliases.length === 0) { throw new Error('No aliases found in vite.config.ts'); @@ -311,10 +295,10 @@ async function main() { a.file === b.file ? a.from.localeCompare(b.from) : a.file.localeCompare(b.file) ); displayRows.forEach((row) => { - const fileLabel = styleText(row.file, ANSI.dim, useColor); - const fromLabel = styleText(`"${row.from}"`, ANSI.red, useColor); - const arrowLabel = styleText(' -> ', ANSI.dim, useColor); - const toLabel = styleText(`"${row.to}"`, ANSI.green, useColor); + const fileLabel = dim(row.file); + const fromLabel = red(`"${row.from}"`); + const arrowLabel = dim(' -> '); + const toLabel = green(`"${row.to}"`); console.log(`${fileLabel}: ${fromLabel}${arrowLabel}${toLabel}`); }); diff --git a/scripts/utils/console-style.js b/scripts/utils/console-style.js new file mode 100644 index 000000000..96ed5bf3e --- /dev/null +++ b/scripts/utils/console-style.js @@ -0,0 +1,55 @@ +/* eslint-disable no-console */ +import process from 'node:process'; + +export const ANSI = { + reset: '\x1b[0m', + red: '\x1b[31m', + green: '\x1b[32m', + dim: '\x1b[2m', +}; + +export function shouldUseColor() { + if (process.env.NO_COLOR !== undefined) return false; + if (process.env.FORCE_COLOR && process.env.FORCE_COLOR !== '0') return true; + return Boolean(process.stdout.isTTY); +} + +export function styleText(text, color, enabled) { + if (!enabled) return text; + return `${color}${text}${ANSI.reset}`; +} + +export function createTextHelpers(options = {}) { + const useColor = options.useColor ?? shouldUseColor(); + const style = (text, color) => styleText(text, color, useColor); + const dim = (text) => styleText(text, ANSI.dim, useColor); + const red = (text) => styleText(text, ANSI.red, useColor); + const green = (text) => styleText(text, ANSI.green, useColor); + return { + useColor, + style, + dim, + red, + green, + }; +} + +export class PrefixedLogger { + constructor(prefix, options = {}) { + this.prefix = prefix; + this.useColor = options.useColor ?? shouldUseColor(); + this.prefixColor = options.prefixColor ?? ANSI.dim; + } + + withPrefix(message) { + return `${styleText(this.prefix, this.prefixColor, this.useColor)} ${message}`; + } + + info(message) { + console.log(this.withPrefix(message)); + } + + error(message) { + console.error(this.withPrefix(message)); + } +} diff --git a/src/app/components/editor/autocomplete/EmoticonAutocomplete.tsx b/src/app/components/editor/autocomplete/EmoticonAutocomplete.tsx index a6c7b3b6b..169266454 100644 --- a/src/app/components/editor/autocomplete/EmoticonAutocomplete.tsx +++ b/src/app/components/editor/autocomplete/EmoticonAutocomplete.tsx @@ -23,10 +23,14 @@ type EmoticonCompleteHandler = (key: string, shortcode: string) => void; type EmoticonSearchItem = PackImageReader | IEmoji; type EmoticonAutocompleteProps = { + title?: string; imagePackRooms: Room[]; editor: Editor; query: AutocompleteQuery; requestClose: () => void; + // this allows you to override the default behaviour of inserting the selection + // used to implement the +: reaction shortcut + onEmoticonSelected?: EmoticonCompleteHandler; }; const SEARCH_OPTIONS: UseAsyncSearchOptions = { @@ -36,10 +40,12 @@ const SEARCH_OPTIONS: UseAsyncSearchOptions = { }; export function EmoticonAutocomplete({ + title, imagePackRooms, editor, query, requestClose, + onEmoticonSelected, }: EmoticonAutocompleteProps) { const mx = useMatrixClient(); const useAuthentication = useMediaAuthentication(); @@ -67,12 +73,14 @@ export function EmoticonAutocomplete({ else resetSearch(); }, [query.text, search, resetSearch]); - const handleAutocomplete: EmoticonCompleteHandler = (key, shortcode) => { - const emoticonEl = createEmoticonElement(key, shortcode); - replaceWithElement(editor, query.range, emoticonEl); - moveCursor(editor, true); - requestClose(); - }; + const handleAutocomplete: EmoticonCompleteHandler = + onEmoticonSelected ?? + ((key, shortcode) => { + const emoticonEl = createEmoticonElement(key, shortcode); + replaceWithElement(editor, query.range, emoticonEl); + moveCursor(editor, true); + requestClose(); + }); useKeyDown(window, (evt: KeyboardEvent) => { onTabPress(evt, () => { @@ -84,7 +92,10 @@ export function EmoticonAutocomplete({ }); return autoCompleteEmoticon.length === 0 ? null : ( - Emojis} requestClose={requestClose}> + {title ?? 'Emojis'}} + requestClose={requestClose} + > {autoCompleteEmoticon.map((emoticon) => { const isCustomEmoji = 'url' in emoticon; const key = isCustomEmoji ? emoticon.url : emoticon.unicode; diff --git a/src/app/components/editor/autocomplete/autocompleteQuery.ts b/src/app/components/editor/autocomplete/autocompleteQuery.ts index 1baa44a13..5b8294afb 100644 --- a/src/app/components/editor/autocomplete/autocompleteQuery.ts +++ b/src/app/components/editor/autocomplete/autocompleteQuery.ts @@ -5,12 +5,16 @@ export enum AutocompletePrefix { UserMention = '@', Emoticon = ':', Command = '/', + Reaction = '+:', } -export const AUTOCOMPLETE_PREFIXES: readonly AutocompletePrefix[] = [ +export const ANYWHERE_AUTOCOMPLETE_PREFIXES: readonly AutocompletePrefix[] = [ AutocompletePrefix.RoomMention, AutocompletePrefix.UserMention, AutocompletePrefix.Emoticon, +]; +export const BEGINNING_AUTOCOMPLETE_PREFIXES: readonly AutocompletePrefix[] = [ AutocompletePrefix.Command, + AutocompletePrefix.Reaction, ]; export type AutocompleteQuery = { @@ -34,7 +38,7 @@ export const getAutocompleteQueryText = ( prefix: string ): string => Editor.string(editor, queryRange).slice(prefix.length); -export const getAutocompleteQuery = ( +export const getAutocompleteQuery = ( editor: Editor, queryRange: BaseRange, validPrefixes: readonly TPrefix[] diff --git a/src/app/components/editor/utils.ts b/src/app/components/editor/utils.ts index 851bc30d3..85ff437a1 100644 --- a/src/app/components/editor/utils.ts +++ b/src/app/components/editor/utils.ts @@ -261,7 +261,8 @@ export const getPrevWorldRange = (editor: Editor): BaseRange | undefined => { const [cursorPoint] = Range.edges(selection); const worldStartPoint = getPointUntilChar(editor, cursorPoint, { reverse: true, - match: (char) => char === ' ', + // line breaks produce empty chars, not \n + match: (char) => /\s|^$/.test(char), }); return worldStartPoint && Editor.range(editor, worldStartPoint, cursorPoint); }; diff --git a/src/app/components/message/modals/MessageDelete.tsx b/src/app/components/message/modals/MessageDelete.tsx index b91bad7f8..6637c97b6 100644 --- a/src/app/components/message/modals/MessageDelete.tsx +++ b/src/app/components/message/modals/MessageDelete.tsx @@ -1,4 +1,4 @@ -import { FormEventHandler, MouseEvent, useCallback } from 'react'; +import { FormEventHandler, MouseEvent, useCallback, useEffect } from 'react'; import { Room, MatrixEvent } from '$types/matrix-sdk'; import { useSetAtom } from 'jotai'; import { @@ -65,6 +65,12 @@ export function MessageDeleteInternal({ room, mEvent, onClose }: MessageDeleteIn ) ); + useEffect(() => { + if (deleteState.status === AsyncStatus.Success) { + onClose(); + } + }, [deleteState.status, onClose]); + const handleSubmit: FormEventHandler = (evt) => { evt.preventDefault(); const eventId = mEvent.getId(); diff --git a/src/app/components/notification-banner/NotificationBanner.css.ts b/src/app/components/notification-banner/NotificationBanner.css.ts new file mode 100644 index 000000000..80c3617fa --- /dev/null +++ b/src/app/components/notification-banner/NotificationBanner.css.ts @@ -0,0 +1,154 @@ +import { keyframes, style } from '@vanilla-extract/css'; +import { color, config, toRem } from 'folds'; + +const slideIn = keyframes({ + from: { + opacity: 0, + transform: 'translateY(-100%)', + }, + to: { + opacity: 1, + transform: 'translateY(0)', + }, +}); + +const slideOut = keyframes({ + from: { + opacity: 1, + transform: 'translateY(0)', + }, + to: { + opacity: 0, + transform: 'translateY(-100%)', + }, +}); + +// Floats at the top of the chat area, starting after the icon sidebar. +export const BannerContainer = style({ + position: 'fixed', + top: 0, + // 66px = sidebar icon strip width — overridden to 0 on mobile below + left: toRem(66), + right: 0, + zIndex: 9999, + display: 'flex', + flexDirection: 'column', + gap: config.space.S200, + padding: config.space.S400, + pointerEvents: 'none', + alignItems: 'stretch', + + '@media': { + // On narrow screens the sidebar collapses, so span the full width. + '(max-width: 768px)': { + left: 0, + }, + }, +}); + +export const Banner = style({ + position: 'relative', + overflow: 'hidden', + pointerEvents: 'all', + display: 'flex', + alignItems: 'center', + gap: config.space.S300, + backgroundColor: color.Surface.Container, + color: color.Surface.OnContainer, + border: `${config.borderWidth.B300} solid ${color.Surface.ContainerLine}`, + borderRadius: toRem(16), + padding: `${config.space.S300} ${config.space.S400}`, + boxShadow: `0 ${toRem(8)} ${toRem(32)} rgba(0, 0, 0, 0.45), 0 ${toRem(2)} ${toRem(8)} rgba(0, 0, 0, 0.3)`, + cursor: 'pointer', + width: '100%', + animationName: slideIn, + animationDuration: '260ms', + animationTimingFunction: 'cubic-bezier(0.22, 0.8, 0.6, 1)', + animationFillMode: 'both', + + selectors: { + '&:hover': { + backgroundColor: color.Surface.ContainerHover, + }, + '&[data-dismissing=true]': { + animationName: slideOut, + animationDuration: '200ms', + animationTimingFunction: 'cubic-bezier(0.4, 0, 1, 1)', + animationFillMode: 'both', + }, + }, +}); + +export const BannerIcon = style({ + width: toRem(44), + height: toRem(44), + objectFit: 'cover', + borderRadius: config.radii.R300, + flexShrink: 0, +}); + +export const BannerContent = style({ + flex: 1, + minWidth: 0, + display: 'flex', + flexDirection: 'column', + gap: toRem(2), +}); + +export const BannerTitle = style({ + fontWeight: 700, +}); + +export const BannerSubtitle = style({ + fontWeight: 400, + opacity: 0.7, +}); + +export const BannerRoomName = style({ + color: color.Primary.Main, + fontWeight: 600, +}); + +// Caps tall previews and fades the bottom edge when content overflows. +export const BannerBody = style({ + position: 'relative', + maxHeight: toRem(56), + overflow: 'hidden', + + selectors: { + '&[data-overflow=true]::after': { + content: '""', + position: 'absolute', + bottom: 0, + left: 0, + right: 0, + height: toRem(28), + background: `linear-gradient(to bottom, transparent, ${color.Surface.Container})`, + pointerEvents: 'none', + }, + '&[data-overflow=true][data-hovered=true]::after': { + background: `linear-gradient(to bottom, transparent, ${color.Surface.ContainerHover})`, + }, + }, +}); + +export const ProgressBar = style({ + position: 'absolute', + bottom: 0, + left: 0, + height: toRem(3), + borderBottomLeftRadius: toRem(16), + backgroundColor: color.Primary.Main, + animationName: keyframes({ + from: { width: '100%' }, + to: { width: '0%' }, + }), + animationTimingFunction: 'linear', + animationFillMode: 'both', + + selectors: { + '&[data-paused=true]': { + animationPlayState: 'paused', + }, + }, +}); diff --git a/src/app/components/notification-banner/NotificationBanner.tsx b/src/app/components/notification-banner/NotificationBanner.tsx new file mode 100644 index 000000000..ad0ba026d --- /dev/null +++ b/src/app/components/notification-banner/NotificationBanner.tsx @@ -0,0 +1,180 @@ +import { useAtom } from 'jotai'; +import { useCallback, useEffect, useRef, useState } from 'react'; +import { Box, Icon, IconButton, Icons, Text } from 'folds'; +import { inAppBannerAtom, InAppBannerNotification } from '$state/sessions'; +import * as css from './NotificationBanner.css'; + +const BANNER_DURATION_MS = 5000; + +// Renders body text capped at a max height with a gradient fade when it overflows. +function BodyText({ text, hovered }: { text: string; hovered: boolean }) { + const ref = useRef(null); + const [overflow, setOverflow] = useState(false); + + useEffect(() => { + const el = ref.current; + if (!el) return; + setOverflow(el.scrollHeight > el.clientHeight); + }, [text]); + + return ( +
+ + {text} + +
+ ); +} + +type BannerItemProps = { + notification: InAppBannerNotification; + onDismiss: (id: string) => void; +}; + +function BannerItem({ notification, onDismiss }: BannerItemProps) { + const [dismissing, setDismissing] = useState(false); + const [paused, setPaused] = useState(false); + const dismissedRef = useRef(false); + const dismissAnimTimerRef = useRef | null>(null); + const elapsedRef = useRef(0); + + // Use a ref to guard against double-dismiss without creating a new callback identity. + const dismiss = useCallback(() => { + if (dismissedRef.current) return; + dismissedRef.current = true; + setDismissing(true); + dismissAnimTimerRef.current = setTimeout(() => onDismiss(notification.id), 200); + }, [notification.id, onDismiss]); + + // Auto-dismiss timer — only runs when not paused. + useEffect(() => { + if (paused) return undefined; + const remaining = BANNER_DURATION_MS - elapsedRef.current; + if (remaining <= 0) { + dismiss(); + return undefined; + } + const startedAt = Date.now(); + const t = setTimeout(dismiss, remaining); + return () => { + clearTimeout(t); + // Accumulate time spent un-paused so we can resume from the right point. + elapsedRef.current += Date.now() - startedAt; + }; + }, [paused, dismiss]); + + useEffect( + () => () => { + if (dismissAnimTimerRef.current) clearTimeout(dismissAnimTimerRef.current); + }, + [] + ); + + const handleClick = () => { + notification.onClick(); + dismiss(); + }; + + // When hovering, pause the auto-dismiss timer. + const handleMouseEnter = () => setPaused(true); + const handleMouseLeave = () => setPaused(false); + + return ( +
{ + if (e.key === 'Enter' || e.key === ' ') handleClick(); + if (e.key === 'Escape') dismiss(); + }} + onMouseEnter={handleMouseEnter} + onMouseLeave={handleMouseLeave} + > + {notification.icon && ( + { + (e.currentTarget as HTMLImageElement).style.display = 'none'; + }} + /> + )} +
+ + {notification.senderName ?? notification.title} + {(notification.roomName || notification.serverName) && ( + + {' (​'} + {notification.roomName && `#${notification.roomName}`} + {notification.roomName && notification.serverName && ', '} + {notification.serverName}) + + )} + + {notification.body && } +
+ + { + e.stopPropagation(); + dismiss(); + }} + aria-label="Dismiss notification" + > + + + +
+
+ ); +} + +/** + * Renders the in-app notification banner stack. + * Mount this once near the root of the client layout. + */ +export function NotificationBanner() { + // We store an array locally so multiple rapid notifications stack briefly. + const [banner, setBanner] = useAtom(inAppBannerAtom); + const [queue, setQueue] = useState([]); + + // Push new notifications into the local queue. + useEffect(() => { + if (!banner) return; + setQueue((prev) => { + // De-duplicate by id + if (prev.some((n) => n.id === banner.id)) return prev; + // Keep at most 3 visible at once — drop the oldest if over limit. + const next = [...prev, banner]; + return next.length > 3 ? next.slice(next.length - 3) : next; + }); + // Clear the atom so the same notification doesn't re-enqueue on re-render. + setBanner(null); + }, [banner, setBanner]); + + const handleDismiss = (id: string) => { + setQueue((prev) => prev.filter((n) => n.id !== id)); + }; + + if (queue.length === 0) return null; + + return ( +
+ {queue.map((n) => ( + + ))} +
+ ); +} diff --git a/src/app/components/notification-banner/index.ts b/src/app/components/notification-banner/index.ts new file mode 100644 index 000000000..75a031d63 --- /dev/null +++ b/src/app/components/notification-banner/index.ts @@ -0,0 +1 @@ +export { NotificationBanner } from './NotificationBanner'; diff --git a/src/app/components/unread-badge/UnreadBadge.tsx b/src/app/components/unread-badge/UnreadBadge.tsx index 6a62642a3..9029cc9b7 100644 --- a/src/app/components/unread-badge/UnreadBadge.tsx +++ b/src/app/components/unread-badge/UnreadBadge.tsx @@ -1,6 +1,8 @@ import { CSSProperties, ReactNode } from 'react'; import { Box, Badge, toRem, Text } from 'folds'; import { millify } from '$plugins/millify'; +import { useSetting } from '$state/hooks/settings'; +import { settingsAtom } from '$state/settings'; type UnreadBadgeProps = { highlight?: boolean; @@ -18,15 +20,17 @@ export function UnreadBadgeCenter({ children }: { children: ReactNode }) { } export function UnreadBadge({ highlight, count }: UnreadBadgeProps) { + const [showCounts] = useSetting(settingsAtom, 'showUnreadCounts'); + const showNumber = showCounts && count > 0; return ( 0 ? '400' : '200'} + size={showNumber ? '400' : '200'} fill="Solid" radii="Pill" outlined={false} > - {count > 0 && ( + {showNumber && ( {millify(count)} diff --git a/src/app/components/user-profile/UserRoomProfile.tsx b/src/app/components/user-profile/UserRoomProfile.tsx index 688126986..0031943dc 100644 --- a/src/app/components/user-profile/UserRoomProfile.tsx +++ b/src/app/components/user-profile/UserRoomProfile.tsx @@ -31,6 +31,8 @@ import { } from '$plugins/react-custom-html-parser'; import { useSpoilerClickHandler } from '$hooks/useSpoilerClickHandler'; import { RenderBody } from '$components/message'; +import { getSettings } from '$state/settings'; +import { filterPronounsByLanguage } from '$utils/pronouns'; import { CreatorChip } from './CreatorChip'; import { UserInviteAlert, UserBanAlert, UserModeration, UserKickAlert } from './UserModeration'; import { PowerChip } from './PowerChip'; @@ -74,7 +76,16 @@ function UserExtendedSection({ return String(val); }; - const pronouns = profile.pronouns?.map((p: any) => clamp(p.summary, 16)).join(', '); + const languageFilterEnabled = getSettings().filterPronounsBasedOnLanguage ?? false; + const languagesToFilterFor = getSettings().filterPronounsLanguages ?? ['en']; + + const pronouns = filterPronounsByLanguage( + profile.pronouns!, + languageFilterEnabled, + languagesToFilterFor + ) + .map((p) => p.summary) + .join(', '); const localTime = useMemo(() => { if (!profile.timezone) return null; diff --git a/src/app/features/room/RoomInput.tsx b/src/app/features/room/RoomInput.tsx index 3c2ca1813..e8e71606d 100644 --- a/src/app/features/room/RoomInput.tsx +++ b/src/app/features/room/RoomInput.tsx @@ -21,7 +21,7 @@ import { StickerEventContent, } from '$types/matrix-sdk'; import { ReactEditor } from 'slate-react'; -import { Editor, Transforms } from 'slate'; +import { Editor, Point, Range, Transforms } from 'slate'; import { Box, config, @@ -51,7 +51,6 @@ import { import { useMatrixClient } from '$hooks/useMatrixClient'; import { - AUTOCOMPLETE_PREFIXES, AutocompletePrefix, AutocompleteQuery, createEmoticonElement, @@ -73,6 +72,8 @@ import { getBeginCommand, trimCommand, getMentions, + ANYWHERE_AUTOCOMPLETE_PREFIXES, + BEGINNING_AUTOCOMPLETE_PREFIXES, } from '$components/editor'; import { EmojiBoard, EmojiBoardTab } from '$components/emoji-board'; import { UseStateProvider } from '$components/UseStateProvider'; @@ -82,6 +83,7 @@ import { getImageInfo, getMxIdLocalPart, mxcUrlToHttp, + toggleReaction, } from '$utils/matrix'; import { useTypingStatusUpdater } from '$hooks/useTypingStatusUpdater'; import { useFilePicker } from '$hooks/useFilePicker'; @@ -141,6 +143,7 @@ import { } from '$utils/delayedEvents'; import { timeHourMinute, timeDayMonthYear } from '$utils/time'; import { stopPropagation } from '$utils/keyboard'; +import { MessageEvent } from '$types/matrix/room'; import { SchedulePickerDialog } from './schedule-send'; import * as css from './schedule-send/SchedulePickerDialog.css'; import { @@ -499,12 +502,10 @@ export const RoomInput = forwardRef( // Cancel failed — leave state intact for retry } } else { - try { - await mx.sendMessage(roomId, content as any); - } catch (error) { - log.error('failed to send message', { roomId }, error); - } resetInput(); + mx.sendMessage(roomId, content as any).catch((error: unknown) => { + log.error('failed to send message', { roomId }, error); + }); } }, [ mx, @@ -559,9 +560,19 @@ export const RoomInput = forwardRef( } const prevWordRange = getPrevWorldRange(editor); - const query = prevWordRange - ? getAutocompleteQuery(editor, prevWordRange, AUTOCOMPLETE_PREFIXES) - : undefined; + if (!prevWordRange) { + setAutocompleteQuery(undefined); + return; + } + + const firstPosition = Editor.start(editor, []); + const isRangeAtBeginning = !Point.isAfter(Range.start(prevWordRange), firstPosition); + const query = + (isRangeAtBeginning + ? getAutocompleteQuery(editor, prevWordRange, BEGINNING_AUTOCOMPLETE_PREFIXES) + : undefined) ?? + getAutocompleteQuery(editor, prevWordRange, ANYWHERE_AUTOCOMPLETE_PREFIXES); + setAutocompleteQuery(query); }, [editor, sendTypingStatus, hideActivity] @@ -572,6 +583,31 @@ export const RoomInput = forwardRef( ReactEditor.focus(editor); }, [editor]); + const handleReactionAutocomplete = (key: string, shortcode: string) => { + const lastMessage = room + .getLiveTimeline() + .getEvents() + .findLast((event) => + ( + [ + MessageEvent.RoomMessage, + MessageEvent.RoomMessageEncrypted, + MessageEvent.Sticker, + ] as string[] + ).includes(event.getType()) + ); + const lastMessageId = lastMessage?.getId(); + + if (lastMessageId) { + toggleReaction(mx, room, lastMessageId, key, shortcode); + } + + resetEditor(editor); + resetEditorHistory(editor); + sendTypingStatus(false); + handleCloseAutocomplete(); + }; + const handleEmoticonSelect = (key: string, shortcode: string) => { editor.insertNode(createEmoticonElement(key, shortcode)); moveCursor(editor); @@ -680,6 +716,16 @@ export const RoomInput = forwardRef( requestClose={handleCloseAutocomplete} /> )} + {autocompleteQuery?.prefix === AutocompletePrefix.Reaction && ( + + )} {autocompleteQuery?.prefix === AutocompletePrefix.Command && ( void) }, [room, onArrive]); }; +const useRelationUpdate = (room: Room, onRelation: () => void) => { + useEffect(() => { + const handleTimelineEvent: EventTimelineSetHandlerMap[RoomEvent.Timeline] = ( + mEvent: MatrixEvent, + eventRoom: Room | undefined, + _toStartOfTimeline: boolean | undefined, + _removed: boolean, + data: IRoomTimelineData + ) => { + // Live Replace events are handled by useLiveEventArrive re-render. + // Non-live Replace events (bundled/historical edits from sliding sync) + // also need to trigger a re-render so makeReplaced state is reflected. + if (eventRoom?.roomId !== room.roomId || data.liveEvent) return; + if (mEvent.getRelation()?.rel_type === RelationType.Replace) { + onRelation(); + } + }; + room.on(RoomEvent.Timeline, handleTimelineEvent); + return () => { + room.removeListener(RoomEvent.Timeline, handleTimelineEvent); + }; + }, [room, onRelation]); +}; + const useLiveTimelineRefresh = (room: Room, onRefresh: () => void) => { useEffect(() => { const handleTimelineRefresh: RoomEventHandlerMap[RoomEvent.TimelineRefresh] = (r: Room) => { @@ -787,6 +811,15 @@ export function RoomTimeline({ }, [room, liveTimelineLinked, timeline.linkedTimelines.length]) ); + // Re-render when non-live Replace relations arrive (bundled/historical edits + // from sliding sync that wouldn't otherwise trigger a timeline update). + useRelationUpdate( + room, + useCallback(() => { + setTimeline((ct) => ({ ...ct })); + }, []) + ); + // Recover from transient empty timeline state when the live timeline // already has events (can happen when opening by event id, then fallbacking). useEffect(() => { @@ -899,11 +932,18 @@ export function RoomTimeline({ ) ); + // Keep a stable ref so timeline state updates (new messages arriving) don't + // cause handleOpenEvent to rebuild and re-trigger this effect, yanking the + // user back to the notification event on every incoming message. + // We only want to scroll once per unique eventId value. + const handleOpenEventRef = useRef(handleOpenEvent); + handleOpenEventRef.current = handleOpenEvent; + useEffect(() => { if (eventId) { - handleOpenEvent(eventId); + handleOpenEventRef.current(eventId); } - }, [eventId, handleOpenEvent]); + }, [eventId]); // handleOpenEvent intentionally omitted — use ref above // Scroll to bottom on initial timeline load useLayoutEffect(() => { @@ -1166,26 +1206,8 @@ export function RoomTimeline({ ); const handleReactionToggle = useCallback( - (targetEventId: string, key: string, shortcode?: string) => { - const relations = getEventReactions(room.getUnfilteredTimelineSet(), targetEventId); - const allReactions = relations?.getSortedAnnotationsByKey() ?? []; - const [, reactionsSet] = allReactions.find(([k]: [string, any]) => k === key) ?? []; - const reactions: MatrixEvent[] = reactionsSet ? Array.from(reactionsSet) : []; - const myReaction = reactions.find(factoryEventSentBy(mx.getUserId()!)); - - if (myReaction && !!(myReaction as any)?.isRelation()) { - mx.redactEvent(room.roomId, (myReaction as any).getId()); - return; - } - const rShortcode = - shortcode || - ((reactions.find(eventWithShortcode) as any)?.getContent().shortcode as string | undefined); - mx.sendEvent( - room.roomId, - MessageEvent.Reaction as any, - getReactionContent(targetEventId, key, rShortcode) - ); - }, + (targetEventId: string, key: string, shortcode?: string) => + toggleReaction(mx, room, targetEventId, key, shortcode), [mx, room] ); @@ -1197,6 +1219,14 @@ export function RoomTimeline({ [mx, room] ); + const handleDeleteFailedSend = useCallback( + (mEvent: MatrixEvent) => { + if (mEvent.getAssociatedStatus() !== EventStatus.NOT_SENT) return; + mx.cancelPendingEvent(mEvent); + }, + [mx] + ); + const handleEdit = useCallback( (editEvtId?: string) => { if (editEvtId) { @@ -1237,8 +1267,14 @@ export function RoomTimeline({ const highlighted = focusItem?.index === item && focusItem.highlight; const editedEvent = getEditedEvent(mEventId, mEvent, timelineSet); - const getContent = (() => - editedEvent?.getContent()['m.new_content'] ?? mEvent.getContent()) as GetContentCallback; + const editedNewContent = editedEvent?.getContent()['m.new_content']; + // If makeReplaced was called with a stripped edit (no m.new_content), + // mEvent.getContent() returns {}. Fall back to getOriginalContent() so + // the message renders with its original content instead of breaking. + const baseContent = mEvent.getContent(); + const safeContent = + Object.keys(baseContent).length > 0 ? baseContent : mEvent.getOriginalContent(); + const getContent = (() => editedNewContent ?? safeContent) as GetContentCallback; const senderId = mEvent.getSender() ?? ''; const senderDisplayName = @@ -1269,6 +1305,7 @@ export function RoomTimeline({ senderDisplayName={senderDisplayName} sendStatus={mEvent.getAssociatedStatus()} onResend={handleResend} + onDeleteFailedSend={handleDeleteFailedSend} onEditId={handleEdit} activeReplyId={activeReplyId} reply={ @@ -1305,7 +1342,7 @@ export function RoomTimeline({ ) : ( - editedEvent?.getContent()['m.new_content'] ?? - mEvent.getContent()) as GetContentCallback; + const editedNewContent = editedEvent?.getContent()['m.new_content']; + const baseContent = mEvent.getContent(); + const safeContent = + Object.keys(baseContent).length > 0 ? baseContent : mEvent.getOriginalContent(); + const getContent = (() => editedNewContent ?? safeContent) as GetContentCallback; return ( void; + onDeleteFailedSend?: (event: MatrixEvent) => void; }; function useMobileDoubleTap(callback: () => void, delay = 300) { @@ -260,17 +262,34 @@ const Pronouns = as< >(({ as: AsPronouns = 'span', pronouns, tagColor, ...props }, ref) => { if (!pronouns || pronouns.length === 0) return null; + const languageFilterEnabled = Boolean(getSettings().filterPronounsBasedOnLanguage ?? false); + // if no language is given use english + const selectedLanguages = (getSettings().filterPronounsLanguages ?? ['en']) + .map((lang) => lang.trim().toLowerCase()) + .filter(Boolean); + + const visiblePronouns = filterPronounsByLanguage( + pronouns, + languageFilterEnabled, + selectedLanguages + ); + const clamp = (str: string, len: number) => (str.length > len ? `${str.slice(0, len)}...` : str); const limit = mobileOrTablet() ? 1 : 3; + // if language specific pronouns can't be found matching the filter return unfiltered + if (visiblePronouns.length === 0) { + visiblePronouns.push(...pronouns); + } + return ( - {pronouns.slice(0, limit).map((p) => ( + {visiblePronouns.slice(0, limit).map((p) => ( {clamp(p.summary, 16)} ))} - {pronouns.length > limit && ...} + {visiblePronouns.length > limit && ...} ); }); @@ -308,6 +327,7 @@ function MessageInternal( activeReplyId, sendStatus, onResend, + onDeleteFailedSend, ...props }: MessageProps & { className?: string; children?: ReactNode }, ref: any @@ -445,6 +465,7 @@ function MessageInternal( sendStatus === EventStatus.SENDING; const isFailedSend = sendStatus === EventStatus.NOT_SENT; const canResend = isFailedSend && senderId === mx.getUserId() && !!onResend; + const canDeleteFailedSend = isFailedSend && senderId === mx.getUserId() && !!onDeleteFailedSend; const handleResendClick: MouseEventHandler = useCallback( (evt) => { @@ -455,6 +476,15 @@ function MessageInternal( [mEvent, onResend] ); + const handleDeleteFailedSendClick: MouseEventHandler = useCallback( + (evt) => { + evt.preventDefault(); + evt.stopPropagation(); + onDeleteFailedSend?.(mEvent); + }, + [mEvent, onDeleteFailedSend] + ); + const MSG_CONTENT_STYLE = { maxWidth: '100%' }; const msgContentJSX = ( @@ -484,13 +514,6 @@ function MessageInternal( {children} )} {reactions} - {isPendingSend && ( - - - Sending... - - - )} {isFailedSend && ( @@ -501,6 +524,15 @@ function MessageInternal( Retry )} + {canDeleteFailedSend && ( + + )} )} diff --git a/src/app/features/room/message/MessageEditor.tsx b/src/app/features/room/message/MessageEditor.tsx index 476bf0cab..e00392dcb 100644 --- a/src/app/features/room/message/MessageEditor.tsx +++ b/src/app/features/room/message/MessageEditor.tsx @@ -27,7 +27,6 @@ import { } from '$types/matrix-sdk'; import { isKeyHotkey } from 'is-hotkey'; import { - AUTOCOMPLETE_PREFIXES, AutocompletePrefix, AutocompleteQuery, CustomEditor, @@ -47,6 +46,7 @@ import { trimCustomHtml, useEditor, getMentions, + ANYWHERE_AUTOCOMPLETE_PREFIXES, } from '$components/editor'; import { useSetting } from '$state/hooks/settings'; import { settingsAtom } from '$state/settings'; @@ -207,7 +207,7 @@ export const MessageEditor = as<'div', MessageEditorProps>( const prevWordRange = getPrevWorldRange(editor); const query = prevWordRange - ? getAutocompleteQuery(editor, prevWordRange, AUTOCOMPLETE_PREFIXES) + ? getAutocompleteQuery(editor, prevWordRange, ANYWHERE_AUTOCOMPLETE_PREFIXES) : undefined; setAutocompleteQuery(query); }, diff --git a/src/app/features/room/message/styles.css.ts b/src/app/features/room/message/styles.css.ts index 8b52f526a..49ccfb928 100644 --- a/src/app/features/room/message/styles.css.ts +++ b/src/app/features/room/message/styles.css.ts @@ -57,11 +57,11 @@ export const ReactionsTooltipText = style({ }); export const MessagePending = style({ - opacity: config.opacity.P500, + opacity: config.opacity.Placeholder, }); export const MessageFailed = style({ - opacity: config.opacity.P400, + opacity: config.opacity.P300, }); export const SendStatusRow = style({ diff --git a/src/app/features/settings/account/BioEditor.tsx b/src/app/features/settings/account/BioEditor.tsx index 3bb33467c..49b47d7b9 100644 --- a/src/app/features/settings/account/BioEditor.tsx +++ b/src/app/features/settings/account/BioEditor.tsx @@ -16,7 +16,6 @@ import { Editor, Transforms } from 'slate'; import { ReactEditor } from 'slate-react'; import { isKeyHotkey } from 'is-hotkey'; import { - AUTOCOMPLETE_PREFIXES, AutocompletePrefix, AutocompleteQuery, CustomEditor, @@ -145,7 +144,7 @@ export function BioEditor({ value, isSaving, imagePackRooms, onSave }: BioEditor } const prevWordRange = getPrevWorldRange(editor); const query = prevWordRange - ? getAutocompleteQuery(editor, prevWordRange, AUTOCOMPLETE_PREFIXES) + ? getAutocompleteQuery(editor, prevWordRange, [AutocompletePrefix.Emoticon]) : undefined; setAutocompleteQuery(query); }, diff --git a/src/app/features/settings/account/PronounEditor.tsx b/src/app/features/settings/account/PronounEditor.tsx index 9edfd1c9b..29ee9467e 100644 --- a/src/app/features/settings/account/PronounEditor.tsx +++ b/src/app/features/settings/account/PronounEditor.tsx @@ -1,6 +1,7 @@ import { useState, useEffect, ChangeEvent } from 'react'; import { Input } from 'folds'; import { SettingTile } from '$components/setting-tile'; +import { parsePronounsInput } from '$utils/pronouns'; type PronounSet = { summary: string; @@ -14,7 +15,9 @@ type PronounEditorProps = { }; export function PronounEditor({ current, onSave }: PronounEditorProps) { - const initialString = current.map((p) => p.summary).join(', '); + const initialString = current + .map((p) => `${p.language ? `${p.language}:` : ''}${p.summary}`) + .join(', '); const [val, setVal] = useState(initialString); useEffect(() => setVal(initialString), [initialString]); @@ -22,11 +25,7 @@ export function PronounEditor({ current, onSave }: PronounEditorProps) { const handleSave = () => { if (val === initialString) return; const safeVal = val.slice(0, 128); - const next = safeVal - .split(',') - .map((s) => s.trim()) - .filter(Boolean) - .map((s) => ({ summary: s.slice(0, 16), language: 'en' })); + const next = parsePronounsInput(safeVal); onSave(next); }; @@ -37,7 +36,9 @@ export function PronounEditor({ current, onSave }: PronounEditorProps) { return ( @@ -204,6 +207,22 @@ function IdentityCosmetics() { } /> + + + } + /> + + + } + /> + } /> + + + } + /> + ); } diff --git a/src/app/features/settings/cosmetics/LanguageSpecificPronouns.tsx b/src/app/features/settings/cosmetics/LanguageSpecificPronouns.tsx new file mode 100644 index 000000000..32c57e59a --- /dev/null +++ b/src/app/features/settings/cosmetics/LanguageSpecificPronouns.tsx @@ -0,0 +1,112 @@ +import { Box, Input, Switch, Text } from 'folds'; +import { SettingTile } from '$components/setting-tile'; +import { SequenceCard } from '$components/sequence-card'; +import { useEffect, useState } from 'react'; +import { getSettings, setSettings } from '$state/settings'; +import { SequenceCardStyle } from '../styles.css'; + +export type LanguageSpecificPronounsConfig = { + enabled?: boolean | string; + languages?: string[]; +}; + +export const resolveLanguageSpecificPronounsEnabled = ( + enabled: LanguageSpecificPronounsConfig['enabled'] +): boolean => { + if (enabled === undefined) return false; + if (typeof enabled === 'boolean') return enabled; + const normalized = String(enabled).trim().toLowerCase(); + if (normalized === 'false' || normalized === '0' || normalized === 'off' || normalized === 'no') + return false; + if (normalized === 'true' || normalized === '1' || normalized === 'on' || normalized === 'yes') + return true; + return false; +}; + +// utility function to split a comma separated list of languages and trim whitespace +function splitAndTrimLanguages(languages: string): string[] { + return languages + .split(',') + .map((lang) => lang.trim()) + .filter((lang) => lang.length > 0); +} + +// MSC4247 allows users to set pronouns in different languages +export function LanguageSpecificPronouns() { + const [useLanguageSpecificPronouns, setEnabled] = useState(false); + const [languageList, setLanguageList] = useState(''); + + // common handler for saving changes to the language specific pronouns settings + const handleSave = (enabled: boolean, languages: string) => { + const currentSettings = getSettings(); + setSettings({ + ...currentSettings, + filterPronounsBasedOnLanguage: enabled, + filterPronounsLanguages: splitAndTrimLanguages(languages), + }); + }; + + // handler for when the language list input changes + const handleLanguageListChange = (e: React.ChangeEvent) => { + const val = e.target.value.trim(); + setLanguageList(val); + // save the new language list to the client config, keeping the enabled state unchanged + handleSave(getSettings().filterPronounsBasedOnLanguage ?? false, val); + }; + + useEffect(() => { + setEnabled( + resolveLanguageSpecificPronounsEnabled(getSettings().filterPronounsBasedOnLanguage ?? false) + ); + setLanguageList(getSettings().filterPronounsLanguages?.join(',') || ''); + }, []); + + // handler for toggling the enabled state of language specific pronouns + const handleSetEnabled = (enabled: boolean) => { + handleSave(enabled, getSettings().filterPronounsLanguages?.join(',') || ''); + setEnabled(enabled); + }; + + return ( + + Language Specific Pronouns + + + } + /> + {useLanguageSpecificPronouns && ( + + } + /> + )} + + + ); +} diff --git a/src/app/features/settings/cosmetics/Themes.tsx b/src/app/features/settings/cosmetics/Themes.tsx index ac666bdca..1440ae602 100644 --- a/src/app/features/settings/cosmetics/Themes.tsx +++ b/src/app/features/settings/cosmetics/Themes.tsx @@ -327,6 +327,7 @@ function PageZoomInput() { } export function Appearance() { const [twitterEmoji, setTwitterEmoji] = useSetting(settingsAtom, 'twitterEmoji'); + const [showUnreadCounts, setShowUnreadCounts] = useSetting(settingsAtom, 'showUnreadCounts'); return ( @@ -346,6 +347,15 @@ export function Appearance() { } /> + + + } + /> + ); diff --git a/src/app/features/settings/experimental/Experimental.tsx b/src/app/features/settings/experimental/Experimental.tsx index 8148c92ed..b97193577 100644 --- a/src/app/features/settings/experimental/Experimental.tsx +++ b/src/app/features/settings/experimental/Experimental.tsx @@ -1,6 +1,7 @@ import { Box, Text, IconButton, Icon, Icons, Scroll } from 'folds'; import { Page, PageContent, PageHeader } from '$components/page'; import { InfoCard } from '$components/info-card'; +import { LanguageSpecificPronouns } from '../cosmetics/LanguageSpecificPronouns'; import { Sync } from '../general'; type ExperimentalProps = { @@ -42,6 +43,9 @@ export function Experimental({ requestClose }: ExperimentalProps) { + + + diff --git a/src/app/hooks/useCommands.ts b/src/app/hooks/useCommands.ts index 7de36934f..dd803e7bf 100644 --- a/src/app/hooks/useCommands.ts +++ b/src/app/hooks/useCommands.ts @@ -30,6 +30,7 @@ import { splitWithSpace } from '$utils/common'; import { useSetting } from '$state/hooks/settings'; import { settingsAtom } from '$state/settings'; import { createRoomEncryptionState } from '$components/create-room'; +import { parsePronounsInput } from '$utils/pronouns'; import { useRoomNavigate } from './useRoomNavigate'; import { enrichWidgetUrl } from './useRoomWidgets'; @@ -887,7 +888,7 @@ export const useCommands = (mx: MatrixClient, room: Room): CommandRecord => { [Command.Pronoun]: { name: Command.Pronoun, description: - 'Set your pronouns for this room. Example: /pronoun "they/them, it/its" | /pronoun reset', + 'Set your pronouns for this room. Example: /pronoun "en:they/them, de:sie/ihr" | /pronoun reset', exe: async (payload) => { const match = payload.trim().match(/^"(.*)"$/); const rawInput = match ? match[1].trim() : payload.trim(); @@ -916,11 +917,7 @@ export const useCommands = (mx: MatrixClient, room: Room): CommandRecord => { return; } - const pronounsArray = rawInput - .split(',') - .map((p) => p.trim()) - .filter((p) => p.length > 0) - .map((p) => ({ summary: p })); + const pronounsArray = parsePronounsInput(rawInput); await mx.sendStateEvent( room.roomId, @@ -928,7 +925,12 @@ export const useCommands = (mx: MatrixClient, room: Room): CommandRecord => { { pronouns: pronounsArray }, userId ); - sendFeedback(`Room pronouns set: ${rawInput}`); + + const feedbackString = pronounsArray + .map((p) => (p.language ? `for ${p.language} "${p.summary}" was set` : p.summary)) + .join(', '); + + sendFeedback(`Room pronouns set: ${feedbackString}`); } catch (e: any) { if (e.errcode === 'M_FORBIDDEN') { sendFeedback('Permission Denied. Could not update room pronouns.'); @@ -939,7 +941,11 @@ export const useCommands = (mx: MatrixClient, room: Room): CommandRecord => { [Command.SPronoun]: { name: Command.SPronoun, description: +<<<<<<< fix-naming-space-commands 'Set your pronouns for this space. Example: /spronoun "they/them, it/its" | /spronoun reset', +======= + 'Set your global pronouns for this space. Example: /gpronoun "en:they/them, de:sie/ihr" | /gpronoun reset', +>>>>>>> dev exe: async (payload) => { const match = payload.trim().match(/^"(.*)"$/); const rawInput = match ? match[1].trim() : payload.trim(); @@ -976,11 +982,7 @@ export const useCommands = (mx: MatrixClient, room: Room): CommandRecord => { return; } - const pronounsArray = rawInput - .split(',') - .map((p) => p.trim()) - .filter((p) => p.length > 0) - .map((p) => ({ summary: p })); + const pronounsArray = parsePronounsInput(rawInput); await mx.sendStateEvent( targetSpaceId as any, @@ -988,7 +990,12 @@ export const useCommands = (mx: MatrixClient, room: Room): CommandRecord => { { pronouns: pronounsArray }, userId ); - sendFeedback(`Global space pronouns set: ${rawInput}`); + + const feedbackString = pronounsArray + .map((p) => (p.language ? `for ${p.language} "${p.summary}" was set` : p.summary)) + .join(', '); + + sendFeedback(`Global space pronouns set: ${feedbackString}`); } catch (e: any) { if (e.errcode === 'M_FORBIDDEN') { sendFeedback('Permission Denied. Could not update space pronouns.'); diff --git a/src/app/hooks/useImagePacks.ts b/src/app/hooks/useImagePacks.ts index 6f38e376a..391543284 100644 --- a/src/app/hooks/useImagePacks.ts +++ b/src/app/hooks/useImagePacks.ts @@ -1,5 +1,5 @@ import { Room } from '$types/matrix-sdk'; -import { useCallback, useMemo, useState } from 'react'; +import { useCallback, useEffect, useMemo, useState } from 'react'; import { AccountDataEvent } from '$types/matrix/accountData'; import { StateEvent } from '$types/matrix/room'; import { @@ -7,8 +7,15 @@ import { getRoomImagePack, getRoomImagePacks, getUserImagePack, + globalPacksScope, ImagePack, ImageUsage, + readCachedPack, + readCachedPacks, + roomPacksScope, + userPackScope, + writeCachedPack, + writeCachedPacks, } from '$plugins/custom-emoji'; import { useMatrixClient } from './useMatrixClient'; import { useAccountDataCallback } from './useAccountDataCallback'; @@ -48,7 +55,17 @@ const imagePackListEqual = (a: ImagePack[], b: ImagePack[]): boolean => { export const useUserImagePack = (): ImagePack | undefined => { const mx = useMatrixClient(); - const [userPack, setUserPack] = useState(() => getUserImagePack(mx)); + const [userPack, setUserPack] = useState(() => { + const live = getUserImagePack(mx); + if (live) return live; + const userId = mx.getUserId(); + return userId ? readCachedPack(userId, userPackScope()) : undefined; + }); + + useEffect(() => { + const userId = mx.getUserId(); + if (userId) writeCachedPack(userId, userPackScope(), userPack); + }, [mx, userPack]); useAccountDataCallback( mx, @@ -70,7 +87,17 @@ export const useUserImagePack = (): ImagePack | undefined => { export const useGlobalImagePacks = (): ImagePack[] => { const mx = useMatrixClient(); - const [globalPacks, setGlobalPacks] = useState(() => getGlobalImagePacks(mx)); + const [globalPacks, setGlobalPacks] = useState(() => { + const live = getGlobalImagePacks(mx); + if (live.length > 0) return live; + const userId = mx.getUserId(); + return userId ? readCachedPacks(userId, globalPacksScope()) : []; + }); + + useEffect(() => { + const userId = mx.getUserId(); + if (userId) writeCachedPacks(userId, globalPacksScope(), globalPacks); + }, [mx, globalPacks]); useAccountDataCallback( mx, @@ -115,7 +142,24 @@ export const useGlobalImagePacks = (): ImagePack[] => { export const useRoomImagePack = (room: Room, stateKey: string): ImagePack | undefined => { const mx = useMatrixClient(); - const [roomPack, setRoomPack] = useState(() => getRoomImagePack(room, stateKey)); + const [roomPack, setRoomPack] = useState(() => { + const live = getRoomImagePack(room, stateKey); + if (live) return live; + const userId = mx.getUserId(); + if (!userId) return undefined; + // Find a matching cached pack by roomId + stateKey + return readCachedPacks(userId, roomPacksScope(room.roomId)).find( + (p) => p.address?.stateKey === stateKey + ); + }); + + useEffect(() => { + const userId = mx.getUserId(); + if (!userId) return; + // Persist all packs for this room whenever this single-pack state changes + const scope = roomPacksScope(room.roomId); + writeCachedPack(userId, scope, roomPack); + }, [mx, room.roomId, roomPack]); useStateEventCallback( mx, @@ -141,7 +185,17 @@ export const useRoomImagePack = (room: Room, stateKey: string): ImagePack | unde export const useRoomImagePacks = (room: Room): ImagePack[] => { const mx = useMatrixClient(); - const [roomPacks, setRoomPacks] = useState(() => getRoomImagePacks(room)); + const [roomPacks, setRoomPacks] = useState(() => { + const live = getRoomImagePacks(room); + if (live.length > 0) return live; + const userId = mx.getUserId(); + return userId ? readCachedPacks(userId, roomPacksScope(room.roomId)) : []; + }); + + useEffect(() => { + const userId = mx.getUserId(); + if (userId) writeCachedPacks(userId, roomPacksScope(room.roomId), roomPacks); + }, [mx, room.roomId, roomPacks]); useStateEventCallback( mx, @@ -166,7 +220,34 @@ export const useRoomImagePacks = (room: Room): ImagePack[] => { export const useRoomsImagePacks = (rooms: Room[]) => { const mx = useMatrixClient(); - const [roomPacks, setRoomPacks] = useState(() => rooms.flatMap(getRoomImagePacks)); + const [roomPacks, setRoomPacks] = useState(() => { + const live = rooms.flatMap(getRoomImagePacks); + if (live.length > 0) return live; + const userId = mx.getUserId(); + if (!userId) return []; + // Seed from cache for each room that has no live packs + return rooms.flatMap((room) => { + const livePacks = getRoomImagePacks(room); + if (livePacks.length > 0) return livePacks; + return readCachedPacks(userId, roomPacksScope(room.roomId)); + }); + }); + + useEffect(() => { + const userId = mx.getUserId(); + if (!userId) return; + // Persist per-room — group packs by roomId and write each bucket + const byRoom = new Map(); + roomPacks.forEach((pack) => { + if (!pack.address) return; + const bucket = byRoom.get(pack.address.roomId) ?? []; + bucket.push(pack); + byRoom.set(pack.address.roomId, bucket); + }); + byRoom.forEach((packs, roomId) => { + writeCachedPacks(userId, roomPacksScope(roomId), packs); + }); + }, [mx, roomPacks]); useStateEventCallback( mx, diff --git a/src/app/hooks/useNotificationJumper.ts b/src/app/hooks/useNotificationJumper.ts index 011549023..1d4f63eaa 100644 --- a/src/app/hooks/useNotificationJumper.ts +++ b/src/app/hooks/useNotificationJumper.ts @@ -1,4 +1,4 @@ -import { useCallback, useEffect } from 'react'; +import { useCallback, useEffect, useRef } from 'react'; import { useAtom, useAtomValue } from 'jotai'; import { SyncState, ClientEvent } from '$types/matrix-sdk'; import { activeSessionIdAtom, pendingNotificationAtom } from '../state/sessions'; @@ -14,30 +14,42 @@ export function NotificationJumper() { const { navigateRoom } = useRoomNavigate(); const log = createLogger('NotificationJumper'); + // Set true the moment we fire navigateRoom. Only reset when `pending` changes + // to a new value (via the effect below). Do NOT reset inside performJump itself: + // setPending(null) is async — resetting here creates a window where atom/render + // churn re-calls performJump (from the ClientEvent.Room listener or effect + // re-runs) before React has committed the null, causing repeated navigation. + const jumpingRef = useRef(false); + const performJump = useCallback(() => { - if (!pending) return; + if (!pending || jumpingRef.current) return; if (pending.targetSessionId && pending.targetSessionId !== activeSessionId) { - log.log('waiting for target session...', { + log.log('waiting for target session atom...', { targetSessionId: pending.targetSessionId, activeSessionId, }); return; } - const isSyncing = mx.getSyncState() === SyncState.Syncing; + // The mx client context may lag one render behind the atom — wait until it catches up. + if (pending.targetSessionId && mx.getUserId() !== pending.targetSessionId) { + log.log('waiting for mx client to switch to target session...', { + targetSessionId: pending.targetSessionId, + currentUserId: mx.getUserId(), + }); + return; + } + const isSyncing = mx.getSyncState() === SyncState.Syncing; const room = mx.getRoom(pending.roomId); const isJoined = room?.getMyMembership() === 'join'; if (isSyncing && isJoined) { log.log('jumping to:', pending.roomId); - - requestAnimationFrame(() => { - requestAnimationFrame(() => { - navigateRoom(pending.roomId, pending.eventId); - setPending(null); - }); - }); + jumpingRef.current = true; + navigateRoom(pending.roomId, pending.eventId); + setPending(null); + // jumpingRef stays true until pending changes — see effect below. } else { log.log('still waiting for room data...', { isSyncing, @@ -47,27 +59,38 @@ export function NotificationJumper() { } }, [pending, activeSessionId, mx, navigateRoom, setPending, log]); + // Reset the guard only when pending is replaced (new notification or cleared). + useEffect(() => { + jumpingRef.current = false; + }, [pending]); + + // Keep a stable ref to the latest performJump so that the listeners below + // always invoke the current version without adding performJump to their dep + // arrays. Adding performJump as a dep causes the effect to re-run (and call + // performJump again) on every atom change during an account switch — that is + // the second source of repeated navigation. + const performJumpRef = useRef(performJump); + performJumpRef.current = performJump; + useSyncState( mx, - useCallback( - (current) => { - if (current === SyncState.Syncing) performJump(); - }, - [performJump] - ) + // Stable callback — reads from ref, so useSyncState never re-registers. + useCallback((current) => { + if (current === SyncState.Syncing) performJumpRef.current(); + }, []) ); useEffect(() => { if (!pending) return undefined; - const onRoom = () => performJump(); + const onRoom = () => performJumpRef.current(); mx.on(ClientEvent.Room, onRoom); - performJump(); + performJumpRef.current(); return () => { mx.removeListener(ClientEvent.Room, onRoom); }; - }, [pending, mx, performJump]); + }, [pending, mx]); // performJump intentionally omitted — use ref above return null; } diff --git a/src/app/hooks/useUserProfile.ts b/src/app/hooks/useUserProfile.ts index 53dccdd4c..f5af57c63 100644 --- a/src/app/hooks/useUserProfile.ts +++ b/src/app/hooks/useUserProfile.ts @@ -79,6 +79,8 @@ export const useUserProfile = ( const mx = useMatrixClient(); const [legacyUsernameColor] = useSetting(settingsAtom, 'legacyUsernameColor'); const [renderGlobalColors] = useSetting(settingsAtom, 'renderGlobalNameColors'); + const [renderRoomColors] = useSetting(settingsAtom, 'renderRoomColors'); + const [renderRoomFonts] = useSetting(settingsAtom, 'renderRoomFonts'); const userSelector = useMemo(() => selectAtom(profilesCacheAtom, (db) => db[userId]), [userId]); @@ -137,15 +139,20 @@ export const useUserProfile = ( let spaceFont; let spacePronouns; - if (room) { + if (room && (renderRoomColors || renderRoomFonts)) { const state = room.getLiveTimeline().getState(EventTimeline.FORWARDS); - const localEvent = state?.getStateEvents(StateEvent.RoomCosmeticsColor, userId); - localColor = (Array.isArray(localEvent) ? localEvent[0] : localEvent)?.getContent()?.color; + if (renderRoomColors) { + const localEvent = state?.getStateEvents(StateEvent.RoomCosmeticsColor, userId); + localColor = (Array.isArray(localEvent) ? localEvent[0] : localEvent)?.getContent()?.color; + } - const localFontEvent = state?.getStateEvents(StateEvent.RoomCosmeticsFont, userId); - localFont = (Array.isArray(localFontEvent) ? localFontEvent[0] : localFontEvent)?.getContent() - ?.font; + if (renderRoomFonts) { + const localFontEvent = state?.getStateEvents(StateEvent.RoomCosmeticsFont, userId); + localFont = ( + Array.isArray(localFontEvent) ? localFontEvent[0] : localFontEvent + )?.getContent()?.font; + } const localPronounEvent = state?.getStateEvents( StateEvent.RoomCosmeticsPronouns as string, @@ -160,13 +167,18 @@ export const useUserProfile = ( const parentSpace = mx.getRoom(parents[0].getStateKey()); const pState = parentSpace?.getLiveTimeline().getState(EventTimeline.FORWARDS); - const spaceEvent = pState?.getStateEvents(StateEvent.RoomCosmeticsColor, userId); - spaceColor = (Array.isArray(spaceEvent) ? spaceEvent[0] : spaceEvent)?.getContent()?.color; + if (renderRoomColors) { + const spaceEvent = pState?.getStateEvents(StateEvent.RoomCosmeticsColor, userId); + spaceColor = (Array.isArray(spaceEvent) ? spaceEvent[0] : spaceEvent)?.getContent() + ?.color; + } - const spaceFontEvent = pState?.getStateEvents(StateEvent.RoomCosmeticsFont, userId); - spaceFont = ( - Array.isArray(spaceFontEvent) ? spaceFontEvent[0] : spaceFontEvent - )?.getContent()?.font; + if (renderRoomFonts) { + const spaceFontEvent = pState?.getStateEvents(StateEvent.RoomCosmeticsFont, userId); + spaceFont = ( + Array.isArray(spaceFontEvent) ? spaceFontEvent[0] : spaceFontEvent + )?.getContent()?.font; + } } } const validGlobalVal = isValidHex(data?.nameColor); @@ -203,5 +215,15 @@ export const useUserProfile = ( resolvedPronouns, pronouns: resolvedPronouns, }; - }, [cached, userId, room, mx, legacyUsernameColor, renderGlobalColors, initialProfile]); + }, [ + cached, + userId, + room, + mx, + legacyUsernameColor, + renderGlobalColors, + initialProfile, + renderRoomColors, + renderRoomFonts, + ]); }; diff --git a/src/app/pages/Router.tsx b/src/app/pages/Router.tsx index d8f6471f7..a5891db6a 100644 --- a/src/app/pages/Router.tsx +++ b/src/app/pages/Router.tsx @@ -55,6 +55,7 @@ import { getSpaceLobbyPath, } from './pathUtils'; import { ClientBindAtoms, ClientLayout, ClientRoot } from './client'; +import { HandleNotificationClick, ClientNonUIFeatures } from './client/ClientNonUIFeatures'; import { Home, HomeRouteRoomProvider, HomeSearch } from './client/home'; import { Direct, DirectCreate, DirectRouteRoomProvider } from './client/direct'; import { RouteSpaceProvider, Space, SpaceRouteRoomProvider, SpaceSearch } from './client/space'; @@ -65,7 +66,6 @@ import { WelcomePage } from './client/WelcomePage'; import { SidebarNav } from './client/SidebarNav'; import { MobileFriendlyPageNav, MobileFriendlyClientNav } from './MobileFriendly'; import { ClientInitStorageAtom } from './client/ClientInitStorageAtom'; -import { ClientNonUIFeatures } from './client/ClientNonUIFeatures'; import { AuthRouteThemeManager, UnAuthRouteThemeManager } from './ThemeManager'; import { ClientRoomsNotificationPreferences } from './client/ClientRoomsNotificationPreferences'; import { HomeCreateRoom } from './client/home/CreateRoom'; @@ -141,6 +141,10 @@ export const createRouter = (clientConfig: ClientConfig, screenSize: ScreenSize) }} element={ + {/* HandleNotificationClick must live outside ClientRoot's loading gate so + SW notification-click postMessages are never dropped during client + reloads (e.g., account switches). It only needs navigate + Jotai atoms. */} + diff --git a/src/app/pages/auth/AuthFooter.tsx b/src/app/pages/auth/AuthFooter.tsx index 53d59271c..3f8f5c04f 100644 --- a/src/app/pages/auth/AuthFooter.tsx +++ b/src/app/pages/auth/AuthFooter.tsx @@ -14,7 +14,7 @@ export function AuthFooter() { target="_blank" rel="noreferrer" > - v1.3.2 + v1.3.3 Powered by Matrix diff --git a/src/app/pages/auth/ServerPicker.tsx b/src/app/pages/auth/ServerPicker.tsx index e66d92a1d..10dddb7d0 100644 --- a/src/app/pages/auth/ServerPicker.tsx +++ b/src/app/pages/auth/ServerPicker.tsx @@ -89,6 +89,8 @@ export function ServerPicker({ size="500" readOnly={!allowCustomServer} onClick={allowCustomServer ? undefined : handleOpenServerMenu} + // disable auto-capitalization, which is usually undesirable for server name input. + autoCapitalize="off" after={ serverList.length === 0 || (serverList.length === 1 && !allowCustomServer) ? undefined : ( } /> {loginState.status === AsyncStatus.Error && ( diff --git a/src/app/pages/client/BackgroundNotifications.tsx b/src/app/pages/client/BackgroundNotifications.tsx index f0b683e4a..1b1f89ec5 100644 --- a/src/app/pages/client/BackgroundNotifications.tsx +++ b/src/app/pages/client/BackgroundNotifications.tsx @@ -9,12 +9,14 @@ import { SyncState, PushProcessor, } from '$types/matrix-sdk'; -import { useAtomValue, useSetAtom } from 'jotai'; +import { useAtom, useAtomValue, useSetAtom } from 'jotai'; import { sessionsAtom, activeSessionIdAtom, Session, pendingNotificationAtom, + backgroundUnreadCountsAtom, + inAppBannerAtom, } from '$state/sessions'; import { useSetting } from '$state/hooks/settings'; import { settingsAtom } from '$state/settings'; @@ -29,16 +31,16 @@ import { NotificationType, StateEvent } from '$types/matrix/room'; import { createLogger } from '$utils/debug'; import LogoSVG from '$public/res/svg/cinny.svg'; import { nicknamesAtom } from '$state/nicknames'; -import { useMatrixClient } from '$hooks/useMatrixClient'; import { buildRoomMessageNotification, resolveNotificationPreviewText, } from '$utils/notificationStyle'; -import { mobileOrTablet } from '$utils/user-agent'; import { startClient, stopClient } from '$client/initMatrix'; import { useClientConfig } from '$hooks/useClientConfig'; const log = createLogger('BackgroundNotifications'); +const isClientReadyForNotifications = (state: SyncState | string | null): boolean => + state === SyncState.Prepared || state === SyncState.Syncing || state === SyncState.Catchup; const startBackgroundClient = async ( session: Session, @@ -66,12 +68,12 @@ const startBackgroundClient = async ( const waitForSync = (mx: MatrixClient): Promise => new Promise((resolve) => { const state = mx.getSyncState(); - if (state === SyncState.Syncing) { + if (isClientReadyForNotifications(state)) { resolve(); return; } const onSync = (newState: SyncState) => { - if (newState === SyncState.Syncing) { + if (isClientReadyForNotifications(newState)) { mx.removeListener(ClientEvent.Sync, onSync); resolve(); } @@ -82,8 +84,7 @@ const waitForSync = (mx: MatrixClient): Promise => export function BackgroundNotifications() { const clientConfig = useClientConfig(); const sessions = useAtomValue(sessionsAtom); - const activeSessionId = useAtomValue(activeSessionIdAtom); - const setActiveSessionId = useSetAtom(activeSessionIdAtom); + const [activeSessionId, setActiveSessionId] = useAtom(activeSessionIdAtom); const [showNotifications] = useSetting(settingsAtom, 'useInAppNotifications'); const [usePushNotifications] = useSetting(settingsAtom, 'usePushNotifications'); const [notificationSound] = useSetting(settingsAtom, 'isNotificationSounds'); @@ -92,14 +93,29 @@ export function BackgroundNotifications() { settingsAtom, 'showMessageContentInEncryptedNotifications' ); - const forcePushOnMobile = usePushNotifications && mobileOrTablet(); - const activeMx = useMatrixClient(); + const shouldRunBackgroundNotifications = showNotifications || usePushNotifications; const nicknames = useAtomValue(nicknamesAtom); const nicknamesRef = useRef(nicknames); nicknamesRef.current = nicknames; + // Refs so handleTimeline callbacks always read current settings without stale closures + const showNotificationsRef = useRef(showNotifications); + showNotificationsRef.current = showNotifications; + const notificationSoundRef = useRef(notificationSound); + notificationSoundRef.current = notificationSound; + const showMessageContentRef = useRef(showMessageContent); + showMessageContentRef.current = showMessageContent; + const showEncryptedMessageContentRef = useRef(showEncryptedMessageContent); + showEncryptedMessageContentRef.current = showEncryptedMessageContent; const clientsRef = useRef>(new Map()); const notifiedEventsRef = useRef>(new Set()); const setPending = useSetAtom(pendingNotificationAtom); + const setBackgroundUnreads = useSetAtom(backgroundUnreadCountsAtom); + const setInAppBanner = useSetAtom(inAppBannerAtom); + // Stable setter refs so async handleTimeline closures never go stale. + const setBackgroundUnreadsRef = useRef(setBackgroundUnreads); + setBackgroundUnreadsRef.current = setBackgroundUnreads; + const setInAppBannerRef = useRef(setInAppBanner); + setInAppBannerRef.current = setInAppBanner; const inactiveSessions = sessions.filter( (s) => s.userId !== (activeSessionId ?? sessions[0]?.userId) @@ -116,36 +132,56 @@ export function BackgroundNotifications() { badge?: string; /** If `true` the notification plays no sound. */ silent?: boolean; - /** Callback when the user taps/clicks the notification. */ + /** Arbitrary payload attached to the notification. + * Must include { type, room_id, event_id, user_id } so the SW notificationclick + * handler can route the tap through HandleNotificationClick for account switching. */ + data?: unknown; + /** Optional callback invoked when the user clicks the notification (window.Notification + * fallback path only; the SW path routes via its own notificationclick handler). */ onClick?: () => void; } useEffect(() => { - if (forcePushOnMobile) return undefined; - if (!showNotifications) return undefined; + if (!shouldRunBackgroundNotifications) return undefined; const { current } = clientsRef; const activeIds = new Set(inactiveSessions.map((s) => s.userId)); - async function sendNotification(opts: NotifyOptions): Promise { + async function sendNotification(opts: NotifyOptions): Promise { + // Prefer ServiceWorkerRegistration.showNotification so that taps are handled + // by the SW notificationclick event. This routes through HandleNotificationClick + // (postMessage path) which does the account switch + deep link reliably on all + // platforms including iOS where window.Notification onclick is not fired. + if ('serviceWorker' in navigator) { + try { + const reg = await navigator.serviceWorker.ready; + await reg.showNotification(opts.title, { + body: opts.body, + icon: opts.icon, + badge: opts.badge, + silent: opts.silent ?? false, + data: opts.data, + } as NotificationOptions); + return; + } catch { + // Fall through to window.Notification if SW registration fails. + } + } if ('Notification' in window && window.Notification.permission === 'granted') { const noti = new window.Notification(opts.title, { icon: opts.icon, badge: opts.badge, body: opts.body, silent: opts.silent ?? false, + data: opts.data, }); if (opts.onClick) { - const cb = opts.onClick; noti.onclick = () => { - cb(); + opts.onClick?.(); noti.close(); }; } - return noti; } - - return undefined; } current.forEach((mx, userId) => { @@ -153,6 +189,12 @@ export function BackgroundNotifications() { log.log('stopping background client for', userId); stopClient(mx); current.delete(userId); + // Clear the background unread badge when this session is no longer a background account. + setBackgroundUnreads((prev) => { + const next = { ...prev }; + delete next[userId]; + return next; + }); } }); @@ -176,18 +218,17 @@ export function BackgroundNotifications() { removed: boolean, data: { liveEvent: boolean } ) => { - if (mx.getSyncState() !== 'SYNCING') return; + if (!isClientReadyForNotifications(mx.getSyncState())) return; if (!room || !data?.liveEvent || room.isSpaceRoom()) return; if (!isNotificationEvent(mEvent)) return; const notifType = getNotificationType(mx, room.roomId); if (notifType === NotificationType.Mute) return; - const activeRoom = activeMx.getRoom(room.roomId); - if (activeRoom?.getMyMembership() === 'join') return; - const eventId = mEvent.getId(); - if (!eventId || notifiedEventsRef.current.has(eventId)) return; + if (!eventId) return; + const dedupeId = `${session.userId}:${eventId}`; + if (notifiedEventsRef.current.has(dedupeId)) return; const sender = mEvent.getSender(); if (!sender || sender === mx.getUserId()) return; @@ -206,28 +247,56 @@ export function BackgroundNotifications() { ? (mxcUrlToHttp(mx, avatarMxc, false, 96, 96, 'crop') ?? undefined) : LogoSVG; - const isHighlight = pushActions.tweaks?.highlight === true; + const loudByRule = Boolean(pushActions.tweaks?.sound); + + // Track background unread count for every notifiable event (loud or silent). + const isHighlight = Boolean(pushActions.tweaks?.highlight); + setBackgroundUnreadsRef.current((prev) => { + const cur = prev[session.userId] ?? { total: 0, highlight: 0 }; + return { + ...prev, + [session.userId]: { + total: cur.total + 1, + highlight: isHighlight ? cur.highlight + 1 : cur.highlight, + }, + }; + }); + + // Silent-rule events: unread badge updated above; no OS notification or sound. + if (!loudByRule && !isHighlight) return; + const isEncryptedRoom = !!getStateEvent(room, StateEvent.RoomEncryption); - notifiedEventsRef.current.add(eventId); + notifiedEventsRef.current.add(dedupeId); // Cap the set so it doesn't grow unbounded if (notifiedEventsRef.current.size > 200) { const first = notifiedEventsRef.current.values().next().value; if (first) notifiedEventsRef.current.delete(first); } + // This component handles ONLY background (inactive) accounts. + // SW push covers the active account when the app is backgrounded. + // When the page is hidden, iOS suspends JS entirely — nothing to do here. + // Only show an in-app notification when the user is actively looking at the app. + if (document.visibilityState !== 'visible') return; + + // Respect in-app notification setting (read from ref to avoid stale closure) + if (!showNotificationsRef.current) return; + const notificationPayload = buildRoomMessageNotification({ - roomName: room.name ?? 'Unknown', + roomName: room.name ?? room.getCanonicalAlias() ?? room.roomId, roomAvatar, username: senderName, + recipientId: session.userId, previewText: resolveNotificationPreviewText({ content: mEvent.getContent(), eventType: mEvent.getType(), isEncryptedRoom, - showMessageContent, - showEncryptedMessageContent, + showMessageContent: showMessageContentRef.current, + showEncryptedMessageContent: showEncryptedMessageContentRef.current, }), - silent: !notificationSound || !isHighlight, + // Play sound only if the push rule requests it and the user has sounds enabled. + silent: !notificationSoundRef.current || !loudByRule, eventId, data: { type: mEvent.getType(), @@ -237,18 +306,38 @@ export function BackgroundNotifications() { }, }); - sendNotification({ - title: notificationPayload.title, - icon: notificationPayload.options.icon, - badge: notificationPayload.options.badge, - body: notificationPayload.options.body, - silent: notificationPayload.options.silent ?? undefined, - onClick: () => { - window.focus(); - setPending({ roomId: room.roomId, eventId, targetSessionId: session.userId }); - if (session.userId !== activeSessionId) setActiveSessionId(session.userId); - }, - }); + const notifOnClick = () => { + window.focus(); + // Always switch to the background account – jotai ignores no-op updates + setActiveSessionId(session.userId); + setPending({ roomId: room.roomId, eventId, targetSessionId: session.userId }); + }; + + if (document.visibilityState === 'visible') { + // App is in the foreground on a different account — show the themed in-app banner. + setInAppBannerRef.current({ + id: dedupeId, + title: notificationPayload.title, + roomName: room.name ?? room.getCanonicalAlias() ?? undefined, + senderName, + body: notificationPayload.options.body, + icon: notificationPayload.options.icon, + onClick: notifOnClick, + }); + } else if (loudByRule) { + // App is backgrounded — fire an OS notification only for loud (sound-tweak) rules. + // Highlight-only events are silently counted in the badge; OS noise is left to the + // user's own push rules for that account. + sendNotification({ + title: notificationPayload.title, + icon: notificationPayload.options.icon, + badge: notificationPayload.options.badge, + body: notificationPayload.options.body, + silent: notificationPayload.options.silent ?? undefined, + data: notificationPayload.options.data, + onClick: notifOnClick, + }); + } }; mx.on(RoomEvent.Timeline, handleTimeline as unknown as (...args: unknown[]) => void); @@ -265,15 +354,11 @@ export function BackgroundNotifications() { }, [ clientConfig.slidingSync, inactiveSessions, - forcePushOnMobile, - showNotifications, - notificationSound, - showMessageContent, - showEncryptedMessageContent, - activeMx, - activeSessionId, + shouldRunBackgroundNotifications, setActiveSessionId, setPending, + setBackgroundUnreads, + setInAppBanner, ]); return null; diff --git a/src/app/pages/client/ClientNonUIFeatures.tsx b/src/app/pages/client/ClientNonUIFeatures.tsx index 5c608d374..f3bbfb26b 100644 --- a/src/app/pages/client/ClientNonUIFeatures.tsx +++ b/src/app/pages/client/ClientNonUIFeatures.tsx @@ -1,9 +1,10 @@ import { useAtomValue, useSetAtom } from 'jotai'; import { ReactNode, useCallback, useEffect, useRef } from 'react'; import { useNavigate } from 'react-router-dom'; -import { EventType, RoomEvent, RoomEventHandlerMap } from '$types/matrix-sdk'; -import { roomToUnreadAtom, unreadEqual, unreadInfoToUnread } from '$state/room/roomToUnread'; +import { EventType, PushProcessor, RoomEvent, RoomEventHandlerMap } from '$types/matrix-sdk'; +import { roomToUnreadAtom } from '$state/room/roomToUnread'; import LogoSVG from '$public/res/svg/cinny.svg'; +import { NotificationBanner } from '$components/notification-banner'; import LogoUnreadSVG from '$public/res/svg/cinny-unread.svg'; import LogoHighlightSVG from '$public/res/svg/cinny-highlight.svg'; import NotificationSound from '$public/sound/notification.ogg'; @@ -19,16 +20,15 @@ import { getMemberDisplayName, getNotificationType, getStateEvent, - getUnreadInfo, isNotificationEvent, } from '$utils/room'; -import { NotificationType, StateEvent, UnreadInfo } from '$types/matrix/room'; +import { NotificationType, StateEvent } from '$types/matrix/room'; import { getMxIdLocalPart, mxcUrlToHttp } from '$utils/matrix'; import { useSelectedRoom } from '$hooks/router/useSelectedRoom'; import { useInboxNotificationsSelected } from '$hooks/router/useInbox'; import { useMediaAuthentication } from '$hooks/useMediaAuthentication'; import { registrationAtom } from '$state/serviceWorkerRegistration'; -import { activeSessionIdAtom, pendingNotificationAtom } from '$state/sessions'; +import { activeSessionIdAtom, pendingNotificationAtom, inAppBannerAtom } from '$state/sessions'; import { buildRoomMessageNotification, resolveNotificationPreviewText, @@ -89,13 +89,24 @@ function FaviconUpdater() { } try { navigator.setAppBadge(total); - if (usePushNotifications && total === 0) { - registration - .getNotifications() - .then((pushNotifications) => - pushNotifications.forEach((pushNotification) => pushNotification.close()) - ); - navigator.clearAppBadge(); + if (usePushNotifications) { + if (total === 0) { + // All rooms read — clear every notification and the badge. + registration.getNotifications().then((notifs) => notifs.forEach((n) => n.close())); + navigator.clearAppBadge(); + } else { + // Dismiss notifications for individual rooms that are now fully read. + registration.getNotifications().then((notifs) => { + notifs.forEach((n) => { + const notifRoomId = n.data?.room_id; + if (!notifRoomId) return; + const roomUnread = roomToUnread.get(notifRoomId); + if (!roomUnread || (roomUnread.total === 0 && roomUnread.highlight === 0)) { + n.close(); + } + }); + }); + } } } catch { // Likely Firefox/Gecko-based and doesn't support badging API @@ -115,7 +126,6 @@ function InviteNotifications() { const [showNotifications] = useSetting(settingsAtom, 'useInAppNotifications'); const [usePushNotifications] = useSetting(settingsAtom, 'usePushNotifications'); const [notificationSound] = useSetting(settingsAtom, 'isNotificationSounds'); - const forcePushOnMobile = usePushNotifications && mobileOrTablet(); const notify = useCallback( (count: number) => { @@ -140,16 +150,22 @@ function InviteNotifications() { }, []); useEffect(() => { - if (forcePushOnMobile) return; - if (usePushNotifications && document.visibilityState !== 'visible') return; - if (invites.length > perviousInviteLen && mx.getSyncState() === 'SYNCING') { - if (showNotifications && notificationPermission('granted')) { - notify(invites.length - perviousInviteLen); - } + if (invites.length <= perviousInviteLen || mx.getSyncState() !== 'SYNCING') return; - if (notificationSound) { - playSound(); - } + // Page hidden: if push is enabled, SW handles the OS notification. If not, nothing to do. + if (document.visibilityState !== 'visible') return; + + // Page is visible — show in-app experience. + // On mobile with push: iOS-style — play sound only, no OS notification (SW is silent when + // the app is visible on mobile, matching foreground behaviour of native chat apps). + // On desktop with push: SW skipped (saw a visible client), so we show the OS notification. + // Without push: always show OS notification when page is visible. + const isVisibleMobileWithPush = usePushNotifications && mobileOrTablet(); + if (!isVisibleMobileWithPush && showNotifications && notificationPermission('granted')) { + notify(invites.length - perviousInviteLen); + } + if (notificationSound) { + playSound(); } }, [ mx, @@ -157,7 +173,6 @@ function InviteNotifications() { perviousInviteLen, showNotifications, usePushNotifications, - forcePushOnMobile, notificationSound, notify, playSound, @@ -173,8 +188,7 @@ function InviteNotifications() { function MessageNotifications() { const audioRef = useRef(null); - const notifRef = useRef(); - const unreadCacheRef = useRef>(new Map()); + const notifiedEventsRef = useRef>(new Set()); const mx = useMatrixClient(); const useAuthentication = useMediaAuthentication(); const [showNotifications] = useSetting(settingsAtom, 'useInAppNotifications'); @@ -185,61 +199,22 @@ function MessageNotifications() { settingsAtom, 'showMessageContentInEncryptedNotifications' ); - const forcePushOnMobile = usePushNotifications && mobileOrTablet(); const nicknames = useAtomValue(nicknamesAtom); const nicknamesRef = useRef(nicknames); nicknamesRef.current = nicknames; const setPending = useSetAtom(pendingNotificationAtom); + const setInAppBanner = useSetAtom(inAppBannerAtom); const selectedRoomId = useSelectedRoom(); const notificationSelected = useInboxNotificationsSelected(); - const notify = useCallback( - ({ - roomName, - roomAvatar, - username, - roomId, - eventId, - previewText, - }: { - roomName: string; - roomAvatar?: string; - username: string; - roomId: string; - eventId: string; - previewText: string; - }) => { - const payload = buildRoomMessageNotification({ - roomName, - roomAvatar, - username, - previewText, - silent: true, - eventId, - }); - const noti = new window.Notification(payload.title, payload.options); - - noti.onclick = () => { - window.focus(); - setPending({ roomId, eventId, targetSessionId: mx.getUserId() ?? undefined }); - - noti.close(); - notifRef.current = undefined; - }; - - notifRef.current?.close(); - notifRef.current = noti; - }, - [mx, setPending] - ); - const playSound = useCallback(() => { const audioElement = audioRef.current; audioElement?.play(); }, []); useEffect(() => { + const pushProcessor = new PushProcessor(mx); const handleTimelineEvent: RoomEventHandlerMap[RoomEvent.Timeline] = ( mEvent, room, @@ -247,9 +222,7 @@ function MessageNotifications() { removed, data ) => { - if (forcePushOnMobile) return; if (mx.getSyncState() !== 'SYNCING') return; - if (usePushNotifications && document.visibilityState !== 'visible') return; if (document.hasFocus() && (selectedRoomId === room?.roomId || notificationSelected)) return; if ( @@ -265,23 +238,85 @@ function MessageNotifications() { const sender = mEvent.getSender(); const eventId = mEvent.getId(); if (!sender || !eventId || mEvent.getSender() === mx.getUserId()) return; - const unreadInfo = getUnreadInfo(room); - const cachedUnreadInfo = unreadCacheRef.current.get(room.roomId); - unreadCacheRef.current.set(room.roomId, unreadInfo); - if (unreadInfo.total === 0) return; - if ( - cachedUnreadInfo && - unreadEqual(unreadInfoToUnread(cachedUnreadInfo), unreadInfoToUnread(unreadInfo)) - ) { - return; + // Deduplicate: don't show a second banner if this event fires twice + // (e.g., decrypted events re-emitted by the SDK). + if (notifiedEventsRef.current.has(eventId)) return; + + const pushActions = pushProcessor.actionsForEvent(mEvent); + if (!pushActions?.notify) return; + const loudByRule = Boolean(pushActions.tweaks?.sound); + const isHighlightByRule = Boolean(pushActions.tweaks?.highlight); + + // If neither a loud nor a highlight rule matches, nothing to show. + if (!isHighlightByRule && !loudByRule) return; + + // Page hidden: SW (push) handles the OS notification. Nothing to do in-app. + if (document.visibilityState !== 'visible') return; + + // Record as notified to prevent duplicate banners (e.g. re-emitted decrypted events). + notifiedEventsRef.current.add(eventId); + if (notifiedEventsRef.current.size > 200) { + const first = notifiedEventsRef.current.values().next().value; + if (first) notifiedEventsRef.current.delete(first); } - if (showNotifications && notificationPermission('granted')) { + // Page is visible — show the themed in-app notification banner for any + // highlighted message (mention / keyword) or loud push rule. + if ((isHighlightByRule || loudByRule) && showNotifications) { const isEncryptedRoom = !!getStateEvent(room, StateEvent.RoomEncryption); const avatarMxc = room.getAvatarFallbackMember()?.getMxcAvatarUrl() ?? room.getMxcAvatarUrl(); - notify({ + const roomAvatar = avatarMxc + ? (mxcUrlToHttp(mx, avatarMxc, useAuthentication, 96, 96, 'crop') ?? undefined) + : undefined; + const resolvedSenderName = + getMemberDisplayName(room, sender, nicknamesRef.current) ?? + getMxIdLocalPart(sender) ?? + sender; + const previewText = resolveNotificationPreviewText({ + content: mEvent.getContent(), + eventType: mEvent.getType(), + isEncryptedRoom, + showMessageContent, + showEncryptedMessageContent, + }); + const payload = buildRoomMessageNotification({ + roomName: room.name ?? 'Unknown', + roomAvatar, + username: resolvedSenderName, + previewText, + silent: !notificationSound, + eventId, + }); + const { roomId } = room; + const capturedEventId = eventId; + const capturedUserId = mx.getUserId() ?? undefined; + const canonicalAlias = room.getCanonicalAlias(); + const serverName = canonicalAlias?.split(':')[1] ?? room.roomId.split(':')[1] ?? undefined; + setInAppBanner({ + id: eventId, + title: payload.title, + roomName: room.name ?? undefined, + serverName, + senderName: resolvedSenderName, + body: previewText, + icon: roomAvatar, + onClick: () => { + window.focus(); + setPending({ roomId, eventId: capturedEventId, targetSessionId: capturedUserId }); + }, + }); + } + + // On desktop without push: also fire an OS notification as a secondary fallback + // so the user is alerted even if the browser window is minimised. + const isVisibleMobileWithPush = usePushNotifications && mobileOrTablet(); + if (!isVisibleMobileWithPush && showNotifications && notificationPermission('granted')) { + const isEncryptedRoom = !!getStateEvent(room, StateEvent.RoomEncryption); + const avatarMxc = + room.getAvatarFallbackMember()?.getMxcAvatarUrl() ?? room.getMxcAvatarUrl(); + const osPayload = buildRoomMessageNotification({ roomName: room.name ?? 'Unknown', roomAvatar: avatarMxc ? (mxcUrlToHttp(mx, avatarMxc, useAuthentication, 96, 96, 'crop') ?? undefined) @@ -290,8 +325,6 @@ function MessageNotifications() { getMemberDisplayName(room, sender, nicknamesRef.current) ?? getMxIdLocalPart(sender) ?? sender, - roomId: room.roomId, - eventId, previewText: resolveNotificationPreviewText({ content: mEvent.getContent(), eventType: mEvent.getType(), @@ -299,10 +332,20 @@ function MessageNotifications() { showMessageContent, showEncryptedMessageContent, }), + // Play sound only if the push rule requests it and the user has sounds enabled. + silent: !notificationSound || !loudByRule, + eventId, }); + const noti = new window.Notification(osPayload.title, osPayload.options); + const { roomId } = room; + noti.onclick = () => { + window.focus(); + setPending({ roomId, eventId, targetSessionId: mx.getUserId() ?? undefined }); + noti.close(); + }; } - if (notificationSound) { + if (notificationSound && loudByRule) { playSound(); } }; @@ -318,9 +361,9 @@ function MessageNotifications() { showMessageContent, showEncryptedMessageContent, usePushNotifications, - forcePushOnMobile, playSound, - notify, + setInAppBanner, + setPending, selectedRoomId, useAuthentication, ]); @@ -351,15 +394,17 @@ type ClientNonUIFeaturesProps = { children: ReactNode; }; -function HandleNotificationClick() { +export function HandleNotificationClick() { const navigate = useNavigate(); - const activeSessionId = useAtomValue(activeSessionIdAtom); const setActiveSessionId = useSetAtom(activeSessionIdAtom); const setPending = useSetAtom(pendingNotificationAtom); useEffect(() => { const handleNotificationClickEvent = (event: any) => { - if (!event.data || !event.source) return; + if (!event.data) return; + // Note: do NOT guard on event.source — iOS Safari sets it to null for + // SW-to-client postMessages (Webkit divergence from spec). The type check + // below is the correct way to filter unrelated messages. const eventData = event.data; if (!(eventData?.type === 'notificationToRoomEvent')) return; const messageData = eventData?.message; @@ -374,9 +419,9 @@ function HandleNotificationClick() { switch (eventType) { case EventType.RoomMessage: case EventType.RoomMessageEncrypted: - if (targetSessionId && targetSessionId !== activeSessionId) { - setActiveSessionId(targetSessionId); - } + // Always set the target session — jotai ignores no-ops if already active. + // This ensures we never accidentally navigate under the wrong account. + if (targetSessionId) setActiveSessionId(targetSessionId); setPending({ roomId: messageData!.room_id, eventId: messageData!.event_id, @@ -385,9 +430,7 @@ function HandleNotificationClick() { return; case EventType.RoomMember: if (!(messageData?.content?.membership === 'invite')) return; - if (targetSessionId && targetSessionId !== activeSessionId) { - setActiveSessionId(targetSessionId); - } + if (targetSessionId) setActiveSessionId(targetSessionId); navigate(getInboxInvitesPath()); break; default: @@ -399,7 +442,7 @@ function HandleNotificationClick() { return () => { navigator.serviceWorker.removeEventListener('message', handleNotificationClickEvent); }; - }, [activeSessionId, navigate, setActiveSessionId, setPending]); + }, [navigate, setActiveSessionId, setPending]); return null; } @@ -415,7 +458,9 @@ function SyncNotificationSettingsWithServiceWorker() { useEffect(() => { if (!('serviceWorker' in navigator)) return; - const preferPushOnMobile = usePushNotifications && mobileOrTablet(); + // preferPushOnMobile=false: SW skips push when page is visible on all devices. + // The in-app path handles the visible case (sound on mobile, OS notification on desktop). + const preferPushOnMobile = false; const payload = { type: 'setNotificationSettings' as const, notificationSoundEnabled: notificationSound, @@ -443,8 +488,8 @@ export function ClientNonUIFeatures({ children }: ClientNonUIFeaturesProps) { - + {children} ); diff --git a/src/app/pages/client/ToRoomEvent.tsx b/src/app/pages/client/ToRoomEvent.tsx index 41d47b81f..48321e66e 100644 --- a/src/app/pages/client/ToRoomEvent.tsx +++ b/src/app/pages/client/ToRoomEvent.tsx @@ -1,43 +1,35 @@ -import { useEffect, useState, useCallback } from 'react'; -import { useParams } from 'react-router-dom'; -import { useAtomValue } from 'jotai'; -import { SyncState } from '$types/matrix-sdk'; - -import { useRoomNavigate } from '../../hooks/useRoomNavigate'; -import { useMatrixClient } from '../../hooks/useMatrixClient'; -import { useSyncState } from '../../hooks/useSyncState'; -import { roomToParentsAtom } from '../../state/room/roomToParents'; -import { mDirectAtom } from '../../state/mDirectList'; +import { useEffect } from 'react'; +import { useParams, useSearchParams } from 'react-router-dom'; +import { useSetAtom } from 'jotai'; +import { activeSessionIdAtom, pendingNotificationAtom } from '$state/sessions'; +// ToRoomEvent handles the /to/:room_id/:event_id route used by the SW when it +// opens a new window for a push notification (killed-app case) OR by client.navigate() +// on iOS where postMessage is unreliable after focus(). +// +// It does NOT navigate itself. Instead it writes to pendingNotificationAtom so +// that NotificationJumper handles the actual navigation once the correct client +// is synced. This survives the ClientRoot account-switch reload that happens when +// setActiveSessionId() changes the active session: ToRoomEvent unmounts as soon +// as ClientRoot calls navigate(getHomePath()), but the atom value persists and +// NotificationJumper picks it up once the new client is ready. export function ToRoomEvent() { - const mx = useMatrixClient(); - const roomToParents = useAtomValue(roomToParentsAtom); - const mDirects = useAtomValue(mDirectAtom); const { room_id: roomId, event_id: eventId } = useParams(); - const { navigateRoom } = useRoomNavigate(); - const [syncState, setSyncState] = useState(mx?.getSyncState() ?? null); - - useSyncState( - mx, - useCallback((s) => setSyncState(s), []) - ); + const [searchParams] = useSearchParams(); + const targetUserId = searchParams.get('uid') ?? undefined; + const setActiveSessionId = useSetAtom(activeSessionIdAtom); + const setPending = useSetAtom(pendingNotificationAtom); useEffect(() => { - if (!roomId || !mx) { - return; - } - if (syncState !== SyncState.Syncing) { - return; - } - if (!roomToParents.size || !mDirects.size) { - return; - } - + if (!roomId) return; + const rid = roomId; // narrowed to string + if (targetUserId) setActiveSessionId(targetUserId); + setPending({ roomId: rid, eventId, targetSessionId: targetUserId }); + // Push a clean entry onto history so the back button doesn't return to /to/… if (window.history.length <= 2) { window.history.pushState({}, '', '/'); } - navigateRoom(roomId, eventId); - }, [mx, syncState, roomToParents, mDirects, roomId, eventId, navigateRoom]); + }, [roomId, eventId, targetUserId, setActiveSessionId, setPending]); return null; } diff --git a/src/app/pages/client/WelcomePage.tsx b/src/app/pages/client/WelcomePage.tsx index 316a6fe37..049de5c0c 100644 --- a/src/app/pages/client/WelcomePage.tsx +++ b/src/app/pages/client/WelcomePage.tsx @@ -19,7 +19,7 @@ export function WelcomePage() { Yet another matrix client fork.{' '} - v1.3.2 + v1.3.3 } diff --git a/src/app/pages/client/sidebar/AccountSwitcherTab.tsx b/src/app/pages/client/sidebar/AccountSwitcherTab.tsx index 866055157..61058d95c 100644 --- a/src/app/pages/client/sidebar/AccountSwitcherTab.tsx +++ b/src/app/pages/client/sidebar/AccountSwitcherTab.tsx @@ -17,8 +17,18 @@ import { import FocusTrap from 'focus-trap-react'; import { useAtom, useAtomValue, useSetAtom } from 'jotai'; import { useNavigate } from 'react-router-dom'; -import { sessionsAtom, activeSessionIdAtom, Session } from '$state/sessions'; -import { SidebarItem, SidebarItemTooltip, SidebarAvatar } from '$components/sidebar'; +import { + sessionsAtom, + activeSessionIdAtom, + Session, + backgroundUnreadCountsAtom, +} from '$state/sessions'; +import { + SidebarItem, + SidebarItemTooltip, + SidebarAvatar, + SidebarItemBadge, +} from '$components/sidebar'; import { UserAvatar } from '$components/user-avatar'; import { nameInitials } from '$utils/common'; import { getMxIdLocalPart, mxcUrlToHttp } from '$utils/matrix'; @@ -33,6 +43,7 @@ import { Settings } from '$features/settings'; import { Modal500 } from '$components/Modal500'; import { createLogger } from '$utils/debug'; import { useClientConfig } from '$hooks/useClientConfig'; +import { UnreadBadge, UnreadBadgeCenter } from '$components/unread-badge'; const log = createLogger('AccountSwitcherTab'); @@ -42,6 +53,7 @@ function AccountRow({ displayName, avatarUrl, isBusy, + unread, onSwitch, onSignOut, }: { @@ -50,6 +62,7 @@ function AccountRow({ displayName?: string; avatarUrl?: string; isBusy?: boolean; + unread?: { total: number; highlight: number }; onSwitch: (session: Session) => void; onSignOut: (session: Session) => void; }) { @@ -77,6 +90,11 @@ function AccountRow({ } after={ + {!isActive && unread && unread.total > 0 && ( + + 0} count={unread.total} /> + + )} {isActive && ( )} @@ -127,6 +145,16 @@ export function AccountSwitcherTab() { const [activeSessionId, setActiveSessionId] = useAtom(activeSessionIdAtom); const setSessions = useSetAtom(sessionsAtom); const useAuthentication = useMediaAuthentication(); + const backgroundUnreads = useAtomValue(backgroundUnreadCountsAtom); + const setBackgroundUnreads = useSetAtom(backgroundUnreadCountsAtom); + + // Total unread count across all background sessions (for the sidebar badge). + const totalBackgroundUnread = Object.entries(backgroundUnreads) + .filter(([uid]) => uid !== (activeSessionId ?? sessions[0]?.userId)) + .reduce((acc, [, u]) => acc + u.total, 0); + const anyBackgroundHighlight = Object.entries(backgroundUnreads) + .filter(([uid]) => uid !== (activeSessionId ?? sessions[0]?.userId)) + .some(([, u]) => u.highlight > 0); const [menuAnchor, setMenuAnchor] = useState(); const [busyUserIds, setBusyUserIds] = useState>(new Set()); @@ -161,8 +189,14 @@ export function AccountSwitcherTab() { setMenuAnchor(undefined); navigate(getHomePath(), { replace: true }); setActiveSessionId(session.userId); + // Clear the unread badge for the account we're now switching into. + setBackgroundUnreads((prev) => { + const next = { ...prev }; + delete next[session.userId]; + return next; + }); }, - [navigate, setActiveSessionId] + [navigate, setActiveSessionId, setBackgroundUnreads] ); const handleSignOut = useCallback( @@ -240,6 +274,11 @@ export function AccountSwitcherTab() { )} + {totalBackgroundUnread > 0 && ( + + + + )} diff --git a/src/app/plugins/custom-emoji/imagePackCache.ts b/src/app/plugins/custom-emoji/imagePackCache.ts new file mode 100644 index 000000000..f15f1fba0 --- /dev/null +++ b/src/app/plugins/custom-emoji/imagePackCache.ts @@ -0,0 +1,125 @@ +/** + * Persistent localStorage cache for image packs (emoji / stickers). + * + * Sliding Sync may not deliver `im.ponies.room_emotes` state events for rooms + * that aren't actively subscribed, so previously-seen packs would silently + * disappear on the next session. This cache persists the serialised pack + * content keyed by (userId, scope) so the UI can show stale-but-usable packs + * while the live state catches up. + * + * Scopes + * 'user' – the user's own im.ponies.user_emotes account-data pack + * 'global' – all globally-enabled room packs via im.ponies.emote_rooms + * 'room:' – packs local to a specific room + */ + +import { PackAddress } from './PackAddress'; +import { ImagePack } from './ImagePack'; +import { PackContent, PackImages } from './types'; + +// -------------------------------------------------------------------------- +// Types stored in localStorage +// -------------------------------------------------------------------------- + +type CachedAddress = { roomId: string; stateKey: string }; + +type CachedPackEntry = { + id: string; + content: PackContent; + address?: CachedAddress; +}; + +// -------------------------------------------------------------------------- +// Constants +// -------------------------------------------------------------------------- + +const STORAGE_KEY_PREFIX = 'sable:imgpk:v1'; + +// -------------------------------------------------------------------------- +// Helpers +// -------------------------------------------------------------------------- + +function storageKey(userId: string, scope: string): string { + return `${STORAGE_KEY_PREFIX}:${userId}:${scope}`; +} + +/** Reconstruct a plain `PackContent` from a live `ImagePack` instance. */ +function toPackContent(pack: ImagePack): PackContent { + const rawImages: PackImages = {}; + pack.images.collection.forEach((img, shortcode) => { + rawImages[shortcode] = img.content; + }); + return { + pack: pack.meta.content, + images: rawImages, + }; +} + +function deserializePacks(entries: CachedPackEntry[]): ImagePack[] { + return entries.map(({ id, content, address }) => { + const addr = address ? new PackAddress(address.roomId, address.stateKey) : undefined; + return new ImagePack(id, content, addr); + }); +} + +function serializePacks(packs: ImagePack[]): CachedPackEntry[] { + return packs + .filter((pack) => !pack.deleted) + .map((pack) => ({ + id: pack.id, + content: toPackContent(pack), + address: pack.address + ? { roomId: pack.address.roomId, stateKey: pack.address.stateKey } + : undefined, + })); +} + +// -------------------------------------------------------------------------- +// Public API +// -------------------------------------------------------------------------- + +/** Read cached packs for the given scope. Returns an empty array on any error. */ +export function readCachedPacks(userId: string, scope: string): ImagePack[] { + try { + const raw = localStorage.getItem(storageKey(userId, scope)); + if (!raw) return []; + const entries = JSON.parse(raw); + if (!Array.isArray(entries)) return []; + return deserializePacks(entries as CachedPackEntry[]); + } catch { + return []; + } +} + +/** Read a single cached pack for the given scope. Returns undefined on any error or miss. */ +export function readCachedPack(userId: string, scope: string): ImagePack | undefined { + return readCachedPacks(userId, scope)[0]; +} + +/** Persist packs for the given scope. Silently ignores storage errors. */ +export function writeCachedPacks(userId: string, scope: string, packs: ImagePack[]): void { + try { + const entries = serializePacks(packs); + if (entries.length === 0) { + localStorage.removeItem(storageKey(userId, scope)); + } else { + localStorage.setItem(storageKey(userId, scope), JSON.stringify(entries)); + } + } catch { + // private browsing / storage quota – silently ignore + } +} + +/** Persist a single pack, or remove the entry when undefined. */ +export function writeCachedPack(userId: string, scope: string, pack: ImagePack | undefined): void { + writeCachedPacks(userId, scope, pack ? [pack] : []); +} + +/** Scope string for the user's own pack. */ +export const userPackScope = () => 'user'; + +/** Scope string for the global pack list. */ +export const globalPacksScope = () => 'global'; + +/** Scope string for a specific room's packs. */ +export const roomPacksScope = (roomId: string) => `room:${roomId}`; diff --git a/src/app/plugins/custom-emoji/index.ts b/src/app/plugins/custom-emoji/index.ts index f833fa5bd..6a9c4e3b2 100644 --- a/src/app/plugins/custom-emoji/index.ts +++ b/src/app/plugins/custom-emoji/index.ts @@ -5,3 +5,4 @@ export * from './PackImagesReader'; export * from './ImagePack'; export * from './types'; export * from './utils'; +export * from './imagePackCache'; diff --git a/src/app/state/room/roomToUnread.ts b/src/app/state/room/roomToUnread.ts index 706b4bd7f..cf0064380 100644 --- a/src/app/state/room/roomToUnread.ts +++ b/src/app/state/room/roomToUnread.ts @@ -10,6 +10,7 @@ import { ReceiptContent, ReceiptType, EventType, + ClientEvent, } from '$types/matrix-sdk'; import { useCallback, useEffect, useRef } from 'react'; import { @@ -32,7 +33,6 @@ import { useSyncState } from '$hooks/useSyncState'; import { useRoomsNotificationPreferencesContext } from '$hooks/useRoomsNotificationPreferences'; import { getClientSyncDiagnostics } from '$client/initMatrix'; import { roomToParentsAtom } from './roomToParents'; -import { mDirectAtom } from '../mDirectList'; export type RoomToUnreadAction = | { @@ -123,14 +123,13 @@ const baseRoomToUnread = atom(new Map()); export const roomToUnreadAtom = atom( (get) => get(baseRoomToUnread), (get, set, action) => { - const dmRoomIds = get(mDirectAtom); - const getEffectiveParents = (roomId: string): Set => - dmRoomIds.has(roomId) ? new Set() : getAllParents(get(roomToParentsAtom), roomId); + const allParentsOf = (roomId: string): Set => + getAllParents(get(roomToParentsAtom), roomId); if (action.type === 'RESET') { const draftRoomToUnread: RoomToUnread = new Map(); action.unreadInfos.forEach((unreadInfo) => { - putUnreadInfo(draftRoomToUnread, getEffectiveParents(unreadInfo.roomId), unreadInfo); + putUnreadInfo(draftRoomToUnread, allParentsOf(unreadInfo.roomId), unreadInfo); }); set(baseRoomToUnread, draftRoomToUnread); return; @@ -144,7 +143,7 @@ export const roomToUnreadAtom = atom deleteUnreadInfo( draftRoomToUnread, - getEffectiveParents(unreadInfo.roomId), + allParentsOf(unreadInfo.roomId), unreadInfo.roomId ) ) @@ -154,14 +153,14 @@ export const roomToUnreadAtom = atom - putUnreadInfo(draftRoomToUnread, getEffectiveParents(unreadInfo.roomId), unreadInfo) + putUnreadInfo(draftRoomToUnread, allParentsOf(unreadInfo.roomId), unreadInfo) ) ); return; @@ -170,7 +169,7 @@ export const roomToUnreadAtom = atom - deleteUnreadInfo(draftRoomToUnread, getEffectiveParents(action.roomId), action.roomId) + deleteUnreadInfo(draftRoomToUnread, allParentsOf(action.roomId), action.roomId) ) ); } @@ -329,6 +328,25 @@ export const useBindRoomToUnreadAtom = (mx: MatrixClient, unreadAtom: typeof roo }; }, [mx, setUnreadAtom]); + // Seed badge state immediately when a room is first registered with the client + // (e.g. after joining or receiving an invite that gets auto-accepted). + // This avoids the brief window after refresh where badges are invisible until + // the next timeline event arrives. Notifications are NOT triggered here — + // ClientNonUIFeatures handles live notification pop-ups via its own listener. + useEffect(() => { + const handleRoomAdded = (room: Room) => { + if (room.isSpaceRoom() || room.getMyMembership() !== Membership.Join) return; + const unreadInfo = getUnreadInfo(room, { applyFixup: shouldApplyUnreadFixup() }); + if (unreadInfo.total > 0 || unreadInfo.highlight > 0) { + setUnreadAtom({ type: 'PUT', unreadInfo }); + } + }; + mx.on(ClientEvent.Room, handleRoomAdded as (room: Room) => void); + return () => { + mx.removeListener(ClientEvent.Room, handleRoomAdded as (room: Room) => void); + }; + }, [mx, setUnreadAtom, shouldApplyUnreadFixup]); + useEffect( () => () => { if (spaceChildResetTimerRef.current !== null) { diff --git a/src/app/state/sessions.ts b/src/app/state/sessions.ts index 5b02e8410..10a4ff3b0 100644 --- a/src/app/state/sessions.ts +++ b/src/app/state/sessions.ts @@ -165,8 +165,42 @@ export const activeSessionIdAtom = atom(null); + +// ─── In-app notification banner ──────────────────────────────────────────── + +export type InAppBannerNotification = { + /** Unique id; used to deduplicate rapid-fire events. */ + id: string; + /** Primary title line – kept for backwards-compat (background accounts). */ + title: string; + /** Room display name (used as the #channel part of the subtitle). */ + roomName?: string; + /** Homeserver extracted from the canonical alias or room ID (e.g. matrix.org). */ + serverName?: string; + /** Display name of the sender. */ + senderName?: string; + body?: string; + /** URL of an avatar or room icon to display inside the banner. */ + icon?: string; + onClick: () => void; +}; + +export const inAppBannerAtom = atom(null); + +// ─── Per-background-account unread counts ────────────────────────────────── + +export type BackgroundUnread = { + total: number; + highlight: number; +}; + +/** + * Keyed by userId. Counts accumulate while a session is in the background + * and are cleared when the user switches to that account. + */ +export const backgroundUnreadCountsAtom = atom>({}); diff --git a/src/app/state/settings.ts b/src/app/state/settings.ts index a68f8dfc5..835984b3f 100644 --- a/src/app/state/settings.ts +++ b/src/app/state/settings.ts @@ -61,12 +61,17 @@ export interface Settings { privacyBlurEmotes: boolean; showPronouns: boolean; renderGlobalNameColors: boolean; + filterPronounsBasedOnLanguage?: boolean; + filterPronounsLanguages?: string[]; + renderRoomColors: boolean; + renderRoomFonts: boolean; // Sable features! mobileGestures: boolean; rightSwipeAction: RightSwipeAction; hideMembershipInReadOnly: boolean; useRightBubbles: boolean; + showUnreadCounts: boolean; } const defaultSettings: Settings = { @@ -114,12 +119,15 @@ const defaultSettings: Settings = { privacyBlurEmotes: false, showPronouns: true, renderGlobalNameColors: true, + renderRoomColors: true, + renderRoomFonts: true, // Sable features! mobileGestures: true, rightSwipeAction: RightSwipeAction.Reply, hideMembershipInReadOnly: true, useRightBubbles: false, + showUnreadCounts: true, }; export const getSettings = () => { diff --git a/src/app/utils/matrix.ts b/src/app/utils/matrix.ts index 12b455b55..46d5e6ecc 100644 --- a/src/app/utils/matrix.ts +++ b/src/app/utils/matrix.ts @@ -16,8 +16,8 @@ import { import to from 'await-to-js'; import { IImageInfo, IThumbnailContent, IVideoInfo } from '$types/matrix/common'; import { AccountDataEvent } from '$types/matrix/accountData'; -import { Membership, StateEvent } from '$types/matrix/room'; -import { getStateEvent } from './room'; +import { Membership, MessageEvent, StateEvent } from '$types/matrix/room'; +import { getEventReactions, getReactionContent, getStateEvent } from './room'; const DOMAIN_REGEX = /\b(?:[a-zA-Z0-9-]+\.)+[a-zA-Z]{2,}\b/; @@ -382,3 +382,29 @@ export const creatorsSupported = (version: string): boolean => { const unsupportedVersion = ['1', '2', '3', '4', '5', '6', '7', '8', '9', '10', '11']; return !unsupportedVersion.includes(version); }; + +export const toggleReaction = ( + mx: MatrixClient, + room: Room, + targetEventId: string, + key: string, + shortcode?: string +) => { + const relations = getEventReactions(room.getUnfilteredTimelineSet(), targetEventId); + const allReactions = relations?.getSortedAnnotationsByKey() ?? []; + const [, reactionsSet] = allReactions.find(([k]: [string, any]) => k === key) ?? []; + const reactions: MatrixEvent[] = reactionsSet ? Array.from(reactionsSet) : []; + const myReaction = reactions.find(factoryEventSentBy(mx.getUserId()!)); + + if (myReaction && !!(myReaction as any)?.isRelation()) { + mx.redactEvent(room.roomId, (myReaction as any).getId()); + return; + } + const rShortcode = + shortcode || (reactions.find(eventWithShortcode)?.getContent().shortcode as string | undefined); + mx.sendEvent( + room.roomId, + MessageEvent.Reaction as any, + getReactionContent(targetEventId, key, rShortcode) + ); +}; diff --git a/src/app/utils/notificationStyle.ts b/src/app/utils/notificationStyle.ts index 0bfd85ad4..550a511f7 100644 --- a/src/app/utils/notificationStyle.ts +++ b/src/app/utils/notificationStyle.ts @@ -11,6 +11,10 @@ type RoomMessageNotificationInput = { silent?: boolean; eventId?: string; data?: unknown; + /** Matrix user ID of the account that received the notification. When provided, + * the account's localpart is appended to the title so multi-account users know + * which account the notification is for. */ + recipientId?: string; }; type NotificationPayload = { @@ -62,6 +66,9 @@ export const resolveNotificationPreviewText = ({ return encryptedContext ? ENCRYPTED_MESSAGE_PREVIEW : DEFAULT_MESSAGE_PREVIEW; }; +/** Extracts the localpart (everything between @ and the first :) from a Matrix user ID. */ +const toLocalpart = (userId: string): string => userId.match(/^@([^:]+):/)?.[1] ?? userId; + export const buildRoomMessageNotification = ({ roomName, username, @@ -70,14 +77,16 @@ export const buildRoomMessageNotification = ({ silent, eventId, data, + recipientId, }: RoomMessageNotificationInput): NotificationPayload => { const sender = getString(username, 'Someone'); const room = getString(roomName, 'Unknown'); const message = getString(previewText, DEFAULT_MESSAGE_PREVIEW); const avatar = getString(roomAvatar, DEFAULT_NOTIFICATION_ICON); + const recipientSuffix = recipientId ? ` • ${toLocalpart(recipientId)}` : ''; return { - title: `${sender} in ${room}`, + title: `${sender} in ${room}${recipientSuffix}`, options: { icon: avatar, badge: avatar || DEFAULT_NOTIFICATION_BADGE, diff --git a/src/app/utils/pronouns.ts b/src/app/utils/pronouns.ts new file mode 100644 index 000000000..a306543c6 --- /dev/null +++ b/src/app/utils/pronouns.ts @@ -0,0 +1,41 @@ +// helper function to convert a comma-separated pronouns string into an array of objects with summary and optional language +export function parsePronounsInput(pronouns: string): { summary: string; language?: string }[] { + return pronouns + .split(',') + .map((s) => s.trim()) + .filter(Boolean) + .map((s) => { + const parts = s.split(':'); + + if (parts.length === 1) { + return { + summary: parts[0].slice(0, 16), + language: 'en', + }; + } + + const [language, summary] = parts; + + return { + language: language || 'en', + summary: summary.slice(0, 16), + }; + }); +} + +// helper function to filter a list of pronouns based on the user's language settings +export function filterPronounsByLanguage( + pronouns: { summary: string; language?: string }[], + enabled: boolean, + languages: string[] +): { summary: string; language?: string }[] { + if (!enabled) return pronouns; + const normalizedLanguages = languages.map((lang) => lang.trim().toLowerCase()); + const filteredPronouns = pronouns.filter((p) => + normalizedLanguages.includes((p.language || 'en').trim().toLowerCase()) + ); + if (filteredPronouns.length === 0) { + return pronouns; + } + return filteredPronouns; +} diff --git a/src/app/utils/room.ts b/src/app/utils/room.ts index aed17e84b..e2b319391 100644 --- a/src/app/utils/room.ts +++ b/src/app/utils/room.ts @@ -13,6 +13,7 @@ import { MatrixEvent, MsgType, NotificationCountType, + PushProcessor, RelationType, Room, RoomMember, @@ -240,18 +241,24 @@ export const getUnreadInfo = (room: Room, options?: UnreadInfoOptions): UnreadIn } let total = room.getUnreadNotificationCount(NotificationCountType.Total); - let highlight = room.getUnreadNotificationCount(NotificationCountType.Highlight); - let syntheticDotUnread = false; + const highlight = room.getUnreadNotificationCount(NotificationCountType.Highlight); // If our latest main-timeline notification event is confirmed read, clamp its stale count. // Only apply to the room (non-thread) portion so thread reply counts are preserved. - if (userId && total > 0 && highlight === 0) { + // Guard: only clamp when the room has NO receipt-confirmed unread events; if roomHaveUnread + // is true then there genuinely are unread messages and the SDK count is not fully stale. + if (userId && total > 0 && highlight === 0 && !roomHaveUnread(room.client, room)) { const roomTotal = room.getRoomUnreadNotificationCount(NotificationCountType.Total); if (roomTotal > 0) { const liveEvents = room.getLiveTimeline().getEvents(); + // Exclude the user's own messages: own sent events are always "read" (hasUserReadEvent + // returns true for them), which would cause the clamp to fire incorrectly. const latestNotification = [...liveEvents] .reverse() - .find((event) => !event.isSending() && isNotificationEvent(event)); + .find( + (event) => + !event.isSending() && event.getSender() !== userId && isNotificationEvent(event) + ); const latestNotificationId = latestNotification?.getId(); if (latestNotificationId && room.hasUserReadEvent(userId, latestNotificationId)) { // Subtract only the stale main-timeline count; thread totals remain intact. @@ -260,19 +267,34 @@ export const getUnreadInfo = (room: Room, options?: UnreadInfoOptions): UnreadIn } } - // Fallback for cases where SDK counters are stale/zero but unread-by-receipt state still exists. - // Represent as a dot badge (count=0) rather than a numeric badge. - if (total === 0 && highlight === 0 && roomHaveUnread(room.client, room)) { - highlight = 1; - syntheticDotUnread = true; + // Fallback: SDK counters are stale/zero but there are receipt-confirmed unread + // messages. Walk the live timeline to compute real counts so the badge number + // and highlight colour reflect actual state rather than a hard-coded stub. + if (total === 0 && highlight === 0 && userId && roomHaveUnread(room.client, room)) { + const readUpToId = room.getEventReadUpTo(userId); + const liveEvents = room.getLiveTimeline().getEvents(); + let fallbackTotal = 0; + let fallbackHighlight = 0; + const pushProcessor = new PushProcessor(room.client); + for (let i = liveEvents.length - 1; i >= 0; i -= 1) { + const event = liveEvents[i]; + if (!event) break; + if (event.getId() === readUpToId) break; + if (isNotificationEvent(event) && event.getSender() !== userId) { + fallbackTotal += 1; + const pushActions = pushProcessor.actionsForEvent(event); + if (pushActions?.tweaks?.highlight) fallbackHighlight += 1; + } + } + if (fallbackTotal > 0) { + return { roomId: room.roomId, highlight: fallbackHighlight, total: fallbackTotal }; + } } - const resolvedTotal = syntheticDotUnread ? total : Math.max(total, highlight); - return { roomId: room.roomId, highlight, - total: resolvedTotal, + total: Math.max(total, highlight), }; }; @@ -498,9 +520,18 @@ export const getLatestEditableEvt = ( return undefined; }; -export const reactionOrEditEvent = (mEvent: MatrixEvent) => - mEvent.getRelation()?.rel_type === RelationType.Annotation || - mEvent.getRelation()?.rel_type === RelationType.Replace; +export const reactionOrEditEvent = (mEvent: MatrixEvent): boolean => { + const relType = mEvent.getRelation()?.rel_type; + if (relType === RelationType.Annotation || relType === RelationType.Replace) return true; + + // Sliding sync proxies may omit m.relates_to on the initial delivery of timeline + // events. Detect edit events by the presence of m.new_content in the event + // content even when the relation metadata is absent, so they are filtered from + // the rendered timeline rather than falling through as unsupported messages. + if (mEvent.getContent()['m.new_content'] !== undefined) return true; + + return false; +}; export const getMentionContent = (userIds: string[], room: boolean): IMentions => { const mMentions: IMentions = {}; diff --git a/src/client/slidingSync.ts b/src/client/slidingSync.ts index c94888439..0c8cf98e3 100644 --- a/src/client/slidingSync.ts +++ b/src/client/slidingSync.ts @@ -136,11 +136,15 @@ const buildDefaultSubscription = (timelineLimit: number): MSC3575RoomSubscriptio [EventType.RoomTombstone, ''], [EventType.RoomJoinRules, ''], [EventType.RoomHistoryVisibility, ''], + [EventType.RoomPowerLevels, ''], [StateEvent.PoniesRoomEmotes, '*'], [StateEvent.RoomWidget, '*'], [StateEvent.GroupCallPrefix, '*'], [EventType.SpaceChild, '*'], [EventType.SpaceParent, '*'], + [StateEvent.RoomCosmeticsColor, '*'], + [StateEvent.RoomCosmeticsFont, '*'], + [StateEvent.RoomCosmeticsPronouns, '*'], ], }); diff --git a/src/sw.ts b/src/sw.ts index 51c5124ad..87fbc3488 100644 --- a/src/sw.ts +++ b/src/sw.ts @@ -17,6 +17,47 @@ const { handlePushNotificationPushData } = createPushNotifications(self, () => ( showEncryptedMessageContent, })); +/** Cache key used to persist notification settings across SW restarts (iOS kills the SW frequently). */ +const SW_SETTINGS_CACHE = 'sable-sw-settings-v1'; +const SW_SETTINGS_URL = '/sw-settings-meta'; + +async function persistSettings() { + try { + const cache = await self.caches.open(SW_SETTINGS_CACHE); + await cache.put( + SW_SETTINGS_URL, + new Response( + JSON.stringify({ + notificationSoundEnabled, + preferPushOnMobile, + showMessageContent, + showEncryptedMessageContent, + }), + { headers: { 'Content-Type': 'application/json' } } + ) + ); + } catch { + // Ignore — caches may be unavailable in some environments. + } +} + +async function loadPersistedSettings() { + try { + const cache = await self.caches.open(SW_SETTINGS_CACHE); + const response = await cache.match(SW_SETTINGS_URL); + if (!response) return; + const s = await response.json(); + if (typeof s.notificationSoundEnabled === 'boolean') + notificationSoundEnabled = s.notificationSoundEnabled; + if (typeof s.preferPushOnMobile === 'boolean') preferPushOnMobile = s.preferPushOnMobile; + if (typeof s.showMessageContent === 'boolean') showMessageContent = s.showMessageContent; + if (typeof s.showEncryptedMessageContent === 'boolean') + showEncryptedMessageContent = s.showEncryptedMessageContent; + } catch { + // Ignore — stale or missing cache is fine; we fall back to defaults. + } +} + type SessionInfo = { accessToken: string; baseUrl: string; @@ -138,6 +179,8 @@ self.addEventListener('message', (event: ExtendableMessageEvent) => { showEncryptedMessageContent = (data as { showEncryptedMessageContent: boolean }) .showEncryptedMessageContent; } + // Persist so settings survive SW restart (iOS kills the SW aggressively). + event.waitUntil(persistSettings()); } }); @@ -213,6 +256,10 @@ const onPushNotification = async (event: PushEvent) => { return; } + // The SW may have been restarted by the OS (iOS is aggressive about this), + // so in-memory settings would be at their defaults. Reload from the cache. + await loadPersistedSettings(); + const clients = await self.clients.matchAll({ type: 'window', includeUncontrolled: true }); const hasVisibleClient = clients.some((client) => client.visibilityState === 'visible'); if (hasVisibleClient && !preferPushOnMobile) { @@ -258,8 +305,16 @@ self.addEventListener('notificationclick', (event: NotificationEvent) => { (eventType === EventType.RoomMessage || eventType === EventType.RoomMessageEncrypted) && messageData?.room_id && messageData?.event_id - ) - targetUrl = `${scope}to/${messageData.room_id}/${messageData.event_id}`; + ) { + // Include the target user ID as ?uid= so ToRoomEvent can switch to the + // correct account before navigating. This covers client.navigate() on iOS + // Safari where postMessage is unreliable after focus(). + const uidParam = + typeof messageData?.user_id === 'string' + ? `?uid=${encodeURIComponent(messageData.user_id)}` + : ''; + targetUrl = `${scope}to/${messageData.room_id}/${messageData.event_id}${uidParam}`; + } if (eventType === EventType.RoomMember && messageData?.content?.membership === 'invite') targetUrl = `${scope}inbox/invites/`; @@ -272,13 +327,27 @@ self.addEventListener('notificationclick', (event: NotificationEvent) => { event.waitUntil( self.clients.matchAll({ type: 'window', includeUncontrolled: true }).then((clientList) => { - const focusedClient = clientList.find((client): client is WindowClient => 'focus' in client); + // Prefer a visible (foreground) tab; fall back to any open window client. + const focusedClient = + clientList.find((c) => c.visibilityState === 'visible') ?? + clientList.find((c): c is WindowClient => 'focus' in c); if (focusedClient) { - return focusedClient.focus().then(() => { - postMessageToClient(focusedClient); + return focusedClient.focus().then((wc) => { + // Prefer client.navigate() — draft API, available on Chrome/Chromium + // (all Android PWAs and desktop), unavailable on iOS Safari / Firefox. + const client = wc ?? focusedClient; + if ('navigate' in client && typeof (client as any).navigate === 'function') { + return (client as any).navigate(targetUrl); + } + // navigate() unavailable: use postMessage. The existing client (whether + // it was in the foreground or just minimized) has a live JS context by + // the time focus() resolves. HandleNotificationClick in the page will + // receive the message and dispatch the account-switch + deep link. + postMessageToClient(client); return null; }); } + // No existing client — open a new window. ToRoomEvent handles the route. if (self.clients.openWindow) { return self.clients.openWindow(targetUrl).then(() => null); } diff --git a/src/sw/pushNotification.ts b/src/sw/pushNotification.ts index 1459df547..b83d956fa 100644 --- a/src/sw/pushNotification.ts +++ b/src/sw/pushNotification.ts @@ -16,8 +16,11 @@ export const createPushNotifications = ( self: ServiceWorkerGlobalScope, getNotificationSettings: () => NotificationSettings ) => { - const resolveSilent = (silent: unknown): boolean => { + const resolveSilent = (silent: unknown, tweakSound?: unknown): boolean => { if (typeof silent === 'boolean') return silent; + // If the push rule doesn't request a sound tweak, the notification should be silent + // (no sound), regardless of the user's global sound preference. + if (!tweakSound) return true; return !getNotificationSettings().notificationSoundEnabled; }; @@ -29,14 +32,24 @@ export const createPushNotifications = ( icon?: string, badge?: string ) => { - await self.registration.showNotification(title, { + const roomId: string | undefined = data?.room_id; + // Group by room so new messages in the same room replace the previous + // notification rather than stacking individually. renotify: true ensures + // the user is still alerted when the existing tag is replaced. + const tag = roomId ? `room-${roomId}` : (data?.event_id ?? 'Cinny'); + const renotify = !!roomId; + // `renotify` is a valid Web API property absent from TypeScript's NotificationOptions type. + // Build the options object separately to avoid the excess-property check, then cast. + const notifOptions = { body, icon: icon ?? DEFAULT_NOTIFICATION_ICON, badge: badge ?? DEFAULT_NOTIFICATION_BADGE, - tag: data?.event_id ?? 'Cinny', + tag, + renotify, silent, data, - }); + }; + await self.registration.showNotification(title, notifOptions as NotificationOptions); }; const handleRoomMessageNotification = async (pushData: any) => { @@ -59,8 +72,9 @@ export const createPushNotifications = ( showMessageContent: getNotificationSettings().showMessageContent, showEncryptedMessageContent: getNotificationSettings().showEncryptedMessageContent, }), - silent: resolveSilent(pushData?.silent), + silent: resolveSilent(pushData?.silent, pushData?.tweaks?.sound), eventId: pushData?.event_id, + recipientId: typeof pushData?.user_id === 'string' ? pushData.user_id : undefined, data, }); await showNotificationWithData( @@ -93,8 +107,9 @@ export const createPushNotifications = ( showMessageContent: getNotificationSettings().showMessageContent, showEncryptedMessageContent: getNotificationSettings().showEncryptedMessageContent, }), - silent: resolveSilent(pushData?.silent), + silent: resolveSilent(pushData?.silent, pushData?.tweaks?.sound), eventId: pushData?.event_id, + recipientId: typeof pushData?.user_id === 'string' ? pushData.user_id : undefined, data, }); await showNotificationWithData( @@ -128,27 +143,6 @@ export const createPushNotifications = ( await showNotificationWithData('New Invitation', body, data, resolveSilent(pushData?.silent)); }; - const fallbackNotification = async (pushData: any) => { - const body = pushData?.content?.body; - let title; - if (body) { - title = pushData?.sender_display_name - ? `${pushData.sender_display_name}${pushData?.room_name ? ` in ${pushData.room_name}` : ''}` - : 'New Notification'; - } else { - title = 'You have a new Notification'; - } - const data = { - type: pushData?.type, - room_id: pushData?.room_id, - event_id: pushData?.event_id, - user_id: pushData?.user_id, - timestamp: Date.now(), - ...pushData.data, - }; - await showNotificationWithData(title, body, data, resolveSilent(pushData?.silent)); - }; - const handlePushNotificationPushData = async (pushData: any) => { const eventType = pushData?.type as EventType | undefined; if (!eventType) { @@ -158,19 +152,19 @@ export const createPushNotifications = ( switch (eventType) { case EventType.RoomMessage: case EventType.Sticker: - return handleRoomMessageNotification(pushData); + await handleRoomMessageNotification(pushData); + break; case EventType.RoomMessageEncrypted: - return handleEncryptedMessageNotification(pushData); + await handleEncryptedMessageNotification(pushData); + break; case EventType.RoomMember: if (!(pushData?.content?.membership === 'invite')) break; - return handleInvitationNotification(pushData); - + await handleInvitationNotification(pushData); + break; default: // no voip support in app anyway break; } - - return fallbackNotification(pushData); }; return { handlePushNotificationPushData }; diff --git a/vite.config.ts b/vite.config.ts index 2c2f1619a..ab5757c2c 100644 --- a/vite.config.ts +++ b/vite.config.ts @@ -12,6 +12,7 @@ import topLevelAwait from 'vite-plugin-top-level-await'; import { VitePWA } from 'vite-plugin-pwa'; import fs from 'fs'; import path from 'path'; +import { cloudflare } from '@cloudflare/vite-plugin'; import buildConfig from './build.config'; const packageJson = JSON.parse( @@ -56,10 +57,6 @@ const copyFiles = { dest: '', rename: 'pdf.worker.min.js', }, - { - src: 'netlify.toml', - dest: '', - }, { src: 'config.json', dest: '', @@ -166,6 +163,14 @@ export default defineConfig({ type: 'module', }, }), + cloudflare({ + config: { + compatibility_date: '2026-03-03', + assets: { + not_found_handling: 'single-page-application', + }, + }, + }), ], optimizeDeps: { // Rebuild dep optimizer cache on each dev start to avoid stale API shapes.