mirror of
https://github.com/vector-im/element-call.git
synced 2026-12-04 10:21:10 +08:00
Compare commits
70
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
4362f7ea89 | ||
|
|
38e9696d22 | ||
|
|
2cf05335af | ||
|
|
f73339199c | ||
|
|
9ba6a31996 | ||
|
|
0691a09dc5 | ||
|
|
090ff55b4a | ||
|
|
e4f816b1fc | ||
|
|
068d968aab | ||
|
|
9f67069451 | ||
|
|
90b48be6b4 | ||
|
|
8e8886b250 | ||
|
|
965e77be36 | ||
|
|
3818c34c3b | ||
|
|
b7374c4906 | ||
|
|
2100b93f5b | ||
|
|
a62d3f4dd9 | ||
|
|
6b9f8cef45 | ||
|
|
48d2639bb9 | ||
|
|
64994af0c8 | ||
|
|
07b6b6ecd6 | ||
|
|
3550e538ab | ||
|
|
86c2d75db4 | ||
|
|
77020cee2a | ||
|
|
464ffb136e | ||
|
|
e6d0e9ffe9 | ||
|
|
50acca9503 | ||
|
|
1b544b0734 | ||
|
|
96700aea6c | ||
|
|
77c7cdd174 | ||
|
|
ab8340e3c2 | ||
|
|
32e35fdfc8 | ||
|
|
6dede3a678 | ||
|
|
8ebf54159a | ||
|
|
60f5c90bb5 | ||
|
|
f2549a0e17 | ||
|
|
3f933c1077 | ||
|
|
2872857be6 | ||
|
|
6888727328 | ||
|
|
474b27d362 | ||
|
|
33ba54e8bd | ||
|
|
c682a9970c | ||
|
|
acd0fd524e | ||
|
|
36b0e41269 | ||
|
|
51e6baea17 | ||
|
|
3a9708020a | ||
|
|
6e6494fe38 | ||
|
|
d506c9828b | ||
|
|
3c81c131a2 | ||
|
|
3c67a5e54a | ||
|
|
4d7e0f9ec9 | ||
|
|
feab263fad | ||
|
|
aaf78518a3 | ||
|
|
6a6e26e049 | ||
|
|
ad8cadc99e | ||
|
|
1f810991df | ||
|
|
ff97bb8994 | ||
|
|
6fb2d6a7ae | ||
|
|
b3f2693086 | ||
|
|
6010acc3fc | ||
|
|
d16239be55 | ||
|
|
bf2714da2c | ||
|
|
dbf13dd2cf | ||
|
|
9545d3778a | ||
|
|
681427151e | ||
|
|
834504d062 | ||
|
|
78311547ce | ||
|
|
9606d25715 | ||
|
|
e2a5fd94ce | ||
|
|
0eff661159 |
@@ -1,22 +1,14 @@
|
||||
name: Prevent blocked
|
||||
on:
|
||||
# zizmor: ignore[dangerous-triggers]
|
||||
# Reason: This workflow does not checkout code or use secrets.
|
||||
# It only reads labels to set a failure status on the PR.
|
||||
pull_request_target:
|
||||
pull_request:
|
||||
types: [opened, labeled, unlabeled, synchronize]
|
||||
|
||||
permissions:
|
||||
pull-requests: read
|
||||
# Required to fail the check on the PR
|
||||
statuses: write
|
||||
permissions: {}
|
||||
|
||||
jobs:
|
||||
prevent-blocked:
|
||||
name: Prevent blocked
|
||||
runs-on: ubuntu-24.04
|
||||
permissions:
|
||||
pull-requests: read
|
||||
steps:
|
||||
- name: Add notice
|
||||
uses: actions/github-script@f28e40c7f34bde8b3046d885e986cb6290c5673b # v7
|
||||
|
||||
@@ -1,15 +1,10 @@
|
||||
name: PR changelog label
|
||||
|
||||
on:
|
||||
# zizmor: ignore[dangerous-triggers]
|
||||
# This is safe because we do not use actions/checkout or execute untrusted code.
|
||||
# Using pull_request_target is necessary to allow status writes for PRs from forks.
|
||||
pull_request_target:
|
||||
pull_request:
|
||||
types: [labeled, unlabeled, opened, synchronize]
|
||||
|
||||
permissions:
|
||||
pull-requests: read
|
||||
statuses: write
|
||||
permissions: {}
|
||||
|
||||
jobs:
|
||||
pr-changelog-label:
|
||||
|
||||
@@ -14,6 +14,8 @@ jobs:
|
||||
# Only run on labelling and skip forks.
|
||||
if: github.event.label.name == 'Claude-Review' && github.event.pull_request.head.repo.full_name == github.repository
|
||||
runs-on: ubuntu-24.04
|
||||
# The turn limit below is generous, so bound the job by time instead.
|
||||
timeout-minutes: 30
|
||||
steps:
|
||||
- name: Checkout code
|
||||
uses: actions/checkout@11d5960a326750d5838078e36cf38b85af677262 # v4.4.0
|
||||
@@ -98,7 +100,8 @@ jobs:
|
||||
|
||||
Use Markdown links for anything that can be navigated to on GitHub such
|
||||
as files, commits, issues, pull requests, workflow runs, etc.
|
||||
# Set a generous turn limit. It's bounded by timeout-minutes above.
|
||||
claude_args: |
|
||||
--model claude-fable-5-1
|
||||
--allowedTools "mcp__github_inline_comment__create_inline_comment,Bash(git log:*),Bash(git diff:*),Bash(git show:*)"
|
||||
--max-turns 50
|
||||
--max-turns 150
|
||||
|
||||
@@ -156,7 +156,9 @@ jobs:
|
||||
|
||||
publish_android:
|
||||
needs: [build_element_call, versioning]
|
||||
if: always()
|
||||
# Release candidates are not published to Maven Central: the organisation's Central account
|
||||
# has a monthly release quota, and Element X Android (the only consumer) ships final releases.
|
||||
if: always() && needs.versioning.outputs.TAG != 'rc'
|
||||
name: Publish Android AAR
|
||||
runs-on: ubuntu-24.04
|
||||
outputs:
|
||||
@@ -188,8 +190,6 @@ jobs:
|
||||
run: |
|
||||
if [[ "${NEEDS_VERSIONING_OUTPUTS_TAG}" == "latest" ]]; then
|
||||
echo "ARTIFACT_VERSION=${NEEDS_VERSIONING_OUTPUTS_UNPREFIXED_VERSION}" >> "$GITHUB_ENV"
|
||||
elif [[ "${NEEDS_VERSIONING_OUTPUTS_TAG}" == "rc" ]]; then
|
||||
echo "ARTIFACT_VERSION=${NEEDS_VERSIONING_OUTPUTS_UNPREFIXED_VERSION}" >> "$GITHUB_ENV"
|
||||
else
|
||||
echo "ARTIFACT_VERSION=${NEEDS_VERSIONING_OUTPUTS_UNPREFIXED_VERSION}-SNAPSHOT" >> "$GITHUB_ENV"
|
||||
fi
|
||||
@@ -338,11 +338,7 @@ jobs:
|
||||
|
||||
### Android AAR
|
||||
|
||||
```
|
||||
dependencies {
|
||||
implementation 'io.element.android:element-call-embedded:${{ needs.publish_android.outputs.ARTIFACT_VERSION }}'
|
||||
}
|
||||
```
|
||||
${{ needs.publish_android.outputs.ARTIFACT_VERSION && format('`implementation ''io.element.android:element-call-embedded:{0}''`', needs.publish_android.outputs.ARTIFACT_VERSION) || 'Not published: release candidates do not go to Maven Central.' }}
|
||||
|
||||
### SwiftPM
|
||||
|
||||
|
||||
Binary file not shown.
@@ -0,0 +1,41 @@
|
||||
/*
|
||||
Copyright 2026 Element Creations Ltd.
|
||||
|
||||
SPDX-License-Identifier: AGPL-3.0-only OR LicenseRef-Element-Commercial
|
||||
Please see LICENSE in the repository root for full details.
|
||||
*/
|
||||
|
||||
/**
|
||||
* The js-sdk for the component: the package's own entry points
|
||||
* (`lib/index.js`, `lib/browser-index.js`) throw when the host's copy has
|
||||
* already loaded one, and `browser-index` also writes the host's globals.
|
||||
* `lib/matrix` is the same API without either. The client this exports
|
||||
* refuses the few calls that would collide with the host's js-sdk: a sync
|
||||
* loop, crypto, and the IndexedDB stores both would open by the same name.
|
||||
*/
|
||||
|
||||
import { IndexedDBStore, MatrixClient } from "matrix-js-sdk/lib/matrix";
|
||||
|
||||
function refuse<C extends { prototype: object }>(
|
||||
cls: C,
|
||||
name: string,
|
||||
methods: (keyof C["prototype"] & string)[],
|
||||
): void {
|
||||
for (const method of methods)
|
||||
Object.defineProperty(cls.prototype, method, {
|
||||
value() {
|
||||
throw new Error(
|
||||
`${name}.${method} is not available in the Element Call component: the host's client does this`,
|
||||
);
|
||||
},
|
||||
});
|
||||
}
|
||||
|
||||
refuse(MatrixClient, "MatrixClient", [
|
||||
"startClient",
|
||||
"initRustCrypto",
|
||||
"clearStores",
|
||||
]);
|
||||
refuse(IndexedDBStore, "IndexedDBStore", ["startup"]);
|
||||
|
||||
export * from "matrix-js-sdk/lib/matrix";
|
||||
@@ -34,14 +34,15 @@
|
||||
"./style.css": "./dist/element-call.css"
|
||||
},
|
||||
"sideEffects": [
|
||||
"*.css"
|
||||
"*.css",
|
||||
"./guestJsSdk.ts"
|
||||
],
|
||||
"scripts": {
|
||||
"prepare": "cd .. && pnpm install --frozen-lockfile && pnpm build:component"
|
||||
},
|
||||
"peerDependencies": {
|
||||
"@vector-im/compound-design-tokens": "^11.0.0",
|
||||
"@vector-im/compound-web": "^10.3.1",
|
||||
"@vector-im/compound-web": "^10.5.0",
|
||||
"react": "^19",
|
||||
"react-dom": "^19"
|
||||
}
|
||||
|
||||
@@ -19,10 +19,10 @@ services:
|
||||
- ./backend/playwright_homeserver-othersite.yaml:/data/cfg/homeserver.yaml:Z
|
||||
element-web:
|
||||
# Pin to a SHA so that upstream cannot break our tests. Renovate handles regular updates.
|
||||
image: ghcr.io/element-hq/element-web:develop@sha256:9ed1f2140ce855b8e599bf4b16f9be47c3295738989574efbb0b8f0e159c5de7
|
||||
image: ghcr.io/element-hq/element-web:develop@sha256:a9fba6e7ea9a32f62bc1459fcdad790662476ff1b2bcebc62fe47e5cf51e3932
|
||||
element-web-1:
|
||||
# Pin to a SHA so that upstream cannot break our tests. Renovate handles regular updates.
|
||||
image: ghcr.io/element-hq/element-web:develop@sha256:9ed1f2140ce855b8e599bf4b16f9be47c3295738989574efbb0b8f0e159c5de7
|
||||
image: ghcr.io/element-hq/element-web:develop@sha256:a9fba6e7ea9a32f62bc1459fcdad790662476ff1b2bcebc62fe47e5cf51e3932
|
||||
volumes:
|
||||
# The other site opens the embedded package under test in place of the
|
||||
# copy its image bundles (the first site opens the dev server's app.
|
||||
|
||||
+25
-25
@@ -46,31 +46,31 @@ possible to support encryption.
|
||||
|
||||
These parameters are relevant to both [widget](./embedded_standalone.md) and [standalone](./embedded_standalone.md) modes:
|
||||
|
||||
| Name | Values | Required for widget | Required for SPA | Description |
|
||||
| ---------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------ | ------------------------------------------------------------------------------------------------- | ---------------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
|
||||
| `intent` | `start_call`, `join_existing`, `start_call_voice`, `join_existing_voice`, `start_call_dm`, `join_existing_dm`, `start_call_dm_voice`, or `join_existing_dm_voice`. | No, defaults to `start_call` | No, defaults to `start_call` | The intent is a special url parameter that defines the defaults for all the other parameters. In most cases it should be enough to only set the intent to setup element-call. |
|
||||
| `allowIceFallback` | `true` or `false` | No, defaults to `false` | No, defaults to `false` | Allows use of fallback STUN servers for ICE if the user's homeserver doesn’t provide any. |
|
||||
| `posthogUserId` | Posthog analytics ID | No | No | Available only with user's consent for sharing telemetry in Element Web. |
|
||||
| `confineToRoom` | `true` or `false` | No, defaults to `false` | No, defaults to `false` | Keeps the user confined to the current call/room. |
|
||||
| `displayName` | | No | No | Display name used for auto-registration. |
|
||||
| `enableE2EE` (deprecated) | `true` or `false` | No, defaults to `true` | No, defaults to `true` | Legacy flag to enable end-to-end encryption, not used in the `livekit` branch. |
|
||||
| `fontScale` | A decimal number such as `0.9` | No, defaults to `1.0` | No, defaults to `1.0` | Factor by which to scale the interface's font size. |
|
||||
| `fonts` | | No | No | Defines the font(s) used by the interface. Multiple font parameters can be specified: `?font=font-one&font=font-two...`. |
|
||||
| `header` | `none`, `standard` or `app_bar` | No, defaults to `standard` | No, defaults to `standard` | The style of headers to show. `standard` is the default arrangement, `none` hides the header entirely, and `app_bar` produces a header with a back button like you might see in mobile apps. The callback for the back button is `window.controls.onBackButtonPressed`. |
|
||||
| `hideScreensharing` | `true` or `false` | No, defaults to `false` | No, defaults to `false` | Hides the screen-sharing button. |
|
||||
| `homeserver` | | Not applicable | No | Homeserver for registering a new (guest) user, configures non-default guest user server when creating a spa link. |
|
||||
| `lang` | [BCP 47](https://www.rfc-editor.org/info/bcp47) code | No | No | The language the app should use. |
|
||||
| `password` | | No | No | E2EE password when using a shared secret. (For individual sender keys in embedded mode this is not required.) |
|
||||
| `controlledAudioDevices` | `true` or `false` | No, defaults to `false` | No, defaults to `false` | Whether the [global JS controls for audio devices](./controls.md#audio-devices) should be enabled, allowing the list of audio devices to be controlled by the app hosting Element Call. |
|
||||
| `roomId` | [Matrix Room ID](https://spec.matrix.org/v1.12/appendices/#room-ids) | Yes | No | Anything about what room we're pointed to should be from useRoomIdentifier which parses the path and resolves alias with respect to the default server name, however roomId is an exception as we need the room ID in embedded widget mode, and not the room alias (or even the via params because we are not trying to join it). This is also not validated, where it is in `useRoomIdentifier()`. |
|
||||
| `showControls` | `true` or `false` | No, defaults to `true` | No, defaults to `true` | Displays controls like mute, screen-share, invite, and hangup buttons during a call. |
|
||||
| `skipLobby` (deprecated: use `intent` instead) | `true` or `false` | No. If `intent` is explicitly `start_call` then defaults to `true`. Otherwise defaults to `false` | No, defaults to `false` | Skips the lobby to join a call directly, can be combined with preload in widget. When `true` the audio and video inputs will be muted by default. (This means there currently is no way to start without muted video if one wants to skip the lobby. Also not in widget mode.) |
|
||||
| `theme` | One of: `light`, `dark`, `light-high-contrast`, `dark-high-contrast` | No, defaults to `dark` | No, defaults to `dark` | UI theme to use. |
|
||||
| `background` | One of: `solid`, `gradient` | No, defaults to `gradient` | No, defaults to `gradient` | Visual style of the page background. |
|
||||
| `viaServers` | Comma separated list of [Matrix Server Names](https://spec.matrix.org/v1.12/appendices/#server-name) | Not applicable | No | Homeserver for joining a room, non-empty value required for rooms not on the user’s default homeserver. |
|
||||
| `sendNotificationType` | `ring` or `notification` | No | No | Will send a "ring" or "notification" `m.rtc.notification` event if the user is the first one in the call. |
|
||||
| `autoLeave` | `true` or `false` | No, defaults to `false` | No, defaults to `false` | Whether the app should automatically leave the call when there is no one left in the call. |
|
||||
| `waitForCallPickup` | `true` or `false` | No, defaults to `false` | No, defaults to `false` | When sending a notification, show UI that the app is awaiting an answer, play a dial tone, and (in widget mode) auto-close the widget once the notification expires. |
|
||||
| Name | Values | Required for widget | Required for SPA | Description |
|
||||
| ---------------------------------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------- | ---------------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
|
||||
| `intent` | `start_call`, `join_existing`, `start_call_voice`, `join_existing_voice`, `start_call_dm`, `join_existing_dm`, `start_call_dm_voice`, `join_existing_dm_voice`, or `video_room`. | No, defaults to `start_call` | No, defaults to `start_call` | The intent is a special url parameter that defines the defaults for all the other parameters. In most cases it should be enough to only set the intent to setup element-call. |
|
||||
| `allowIceFallback` | `true` or `false` | No, defaults to `false` | No, defaults to `false` | Allows use of fallback STUN servers for ICE if the user's homeserver doesn’t provide any. |
|
||||
| `posthogUserId` | Posthog analytics ID | No | No | Available only with user's consent for sharing telemetry in Element Web. |
|
||||
| `confineToRoom` | `true` or `false` | No, defaults to `false` | No, defaults to `false` | Keeps the user confined to the current call/room. |
|
||||
| `displayName` | | No | No | Display name used for auto-registration. |
|
||||
| `enableE2EE` (deprecated) | `true` or `false` | No, defaults to `true` | No, defaults to `true` | Legacy flag to enable end-to-end encryption, not used in the `livekit` branch. |
|
||||
| `fontScale` | A decimal number such as `0.9` | No, defaults to `1.0` | No, defaults to `1.0` | Factor by which to scale the interface's font size. |
|
||||
| `fonts` | | No | No | Defines the font(s) used by the interface. Multiple font parameters can be specified: `?font=font-one&font=font-two...`. |
|
||||
| `header` | `none`, `standard` or `app_bar` | No, defaults to `standard` | No, defaults to `standard` | The style of headers to show. `standard` is the default arrangement, `none` hides the header entirely, and `app_bar` produces a header with a back button like you might see in mobile apps. The callback for the back button is `window.controls.onBackButtonPressed`. |
|
||||
| `hideScreensharing` | `true` or `false` | No, defaults to `false` | No, defaults to `false` | Hides the screen-sharing button. |
|
||||
| `homeserver` | | Not applicable | No | Homeserver for registering a new (guest) user, configures non-default guest user server when creating a spa link. |
|
||||
| `lang` | [BCP 47](https://www.rfc-editor.org/info/bcp47) code | No | No | The language the app should use. |
|
||||
| `password` | | No | No | E2EE password when using a shared secret. (For individual sender keys in embedded mode this is not required.) |
|
||||
| `controlledAudioDevices` | `true` or `false` | No, defaults to `false` | No, defaults to `false` | Whether the [global JS controls for audio devices](./controls.md#audio-devices) should be enabled, allowing the list of audio devices to be controlled by the app hosting Element Call. |
|
||||
| `roomId` | [Matrix Room ID](https://spec.matrix.org/v1.12/appendices/#room-ids) | Yes | No | Anything about what room we're pointed to should be from useRoomIdentifier which parses the path and resolves alias with respect to the default server name, however roomId is an exception as we need the room ID in embedded widget mode, and not the room alias (or even the via params because we are not trying to join it). This is also not validated, where it is in `useRoomIdentifier()`. |
|
||||
| `showControls` | `true` or `false` | No, defaults to `true` | No, defaults to `true` | Displays controls like mute, screen-share, invite, and hangup buttons during a call. |
|
||||
| `skipLobby` (deprecated: use `intent` instead) | `true` or `false` | No. If `intent` is explicitly `start_call` then defaults to `true`. Otherwise defaults to `false` | No, defaults to `false` | Skips the lobby to join a call directly, can be combined with preload in widget. When `true` the audio and video inputs will be muted by default. (This means there currently is no way to start without muted video if one wants to skip the lobby. Also not in widget mode.) |
|
||||
| `theme` | One of: `light`, `dark`, `light-high-contrast`, `dark-high-contrast` | No, defaults to `dark` | No, defaults to `dark` | UI theme to use. |
|
||||
| `background` | One of: `solid`, `gradient` | No, defaults to `gradient` | No, defaults to `gradient` | Visual style of the page background. |
|
||||
| `viaServers` | Comma separated list of [Matrix Server Names](https://spec.matrix.org/v1.12/appendices/#server-name) | Not applicable | No | Homeserver for joining a room, non-empty value required for rooms not on the user’s default homeserver. |
|
||||
| `sendNotificationType` | `ring` or `notification` | No | No | Will send a "ring" or "notification" `m.rtc.notification` event if the user is the first one in the call. |
|
||||
| `autoLeave` | `true` or `false` | No, defaults to `false` | No, defaults to `false` | Whether the app should automatically leave the call when there is no one left in the call. |
|
||||
| `waitForCallPickup` | `true` or `false` | No, defaults to `false` | No, defaults to `false` | When sending a notification, show UI that the app is awaiting an answer, play a dial tone, and (in widget mode) auto-close the widget once the notification expires. |
|
||||
|
||||
### Widget-only parameters
|
||||
|
||||
|
||||
+1
-1
@@ -4,6 +4,7 @@
|
||||
},
|
||||
"action": {
|
||||
"add_background_image": "Add image",
|
||||
"adjust_view": "Adjust view",
|
||||
"close": "Close",
|
||||
"copy_link": "Copy link",
|
||||
"edit": "Edit",
|
||||
@@ -158,7 +159,6 @@
|
||||
},
|
||||
"layout_grid_label": "Grid",
|
||||
"layout_spotlight_label": "Spotlight",
|
||||
"layout_switch_label": "Layout",
|
||||
"lobby": {
|
||||
"ask_to_join": "Request to join call",
|
||||
"join_as_guest": "Join as guest",
|
||||
|
||||
+7
-6
@@ -39,8 +39,8 @@
|
||||
"lint:knip": "knip",
|
||||
"lint:externals": "node scripts/check-component-externals.mjs",
|
||||
"lint:types": "tsc",
|
||||
"i18n": "npx i18next-cli extract",
|
||||
"i18n:check": "npx i18next-cli extract --ci",
|
||||
"i18n": "i18next-cli extract",
|
||||
"i18n:check": "i18next-cli extract --ci",
|
||||
"test": "vitest",
|
||||
"test:storybook": "vitest --project=storybook",
|
||||
"test:unit": "vitest --project=unit",
|
||||
@@ -55,6 +55,7 @@
|
||||
"build-storybook": "storybook build"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@base-ui/react": "^1.9.0",
|
||||
"@codecov/vite-plugin": "^2.0.0",
|
||||
"@fontsource/inconsolata": "^5.1.0",
|
||||
"@fontsource/inter": "^5.1.0",
|
||||
@@ -90,7 +91,7 @@
|
||||
"@typescript-eslint/utils": "^8.61.0",
|
||||
"@use-gesture/react": "^10.2.11",
|
||||
"@vector-im/compound-design-tokens": "^11.0.0",
|
||||
"@vector-im/compound-web": "^10.5.0",
|
||||
"@vector-im/compound-web": "^10.8.0",
|
||||
"@vitejs/plugin-react": "^6.0.2",
|
||||
"@vitest/browser-playwright": "^4.1.5",
|
||||
"@vitest/coverage-v8": "^4.0.18",
|
||||
@@ -105,16 +106,16 @@
|
||||
"i18next": "^26.0.0",
|
||||
"i18next-browser-languagedetector": "^8.0.0",
|
||||
"i18next-cli": "^1.61.0",
|
||||
"jsdom": "^26.0.0",
|
||||
"jsdom": "^31.0.0",
|
||||
"knip": "^5.86.0",
|
||||
"livekit-client": "^2.18.1",
|
||||
"lodash-es": "^4.17.21",
|
||||
"loglevel": "^1.9.1",
|
||||
"matrix-js-sdk": "github:matrix-org/matrix-js-sdk#6c8b1b418189919bc69fd9df5e57354e7b3c39cb",
|
||||
"matrix-js-sdk": "github:matrix-org/matrix-js-sdk#aa1a8db0689465a8549546aea4c6cf1e696d6e44",
|
||||
"matrix-widget-api": "^1.18.0",
|
||||
"node-stdlib-browser": "^1.3.1",
|
||||
"normalize.css": "^8.0.1",
|
||||
"oxfmt": "^0.79.0",
|
||||
"oxfmt": "^0.80.0",
|
||||
"oxlint": "^1.70.0",
|
||||
"oxlint-tsgolint": "^0.25.0",
|
||||
"pako": "^3.0.3",
|
||||
|
||||
+10
-3
@@ -27,10 +27,17 @@ process.env.NODE_EXTRA_CA_CERTS = join(
|
||||
"backend/dev_tls_local-ca.crt",
|
||||
);
|
||||
|
||||
const commonDeviceOptions = {
|
||||
// Disabling motion-based animations helps Playwright position the cursor
|
||||
// correctly when clicking on menus etc.
|
||||
reducedMotion: "reduce" as const,
|
||||
ignoreHTTPSErrors: true,
|
||||
};
|
||||
|
||||
const desktopChrome = {
|
||||
...devices["Desktop Chrome"],
|
||||
...commonDeviceOptions,
|
||||
permissions: ["clipboard-write", "clipboard-read", "microphone", "camera"],
|
||||
ignoreHTTPSErrors: true,
|
||||
launchOptions: {
|
||||
args: [
|
||||
"--use-fake-ui-for-media-stream",
|
||||
@@ -116,7 +123,7 @@ export default defineConfig({
|
||||
testIgnore: ["**/mobile/**", "**/widget/widget-rtc-sdk.spec.ts"],
|
||||
use: {
|
||||
...devices["Desktop Firefox"],
|
||||
ignoreHTTPSErrors: true,
|
||||
...commonDeviceOptions,
|
||||
launchOptions: {
|
||||
firefoxUserPrefs: {
|
||||
"permissions.default.microphone": 1,
|
||||
@@ -140,7 +147,7 @@ export default defineConfig({
|
||||
testMatch: "**/mobile/**",
|
||||
use: {
|
||||
...devices["Pixel 7"],
|
||||
ignoreHTTPSErrors: true,
|
||||
...commonDeviceOptions,
|
||||
permissions: [
|
||||
"clipboard-write",
|
||||
"clipboard-read",
|
||||
|
||||
@@ -62,8 +62,7 @@ test("Sign up a new account, then login, then logout", async ({ browser }) => {
|
||||
test("As a guest, create a call, share link and other join", async ({
|
||||
browser,
|
||||
}) => {
|
||||
// Use reduce motion to disable animations that are making the tests a bit flaky
|
||||
const creatorContext = await browser.newContext({ reducedMotion: "reduce" });
|
||||
const creatorContext = await browser.newContext();
|
||||
const creatorPage = await creatorContext.newPage();
|
||||
|
||||
await creatorPage.goto("/");
|
||||
@@ -76,7 +75,8 @@ test("As a guest, create a call, share link and other join", async ({
|
||||
// join
|
||||
await creatorPage.getByTestId("lobby_joinCall").click();
|
||||
// Spotlight mode to make checking the test visually clearer
|
||||
await creatorPage.getByRole("radio", { name: "Spotlight" }).check();
|
||||
await creatorPage.getByRole("button", { name: "Adjust view" }).click();
|
||||
await creatorPage.getByRole("menuitemradio", { name: "Spotlight" }).click();
|
||||
|
||||
// Get the invite link
|
||||
const inviteLink = await SpaHelpers.getCallInviteLink(creatorPage);
|
||||
@@ -84,9 +84,7 @@ test("As a guest, create a call, share link and other join", async ({
|
||||
// ========
|
||||
// ACT: The other user use the invite link to join the call as a guest
|
||||
// ========
|
||||
const guestInviteeContext = await browser.newContext({
|
||||
reducedMotion: "reduce",
|
||||
});
|
||||
const guestInviteeContext = await browser.newContext();
|
||||
const guestPage = await guestInviteeContext.newPage();
|
||||
await SpaHelpers.joinCallFromInviteLink(guestPage, inviteLink);
|
||||
|
||||
|
||||
@@ -50,13 +50,13 @@ test.describe("the quick audio menu", () => {
|
||||
}) => {
|
||||
// Two browsers and a real call.
|
||||
test.slow();
|
||||
const hostContext = await browser.newContext({ reducedMotion: "reduce" });
|
||||
const hostContext = await browser.newContext();
|
||||
const host = await hostContext.newPage();
|
||||
await installFakeDevices(host, { microphones: 3, speakers: 3 });
|
||||
await joinACall(host, "Host", "Device switch");
|
||||
|
||||
const inviteLink = await SpaHelpers.getCallInviteLink(host);
|
||||
const guestContext = await browser.newContext({ reducedMotion: "reduce" });
|
||||
const guestContext = await browser.newContext();
|
||||
const guest = await guestContext.newPage();
|
||||
await SpaHelpers.joinCallFromInviteLink(guest, inviteLink, "Guest");
|
||||
await SpaHelpers.expectVideoTilesCount(guest, 2);
|
||||
@@ -85,13 +85,13 @@ test.describe("the quick audio menu", () => {
|
||||
}) => {
|
||||
// Two browsers and a real call.
|
||||
test.slow();
|
||||
const hostContext = await browser.newContext({ reducedMotion: "reduce" });
|
||||
const hostContext = await browser.newContext();
|
||||
const host = await hostContext.newPage();
|
||||
await installFakeDevices(host);
|
||||
await joinACall(host, "Muted host", "Muted meter");
|
||||
|
||||
const inviteLink = await SpaHelpers.getCallInviteLink(host);
|
||||
const guestContext = await browser.newContext({ reducedMotion: "reduce" });
|
||||
const guestContext = await browser.newContext();
|
||||
const guest = await guestContext.newPage();
|
||||
await SpaHelpers.joinCallFromInviteLink(guest, inviteLink, "Listener");
|
||||
await SpaHelpers.expectVideoTilesCount(guest, 2);
|
||||
|
||||
@@ -30,15 +30,6 @@ import { SpaHelpers } from "../spa-helpers.ts";
|
||||
// are sized for that, so the tests have to be too
|
||||
test.describe.configure({ timeout: 180_000 });
|
||||
|
||||
/** The settings button, whichever of the two the footer is currently showing. */
|
||||
function settingsButton(pane: Locator): Locator {
|
||||
return pane
|
||||
.getByTestId("settings-bottom-left")
|
||||
.or(pane.getByTestId("settings-bottom-center"))
|
||||
.filter({ visible: true })
|
||||
.first();
|
||||
}
|
||||
|
||||
test("holds a call between two components on one page", async ({ page }) => {
|
||||
const { username, roomId } = await createUserAndRoom("twocomponents");
|
||||
const panes = await startHarness(page, username, roomId);
|
||||
@@ -81,7 +72,7 @@ test("keeps its modals inside the container it was given", async ({ page }) => {
|
||||
// rather than the container until it was made a containing block. The
|
||||
// settings dialog spilled over the host's interface; the reaction picker sat
|
||||
// at 82vh, which put it below the container entirely and so out of sight.
|
||||
await settingsButton(pane).click();
|
||||
await pane.getByTestId("settings-bottom").click();
|
||||
await expectWithin(pane.getByRole("dialog"), container);
|
||||
await pane.getByTestId("modal_close").click();
|
||||
|
||||
@@ -112,7 +103,8 @@ test("keeps the call inside the container, wherever the host put it", async ({
|
||||
// the container below a header of its own, so a grid offset measured from
|
||||
// the top of the page instead of from the root would land the tile on top of
|
||||
// the footer and out of the bottom of the container.
|
||||
await pane.getByRole("radio", { name: "Spotlight" }).check();
|
||||
await pane.getByRole("button", { name: "Adjust view" }).click();
|
||||
await page.getByRole("menuitemradio", { name: "Spotlight" }).click();
|
||||
const tile = pane.getByTestId("videoTile").first();
|
||||
await expect(tile).toBeVisible({ timeout: 60_000 });
|
||||
await expectWithin(tile, container);
|
||||
|
||||
@@ -30,7 +30,7 @@ export const mobileTest = test.extend<MobileCreateFixtures>({
|
||||
async function createCallAndInvite(
|
||||
browser: Browser,
|
||||
): Promise<{ page: Page; inviteLink: string }> {
|
||||
const creatorContext = await browser.newContext({ reducedMotion: "reduce" });
|
||||
const creatorContext = await browser.newContext();
|
||||
const creatorPage = await creatorContext.newPage();
|
||||
|
||||
await creatorPage.goto("/");
|
||||
|
||||
@@ -58,9 +58,7 @@ mobileTest(
|
||||
// ========
|
||||
// ACT: The other user use the invite link to join the call as a guest
|
||||
// ========
|
||||
const guestInviteeContext = await browser.newContext({
|
||||
reducedMotion: "reduce",
|
||||
});
|
||||
const guestInviteeContext = await browser.newContext();
|
||||
const guestPage = await guestInviteeContext.newPage();
|
||||
await guestPage.goto(inviteLink + "&controlledAudioDevices=true");
|
||||
|
||||
|
||||
@@ -12,8 +12,7 @@ test("When creator left, avoid reconnect to the same SFU", async ({
|
||||
browserName,
|
||||
}) => {
|
||||
test.skip(browserName === "firefox", "Browser independent");
|
||||
// Use reduce motion to disable animations that are making the tests a bit flaky
|
||||
const creatorContext = await browser.newContext({ reducedMotion: "reduce" });
|
||||
const creatorContext = await browser.newContext();
|
||||
const creatorPage = await creatorContext.newPage();
|
||||
|
||||
await creatorPage.goto("/");
|
||||
@@ -31,7 +30,8 @@ test("When creator left, avoid reconnect to the same SFU", async ({
|
||||
// join
|
||||
await creatorPage.getByTestId("lobby_joinCall").click();
|
||||
// Spotlight mode to make checking the test visually clearer
|
||||
await creatorPage.getByRole("radio", { name: "Spotlight" }).check();
|
||||
await creatorPage.getByRole("button", { name: "Adjust view" }).click();
|
||||
await creatorPage.getByRole("menuitemradio", { name: "Spotlight" }).click();
|
||||
|
||||
// Get the invite link
|
||||
await creatorPage.getByRole("button", { name: "Invite" }).click();
|
||||
@@ -51,9 +51,7 @@ test("When creator left, avoid reconnect to the same SFU", async ({
|
||||
// ========
|
||||
// ACT: The other user use the invite link to join the call as a guest
|
||||
// ========
|
||||
const guestB = await browser.newContext({
|
||||
reducedMotion: "reduce",
|
||||
});
|
||||
const guestB = await browser.newContext();
|
||||
const guestBPage = await guestB.newPage();
|
||||
|
||||
await guestBPage.goto(inviteLink);
|
||||
@@ -61,14 +59,13 @@ test("When creator left, avoid reconnect to the same SFU", async ({
|
||||
await expect(guestBPage.getByTestId("joincall_joincall")).toBeVisible();
|
||||
await guestBPage.getByTestId("joincall_joincall").click();
|
||||
await guestBPage.getByTestId("lobby_joinCall").click();
|
||||
await guestBPage.getByRole("radio", { name: "Spotlight" }).check();
|
||||
await guestBPage.getByRole("button", { name: "Adjust view" }).click();
|
||||
await guestBPage.getByRole("menuitemradio", { name: "Spotlight" }).click();
|
||||
|
||||
// ========
|
||||
// ACT: add a third user to the call to reproduce the bug
|
||||
// ========
|
||||
const guestC = await browser.newContext({
|
||||
reducedMotion: "reduce",
|
||||
});
|
||||
const guestC = await browser.newContext();
|
||||
const guestCPage = await guestC.newPage();
|
||||
// Track WebSocket connections
|
||||
let wsConnectionCount = 0;
|
||||
@@ -85,7 +82,8 @@ test("When creator left, avoid reconnect to the same SFU", async ({
|
||||
await expect(guestCPage.getByTestId("joincall_joincall")).toBeVisible();
|
||||
await guestCPage.getByTestId("joincall_joincall").click();
|
||||
await guestCPage.getByTestId("lobby_joinCall").click();
|
||||
await guestCPage.getByRole("radio", { name: "Spotlight" }).check();
|
||||
await guestCPage.getByRole("button", { name: "Adjust view" }).click();
|
||||
await guestCPage.getByRole("menuitemradio", { name: "Spotlight" }).click();
|
||||
|
||||
await guestCPage.waitForTimeout(1000);
|
||||
if (wsConnectionCount === 2) {
|
||||
|
||||
@@ -33,7 +33,7 @@ async function setupTwoUserSpaCall(
|
||||
await interceptEventSend(
|
||||
page,
|
||||
// This room is not encrypted, so the event is sent in clear
|
||||
"org.matrix.msc4143.rtc.member",
|
||||
"m.rtc.member",
|
||||
(req) => {
|
||||
androlHasSentStickyEvent =
|
||||
androlHasSentStickyEvent || isStickySend(req.url());
|
||||
@@ -46,9 +46,7 @@ async function setupTwoUserSpaCall(
|
||||
const inviteLink = await SpaHelpers.getCallInviteLink(page);
|
||||
|
||||
// Other
|
||||
const guestInviteeContext = await browser.newContext({
|
||||
reducedMotion: "reduce",
|
||||
});
|
||||
const guestInviteeContext = await browser.newContext();
|
||||
const guestPage = await guestInviteeContext.newPage();
|
||||
|
||||
await guestPage.goto("/");
|
||||
@@ -62,7 +60,7 @@ async function setupTwoUserSpaCall(
|
||||
await interceptEventSend(
|
||||
guestPage,
|
||||
// This room is not encrypted, so the event is sent in clear
|
||||
"org.matrix.msc4143.rtc.member",
|
||||
"m.rtc.member",
|
||||
(req) => {
|
||||
pevaraHasSentStickyEvent =
|
||||
pevaraHasSentStickyEvent || isStickySend(req.url());
|
||||
|
||||
@@ -88,7 +88,8 @@ async function joinCallFromInviteLink(
|
||||
}
|
||||
|
||||
await page.getByTestId("lobby_joinCall").click();
|
||||
await page.getByRole("radio", { name: "Spotlight" }).check();
|
||||
await page.getByRole("button", { name: "Adjust view" }).click();
|
||||
await page.getByRole("menuitemradio", { name: "Spotlight" }).click();
|
||||
}
|
||||
|
||||
async function setRtcModeFromSettings(
|
||||
|
||||
@@ -58,20 +58,20 @@ const cases: {
|
||||
guestFlows: ["cs-api"],
|
||||
},
|
||||
{
|
||||
// Publishers keep the legacy participant identity that clients predating
|
||||
// MSC4195 expect, which only the JWT service assigns.
|
||||
// The client-server API is preferred wherever a transport names a url.
|
||||
// Clients since 0.28.1 match such a publisher by either identity.
|
||||
hostShape: "url+legacy",
|
||||
guestShape: "url+legacy",
|
||||
hostFlows: ["service-legacy"],
|
||||
guestFlows: ["service-legacy"],
|
||||
hostFlows: ["cs-api"],
|
||||
guestFlows: ["cs-api"],
|
||||
},
|
||||
{
|
||||
// The MatrixRTC mode has no bearing on the choice.
|
||||
hostShape: "url+legacy",
|
||||
guestShape: "url+legacy",
|
||||
mode: "2_0",
|
||||
hostFlows: ["service-legacy"],
|
||||
guestFlows: ["service-legacy"],
|
||||
hostFlows: ["cs-api"],
|
||||
guestFlows: ["cs-api"],
|
||||
},
|
||||
{
|
||||
hostShape: "url",
|
||||
@@ -80,10 +80,12 @@ const cases: {
|
||||
guestFlows: ["service-legacy", "cs-api"],
|
||||
},
|
||||
{
|
||||
// Both reach the SFU through the client-server API, under one identity
|
||||
// each, so one connection serves the own and the other's transport.
|
||||
hostShape: "url",
|
||||
guestShape: "url+legacy",
|
||||
hostFlows: ["cs-api", "service-default"],
|
||||
guestFlows: ["service-legacy", "cs-api"],
|
||||
hostFlows: ["cs-api"],
|
||||
guestFlows: ["cs-api"],
|
||||
},
|
||||
];
|
||||
|
||||
@@ -103,7 +105,7 @@ for (const { hostShape, guestShape, mode, hostFlows, guestFlows } of cases) {
|
||||
const inviteLink = await SpaHelpers.getCallInviteLink(page);
|
||||
|
||||
// The guest joins.
|
||||
const guestContext = await browser.newContext({ reducedMotion: "reduce" });
|
||||
const guestContext = await browser.newContext();
|
||||
const guestPage = await guestContext.newPage();
|
||||
await advertiseTransport(guestPage, shapes[guestShape]);
|
||||
const guestRequests = recordAuthRequests(guestPage);
|
||||
@@ -160,6 +162,53 @@ test("Publisher shows an error when the homeserver lacks MSC4195", async ({
|
||||
).toBeVisible();
|
||||
});
|
||||
|
||||
test("Falls back to the JWT service for a url+legacy transport when the homeserver lacks MSC4195", async ({
|
||||
browser,
|
||||
page,
|
||||
browserName,
|
||||
}) => {
|
||||
skipOnFirefox(browserName);
|
||||
|
||||
// The host starts the call; its C-S requests fail.
|
||||
await advertiseTransport(page, shapes["url+legacy"]);
|
||||
await rejectCsApiTokens(page);
|
||||
const hostRequests = recordAuthRequests(page);
|
||||
await page.goto("/");
|
||||
await SpaHelpers.createCall(page, "Androl", "HelloCall", true);
|
||||
const inviteLink = await SpaHelpers.getCallInviteLink(page);
|
||||
|
||||
// The guest joins, and its C-S requests fail as well.
|
||||
const guestContext = await browser.newContext();
|
||||
const guestPage = await guestContext.newPage();
|
||||
await advertiseTransport(guestPage, shapes["url+legacy"]);
|
||||
await rejectCsApiTokens(guestPage);
|
||||
const guestRequests = recordAuthRequests(guestPage);
|
||||
await SpaHelpers.joinCallFromInviteLink(guestPage, inviteLink, "Pevara");
|
||||
|
||||
// The call connects all the same.
|
||||
await SpaHelpers.expectVideoTilesCount(page, 2);
|
||||
await SpaHelpers.expectVideoTilesCount(guestPage, 2);
|
||||
|
||||
for (const requests of [hostRequests, guestRequests]) {
|
||||
// Each published through the JWT service, under the legacy identity, and
|
||||
// subscribes to the other over that same connection.
|
||||
expect(flowsOf(requests)).toEqual(
|
||||
new Set<Flow>(["cs-api", "service-legacy"]),
|
||||
);
|
||||
// The homeserver is asked once. Nothing asks it again once the API is
|
||||
// known to be missing.
|
||||
expect(requests.filter(({ flow }) => flow === "cs-api")).toHaveLength(1);
|
||||
for (const request of requests) {
|
||||
if (request.flow === "cs-api") {
|
||||
expect(request.status).toBe(404);
|
||||
} else {
|
||||
expect(request.status).toBe(200);
|
||||
expect(request.identity).toMatch(legacyIdentity);
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
test("Group call with all possible transport shapes at once", async ({
|
||||
browser,
|
||||
page,
|
||||
@@ -175,13 +224,13 @@ test("Group call with all possible transport shapes at once", async ({
|
||||
const inviteLink = await SpaHelpers.getCallInviteLink(page);
|
||||
|
||||
// The guest with a legacy transport joins.
|
||||
const bobContext = await browser.newContext({ reducedMotion: "reduce" });
|
||||
const bobContext = await browser.newContext();
|
||||
const bobPage = await bobContext.newPage();
|
||||
await advertiseTransport(bobPage, shapes.legacy);
|
||||
await SpaHelpers.joinCallFromInviteLink(bobPage, inviteLink, "Bob");
|
||||
|
||||
// The guest with a url+legacy transport joins.
|
||||
const carolContext = await browser.newContext({ reducedMotion: "reduce" });
|
||||
const carolContext = await browser.newContext();
|
||||
const carolPage = await carolContext.newPage();
|
||||
await advertiseTransport(carolPage, shapes["url+legacy"]);
|
||||
await SpaHelpers.joinCallFromInviteLink(carolPage, inviteLink, "Carol");
|
||||
@@ -193,13 +242,12 @@ test("Group call with all possible transport shapes at once", async ({
|
||||
});
|
||||
|
||||
/**
|
||||
* Delegation follows the flow that authenticated the publisher: the homeserver
|
||||
* for a `url`-only transport, the JWT service wherever there is one.
|
||||
* Delegation follows the flow that authenticated the publisher.
|
||||
*/
|
||||
const delegationCases: { shape: Shape; via: Delegation["via"] }[] = [
|
||||
{ shape: "url", via: "homeserver" },
|
||||
{ shape: "legacy", via: "service" },
|
||||
{ shape: "url+legacy", via: "service" },
|
||||
{ shape: "url+legacy", via: "homeserver" },
|
||||
];
|
||||
|
||||
for (const { shape, via } of delegationCases) {
|
||||
@@ -217,7 +265,7 @@ for (const { shape, via } of delegationCases) {
|
||||
const inviteLink = await SpaHelpers.getCallInviteLink(page);
|
||||
|
||||
// The guest joins.
|
||||
const guestContext = await browser.newContext({ reducedMotion: "reduce" });
|
||||
const guestContext = await browser.newContext();
|
||||
const guestPage = await guestContext.newPage();
|
||||
await advertiseTransport(guestPage, shapes[shape]);
|
||||
const delayedLeave = recordDelayedLeave(guestPage);
|
||||
@@ -228,10 +276,10 @@ for (const { shape, via } of delegationCases) {
|
||||
await SpaHelpers.expectVideoTilesCount(page, 2);
|
||||
await SpaHelpers.expectVideoTilesCount(guestPage, 2);
|
||||
|
||||
// The guest handed its delayed leave over, after probing for delegation
|
||||
// support with bodiless requests, which count as supported unless they
|
||||
// 404. The homeserver is always probed; the JWT service only when there
|
||||
// is one.
|
||||
// The guest handed its delayed leave over. A JWT service is first probed
|
||||
// for delegation support with a bodiless request, which counts as
|
||||
// supported unless it 404s. A homeserver that issued the token is not
|
||||
// probed.
|
||||
await expect
|
||||
.poll(() => delegations.at(-1))
|
||||
.toEqual({
|
||||
@@ -241,7 +289,9 @@ for (const { shape, via } of delegationCases) {
|
||||
...(via === "homeserver" && { sfuUrl }),
|
||||
});
|
||||
const probes = delegations.slice(0, -1);
|
||||
expect(probes.some((probe) => probe.via === via)).toBe(true);
|
||||
expect(probes.map((probe) => probe.via)).toEqual(
|
||||
via === "service" ? ["service"] : [],
|
||||
);
|
||||
for (const probe of probes) {
|
||||
expect(probe.status).toBeGreaterThanOrEqual(400);
|
||||
expect(probe.status).not.toBe(404);
|
||||
@@ -277,7 +327,7 @@ test("Subscribers get tokens for a remote homeserver's SFU over federation", asy
|
||||
const inviteLink = await SpaHelpers.getCallInviteLink(page);
|
||||
|
||||
// The guest lives on the default homeserver and joins over federation.
|
||||
const guestContext = await browser.newContext({ reducedMotion: "reduce" });
|
||||
const guestContext = await browser.newContext();
|
||||
const guestPage = await guestContext.newPage();
|
||||
await advertiseTransport(guestPage, shapes.url);
|
||||
const guestRequests = recordAuthRequests(guestPage);
|
||||
|
||||
@@ -86,7 +86,11 @@ widgetTest("Sharing screen in group call", async ({ addUser, browserName }) => {
|
||||
const frame = alice.page
|
||||
.locator('iframe[title="Element Call"]')
|
||||
.contentFrame();
|
||||
await expect(frame.getByRole("radio", { name: "Grid" })).toBeChecked();
|
||||
await frame.getByRole("button", { name: "Adjust view" }).click();
|
||||
await expect(
|
||||
frame.getByRole("menuitemradio", { name: "Grid" }),
|
||||
).toBeChecked();
|
||||
await frame.getByRole("menu").press("Escape");
|
||||
}
|
||||
|
||||
// Others should have switched to spotlight
|
||||
@@ -95,7 +99,11 @@ widgetTest("Sharing screen in group call", async ({ addUser, browserName }) => {
|
||||
.locator('iframe[title="Element Call"]')
|
||||
.contentFrame();
|
||||
|
||||
await expect(frame.getByRole("radio", { name: "Spotlight" })).toBeChecked();
|
||||
await frame.getByRole("button", { name: "Adjust view" }).click();
|
||||
await expect(
|
||||
frame.getByRole("menuitemradio", { name: "Spotlight" }),
|
||||
).toBeChecked();
|
||||
await frame.getByRole("menu").press("Escape");
|
||||
}
|
||||
// await alice.page.pause();
|
||||
// await bob.page.pause();
|
||||
|
||||
@@ -123,9 +123,7 @@ export class TestHelpers {
|
||||
);
|
||||
|
||||
// STEP 2: Open browser and login
|
||||
const userContext = await browser.newContext({
|
||||
reducedMotion: "reduce",
|
||||
});
|
||||
const userContext = await browser.newContext();
|
||||
const page = await userContext.newPage();
|
||||
await page.goto(host);
|
||||
|
||||
|
||||
Generated
+959
-1008
File diff suppressed because it is too large
Load Diff
+2
-2
@@ -28,8 +28,8 @@ overrides:
|
||||
# - https://github.com/advisories/GHSA-7r86-cg39-jmmj
|
||||
# - https://github.com/advisories/GHSA-23c5-xmqv-rm74
|
||||
"minimatch": "^11.0.0"
|
||||
# Security fix: https://github.com/element-hq/element-call/security/dependabot/109
|
||||
"glob": "^10.5.0"
|
||||
# The v8 line is deprecated.
|
||||
"eslint": "^9.0.0"
|
||||
# Security fix: https://github.com/advisories/GHSA-6pq8-jhm2-2vcw
|
||||
"qs": ">=6.16.1"
|
||||
# Security fix: https://github.com/advisories/GHSA-2883-xcg3-v3hh
|
||||
|
||||
+4
-2
@@ -28,12 +28,14 @@
|
||||
{
|
||||
"groupName": "matrix-widget-api",
|
||||
"matchDepNames": ["matrix-widget-api"],
|
||||
"extends": ["schedule:weekly"]
|
||||
"extends": ["schedule:weekly"],
|
||||
"minimumReleaseAge": null
|
||||
},
|
||||
{
|
||||
"groupName": "Compound",
|
||||
"matchPackageNames": ["@vector-im/compound-{/,}**"],
|
||||
"extends": ["schedule:weekly"]
|
||||
"extends": ["schedule:weekly"],
|
||||
"minimumReleaseAge": null
|
||||
},
|
||||
{
|
||||
"groupName": "LiveKit client",
|
||||
|
||||
@@ -6,18 +6,18 @@ Please see LICENSE in the repository root for full details.
|
||||
*/
|
||||
|
||||
/**
|
||||
* Checks the component build's output for what a host must not be handed.
|
||||
* Checks the component build's output for things we do not want to end up in the
|
||||
* component target.
|
||||
*
|
||||
* A library build inlines every asset it meets as a data URL unless the import
|
||||
* says otherwise, and does so silently: one import without `no-inline` and the
|
||||
* module grows by the asset, encoded a third larger, that every host then
|
||||
* downloads and parses before the first call. MediaPipe's runtime alone is
|
||||
* 11 MB. A reference to a file by an absolute path is just as silent and
|
||||
* breaks at runtime instead, since a host serves the module from wherever it
|
||||
* likes. And the standalone app's client store worker, which carries a copy of
|
||||
* the Matrix SDK and its crypto, has no business in a package whose host
|
||||
* supplies the client: the bundler emits it on loading its import, used or
|
||||
* not (see src/utils/initClient.ts). This fails the build on each of those.
|
||||
* A library build inlines every asset it needs as a data URL unless the import
|
||||
* says otherwise: if one adds an import without `no-inline` the
|
||||
* module grows by the asset (due to encoding a third larger than the original file)
|
||||
* that every host then downloads and parses before the first call.
|
||||
* MediaPipe's runtime alone is 11 MB, so it should not be inlined.
|
||||
* The standalone app's client store worker, which carries a copy of the Matrix SDK
|
||||
* and its crypto, is also not needed in a package whose host supplies the client:
|
||||
* the bundler packages if it is imported, even if not used (see src/utils/initClient.ts).
|
||||
* The script makes sure, the build fails on each of those issues.
|
||||
*/
|
||||
|
||||
import { existsSync } from "node:fs";
|
||||
|
||||
+50
-24
@@ -120,10 +120,10 @@ LiveKit participants.
|
||||
The session discovers the transport from the homeserver and the backend prepares
|
||||
it, both before `join()`, so that the membership can name it and the first frames
|
||||
go out as soon as the state event is sent. Preparing is the backend's own
|
||||
business: for LiveKit the token exchange for the publisher connection, and the
|
||||
probe that decides whether the service that issued the token can take over the
|
||||
delayed leave, which picks the delayed leave timings the join uses. The join
|
||||
waits for the publisher to hold its token, so that the LiveKit room exists
|
||||
business: for LiveKit the token exchange for the publisher connection, and
|
||||
with it whether that service can take over the delayed leave (assumed for a homeserver,
|
||||
probed for a JWT service), which picks the delayed leave timings the join uses. The
|
||||
join waits for the publisher to hold its token, so that the LiveKit room exists
|
||||
before a subscriber, who lacks the permission to create it, asks for a token
|
||||
of its own. The tracks are created once the membership is `joined`, with their
|
||||
upstream paused until then. A lobby that wants them earlier captures them with
|
||||
@@ -588,32 +588,58 @@ without one, LiveKit is built from the LiveKit-flavoured client options.
|
||||
|
||||
A LiveKit transport comes in three shapes while MSC4195 settles: an SFU `url`,
|
||||
a JWT service `livekit_service_url`, or both. `media-backend/livekit/auth/`
|
||||
fronts the two flows and chooses between them per connection, from the shape
|
||||
and from the role we take on the transport:
|
||||
fronts the two flows and chooses between them from the shape, preferring the
|
||||
client-server API wherever the transport names a `url`:
|
||||
|
||||
| Transport | Publisher | Subscriber |
|
||||
| -------------------------- | ------------------------------------------ | ---------------------------------------------------------------------------------------------------------------------- |
|
||||
| `url` only | client-server API `get_token`, no fallback | client-server API `get_token`, no fallback |
|
||||
| `livekit_service_url` only | JWT service `/sfu/get` (legacy identity) | JWT service `/get_token` (hashed identity) |
|
||||
| both | JWT service `/sfu/get` (legacy identity) | client-server API, falling back to the JWT service `/get_token` where the homeserver, or a widget host, has no MSC4195 |
|
||||
| Transport | Publisher | Subscriber |
|
||||
| -------------------------- | ---------------------------------------------------------------- | ------------------------------------------------------------------ |
|
||||
| `url` only | client-server API `get_token`, no fallback | client-server API `get_token`, no fallback |
|
||||
| `livekit_service_url` only | JWT service `/sfu/get` (legacy identity) | JWT service `/get_token` (hashed identity) |
|
||||
| both | client-server API, else JWT service `/sfu/get` (legacy identity) | client-server API, else JWT service `/get_token` (hashed identity) |
|
||||
|
||||
A publisher on a transport with a service URL keeps the legacy
|
||||
`<user_id>:<device_id>` identity, because clients predating MSC4195 match a
|
||||
membership against that and nothing else; a subscriber is matched by nobody and
|
||||
takes the more private hashed identity. A publisher never falls back: a
|
||||
homeserver that advertises a `url` without implementing MSC4195 is misconfigured
|
||||
and fails with `NoMatrix2AuthorizationService`, so the admin hears about it.
|
||||
The MatrixRTC mode plays no part in the choice. The delayed leave is delegated
|
||||
through the same flow that issued the publisher's token, so that the identity
|
||||
the service watches for on the SFU is the one we publish under, and the
|
||||
delegation probe before the join asks only that service.
|
||||
A member whose transport names both is matched against either identity (since
|
||||
Element Call 0.28.1), so a publisher may take either flow. On the JWT service
|
||||
a publisher uses `/sfu/get`, the only endpoint that assigns the legacy
|
||||
`<user_id>:<device_id>` identity. A subscriber is matched by nobody and takes
|
||||
the hashed one.
|
||||
|
||||
The JWT service stands in only where our homeserver has no MSC4195 endpoints.
|
||||
A homeserver that has them advertises a `url`, so whether the API is usable is
|
||||
read off our own transport: `prepareLocalTransport` stores it with the local
|
||||
transport, and it is the one input, next to a transport's shape, to
|
||||
`chooseAuthFlow`. Where ours names only a JWT service, transports naming both
|
||||
go through that service from the start.
|
||||
|
||||
A homeserver may advertise a `url` and still lack the endpoints, as may a
|
||||
widget host. A token request is then answered with a 404, `M_NOT_FOUND` or
|
||||
`M_UNRECOGNIZED` (`isCsApiUnavailable`) and fails with
|
||||
`NoMatrix2AuthorizationService`, which the publisher connection reports to
|
||||
the backend before the error surfaces. Where our transport names a JWT service
|
||||
too, the backend stores the local transport again with the API ruled out; the
|
||||
failed connection is stopped with its map and never shows as an error. Only
|
||||
the publisher's request rules the API out: it is the first one made, and a
|
||||
subscriber's 404 once we publish through the API fails that connection alone.
|
||||
A transport with a `url` alone has no fallback and fails the join. The MatrixRTC mode
|
||||
plays no part in the choice.
|
||||
|
||||
A connection is created with its flow and keeps it for life. The delayed leave
|
||||
is delegated through the publisher connection's flow, the one that issued its
|
||||
token, so that the service watches for the identity we publish under. A
|
||||
homeserver that issued the token is assumed to delegate. Only a JWT service is
|
||||
probed, before the join.
|
||||
|
||||
The client-server API needs the name of the homeserver the transport belongs to:
|
||||
our own homeserver asks that server for the token, over federation where it is
|
||||
not ours. The backend derives it from the member's user id, and from our own for
|
||||
the local transport, and keys its connections on the transport plus the server
|
||||
name where the transport has a `url`. A JWT service is reached directly, so
|
||||
members of several homeservers advertising the same one share a connection.
|
||||
the local transport. A JWT service is reached directly, so members of several
|
||||
homeservers advertising the same one share a connection.
|
||||
|
||||
Connections are keyed on the flow and what it authenticates against: the `url`
|
||||
plus the server name for the client-server API, the service URL for the JWT
|
||||
service. Transports with the same key would get us the same identity on the
|
||||
same SFU, so they share a connection. A connection map is built per local
|
||||
transport, so whether the API is usable is fixed for the life of a map and of
|
||||
every key in it; ruling the API out replaces the map.
|
||||
|
||||
## Media: `tracks$` and `MediaTrack`
|
||||
|
||||
|
||||
+2
-2
@@ -75,6 +75,6 @@ export {
|
||||
} from "./src/media-backend/livekit/videoProcessor";
|
||||
// For a developer panel to check a transport before using it
|
||||
export {
|
||||
getSFUConfig as authenticateWithTransport,
|
||||
type GetSFUConfigParams as AuthenticateWithTransportParams,
|
||||
authenticateWithTransport,
|
||||
type AuthenticateWithTransportParams,
|
||||
} from "./src/media-backend/livekit/auth";
|
||||
|
||||
@@ -42,7 +42,11 @@ import {
|
||||
} from "./Connection.ts";
|
||||
import { ObservableScope } from "../../reactive/ObservableScope";
|
||||
import { type ClientGetTokenParts, type ClientOpenIDParts } from "./auth";
|
||||
import { LivekitConnectionError, MatrixRTCError } from "../../errors";
|
||||
import {
|
||||
LivekitConnectionError,
|
||||
MatrixRTCError,
|
||||
NoMatrix2AuthorizationService,
|
||||
} from "../../errors";
|
||||
import { testJWTToken } from "../../utils/test-fixtures";
|
||||
import { ownMemberMock } from "../../utils/test";
|
||||
import { mockRemoteParticipant } from "./test";
|
||||
@@ -63,15 +67,15 @@ const FIREFOX_USER_AGENT =
|
||||
const CHROME_USER_AGENT =
|
||||
"Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/141.0.0.0 Safari/537.36";
|
||||
|
||||
const transport: UnstableLivekitTransport = {
|
||||
type: "livekit",
|
||||
url: "wss://matrix-rtc.m.localhost/livekit/sfu",
|
||||
};
|
||||
const url = "wss://matrix-rtc.m.localhost/livekit/sfu";
|
||||
const transport: UnstableLivekitTransport = { type: "livekit", url };
|
||||
|
||||
/** The options of a subscriber connection to `transport`. */
|
||||
function connectionOpts(): ConnectionOpts {
|
||||
return {
|
||||
client,
|
||||
flow: { kind: "csApi", url },
|
||||
onCsApiMissing: vi.fn(),
|
||||
roomId: ROOM_ID,
|
||||
slotId: SLOT_ID,
|
||||
role: "subscriber",
|
||||
@@ -372,6 +376,7 @@ describe("Start connection states", () => {
|
||||
...connectionOpts(),
|
||||
role: "publisher",
|
||||
transport: { type: "livekit", livekit_service_url: serviceUrl },
|
||||
flow: { kind: "openID", serviceUrl },
|
||||
},
|
||||
logger,
|
||||
);
|
||||
@@ -387,6 +392,61 @@ describe("Start connection states", () => {
|
||||
expect(connection.livekitAlias).toBe("!example_room_id");
|
||||
});
|
||||
|
||||
it.each([
|
||||
["reports", "publisher", 1],
|
||||
// A 404 there, once we publish through the API, is not the API missing
|
||||
["does not report", "subscriber", 0],
|
||||
] as const)(
|
||||
"%s the CS API missing as a %s where the homeserver lacks the endpoint",
|
||||
async (_what, role, reports) => {
|
||||
setupTest();
|
||||
const opts = { ...connectionOpts(), role };
|
||||
client.getLivekitToken.mockRejectedValue(
|
||||
new MatrixError({ errcode: "M_UNRECOGNIZED" }, 404),
|
||||
);
|
||||
const connection = new Connection(opts, logger);
|
||||
|
||||
await expect(connection.start()).rejects.toThrow(
|
||||
expect.any(NoMatrix2AuthorizationService),
|
||||
);
|
||||
expect(opts.onCsApiMissing).toHaveBeenCalledTimes(reports);
|
||||
expect(connection.state$.value.state).toBe("error");
|
||||
},
|
||||
);
|
||||
|
||||
it("does not show as failed when reporting the CS API missing gets it stopped", async () => {
|
||||
setupTest();
|
||||
fakeLivekitRoom.disconnect.mockResolvedValue(undefined);
|
||||
client.getLivekitToken.mockRejectedValue(
|
||||
new MatrixError({ errcode: "M_UNRECOGNIZED" }, 404),
|
||||
);
|
||||
const connection: Connection = new Connection(
|
||||
{
|
||||
...connectionOpts(),
|
||||
role: "publisher",
|
||||
onCsApiMissing: () => void connection.stop(),
|
||||
},
|
||||
logger,
|
||||
);
|
||||
|
||||
await connection.start();
|
||||
await vi.waitFor(() =>
|
||||
expect(connection.state$.value).toEqual({ state: "stopped" }),
|
||||
);
|
||||
});
|
||||
|
||||
it("does not report the CS API missing where the homeserver refuses the request", async () => {
|
||||
setupTest();
|
||||
const opts = { ...connectionOpts(), role: "publisher" as const };
|
||||
client.getLivekitToken.mockRejectedValue(
|
||||
new MatrixError({ errcode: "M_FORBIDDEN" }, 403),
|
||||
);
|
||||
const connection = new Connection(opts, logger);
|
||||
|
||||
await expect(connection.start()).rejects.toThrow();
|
||||
expect(opts.onCsApiMissing).not.toHaveBeenCalled();
|
||||
});
|
||||
|
||||
it("retries a join that failed on the WebSocket in Firefox", async () => {
|
||||
setupTest();
|
||||
mockUserAgent(FIREFOX_USER_AGENT);
|
||||
|
||||
@@ -32,6 +32,7 @@ import { type CallMembershipIdentityParts } from "matrix-js-sdk/lib/matrixrtc/En
|
||||
import {
|
||||
type ClientGetTokenParts,
|
||||
type ClientOpenIDParts,
|
||||
type AuthFlow,
|
||||
type ConnectionRole,
|
||||
getSFUConfig,
|
||||
type SFUConfig,
|
||||
@@ -42,6 +43,7 @@ import {
|
||||
MatrixRTCError,
|
||||
InsufficientCapacityError,
|
||||
LivekitConnectionError,
|
||||
NoMatrix2AuthorizationService,
|
||||
PeerConnectionTimeoutError,
|
||||
SFURoomCreationRestrictedError,
|
||||
UnknownRTCError,
|
||||
@@ -58,6 +60,13 @@ export interface ConnectionOpts {
|
||||
serverName: string;
|
||||
/** The Matrix client, for the token exchange. */
|
||||
client: ClientGetTokenParts & ClientOpenIDParts;
|
||||
/** The flow to authenticate with. */
|
||||
flow: AuthFlow;
|
||||
/**
|
||||
* Called when the client-server API flow finds the API missing while
|
||||
* authenticating us as a publisher.
|
||||
*/
|
||||
onCsApiMissing: () => void;
|
||||
/** The Matrix room the session is in. */
|
||||
roomId: string;
|
||||
/** The MatrixRTC slot the session is in. */
|
||||
@@ -106,6 +115,9 @@ export class Connection {
|
||||
/** The homeserver the transport belongs to. */
|
||||
public readonly serverName: string;
|
||||
|
||||
/** The flow that issues this connection's tokens. */
|
||||
public readonly flow: AuthFlow;
|
||||
|
||||
public readonly livekitRoom: LivekitRoom;
|
||||
|
||||
private scope: ObservableScope;
|
||||
@@ -134,6 +146,7 @@ export class Connection {
|
||||
protected stopped = false;
|
||||
|
||||
private readonly client: ClientGetTokenParts & ClientOpenIDParts;
|
||||
private readonly onCsApiMissing: () => void;
|
||||
private readonly roomId: string;
|
||||
private readonly slotId: string;
|
||||
private readonly logger: Logger;
|
||||
@@ -161,6 +174,8 @@ export class Connection {
|
||||
this.transport = transport;
|
||||
this.serverName = serverName;
|
||||
this.client = client;
|
||||
this.flow = opts.flow;
|
||||
this.onCsApiMissing = opts.onCsApiMissing;
|
||||
|
||||
this.remoteParticipants$ = scope.behavior(
|
||||
// Only tracks remote participants
|
||||
@@ -401,16 +416,32 @@ export class Connection {
|
||||
}
|
||||
|
||||
protected async getSFUConfig(): Promise<SFUConfig> {
|
||||
return await getSFUConfig({
|
||||
client: this.client,
|
||||
membership: this.ownMembershipIdentity,
|
||||
role: this.role,
|
||||
transport: this.transport,
|
||||
serverName: this.serverName,
|
||||
roomId: this.roomId,
|
||||
slotId: this.slotId,
|
||||
logger: this.logger,
|
||||
});
|
||||
try {
|
||||
return await getSFUConfig({
|
||||
client: this.client,
|
||||
membership: this.ownMembershipIdentity,
|
||||
role: this.role,
|
||||
flow: this.flow,
|
||||
serverName: this.serverName,
|
||||
roomId: this.roomId,
|
||||
slotId: this.slotId,
|
||||
logger: this.logger,
|
||||
});
|
||||
} catch (e) {
|
||||
// If authenticating through the CS API failed and we are the publisher
|
||||
// connection, trigger the callback before the error surfaces. If falling
|
||||
// back to the OpenID flow is possible, the connection is stopped and
|
||||
// replaced, so it never shows as failed.
|
||||
//
|
||||
// Subscriber connections are explicitly excluded here because the publishing
|
||||
// connection may already have authenticated and delegated its delayed leave.
|
||||
if (
|
||||
e instanceof NoMatrix2AuthorizationService &&
|
||||
this.role === "publisher"
|
||||
)
|
||||
this.onCsApiMissing();
|
||||
throw e;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -18,7 +18,11 @@ import { type PublishRequest } from "../../media-api";
|
||||
import { constant } from "../../reactive/Behavior";
|
||||
import { ownMemberMock, testScope } from "../../utils/test";
|
||||
import { testJWTToken } from "../../utils/test-fixtures";
|
||||
import { type ClientGetTokenParts, type ClientOpenIDParts } from "./auth";
|
||||
import {
|
||||
type ClientGetTokenParts,
|
||||
type ClientOpenIDParts,
|
||||
chooseAuthFlow,
|
||||
} from "./auth";
|
||||
import {
|
||||
LivekitConnectionFactory,
|
||||
type ResolvedConnection,
|
||||
@@ -50,6 +54,7 @@ function create(
|
||||
): { connection: ResolvedConnection; options: RoomOptions } {
|
||||
const factory = new LivekitConnectionFactory(
|
||||
client(),
|
||||
() => {},
|
||||
"!room:example.org",
|
||||
"m.call#ROOM",
|
||||
publish,
|
||||
@@ -62,6 +67,7 @@ function create(
|
||||
"subscriber",
|
||||
transport,
|
||||
"example.org",
|
||||
chooseAuthFlow(transport, true),
|
||||
ownMemberMock,
|
||||
logger,
|
||||
) as ResolvedConnection;
|
||||
|
||||
@@ -24,6 +24,7 @@ import { type PublishRequest } from "../../media-api";
|
||||
import { type Behavior } from "../../reactive/Behavior";
|
||||
import { type ObservableScope } from "../../reactive/ObservableScope";
|
||||
import {
|
||||
type AuthFlow,
|
||||
type ClientGetTokenParts,
|
||||
type ClientOpenIDParts,
|
||||
type ConnectionRole,
|
||||
@@ -44,6 +45,7 @@ export interface ConnectionFactory {
|
||||
role: ConnectionRole,
|
||||
transport: UnstableLivekitTransport,
|
||||
serverName: string,
|
||||
flow: AuthFlow,
|
||||
ownMembershipIdentity: CallMembershipIdentityParts,
|
||||
logger: Logger,
|
||||
): Connection;
|
||||
@@ -102,6 +104,7 @@ function resolvedTransport(config: SFUConfig): ResolvedTransport {
|
||||
export class LivekitConnectionFactory implements ConnectionFactory {
|
||||
public constructor(
|
||||
private readonly client: ClientGetTokenParts & ClientOpenIDParts,
|
||||
private readonly onCsApiMissing: () => void,
|
||||
private readonly roomId: string,
|
||||
private readonly slotId: string,
|
||||
private readonly publish: PublishRequest[],
|
||||
@@ -115,6 +118,7 @@ export class LivekitConnectionFactory implements ConnectionFactory {
|
||||
role: ConnectionRole,
|
||||
transport: UnstableLivekitTransport,
|
||||
serverName: string,
|
||||
flow: AuthFlow,
|
||||
ownMembershipIdentity: CallMembershipIdentityParts,
|
||||
logger: Logger,
|
||||
): Connection {
|
||||
@@ -125,7 +129,9 @@ export class LivekitConnectionFactory implements ConnectionFactory {
|
||||
role,
|
||||
transport,
|
||||
serverName,
|
||||
flow,
|
||||
client: this.client,
|
||||
onCsApiMissing: this.onCsApiMissing,
|
||||
scope,
|
||||
livekitRoomFactory: () =>
|
||||
new LivekitRoom(
|
||||
|
||||
@@ -16,11 +16,7 @@ import {
|
||||
mapEpoch,
|
||||
ObservableScope,
|
||||
} from "../../reactive/ObservableScope";
|
||||
import {
|
||||
createConnectionMap$,
|
||||
ConnectionMap,
|
||||
keyFor,
|
||||
} from "./ConnectionMap.ts";
|
||||
import { createConnectionMap$, ConnectionMap } from "./ConnectionMap.ts";
|
||||
import { type ConnectionFactory } from "./ConnectionFactory.ts";
|
||||
import { type Connection } from "./Connection.ts";
|
||||
import { ownMemberMock, withTestScheduler } from "../../utils/test";
|
||||
@@ -43,6 +39,33 @@ const TRANSPORT_2: TransportLocator = {
|
||||
serverName: "sample.com",
|
||||
};
|
||||
|
||||
const SERVICE_URL_TRANSPORT: TransportLocator = {
|
||||
transport: {
|
||||
type: "livekit",
|
||||
livekit_service_url: "https://jwt.example.org",
|
||||
},
|
||||
serverName: "example.org",
|
||||
};
|
||||
|
||||
const URL_TRANSPORT: TransportLocator = {
|
||||
transport: { type: "livekit", url: "wss://sfu.example.org" },
|
||||
serverName: "example.org",
|
||||
};
|
||||
|
||||
/** Names the same SFU as URL_TRANSPORT and the same service as SERVICE_URL_TRANSPORT. */
|
||||
const URL_AND_SERVICE_URL_TRANSPORT: TransportLocator = {
|
||||
transport: {
|
||||
type: "livekit",
|
||||
url: "wss://sfu.example.org",
|
||||
livekit_service_url: "https://jwt.example.org",
|
||||
},
|
||||
serverName: "example.org",
|
||||
};
|
||||
|
||||
/** Tells the locators used here apart; not the key the map folds them by. */
|
||||
const keyFor = ({ transport, serverName }: TransportLocator): string =>
|
||||
JSON.stringify([transport, serverName]);
|
||||
|
||||
function findConnection(
|
||||
transport: TransportLocator,
|
||||
connections: Connection[],
|
||||
@@ -97,7 +120,7 @@ describe("connections$ stream", () => {
|
||||
const connectionMap$ = createConnectionMap$({
|
||||
scope: testScope,
|
||||
connectionFactory: fakeConnectionFactory,
|
||||
localTransport: TRANSPORT_1,
|
||||
localTransport: { ...TRANSPORT_1, csApiUsable: true },
|
||||
remoteTransports$: behavior("a", {
|
||||
a: new Epoch([TRANSPORT_1, TRANSPORT_2], 0),
|
||||
}),
|
||||
@@ -134,7 +157,7 @@ describe("connections$ stream", () => {
|
||||
const connectionMap$ = createConnectionMap$({
|
||||
scope: testScope,
|
||||
connectionFactory: fakeConnectionFactory,
|
||||
localTransport: TRANSPORT_1,
|
||||
localTransport: { ...TRANSPORT_1, csApiUsable: true },
|
||||
remoteTransports$: behavior("a", {
|
||||
a: new Epoch([TRANSPORT_2], 0),
|
||||
}),
|
||||
@@ -150,6 +173,7 @@ describe("connections$ stream", () => {
|
||||
"publisher",
|
||||
TRANSPORT_1.transport,
|
||||
TRANSPORT_1.serverName,
|
||||
{ kind: "openID", serviceUrl: "https://lk.example.org" },
|
||||
ownMemberMock,
|
||||
expect.anything(),
|
||||
);
|
||||
@@ -158,6 +182,7 @@ describe("connections$ stream", () => {
|
||||
"subscriber",
|
||||
TRANSPORT_2.transport,
|
||||
TRANSPORT_2.serverName,
|
||||
{ kind: "openID", serviceUrl: "https://lk.sample.com" },
|
||||
ownMemberMock,
|
||||
expect.anything(),
|
||||
);
|
||||
@@ -176,7 +201,7 @@ describe("connections$ stream", () => {
|
||||
const connectionMap$ = createConnectionMap$({
|
||||
scope: testScope,
|
||||
connectionFactory: fakeConnectionFactory,
|
||||
localTransport: TRANSPORT_1,
|
||||
localTransport: { ...TRANSPORT_1, csApiUsable: true },
|
||||
remoteTransports$: behavior("a", {
|
||||
a: new Epoch([sameServiceElsewhere], 0),
|
||||
}),
|
||||
@@ -198,6 +223,7 @@ describe("connections$ stream", () => {
|
||||
"publisher",
|
||||
TRANSPORT_1.transport,
|
||||
"example.org",
|
||||
{ kind: "openID", serviceUrl: "https://lk.example.org" },
|
||||
expect.anything(),
|
||||
expect.anything(),
|
||||
);
|
||||
@@ -220,7 +246,7 @@ describe("connections$ stream", () => {
|
||||
const connectionMap$ = createConnectionMap$({
|
||||
scope: testScope,
|
||||
connectionFactory: fakeConnectionFactory,
|
||||
localTransport: urlTransport,
|
||||
localTransport: { ...urlTransport, csApiUsable: true },
|
||||
remoteTransports$: behavior("a", {
|
||||
a: new Epoch([sameUrlElsewhere], 0),
|
||||
}),
|
||||
@@ -243,42 +269,42 @@ describe("connections$ stream", () => {
|
||||
});
|
||||
});
|
||||
|
||||
test("Shares connection between local livekit_service_url transport and remote url + livekit_service_url transport", () => {
|
||||
withTestScheduler(({ behavior, expectObservable, scope }) => {
|
||||
const serviceUrlTransport: TransportLocator = {
|
||||
transport: {
|
||||
type: "livekit",
|
||||
livekit_service_url: "https://jwt.example.org",
|
||||
},
|
||||
serverName: "example.org",
|
||||
};
|
||||
const urlAndServiceUrlTransport: TransportLocator = {
|
||||
transport: {
|
||||
type: "livekit",
|
||||
livekit_service_url: "https://jwt.example.org",
|
||||
url: "wss://sfu.elsewhere.org",
|
||||
},
|
||||
// Should pass even if local server != remote server
|
||||
serverName: "elsewhere.org",
|
||||
};
|
||||
test("Shares connection between url transport and url + livekit_service_url transport", () => {
|
||||
withTestScheduler(({ expectObservable, scope }) => {
|
||||
const connectionMap$ = createConnectionMap$({
|
||||
scope,
|
||||
connectionFactory: fakeConnectionFactory,
|
||||
localTransport: serviceUrlTransport,
|
||||
remoteTransports$: constant(new Epoch([urlAndServiceUrlTransport])),
|
||||
localTransport: { ...URL_AND_SERVICE_URL_TRANSPORT, csApiUsable: true },
|
||||
remoteTransports$: constant(
|
||||
new Epoch([URL_TRANSPORT, SERVICE_URL_TRANSPORT]),
|
||||
),
|
||||
logger,
|
||||
ownMembershipIdentity: ownMemberMock,
|
||||
});
|
||||
|
||||
expectObservable(
|
||||
connectionMap$.pipe(mapEpoch((d) => d.getConnections())),
|
||||
).toBe("a", {
|
||||
a: expect.toSatisfy(({ value: cs }: Epoch<Connection[]>) => {
|
||||
// One connection total, since local and remote connections are shared
|
||||
expect(cs.length).toBe(1);
|
||||
expect(findConnection(serviceUrlTransport, cs)).toBeDefined();
|
||||
expect(findConnection(serviceUrlTransport, cs)).toBe(
|
||||
findConnection(urlAndServiceUrlTransport, cs),
|
||||
expectObservable(connectionMap$).toBe("a", {
|
||||
a: expect.toSatisfy(({ value: map }: Epoch<ConnectionMap>) => {
|
||||
// Both get the CS API flow, and with it the same identity on the
|
||||
// same SFU. The JWT service assigns another, so it may stay apart.
|
||||
expect(map.getConnections().length).toBe(2);
|
||||
const shared = map.getConnectionForTransport(
|
||||
URL_AND_SERVICE_URL_TRANSPORT,
|
||||
);
|
||||
expect(shared).not.toBeNull();
|
||||
expect(map.getConnectionForTransport(URL_TRANSPORT)).toBe(shared);
|
||||
expect(map.getConnectionForTransport(SERVICE_URL_TRANSPORT)).not.toBe(
|
||||
shared,
|
||||
);
|
||||
expect(
|
||||
vi.mocked(fakeConnectionFactory).createConnection,
|
||||
).toHaveBeenCalledWith(
|
||||
expect.anything(),
|
||||
"publisher",
|
||||
URL_AND_SERVICE_URL_TRANSPORT.transport,
|
||||
"example.org",
|
||||
{ kind: "csApi", url: "wss://sfu.example.org" },
|
||||
ownMemberMock,
|
||||
expect.anything(),
|
||||
);
|
||||
return true;
|
||||
}),
|
||||
@@ -286,44 +312,34 @@ describe("connections$ stream", () => {
|
||||
});
|
||||
});
|
||||
|
||||
test("Shares connection between remote livekit_service_url transport and remote url + livekit_service_url transport", () => {
|
||||
withTestScheduler(({ behavior, expectObservable, scope }) => {
|
||||
const serviceUrlTransport: TransportLocator = {
|
||||
transport: {
|
||||
type: "livekit",
|
||||
livekit_service_url: "https://jwt.example.org",
|
||||
},
|
||||
serverName: "example.org",
|
||||
};
|
||||
const urlAndServiceUrlTransport: TransportLocator = {
|
||||
transport: {
|
||||
type: "livekit",
|
||||
livekit_service_url: "https://jwt.example.org",
|
||||
url: "wss://sfu.elsewhere.org",
|
||||
},
|
||||
// Should pass even if local server != remote server
|
||||
serverName: "elsewhere.org",
|
||||
};
|
||||
test("Shares connection between livekit_service_url transport and url + livekit_service_url transport without the CS API", () => {
|
||||
withTestScheduler(({ expectObservable, scope }) => {
|
||||
const connectionMap$ = createConnectionMap$({
|
||||
scope,
|
||||
connectionFactory: fakeConnectionFactory,
|
||||
localTransport: TRANSPORT_2,
|
||||
localTransport: { ...SERVICE_URL_TRANSPORT, csApiUsable: false },
|
||||
remoteTransports$: constant(
|
||||
new Epoch([serviceUrlTransport, urlAndServiceUrlTransport]),
|
||||
new Epoch([
|
||||
{
|
||||
...URL_AND_SERVICE_URL_TRANSPORT,
|
||||
// Should pass even if local server != remote server
|
||||
serverName: "elsewhere.org",
|
||||
},
|
||||
]),
|
||||
),
|
||||
logger,
|
||||
ownMembershipIdentity: ownMemberMock,
|
||||
});
|
||||
|
||||
expectObservable(
|
||||
connectionMap$.pipe(mapEpoch((d) => d.getConnections())),
|
||||
).toBe("a", {
|
||||
a: expect.toSatisfy(({ value: cs }: Epoch<Connection[]>) => {
|
||||
// Two connections total: a local connection and a shared remote connection
|
||||
expect(cs.length).toBe(2);
|
||||
expect(findConnection(serviceUrlTransport, cs)).toBeDefined();
|
||||
expect(findConnection(serviceUrlTransport, cs)).toBe(
|
||||
findConnection(urlAndServiceUrlTransport, cs),
|
||||
expectObservable(connectionMap$).toBe("a", {
|
||||
a: expect.toSatisfy(({ value: map }: Epoch<ConnectionMap>) => {
|
||||
// One connection total, since both go through the same JWT service
|
||||
expect(map.getConnections().length).toBe(1);
|
||||
expect(
|
||||
map.getConnectionForTransport(SERVICE_URL_TRANSPORT),
|
||||
).not.toBeNull();
|
||||
expect(map.getConnectionForTransport(SERVICE_URL_TRANSPORT)).toBe(
|
||||
map.getConnectionForTransport(URL_AND_SERVICE_URL_TRANSPORT),
|
||||
);
|
||||
return true;
|
||||
}),
|
||||
@@ -331,12 +347,35 @@ describe("connections$ stream", () => {
|
||||
});
|
||||
});
|
||||
|
||||
test("Publishes on a url + livekit_service_url transport through the JWT service without the CS API", () => {
|
||||
createConnectionMap$({
|
||||
scope: testScope,
|
||||
connectionFactory: fakeConnectionFactory,
|
||||
localTransport: { ...URL_AND_SERVICE_URL_TRANSPORT, csApiUsable: false },
|
||||
remoteTransports$: constant(new Epoch([])),
|
||||
logger,
|
||||
ownMembershipIdentity: ownMemberMock,
|
||||
});
|
||||
|
||||
expect(
|
||||
vi.mocked(fakeConnectionFactory).createConnection,
|
||||
).toHaveBeenCalledExactlyOnceWith(
|
||||
expect.anything(),
|
||||
"publisher",
|
||||
URL_AND_SERVICE_URL_TRANSPORT.transport,
|
||||
"example.org",
|
||||
{ kind: "openID", serviceUrl: "https://jwt.example.org" },
|
||||
ownMemberMock,
|
||||
expect.anything(),
|
||||
);
|
||||
});
|
||||
|
||||
test("Should start connection only once", () => {
|
||||
withTestScheduler(({ behavior, expectObservable }) => {
|
||||
const connectionMap$ = createConnectionMap$({
|
||||
scope: testScope,
|
||||
connectionFactory: fakeConnectionFactory,
|
||||
localTransport: TRANSPORT_1,
|
||||
localTransport: { ...TRANSPORT_1, csApiUsable: true },
|
||||
remoteTransports$: behavior("abcdef", {
|
||||
a: new Epoch([TRANSPORT_1], 0),
|
||||
b: new Epoch([TRANSPORT_1], 1),
|
||||
@@ -379,7 +418,7 @@ describe("connections$ stream", () => {
|
||||
const connectionMap$ = createConnectionMap$({
|
||||
scope: testScope,
|
||||
connectionFactory: fakeConnectionFactory,
|
||||
localTransport: TRANSPORT_1,
|
||||
localTransport: { ...TRANSPORT_1, csApiUsable: true },
|
||||
remoteTransports$: behavior("abc", {
|
||||
a: new Epoch([TRANSPORT_1], 0),
|
||||
b: new Epoch([TRANSPORT_1, TRANSPORT_2], 1),
|
||||
@@ -422,9 +461,21 @@ describe("connections$ stream", () => {
|
||||
});
|
||||
|
||||
describe("ConnectionMap", () => {
|
||||
test("hands out the connection we publish on, if any", () => {
|
||||
const connection = (role: string, locator: TransportLocator): Connection =>
|
||||
({ role, ...locator }) as unknown as Connection;
|
||||
const data = new ConnectionMap(true);
|
||||
expect(data.getPublisherConnection()).toBeNull();
|
||||
|
||||
const publisher = connection("publisher", TRANSPORT_1);
|
||||
data.add(connection("subscriber", TRANSPORT_2), []);
|
||||
data.add(publisher, []);
|
||||
expect(data.getPublisherConnection()).toBe(publisher);
|
||||
});
|
||||
|
||||
test("warns when a second connection to the same URL is merged", () => {
|
||||
const warn = vi.spyOn(logger, "warn").mockImplementation(() => {});
|
||||
const data = new ConnectionMap(logger);
|
||||
const data = new ConnectionMap(true, logger);
|
||||
const connection = TRANSPORT_1 as unknown as Connection;
|
||||
const p = (identity: string): RemoteParticipant =>
|
||||
({ identity }) as unknown as RemoteParticipant;
|
||||
@@ -520,7 +571,7 @@ describe("connectionMap$", () => {
|
||||
const connectionMap$ = createConnectionMap$({
|
||||
scope: testScope,
|
||||
connectionFactory: fakeConnectionFactory,
|
||||
localTransport: TRANSPORT_1,
|
||||
localTransport: { ...TRANSPORT_1, csApiUsable: true },
|
||||
remoteTransports$: behavior("a", {
|
||||
a: new Epoch([TRANSPORT_1, TRANSPORT_2], 0),
|
||||
}),
|
||||
|
||||
@@ -18,63 +18,67 @@ import {
|
||||
type ObservableScope,
|
||||
} from "../../reactive/ObservableScope";
|
||||
import { generateItemsWithEpoch } from "../../reactive/observable";
|
||||
import {
|
||||
chooseAuthFlow,
|
||||
type ConnectionRole,
|
||||
type TransportLocator,
|
||||
} from "./auth";
|
||||
import { chooseAuthFlow, type TransportLocator } from "./auth";
|
||||
import { type Connection } from "./Connection";
|
||||
import { type ConnectionFactory } from "./ConnectionFactory";
|
||||
|
||||
// Branded, so that only values returned by `keyFor` can be used as keys
|
||||
export type TransportKey = string & { __transportKey: true };
|
||||
// Branded, so that only values returned by `connectionKey` can be used as keys
|
||||
type ConnectionKey = string & { __connectionKey: true };
|
||||
|
||||
/**
|
||||
* Converts a {@link TransportLocator} to a key suitable for identifying it in a
|
||||
* map of connections.
|
||||
*
|
||||
* @param csApiUsable - Whether the map the key is for uses the client-server API
|
||||
* where a transport leaves the choice.
|
||||
*
|
||||
* Note that we deliberately don't use `TransportLocatorWithCsSupport` to infer
|
||||
* `csApiUsable`. That setting would be transport-specific. Instead, `csApiUsable`
|
||||
* is passed in from the connection map's own setting, fixed at creation time.
|
||||
*/
|
||||
export function keyFor({
|
||||
transport,
|
||||
serverName,
|
||||
}: TransportLocator): TransportKey {
|
||||
function connectionKey(
|
||||
{ transport, serverName }: TransportLocator,
|
||||
csApiUsable: boolean,
|
||||
): ConnectionKey {
|
||||
// Base the key on the auth flow we would use, so that we never create two
|
||||
// connections that share the same auth details. (That would be bad, as we
|
||||
// might then try to connect to the same SFU twice with the same participant
|
||||
// ID, resulting in only one working connection.)
|
||||
// TODO: This strategy will not work once `chooseAuthFlow` begins allowing for
|
||||
// falling back from the CS API flow to the OpenID flow.
|
||||
const flow = chooseAuthFlow(transport);
|
||||
const flow = chooseAuthFlow(transport, csApiUsable);
|
||||
// Serialize the fields in a consistent order
|
||||
return JSON.stringify([
|
||||
flow.kind,
|
||||
// With the CS API flow, we additionally need to distinguish server names
|
||||
...(flow.kind === "csApi" ? [flow.url, serverName] : [flow.serviceUrl]),
|
||||
]) as TransportKey;
|
||||
]) as ConnectionKey;
|
||||
}
|
||||
|
||||
function removeDuplicateTransports(
|
||||
transports: TransportLocator[],
|
||||
): TransportLocator[] {
|
||||
// The first locator wins, so the local one stays first in the list
|
||||
const map = new Map<TransportKey, TransportLocator>();
|
||||
for (const transport of transports) {
|
||||
const key = keyFor(transport);
|
||||
if (!map.has(key)) map.set(key, transport);
|
||||
}
|
||||
return [...map.values()];
|
||||
/** The transport we publish on, with what is fixed for its connection map. */
|
||||
export interface TransportLocatorWithCsSupport extends TransportLocator {
|
||||
/**
|
||||
* Whether a transport naming both a `url` and a `livekit_service_url` is
|
||||
* reached through the client-server API.
|
||||
*/
|
||||
csApiUsable: boolean;
|
||||
}
|
||||
|
||||
/** The connections at one moment, with the remote participants seen on each. */
|
||||
export class ConnectionMap {
|
||||
private readonly map = new Map<
|
||||
TransportKey,
|
||||
ConnectionKey,
|
||||
{ connection: Connection; participants: RemoteParticipant[] }
|
||||
>();
|
||||
|
||||
public constructor(private readonly logger?: Logger) {}
|
||||
/**
|
||||
* @param csApiUsable - What the connections were keyed with.
|
||||
*/
|
||||
public constructor(
|
||||
private readonly csApiUsable: boolean,
|
||||
private readonly logger?: Logger,
|
||||
) {}
|
||||
|
||||
public add(connection: Connection, participants: RemoteParticipant[]): void {
|
||||
const key = keyFor(connection);
|
||||
const key = connectionKey(connection, this.csApiUsable);
|
||||
const existing = this.map.get(key);
|
||||
if (!existing) {
|
||||
this.map.set(key, { connection, participants });
|
||||
@@ -92,16 +96,25 @@ export class ConnectionMap {
|
||||
return Array.from(this.map.values()).map(({ connection }) => connection);
|
||||
}
|
||||
|
||||
/** The connection we publish on or `null` if no publishing connection exists in the map. */
|
||||
public getPublisherConnection(): Connection | null {
|
||||
return (
|
||||
this.getConnections().find(({ role }) => role === "publisher") ?? null
|
||||
);
|
||||
}
|
||||
|
||||
public getConnectionForTransport(
|
||||
transport: TransportLocator,
|
||||
): Connection | null {
|
||||
return this.map.get(keyFor(transport))?.connection ?? null;
|
||||
const key = connectionKey(transport, this.csApiUsable);
|
||||
return this.map.get(key)?.connection ?? null;
|
||||
}
|
||||
|
||||
public getParticipantsForTransport(
|
||||
transport: TransportLocator,
|
||||
): RemoteParticipant[] {
|
||||
return this.map.get(keyFor(transport))?.participants ?? [];
|
||||
const key = connectionKey(transport, this.csApiUsable);
|
||||
return this.map.get(key)?.participants ?? [];
|
||||
}
|
||||
}
|
||||
|
||||
@@ -109,7 +122,7 @@ interface Props {
|
||||
scope: ObservableScope;
|
||||
connectionFactory: ConnectionFactory;
|
||||
/** The transport we publish on; the one connection with the publisher role. */
|
||||
localTransport: TransportLocator;
|
||||
localTransport: TransportLocatorWithCsSupport;
|
||||
/** Every transport some member is on, deduplicated against the local one. */
|
||||
remoteTransports$: Behavior<Epoch<TransportLocator[]>>;
|
||||
logger: Logger;
|
||||
@@ -130,42 +143,41 @@ export function createConnectionMap$({
|
||||
ownMembershipIdentity,
|
||||
}: Props): Behavior<Epoch<ConnectionMap>> {
|
||||
const logger = parentLogger.getChild("[ConnectionMap]");
|
||||
const { csApiUsable } = localTransport;
|
||||
|
||||
const localAndRemoteTransports$: Behavior<Epoch<TransportLocator[]>> =
|
||||
scope.behavior(
|
||||
remoteTransports$.pipe(
|
||||
mapEpoch((remoteTransports) =>
|
||||
removeDuplicateTransports([localTransport, ...remoteTransports]),
|
||||
),
|
||||
tap((transports) =>
|
||||
logger.debug("localAndRemoteTransports$ = ", transports),
|
||||
),
|
||||
const transportsByKey$ = scope.behavior(
|
||||
remoteTransports$.pipe(
|
||||
mapEpoch(
|
||||
(remote) =>
|
||||
// The last locator wins a key, so the local one goes last
|
||||
new Map(
|
||||
[...remote, localTransport].map((transport) => [
|
||||
connectionKey(transport, csApiUsable),
|
||||
transport,
|
||||
]),
|
||||
),
|
||||
),
|
||||
);
|
||||
|
||||
const localTransportKey = keyFor(localTransport);
|
||||
tap(({ value }) =>
|
||||
logger.debug("transportsByKey$ = ", [...value.values()]),
|
||||
),
|
||||
),
|
||||
);
|
||||
|
||||
const localTransportKey = connectionKey(localTransport, csApiUsable);
|
||||
const connections$ = scope.behavior(
|
||||
localAndRemoteTransports$.pipe(
|
||||
transportsByKey$.pipe(
|
||||
generateItemsWithEpoch(
|
||||
"ConnectionMap connections$",
|
||||
function* (transports) {
|
||||
for (const transport of transports) {
|
||||
const role: ConnectionRole =
|
||||
keyFor(transport) === localTransportKey
|
||||
? "publisher"
|
||||
: "subscriber";
|
||||
// The locator is an object, so a stable key stands in for it
|
||||
yield { keys: [role, keyFor(transport)], data: transport };
|
||||
}
|
||||
},
|
||||
(scope, locator$, role, _key) => {
|
||||
// The locator is an object, so a stable key stands in for it
|
||||
(byKey) => Array.from(byKey, ([key, data]) => ({ keys: [key], data })),
|
||||
(scope, locator$, key) => {
|
||||
const { transport, serverName } = locator$.value;
|
||||
const connection = connectionFactory.createConnection(
|
||||
scope,
|
||||
role,
|
||||
key === localTransportKey ? "publisher" : "subscriber",
|
||||
transport,
|
||||
serverName,
|
||||
chooseAuthFlow(transport, csApiUsable),
|
||||
ownMembershipIdentity,
|
||||
logger,
|
||||
);
|
||||
@@ -181,7 +193,7 @@ export function createConnectionMap$({
|
||||
connections$.pipe(
|
||||
switchMap(({ value: connections, epoch }) => {
|
||||
if (connections.length === 0)
|
||||
return of(new Epoch(new ConnectionMap(), epoch));
|
||||
return of(new Epoch(new ConnectionMap(csApiUsable), epoch));
|
||||
return combineLatest(
|
||||
connections.map((connection) =>
|
||||
connection.remoteParticipants$.pipe(
|
||||
@@ -189,7 +201,7 @@ export function createConnectionMap$({
|
||||
),
|
||||
),
|
||||
(...list) => {
|
||||
const map = new ConnectionMap(logger);
|
||||
const map = new ConnectionMap(csApiUsable, logger);
|
||||
for (const item of list)
|
||||
map.add(item.connection, item.participants);
|
||||
return new Epoch(map, epoch);
|
||||
|
||||
@@ -54,7 +54,7 @@ function setup(connections: Connection[]): {
|
||||
connections$: BehaviorSubject<Epoch<ConnectionMap>>;
|
||||
sendData: (topic: string, text: string) => Promise<void>;
|
||||
} {
|
||||
const data = new ConnectionMap();
|
||||
const data = new ConnectionMap(true);
|
||||
for (const connection of connections) data.add(connection, []);
|
||||
const connections$ = new BehaviorSubject(new Epoch(data));
|
||||
const { data$, sendData } = createDataChannel$({
|
||||
@@ -99,7 +99,7 @@ describe("data$", () => {
|
||||
const second = fakeConnection("https://sfu-2");
|
||||
const { received, connections$ } = setup([first.connection]);
|
||||
|
||||
const data = new ConnectionMap();
|
||||
const data = new ConnectionMap(true);
|
||||
data.add(first.connection, []);
|
||||
data.add(second.connection, []);
|
||||
connections$.next(new Epoch(data, 1));
|
||||
|
||||
@@ -148,7 +148,6 @@ describe("toMediaConnectionState", () => {
|
||||
|
||||
describe("createLivekitBackend", () => {
|
||||
const homeserver = "https://matrix.example.org";
|
||||
const homeserverEndpoint = `${homeserver}/_matrix/client/unstable/io.element.msc4195/rtc/livekit/delegate_delayed_leave`;
|
||||
const urlTransport: UnstableLivekitTransport = {
|
||||
type: "livekit",
|
||||
url: "wss://sfu.example.org",
|
||||
@@ -169,6 +168,7 @@ describe("createLivekitBackend", () => {
|
||||
participants$: BehaviorSubject<RemoteParticipant[]>;
|
||||
state$: BehaviorSubject<ConnectionState>;
|
||||
}[];
|
||||
let onCsApiMissing: () => void;
|
||||
const connected: ConnectionState = {
|
||||
state: "authenticated",
|
||||
livekitState: LivekitConnectionState.Connected,
|
||||
@@ -177,13 +177,15 @@ describe("createLivekitBackend", () => {
|
||||
/** Stands in for the factory: connections whose state and participants the test drives. */
|
||||
function stubFactory(initialState: ConnectionState): void {
|
||||
vi.spyOn(connectionFactory, "LivekitConnectionFactory").mockImplementation(
|
||||
function (this: unknown) {
|
||||
function (this: unknown, _client, onMissing) {
|
||||
onCsApiMissing = onMissing;
|
||||
return {
|
||||
createConnection: (
|
||||
scope: ObservableScope,
|
||||
role: auth.ConnectionRole,
|
||||
transport: UnstableLivekitTransport,
|
||||
serverName: string,
|
||||
flow: auth.AuthFlow,
|
||||
): Connection => {
|
||||
const participants$ = new BehaviorSubject<RemoteParticipant[]>([]);
|
||||
const state$ = new BehaviorSubject<ConnectionState>(initialState);
|
||||
@@ -191,6 +193,7 @@ describe("createLivekitBackend", () => {
|
||||
role,
|
||||
transport,
|
||||
serverName,
|
||||
flow,
|
||||
state$,
|
||||
remoteParticipants$: scope.behavior(participants$),
|
||||
livekitRoom: fakeLivekitRoom(),
|
||||
@@ -232,17 +235,15 @@ describe("createLivekitBackend", () => {
|
||||
}
|
||||
|
||||
// Delegation goes through whichever service authenticates us as a
|
||||
// publisher: the JWT service wherever the transport names one, the
|
||||
// homeserver for a `url` alone
|
||||
// publisher.
|
||||
it.each([
|
||||
["the JWT service", exampleTransport, 404, 401, true],
|
||||
["the JWT service, and only it", bothTransport, 401, 404, false],
|
||||
["the homeserver", urlTransport, 401, 404, true],
|
||||
["neither", exampleTransport, 404, 404, false],
|
||||
["a JWT service that delegates", exampleTransport, 401, true],
|
||||
["a JWT service that does not delegate", exampleTransport, 404, false],
|
||||
["the homeserver over the JWT service", bothTransport, 404, true],
|
||||
["the homeserver", urlTransport, 404, true],
|
||||
])(
|
||||
"prepares the local transport and asks %s about delegation",
|
||||
async (_name, transport, homeserverStatus, serviceStatus, expected) => {
|
||||
fetchMock.post(homeserverEndpoint, homeserverStatus);
|
||||
"prepares the local transport for delegation through %s",
|
||||
async (_name, transport, serviceStatus, expected) => {
|
||||
fetchMock.post(
|
||||
`${exampleServiceUrl}/delegate_delayed_leave`,
|
||||
serviceStatus,
|
||||
@@ -251,6 +252,10 @@ describe("createLivekitBackend", () => {
|
||||
const capabilities = await backend().prepareLocalTransport(transport);
|
||||
|
||||
expect(capabilities).toEqual({ canDelegateDelayedLeave: expected });
|
||||
// Only the service that issued the publisher's token is asked.
|
||||
expect(
|
||||
fetchMock.called(`${exampleServiceUrl}/delegate_delayed_leave`),
|
||||
).toBe(transport === exampleTransport);
|
||||
expect(connections).toHaveLength(1);
|
||||
expect(connections[0].connection.role).toBe("publisher");
|
||||
expect(connections[0].connection.transport).toEqual(transport);
|
||||
@@ -259,9 +264,8 @@ describe("createLivekitBackend", () => {
|
||||
);
|
||||
|
||||
it("prepares a remote SFU's transport on its homeserver, where delegation is not possible", async () => {
|
||||
// Our own homeserver would delegate, so only the SFU being remote can
|
||||
// explain delegation being skipped
|
||||
fetchMock.post(homeserverEndpoint, 401);
|
||||
// A token through the homeserver means delegation, unless the SFU is
|
||||
// another homeserver's.
|
||||
const remoteTransport: UnstableLivekitTransport = {
|
||||
type: "livekit",
|
||||
url: "wss://sfu.sample.com",
|
||||
@@ -276,7 +280,6 @@ describe("createLivekitBackend", () => {
|
||||
});
|
||||
|
||||
it("waits for the publisher connection to hold its token before the join", async () => {
|
||||
fetchMock.post(homeserverEndpoint, 404);
|
||||
fetchMock.post(`${exampleServiceUrl}/delegate_delayed_leave`, 404);
|
||||
stubFactory({ state: "authenticating" });
|
||||
|
||||
@@ -293,7 +296,6 @@ describe("createLivekitBackend", () => {
|
||||
});
|
||||
|
||||
it("fails the preparation with the publisher connection's error", async () => {
|
||||
fetchMock.post(homeserverEndpoint, 404);
|
||||
fetchMock.post(`${exampleServiceUrl}/delegate_delayed_leave`, 404);
|
||||
stubFactory({ state: "authenticating" });
|
||||
const preparing = backend().prepareLocalTransport(exampleTransport);
|
||||
@@ -303,8 +305,60 @@ describe("createLivekitBackend", () => {
|
||||
await expect(preparing).rejects.toBe(error);
|
||||
});
|
||||
|
||||
it.each([
|
||||
["names no JWT service", urlTransport],
|
||||
["names no url", exampleTransport],
|
||||
])(
|
||||
"keeps its connections where the CS API is found missing and our transport %s",
|
||||
async (_what, transport) => {
|
||||
fetchMock.post(`${exampleServiceUrl}/delegate_delayed_leave`, 404);
|
||||
await backend().prepareLocalTransport(transport);
|
||||
onCsApiMissing();
|
||||
expect(connections).toHaveLength(1);
|
||||
},
|
||||
);
|
||||
|
||||
it("moves the publisher to the JWT service where the CS API is found missing", async () => {
|
||||
fetchMock.post(`${exampleServiceUrl}/delegate_delayed_leave`, 401);
|
||||
const delegate = vi.spyOn(auth, "delegateDelayedLeave").mockResolvedValue();
|
||||
stubFactory({ state: "authenticating" });
|
||||
|
||||
const b = backend();
|
||||
let prepared = false;
|
||||
const preparing = b.prepareLocalTransport(bothTransport).then((c) => {
|
||||
prepared = true;
|
||||
return c;
|
||||
});
|
||||
await flushPromises();
|
||||
expect(connections).toHaveLength(1);
|
||||
expect(connections[0].connection.flow.kind).toBe("csApi");
|
||||
|
||||
// The publisher's token request finds no API.
|
||||
onCsApiMissing();
|
||||
expect(connections).toHaveLength(2);
|
||||
expect(connections[1].connection.role).toBe("publisher");
|
||||
expect(connections[1].connection.transport).toEqual(bothTransport);
|
||||
expect(connections[1].connection.flow.kind).toBe("openID");
|
||||
|
||||
// The replaced connection winding down is not the preparation failing.
|
||||
connections[0].state$.next({ state: "stopped" });
|
||||
await flushPromises();
|
||||
expect(prepared).toBe(false);
|
||||
|
||||
connections[1].state$.next(connected);
|
||||
expect(await preparing).toEqual({ canDelegateDelayedLeave: true });
|
||||
expect(
|
||||
fetchMock.called(`${exampleServiceUrl}/delegate_delayed_leave`),
|
||||
).toBe(true);
|
||||
|
||||
await b.delegateDelayedLeave("delay-1");
|
||||
expect(delegate.mock.calls[0][0].flow).toEqual({
|
||||
kind: "openID",
|
||||
serviceUrl: exampleServiceUrl,
|
||||
});
|
||||
});
|
||||
|
||||
it("delegates the leave through the flow that authenticated the publisher", async () => {
|
||||
fetchMock.post(homeserverEndpoint, 401);
|
||||
const delegate = vi.spyOn(auth, "delegateDelayedLeave").mockResolvedValue();
|
||||
const b = backend();
|
||||
await expect(b.delegateDelayedLeave("delay-1")).rejects.toThrow(
|
||||
@@ -318,7 +372,7 @@ describe("createLivekitBackend", () => {
|
||||
expect.objectContaining({
|
||||
client,
|
||||
membership: ownMemberMock,
|
||||
transport: urlTransport,
|
||||
flow: { kind: "csApi", url: "wss://sfu.example.org" },
|
||||
roomId: "!room:example.org",
|
||||
slotId: "m.call#ROOM",
|
||||
delayId: "delay-1",
|
||||
@@ -360,7 +414,6 @@ describe("createLivekitBackend", () => {
|
||||
async function prepared(): Promise<
|
||||
ReturnType<typeof createLivekitBackend>
|
||||
> {
|
||||
fetchMock.post(homeserverEndpoint, 404);
|
||||
fetchMock.post(`${exampleServiceUrl}/delegate_delayed_leave`, 404);
|
||||
const b = backend();
|
||||
await b.prepareLocalTransport(bothTransport);
|
||||
@@ -392,6 +445,30 @@ describe("createLivekitBackend", () => {
|
||||
},
|
||||
);
|
||||
|
||||
it("reaches a url + livekit_service_url member through the JWT service where our transport names no url", async () => {
|
||||
fetchMock.post(`${exampleServiceUrl}/delegate_delayed_leave`, 404);
|
||||
const b = backend();
|
||||
await b.prepareLocalTransport(exampleTransport);
|
||||
const media = b.mediaFor(
|
||||
testScope(),
|
||||
bob(bothTransport, [hashedId, legacyId]),
|
||||
);
|
||||
await flushPromises();
|
||||
// Bob names our JWT service, so no connection of his own, and none
|
||||
// through a client-server API our homeserver does not have
|
||||
expect(connections).toHaveLength(1);
|
||||
expect(connections[0].connection.flow.kind).toBe("openID");
|
||||
|
||||
connections[0].participants$.next([
|
||||
mockRemoteParticipant({
|
||||
identity: hashedId,
|
||||
trackPublications: new Map(),
|
||||
}),
|
||||
]);
|
||||
await flushPromises();
|
||||
expect(media.tracks$.value).toEqual([]);
|
||||
});
|
||||
|
||||
it("does not match a member with two candidate identities to anyone else", async () => {
|
||||
const b = await prepared();
|
||||
const media = b.mediaFor(
|
||||
@@ -463,10 +540,11 @@ describe("createLivekitBackend", () => {
|
||||
(c) => c.connection.role === "subscriber",
|
||||
);
|
||||
expect(remote?.connection.transport).toEqual(otherTransport);
|
||||
expect(b.connections$.value.map(({ transport }) => transport)).toEqual([
|
||||
bothTransport,
|
||||
otherTransport,
|
||||
]);
|
||||
const transports = b.connections$.value.map(({ transport }) => transport);
|
||||
expect(transports).toHaveLength(2);
|
||||
expect(transports).toEqual(
|
||||
expect.arrayContaining([bothTransport, otherTransport]),
|
||||
);
|
||||
|
||||
transport$.next(bob(bothTransport, [legacyId]).transport$.value);
|
||||
await flushPromises();
|
||||
|
||||
@@ -18,6 +18,7 @@ import {
|
||||
filter,
|
||||
firstValueFrom,
|
||||
map,
|
||||
NEVER,
|
||||
type Observable,
|
||||
of,
|
||||
switchMap,
|
||||
@@ -41,17 +42,12 @@ import {
|
||||
type MediaBackendContext,
|
||||
type TransportCapabilities,
|
||||
} from "../api";
|
||||
import {
|
||||
chooseAuthFlow,
|
||||
delegateDelayedLeave,
|
||||
type TransportLocator,
|
||||
} from "./auth";
|
||||
import { delegateDelayedLeave, type TransportLocator } from "./auth";
|
||||
import { type Connection } from "./Connection";
|
||||
import {
|
||||
ConnectionMap,
|
||||
createConnectionMap$,
|
||||
keyFor,
|
||||
type TransportKey,
|
||||
type TransportLocatorWithCsSupport,
|
||||
} from "./ConnectionMap";
|
||||
import {
|
||||
LivekitConnectionFactory,
|
||||
@@ -69,7 +65,7 @@ import { createLivekitLocalMedia } from "./LocalMedia";
|
||||
export interface LivekitBackendOptions {
|
||||
/**
|
||||
* `getOpenIdToken` for the JWT service flow, the MSC4195 methods for the
|
||||
* client-server API flow, `baseUrl` for the delegation probe and handover.
|
||||
* client-server API flow, `baseUrl` for the delegation handover.
|
||||
*/
|
||||
client: Pick<
|
||||
MatrixClient,
|
||||
@@ -103,12 +99,20 @@ export function createLivekitBackend(
|
||||
: [requestsOrMedia.requests, requestsOrMedia];
|
||||
const keyProvider = createKeyProvider(encryptionSystem, mediaKeys$, logger);
|
||||
const transports = createTransportRegistry(scope);
|
||||
const localTransport$ = new BehaviorSubject<TransportLocator | null>(null);
|
||||
const localTransport$ =
|
||||
new BehaviorSubject<TransportLocatorWithCsSupport | null>(null);
|
||||
const audioOutputDeviceId$ = new BehaviorSubject<string | undefined>(
|
||||
undefined,
|
||||
);
|
||||
const connectionFactory = new LivekitConnectionFactory(
|
||||
client,
|
||||
// The MSC defines no unstable feature flag. If the transport names a
|
||||
// JWT service too, start over without the CS API.
|
||||
() => {
|
||||
const local = localTransport$.value;
|
||||
if (local?.csApiUsable && "livekit_service_url" in local.transport)
|
||||
localTransport$.next({ ...local, csApiUsable: false });
|
||||
},
|
||||
roomId,
|
||||
slotId,
|
||||
publish,
|
||||
@@ -118,7 +122,8 @@ export function createLivekitBackend(
|
||||
);
|
||||
|
||||
// A new map, in a scope of its own, whenever the local transport changes:
|
||||
// the publisher role sits on one connection, and which one is fixed per map
|
||||
// the publisher role sits on one connection, and which one is fixed per map,
|
||||
// as is whether the client-server API is usable
|
||||
const connectionMap$ = scope.behavior<Epoch<ConnectionMap>>(
|
||||
mapScoped(scope, localTransport$, (mapScope, localTransport) =>
|
||||
createConnectionMap$({
|
||||
@@ -129,13 +134,17 @@ export function createLivekitBackend(
|
||||
logger,
|
||||
ownMembershipIdentity,
|
||||
}),
|
||||
).pipe(switchMap((map$) => map$ ?? of(new Epoch(new ConnectionMap())))),
|
||||
).pipe(
|
||||
switchMap(
|
||||
// Nothing is looked up in an empty map, so how it is keyed is moot.
|
||||
(map$) => map$ ?? of(new Epoch(new ConnectionMap(true))),
|
||||
),
|
||||
),
|
||||
);
|
||||
|
||||
const localMedia_ = createLivekitLocalMedia({
|
||||
scope,
|
||||
connectionMap$,
|
||||
localTransport$,
|
||||
publish,
|
||||
media,
|
||||
audioOutputDeviceId$,
|
||||
@@ -143,15 +152,16 @@ export function createLivekitBackend(
|
||||
logger,
|
||||
});
|
||||
|
||||
// Probed once: the answer cannot change within a session
|
||||
const homeserverSupportsDelegation = supportsDelegation(
|
||||
`${client.baseUrl}/_matrix/client/unstable/io.element.msc4195/rtc/livekit/delegate_delayed_leave`,
|
||||
"homeserver",
|
||||
logger,
|
||||
);
|
||||
|
||||
const ownServerName = serverNameOf(ownMembershipIdentity.userId);
|
||||
|
||||
/**
|
||||
* Sets `localTransport$`, the transport we publish on. As a side effect,
|
||||
* this creates the connection map, which lets subscribing connections start,
|
||||
* too.
|
||||
*
|
||||
* Resolves once the publisher connection holds its token and reports
|
||||
* whether the service that issued it can take over the delayed leave.
|
||||
*/
|
||||
const prepareLocalTransport = async (
|
||||
transport: Transport,
|
||||
): Promise<TransportCapabilities> => {
|
||||
@@ -162,45 +172,46 @@ export function createLivekitBackend(
|
||||
ownMembershipIdentity.userId,
|
||||
);
|
||||
const locator: TransportLocator = { transport, serverName };
|
||||
let canDelegate: Promise<boolean>;
|
||||
// A homeserver with the client-server API advertises a `url`.
|
||||
localTransport$.next({ ...locator, csApiUsable: "url" in transport });
|
||||
// The membership is only sent once the publisher connection holds its
|
||||
// token, so that the LiveKit room exists before anyone subscribes to it:
|
||||
// a subscriber lacks the permission to create it and would fail without
|
||||
// retrying
|
||||
const { flow } = await authenticated(localMedia_.connection$);
|
||||
if (serverName !== ownServerName) {
|
||||
// Our homeserver only takes over leaves for its own SFUs
|
||||
logger.info(
|
||||
`Publishing on a remote SFU of ${serverName}, delegation is not possible`,
|
||||
);
|
||||
canDelegate = Promise.resolve(false);
|
||||
} else {
|
||||
// Check for support using the same auth flow that we intend to use later
|
||||
const flow = chooseAuthFlow(transport);
|
||||
canDelegate =
|
||||
flow.kind === "openID"
|
||||
? supportsDelegation(
|
||||
`${flow.serviceUrl}/delegate_delayed_leave`,
|
||||
`transport ${flow.serviceUrl}`,
|
||||
logger,
|
||||
)
|
||||
: homeserverSupportsDelegation;
|
||||
return { canDelegateDelayedLeave: false };
|
||||
}
|
||||
localTransport$.next(locator);
|
||||
// The membership is only sent once the publisher connection holds its
|
||||
// token, so that the LiveKit room exists before anyone subscribes to it:
|
||||
// a subscriber lacks the permission to create it and would fail without
|
||||
// retrying
|
||||
const [, canDelegateDelayedLeave] = await Promise.all([
|
||||
authenticated(localMedia_.connection$),
|
||||
canDelegate,
|
||||
]);
|
||||
return { canDelegateDelayedLeave };
|
||||
// Now that we are authenticated, check which flow was used so that we can
|
||||
// use the same flow for delegation.
|
||||
if (flow.kind === "csApi") {
|
||||
// If the client-server authentication endpoint is available, the delegation
|
||||
// endpoint is available, too. Both have been released together in lk-jwt-service.
|
||||
return { canDelegateDelayedLeave: true };
|
||||
}
|
||||
// The OpenID flow was used but the lk-jwt-instance may still predate delegation. Check
|
||||
// if the delegation endpoint is supported.
|
||||
return {
|
||||
canDelegateDelayedLeave: await supportsDelegation(
|
||||
`${flow.serviceUrl}/delegate_delayed_leave`,
|
||||
`transport ${flow.serviceUrl}`,
|
||||
logger,
|
||||
),
|
||||
};
|
||||
};
|
||||
|
||||
const delegateLeave = async (delayId: string): Promise<void> => {
|
||||
const local = localTransport$.value;
|
||||
if (local === null)
|
||||
const connection = localMedia_.connection$.value;
|
||||
if (connection === null)
|
||||
throw new MatrixRTCError("No local transport to delegate the leave to");
|
||||
await delegateDelayedLeave({
|
||||
client,
|
||||
membership: ownMembershipIdentity,
|
||||
transport: local.transport,
|
||||
flow: connection.flow,
|
||||
roomId,
|
||||
slotId,
|
||||
delayId,
|
||||
@@ -225,7 +236,9 @@ export function createLivekitBackend(
|
||||
}
|
||||
: undefined;
|
||||
}),
|
||||
distinctUntilChanged((a, b) => (a && keyFor(a)) === (b && keyFor(b))),
|
||||
distinctUntilChanged(
|
||||
(a, b) => (a && transportKey(a)) === (b && transportKey(b)),
|
||||
),
|
||||
),
|
||||
);
|
||||
transports.follow(memberScope, locator$);
|
||||
@@ -292,27 +305,31 @@ export function createLivekitBackend(
|
||||
};
|
||||
}
|
||||
|
||||
/** Resolves once the connection holds its token; rejects with its error otherwise. */
|
||||
/** Resolves with the connection once it holds its token; rejects with its error otherwise. */
|
||||
async function authenticated(
|
||||
connection$: Behavior<Connection | null>,
|
||||
): Promise<void> {
|
||||
const state = await firstValueFrom(
|
||||
): Promise<Connection> {
|
||||
const { connection, state } = await firstValueFrom(
|
||||
connection$.pipe(
|
||||
switchMap((connection) => connection?.state$ ?? of(null)),
|
||||
switchMap(
|
||||
(connection) =>
|
||||
connection?.state$.pipe(map((state) => ({ connection, state }))) ??
|
||||
NEVER,
|
||||
),
|
||||
filter(
|
||||
(state) =>
|
||||
state !== null &&
|
||||
(state.state === "authenticated" ||
|
||||
state.state === "error" ||
|
||||
state.state === "stopped"),
|
||||
({ state }) =>
|
||||
state.state === "authenticated" ||
|
||||
state.state === "error" ||
|
||||
state.state === "stopped",
|
||||
),
|
||||
),
|
||||
);
|
||||
if (state?.state === "error") throw state.error;
|
||||
if (state?.state === "stopped")
|
||||
if (state.state === "error") throw state.error;
|
||||
if (state.state === "stopped")
|
||||
throw new MatrixRTCError(
|
||||
"The local connection stopped before it was authenticated",
|
||||
);
|
||||
return connection;
|
||||
}
|
||||
|
||||
function backendConnection$(
|
||||
@@ -331,6 +348,19 @@ function backendConnection$(
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* The key used for a transport locator in the transport registry.
|
||||
*
|
||||
* Note that this is *not* the key used for folding locators into connections.
|
||||
*/
|
||||
function transportKey({ transport, serverName }: TransportLocator): string {
|
||||
return JSON.stringify([
|
||||
"url" in transport ? transport.url : null,
|
||||
"livekit_service_url" in transport ? transport.livekit_service_url : null,
|
||||
serverName,
|
||||
]);
|
||||
}
|
||||
|
||||
export interface TransportRegistry {
|
||||
/** Keeps a member's transport registered for as long as its scope lives. */
|
||||
follow(
|
||||
@@ -350,7 +380,7 @@ export function createTransportRegistry(
|
||||
scope: ObservableScope,
|
||||
): TransportRegistry {
|
||||
const counts = new Map<
|
||||
TransportKey,
|
||||
string,
|
||||
{ locator: TransportLocator; count: number }
|
||||
>();
|
||||
const transports = new BehaviorSubject<TransportLocator[]>([]);
|
||||
@@ -358,7 +388,7 @@ export function createTransportRegistry(
|
||||
transports.next([...counts.values()].map(({ locator }) => locator));
|
||||
|
||||
const register = (locator: TransportLocator): (() => void) => {
|
||||
const key = keyFor(locator);
|
||||
const key = transportKey(locator);
|
||||
const entry = counts.get(key) ?? { locator, count: 0 };
|
||||
entry.count++;
|
||||
if (entry.count === 1) {
|
||||
|
||||
@@ -23,16 +23,11 @@ import { FailToStartLivekitConnection, MatrixRTCError } from "../../errors";
|
||||
import { Epoch, type ObservableScope } from "../../reactive/ObservableScope";
|
||||
import { flushPromises, mockEmitter, testScope } from "../../utils/test";
|
||||
import { MediaConnectionState } from "../api";
|
||||
import { type TransportLocator } from "./auth";
|
||||
import { type Connection, type ConnectionState } from "./Connection";
|
||||
import { ConnectionMap } from "./ConnectionMap";
|
||||
import { createLivekitLocalMedia } from "./LocalMedia";
|
||||
import { exampleTransport } from "./test";
|
||||
|
||||
const localTransport: TransportLocator = {
|
||||
transport: exampleTransport,
|
||||
serverName: "example.org",
|
||||
};
|
||||
const connected: ConnectionState = {
|
||||
state: "authenticated",
|
||||
livekitState: LivekitConnectionState.Connected,
|
||||
@@ -69,7 +64,7 @@ function fakeConnection(state: ConnectionState = connected): FakeConnection {
|
||||
}
|
||||
|
||||
function mapOf(...connections: Connection[]): Epoch<ConnectionMap> {
|
||||
const map = new ConnectionMap();
|
||||
const map = new ConnectionMap(true);
|
||||
for (const connection of connections) map.add(connection, []);
|
||||
return new Epoch(map);
|
||||
}
|
||||
@@ -80,46 +75,44 @@ function setup(
|
||||
): {
|
||||
media: ReturnType<typeof createLivekitLocalMedia>;
|
||||
connectionMap$: BehaviorSubject<Epoch<ConnectionMap>>;
|
||||
localTransport$: BehaviorSubject<TransportLocator | null>;
|
||||
audioOutputDeviceId$: BehaviorSubject<string | undefined>;
|
||||
} {
|
||||
const connectionMap$ = new BehaviorSubject(mapOf());
|
||||
const localTransport$ = new BehaviorSubject<TransportLocator | null>(null);
|
||||
const audioOutputDeviceId$ = new BehaviorSubject<string | undefined>(
|
||||
undefined,
|
||||
);
|
||||
const media = createLivekitLocalMedia({
|
||||
scope,
|
||||
connectionMap$: scope.behavior(connectionMap$),
|
||||
localTransport$: scope.behavior(localTransport$),
|
||||
publish,
|
||||
audioOutputDeviceId$,
|
||||
encryptionSystem: { kind: E2eeType.NONE },
|
||||
logger,
|
||||
});
|
||||
return { media, connectionMap$, localTransport$, audioOutputDeviceId$ };
|
||||
return { media, connectionMap$, audioOutputDeviceId$ };
|
||||
}
|
||||
|
||||
describe("createLivekitLocalMedia", () => {
|
||||
it("finds the connection to the local transport once both are known", () => {
|
||||
const { media, connectionMap$, localTransport$ } = setup();
|
||||
it("takes the publisher connection from the map once there is one", () => {
|
||||
const { media, connectionMap$ } = setup();
|
||||
const { connection } = fakeConnection();
|
||||
const subscriber = {
|
||||
...fakeConnection().connection,
|
||||
role: "subscriber",
|
||||
transport: { type: "livekit", livekit_service_url: "https://other" },
|
||||
} as unknown as Connection;
|
||||
expect(media.connection$.value).toBeNull();
|
||||
expect(media.connectionState$.value).toBe(MediaConnectionState.Initialized);
|
||||
|
||||
connectionMap$.next(mapOf(connection));
|
||||
expect(media.connection$.value).toBeNull();
|
||||
|
||||
localTransport$.next(localTransport);
|
||||
connectionMap$.next(mapOf(subscriber, connection));
|
||||
expect(media.connection$.value).toBe(connection);
|
||||
expect(media.connectionState$.value).toBe(MediaConnectionState.Connected);
|
||||
});
|
||||
|
||||
it("follows the connection's state", () => {
|
||||
const { media, connectionMap$, localTransport$ } = setup();
|
||||
const { media, connectionMap$ } = setup();
|
||||
const { connection, state$ } = fakeConnection({ state: "authenticating" });
|
||||
connectionMap$.next(mapOf(connection));
|
||||
localTransport$.next(localTransport);
|
||||
expect(media.connectionState$.value).toBe(MediaConnectionState.Preparing);
|
||||
|
||||
const error = new MatrixRTCError("no token");
|
||||
@@ -128,10 +121,9 @@ describe("createLivekitLocalMedia", () => {
|
||||
});
|
||||
|
||||
it("creates the tracks on the first publish and holds them back until then", async () => {
|
||||
const { media, connectionMap$, localTransport$ } = setup();
|
||||
const { media, connectionMap$ } = setup();
|
||||
const { connection, participant } = fakeConnection();
|
||||
connectionMap$.next(mapOf(connection));
|
||||
localTransport$.next(localTransport);
|
||||
await flushPromises();
|
||||
expect(participant.setMicrophoneEnabled).not.toHaveBeenCalled();
|
||||
expect(media.tracks$.value).toEqual([]);
|
||||
@@ -148,10 +140,9 @@ describe("createLivekitLocalMedia", () => {
|
||||
});
|
||||
|
||||
it("pauses the upstream while the member is not publishing", async () => {
|
||||
const { media, connectionMap$, localTransport$ } = setup();
|
||||
const { media, connectionMap$ } = setup();
|
||||
const { connection, participant } = fakeConnection();
|
||||
connectionMap$.next(mapOf(connection));
|
||||
localTransport$.next(localTransport);
|
||||
media.setPublishing(true);
|
||||
await flushPromises();
|
||||
|
||||
@@ -169,7 +160,7 @@ describe("createLivekitLocalMedia", () => {
|
||||
});
|
||||
|
||||
it("resolves a publish made before the connection exists once it is up", async () => {
|
||||
const { media, connectionMap$, localTransport$ } = setup();
|
||||
const { media, connectionMap$ } = setup();
|
||||
let published: string | undefined;
|
||||
const publishing = media
|
||||
.publish({ source: "camera" })
|
||||
@@ -179,7 +170,6 @@ describe("createLivekitLocalMedia", () => {
|
||||
|
||||
const { connection, participant } = fakeConnection();
|
||||
connectionMap$.next(mapOf(connection));
|
||||
localTransport$.next(localTransport);
|
||||
media.setPublishing(true);
|
||||
await publishing;
|
||||
|
||||
@@ -193,10 +183,9 @@ describe("createLivekitLocalMedia", () => {
|
||||
});
|
||||
|
||||
it("publishes a request at once on a started publisher", async () => {
|
||||
const { media, connectionMap$, localTransport$ } = setup();
|
||||
const { media, connectionMap$ } = setup();
|
||||
const { connection, participant } = fakeConnection();
|
||||
connectionMap$.next(mapOf(connection));
|
||||
localTransport$.next(localTransport);
|
||||
media.setPublishing(true);
|
||||
await flushPromises();
|
||||
|
||||
@@ -211,10 +200,9 @@ describe("createLivekitLocalMedia", () => {
|
||||
});
|
||||
|
||||
it("rejects a publish the device refuses, and forgets the request", async () => {
|
||||
const { media, connectionMap$, localTransport$ } = setup();
|
||||
const { media, connectionMap$ } = setup();
|
||||
const { connection, participant } = fakeConnection();
|
||||
connectionMap$.next(mapOf(connection));
|
||||
localTransport$.next(localTransport);
|
||||
media.setPublishing(true);
|
||||
await flushPromises();
|
||||
vi.mocked(participant.setCameraEnabled).mockRejectedValueOnce(
|
||||
@@ -234,10 +222,9 @@ describe("createLivekitLocalMedia", () => {
|
||||
});
|
||||
|
||||
it("publishes again on a new connection and stops the old tracks", async () => {
|
||||
const { media, connectionMap$, localTransport$ } = setup();
|
||||
const { media, connectionMap$ } = setup();
|
||||
const first = fakeConnection();
|
||||
connectionMap$.next(mapOf(first.connection));
|
||||
localTransport$.next(localTransport);
|
||||
media.setPublishing(true);
|
||||
await flushPromises();
|
||||
await media.publish({ source: "camera" });
|
||||
@@ -263,10 +250,9 @@ describe("createLivekitLocalMedia", () => {
|
||||
});
|
||||
|
||||
it("remembers a mute across connections", async () => {
|
||||
const { media, connectionMap$, localTransport$ } = setup();
|
||||
const { media, connectionMap$ } = setup();
|
||||
const first = fakeConnection();
|
||||
connectionMap$.next(mapOf(first.connection));
|
||||
localTransport$.next(localTransport);
|
||||
media.setPublishing(true);
|
||||
await flushPromises();
|
||||
|
||||
@@ -285,10 +271,9 @@ describe("createLivekitLocalMedia", () => {
|
||||
});
|
||||
|
||||
it("unpublishes a source, the screen share audio with its video", async () => {
|
||||
const { media, connectionMap$, localTransport$ } = setup();
|
||||
const { media, connectionMap$ } = setup();
|
||||
const { connection, participant } = fakeConnection();
|
||||
connectionMap$.next(mapOf(connection));
|
||||
localTransport$.next(localTransport);
|
||||
media.setPublishing(true);
|
||||
await flushPromises();
|
||||
await media.publish({ source: "screenShare" });
|
||||
@@ -302,10 +287,9 @@ describe("createLivekitLocalMedia", () => {
|
||||
});
|
||||
|
||||
it("keeps the first failure to publish", async () => {
|
||||
const { media, connectionMap$, localTransport$ } = setup();
|
||||
const { media, connectionMap$ } = setup();
|
||||
const { connection, participant } = fakeConnection();
|
||||
connectionMap$.next(mapOf(connection));
|
||||
localTransport$.next(localTransport);
|
||||
media.setPublishing(true);
|
||||
await flushPromises();
|
||||
expect(media.publishError$.value).toBeNull();
|
||||
@@ -326,14 +310,12 @@ describe("createLivekitLocalMedia", () => {
|
||||
});
|
||||
|
||||
it("plays on the device given, on the current room and the rooms to come", async () => {
|
||||
const { media, connectionMap$, localTransport$, audioOutputDeviceId$ } =
|
||||
setup();
|
||||
const { media, connectionMap$, audioOutputDeviceId$ } = setup();
|
||||
await media.setAudioOutputDeviceId("speaker");
|
||||
expect(audioOutputDeviceId$.value).toBe("speaker");
|
||||
|
||||
const { connection, room } = fakeConnection();
|
||||
connectionMap$.next(mapOf(connection));
|
||||
localTransport$.next(localTransport);
|
||||
await flushPromises();
|
||||
await media.setAudioOutputDeviceId("headset");
|
||||
|
||||
|
||||
@@ -40,7 +40,6 @@ import {
|
||||
type ObservableScope,
|
||||
} from "../../reactive/ObservableScope";
|
||||
import { type LocalMediaBackend, MediaConnectionState } from "../api";
|
||||
import { type TransportLocator } from "./auth";
|
||||
import { type Connection } from "./Connection";
|
||||
import { type ConnectionMap } from "./ConnectionMap";
|
||||
import {
|
||||
@@ -54,9 +53,8 @@ import { toMediaConnectionState } from "./connectionState";
|
||||
|
||||
interface Props {
|
||||
scope: ObservableScope;
|
||||
/** Holds the connection we publish on once the local transport is known. */
|
||||
connectionMap$: Behavior<Epoch<ConnectionMap>>;
|
||||
/** The transport we publish on; null until the session has found it. */
|
||||
localTransport$: Behavior<TransportLocator | null>;
|
||||
publish: PublishRequest[];
|
||||
/** Tracks the host captured ahead of the join; the publisher takes them over. */
|
||||
media?: LocalMedia;
|
||||
@@ -80,7 +78,6 @@ export interface LivekitLocalMedia extends LocalMediaBackend {
|
||||
export function createLivekitLocalMedia({
|
||||
scope,
|
||||
connectionMap$,
|
||||
localTransport$,
|
||||
publish: initialRequests,
|
||||
media,
|
||||
audioOutputDeviceId$,
|
||||
@@ -90,10 +87,8 @@ export function createLivekitLocalMedia({
|
||||
const logger = parentLogger.getChild("[LocalMedia]");
|
||||
|
||||
const connection$ = scope.behavior(
|
||||
combineLatest(
|
||||
[connectionMap$, localTransport$],
|
||||
({ value: connections }, transport) =>
|
||||
transport && connections.getConnectionForTransport(transport),
|
||||
connectionMap$.pipe(
|
||||
map(({ value: connections }) => connections.getPublisherConnection()),
|
||||
),
|
||||
);
|
||||
|
||||
|
||||
@@ -14,7 +14,6 @@ import {
|
||||
import { type CallMembershipIdentityParts } from "matrix-js-sdk/lib/matrixrtc/EncryptionManager";
|
||||
|
||||
import { serverNameOfTransport } from "../../utils/serverName";
|
||||
import { isCsApiUnavailable } from "./auth";
|
||||
import * as csApi from "./auth/csApi";
|
||||
import { decodeSFUJWTPayload } from "./auth/types";
|
||||
|
||||
@@ -90,7 +89,7 @@ export async function findRemotePublishLivekitTransport({
|
||||
continue;
|
||||
}
|
||||
} catch (e) {
|
||||
if (isCsApiUnavailable(e)) {
|
||||
if (csApi.isCsApiUnavailable(e)) {
|
||||
// Without the endpoint no further candidate can work
|
||||
logger.warn(
|
||||
`Cannot use the MSC4195 get_token endpoint (${e}), so no remote SFU can be used`,
|
||||
|
||||
@@ -5,7 +5,12 @@ SPDX-License-Identifier: AGPL-3.0-only OR LicenseRef-Element-Commercial
|
||||
Please see LICENSE in the repository root for full details.
|
||||
*/
|
||||
|
||||
import { ConnectionError, HTTPError, type MatrixClient } from "matrix-js-sdk";
|
||||
import {
|
||||
ConnectionError,
|
||||
HTTPError,
|
||||
type MatrixClient,
|
||||
MatrixError,
|
||||
} from "matrix-js-sdk";
|
||||
import { type CallMembershipIdentityParts } from "matrix-js-sdk/lib/matrixrtc/EncryptionManager";
|
||||
|
||||
import { doNetworkOperationWithRetry } from "../../../utils/network";
|
||||
@@ -20,6 +25,63 @@ function isNetworkError(e: unknown): boolean {
|
||||
return e instanceof HTTPError || e instanceof ConnectionError;
|
||||
}
|
||||
|
||||
/**
|
||||
* Whether an error means the homeserver does not implement the MSC4195
|
||||
* endpoints. Such a homeserver answers with whatever it uses for unknown
|
||||
* routes (Synapse: 404 with `M_UNRECOGNIZED`), so any 404 counts.
|
||||
*/
|
||||
export function isCsApiUnavailable(e: unknown): boolean {
|
||||
const answer = unwrapErrorDetails(e);
|
||||
return (
|
||||
answer !== undefined &&
|
||||
(answer.status === 404 ||
|
||||
answer.errcode === "M_NOT_FOUND" ||
|
||||
answer.errcode === "M_UNRECOGNIZED")
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Tries to unwrap the details from an unknown error object, regardless of whether
|
||||
* it came from the Widget API or not.
|
||||
*/
|
||||
function unwrapErrorDetails(
|
||||
e: unknown,
|
||||
): { status?: number; errcode?: string } | undefined {
|
||||
// If the error is an instance of `MatrixError`, take its details directly.
|
||||
if (e instanceof MatrixError) {
|
||||
return { status: e.httpStatus, errcode: e.errcode };
|
||||
}
|
||||
|
||||
// If the error originated from the widget API, try to extract the bundled
|
||||
// Matrix API error. We identify the widget's `WidgetApiResponseError` by
|
||||
// the shape of its payload to avoid making the SDK dependent on the widget
|
||||
// API. This isn't great, but we'll drop this branch anyway once we eliminate
|
||||
// usage of the widget API.
|
||||
if (e instanceof Error && "data" in e) {
|
||||
const relayed = (
|
||||
e as {
|
||||
data?: {
|
||||
matrix_api_error?: {
|
||||
http_status?: unknown;
|
||||
response?: { errcode?: unknown };
|
||||
};
|
||||
};
|
||||
}
|
||||
).data?.matrix_api_error;
|
||||
if (typeof relayed === "object" && relayed !== null) {
|
||||
const { http_status: status, response } = relayed;
|
||||
const errcode = response?.errcode;
|
||||
return {
|
||||
status: typeof status === "number" ? status : undefined,
|
||||
errcode: typeof errcode === "string" ? errcode : undefined,
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
// We're not able to extract any details from this error.
|
||||
return undefined;
|
||||
}
|
||||
|
||||
export type ClientGetTokenParts = Pick<MatrixClient, "getLivekitToken">;
|
||||
|
||||
export interface GetSFUConfigParams {
|
||||
|
||||
@@ -20,7 +20,13 @@ import {
|
||||
} from "../../../utils/test-fixtures";
|
||||
import type * as csApi from "./csApi";
|
||||
import type * as openID from "./openID";
|
||||
import { chooseAuthFlow, delegateDelayedLeave, getSFUConfig } from ".";
|
||||
import {
|
||||
type AuthFlow,
|
||||
authenticateWithTransport,
|
||||
chooseAuthFlow,
|
||||
delegateDelayedLeave,
|
||||
getSFUConfig,
|
||||
} from ".";
|
||||
|
||||
const aliceId = `${aliceUserId}:${aliceDeviceId}`;
|
||||
const csApiJWTToken = createJWTToken(aliceId, "via CS API");
|
||||
@@ -67,6 +73,9 @@ const urlAndServiceUrlTransport: UnstableLivekitTransport = {
|
||||
...serviceUrlTransport,
|
||||
};
|
||||
|
||||
const viaCsApi: AuthFlow = { kind: "csApi", url: "wss://livekit.example.org" };
|
||||
const viaOpenID: AuthFlow = { kind: "openID", serviceUrl };
|
||||
|
||||
/** The JWT service, answering each endpoint with a token that names it. */
|
||||
function mockJWTService(): void {
|
||||
fetchMock.post(`${serviceUrl}/sfu/get`, {
|
||||
@@ -100,11 +109,9 @@ describe("getSFUConfig", () => {
|
||||
logger,
|
||||
};
|
||||
|
||||
it("uses CS API with url transport", async () => {
|
||||
it("uses the CS API for the CS API flow", async () => {
|
||||
mockJWTService();
|
||||
expect(
|
||||
await getSFUConfig({ ...defaultParams, transport: urlTransport }),
|
||||
).toEqual(
|
||||
expect(await getSFUConfig({ ...defaultParams, flow: viaCsApi })).toEqual(
|
||||
expect.objectContaining({
|
||||
jwt: csApiJWTToken,
|
||||
livekitAlias: "via CS API",
|
||||
@@ -120,21 +127,19 @@ describe("getSFUConfig", () => {
|
||||
expect(jwtServiceCalls()).toEqual([]);
|
||||
});
|
||||
|
||||
it("does not fall back to OpenID with url transport", async () => {
|
||||
it("reports the CS API missing where the homeserver lacks the endpoint, without falling back", async () => {
|
||||
mockJWTService();
|
||||
client.getLivekitToken.mockRejectedValueOnce(unsupportedError);
|
||||
await expect(
|
||||
getSFUConfig({ ...defaultParams, transport: urlTransport }),
|
||||
getSFUConfig({ ...defaultParams, flow: viaCsApi }),
|
||||
).rejects.toThrow(expect.any(NoMatrix2AuthorizationService));
|
||||
expect(client.getLivekitToken).toHaveBeenCalled();
|
||||
expect(jwtServiceCalls()).toEqual([]);
|
||||
});
|
||||
|
||||
it("uses OpenID with livekit_service_url transport", async () => {
|
||||
it("uses the JWT service for the OpenID flow", async () => {
|
||||
mockJWTService();
|
||||
expect(
|
||||
await getSFUConfig({ ...defaultParams, transport: serviceUrlTransport }),
|
||||
).toEqual(
|
||||
expect(await getSFUConfig({ ...defaultParams, flow: viaOpenID })).toEqual(
|
||||
expect.objectContaining({
|
||||
jwt: defaultJWTToken,
|
||||
livekitAlias: "via default endpoint",
|
||||
@@ -144,80 +149,141 @@ describe("getSFUConfig", () => {
|
||||
expect(jwtServiceCalls()).toEqual(["/get_token"]);
|
||||
});
|
||||
|
||||
it("uses OpenID when subscribing with url + livekit_service_url transport", async () => {
|
||||
it("does not report the CS API missing where the homeserver refuses the request", async () => {
|
||||
mockJWTService();
|
||||
expect(
|
||||
await getSFUConfig({
|
||||
...defaultParams,
|
||||
transport: urlAndServiceUrlTransport,
|
||||
}),
|
||||
).toEqual(
|
||||
expect.objectContaining({
|
||||
jwt: defaultJWTToken,
|
||||
livekitAlias: "via default endpoint",
|
||||
}),
|
||||
);
|
||||
expect(client.getLivekitToken).not.toHaveBeenCalled();
|
||||
expect(jwtServiceCalls()).toEqual(["/get_token"]);
|
||||
});
|
||||
|
||||
it("surfaces the widget host's refusal with url transport", async () => {
|
||||
mockJWTService();
|
||||
const error = new Error(
|
||||
"The rtc_livekit_get_token action is not supported by the client.",
|
||||
);
|
||||
client.getLivekitToken.mockRejectedValueOnce(error);
|
||||
const forbidden = new MatrixError({ errcode: "M_FORBIDDEN" }, 403);
|
||||
client.getLivekitToken.mockRejectedValueOnce(forbidden);
|
||||
await expect(
|
||||
getSFUConfig({ ...defaultParams, transport: urlTransport }),
|
||||
).rejects.toThrow(error);
|
||||
getSFUConfig({ ...defaultParams, flow: viaCsApi }),
|
||||
).rejects.toThrow(forbidden);
|
||||
expect(jwtServiceCalls()).toEqual([]);
|
||||
});
|
||||
|
||||
it("uses CS API when publishing with url transport", async () => {
|
||||
it("reports the CS API missing for another homeserver's transport", async () => {
|
||||
mockJWTService();
|
||||
client.getLivekitToken.mockRejectedValueOnce(
|
||||
new MatrixError({ errcode: "M_UNRECOGNIZED" }, 404),
|
||||
);
|
||||
await expect(
|
||||
getSFUConfig({
|
||||
...defaultParams,
|
||||
serverName: "elsewhere.org",
|
||||
flow: viaCsApi,
|
||||
}),
|
||||
).rejects.toThrow(expect.any(NoMatrix2AuthorizationService));
|
||||
expect(jwtServiceCalls()).toEqual([]);
|
||||
});
|
||||
|
||||
it("reports the CS API missing where a widget host relays the homeserver's not found", async () => {
|
||||
mockJWTService();
|
||||
// The widget API's WidgetApiResponseError arrives in a minified build.
|
||||
const relayed = Object.assign(new Error("Unrecognized request"), {
|
||||
name: "n",
|
||||
data: {
|
||||
matrix_api_error: {
|
||||
http_status: 404,
|
||||
response: { errcode: "M_UNRECOGNIZED" },
|
||||
},
|
||||
},
|
||||
});
|
||||
client.getLivekitToken.mockRejectedValueOnce(relayed);
|
||||
await expect(
|
||||
getSFUConfig({ ...defaultParams, flow: viaCsApi }),
|
||||
).rejects.toThrow(expect.any(NoMatrix2AuthorizationService));
|
||||
expect(jwtServiceCalls()).toEqual([]);
|
||||
});
|
||||
|
||||
it.each([
|
||||
["a token that does not decode", { jwt: "not a token" }],
|
||||
["an error of our own", new TypeError("oops")],
|
||||
])("does not judge the CS API by %s", async (_what, outcome) => {
|
||||
mockJWTService();
|
||||
if (outcome instanceof Error)
|
||||
client.getLivekitToken.mockRejectedValueOnce(outcome);
|
||||
else client.getLivekitToken.mockResolvedValueOnce(outcome);
|
||||
await expect(
|
||||
getSFUConfig({ ...defaultParams, flow: viaCsApi }),
|
||||
).rejects.not.toBeInstanceOf(NoMatrix2AuthorizationService);
|
||||
expect(jwtServiceCalls()).toEqual([]);
|
||||
});
|
||||
|
||||
it("uses the CS API when publishing through the CS API flow", async () => {
|
||||
mockJWTService();
|
||||
expect(
|
||||
await getSFUConfig({
|
||||
...defaultParams,
|
||||
transport: urlTransport,
|
||||
flow: viaCsApi,
|
||||
role: "publisher",
|
||||
}),
|
||||
).toEqual(expect.objectContaining({ jwt: csApiJWTToken }));
|
||||
expect(client.getLivekitToken).toHaveBeenCalled();
|
||||
expect(jwtServiceCalls()).toEqual([]);
|
||||
});
|
||||
});
|
||||
|
||||
it("does not fall back to OpenID when publishing with url transport", async () => {
|
||||
describe("authenticateWithTransport", () => {
|
||||
const defaultParams = {
|
||||
client,
|
||||
membership,
|
||||
serverName: "example.org",
|
||||
role: "subscriber" as const,
|
||||
roomId,
|
||||
slotId,
|
||||
logger,
|
||||
};
|
||||
|
||||
it("uses CS API with url + livekit_service_url transport", async () => {
|
||||
mockJWTService();
|
||||
client.getLivekitToken.mockRejectedValueOnce(unsupportedError);
|
||||
await expect(
|
||||
getSFUConfig({
|
||||
expect(
|
||||
await authenticateWithTransport({
|
||||
...defaultParams,
|
||||
transport: urlTransport,
|
||||
role: "publisher",
|
||||
transport: urlAndServiceUrlTransport,
|
||||
}),
|
||||
).rejects.toThrow(expect.any(NoMatrix2AuthorizationService));
|
||||
expect(client.getLivekitToken).toHaveBeenCalled();
|
||||
).toEqual(expect.objectContaining({ jwt: csApiJWTToken }));
|
||||
expect(jwtServiceCalls()).toEqual([]);
|
||||
});
|
||||
|
||||
it("uses the legacy OpenID endpoint when publishing with url + livekit_service_url transport", async () => {
|
||||
it.each([
|
||||
["subscriber", "/get_token", defaultJWTToken],
|
||||
["publisher", "/sfu/get", legacyJWTToken],
|
||||
] as const)(
|
||||
"falls back to OpenID as %s where the homeserver lacks the endpoint",
|
||||
async (role, endpoint, jwt) => {
|
||||
mockJWTService();
|
||||
client.getLivekitToken.mockRejectedValueOnce(unsupportedError);
|
||||
expect(
|
||||
await authenticateWithTransport({
|
||||
...defaultParams,
|
||||
transport: urlAndServiceUrlTransport,
|
||||
role,
|
||||
}),
|
||||
).toEqual(expect.objectContaining({ jwt }));
|
||||
expect(client.getLivekitToken).toHaveBeenCalledTimes(1);
|
||||
expect(jwtServiceCalls()).toEqual([endpoint]);
|
||||
},
|
||||
);
|
||||
|
||||
it("does not fall back with url transport", async () => {
|
||||
mockJWTService();
|
||||
// Subscribers predating MSC4195 expect a legacy participant identity from
|
||||
// anyone advertising a membership, which only the JWT service assigns
|
||||
expect(
|
||||
await getSFUConfig({
|
||||
client.getLivekitToken.mockRejectedValueOnce(unsupportedError);
|
||||
await expect(
|
||||
authenticateWithTransport({ ...defaultParams, transport: urlTransport }),
|
||||
).rejects.toThrow(expect.any(NoMatrix2AuthorizationService));
|
||||
expect(client.getLivekitToken).toHaveBeenCalledTimes(1);
|
||||
expect(jwtServiceCalls()).toEqual([]);
|
||||
});
|
||||
|
||||
it("does not fall back where the homeserver refuses the request", async () => {
|
||||
mockJWTService();
|
||||
const forbidden = new MatrixError({ errcode: "M_FORBIDDEN" }, 403);
|
||||
client.getLivekitToken.mockRejectedValueOnce(forbidden);
|
||||
await expect(
|
||||
authenticateWithTransport({
|
||||
...defaultParams,
|
||||
transport: urlAndServiceUrlTransport,
|
||||
role: "publisher",
|
||||
}),
|
||||
).toEqual(
|
||||
expect.objectContaining({
|
||||
jwt: legacyJWTToken,
|
||||
livekitAlias: "via legacy endpoint",
|
||||
}),
|
||||
);
|
||||
expect(client.getLivekitToken).not.toHaveBeenCalled();
|
||||
expect(jwtServiceCalls()).toEqual(["/sfu/get"]);
|
||||
).rejects.toThrow(forbidden);
|
||||
expect(jwtServiceCalls()).toEqual([]);
|
||||
});
|
||||
});
|
||||
|
||||
@@ -242,9 +308,9 @@ describe("delegateDelayedLeave", () => {
|
||||
return { delay_id, delay_timeout, delay_cs_api_url };
|
||||
}
|
||||
|
||||
it("uses CS API with url transport", async () => {
|
||||
it("uses the CS API for the CS API flow", async () => {
|
||||
mockJWTService();
|
||||
await delegateDelayedLeave({ ...defaultParams, transport: urlTransport });
|
||||
await delegateDelayedLeave({ ...defaultParams, flow: viaCsApi });
|
||||
expect(client.delegateDelayedLeave).toHaveBeenCalledWith({
|
||||
url: urlTransport.url,
|
||||
room_id: roomId,
|
||||
@@ -255,37 +321,19 @@ describe("delegateDelayedLeave", () => {
|
||||
expect(jwtServiceCalls()).toEqual([]);
|
||||
});
|
||||
|
||||
it("does not fall back to OpenID with url transport", async () => {
|
||||
it("does not fall back to the JWT service from the CS API flow", async () => {
|
||||
mockJWTService();
|
||||
client.delegateDelayedLeave.mockRejectedValueOnce(unsupportedError);
|
||||
await expect(
|
||||
delegateDelayedLeave({ ...defaultParams, transport: urlTransport }),
|
||||
delegateDelayedLeave({ ...defaultParams, flow: viaCsApi }),
|
||||
).rejects.toThrow();
|
||||
expect(client.delegateDelayedLeave).toHaveBeenCalled();
|
||||
expect(jwtServiceCalls()).toEqual([]);
|
||||
});
|
||||
|
||||
it("uses OpenID with livekit_service_url transport", async () => {
|
||||
it("uses the JWT service for the OpenID flow", async () => {
|
||||
mockJWTService();
|
||||
await delegateDelayedLeave({
|
||||
...defaultParams,
|
||||
transport: serviceUrlTransport,
|
||||
});
|
||||
expect(client.delegateDelayedLeave).not.toHaveBeenCalled();
|
||||
expect(delegationViaJWTService()).toEqual({
|
||||
delay_id: "delay123",
|
||||
delay_timeout: 3_600_000,
|
||||
delay_cs_api_url: client.baseUrl,
|
||||
});
|
||||
});
|
||||
|
||||
it("uses OpenID with url + livekit_service_url transport", async () => {
|
||||
mockJWTService();
|
||||
// Must match the flow that got the token, so the identities line up
|
||||
await delegateDelayedLeave({
|
||||
...defaultParams,
|
||||
transport: urlAndServiceUrlTransport,
|
||||
});
|
||||
await delegateDelayedLeave({ ...defaultParams, flow: viaOpenID });
|
||||
expect(client.delegateDelayedLeave).not.toHaveBeenCalled();
|
||||
expect(delegationViaJWTService()).toEqual({
|
||||
delay_id: "delay123",
|
||||
@@ -297,21 +345,16 @@ describe("delegateDelayedLeave", () => {
|
||||
|
||||
describe("chooseAuthFlow", () => {
|
||||
it.each([
|
||||
["url", urlTransport, { kind: "csApi", url: urlTransport.url }],
|
||||
[
|
||||
"livekit_service_url",
|
||||
serviceUrlTransport,
|
||||
{ kind: "openID", serviceUrl },
|
||||
],
|
||||
[
|
||||
"url + livekit_service_url",
|
||||
urlAndServiceUrlTransport,
|
||||
{ kind: "openID", serviceUrl },
|
||||
],
|
||||
["url", urlTransport, true, viaCsApi],
|
||||
["url", urlTransport, false, viaCsApi],
|
||||
["livekit_service_url", serviceUrlTransport, true, viaOpenID],
|
||||
["livekit_service_url", serviceUrlTransport, false, viaOpenID],
|
||||
["url + livekit_service_url", urlAndServiceUrlTransport, true, viaCsApi],
|
||||
["url + livekit_service_url", urlAndServiceUrlTransport, false, viaOpenID],
|
||||
] as const)(
|
||||
"chooses the flow for a %s transport as %s",
|
||||
(_shape, transport, flow) => {
|
||||
expect(chooseAuthFlow(transport)).toEqual(flow);
|
||||
"chooses the flow for a %s transport with the CS API usable: %s",
|
||||
(_shape, transport, csApiUsable, flow) => {
|
||||
expect(chooseAuthFlow(transport, csApiUsable)).toEqual(flow);
|
||||
},
|
||||
);
|
||||
});
|
||||
|
||||
@@ -6,13 +6,9 @@ Please see LICENSE in the repository root for full details.
|
||||
*/
|
||||
|
||||
/**
|
||||
* Authentication with a LiveKit transport: the MSC4195 client-server API
|
||||
* through our homeserver for a transport with an SFU `url`, the OpenID flow
|
||||
* against the JWT service for one with a `livekit_service_url`, and the
|
||||
* choice between them where a transport carries both.
|
||||
* Authentication with a LiveKit transport.
|
||||
*/
|
||||
|
||||
import { ConnectionError, MatrixError } from "matrix-js-sdk";
|
||||
import { type Logger } from "matrix-js-sdk/lib/logger";
|
||||
import { type UnstableLivekitTransport } from "matrix-js-sdk/lib/matrixrtc";
|
||||
import { type CallMembershipIdentityParts } from "matrix-js-sdk/lib/matrixrtc/EncryptionManager";
|
||||
@@ -26,37 +22,11 @@ export type { ClientOpenIDParts } from "./openID";
|
||||
export type { ClientGetTokenParts, ClientDelegationParts } from "./csApi";
|
||||
export type * from "./types";
|
||||
|
||||
/**
|
||||
* Whether an error means the homeserver does not implement the MSC4195
|
||||
* endpoints. The MSC says `M_NOT_FOUND`; a homeserver without support answers
|
||||
* with whatever it uses for unknown routes (Synapse: 404 with
|
||||
* `M_UNRECOGNIZED`), so any 404 counts.
|
||||
*/
|
||||
function isEndpointUnsupported(e: unknown): boolean {
|
||||
return (
|
||||
e instanceof MatrixError &&
|
||||
(e.httpStatus === 404 ||
|
||||
e.errcode === "M_NOT_FOUND" ||
|
||||
e.errcode === "M_UNRECOGNIZED")
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Whether an error means the MSC4195 client-server API cannot be used from
|
||||
* here: the homeserver does not implement it, or the request never reached
|
||||
* the homeserver because a widget host does not expose the endpoint
|
||||
* (MSC4533), which the widget API reports as a plain error. A connection
|
||||
* error is neither: the endpoint may well exist.
|
||||
*/
|
||||
export function isCsApiUnavailable(e: unknown): boolean {
|
||||
if (isEndpointUnsupported(e)) return true;
|
||||
return !(e instanceof MatrixError) && !(e instanceof ConnectionError);
|
||||
}
|
||||
|
||||
export interface GetSFUConfigParams {
|
||||
client: csApi.ClientGetTokenParts & openID.ClientOpenIDParts;
|
||||
membership: CallMembershipIdentityParts;
|
||||
transport: UnstableLivekitTransport;
|
||||
/** The flow to authenticate with, as chosen by {@link chooseAuthFlow}. */
|
||||
flow: AuthFlow;
|
||||
/** The homeserver the transport belongs to. */
|
||||
serverName: string;
|
||||
roomId: string;
|
||||
@@ -66,20 +36,22 @@ export interface GetSFUConfigParams {
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets an {@link SFUConfig} appropriate for connecting to a given transport,
|
||||
* using whichever auth flow is appropriate.
|
||||
* Gets an {@link SFUConfig} for connecting to a transport through the given
|
||||
* auth flow.
|
||||
*
|
||||
* @throws {@link NoMatrix2AuthorizationService} if the client-server API flow
|
||||
* finds the API missing.
|
||||
*/
|
||||
export async function getSFUConfig({
|
||||
client,
|
||||
membership,
|
||||
transport,
|
||||
flow,
|
||||
serverName,
|
||||
roomId,
|
||||
slotId,
|
||||
role,
|
||||
logger,
|
||||
}: GetSFUConfigParams): Promise<SFUConfig> {
|
||||
const flow = chooseAuthFlow(transport);
|
||||
if (flow.kind === "openID") {
|
||||
return await openID.getSFUConfig({
|
||||
client,
|
||||
@@ -101,10 +73,14 @@ export async function getSFUConfig({
|
||||
slotId,
|
||||
});
|
||||
} catch (e) {
|
||||
if (isEndpointUnsupported(e)) {
|
||||
logger.error(
|
||||
if (csApi.isCsApiUnavailable(e)) {
|
||||
logger.warn(
|
||||
`Homeserver does not support the MSC4195 get_token endpoint, cannot get token for transport ${flow.url}`,
|
||||
);
|
||||
// This is our own homeserver's answer. as per MSC4195, only 403 /
|
||||
// M_FORBIDDEN and 400 / M_INVALID_PARAM are forwarded from the remote
|
||||
// server. Any other remote error becomes 502 / M_UNKNOWN on the
|
||||
// client-server API.
|
||||
throw new NoMatrix2AuthorizationService(e as Error);
|
||||
}
|
||||
throw e;
|
||||
@@ -112,11 +88,40 @@ export async function getSFUConfig({
|
||||
}
|
||||
}
|
||||
|
||||
export type AuthenticateWithTransportParams = Omit<
|
||||
GetSFUConfigParams,
|
||||
"flow"
|
||||
> & { transport: UnstableLivekitTransport };
|
||||
|
||||
/**
|
||||
* Authenticates with a transport once, outside any session. This automatically
|
||||
* falls back from the client-server API flow to the OpenID flow if needed and
|
||||
* possible.
|
||||
*
|
||||
* @throws {@link NoMatrix2AuthorizationService} if the client-server API is missing
|
||||
* but the transport does not allow falling back to the OpenID flow.
|
||||
*/
|
||||
export async function authenticateWithTransport({
|
||||
transport,
|
||||
...params
|
||||
}: AuthenticateWithTransportParams): Promise<SFUConfig> {
|
||||
try {
|
||||
const flow = chooseAuthFlow(transport, true);
|
||||
return await getSFUConfig({ ...params, flow });
|
||||
} catch (e) {
|
||||
const flow = chooseAuthFlow(transport, false);
|
||||
// Nothing else to try unless the API is missing and there is a JWT service
|
||||
if (!(e instanceof NoMatrix2AuthorizationService) || flow.kind !== "openID")
|
||||
throw e;
|
||||
return await getSFUConfig({ ...params, flow });
|
||||
}
|
||||
}
|
||||
|
||||
export interface DelegateDelayedLeaveParams {
|
||||
client: csApi.ClientDelegationParts & openID.ClientOpenIDParts;
|
||||
membership: CallMembershipIdentityParts;
|
||||
/** The transport we publish on. */
|
||||
transport: UnstableLivekitTransport;
|
||||
/** The flow that issued the token we publish with. */
|
||||
flow: AuthFlow;
|
||||
roomId: string;
|
||||
slotId: string;
|
||||
delayId: string;
|
||||
@@ -133,14 +138,13 @@ export interface DelegateDelayedLeaveParams {
|
||||
export async function delegateDelayedLeave({
|
||||
client,
|
||||
membership,
|
||||
transport,
|
||||
flow,
|
||||
roomId,
|
||||
slotId,
|
||||
delayId,
|
||||
delayTimeoutMs,
|
||||
logger,
|
||||
}: DelegateDelayedLeaveParams): Promise<void> {
|
||||
const flow = chooseAuthFlow(transport);
|
||||
if (flow.kind === "csApi") {
|
||||
try {
|
||||
await csApi.delegateDelayedLeave({
|
||||
@@ -152,7 +156,7 @@ export async function delegateDelayedLeave({
|
||||
delayId,
|
||||
});
|
||||
} catch (e) {
|
||||
if (isEndpointUnsupported(e))
|
||||
if (csApi.isCsApiUnavailable(e))
|
||||
logger.error(
|
||||
"Server misconfigured: transport contains a 'url' field but server does not support the MSC4195 delegate_delayed_leave endpoint",
|
||||
);
|
||||
@@ -181,18 +185,21 @@ export type AuthFlow =
|
||||
| { kind: "openID"; serviceUrl: string };
|
||||
|
||||
/**
|
||||
* Chooses which auth flow to use for a given transport. For now this returns a
|
||||
* single auth flow, with no provision for a fallback behavior.
|
||||
* Chooses which auth flow to use for a given transport.
|
||||
*/
|
||||
export function chooseAuthFlow(transport: UnstableLivekitTransport): AuthFlow {
|
||||
export function chooseAuthFlow(
|
||||
transport: UnstableLivekitTransport,
|
||||
csApiUsable: boolean,
|
||||
): AuthFlow {
|
||||
// If we only have url, we have no choice but to use the CS API.
|
||||
if ("url" in transport && !("livekit_service_url" in transport))
|
||||
return { kind: "csApi", url: transport.url };
|
||||
// All other transports use the OpenID flow, even if they contain a `url`.
|
||||
// This is necessary since the auth flow determines the participant identity
|
||||
// format, and we still have older clients out in the wild which would not yet
|
||||
// know to look for a hashed participant identity in case `url` is present in
|
||||
// someone else's transport.
|
||||
// TODO: Once users have updated their clients, choose the CS API flow if
|
||||
// available, keeping OpenID as a fallback.
|
||||
|
||||
// If we have both url and livekit_service_url, prefer the CS API if it is usable.
|
||||
if ("url" in transport && csApiUsable)
|
||||
return { kind: "csApi", url: transport.url };
|
||||
|
||||
// If the CS API is not usable or we only have livekit_service_url, fall back
|
||||
// to using the OpenID flow.
|
||||
return { kind: "openID", serviceUrl: transport.livekit_service_url };
|
||||
}
|
||||
|
||||
@@ -0,0 +1,68 @@
|
||||
/*
|
||||
Copyright 2026 Element Creations Ltd.
|
||||
|
||||
SPDX-License-Identifier: AGPL-3.0-only OR LicenseRef-Element-Commercial
|
||||
Please see LICENSE in the repository root for full details.
|
||||
*/
|
||||
|
||||
.popover {
|
||||
position: relative;
|
||||
border-radius: var(--cpd-space-3x);
|
||||
background: var(--cpd-color-bg-canvas-default);
|
||||
box-shadow: var(--big-drop-shadow);
|
||||
padding: var(--cpd-space-5x);
|
||||
box-sizing: border-box;
|
||||
inline-size: 310px;
|
||||
max-inline-size: 90vw;
|
||||
|
||||
/* Draw an internal border */
|
||||
&::after {
|
||||
content: "";
|
||||
position: absolute;
|
||||
inset: 0;
|
||||
border: var(--cpd-border-width-1) solid
|
||||
var(--cpd-color-border-interactive-secondary);
|
||||
border-radius: inherit;
|
||||
pointer-events: none;
|
||||
}
|
||||
|
||||
transition:
|
||||
opacity 180ms,
|
||||
transform 180ms;
|
||||
|
||||
&[data-starting-style] {
|
||||
opacity: 0;
|
||||
@media (prefers-reduced-motion: no-preference) {
|
||||
transform: translate(0, var(--cpd-space-3x));
|
||||
}
|
||||
}
|
||||
|
||||
&[data-ending-style] {
|
||||
transition-duration: 110ms;
|
||||
opacity: 0;
|
||||
@media (prefers-reduced-motion: no-preference) {
|
||||
transform: translate(0, var(--cpd-space-2x));
|
||||
}
|
||||
}
|
||||
|
||||
p {
|
||||
font: var(--cpd-font-body-sm-regular);
|
||||
color: var(--cpd-color-text-secondary);
|
||||
margin-block-end: var(--cpd-space-4x);
|
||||
}
|
||||
}
|
||||
|
||||
.title {
|
||||
width: 100%;
|
||||
display: flex;
|
||||
|
||||
> h3 {
|
||||
margin-block-end: var(--cpd-space-2x);
|
||||
flex-grow: 1;
|
||||
}
|
||||
|
||||
> button {
|
||||
margin-block-start: calc(-1 * var(--cpd-space-1x));
|
||||
margin-inline-end: calc(-1 * var(--cpd-space-1x));
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,41 @@
|
||||
/*
|
||||
Copyright 2026 Element Creations Ltd.
|
||||
|
||||
SPDX-License-Identifier: AGPL-3.0-only OR LicenseRef-Element-Commercial
|
||||
Please see LICENSE in the repository root for full details.
|
||||
*/
|
||||
|
||||
import type { Meta, StoryObj } from "@storybook/react-vite";
|
||||
import { Popover } from "./Popover";
|
||||
import { Button } from "@vector-im/compound-web";
|
||||
import { VideoCallOffSolidIcon } from "@vector-im/compound-design-tokens/assets/web/icons";
|
||||
import { useState } from "react";
|
||||
|
||||
const meta = {
|
||||
component: Popover,
|
||||
} satisfies Meta<typeof Popover>;
|
||||
|
||||
export default meta;
|
||||
|
||||
export const Default: StoryObj = {
|
||||
render: () => {
|
||||
const [open, setOpen] = useState(true);
|
||||
return (
|
||||
<Popover
|
||||
title="Poor connection"
|
||||
trigger={<Button>Open popover</Button>}
|
||||
open={open}
|
||||
onOpenChange={setOpen}
|
||||
>
|
||||
<p>Turn off all videos to improve call performance.</p>
|
||||
<Button
|
||||
size="md"
|
||||
Icon={VideoCallOffSolidIcon}
|
||||
style={{ width: "100%", marginBlockStart: 24 }}
|
||||
>
|
||||
Turn off all videos
|
||||
</Button>
|
||||
</Popover>
|
||||
);
|
||||
},
|
||||
};
|
||||
@@ -0,0 +1,30 @@
|
||||
/*
|
||||
Copyright 2026 Element Creations Ltd.
|
||||
|
||||
SPDX-License-Identifier: AGPL-3.0-only OR LicenseRef-Element-Commercial
|
||||
Please see LICENSE in the repository root for full details.
|
||||
*/
|
||||
|
||||
import { expect, test } from "vitest";
|
||||
import { axe } from "vitest-axe";
|
||||
import { render, screen } from "@testing-library/react";
|
||||
|
||||
import { Popover } from "./Popover";
|
||||
|
||||
test("Popover renders", async () => {
|
||||
render(
|
||||
<Popover
|
||||
title="Example"
|
||||
trigger={<button>Open popover</button>}
|
||||
open
|
||||
onOpenChange={() => {}}
|
||||
>
|
||||
<p>This is an example of a popover.</p>
|
||||
</Popover>,
|
||||
);
|
||||
const button = screen.getByRole("button", { name: "Open popover" });
|
||||
const popover = screen.getByRole("dialog", { name: "Example" });
|
||||
expect(button).toMatchSnapshot("button");
|
||||
expect(popover).toMatchSnapshot("popover");
|
||||
expect(await axe(document.body)).toHaveNoViolations();
|
||||
});
|
||||
+104
@@ -0,0 +1,104 @@
|
||||
/*
|
||||
Copyright 2026 Element Creations Ltd.
|
||||
|
||||
SPDX-License-Identifier: AGPL-3.0-only OR LicenseRef-Element-Commercial
|
||||
Please see LICENSE in the repository root for full details.
|
||||
*/
|
||||
|
||||
import { type FC, type ReactElement, type ReactNode } from "react";
|
||||
import { Popover as BUIPopover } from "@base-ui/react/popover";
|
||||
|
||||
import styles from "./Popover.module.css";
|
||||
import { Heading, IconButton } from "@vector-im/compound-web";
|
||||
import { CloseIcon } from "@vector-im/compound-design-tokens/assets/web/icons";
|
||||
import classNames from "classnames";
|
||||
import { useRootElement } from "./RootElementContext";
|
||||
import { useTranslation } from "react-i18next";
|
||||
|
||||
export interface PopoverProps {
|
||||
/**
|
||||
* The popover title.
|
||||
*/
|
||||
title: string;
|
||||
/**
|
||||
* The button that opens the popover. This must be a component that accepts a
|
||||
* ref and spreads props.
|
||||
*
|
||||
* https://base-ui.com/react/handbook/composition
|
||||
*/
|
||||
trigger: ReactElement;
|
||||
/**
|
||||
* Whether the popover is open.
|
||||
*/
|
||||
open: boolean;
|
||||
/**
|
||||
* Event handler called when the user tries to open or close the popover.
|
||||
*/
|
||||
onOpenChange: (open: boolean) => void;
|
||||
/**
|
||||
* The popover contents.
|
||||
*/
|
||||
children: ReactNode;
|
||||
className?: string;
|
||||
/**
|
||||
* The side of the trigger on which to place the popover. Note that the menu
|
||||
* may still end up on a different side than the one you request if there
|
||||
* isn't enough space.
|
||||
* @default bottom
|
||||
*/
|
||||
side?: "top" | "bottom" | "left" | "right" | "inline-end" | "inline-start";
|
||||
/**
|
||||
* The edge along which the popover and trigger will be aligned.
|
||||
* @default center
|
||||
*/
|
||||
align?: "start" | "center" | "end";
|
||||
}
|
||||
|
||||
/**
|
||||
* A popover opened by pressing a button.
|
||||
*/
|
||||
export const Popover: FC<PopoverProps> = ({
|
||||
title,
|
||||
trigger,
|
||||
open,
|
||||
onOpenChange,
|
||||
children,
|
||||
className,
|
||||
side,
|
||||
align,
|
||||
}) => {
|
||||
const { t } = useTranslation();
|
||||
const rootElement = useRootElement();
|
||||
return (
|
||||
<BUIPopover.Root open={open} onOpenChange={onOpenChange}>
|
||||
<BUIPopover.Trigger render={trigger} />
|
||||
<BUIPopover.Portal container={rootElement}>
|
||||
<BUIPopover.Positioner sideOffset={8} side={side} align={align}>
|
||||
<BUIPopover.Popup className={classNames(styles.popover, className)}>
|
||||
<div className={styles.title}>
|
||||
<BUIPopover.Title
|
||||
render={
|
||||
<Heading as="h3" type="body" weight="semibold" size="lg">
|
||||
{title}
|
||||
</Heading>
|
||||
}
|
||||
/>
|
||||
<BUIPopover.Close
|
||||
render={
|
||||
<IconButton
|
||||
kind="secondary"
|
||||
size="28px"
|
||||
aria-label={t("action.close")}
|
||||
>
|
||||
<CloseIcon />
|
||||
</IconButton>
|
||||
}
|
||||
/>
|
||||
</div>
|
||||
{children}
|
||||
</BUIPopover.Popup>
|
||||
</BUIPopover.Positioner>
|
||||
</BUIPopover.Portal>
|
||||
</BUIPopover.Root>
|
||||
);
|
||||
};
|
||||
@@ -41,6 +41,7 @@ export enum UserIntent {
|
||||
StartNewCallDMVoice = "start_call_dm_voice",
|
||||
JoinExistingCallDM = "join_existing_dm",
|
||||
JoinExistingCallDMVoice = "join_existing_dm_voice",
|
||||
VideoRoom = "video_room",
|
||||
Unknown = "unknown",
|
||||
}
|
||||
|
||||
@@ -143,6 +144,18 @@ export interface UrlConfiguration {
|
||||
* Defaults to true.
|
||||
*/
|
||||
noiseSuppression?: boolean;
|
||||
/**
|
||||
* Whether the user may start with the microphone on, whether or not the
|
||||
* lobby is shown. Set by the intent, not a URL parameter.
|
||||
* Defaults to true.
|
||||
*/
|
||||
initialAudioEnabled?: boolean;
|
||||
/**
|
||||
* Whether the user may start with the camera on, whether or not the lobby is
|
||||
* shown. Set by the intent, not a URL parameter.
|
||||
* Defaults to true.
|
||||
*/
|
||||
initialVideoEnabled?: boolean;
|
||||
|
||||
callIntent?: RTCCallIntent;
|
||||
}
|
||||
@@ -222,6 +235,14 @@ export function configurationForIntent(intent: UserIntent): UrlConfiguration {
|
||||
preset.autoLeaveWhenOthersLeft = true;
|
||||
preset.callIntent = preset.callIntent ?? RTC_CALL_INTENT_VIDEO;
|
||||
break;
|
||||
case UserIntent.VideoRoom:
|
||||
preset.skipLobby = false;
|
||||
preset.returnToLobby = true;
|
||||
preset.callIntent = RTC_CALL_INTENT_VIDEO;
|
||||
// Opening the room should not turn on the user's microphone or camera.
|
||||
preset.initialAudioEnabled = false;
|
||||
preset.initialVideoEnabled = false;
|
||||
break;
|
||||
// Non widget usecase defaults
|
||||
default:
|
||||
preset = {
|
||||
|
||||
@@ -318,6 +318,20 @@ describe("UrlParams", () => {
|
||||
).toMatchObject(joinExistingCallDefaults("desktop"));
|
||||
});
|
||||
|
||||
it("accepts video_room", () => {
|
||||
expect(
|
||||
computeUrlParams(
|
||||
"?intent=video_room&widgetId=1234&parentUrl=parent.org",
|
||||
),
|
||||
).toMatchObject({
|
||||
...joinExistingCallDefaults("desktop"),
|
||||
returnToLobby: true,
|
||||
callIntent: RTC_CALL_INTENT_VIDEO,
|
||||
initialAudioEnabled: false,
|
||||
initialVideoEnabled: false,
|
||||
});
|
||||
});
|
||||
|
||||
it("accepts start_call_voice", () => {
|
||||
expect(
|
||||
computeUrlParams(
|
||||
@@ -408,6 +422,19 @@ describe("UrlParams", () => {
|
||||
});
|
||||
});
|
||||
|
||||
describe.each(["initialAudioEnabled", "initialVideoEnabled"] as const)(
|
||||
"%s",
|
||||
(name) => {
|
||||
it("is not read from the URL", () => {
|
||||
expect(
|
||||
computeUrlParams(
|
||||
`?${name}=false&intent=join_existing&widgetId=1234&parentUrl=parent.org`,
|
||||
)[name],
|
||||
).toBeUndefined();
|
||||
});
|
||||
},
|
||||
);
|
||||
|
||||
describe("noiseSuppression", () => {
|
||||
it("defaults to true", () => {
|
||||
expect(computeUrlParams().noiseSuppression).toBe(true);
|
||||
|
||||
@@ -61,7 +61,7 @@ exports[`the modal renders as a drawer in mobile viewports 1`] = `
|
||||
/>
|
||||
<h2
|
||||
id="radix-_r_a_"
|
||||
style="position: absolute; border: 0px; width: 1px; height: 1px; padding: 0px; margin: -1px; overflow: hidden; clip: rect(0px, 0px, 0px, 0px); white-space: nowrap; word-wrap: normal;"
|
||||
style="position: absolute; border: 0px; width: 1px; height: 1px; padding: 0px; margin: -1px; overflow: hidden; clip: rect(0px, 0px, 0px, 0px); white-space: nowrap; overflow-wrap: normal;"
|
||||
>
|
||||
My modal
|
||||
</h2>
|
||||
|
||||
@@ -0,0 +1,71 @@
|
||||
// Vitest Snapshot v1, https://vitest.dev/guide/snapshot.html
|
||||
|
||||
exports[`Popover renders > button 1`] = `
|
||||
<button
|
||||
aria-controls="_r_0_"
|
||||
aria-expanded="true"
|
||||
aria-haspopup="dialog"
|
||||
data-base-ui-click-trigger=""
|
||||
data-popup-open=""
|
||||
id="base-ui-_r_1_"
|
||||
tabindex="0"
|
||||
type="button"
|
||||
>
|
||||
Open popover
|
||||
</button>
|
||||
`;
|
||||
|
||||
exports[`Popover renders > popover 1`] = `
|
||||
<div
|
||||
aria-labelledby="base-ui-_r_4_"
|
||||
class="_popover_8e8188"
|
||||
data-align="center"
|
||||
data-base-ui-focusable=""
|
||||
data-open=""
|
||||
data-side="bottom"
|
||||
id="_r_0_"
|
||||
role="dialog"
|
||||
tabindex="-1"
|
||||
>
|
||||
<div
|
||||
class="_title_8e8188"
|
||||
>
|
||||
<h3
|
||||
class="_typography_6v6n8_153 _font-body-lg-semibold_6v6n8_74"
|
||||
id="base-ui-_r_4_"
|
||||
>
|
||||
Example
|
||||
</h3>
|
||||
<button
|
||||
aria-disabled="false"
|
||||
aria-label="Close"
|
||||
class="_icon-button_1215g_8"
|
||||
data-kind="secondary"
|
||||
role="button"
|
||||
style="--cpd-icon-button-size: 28px;"
|
||||
tabindex="0"
|
||||
type="button"
|
||||
>
|
||||
<div
|
||||
class="_indicator-icon_j097f_17"
|
||||
style="--cpd-icon-button-size: 100%;"
|
||||
>
|
||||
<svg
|
||||
fill="currentColor"
|
||||
height="1em"
|
||||
viewBox="0 0 24 24"
|
||||
width="1em"
|
||||
xmlns="http://www.w3.org/2000/svg"
|
||||
>
|
||||
<path
|
||||
d="M6.293 6.293a1 1 0 0 1 1.414 0L12 10.586l4.293-4.293a1 1 0 1 1 1.414 1.414L13.414 12l4.293 4.293a1 1 0 0 1-1.414 1.414L12 13.414l-4.293 4.293a1 1 0 0 1-1.414-1.414L10.586 12 6.293 7.707a1 1 0 0 1 0-1.414"
|
||||
/>
|
||||
</svg>
|
||||
</div>
|
||||
</button>
|
||||
</div>
|
||||
<p>
|
||||
This is an example of a popover.
|
||||
</p>
|
||||
</div>
|
||||
`;
|
||||
+31
-32
@@ -25,11 +25,14 @@ import {
|
||||
OverflowVerticalIcon,
|
||||
VolumeOnSolidIcon,
|
||||
VolumeOffSolidIcon,
|
||||
SettingsSolidIcon,
|
||||
GridIcon,
|
||||
SpotlightViewIcon,
|
||||
} from "@vector-im/compound-design-tokens/assets/web/icons";
|
||||
|
||||
import styles from "./Button.module.css";
|
||||
import callFooterStyles from "../components/CallFooter.module.css";
|
||||
import { platform } from "../Platform";
|
||||
import { type LayoutMode } from "../state/LayoutSwitchViewModel";
|
||||
|
||||
interface MicButtonProps extends ComponentPropsWithoutRef<"button"> {
|
||||
enabled: boolean;
|
||||
@@ -149,6 +152,7 @@ interface LoudspeakerButtonProps extends ComponentPropsWithoutRef<"button"> {
|
||||
size?: "md" | "lg";
|
||||
loudspeakerModeEnabled: boolean;
|
||||
}
|
||||
|
||||
export const LoudspeakerButton: FC<LoudspeakerButtonProps> = ({
|
||||
loudspeakerModeEnabled,
|
||||
...props
|
||||
@@ -171,36 +175,37 @@ export const LoudspeakerButton: FC<LoudspeakerButtonProps> = ({
|
||||
);
|
||||
};
|
||||
|
||||
function classNamesForScreenWidth(
|
||||
className?: string,
|
||||
forScreenWidth?: "wide" | "narrow",
|
||||
): string {
|
||||
return classNames(className, {
|
||||
[callFooterStyles.settingsOnlyShowWide]: forScreenWidth === "wide",
|
||||
[callFooterStyles.settingsOnlyShowNarrow]: forScreenWidth === "narrow",
|
||||
});
|
||||
interface LayoutSwitchButtonProps extends ComponentPropsWithoutRef<"button"> {
|
||||
layout: LayoutMode;
|
||||
}
|
||||
|
||||
interface SettingsIconButtonProps extends ComponentPropsWithoutRef<"button"> {
|
||||
/** If this buttons should be setup to be used in the app bar */
|
||||
showForScreenWidth?: "wide" | "narrow";
|
||||
kind?: "secondary" | "primary";
|
||||
}
|
||||
export const SettingsIconButton: FC<SettingsIconButtonProps> = ({
|
||||
showForScreenWidth,
|
||||
className,
|
||||
export const LayoutSwitchButton: FC<LayoutSwitchButtonProps> = ({
|
||||
layout,
|
||||
...props
|
||||
}) => {
|
||||
const { t } = useTranslation();
|
||||
const Icon =
|
||||
platform === "android" ? OverflowVerticalIcon : OverflowHorizontalIcon;
|
||||
return (
|
||||
<Tooltip label={t("action.adjust_view")}>
|
||||
<CpdButton
|
||||
iconOnly
|
||||
Icon={layout === "grid" ? GridIcon : SpotlightViewIcon}
|
||||
kind="secondary"
|
||||
{...props}
|
||||
/>
|
||||
</Tooltip>
|
||||
);
|
||||
};
|
||||
|
||||
interface SettingsIconButtonProps extends ComponentPropsWithoutRef<"button"> {
|
||||
kind?: "secondary" | "primary";
|
||||
}
|
||||
|
||||
export const SettingsIconButton: FC<SettingsIconButtonProps> = (props) => {
|
||||
const { t } = useTranslation();
|
||||
return (
|
||||
<Tooltip label={t("common.settings")}>
|
||||
<IconButton
|
||||
className={classNamesForScreenWidth(className, showForScreenWidth)}
|
||||
{...props}
|
||||
>
|
||||
<Icon aria-hidden />
|
||||
<IconButton {...props}>
|
||||
<SettingsSolidIcon aria-hidden />
|
||||
</IconButton>
|
||||
</Tooltip>
|
||||
);
|
||||
@@ -208,19 +213,13 @@ export const SettingsIconButton: FC<SettingsIconButtonProps> = ({
|
||||
|
||||
interface SettingsButtonProps extends ComponentPropsWithoutRef<"button"> {
|
||||
size?: "md" | "lg";
|
||||
/** If this buttons should be setup to be used in the app bar */
|
||||
showForScreenWidth?: "wide" | "narrow";
|
||||
}
|
||||
export const SettingsButton: FC<SettingsButtonProps> = ({
|
||||
showForScreenWidth,
|
||||
className,
|
||||
...props
|
||||
}) => {
|
||||
|
||||
export const SettingsButton: FC<SettingsButtonProps> = (props) => {
|
||||
const { t } = useTranslation();
|
||||
return (
|
||||
<Tooltip label={t("common.settings")}>
|
||||
<CpdButton
|
||||
className={classNamesForScreenWidth(className, showForScreenWidth)}
|
||||
iconOnly
|
||||
Icon={
|
||||
platform === "android" ? OverflowVerticalIcon : OverflowHorizontalIcon
|
||||
|
||||
@@ -112,7 +112,6 @@ export const BackgroundEffectGrid: FC<Props> = ({
|
||||
disabled={disabled}
|
||||
data-disabled={disabled ? "" : undefined}
|
||||
label={null}
|
||||
hideChevron
|
||||
className={styles.tile}
|
||||
// Without a handler it isn't one of the menu's items, so the keyboard
|
||||
// passes over it.
|
||||
@@ -160,7 +159,6 @@ export const BackgroundEffectGrid: FC<Props> = ({
|
||||
onAdd === undefined ? null : (
|
||||
<MenuItem
|
||||
label={null}
|
||||
hideChevron
|
||||
className={styles.tile}
|
||||
onSelect={(e) => {
|
||||
e.preventDefault();
|
||||
|
||||
@@ -24,7 +24,7 @@ import * as CallFooterStories from "./CallFooter.stories";
|
||||
|
||||
<Title> Call Footer </Title>
|
||||
|
||||
The footer compoentn contains all main interactions needed for a call.
|
||||
The footer component contains all main interactions needed for a call.
|
||||
|
||||
<Subtitle> Mobile layouts </Subtitle>
|
||||
|
||||
|
||||
@@ -9,9 +9,10 @@ Please see LICENSE in the repository root for full details.
|
||||
position: sticky;
|
||||
inset-block-end: 0;
|
||||
z-index: var(--call-view-header-footer-layer);
|
||||
pointer-events: none;
|
||||
display: grid;
|
||||
grid-template-columns: 1fr auto 1fr;
|
||||
grid-template-areas: ". buttons layout";
|
||||
grid-template-areas: ". buttons .";
|
||||
align-items: center;
|
||||
gap: var(--cpd-space-3x);
|
||||
/* Ensure that footer lies within the safe area */
|
||||
@@ -19,6 +20,10 @@ Please see LICENSE in the repository root for full details.
|
||||
padding-right: calc(env(safe-area-inset-right) + var(--cpd-space-6x));
|
||||
padding-block: var(--cpd-space-10x)
|
||||
calc(env(safe-area-inset-bottom) + var(--cpd-space-10x));
|
||||
|
||||
> * {
|
||||
pointer-events: auto;
|
||||
}
|
||||
}
|
||||
|
||||
.footer.hidden {
|
||||
@@ -26,21 +31,57 @@ Please see LICENSE in the repository root for full details.
|
||||
}
|
||||
|
||||
.footer.overlay {
|
||||
transition: opacity 0.18s;
|
||||
opacity: 0;
|
||||
|
||||
> .buttons {
|
||||
transition: transform 0.18s;
|
||||
@media (prefers-reduced-motion: no-preference) {
|
||||
transform: translateY(var(--slide-distance));
|
||||
}
|
||||
}
|
||||
|
||||
> * {
|
||||
animation: none;
|
||||
}
|
||||
}
|
||||
|
||||
@keyframes enable-pointer-events {
|
||||
0% {
|
||||
pointer-events: none;
|
||||
}
|
||||
100% {
|
||||
pointer-events: auto;
|
||||
}
|
||||
}
|
||||
|
||||
.footer.overlay:not(.hidden) {
|
||||
/* Note that the footer is still position: sticky in this case so that certain
|
||||
tiles can move up out of the way of the footer when visible. */
|
||||
opacity: 1;
|
||||
transition: opacity 0.15s;
|
||||
|
||||
> .buttons {
|
||||
transform: none;
|
||||
}
|
||||
|
||||
> * {
|
||||
/* Enable pointer events after a short timeout, so that tapping to reveal the
|
||||
footer won't immediately cause any of the buttons to be pressed. */
|
||||
animation: enable-pointer-events 1ms;
|
||||
}
|
||||
}
|
||||
|
||||
.footer.overlay.hidden {
|
||||
display: grid;
|
||||
opacity: 0;
|
||||
pointer-events: none;
|
||||
/* Switch to position: absolute so the footer takes up no space in the layout
|
||||
when hidden. */
|
||||
position: absolute;
|
||||
inset-block-end: 0;
|
||||
inset-inline: 0;
|
||||
|
||||
> * {
|
||||
pointer-events: none;
|
||||
}
|
||||
}
|
||||
|
||||
/* Keep the footer while it is in use: focus inside it, or a menu opened from
|
||||
@@ -48,10 +89,17 @@ Please see LICENSE in the repository root for full details.
|
||||
.footer.overlay:has(:focus-visible),
|
||||
.footer.overlay:has([aria-expanded="true"]) {
|
||||
opacity: 1;
|
||||
pointer-events: initial;
|
||||
|
||||
> .buttons {
|
||||
transform: none;
|
||||
}
|
||||
|
||||
> * {
|
||||
pointer-events: auto;
|
||||
}
|
||||
}
|
||||
|
||||
.settingsLogoContainer {
|
||||
.logoContainer {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: var(--cpd-space-4x);
|
||||
@@ -70,13 +118,45 @@ Please see LICENSE in the repository root for full details.
|
||||
.buttons {
|
||||
grid-area: buttons;
|
||||
justify-self: center;
|
||||
background: var(--cpd-color-bg-canvas-default);
|
||||
border-radius: var(--cpd-radius-pill-effect);
|
||||
box-shadow: var(--big-drop-shadow);
|
||||
display: flex;
|
||||
gap: var(--cpd-space-3x);
|
||||
flex-wrap: nowrap;
|
||||
}
|
||||
|
||||
.layout {
|
||||
grid-area: layout;
|
||||
justify-self: end;
|
||||
:global(.cpd-theme-light),
|
||||
:global(.cpd-theme-light-hc) {
|
||||
.buttons {
|
||||
background: var(--cpd-color-bg-canvas-default);
|
||||
}
|
||||
}
|
||||
|
||||
/* Dark theme uses a different background color, since the drop shadow doesn't
|
||||
provide enough contrast */
|
||||
:global(.cpd-theme-dark),
|
||||
:global(.cpd-theme-dark-hc) {
|
||||
.buttons {
|
||||
background: var(--cpd-color-bg-subtle-primary);
|
||||
}
|
||||
}
|
||||
|
||||
@media (prefers-color-scheme: dark) {
|
||||
.buttons {
|
||||
background: var(--cpd-color-bg-subtle-primary);
|
||||
}
|
||||
}
|
||||
|
||||
.footer[data-button-size="md"] > .buttons {
|
||||
padding: var(--cpd-space-3x);
|
||||
gap: var(--cpd-space-2x);
|
||||
--slide-distance: var(--cpd-space-2x);
|
||||
}
|
||||
|
||||
.footer[data-button-size="lg"] > .buttons {
|
||||
padding: var(--cpd-space-4x);
|
||||
gap: var(--cpd-space-4x);
|
||||
--slide-distance: var(--cpd-space-4x);
|
||||
}
|
||||
|
||||
/*First hide the logo*/
|
||||
@@ -86,30 +166,16 @@ Please see LICENSE in the repository root for full details.
|
||||
}
|
||||
}
|
||||
|
||||
.settingsOnlyShowNarrow {
|
||||
display: none;
|
||||
}
|
||||
.settingsOnlyShowWide {
|
||||
display: inherit;
|
||||
}
|
||||
|
||||
/*
|
||||
With the logo hidden >500px is enough space to show overflow, buttons, layout.
|
||||
Once we exceed 500 we hide everything except the buttons.
|
||||
With the logo hidden >500px is enough space to show logo and buttons.
|
||||
Once we exceed 500 we hide the logo.
|
||||
*/
|
||||
@container element-call (max-width: 500px) {
|
||||
.footer {
|
||||
grid-template-areas: "buttons buttons buttons";
|
||||
}
|
||||
|
||||
.settingsOnlyShowNarrow {
|
||||
display: inherit;
|
||||
}
|
||||
.settingsOnlyShowWide {
|
||||
display: none;
|
||||
}
|
||||
|
||||
.settingsLogoContainer {
|
||||
.logoContainer {
|
||||
display: none;
|
||||
}
|
||||
|
||||
@@ -156,9 +222,3 @@ Once we exceed 500 we hide everything except the buttons.
|
||||
display: none;
|
||||
}
|
||||
}
|
||||
|
||||
@container element-call (min-width: 800px) {
|
||||
.buttons {
|
||||
gap: var(--cpd-space-4x);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -5,7 +5,7 @@ SPDX-License-Identifier: AGPL-3.0-only OR LicenseRef-Element-Commercial
|
||||
Please see LICENSE in the repository root for full details.
|
||||
*/
|
||||
|
||||
import { expect, fn, userEvent, within } from "storybook/test";
|
||||
import { expect, fn, userEvent, waitFor, within } from "storybook/test";
|
||||
import { BehaviorSubject } from "rxjs";
|
||||
import { type JSX, type ReactNode } from "react";
|
||||
import { Link } from "@vector-im/compound-web";
|
||||
@@ -172,7 +172,7 @@ export const Default: Story = {
|
||||
openSettings: fn(),
|
||||
toggleScreenSharing: fn(),
|
||||
hangup: fn(),
|
||||
buttonSize: "lg",
|
||||
buttonSize: "md",
|
||||
showFooter: true,
|
||||
hideControls: false,
|
||||
asOverlay: false,
|
||||
@@ -202,8 +202,11 @@ export const StaysWhileAMenuIsOpen: Story = {
|
||||
const footer = canvasElement.querySelector<HTMLElement>(
|
||||
'[data-testid="footer-container"]',
|
||||
)!;
|
||||
await userEvent.click(
|
||||
within(canvasElement).getByRole("button", { name: "Microphone" }),
|
||||
// Open microphone menu once footer becomes interactive
|
||||
await waitFor(async () =>
|
||||
userEvent.click(
|
||||
within(canvasElement).getByRole("button", { name: "Microphone" }),
|
||||
),
|
||||
);
|
||||
await expect(document.body.querySelector('[role="menu"]')).not.toBeNull();
|
||||
|
||||
@@ -232,8 +235,9 @@ export const SpotlightMode: Story = {
|
||||
layout: "spotlight",
|
||||
},
|
||||
play: async ({ args, canvasElement }) => {
|
||||
const canvas = within(canvasElement);
|
||||
await userEvent.click(canvas.getByRole("radio", { name: "Grid" }));
|
||||
const canvas = within(canvasElement.parentElement!);
|
||||
await userEvent.click(canvas.getByRole("button", { name: "Adjust view" }));
|
||||
await userEvent.click(canvas.getByRole("menuitemradio", { name: "Grid" }));
|
||||
await expect(args.setLayout).toHaveBeenCalledWith("grid");
|
||||
await userEvent.click(canvas.getByRole("switch", { name: "Share screen" }));
|
||||
await expect(args.toggleScreenSharing).toHaveBeenCalled();
|
||||
@@ -269,12 +273,11 @@ export const Pip: Story = {
|
||||
...Default,
|
||||
args: {
|
||||
...Default.args,
|
||||
buttonSize: "md",
|
||||
layout: null,
|
||||
},
|
||||
play: async ({ canvasElement }) => {
|
||||
await expect(
|
||||
within(canvasElement).queryByRole("radio", { name: "Spotlight" }),
|
||||
within(canvasElement).queryByRole("button", { name: "Adjust view" }),
|
||||
).not.toBeInTheDocument();
|
||||
},
|
||||
};
|
||||
@@ -301,6 +304,7 @@ export const MobileLayout: Story = {
|
||||
args: {
|
||||
...Default.args,
|
||||
showLogo: false,
|
||||
buttonSize: "lg",
|
||||
|
||||
audioOutputSwitcher: { targetOutput: "speaker", switch: fn() },
|
||||
},
|
||||
@@ -332,6 +336,7 @@ export const LobbyRecentButtonMobile: Story = {
|
||||
...Default.args,
|
||||
children: <Link>Back To Recents</Link>,
|
||||
showLogo: false,
|
||||
buttonSize: "lg",
|
||||
layout: null,
|
||||
toggleScreenSharing: undefined,
|
||||
},
|
||||
|
||||
@@ -16,7 +16,6 @@ import {
|
||||
SettingsButton,
|
||||
ReactionToggleButton,
|
||||
LoudspeakerButton,
|
||||
SettingsIconButton,
|
||||
type ReactionData,
|
||||
} from "../button";
|
||||
import styles from "./CallFooter.module.css";
|
||||
@@ -120,20 +119,6 @@ export const CallFooter: FC<FooterProps> = ({
|
||||
|
||||
const buttons: JSX.Element[] = [];
|
||||
|
||||
if (openSettings !== undefined) {
|
||||
// Add the settings button to the center group so it's visible on small
|
||||
// screens. On larger screens the SettingsIconButton with
|
||||
// showForScreenWidth="wide" in the settingsLogoContainer is used instead.
|
||||
buttons.push(
|
||||
<SettingsButton
|
||||
key="settings"
|
||||
showForScreenWidth="narrow"
|
||||
onClick={openSettings}
|
||||
data-testid="settings-bottom-center"
|
||||
/>,
|
||||
);
|
||||
}
|
||||
|
||||
buttons.push(
|
||||
<MediaMenuButton
|
||||
key="audio"
|
||||
@@ -189,6 +174,28 @@ export const CallFooter: FC<FooterProps> = ({
|
||||
|
||||
if (audioOutputButton) buttons.push(audioOutputButton);
|
||||
|
||||
if (layoutSwitchVm !== null) {
|
||||
buttons.push(
|
||||
<LayoutSwitch
|
||||
key="layout"
|
||||
vm={layoutSwitchVm}
|
||||
className={styles.layout}
|
||||
size={buttonSize}
|
||||
/>,
|
||||
);
|
||||
}
|
||||
|
||||
if (openSettings !== undefined) {
|
||||
buttons.push(
|
||||
<SettingsButton
|
||||
size={buttonSize}
|
||||
key="settings"
|
||||
onClick={openSettings}
|
||||
data-testid="settings-bottom"
|
||||
/>,
|
||||
);
|
||||
}
|
||||
|
||||
if (hangup)
|
||||
buttons.push(
|
||||
<EndCallButton
|
||||
@@ -221,28 +228,17 @@ export const CallFooter: FC<FooterProps> = ({
|
||||
<div
|
||||
ref={ref}
|
||||
data-testid="footer-container"
|
||||
data-button-size={buttonSize}
|
||||
className={classNames(className, styles.footer, {
|
||||
[styles.overlay]: asOverlay,
|
||||
[styles.hidden]: !showFooter,
|
||||
})}
|
||||
>
|
||||
<div className={styles.settingsLogoContainer}>
|
||||
{openSettings !== undefined && (
|
||||
<SettingsIconButton
|
||||
key="settings"
|
||||
kind="secondary"
|
||||
showForScreenWidth="wide"
|
||||
onClick={openSettings}
|
||||
data-testid="settings-bottom-left"
|
||||
/>
|
||||
)}
|
||||
<div className={styles.logoContainer}>
|
||||
{children}
|
||||
{(showLogo || debugTileLayout) && logoDebugContainer}
|
||||
</div>
|
||||
{!hideControls && <div className={styles.buttons}>{buttons}</div>}
|
||||
{!hideControls && layoutSwitchVm && (
|
||||
<LayoutSwitch vm={layoutSwitchVm} className={styles.layout} />
|
||||
)}
|
||||
</div>
|
||||
);
|
||||
};
|
||||
|
||||
@@ -80,9 +80,7 @@ export function createCallFooterViewModel(
|
||||
hideControls$: constant(!showControls),
|
||||
showModals$: callModel.showModals$,
|
||||
asOverlay$: callModel.edgeToEdge$,
|
||||
buttonSize$: scope.behavior(
|
||||
isPip$.pipe(map<boolean, "md" | "lg">((pip) => (pip ? "md" : "lg"))),
|
||||
),
|
||||
buttonSize$: constant(platform === "desktop" ? "md" : "lg"),
|
||||
|
||||
openSettings$: scope.behavior(
|
||||
combineLatest([
|
||||
@@ -162,7 +160,7 @@ export function createLobbyFooterViewModel(
|
||||
hideControls: false,
|
||||
asOverlay: false,
|
||||
showModals: true,
|
||||
buttonSize: "lg",
|
||||
buttonSize: platform === "desktop" ? "md" : "lg",
|
||||
openSettings,
|
||||
hangup,
|
||||
debugTileLayout: false,
|
||||
|
||||
@@ -26,7 +26,7 @@ function MediaMenuButtonStoryWrapper({
|
||||
...snapshot
|
||||
}: MediaMenuSnapshot & { kind: "audio" | "video" }): ReactNode {
|
||||
const vm = useStaticViewModel(snapshot);
|
||||
return <MediaMenuButton kind={kind} vm={vm} size="lg" />;
|
||||
return <MediaMenuButton kind={kind} vm={vm} size="md" />;
|
||||
}
|
||||
|
||||
const meta = {
|
||||
|
||||
@@ -88,6 +88,7 @@ export const MediaMenuButton: FC<Props> = ({ vm, kind, size }) => {
|
||||
|
||||
return kind === "audio" ? (
|
||||
<MediaMuteAndSwitchButton
|
||||
size={size}
|
||||
iconsAndLabels="audio"
|
||||
enabled={enabled}
|
||||
busy={busy}
|
||||
@@ -102,6 +103,7 @@ export const MediaMenuButton: FC<Props> = ({ vm, kind, size }) => {
|
||||
/>
|
||||
) : (
|
||||
<MediaMuteAndSwitchButton
|
||||
size={size}
|
||||
iconsAndLabels="video"
|
||||
enabled={enabled}
|
||||
busy={busy}
|
||||
|
||||
@@ -16,12 +16,24 @@ Please see LICENSE in the repository root for full details.
|
||||
.containerOpen {
|
||||
background-color: var(--cpd-color-bg-action-primary-pressed);
|
||||
}
|
||||
.chevronIconOpen > svg {
|
||||
color: var(--cpd-color-icon-on-solid-primary);
|
||||
}
|
||||
.menuButton {
|
||||
width: 40px;
|
||||
background-color: transparent !important;
|
||||
|
||||
&[data-size="md"] {
|
||||
width: var(--cpd-space-8x);
|
||||
}
|
||||
&[data-size="lg"] {
|
||||
width: var(--cpd-space-10x);
|
||||
}
|
||||
|
||||
> svg {
|
||||
color: var(--cpd-color-icon-secondary);
|
||||
/* Nudge the icon toward the toggle button to perceptually center it */
|
||||
margin-inline-start: calc(-1 * var(--cpd-space-1x));
|
||||
}
|
||||
}
|
||||
.menuButton.chevronIconOpen > svg {
|
||||
color: var(--cpd-color-icon-on-solid-primary);
|
||||
}
|
||||
.itemIcon {
|
||||
color: var(--cpd-color-text-secondary);
|
||||
|
||||
@@ -291,7 +291,7 @@ describe("MediaMuteAndSwitchButton", () => {
|
||||
// After clicking, plannedSelection="mic2" but selectedOption is still "mic1",
|
||||
// so mic2 should be in an activating state
|
||||
screen.getByRole("menuitemradio", {
|
||||
name: "Microphone 2 Activating…",
|
||||
name: /^Microphone 2\s*Activating…$/,
|
||||
checked: false,
|
||||
});
|
||||
|
||||
|
||||
@@ -57,6 +57,7 @@ export interface MenuOptions {
|
||||
}
|
||||
|
||||
export interface MediaMuteAndSwitchButtonProps {
|
||||
size?: "md" | "lg";
|
||||
/** If the Mute button is enabled */
|
||||
enabled?: boolean;
|
||||
/** Callback if the mute button is clicked */
|
||||
@@ -120,6 +121,7 @@ const MENU_MARGIN = 16;
|
||||
const PREVIEW_GAP = 12;
|
||||
|
||||
export const MediaMuteAndSwitchButton: FC<MediaMuteAndSwitchButtonProps> = ({
|
||||
size,
|
||||
enabled,
|
||||
busy,
|
||||
onMuteClick,
|
||||
@@ -276,6 +278,7 @@ export const MediaMuteAndSwitchButton: FC<MediaMuteAndSwitchButtonProps> = ({
|
||||
const MuteButton = audioMeter ? MicButton : VideoButton;
|
||||
const button = (
|
||||
<MuteButton
|
||||
size={size}
|
||||
enabled={enabled ?? false}
|
||||
busy={isBusy}
|
||||
onClick={(e) => {
|
||||
@@ -365,7 +368,6 @@ export const MediaMuteAndSwitchButton: FC<MediaMuteAndSwitchButtonProps> = ({
|
||||
<MenuItem
|
||||
// A radio input may not sit inside a button.
|
||||
as="div"
|
||||
hideChevron
|
||||
disabled={disabled}
|
||||
label={labelText(label, numbered)}
|
||||
Icon={
|
||||
@@ -447,7 +449,7 @@ export const MediaMuteAndSwitchButton: FC<MediaMuteAndSwitchButtonProps> = ({
|
||||
})}
|
||||
Icon={menuOpen ? ChevronUpIcon : ChevronDownIcon}
|
||||
kind={"tertiary"}
|
||||
size="lg"
|
||||
size={size}
|
||||
aria-label={optionsButtonLabel}
|
||||
/>
|
||||
}
|
||||
|
||||
@@ -25,19 +25,25 @@ describe("useGroupCallRooms", () => {
|
||||
expect(listedRoomIds([room])).toEqual([room.roomId]);
|
||||
});
|
||||
|
||||
test("lists a joined room with a sticky RTC membership", () => {
|
||||
const room = mockCallRoom({
|
||||
stickyEvents: [new MatrixEvent({ type: EventType.RTCMembership })],
|
||||
});
|
||||
expect(listedRoomIds([room])).toEqual([room.roomId]);
|
||||
});
|
||||
test.each([EventType.RTCMembershipStable, EventType.RTCMembership])(
|
||||
"lists a joined room with a sticky %s membership",
|
||||
(type) => {
|
||||
const room = mockCallRoom({
|
||||
stickyEvents: [new MatrixEvent({ type })],
|
||||
});
|
||||
expect(listedRoomIds([room])).toEqual([room.roomId]);
|
||||
},
|
||||
);
|
||||
|
||||
test("lists a joined room with an RTC membership in its timeline", () => {
|
||||
const room = mockCallRoom({
|
||||
timelineEvents: [new MatrixEvent({ type: EventType.RTCMembership })],
|
||||
});
|
||||
expect(listedRoomIds([room])).toEqual([room.roomId]);
|
||||
});
|
||||
test.each([EventType.RTCMembershipStable, EventType.RTCMembership])(
|
||||
"lists a joined room with a %s membership in its timeline",
|
||||
(type) => {
|
||||
const room = mockCallRoom({
|
||||
timelineEvents: [new MatrixEvent({ type })],
|
||||
});
|
||||
expect(listedRoomIds([room])).toEqual([room.roomId]);
|
||||
},
|
||||
);
|
||||
|
||||
test("lists a knocked room without any call events", () => {
|
||||
const room = mockCallRoom({
|
||||
@@ -61,8 +67,12 @@ describe("useGroupCallRooms", () => {
|
||||
const room = mockCallRoom({
|
||||
membership,
|
||||
legacyMemberState: true,
|
||||
stickyEvents: [new MatrixEvent({ type: EventType.RTCMembership })],
|
||||
timelineEvents: [new MatrixEvent({ type: EventType.RTCMembership })],
|
||||
stickyEvents: [
|
||||
new MatrixEvent({ type: EventType.RTCMembershipStable }),
|
||||
],
|
||||
timelineEvents: [
|
||||
new MatrixEvent({ type: EventType.RTCMembershipStable }),
|
||||
],
|
||||
});
|
||||
expect(listedRoomIds([room])).toEqual([]);
|
||||
},
|
||||
|
||||
@@ -7,6 +7,7 @@ Please see LICENSE in the repository root for full details.
|
||||
|
||||
import {
|
||||
type MatrixClient,
|
||||
type MatrixEvent,
|
||||
type RoomMember,
|
||||
type Room,
|
||||
RoomEvent,
|
||||
@@ -143,19 +144,25 @@ const roomHasCallMembershipEvents = (room: Room): boolean => {
|
||||
|
||||
// Check for recent calls using sticky events.
|
||||
for (const sticky of room._unstable_getStickyEvents()) {
|
||||
if (sticky.getType() === EventType.RTCMembership) {
|
||||
if (isRtcMembershipEvent(sticky)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
// Otherwise, check recent event history to see if anyone had
|
||||
// sent a call membership in here.
|
||||
return timeline
|
||||
.getEvents()
|
||||
.some((e) => e.getType() === EventType.RTCMembership);
|
||||
return timeline.getEvents().some(isRtcMembershipEvent);
|
||||
// Otherwise, it's *unlikely* this room was ever a call.
|
||||
};
|
||||
|
||||
// Memberships sent before the event type was stabilised still mark a call room.
|
||||
function isRtcMembershipEvent(event: MatrixEvent): boolean {
|
||||
const type = event.getType();
|
||||
return (
|
||||
type === EventType.RTCMembershipStable || type === EventType.RTCMembership
|
||||
);
|
||||
}
|
||||
|
||||
export function useGroupCallRooms(client: MatrixClient): GroupCallRoom[] {
|
||||
const [rooms, setRooms] = useState<GroupCallRoom[]>([]);
|
||||
|
||||
|
||||
+14
-11
@@ -137,23 +137,24 @@ beforeEach(() => {
|
||||
);
|
||||
});
|
||||
|
||||
function createCallView(
|
||||
async function createCallView(
|
||||
hostBridge: HostBridge,
|
||||
joined = true,
|
||||
options: {
|
||||
/** Wait for the host to say when to join, rather than joining at once. */
|
||||
preload?: boolean;
|
||||
} = {},
|
||||
): {
|
||||
): Promise<{
|
||||
rtcSession: MatrixRTCSession;
|
||||
getByText: ReturnType<typeof render>["getByText"];
|
||||
} {
|
||||
}> {
|
||||
const client = {
|
||||
...mockEmitter(),
|
||||
getUser: () => null,
|
||||
getUserId: () => localRtcMember.userId,
|
||||
getDeviceId: () => localRtcMember.deviceId,
|
||||
getRoom: (rId) => (rId === roomId ? room : null),
|
||||
doesServerSupportUnstableFeature: vi.fn().mockResolvedValue(true),
|
||||
} as Partial<MatrixClient> as MatrixClient;
|
||||
const room = mockMatrixRoom({
|
||||
relations: {
|
||||
@@ -203,6 +204,8 @@ function createCallView(
|
||||
</HostBridgeProvider>
|
||||
</BrowserRouter>,
|
||||
);
|
||||
// Let the homeserver capability check resolve, which the call waits for
|
||||
await act(flushPromises);
|
||||
return {
|
||||
getByText,
|
||||
rtcSession: rtcSession.asMockedSession(),
|
||||
@@ -211,7 +214,7 @@ function createCallView(
|
||||
|
||||
test.skip("CallView plays a leave sound asynchronously in SPA mode", async () => {
|
||||
const user = userEvent.setup();
|
||||
const { getByText, rtcSession } = createCallView(nullHostBridge);
|
||||
const { getByText, rtcSession } = await createCallView(nullHostBridge);
|
||||
const leaveButton = getByText("Leave");
|
||||
await user.click(leaveButton);
|
||||
expect(playSound).toHaveBeenCalledWith("left");
|
||||
@@ -241,7 +244,7 @@ test.skip("CallView plays a leave sound synchronously in widget mode", async ()
|
||||
soundDuration: {},
|
||||
});
|
||||
|
||||
const { getByText, rtcSession } = createCallView(hostBridge);
|
||||
const { getByText, rtcSession } = await createCallView(hostBridge);
|
||||
const leaveButton = getByText("Leave");
|
||||
await user.click(leaveButton);
|
||||
await flushPromises();
|
||||
@@ -274,7 +277,7 @@ test("Should ask the host to close when all other left and play a sound", async
|
||||
soundDuration: {},
|
||||
});
|
||||
|
||||
const { getByText } = createCallView(hostBridge);
|
||||
const { getByText } = await createCallView(hostBridge);
|
||||
const leaveButton = getByText("SimulateOtherLeft");
|
||||
await user.click(leaveButton);
|
||||
await flushPromises();
|
||||
@@ -291,7 +294,7 @@ test("Waits for the host to say when to join, when preloaded", async () => {
|
||||
const join$ = new Subject<HostRequest<JoinCallData>>();
|
||||
const hostBridge: HostBridge = { ...nullHostBridge, join$ };
|
||||
|
||||
createCallView(hostBridge, false, { preload: true });
|
||||
await createCallView(hostBridge, false, { preload: true });
|
||||
await flushPromises();
|
||||
// Past the lobby, but not in the call: the host has not asked yet
|
||||
expect(screen.queryByText("Leave")).toBeNull();
|
||||
@@ -316,7 +319,7 @@ test("Should not ask the host to close when auto leave due to error", async () =
|
||||
close,
|
||||
};
|
||||
|
||||
const { getByText } = createCallView(hostBridge);
|
||||
const { getByText } = await createCallView(hostBridge);
|
||||
const leaveButton = getByText("SimulateErrorLeft");
|
||||
await user.click(leaveButton);
|
||||
await flushPromises();
|
||||
@@ -339,7 +342,7 @@ test.skip("CallView leaves the session when an error occurs", async () => {
|
||||
);
|
||||
});
|
||||
const user = userEvent.setup();
|
||||
const { rtcSession } = createCallView(nullHostBridge);
|
||||
const { rtcSession } = await createCallView(nullHostBridge);
|
||||
await user.click(screen.getByRole("button", { name: "Panic!" }));
|
||||
screen.getByText("Something went wrong");
|
||||
expect(leaveRTCSession).toHaveBeenCalledWith(
|
||||
@@ -356,7 +359,7 @@ test.skip("CallView shows errors that occur during joining", async () => {
|
||||
onTestFinished(() => {
|
||||
enterRTCSession.mockReset();
|
||||
});
|
||||
createCallView(nullHostBridge, false);
|
||||
await createCallView(nullHostBridge, false);
|
||||
await user.click(screen.getByRole("button", { name: "Join call" }));
|
||||
screen.getByText("Call is not supported");
|
||||
});
|
||||
@@ -378,7 +381,7 @@ test("user can reconnect after losing the connection", async () => {
|
||||
},
|
||||
);
|
||||
const user = userEvent.setup();
|
||||
createCallView(nullHostBridge, true);
|
||||
await createCallView(nullHostBridge, true);
|
||||
await user.click(screen.getByRole("button", { name: "LoseConnection" }));
|
||||
await screen.findByText("Connection lost");
|
||||
// Never joined, so there was no call to leave
|
||||
|
||||
+40
-2
@@ -13,7 +13,12 @@ import {
|
||||
useMemo,
|
||||
useState,
|
||||
} from "react";
|
||||
import { type MatrixClient, JoinRule, type Room } from "matrix-js-sdk";
|
||||
import {
|
||||
type MatrixClient,
|
||||
JoinRule,
|
||||
type Room,
|
||||
UNSTABLE_MSC4354_STICKY_EVENTS,
|
||||
} from "matrix-js-sdk";
|
||||
import {
|
||||
Room as LivekitRoom,
|
||||
isE2EESupported as isE2EESupportedBrowser,
|
||||
@@ -166,7 +171,35 @@ export const CallView: FC<Props> = ({
|
||||
return (): void => scope.end();
|
||||
}, [backend, e2eeSystem, externalRtcSession]);
|
||||
|
||||
if (muteStates === null || slot === null) return null;
|
||||
// Known before the call renders, so a join without a lobby picks the right
|
||||
// Matrix RTC mode
|
||||
const [stickyEventsSupported, setStickyEventsSupported] = useState<
|
||||
boolean | null
|
||||
>(null);
|
||||
useEffect(() => {
|
||||
let cancelled = false;
|
||||
void backend
|
||||
.doesServerSupportUnstableFeature(UNSTABLE_MSC4354_STICKY_EVENTS)
|
||||
.catch((e) => {
|
||||
// This will also fail in embedded mode if the HS does not
|
||||
// set `Access-Control-Allow-Origin: *`:
|
||||
// The page is loaded from a file url (origin=null) + widget api does not handle this
|
||||
// -> a raw http request will be used -> CORS errors due to origin=null
|
||||
// The conclusion is: matrix 2.0 mode will always fall back in widget mode on mobile.
|
||||
// This is acceptable as we plan to not extend the widget api for full 2.0 mode support.
|
||||
logger.warn("Failed to check if sticky events are supported", e);
|
||||
return false;
|
||||
})
|
||||
.then((supported) => {
|
||||
if (!cancelled) setStickyEventsSupported(supported);
|
||||
});
|
||||
return (): void => {
|
||||
cancelled = true;
|
||||
};
|
||||
}, [backend]);
|
||||
|
||||
if (muteStates === null || slot === null || stickyEventsSupported === null)
|
||||
return null;
|
||||
|
||||
return (
|
||||
<LoadedCallView
|
||||
@@ -180,6 +213,7 @@ export const CallView: FC<Props> = ({
|
||||
joined={joined}
|
||||
setJoined={setJoined}
|
||||
muteStates={muteStates}
|
||||
stickyEventsSupported={stickyEventsSupported}
|
||||
/>
|
||||
);
|
||||
};
|
||||
@@ -249,6 +283,8 @@ interface LoadedProps extends Omit<Props, "rtcSession" | "backend"> {
|
||||
joined: boolean;
|
||||
setJoined: (value: boolean) => void;
|
||||
muteStates: MuteStates;
|
||||
/** Whether the homeserver supports sticky events (MSC4354), which Matrix 2.0 needs. */
|
||||
stickyEventsSupported: boolean;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -281,6 +317,7 @@ const LoadedCallView: FC<LoadedProps> = ({
|
||||
joined,
|
||||
setJoined,
|
||||
muteStates,
|
||||
stickyEventsSupported,
|
||||
}) => {
|
||||
// Used to thread through any errors that occur outside the error boundary
|
||||
const [externalError, setExternalError] = useState<ElementCallError | null>(
|
||||
@@ -619,6 +656,7 @@ const LoadedCallView: FC<LoadedProps> = ({
|
||||
media={media}
|
||||
muteStates={muteStates}
|
||||
e2eeSystem={e2eeSystem}
|
||||
stickyEventsSupported={stickyEventsSupported}
|
||||
//otelGroupCallMembership={otelGroupCallMembership}
|
||||
onShareClick={onShareClick}
|
||||
/>
|
||||
|
||||
@@ -14,23 +14,6 @@ Please see LICENSE in the repository root for full details.
|
||||
overflow-y: auto;
|
||||
}
|
||||
|
||||
/* Normally the footer uses a transparent background to allow our expressive
|
||||
page gradients to shine through. However, we sometimes need to visually separate
|
||||
it from the content underneath. If the call layout is overflowing, or if the
|
||||
spotlight tile is maximised and displaying video, apply a gradient background. */
|
||||
.overflowing > .footer,
|
||||
.fixedGrid:has(
|
||||
> .tile[data-maximised="true"]
|
||||
.spotlightItem[data-background="transparent"][data-video-enabled="true"][aria-hidden="false"]
|
||||
)
|
||||
~ .footer {
|
||||
background: linear-gradient(
|
||||
180deg,
|
||||
rgba(0, 0, 0, 0) 0%,
|
||||
var(--cpd-color-bg-canvas-default) 100%
|
||||
);
|
||||
}
|
||||
|
||||
.header {
|
||||
position: sticky;
|
||||
flex-shrink: 0;
|
||||
|
||||
@@ -7,6 +7,7 @@ Please see LICENSE in the repository root for full details.
|
||||
*/
|
||||
|
||||
import {
|
||||
afterEach,
|
||||
beforeEach,
|
||||
describe,
|
||||
expect,
|
||||
@@ -20,8 +21,10 @@ import { BrowserRouter } from "react-router-dom";
|
||||
import { TooltipProvider } from "@vector-im/compound-web";
|
||||
import userEvent from "@testing-library/user-event";
|
||||
|
||||
import { ActiveCall, InCallView } from "./InCallView";
|
||||
import { ActiveCall, InCallView, rtcParticipationOptions } from "./InCallView";
|
||||
import { getUrlParams } from "../UrlParams";
|
||||
import {
|
||||
mockConfig,
|
||||
mockMediaDevices,
|
||||
mockMuteStates,
|
||||
mockRtcMembership,
|
||||
@@ -43,7 +46,11 @@ import { ReactionsSenderProvider } from "../reactions/useReactionsSender";
|
||||
import { useRoomEncryptionSystem } from "../e2ee/sharedKeyManagement";
|
||||
import { MemberAudioRenderer } from "../tracks/MemberAudioRenderer";
|
||||
import type * as MatrixRTCSdk from "@element-hq/matrixrtc-sdk";
|
||||
import { constant, type RTCSlot } from "@element-hq/matrixrtc-sdk";
|
||||
import {
|
||||
constant,
|
||||
MatrixRTCMode,
|
||||
type RTCSlot,
|
||||
} from "@element-hq/matrixrtc-sdk";
|
||||
import { MediaDevicesContext } from "../MediaDevicesContext";
|
||||
import { type MediaDevices as ECMediaDevices } from "../state/MediaDevices";
|
||||
import { AppBar } from "../AppBar";
|
||||
@@ -246,6 +253,7 @@ function renderActiveCall(slot: RTCSlot): RenderResult {
|
||||
onShareClick={null}
|
||||
e2eeSystem={{ kind: E2eeType.NONE }}
|
||||
media={fakeLocalMedia()}
|
||||
stickyEventsSupported
|
||||
onLeft={(): void => {}}
|
||||
/>
|
||||
</TooltipProvider>
|
||||
@@ -255,6 +263,32 @@ function renderActiveCall(slot: RTCSlot): RenderResult {
|
||||
);
|
||||
}
|
||||
|
||||
describe("rtcParticipationOptions", () => {
|
||||
const urlParams = getUrlParams("", "");
|
||||
afterEach(() => vi.restoreAllMocks());
|
||||
|
||||
it("joins in Matrix 2.0 mode when the homeserver supports sticky events", () => {
|
||||
mockConfig({ matrix_rtc_mode: MatrixRTCMode.Matrix_2_0 });
|
||||
expect(rtcParticipationOptions(urlParams, true).matrixRTCMode).toBe(
|
||||
MatrixRTCMode.Matrix_2_0,
|
||||
);
|
||||
});
|
||||
|
||||
it("falls back to compatibility mode when the homeserver lacks sticky events", () => {
|
||||
mockConfig({ matrix_rtc_mode: MatrixRTCMode.Matrix_2_0 });
|
||||
expect(rtcParticipationOptions(urlParams, false).matrixRTCMode).toBe(
|
||||
MatrixRTCMode.Compatibility,
|
||||
);
|
||||
});
|
||||
|
||||
it("keeps compatibility mode when the homeserver lacks sticky events", () => {
|
||||
mockConfig({ matrix_rtc_mode: MatrixRTCMode.Compatibility });
|
||||
expect(rtcParticipationOptions(urlParams, false).matrixRTCMode).toBe(
|
||||
MatrixRTCMode.Compatibility,
|
||||
);
|
||||
});
|
||||
});
|
||||
|
||||
describe("ActiveCall", () => {
|
||||
it("creates the view models and renders the call", async () => {
|
||||
const { findByTestId } = renderActiveCall(mockSlot());
|
||||
@@ -315,6 +349,7 @@ describe("ActiveCall", () => {
|
||||
onShareClick={null}
|
||||
e2eeSystem={{ kind: E2eeType.NONE }}
|
||||
media={fakeLocalMedia()}
|
||||
stickyEventsSupported
|
||||
onLeft={(): void => {}}
|
||||
/>
|
||||
</TooltipProvider>
|
||||
|
||||
+21
-19
@@ -55,7 +55,7 @@ import { SpotlightTile } from "../tile/SpotlightTile";
|
||||
import {
|
||||
type EncryptionSystem,
|
||||
type LocalMedia,
|
||||
type MatrixRTCMode,
|
||||
MatrixRTCMode,
|
||||
} from "@element-hq/matrixrtc-sdk";
|
||||
import { E2eeType } from "../e2ee/e2eeType";
|
||||
import { makeGridLayout } from "../grid/GridLayout";
|
||||
@@ -194,6 +194,8 @@ export interface ActiveCallProps extends Omit<
|
||||
e2eeSystem: EncryptionSystem;
|
||||
/** The tracks the lobby opened, for the join to publish. */
|
||||
media: LocalMedia;
|
||||
/** Whether the homeserver supports sticky events (MSC4354), which Matrix 2.0 needs. */
|
||||
stickyEventsSupported: boolean;
|
||||
// TODO refactor those reasons into an enum
|
||||
onLeft: (
|
||||
reason: "user" | "timeout" | "decline" | "allOthersLeft" | "error",
|
||||
@@ -229,7 +231,7 @@ export const ActiveCall: FC<ActiveCallProps> = (props) => {
|
||||
|
||||
const capture = captureSettings();
|
||||
const rtcParticipation = props.slot.join({
|
||||
...rtcParticipationOptions(urlParams),
|
||||
...rtcParticipationOptions(urlParams, props.stickyEventsSupported),
|
||||
// Without a lobby nothing was captured and the join captures itself
|
||||
publish:
|
||||
props.media.requests.length > 0
|
||||
@@ -290,6 +292,7 @@ export const ActiveCall: FC<ActiveCallProps> = (props) => {
|
||||
backgroundEffectsState$,
|
||||
props.client,
|
||||
props.media,
|
||||
props.stickyEventsSupported,
|
||||
rootElement,
|
||||
]);
|
||||
|
||||
@@ -413,7 +416,6 @@ export const InCallView: FC<InCallViewProps> = ({
|
||||
const screenShareError = useBehavior(vm.screenShareError$);
|
||||
const layout = useBehavior(vm.layout$);
|
||||
const edgeToEdge = useBehavior(vm.edgeToEdge$);
|
||||
const overflowing = useBehavior(vm.overflowing$);
|
||||
const showNameTags = useBehavior(vm.showNameTags$);
|
||||
const showHeader = useBehavior(vm.showHeader$);
|
||||
const showModals = useBehavior(vm.showModals$);
|
||||
@@ -636,7 +638,6 @@ export const InCallView: FC<InCallViewProps> = ({
|
||||
showRingingStatus={showRingingStatus}
|
||||
focusable={!contentObscured}
|
||||
className={classNames(className, styles.tile)}
|
||||
itemClassName={styles.spotlightItem}
|
||||
style={style}
|
||||
/>
|
||||
);
|
||||
@@ -662,7 +663,6 @@ export const InCallView: FC<InCallViewProps> = ({
|
||||
return (
|
||||
<SpotlightTile
|
||||
className={styles.tile}
|
||||
itemClassName={styles.spotlightItem}
|
||||
data-maximised
|
||||
vm={layout.spotlight}
|
||||
expanded
|
||||
@@ -753,10 +753,6 @@ export const InCallView: FC<InCallViewProps> = ({
|
||||
/>,
|
||||
);
|
||||
|
||||
// Only hide the settings button if we have an AppBar header and we are showing the header
|
||||
const footer = footerVm !== null && (
|
||||
<CallFooter className={styles.footer} ref={footerRef} vm={footerVm} />
|
||||
);
|
||||
const connectedTransports = useBehavior(vm.connectedTransports$);
|
||||
const localMember = useBehavior(vm.localMember$);
|
||||
const localTransport = useBehavior(
|
||||
@@ -768,9 +764,7 @@ export const InCallView: FC<InCallViewProps> = ({
|
||||
// and the footer is also viewable by moving focus into it, so this is fine.
|
||||
// eslint-disable-next-line jsx-a11y/no-static-element-interactions
|
||||
<div
|
||||
className={classNames(styles.inRoom, {
|
||||
[styles.overflowing]: overflowing,
|
||||
})}
|
||||
className={styles.inRoom}
|
||||
ref={containerRef}
|
||||
// Which layout the call has settled on, for tests and for anyone
|
||||
// wondering why the call looks the way it does at the size it was given
|
||||
@@ -789,7 +783,7 @@ export const InCallView: FC<InCallViewProps> = ({
|
||||
{screenShareToast}
|
||||
{earpieceOverlay}
|
||||
<ReactionsOverlay vm={vm} />
|
||||
{footer}
|
||||
<CallFooter ref={footerRef} vm={footerVm} />
|
||||
{showModals && (
|
||||
<>
|
||||
<RageshakeRequestModal {...rageshakeRequestModalProps} />
|
||||
@@ -867,16 +861,24 @@ export function captureSettings(): CaptureSettings {
|
||||
*/
|
||||
export function rtcParticipationOptions(
|
||||
urlParams: ReturnType<typeof useUrlParams>,
|
||||
stickyEventsSupported: boolean,
|
||||
): Omit<RTCParticipationOptions, "publish"> {
|
||||
const config = Config.get();
|
||||
const session = config.matrix_rtc_session;
|
||||
// matrix_rtc_mode in config.json overrides the user's Developer Settings
|
||||
// choice. We merely sample the current mode here, so the user would need
|
||||
// to manually rejoin to switch to a different one.
|
||||
let matrixRTCMode =
|
||||
(config.matrix_rtc_mode as MatrixRTCMode | undefined) ??
|
||||
matrixRTCModeSetting.value$.value;
|
||||
if (matrixRTCMode === MatrixRTCMode.Matrix_2_0 && !stickyEventsSupported) {
|
||||
rootLogger.warn(
|
||||
"Homeserver does not support sticky events (MSC4354), falling back from Matrix 2.0 to compatibility mode",
|
||||
);
|
||||
matrixRTCMode = MatrixRTCMode.Compatibility;
|
||||
}
|
||||
return {
|
||||
// matrix_rtc_mode in config.json overrides the user's Developer Settings
|
||||
// choice. We merely sample the current mode here, so the user would need
|
||||
// to manually rejoin to switch to a different one.
|
||||
matrixRTCMode:
|
||||
(config.matrix_rtc_mode as MatrixRTCMode | undefined) ??
|
||||
matrixRTCModeSetting.value$.value,
|
||||
matrixRTCMode,
|
||||
sendNotificationType: urlParams.sendNotificationType,
|
||||
callIntent: urlParams.callIntent,
|
||||
timings: {
|
||||
|
||||
+41
-21
@@ -5,40 +5,60 @@ SPDX-License-Identifier: AGPL-3.0-only OR LicenseRef-Element-Commercial
|
||||
Please see LICENSE in the repository root for full details.
|
||||
*/
|
||||
|
||||
import { useId, type FC } from "react";
|
||||
import {
|
||||
SpotlightViewIcon,
|
||||
type ReactNode,
|
||||
useState,
|
||||
type FC,
|
||||
type ComponentType,
|
||||
type SVGAttributes,
|
||||
} from "react";
|
||||
import { useTranslation } from "react-i18next";
|
||||
import { Menu, OptionMenuItem } from "@vector-im/compound-web";
|
||||
import {
|
||||
GridIcon,
|
||||
SpotlightViewIcon,
|
||||
} from "@vector-im/compound-design-tokens/assets/web/icons";
|
||||
|
||||
import { type LayoutSwitchViewModel } from "../state/LayoutSwitchViewModel";
|
||||
import {
|
||||
type LayoutMode,
|
||||
type LayoutSwitchViewModel,
|
||||
} from "../state/LayoutSwitchViewModel";
|
||||
import { useBehavior } from "../useBehavior";
|
||||
import { useTranslation } from "react-i18next";
|
||||
import { Switch } from "@vector-im/compound-web";
|
||||
import { LayoutSwitchButton } from "../button";
|
||||
|
||||
interface Props {
|
||||
interface LayoutSwitchProps {
|
||||
vm: LayoutSwitchViewModel;
|
||||
className?: string;
|
||||
size?: "md" | "lg";
|
||||
}
|
||||
|
||||
export const LayoutSwitch: FC<Props> = ({ vm, className }) => {
|
||||
export const LayoutSwitch: FC<LayoutSwitchProps> = ({ vm, ...props }) => {
|
||||
const { t } = useTranslation();
|
||||
const layout = useBehavior(vm.layout$);
|
||||
const name = useId();
|
||||
const [open, setOpen] = useState(false);
|
||||
|
||||
return (
|
||||
<Switch<"spotlight", "grid">
|
||||
name={name}
|
||||
aria-label={t("layout_switch_label")}
|
||||
leftLabel={t("layout_spotlight_label")}
|
||||
leftValue="spotlight"
|
||||
leftIcon={SpotlightViewIcon}
|
||||
rightLabel={t("layout_grid_label")}
|
||||
rightValue="grid"
|
||||
rightIcon={GridIcon}
|
||||
className={className}
|
||||
value={layout}
|
||||
onChange={vm.setLayout}
|
||||
const menuItem = (
|
||||
value: LayoutMode,
|
||||
label: string,
|
||||
Icon: ComponentType<SVGAttributes<SVGElement>>,
|
||||
): ReactNode => (
|
||||
<OptionMenuItem
|
||||
label={label}
|
||||
Icon={Icon}
|
||||
checked={layout === value}
|
||||
onSelect={() => vm.setLayout(value)}
|
||||
/>
|
||||
);
|
||||
|
||||
return (
|
||||
<Menu
|
||||
title={t("action.adjust_view")}
|
||||
open={open}
|
||||
onOpenChange={setOpen}
|
||||
trigger={<LayoutSwitchButton layout={layout} {...props} />}
|
||||
>
|
||||
{menuItem("grid", t("layout_grid_label"), GridIcon)}
|
||||
{menuItem("spotlight", t("layout_spotlight_label"), SpotlightViewIcon)}
|
||||
</Menu>
|
||||
);
|
||||
};
|
||||
|
||||
@@ -108,7 +108,6 @@ exports[`InCallView > rendering > renders 1`] = `
|
||||
</div>
|
||||
<div
|
||||
class="_fixedGrid_4e7ff8 _grid_b0d1cd"
|
||||
style="inset-block-start: NaNpx;"
|
||||
>
|
||||
<div />
|
||||
</div>
|
||||
@@ -168,39 +167,13 @@ exports[`InCallView > rendering > renders 1`] = `
|
||||
class="_container_8084b5"
|
||||
/>
|
||||
<div
|
||||
class="_footer_4e7ff8 _footer_20b7b4"
|
||||
class="_footer_20b7b4"
|
||||
data-button-size="md"
|
||||
data-testid="footer-container"
|
||||
>
|
||||
<div
|
||||
class="_settingsLogoContainer_20b7b4"
|
||||
class="_logoContainer_20b7b4"
|
||||
>
|
||||
<button
|
||||
aria-labelledby="_r_b_"
|
||||
class="_icon-button_1215g_8 _settingsOnlyShowWide_20b7b4"
|
||||
data-kind="secondary"
|
||||
data-testid="settings-bottom-left"
|
||||
role="button"
|
||||
style="--cpd-icon-button-size: 32px;"
|
||||
tabindex="0"
|
||||
>
|
||||
<div
|
||||
class="_indicator-icon_j097f_17"
|
||||
style="--cpd-icon-button-size: 100%;"
|
||||
>
|
||||
<svg
|
||||
aria-hidden="true"
|
||||
fill="currentColor"
|
||||
height="1em"
|
||||
viewBox="0 0 24 24"
|
||||
width="1em"
|
||||
xmlns="http://www.w3.org/2000/svg"
|
||||
>
|
||||
<path
|
||||
d="M6 14q-.824 0-1.412-.588A1.93 1.93 0 0 1 4 12q0-.825.588-1.412A1.93 1.93 0 0 1 6 10q.824 0 1.412.588Q8 11.175 8 12t-.588 1.412A1.93 1.93 0 0 1 6 14m6 0q-.825 0-1.412-.588A1.93 1.93 0 0 1 10 12q0-.825.588-1.412A1.93 1.93 0 0 1 12 10q.825 0 1.412.588Q14 11.175 14 12t-.588 1.412A1.93 1.93 0 0 1 12 14m6 0q-.824 0-1.413-.588A1.93 1.93 0 0 1 16 12q0-.825.587-1.412A1.93 1.93 0 0 1 18 10q.824 0 1.413.588Q20 11.175 20 12t-.587 1.412A1.93 1.93 0 0 1 18 14"
|
||||
/>
|
||||
</svg>
|
||||
</div>
|
||||
</button>
|
||||
<div
|
||||
class="_logo_20b7b4"
|
||||
>
|
||||
@@ -309,36 +282,14 @@ exports[`InCallView > rendering > renders 1`] = `
|
||||
<div
|
||||
class="_buttons_20b7b4"
|
||||
>
|
||||
<button
|
||||
aria-labelledby="_r_g_"
|
||||
class="_button_1nw83_8 _settingsOnlyShowNarrow_20b7b4 _has-icon_1nw83_60 _icon-only_1nw83_53"
|
||||
data-kind="secondary"
|
||||
data-size="lg"
|
||||
data-testid="settings-bottom-center"
|
||||
role="button"
|
||||
tabindex="0"
|
||||
>
|
||||
<svg
|
||||
aria-hidden="true"
|
||||
fill="currentColor"
|
||||
height="24"
|
||||
viewBox="0 0 24 24"
|
||||
width="24"
|
||||
xmlns="http://www.w3.org/2000/svg"
|
||||
>
|
||||
<path
|
||||
d="M6 14q-.824 0-1.412-.588A1.93 1.93 0 0 1 4 12q0-.825.588-1.412A1.93 1.93 0 0 1 6 10q.824 0 1.412.588Q8 11.175 8 12t-.588 1.412A1.93 1.93 0 0 1 6 14m6 0q-.825 0-1.412-.588A1.93 1.93 0 0 1 10 12q0-.825.588-1.412A1.93 1.93 0 0 1 12 10q.825 0 1.412.588Q14 11.175 14 12t-.588 1.412A1.93 1.93 0 0 1 12 14m6 0q-.824 0-1.413-.588A1.93 1.93 0 0 1 16 12q0-.825.587-1.412A1.93 1.93 0 0 1 18 10q.824 0 1.413.588Q20 11.175 20 12t-.587 1.412A1.93 1.93 0 0 1 18 14"
|
||||
/>
|
||||
</svg>
|
||||
</button>
|
||||
<button
|
||||
aria-busy="false"
|
||||
aria-checked="false"
|
||||
aria-disabled="true"
|
||||
aria-labelledby="_r_l_"
|
||||
aria-labelledby="_r_b_"
|
||||
class="_button_1nw83_8 _has-icon_1nw83_60 _icon-only_1nw83_53"
|
||||
data-kind="primary"
|
||||
data-size="lg"
|
||||
data-size="md"
|
||||
data-testid="incall_mute"
|
||||
role="switch"
|
||||
tabindex="0"
|
||||
@@ -346,9 +297,9 @@ exports[`InCallView > rendering > renders 1`] = `
|
||||
<svg
|
||||
aria-hidden="true"
|
||||
fill="currentColor"
|
||||
height="24"
|
||||
height="20"
|
||||
viewBox="0 0 24 24"
|
||||
width="24"
|
||||
width="20"
|
||||
xmlns="http://www.w3.org/2000/svg"
|
||||
>
|
||||
<path
|
||||
@@ -360,10 +311,10 @@ exports[`InCallView > rendering > renders 1`] = `
|
||||
aria-busy="false"
|
||||
aria-checked="false"
|
||||
aria-disabled="true"
|
||||
aria-labelledby="_r_q_"
|
||||
aria-labelledby="_r_g_"
|
||||
class="_button_1nw83_8 _has-icon_1nw83_60 _icon-only_1nw83_53"
|
||||
data-kind="primary"
|
||||
data-size="lg"
|
||||
data-size="md"
|
||||
data-testid="incall_videomute"
|
||||
role="switch"
|
||||
tabindex="0"
|
||||
@@ -371,9 +322,9 @@ exports[`InCallView > rendering > renders 1`] = `
|
||||
<svg
|
||||
aria-hidden="true"
|
||||
fill="currentColor"
|
||||
height="24"
|
||||
height="20"
|
||||
viewBox="0 0 24 24"
|
||||
width="24"
|
||||
width="20"
|
||||
xmlns="http://www.w3.org/2000/svg"
|
||||
>
|
||||
<path
|
||||
@@ -385,19 +336,19 @@ exports[`InCallView > rendering > renders 1`] = `
|
||||
aria-disabled="false"
|
||||
aria-expanded="false"
|
||||
aria-haspopup="true"
|
||||
aria-labelledby="_r_v_"
|
||||
aria-labelledby="_r_l_"
|
||||
class="_button_1nw83_8 _raiseHand_20b7b4 _has-icon_1nw83_60 _icon-only_1nw83_53"
|
||||
data-kind="secondary"
|
||||
data-size="lg"
|
||||
data-size="md"
|
||||
role="button"
|
||||
tabindex="0"
|
||||
>
|
||||
<svg
|
||||
aria-hidden="true"
|
||||
fill="currentColor"
|
||||
height="24"
|
||||
height="20"
|
||||
viewBox="0 0 24 24"
|
||||
width="24"
|
||||
width="20"
|
||||
xmlns="http://www.w3.org/2000/svg"
|
||||
>
|
||||
<path
|
||||
@@ -408,10 +359,59 @@ exports[`InCallView > rendering > renders 1`] = `
|
||||
</svg>
|
||||
</button>
|
||||
<button
|
||||
aria-labelledby="_r_17_"
|
||||
aria-disabled="false"
|
||||
aria-expanded="false"
|
||||
aria-haspopup="menu"
|
||||
aria-labelledby="_r_v_"
|
||||
class="_button_1nw83_8 _layout_20b7b4 _has-icon_1nw83_60 _icon-only_1nw83_53"
|
||||
data-kind="secondary"
|
||||
data-size="md"
|
||||
data-state="closed"
|
||||
id="radix-_r_t_"
|
||||
role="button"
|
||||
tabindex="0"
|
||||
type="button"
|
||||
>
|
||||
<svg
|
||||
aria-hidden="true"
|
||||
fill="currentColor"
|
||||
height="20"
|
||||
viewBox="0 0 24 24"
|
||||
width="20"
|
||||
xmlns="http://www.w3.org/2000/svg"
|
||||
>
|
||||
<path
|
||||
d="M4 11a.97.97 0 0 1-.712-.287A.97.97 0 0 1 3 10V4q0-.424.288-.712A.97.97 0 0 1 4 3h6q.424 0 .713.288Q11 3.575 11 4v6q0 .424-.287.713A.97.97 0 0 1 10 11zm5-2V5H5v4zm5 12a.97.97 0 0 1-.713-.288A.97.97 0 0 1 13 20v-6q0-.424.287-.713A.97.97 0 0 1 14 13h6q.424 0 .712.287.288.288.288.713v6q0 .424-.288.712A.97.97 0 0 1 20 21zm5-2v-4h-4v4zM4 21a.97.97 0 0 1-.712-.288A.97.97 0 0 1 3 20v-6q0-.424.288-.713A.97.97 0 0 1 4 13h6q.424 0 .713.287.287.288.287.713v6q0 .424-.287.712A.97.97 0 0 1 10 21zm5-2v-4H5v4zm5-8a.97.97 0 0 1-.713-.287A.97.97 0 0 1 13 10V4q0-.424.287-.712A.97.97 0 0 1 14 3h6q.424 0 .712.288Q21 3.575 21 4v6q0 .424-.288.713A.97.97 0 0 1 20 11zm5-2V5h-4v4z"
|
||||
/>
|
||||
</svg>
|
||||
</button>
|
||||
<button
|
||||
aria-labelledby="_r_14_"
|
||||
class="_button_1nw83_8 _has-icon_1nw83_60 _icon-only_1nw83_53"
|
||||
data-kind="secondary"
|
||||
data-size="md"
|
||||
data-testid="settings-bottom"
|
||||
role="button"
|
||||
tabindex="0"
|
||||
>
|
||||
<svg
|
||||
aria-hidden="true"
|
||||
fill="currentColor"
|
||||
height="20"
|
||||
viewBox="0 0 24 24"
|
||||
width="20"
|
||||
xmlns="http://www.w3.org/2000/svg"
|
||||
>
|
||||
<path
|
||||
d="M6 14q-.824 0-1.412-.588A1.93 1.93 0 0 1 4 12q0-.825.588-1.412A1.93 1.93 0 0 1 6 10q.824 0 1.412.588Q8 11.175 8 12t-.588 1.412A1.93 1.93 0 0 1 6 14m6 0q-.825 0-1.412-.588A1.93 1.93 0 0 1 10 12q0-.825.588-1.412A1.93 1.93 0 0 1 12 10q.825 0 1.412.588Q14 11.175 14 12t-.588 1.412A1.93 1.93 0 0 1 12 14m6 0q-.824 0-1.413-.588A1.93 1.93 0 0 1 16 12q0-.825.587-1.412A1.93 1.93 0 0 1 18 10q.824 0 1.413.588Q20 11.175 20 12t-.587 1.412A1.93 1.93 0 0 1 18 14"
|
||||
/>
|
||||
</svg>
|
||||
</button>
|
||||
<button
|
||||
aria-labelledby="_r_19_"
|
||||
class="_button_1nw83_8 _has-icon_1nw83_60 _icon-only_1nw83_53 _destructive_1nw83_110"
|
||||
data-kind="primary"
|
||||
data-size="lg"
|
||||
data-size="md"
|
||||
data-testid="incall_leave"
|
||||
role="button"
|
||||
tabindex="0"
|
||||
@@ -419,9 +419,9 @@ exports[`InCallView > rendering > renders 1`] = `
|
||||
<svg
|
||||
aria-hidden="true"
|
||||
fill="currentColor"
|
||||
height="24"
|
||||
height="20"
|
||||
viewBox="0 0 24 24"
|
||||
width="24"
|
||||
width="20"
|
||||
xmlns="http://www.w3.org/2000/svg"
|
||||
>
|
||||
<path
|
||||
@@ -430,51 +430,6 @@ exports[`InCallView > rendering > renders 1`] = `
|
||||
</svg>
|
||||
</button>
|
||||
</div>
|
||||
<fieldset
|
||||
aria-label="Layout"
|
||||
class="_toggle_1kvhc_9 _layout_20b7b4"
|
||||
data-size="lg"
|
||||
>
|
||||
<input
|
||||
aria-labelledby="_r_1d_"
|
||||
name="_r_1c_"
|
||||
type="radio"
|
||||
value="spotlight"
|
||||
/>
|
||||
<svg
|
||||
aria-hidden="true"
|
||||
fill="currentColor"
|
||||
height="1em"
|
||||
viewBox="0 0 24 24"
|
||||
width="1em"
|
||||
xmlns="http://www.w3.org/2000/svg"
|
||||
>
|
||||
<path
|
||||
clip-rule="evenodd"
|
||||
d="M20 6H4v12h16zM4 4a2 2 0 0 0-2 2v12a2 2 0 0 0 2 2h16a2 2 0 0 0 2-2V6a2 2 0 0 0-2-2z"
|
||||
fill-rule="evenodd"
|
||||
/>
|
||||
</svg>
|
||||
<input
|
||||
aria-labelledby="_r_1i_"
|
||||
checked=""
|
||||
name="_r_1c_"
|
||||
type="radio"
|
||||
value="grid"
|
||||
/>
|
||||
<svg
|
||||
aria-hidden="true"
|
||||
fill="currentColor"
|
||||
height="1em"
|
||||
viewBox="0 0 24 24"
|
||||
width="1em"
|
||||
xmlns="http://www.w3.org/2000/svg"
|
||||
>
|
||||
<path
|
||||
d="M4 11a.97.97 0 0 1-.712-.287A.97.97 0 0 1 3 10V4q0-.424.288-.712A.97.97 0 0 1 4 3h6q.424 0 .713.288Q11 3.575 11 4v6q0 .424-.287.713A.97.97 0 0 1 10 11zm5-2V5H5v4zm5 12a.97.97 0 0 1-.713-.288A.97.97 0 0 1 13 20v-6q0-.424.287-.713A.97.97 0 0 1 14 13h6q.424 0 .712.287.288.288.288.713v6q0 .424-.288.712A.97.97 0 0 1 20 21zm5-2v-4h-4v4zM4 21a.97.97 0 0 1-.712-.288A.97.97 0 0 1 3 20v-6q0-.424.288-.713A.97.97 0 0 1 4 13h6q.424 0 .713.287.287.288.287.713v6q0 .424-.287.712A.97.97 0 0 1 10 21zm5-2v-4H5v4zm5-8a.97.97 0 0 1-.713-.287A.97.97 0 0 1 13 10V4q0-.424.287-.712A.97.97 0 0 1 14 3h6q.424 0 .712.288Q21 3.575 21 4v6q0 .424-.288.713A.97.97 0 0 1 20 11zm5-2V5h-4v4z"
|
||||
/>
|
||||
</svg>
|
||||
</fieldset>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@@ -7,7 +7,7 @@ exports[`LobbyView > renders with AppBar android 1`] = `
|
||||
>
|
||||
<header>
|
||||
<button
|
||||
aria-labelledby="_r_36_"
|
||||
aria-labelledby="_r_2k_"
|
||||
class="_icon-button_1215g_8 _primaryButton_221541"
|
||||
data-kind="primary"
|
||||
role="button"
|
||||
@@ -96,69 +96,20 @@ exports[`LobbyView > renders with AppBar android 1`] = `
|
||||
</div>
|
||||
<div
|
||||
class="_footer_20b7b4"
|
||||
data-button-size="lg"
|
||||
data-testid="footer-container"
|
||||
>
|
||||
<div
|
||||
class="_settingsLogoContainer_20b7b4"
|
||||
>
|
||||
<button
|
||||
aria-labelledby="_r_3c_"
|
||||
class="_icon-button_1215g_8 _settingsOnlyShowWide_20b7b4"
|
||||
data-kind="secondary"
|
||||
data-testid="settings-bottom-left"
|
||||
role="button"
|
||||
style="--cpd-icon-button-size: 32px;"
|
||||
tabindex="0"
|
||||
>
|
||||
<div
|
||||
class="_indicator-icon_j097f_17"
|
||||
style="--cpd-icon-button-size: 100%;"
|
||||
>
|
||||
<svg
|
||||
aria-hidden="true"
|
||||
fill="currentColor"
|
||||
height="1em"
|
||||
viewBox="0 0 24 24"
|
||||
width="1em"
|
||||
xmlns="http://www.w3.org/2000/svg"
|
||||
>
|
||||
<path
|
||||
d="M12 20q-.825 0-1.412-.587A1.93 1.93 0 0 1 10 18q0-.824.588-1.413A1.93 1.93 0 0 1 12 16q.825 0 1.412.587Q14 17.176 14 18t-.588 1.413A1.93 1.93 0 0 1 12 20m0-6q-.825 0-1.412-.588A1.93 1.93 0 0 1 10 12q0-.825.588-1.412A1.93 1.93 0 0 1 12 10q.825 0 1.412.588Q14 11.175 14 12t-.588 1.412A1.93 1.93 0 0 1 12 14m0-6q-.825 0-1.412-.588A1.93 1.93 0 0 1 10 6q0-.824.588-1.412A1.93 1.93 0 0 1 12 4q.825 0 1.412.588Q14 5.175 14 6q0 .824-.588 1.412A1.93 1.93 0 0 1 12 8"
|
||||
/>
|
||||
</svg>
|
||||
</div>
|
||||
</button>
|
||||
</div>
|
||||
class="_logoContainer_20b7b4"
|
||||
/>
|
||||
<div
|
||||
class="_buttons_20b7b4"
|
||||
>
|
||||
<button
|
||||
aria-labelledby="_r_3h_"
|
||||
class="_button_1nw83_8 _settingsOnlyShowNarrow_20b7b4 _has-icon_1nw83_60 _icon-only_1nw83_53"
|
||||
data-kind="secondary"
|
||||
data-size="lg"
|
||||
data-testid="settings-bottom-center"
|
||||
role="button"
|
||||
tabindex="0"
|
||||
>
|
||||
<svg
|
||||
aria-hidden="true"
|
||||
fill="currentColor"
|
||||
height="24"
|
||||
viewBox="0 0 24 24"
|
||||
width="24"
|
||||
xmlns="http://www.w3.org/2000/svg"
|
||||
>
|
||||
<path
|
||||
d="M12 20q-.825 0-1.412-.587A1.93 1.93 0 0 1 10 18q0-.824.588-1.413A1.93 1.93 0 0 1 12 16q.825 0 1.412.587Q14 17.176 14 18t-.588 1.413A1.93 1.93 0 0 1 12 20m0-6q-.825 0-1.412-.588A1.93 1.93 0 0 1 10 12q0-.825.588-1.412A1.93 1.93 0 0 1 12 10q.825 0 1.412.588Q14 11.175 14 12t-.588 1.412A1.93 1.93 0 0 1 12 14m0-6q-.825 0-1.412-.588A1.93 1.93 0 0 1 10 6q0-.824.588-1.412A1.93 1.93 0 0 1 12 4q.825 0 1.412.588Q14 5.175 14 6q0 .824-.588 1.412A1.93 1.93 0 0 1 12 8"
|
||||
/>
|
||||
</svg>
|
||||
</button>
|
||||
<button
|
||||
aria-busy="false"
|
||||
aria-checked="false"
|
||||
aria-disabled="true"
|
||||
aria-labelledby="_r_3m_"
|
||||
aria-labelledby="_r_2q_"
|
||||
class="_button_1nw83_8 _has-icon_1nw83_60 _icon-only_1nw83_53"
|
||||
data-kind="primary"
|
||||
data-size="lg"
|
||||
@@ -183,7 +134,7 @@ exports[`LobbyView > renders with AppBar android 1`] = `
|
||||
aria-busy="false"
|
||||
aria-checked="false"
|
||||
aria-disabled="true"
|
||||
aria-labelledby="_r_3r_"
|
||||
aria-labelledby="_r_2v_"
|
||||
class="_button_1nw83_8 _has-icon_1nw83_60 _icon-only_1nw83_53"
|
||||
data-kind="primary"
|
||||
data-size="lg"
|
||||
@@ -205,7 +156,29 @@ exports[`LobbyView > renders with AppBar android 1`] = `
|
||||
</svg>
|
||||
</button>
|
||||
<button
|
||||
aria-labelledby="_r_40_"
|
||||
aria-labelledby="_r_34_"
|
||||
class="_button_1nw83_8 _has-icon_1nw83_60 _icon-only_1nw83_53"
|
||||
data-kind="secondary"
|
||||
data-size="lg"
|
||||
data-testid="settings-bottom"
|
||||
role="button"
|
||||
tabindex="0"
|
||||
>
|
||||
<svg
|
||||
aria-hidden="true"
|
||||
fill="currentColor"
|
||||
height="24"
|
||||
viewBox="0 0 24 24"
|
||||
width="24"
|
||||
xmlns="http://www.w3.org/2000/svg"
|
||||
>
|
||||
<path
|
||||
d="M12 20q-.825 0-1.412-.587A1.93 1.93 0 0 1 10 18q0-.824.588-1.413A1.93 1.93 0 0 1 12 16q.825 0 1.412.587Q14 17.176 14 18t-.588 1.413A1.93 1.93 0 0 1 12 20m0-6q-.825 0-1.412-.588A1.93 1.93 0 0 1 10 12q0-.825.588-1.412A1.93 1.93 0 0 1 12 10q.825 0 1.412.588Q14 11.175 14 12t-.588 1.412A1.93 1.93 0 0 1 12 14m0-6q-.825 0-1.412-.588A1.93 1.93 0 0 1 10 6q0-.824.588-1.412A1.93 1.93 0 0 1 12 4q.825 0 1.412.588Q14 5.175 14 6q0 .824-.588 1.412A1.93 1.93 0 0 1 12 8"
|
||||
/>
|
||||
</svg>
|
||||
</button>
|
||||
<button
|
||||
aria-labelledby="_r_39_"
|
||||
class="_button_1nw83_8 _has-icon_1nw83_60 _icon-only_1nw83_53 _destructive_1nw83_110"
|
||||
data-kind="primary"
|
||||
data-size="lg"
|
||||
@@ -239,7 +212,7 @@ exports[`LobbyView > renders with AppBar ios 1`] = `
|
||||
>
|
||||
<header>
|
||||
<button
|
||||
aria-labelledby="_r_4a_"
|
||||
aria-labelledby="_r_3i_"
|
||||
class="_icon-button_1215g_8 _primaryButton_221541"
|
||||
data-kind="primary"
|
||||
role="button"
|
||||
@@ -328,69 +301,20 @@ exports[`LobbyView > renders with AppBar ios 1`] = `
|
||||
</div>
|
||||
<div
|
||||
class="_footer_20b7b4"
|
||||
data-button-size="lg"
|
||||
data-testid="footer-container"
|
||||
>
|
||||
<div
|
||||
class="_settingsLogoContainer_20b7b4"
|
||||
>
|
||||
<button
|
||||
aria-labelledby="_r_4g_"
|
||||
class="_icon-button_1215g_8 _settingsOnlyShowWide_20b7b4"
|
||||
data-kind="secondary"
|
||||
data-testid="settings-bottom-left"
|
||||
role="button"
|
||||
style="--cpd-icon-button-size: 32px;"
|
||||
tabindex="0"
|
||||
>
|
||||
<div
|
||||
class="_indicator-icon_j097f_17"
|
||||
style="--cpd-icon-button-size: 100%;"
|
||||
>
|
||||
<svg
|
||||
aria-hidden="true"
|
||||
fill="currentColor"
|
||||
height="1em"
|
||||
viewBox="0 0 24 24"
|
||||
width="1em"
|
||||
xmlns="http://www.w3.org/2000/svg"
|
||||
>
|
||||
<path
|
||||
d="M6 14q-.824 0-1.412-.588A1.93 1.93 0 0 1 4 12q0-.825.588-1.412A1.93 1.93 0 0 1 6 10q.824 0 1.412.588Q8 11.175 8 12t-.588 1.412A1.93 1.93 0 0 1 6 14m6 0q-.825 0-1.412-.588A1.93 1.93 0 0 1 10 12q0-.825.588-1.412A1.93 1.93 0 0 1 12 10q.825 0 1.412.588Q14 11.175 14 12t-.588 1.412A1.93 1.93 0 0 1 12 14m6 0q-.824 0-1.413-.588A1.93 1.93 0 0 1 16 12q0-.825.587-1.412A1.93 1.93 0 0 1 18 10q.824 0 1.413.588Q20 11.175 20 12t-.587 1.412A1.93 1.93 0 0 1 18 14"
|
||||
/>
|
||||
</svg>
|
||||
</div>
|
||||
</button>
|
||||
</div>
|
||||
class="_logoContainer_20b7b4"
|
||||
/>
|
||||
<div
|
||||
class="_buttons_20b7b4"
|
||||
>
|
||||
<button
|
||||
aria-labelledby="_r_4l_"
|
||||
class="_button_1nw83_8 _settingsOnlyShowNarrow_20b7b4 _has-icon_1nw83_60 _icon-only_1nw83_53"
|
||||
data-kind="secondary"
|
||||
data-size="lg"
|
||||
data-testid="settings-bottom-center"
|
||||
role="button"
|
||||
tabindex="0"
|
||||
>
|
||||
<svg
|
||||
aria-hidden="true"
|
||||
fill="currentColor"
|
||||
height="24"
|
||||
viewBox="0 0 24 24"
|
||||
width="24"
|
||||
xmlns="http://www.w3.org/2000/svg"
|
||||
>
|
||||
<path
|
||||
d="M6 14q-.824 0-1.412-.588A1.93 1.93 0 0 1 4 12q0-.825.588-1.412A1.93 1.93 0 0 1 6 10q.824 0 1.412.588Q8 11.175 8 12t-.588 1.412A1.93 1.93 0 0 1 6 14m6 0q-.825 0-1.412-.588A1.93 1.93 0 0 1 10 12q0-.825.588-1.412A1.93 1.93 0 0 1 12 10q.825 0 1.412.588Q14 11.175 14 12t-.588 1.412A1.93 1.93 0 0 1 12 14m6 0q-.824 0-1.413-.588A1.93 1.93 0 0 1 16 12q0-.825.587-1.412A1.93 1.93 0 0 1 18 10q.824 0 1.413.588Q20 11.175 20 12t-.587 1.412A1.93 1.93 0 0 1 18 14"
|
||||
/>
|
||||
</svg>
|
||||
</button>
|
||||
<button
|
||||
aria-busy="false"
|
||||
aria-checked="false"
|
||||
aria-disabled="true"
|
||||
aria-labelledby="_r_4q_"
|
||||
aria-labelledby="_r_3o_"
|
||||
class="_button_1nw83_8 _has-icon_1nw83_60 _icon-only_1nw83_53"
|
||||
data-kind="primary"
|
||||
data-size="lg"
|
||||
@@ -415,7 +339,7 @@ exports[`LobbyView > renders with AppBar ios 1`] = `
|
||||
aria-busy="false"
|
||||
aria-checked="false"
|
||||
aria-disabled="true"
|
||||
aria-labelledby="_r_4v_"
|
||||
aria-labelledby="_r_3t_"
|
||||
class="_button_1nw83_8 _has-icon_1nw83_60 _icon-only_1nw83_53"
|
||||
data-kind="primary"
|
||||
data-size="lg"
|
||||
@@ -437,7 +361,29 @@ exports[`LobbyView > renders with AppBar ios 1`] = `
|
||||
</svg>
|
||||
</button>
|
||||
<button
|
||||
aria-labelledby="_r_54_"
|
||||
aria-labelledby="_r_42_"
|
||||
class="_button_1nw83_8 _has-icon_1nw83_60 _icon-only_1nw83_53"
|
||||
data-kind="secondary"
|
||||
data-size="lg"
|
||||
data-testid="settings-bottom"
|
||||
role="button"
|
||||
tabindex="0"
|
||||
>
|
||||
<svg
|
||||
aria-hidden="true"
|
||||
fill="currentColor"
|
||||
height="24"
|
||||
viewBox="0 0 24 24"
|
||||
width="24"
|
||||
xmlns="http://www.w3.org/2000/svg"
|
||||
>
|
||||
<path
|
||||
d="M6 14q-.824 0-1.412-.588A1.93 1.93 0 0 1 4 12q0-.825.588-1.412A1.93 1.93 0 0 1 6 10q.824 0 1.412.588Q8 11.175 8 12t-.588 1.412A1.93 1.93 0 0 1 6 14m6 0q-.825 0-1.412-.588A1.93 1.93 0 0 1 10 12q0-.825.588-1.412A1.93 1.93 0 0 1 12 10q.825 0 1.412.588Q14 11.175 14 12t-.588 1.412A1.93 1.93 0 0 1 12 14m6 0q-.824 0-1.413-.588A1.93 1.93 0 0 1 16 12q0-.825.587-1.412A1.93 1.93 0 0 1 18 10q.824 0 1.413.588Q20 11.175 20 12t-.587 1.412A1.93 1.93 0 0 1 18 14"
|
||||
/>
|
||||
</svg>
|
||||
</button>
|
||||
<button
|
||||
aria-labelledby="_r_47_"
|
||||
class="_button_1nw83_8 _has-icon_1nw83_60 _icon-only_1nw83_53 _destructive_1nw83_110"
|
||||
data-kind="primary"
|
||||
data-size="lg"
|
||||
@@ -606,38 +552,12 @@ exports[`LobbyView > renders with header and participant count 1`] = `
|
||||
</div>
|
||||
<div
|
||||
class="_footer_20b7b4"
|
||||
data-button-size="lg"
|
||||
data-testid="footer-container"
|
||||
>
|
||||
<div
|
||||
class="_settingsLogoContainer_20b7b4"
|
||||
class="_logoContainer_20b7b4"
|
||||
>
|
||||
<button
|
||||
aria-labelledby="_r_6_"
|
||||
class="_icon-button_1215g_8 _settingsOnlyShowWide_20b7b4"
|
||||
data-kind="secondary"
|
||||
data-testid="settings-bottom-left"
|
||||
role="button"
|
||||
style="--cpd-icon-button-size: 32px;"
|
||||
tabindex="0"
|
||||
>
|
||||
<div
|
||||
class="_indicator-icon_j097f_17"
|
||||
style="--cpd-icon-button-size: 100%;"
|
||||
>
|
||||
<svg
|
||||
aria-hidden="true"
|
||||
fill="currentColor"
|
||||
height="1em"
|
||||
viewBox="0 0 24 24"
|
||||
width="1em"
|
||||
xmlns="http://www.w3.org/2000/svg"
|
||||
>
|
||||
<path
|
||||
d="M12 20q-.825 0-1.412-.587A1.93 1.93 0 0 1 10 18q0-.824.588-1.413A1.93 1.93 0 0 1 12 16q.825 0 1.412.587Q14 17.176 14 18t-.588 1.413A1.93 1.93 0 0 1 12 20m0-6q-.825 0-1.412-.588A1.93 1.93 0 0 1 10 12q0-.825.588-1.412A1.93 1.93 0 0 1 12 10q.825 0 1.412.588Q14 11.175 14 12t-.588 1.412A1.93 1.93 0 0 1 12 14m0-6q-.825 0-1.412-.588A1.93 1.93 0 0 1 10 6q0-.824.588-1.412A1.93 1.93 0 0 1 12 4q.825 0 1.412.588Q14 5.175 14 6q0 .824-.588 1.412A1.93 1.93 0 0 1 12 8"
|
||||
/>
|
||||
</svg>
|
||||
</div>
|
||||
</button>
|
||||
<div
|
||||
class="_logo_20b7b4"
|
||||
>
|
||||
@@ -746,33 +666,11 @@ exports[`LobbyView > renders with header and participant count 1`] = `
|
||||
<div
|
||||
class="_buttons_20b7b4"
|
||||
>
|
||||
<button
|
||||
aria-labelledby="_r_b_"
|
||||
class="_button_1nw83_8 _settingsOnlyShowNarrow_20b7b4 _has-icon_1nw83_60 _icon-only_1nw83_53"
|
||||
data-kind="secondary"
|
||||
data-size="lg"
|
||||
data-testid="settings-bottom-center"
|
||||
role="button"
|
||||
tabindex="0"
|
||||
>
|
||||
<svg
|
||||
aria-hidden="true"
|
||||
fill="currentColor"
|
||||
height="24"
|
||||
viewBox="0 0 24 24"
|
||||
width="24"
|
||||
xmlns="http://www.w3.org/2000/svg"
|
||||
>
|
||||
<path
|
||||
d="M12 20q-.825 0-1.412-.587A1.93 1.93 0 0 1 10 18q0-.824.588-1.413A1.93 1.93 0 0 1 12 16q.825 0 1.412.587Q14 17.176 14 18t-.588 1.413A1.93 1.93 0 0 1 12 20m0-6q-.825 0-1.412-.588A1.93 1.93 0 0 1 10 12q0-.825.588-1.412A1.93 1.93 0 0 1 12 10q.825 0 1.412.588Q14 11.175 14 12t-.588 1.412A1.93 1.93 0 0 1 12 14m0-6q-.825 0-1.412-.588A1.93 1.93 0 0 1 10 6q0-.824.588-1.412A1.93 1.93 0 0 1 12 4q.825 0 1.412.588Q14 5.175 14 6q0 .824-.588 1.412A1.93 1.93 0 0 1 12 8"
|
||||
/>
|
||||
</svg>
|
||||
</button>
|
||||
<button
|
||||
aria-busy="false"
|
||||
aria-checked="false"
|
||||
aria-disabled="true"
|
||||
aria-labelledby="_r_g_"
|
||||
aria-labelledby="_r_6_"
|
||||
class="_button_1nw83_8 _has-icon_1nw83_60 _icon-only_1nw83_53"
|
||||
data-kind="primary"
|
||||
data-size="lg"
|
||||
@@ -797,7 +695,7 @@ exports[`LobbyView > renders with header and participant count 1`] = `
|
||||
aria-busy="false"
|
||||
aria-checked="false"
|
||||
aria-disabled="true"
|
||||
aria-labelledby="_r_l_"
|
||||
aria-labelledby="_r_b_"
|
||||
class="_button_1nw83_8 _has-icon_1nw83_60 _icon-only_1nw83_53"
|
||||
data-kind="primary"
|
||||
data-size="lg"
|
||||
@@ -819,7 +717,29 @@ exports[`LobbyView > renders with header and participant count 1`] = `
|
||||
</svg>
|
||||
</button>
|
||||
<button
|
||||
aria-labelledby="_r_q_"
|
||||
aria-labelledby="_r_g_"
|
||||
class="_button_1nw83_8 _has-icon_1nw83_60 _icon-only_1nw83_53"
|
||||
data-kind="secondary"
|
||||
data-size="lg"
|
||||
data-testid="settings-bottom"
|
||||
role="button"
|
||||
tabindex="0"
|
||||
>
|
||||
<svg
|
||||
aria-hidden="true"
|
||||
fill="currentColor"
|
||||
height="24"
|
||||
viewBox="0 0 24 24"
|
||||
width="24"
|
||||
xmlns="http://www.w3.org/2000/svg"
|
||||
>
|
||||
<path
|
||||
d="M12 20q-.825 0-1.412-.587A1.93 1.93 0 0 1 10 18q0-.824.588-1.413A1.93 1.93 0 0 1 12 16q.825 0 1.412.587Q14 17.176 14 18t-.588 1.413A1.93 1.93 0 0 1 12 20m0-6q-.825 0-1.412-.588A1.93 1.93 0 0 1 10 12q0-.825.588-1.412A1.93 1.93 0 0 1 12 10q.825 0 1.412.588Q14 11.175 14 12t-.588 1.412A1.93 1.93 0 0 1 12 14m0-6q-.825 0-1.412-.588A1.93 1.93 0 0 1 10 6q0-.824.588-1.412A1.93 1.93 0 0 1 12 4q.825 0 1.412.588Q14 5.175 14 6q0 .824-.588 1.412A1.93 1.93 0 0 1 12 8"
|
||||
/>
|
||||
</svg>
|
||||
</button>
|
||||
<button
|
||||
aria-labelledby="_r_l_"
|
||||
class="_button_1nw83_8 _has-icon_1nw83_60 _icon-only_1nw83_53 _destructive_1nw83_110"
|
||||
data-kind="primary"
|
||||
data-size="lg"
|
||||
|
||||
@@ -422,6 +422,54 @@ describe("DeveloperSettingsTab", () => {
|
||||
expect(checkedValue).toBeChecked();
|
||||
},
|
||||
);
|
||||
|
||||
it("shows the compatibility fallback when matrix_2_0 is forced but the homeserver lacks sticky events", async () => {
|
||||
mockConfig({ matrix_rtc_mode: MatrixRTCMode.Matrix_2_0 });
|
||||
const client = createMockMatrixClient();
|
||||
vi.mocked(client.doesServerSupportUnstableFeature).mockResolvedValue(
|
||||
false,
|
||||
);
|
||||
|
||||
render(
|
||||
<TooltipProvider>
|
||||
<DeveloperSettingsTab
|
||||
client={client}
|
||||
env={{} as unknown as ImportMetaEnv}
|
||||
vm={outOfCallDeveloperSettingsTabViewModel}
|
||||
/>
|
||||
</TooltipProvider>,
|
||||
);
|
||||
|
||||
expect(
|
||||
await screen.findByText(/calls fall back to compatibility mode/),
|
||||
).toBeInTheDocument();
|
||||
const radios = getModeRadios();
|
||||
expect(radios.compatibility).toBeChecked();
|
||||
expect(radios.matrix20).not.toBeChecked();
|
||||
});
|
||||
|
||||
it("shows no fallback when matrix_2_0 is forced and the homeserver has sticky events", async () => {
|
||||
mockConfig({ matrix_rtc_mode: MatrixRTCMode.Matrix_2_0 });
|
||||
const client = createMockMatrixClient();
|
||||
|
||||
render(
|
||||
<TooltipProvider>
|
||||
<DeveloperSettingsTab
|
||||
client={client}
|
||||
env={{} as unknown as ImportMetaEnv}
|
||||
vm={outOfCallDeveloperSettingsTabViewModel}
|
||||
/>
|
||||
</TooltipProvider>,
|
||||
);
|
||||
|
||||
await waitFor(() =>
|
||||
expect(client.doesServerSupportUnstableFeature).toHaveBeenCalled(),
|
||||
);
|
||||
expect(
|
||||
screen.queryByText(/calls fall back to compatibility mode/),
|
||||
).toBeNull();
|
||||
expect(getModeRadios().matrix20).toBeChecked();
|
||||
});
|
||||
});
|
||||
|
||||
describe("KeyRotationStatus", () => {
|
||||
|
||||
@@ -146,7 +146,10 @@ export const DeveloperSettingsTab: FC<Props> = ({
|
||||
debugTileLayoutSetting,
|
||||
);
|
||||
|
||||
const [stickyEventsSupported, setStickyEventsSupported] = useState(false);
|
||||
// null until the homeserver has answered
|
||||
const [stickyEventsSupported, setStickyEventsSupported] = useState<
|
||||
boolean | null
|
||||
>(null);
|
||||
useEffect(() => {
|
||||
client
|
||||
.doesServerSupportUnstableFeature(UNSTABLE_MSC4354_STICKY_EVENTS)
|
||||
@@ -155,6 +158,8 @@ export const DeveloperSettingsTab: FC<Props> = ({
|
||||
})
|
||||
.catch((ex) => {
|
||||
logger.warn("Failed to check if sticky events are supported", ex);
|
||||
// As the call does
|
||||
setStickyEventsSupported(false);
|
||||
});
|
||||
}, [client]);
|
||||
|
||||
@@ -170,7 +175,13 @@ export const DeveloperSettingsTab: FC<Props> = ({
|
||||
| MatrixRTCMode
|
||||
| undefined;
|
||||
const matrixRTCModeForced = configMatrixRTCMode !== undefined;
|
||||
const effectiveMatrixRTCMode = configMatrixRTCMode ?? matrixRTCMode;
|
||||
// The call joins in compatibility mode instead, see `rtcParticipationOptions`
|
||||
const stickyFallback =
|
||||
configMatrixRTCMode === MatrixRTCMode.Matrix_2_0 &&
|
||||
stickyEventsSupported === false;
|
||||
const effectiveMatrixRTCMode = stickyFallback
|
||||
? MatrixRTCMode.Compatibility
|
||||
: (configMatrixRTCMode ?? matrixRTCMode);
|
||||
|
||||
const [showConnectionStats, setShowConnectionStats] = useSetting(
|
||||
showConnectionStatsSetting,
|
||||
@@ -569,6 +580,12 @@ export const DeveloperSettingsTab: FC<Props> = ({
|
||||
{t("developer_mode.matrixRTCMode.title")}
|
||||
</Heading>
|
||||
{matrixRTCModeForced && <p>Your deployment overrides the mode.</p>}
|
||||
{stickyFallback && (
|
||||
<p>
|
||||
Your homeserver does not support sticky events (MSC4354), so calls
|
||||
fall back to compatibility mode.
|
||||
</p>
|
||||
)}
|
||||
<Form>
|
||||
<InlineField
|
||||
name={matrixRTCModeRadioGroup}
|
||||
@@ -592,7 +609,7 @@ export const DeveloperSettingsTab: FC<Props> = ({
|
||||
<RadioControl
|
||||
checked={effectiveMatrixRTCMode === MatrixRTCMode.Matrix_2_0}
|
||||
value={MatrixRTCMode.Matrix_2_0}
|
||||
disabled={matrixRTCModeForced || !stickyEventsSupported}
|
||||
disabled={matrixRTCModeForced || stickyEventsSupported !== true}
|
||||
onChange={onMatrixRTCModeChange}
|
||||
/>
|
||||
}
|
||||
|
||||
@@ -304,7 +304,6 @@ const showFooterMs = 4000;
|
||||
|
||||
interface LayoutScanState {
|
||||
layout: Layout | null;
|
||||
overflowing: boolean;
|
||||
tiles: TileStore;
|
||||
}
|
||||
|
||||
@@ -457,10 +456,6 @@ export interface CallViewModel {
|
||||
* and header as overlays.
|
||||
*/
|
||||
edgeToEdge$: Behavior<boolean>;
|
||||
/**
|
||||
* Whether the call layout is overflowing the interface (causing it to scroll).
|
||||
*/
|
||||
overflowing$: Behavior<boolean>;
|
||||
|
||||
/**
|
||||
* Whether modals such as settings and reactions should be accessible at all.
|
||||
@@ -1341,7 +1336,6 @@ export function createCallViewModel$(
|
||||
let layout: Layout;
|
||||
let newTiles: TileStore;
|
||||
let pip: GridTileViewModel | undefined;
|
||||
let overflowing = false;
|
||||
switch (media.type) {
|
||||
case "grid":
|
||||
case "spotlight-landscape":
|
||||
@@ -1353,7 +1347,6 @@ export function createCallViewModel$(
|
||||
setVisibleTiles,
|
||||
prevTiles,
|
||||
);
|
||||
overflowing = newTiles.gridTiles.length > visibleTiles;
|
||||
break;
|
||||
case "spotlight-expanded":
|
||||
[layout, newTiles] = spotlightExpandedLayout(
|
||||
@@ -1387,9 +1380,9 @@ export function createCallViewModel$(
|
||||
tile.setShowOutline(tile === pip);
|
||||
}
|
||||
|
||||
return { layout, overflowing, tiles: newTiles };
|
||||
return { layout, tiles: newTiles };
|
||||
},
|
||||
{ layout: null, overflowing: false, tiles: TileStore.empty() },
|
||||
{ layout: null, tiles: TileStore.empty() },
|
||||
),
|
||||
),
|
||||
);
|
||||
@@ -1405,10 +1398,6 @@ export function createCallViewModel$(
|
||||
),
|
||||
);
|
||||
|
||||
const overflowing$ = scope.behavior<boolean>(
|
||||
layoutInternals$.pipe(map(({ overflowing }) => overflowing)),
|
||||
);
|
||||
|
||||
/**
|
||||
* The current generation of the tile store, exposed for debugging purposes.
|
||||
*/
|
||||
@@ -1652,7 +1641,6 @@ export function createCallViewModel$(
|
||||
settingsOpen$: settingsOpen$,
|
||||
setSettingsOpen$: setSettingsOpen$,
|
||||
edgeToEdge$,
|
||||
overflowing$,
|
||||
earpieceMode$: earpieceMode$,
|
||||
audioOutputSwitcher$: audioOutputSwitcher$,
|
||||
reconnecting$,
|
||||
|
||||
@@ -31,6 +31,8 @@ test.each<{
|
||||
false,
|
||||
callIntent,
|
||||
allowJoinUnmutedViaIntent,
|
||||
true,
|
||||
true,
|
||||
);
|
||||
expect(audioEnabled).toBe(true);
|
||||
expect(videoEnabled).toBe(callIntent !== RTC_CALL_INTENT_AUDIO);
|
||||
@@ -50,6 +52,8 @@ test.each<{
|
||||
true,
|
||||
callIntent,
|
||||
false,
|
||||
true,
|
||||
true,
|
||||
);
|
||||
expect(audioEnabled).toBe(false);
|
||||
expect(videoEnabled).toBe(false);
|
||||
@@ -69,8 +73,32 @@ test.each<{
|
||||
true,
|
||||
callIntent,
|
||||
true,
|
||||
true,
|
||||
true,
|
||||
);
|
||||
expect(audioEnabled).toBe(true);
|
||||
expect(videoEnabled).toBe(callIntent !== RTC_CALL_INTENT_AUDIO);
|
||||
},
|
||||
);
|
||||
|
||||
test.each<{
|
||||
initialAudioEnabled: boolean;
|
||||
initialVideoEnabled: boolean;
|
||||
}>([
|
||||
{ initialAudioEnabled: false, initialVideoEnabled: true },
|
||||
{ initialAudioEnabled: true, initialVideoEnabled: false },
|
||||
{ initialAudioEnabled: false, initialVideoEnabled: false },
|
||||
])(
|
||||
"Should start the devices the intent disables muted, even if allowed unmuted (initialAudioEnabled: $initialAudioEnabled, initialVideoEnabled: $initialVideoEnabled)",
|
||||
({ initialAudioEnabled, initialVideoEnabled }) => {
|
||||
const { audioEnabled, videoEnabled } = calculateInitialMuteState(
|
||||
false,
|
||||
RTC_CALL_INTENT_VIDEO,
|
||||
true,
|
||||
initialAudioEnabled,
|
||||
initialVideoEnabled,
|
||||
);
|
||||
expect(audioEnabled).toBe(initialAudioEnabled);
|
||||
expect(videoEnabled).toBe(initialVideoEnabled);
|
||||
},
|
||||
);
|
||||
|
||||
@@ -21,14 +21,20 @@ import {
|
||||
* @param allowJoinUnmutedViaIntent Whether the host vouches for the intent
|
||||
* enough to start the user unmuted without a lobby (see
|
||||
* `HostBridge.allowJoinUnmutedViaIntent`).
|
||||
* @param initialAudioEnabled Whether the intent lets the microphone start on
|
||||
* (see `UrlConfiguration.initialAudioEnabled`). Only ever turns it off.
|
||||
* @param initialVideoEnabled Whether the intent lets the camera start on (see
|
||||
* `UrlConfiguration.initialVideoEnabled`). Only ever turns it off.
|
||||
*/
|
||||
export function calculateInitialMuteState(
|
||||
skipLobby: boolean,
|
||||
callIntent: RTCCallIntent | undefined,
|
||||
allowJoinUnmutedViaIntent: boolean,
|
||||
initialAudioEnabled: boolean,
|
||||
initialVideoEnabled: boolean,
|
||||
): { audioEnabled: boolean; videoEnabled: boolean } {
|
||||
logger.debug(
|
||||
`calculateInitialMuteState: skipLobby=${skipLobby}, callIntent=${callIntent} allowJoinUnmutedViaIntent=${allowJoinUnmutedViaIntent}`,
|
||||
`calculateInitialMuteState: skipLobby=${skipLobby}, callIntent=${callIntent} allowJoinUnmutedViaIntent=${allowJoinUnmutedViaIntent} initialAudioEnabled=${initialAudioEnabled} initialVideoEnabled=${initialVideoEnabled}`,
|
||||
);
|
||||
|
||||
if (skipLobby && !allowJoinUnmutedViaIntent) {
|
||||
@@ -44,9 +50,9 @@ export function calculateInitialMuteState(
|
||||
// A host that vouches for the intent is a trusted environment, so it allows
|
||||
// unmuted by default. Same for when showing a lobby, as users can adjust
|
||||
// their settings there. Additionally, if the call intent is "m.audio", we
|
||||
// disable video by default.
|
||||
// disable video by default. The intent can still start either off.
|
||||
return {
|
||||
audioEnabled: true,
|
||||
videoEnabled: callIntent != RTC_CALL_INTENT_AUDIO,
|
||||
audioEnabled: initialAudioEnabled,
|
||||
videoEnabled: initialVideoEnabled && callIntent != RTC_CALL_INTENT_AUDIO,
|
||||
};
|
||||
}
|
||||
|
||||
@@ -40,6 +40,8 @@ export function useMuteStates(): MuteStates | null {
|
||||
urlParams.skipLobby,
|
||||
urlParams.callIntent,
|
||||
hostBridge.allowJoinUnmutedViaIntent,
|
||||
urlParams.initialAudioEnabled ?? true,
|
||||
urlParams.initialVideoEnabled ?? true,
|
||||
),
|
||||
hostBridge,
|
||||
),
|
||||
|
||||
@@ -359,7 +359,6 @@ const ScreenShareVolumeButton: FC<ScreenShareVolumeButtonProps> = ({ vm }) => {
|
||||
className={styles.volumeMenuItem}
|
||||
onSelect={null}
|
||||
label={null}
|
||||
hideChevron={true}
|
||||
>
|
||||
<button className={styles.menuMuteButton} onClick={onMuteButtonClick}>
|
||||
<VolumeIcon aria-hidden width={24} height={24} />
|
||||
@@ -392,10 +391,6 @@ interface Props {
|
||||
showRingingStatus: boolean;
|
||||
focusable: boolean;
|
||||
className?: string;
|
||||
/**
|
||||
* CSS class of the individual spotlight items.
|
||||
*/
|
||||
itemClassName?: string;
|
||||
style?: ComponentProps<typeof animated.div>["style"];
|
||||
}
|
||||
|
||||
@@ -411,7 +406,6 @@ export const SpotlightTile: FC<Props> = ({
|
||||
showRingingStatus,
|
||||
focusable = true,
|
||||
className,
|
||||
itemClassName,
|
||||
style,
|
||||
}) => {
|
||||
const { t } = useTranslation();
|
||||
@@ -535,7 +529,6 @@ export const SpotlightTile: FC<Props> = ({
|
||||
// remove all scroll snap points except for just the one media
|
||||
// that we want to bring into view
|
||||
snap={scrollToId === null || scrollToId === vm.id}
|
||||
className={itemClassName}
|
||||
aria-hidden={(scrollToId ?? visibleId) !== vm.id}
|
||||
/>
|
||||
))}
|
||||
|
||||
@@ -53,6 +53,13 @@ window.matchMedia = global.matchMedia = (): MediaQueryList =>
|
||||
removeEventListener: () => {},
|
||||
}) as Partial<MediaQueryList> as MediaQueryList;
|
||||
|
||||
// Disable animations. jsdom computes `animation-name` from our stylesheets but
|
||||
// never runs an animation, so anything that waits for `animationend` before
|
||||
// unmounting (Radix dialogs, for one) would stay mounted forever.
|
||||
const noAnimations = document.createElement("style");
|
||||
noAnimations.textContent = "* { animation: none !important; }";
|
||||
document.head.appendChild(noAnimations);
|
||||
|
||||
// jsdom does no layout and has no ResizeObserver. The call view observes the
|
||||
// size of its root element; this one reports nothing, so that element stays at
|
||||
// whatever size jsdom says it is unless a test says otherwise.
|
||||
|
||||
@@ -5,8 +5,9 @@ SPDX-License-Identifier: AGPL-3.0-only OR LicenseRef-Element-Commercial
|
||||
Please see LICENSE in the repository root for full details.
|
||||
*/
|
||||
|
||||
import { defineConfig } from "vite";
|
||||
import { defineConfig, mergeConfig } from "vite";
|
||||
import { posix } from "node:path";
|
||||
import { fileURLToPath } from "node:url";
|
||||
|
||||
import { vitePluginsConfig, withoutMatrixCrypto } from "./vite.config.ts";
|
||||
import { scopeStylesToRoot } from "./component/build/scopeStylesToRoot.ts";
|
||||
@@ -21,17 +22,23 @@ export default defineConfig(({ mode }) => {
|
||||
return {
|
||||
...base,
|
||||
plugins: [...(base.plugins ?? []), withoutMatrixCrypto()],
|
||||
resolve: {
|
||||
...base.resolve,
|
||||
alias: {
|
||||
...base.resolve?.alias,
|
||||
// mergeConfig appends to the base's aliases, whatever form they are in
|
||||
resolve: mergeConfig(base.resolve ?? {}, {
|
||||
alias: [
|
||||
// react-i18next depends on the CommonJS `use-sync-external-store/shim`, whose
|
||||
// `require("react")` cannot be bundled against an external React: rolldown leaves a
|
||||
// `require` shim that throws in the browser. React 18+ provides `useSyncExternalStore`
|
||||
// itself, so point the shim at React.
|
||||
"use-sync-external-store/shim": "react",
|
||||
},
|
||||
},
|
||||
{ find: "use-sync-external-store/shim", replacement: "react" },
|
||||
// Only the bare name, not its subpaths: see component/guestJsSdk.ts
|
||||
{
|
||||
find: /^matrix-js-sdk$/,
|
||||
replacement: fileURLToPath(
|
||||
new URL("./component/guestJsSdk.ts", import.meta.url),
|
||||
),
|
||||
},
|
||||
],
|
||||
}),
|
||||
// A library has no public directory to serve. Without this the build copies
|
||||
// whatever is in `public` — including the developer's own config.json, which
|
||||
// is not in the repository — into the output we would publish.
|
||||
|
||||
Reference in New Issue
Block a user