Compare commits

..

1 Commits

Author SHA1 Message Date
lebaudantoine 61f12a9842 ⚗️ first attempt at distilling the UI kit
No LLMs were harmed during this experiment.
2026-11-17 01:10:05 +01:00
155 changed files with 1848 additions and 1498 deletions
-6
View File
@@ -31,11 +31,6 @@ and this project adheres to
- 🚸(frontend) bring new speakers to the top of the carousel
- 🚸(frontend) bring raised hands into view in the carousel
- ⚡️(frontend) serve illustrations as WebP with a PNG fallback
- ⚡️(frontend) preload notification sound on the pre-join screen when idle
- ⚡️(frontend) cache mediapipe models served by nginx
- ⚡️(frontend) preload background effects assets on hover
- ⚡️(frontend) lazy load the settings dialog
- ⚡️(frontend) serve preset virtual backgrounds as WebP
### Fixed
@@ -56,7 +51,6 @@ and this project adheres to
- ♿️(frontend) show the focus ring on connection test detail cards
- ♿️(frontend) use a heading for every connection test card title
- ♿️(frontend) put the ProConnect link label inside the link
- ⚡️(frontend) serve sounds as content-hashed, long-term cached assets
## [1.37.0] - 2026-11-01
+1 -1
View File
@@ -33,7 +33,7 @@ server {
}
# Serve static files with caching
location ~* ^/assets/.*\.(css|js|json|png|jpg|jpeg|gif|webp|ico|svg|woff|woff2|ttf|eot|mp3)$ {
location ~* ^/assets/.*\.(css|js|json|png|jpg|jpeg|gif|webp|ico|svg|woff|woff2|ttf|eot)$ {
expires 30d;
add_header Cache-Control "public, max-age=2592000";
}
+1 -6
View File
@@ -71,13 +71,8 @@ server {
add_header Cache-Control "public, max-age=2592000";
}
location ^~ /assets/mediapipe/models/ {
expires 30d;
add_header Cache-Control "public, max-age=2592000";
}
# Serve static files with caching
location ~* ^/assets/.*\.(css|js|json|png|jpg|jpeg|gif|webp|ico|svg|woff|woff2|ttf|eot|mp3)$ {
location ~* ^/assets/.*\.(css|js|json|png|jpg|jpeg|gif|webp|ico|svg|woff|woff2|ttf|eot)$ {
expires 30d;
add_header Cache-Control "public, max-age=2592000";
}
+1 -6
View File
@@ -10,13 +10,8 @@ server {
add_header Cache-Control "public, max-age=2592000";
}
location ^~ /assets/mediapipe/models/ {
expires 30d;
add_header Cache-Control "public, max-age=2592000";
}
# Serve static files with caching
location ~* ^/assets/.*\.(css|js|json|png|jpg|jpeg|gif|webp|ico|svg|woff|woff2|ttf|eot|mp3)$ {
location ~* ^/assets/.*\.(css|js|json|png|jpg|jpeg|gif|webp|ico|svg|woff|woff2|ttf|eot)$ {
expires 30d;
add_header Cache-Control "public, max-age=2592000";
}
+2 -2
View File
@@ -73,9 +73,9 @@ export default tseslint.config(
},
},
// CJS and root-level JS config files (postcss.config.js, etc.)
// CJS, root-level JS config files (postcss.config.js, etc.) and Node scripts
{
files: ['**/*.cjs', '*.config.js'],
files: ['**/*.cjs', '*.config.js', 'scripts/**/*.mjs'],
languageOptions: {
globals: {
...globals.node,
+14 -11
View File
@@ -22,7 +22,6 @@
"@tanstack/react-query": "5.101.4",
"@timephy/rnnoise-wasm": "1.0.0",
"hoofd": "1.7.3",
"howler": "2.2.4",
"humanize-duration": "3.34.1",
"i18next": "26.3.6",
"i18next-browser-languagedetector": "8.2.1",
@@ -36,6 +35,7 @@
"react-dom": "18.3.1",
"react-i18next": "17.0.12",
"react-stately": "3.49.0",
"use-sound": "5.0.0",
"valtio": "2.3.2",
"wouter": "3.10.0"
},
@@ -44,7 +44,6 @@
"@pandacss/dev": "1.11.1",
"@tanstack/eslint-plugin-query": "5.100.14",
"@tanstack/react-query-devtools": "5.100.14",
"@types/howler": "2.2.13",
"@types/humanize-duration": "3.27.4",
"@types/node": "24.12.4",
"@types/react": "18.3.12",
@@ -2556,13 +2555,6 @@
"dev": true,
"license": "MIT"
},
"node_modules/@types/howler": {
"version": "2.2.13",
"resolved": "https://registry.npmjs.org/@types/howler/-/howler-2.2.13.tgz",
"integrity": "sha512-40+EBjqIHHrC4VShlz/7i0lBUsE3QkgzZinQQji74Hd8sBkJZUBaT7LWFLK6rcabsDOOQpoMbEJvtaFQwxOu/g==",
"dev": true,
"license": "MIT"
},
"node_modules/@types/humanize-duration": {
"version": "3.27.4",
"resolved": "https://registry.npmjs.org/@types/humanize-duration/-/humanize-duration-3.27.4.tgz",
@@ -6466,8 +6458,7 @@
"node_modules/howler": {
"version": "2.2.4",
"resolved": "https://registry.npmjs.org/howler/-/howler-2.2.4.tgz",
"integrity": "sha512-iARIBPgcQrwtEr+tALF+rapJ8qSc+Set2GJQl7xT1MQzWaVkFebdJhR3alVlSiUf5U7nAANKuj3aWpwerocD5w==",
"license": "MIT"
"integrity": "sha512-iARIBPgcQrwtEr+tALF+rapJ8qSc+Set2GJQl7xT1MQzWaVkFebdJhR3alVlSiUf5U7nAANKuj3aWpwerocD5w=="
},
"node_modules/html-parse-stringify": {
"version": "4.0.1",
@@ -11186,6 +11177,18 @@
"punycode": "^2.1.0"
}
},
"node_modules/use-sound": {
"version": "5.0.0",
"resolved": "https://registry.npmjs.org/use-sound/-/use-sound-5.0.0.tgz",
"integrity": "sha512-MNHT3FFC5HxNCrgZtrnpIMJI2cw/0D2xismcrtyht8BTuF5FhFhb57xO/jlQr2xJaFrc/0btzRQvGyHQwB7PVA==",
"license": "MIT",
"dependencies": {
"howler": "^2.2.4"
},
"peerDependencies": {
"react": ">=16.8"
}
},
"node_modules/use-sync-external-store": {
"version": "1.6.0",
"resolved": "https://registry.npmjs.org/use-sync-external-store/-/use-sync-external-store-1.6.0.tgz",
+2 -2
View File
@@ -12,6 +12,7 @@
"lint:fix": "eslint . --fix",
"preview": "vite preview",
"i18n:extract": "npx i18next -c i18next-parser.config.json",
"theme:sync": "node scripts/sync-ui-kit-tokens.mjs",
"format": "prettier --write ./src",
"check": "prettier --check ./src"
},
@@ -30,7 +31,6 @@
"@tanstack/react-query": "5.101.4",
"@timephy/rnnoise-wasm": "1.0.0",
"hoofd": "1.7.3",
"howler": "2.2.4",
"humanize-duration": "3.34.1",
"i18next": "26.3.6",
"i18next-browser-languagedetector": "8.2.1",
@@ -44,6 +44,7 @@
"react-dom": "18.3.1",
"react-i18next": "17.0.12",
"react-stately": "3.49.0",
"use-sound": "5.0.0",
"valtio": "2.3.2",
"wouter": "3.10.0"
},
@@ -52,7 +53,6 @@
"@pandacss/dev": "1.11.1",
"@tanstack/eslint-plugin-query": "5.100.14",
"@tanstack/react-query-devtools": "5.100.14",
"@types/howler": "2.2.13",
"@types/humanize-duration": "3.27.4",
"@types/node": "24.12.4",
"@types/react": "18.3.12",
+8 -421
View File
@@ -1,431 +1,18 @@
import pandaPreset from '@pandacss/preset-panda'
import {
Config,
Tokens,
defineConfig,
defineSemanticTokens,
defineTextStyles,
defineTokens,
} from '@pandacss/dev'
import { defineConfig } from '@pandacss/dev'
import { conditions, theme } from './src/styles/theme'
const spacing: Tokens['spacing'] = {
0: { value: '0rem' },
0.125: { value: '0.125rem' },
0.25: { value: '0.25rem' },
0.375: { value: '0.375rem' },
0.5: { value: '0.5rem' },
0.625: { value: '0.625rem' },
0.75: { value: '0.75rem' },
1: { value: '1rem' },
1.25: { value: '1.25rem' },
1.5: { value: '1.5rem' },
1.75: { value: '1.75rem' },
2: { value: '2rem' },
2.25: { value: '2.25rem' },
2.5: { value: '2.5rem' },
2.75: { value: '2.75rem' },
3: { value: '3rem' },
3.5: { value: '3.5rem' },
4: { value: '4rem' },
}
const config: Config = {
export default defineConfig({
preflight: true,
include: ['./src/**/*.{js,jsx,ts,tsx}'],
exclude: [],
jsxFramework: 'react',
outdir: 'src/styled-system',
globalFontface: {},
// The document font follows the `sans` token on every page: this is the
// variable custom themes and the accessibility fonts override.
globalVars: {
'--global-font-body': 'var(--fonts-sans)',
},
theme: {
...pandaPreset.theme,
// media queries are defined in em so that zooming with text-only mode triggers breakpoints
breakpoints: {
xs: '22.6em', // 360px (we assume less than that are old/entry level mobile phones)
xsm: '31.25em', // 500px,
sm: '40em', // 640px
md: '48em', // 768px
lg: '64em', // 1024px
xl: '80em', // 1280px
'2xl': '96em', // 1536px
},
keyframes: {
slide: {
from: {
transform: 'var(--origin)',
opacity: 0,
},
to: {
transform: 'translateY(0)',
opacity: 1,
},
},
fade: { from: { opacity: 0 }, to: { opacity: 1 } },
pulse: {
'0%': { boxShadow: '0 0 0 0 rgba(255, 255, 255, 0.7)' },
'75%': { boxShadow: '0 0 0 30px rgba(255, 255, 255, 0)' },
'100%': { boxShadow: '0 0 0 0 rgba(255, 255, 255, 0)' },
},
active_speaker: {
'0%': { height: '25%' },
'25%': { height: '45%' },
'50%': { height: '20%' },
'100%': { height: '55%' },
},
active_speaker_small: {
'0%': { height: '20%' },
'25%': { height: '25%' },
'50%': { height: '18%' },
'100%': { height: '25%' },
},
wave_hand: {
'0%': { transform: 'rotate(0deg)' },
'20%': { transform: 'rotate(-20deg)' },
'80%': { transform: 'rotate(20deg)' },
'100%': { transform: 'rotate(0)' },
},
pulse_background: {
'0%': { opacity: '1' },
'50%': { opacity: '0.65' },
'100%': { opacity: '1' },
},
rotate: {
'0%': {
transform: 'rotate(0deg)',
},
'100%': {
transform: 'rotate(360deg)',
},
},
prixClipFix: {
'0%': {
clipPath: 'polygon(50% 50%, 0 0, 0 0, 0 0, 0 0, 0 0)',
},
'25%': {
clipPath: 'polygon(50% 50%, 0 0, 100% 0, 100% 0, 100% 0, 100% 0)',
},
'50%': {
clipPath:
'polygon(50% 50%, 0 0, 100% 0, 100% 100%, 100% 100%, 100% 100%)',
},
'75%': {
clipPath: 'polygon(50% 50%, 0 0, 100% 0, 100% 100%, 0 100%, 0 100%)',
},
'100%': {
clipPath: 'polygon(50% 50%, 0 0, 100% 0, 100% 100%, 0 100%, 0 0)',
},
},
overlayIn: {
from: { opacity: 0 },
to: { opacity: 0.6 },
},
},
tokens: defineTokens({
/* we take a few things from the panda preset but for now we clear out some stuff.
* This way we'll only add the things we need step by step and prevent using lots of different things.
*/
...pandaPreset.theme.tokens,
colors: defineTokens.colors({
...pandaPreset.theme.tokens.colors,
primaryDark: {
50: { value: '#161622' },
75: { value: '#222234' },
100: { value: '#2D2D46' },
200: { value: '#43436A' },
300: { value: '#5A5A8F' },
400: { value: '#7070B3' },
500: { value: '#8787D7' },
600: { value: '#9D9DDF' },
700: { value: '#B3B3E7' },
800: { value: '#C9C9EE' },
900: { value: '#DFDFF6' },
950: { value: '#F5F5FE' },
action: { value: '#C1C1FB' },
},
primary: {
50: { value: '#F5F5FE' },
100: { value: '#ECECFE' },
200: { value: '#E3E3FB' },
300: { value: '#CACAFB' },
400: { value: '#8585F6' },
500: { value: '#6A6AF4' },
600: { value: '#313178' },
700: { value: '#272747' },
800: { value: '#000091' },
900: { value: '#21213F' },
950: { value: '#1B1B35' },
action: { value: '#1212FF' },
},
greyscale: {
'000': { value: '#FFFFFF' },
50: { value: '#F6F6F6' },
100: { value: '#EEEEEE' },
200: { value: '#E5E5E5' },
250: { value: '#DDDDDD' },
300: { value: '#CECECE' },
400: { value: '#929292' },
500: { value: '#7C7C7C' },
600: { value: '#666666' },
700: { value: '#3A3A3A' },
750: { value: '#353535' },
800: { value: '#2A2A2A' },
900: { value: '#242424' },
950: { value: '#1E1E1E' },
1000: { value: '#161616' },
},
error: {
100: { value: '#261212' },
200: { value: '#6C302E' },
300: { value: '#983533' },
400: { value: '#CA3632' },
500: { value: '#EF413D' },
600: { value: '#EE6A66' },
700: { value: '#F28D8A' },
800: { value: '#F6AFAD' },
900: { value: '#FAD2D1' },
950: { value: '#FFF4F4' },
},
}),
animations: {},
blurs: {},
/* just directly use values as tokens. This allows us to follow a specific design scale,
* without having to remember what 'sm' or '2xl' actually means.
*
* see semanticTokens for tokens targeting specific usages
*/
fonts: {
sans: {
value: [
'ui-sans-serif',
'system-ui',
'-apple-system',
'BlinkMacSystemFont',
'"Segoe UI"',
'Roboto',
'"Helvetica Neue"',
'Arial',
'"Noto Sans"',
'sans-serif',
'"Apple Color Emoji"',
'"Segoe UI Emoji"',
'"Segoe UI Symbol"',
'"Noto Color Emoji"',
],
},
serif: {
value: [
'ui-serif',
'Georgia',
'Cambria',
'"Times New Roman"',
'Times',
'serif',
],
},
mono: {
value: [
'Source Code Pro',
'ui-monospace',
'SFMono-Regular',
'Menlo',
'Monaco',
'Consolas',
'"Liberation Mono"',
'"Courier New"',
'monospace',
],
},
},
fontSizes: {
10: { value: '0.625rem' },
12: { value: '0.75rem' },
14: { value: '0.875rem' },
16: { value: '1rem' },
20: { value: '1.25rem' },
24: { value: '1.5rem' },
28: { value: '1.75rem' },
32: { value: '2rem' },
40: { value: '2.375rem' },
48: { value: '3rem' },
64: { value: '4rem' },
},
letterSpacings: {},
shadows: {
sm: {
value: [
'0 1px 3px 0 rgb(0 0 0 / 0.1)',
'0 1px 2px -1px rgb(0 0 0 / 0.1)',
],
},
},
lineHeights: {
1: { value: '1' },
1.25: { value: '1.25' },
1.375: { value: '1.375' },
1.5: { value: '1.5' },
1.625: { value: '1.625' },
2: { value: '2' },
},
radii: {
4: { value: '0.25rem' },
6: { value: '0.375rem' },
8: { value: '0.5rem' },
16: { value: '1rem' },
full: { value: '9999px' },
},
sizes: {
...spacing,
full: { value: '100%' },
min: { value: 'min-content' },
max: { value: 'max-content' },
fit: { value: 'fit-content' },
// room layout
'room-side-panel': { value: '360px' },
'room-side-panel-margin': { value: '1.5rem' },
'room-control-bar': { value: '80px' },
'room-reaction-toolbar-height': { value: '42px' },
'tooltip-spacing': { value: '8px' },
},
spacing,
}),
semanticTokens: defineSemanticTokens({
colors: {
default: {
text: { value: '{colors.greyscale.1000}' },
bg: { value: 'white' },
subtle: { value: '{colors.gray.100}' },
'subtle-text': { value: '{colors.gray.600}' },
},
box: {
text: { value: '{colors.default.text}' },
bg: { value: '{colors.white}' },
border: { value: '{colors.gray.300}' },
},
control: {
DEFAULT: { value: '{colors.gray.100}' },
hover: { value: '{colors.gray.200}' },
active: { value: '{colors.gray.300}' },
text: { value: '{colors.default.text}' },
border: { value: '{colors.gray.500}' },
subtle: { value: '{colors.gray.400}' },
},
primary: {
DEFAULT: { value: '{colors.blue.700}' },
hover: { value: '{colors.blue.800}' },
active: { value: '{colors.blue.900}' },
text: { value: '{colors.white}' },
warm: { value: '{colors.blue.300}' },
subtle: { value: '{colors.blue.100}' },
'subtle-text': { value: '{colors.blue.700}' },
},
danger: {
DEFAULT: { value: '{colors.red.600}' },
hover: { value: '{colors.red.700}' },
active: { value: '{colors.red.800}' },
text: { value: '{colors.white}' },
subtle: { value: '{colors.red.100}' },
'subtle-text': { value: '{colors.red.700}' },
...pandaPreset.theme.tokens.colors.red,
},
alert: {
DEFAULT: { value: '{colors.blue.700}' },
notification: { value: '{colors.red.600}' },
},
success: {
DEFAULT: { value: '{colors.green.700}' },
hover: { value: '{colors.green.800}' },
active: { value: '{colors.green.900}' },
text: { value: '{colors.white}' },
subtle: { value: '{colors.green.100}' },
'subtle-text': { value: '{colors.green.800}' },
...pandaPreset.theme.tokens.colors.green,
},
warning: {
DEFAULT: { value: '{colors.amber.700}' },
hover: { value: '{colors.amber.800}' },
active: { value: '{colors.amber.900}' },
text: { value: '{colors.white}' },
subtle: { value: '{colors.amber.100}' },
'subtle-text': { value: '{colors.amber.700}' },
},
focusRing: { value: 'rgb(74, 121, 199)' },
},
shadows: {
box: { value: '{shadows.sm}' },
},
spacing: {
boxPadding: {
DEFAULT: { value: '{spacing.2}' },
sm: { value: '{spacing.1}' },
xs: { value: '{spacing.0.5}' },
},
boxMargin: {
xs: { value: '{spacing.0.5}' },
DEFAULT: { value: '{spacing.1}' },
lg: { value: '{spacing.2}' },
},
paragraph: { value: '{spacing.0.5}' },
heading: { value: '{spacing.1}' },
gutter: { value: '{spacing.1}' },
textfield: { value: '{spacing.1}' },
},
}),
textStyles: defineTextStyles({
display: {
value: {
fontSize: '3rem',
lineHeight: '2rem',
fontWeight: 700,
},
},
h1: {
value: {
fontSize: '1.5rem',
lineHeight: '2rem',
fontWeight: 700,
},
},
h2: {
value: {
fontSize: '1.25rem',
lineHeight: '1.75rem',
fontWeight: 700,
},
},
h3: {
value: {
fontSize: '1.125rem',
lineHeight: '1.75rem',
},
},
body: {
value: {
fontSize: '1rem',
lineHeight: '1.5',
},
},
sm: {
value: {
fontSize: '0.875rem',
lineHeight: '1.25rem',
},
},
xs: {
value: {
fontSize: '0.825rem',
lineHeight: '1.15rem',
},
},
badge: {
value: {
fontSize: '0.75rem',
lineHeight: '1rem',
},
},
}),
},
}
export default defineConfig(config)
conditions,
theme,
})
Binary file not shown.

Before

Width:  |  Height:  |  Size: 172 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 309 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 394 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 436 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 202 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 222 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 294 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 348 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 7.3 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 9.1 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 11 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 11 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 9.9 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 8.4 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 10 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 11 KiB

+284
View File
@@ -0,0 +1,284 @@
#!/usr/bin/env node
/**
* Mirrors the colors of the La Suite UI kit into Panda token files.
*
* The UI kit (https://github.com/suitenumerique/ui-kit) is the source of truth
* for our design tokens. It publishes them as CSS custom properties in the
* stylesheet of `@gouvfr-lasuite/ui-components`, one block per theme. This
* script reads one theme out of that stylesheet and rewrites:
*
* src/styles/theme/ui-kit/colors.ts the kit's `globals.colors`
* src/styles/theme/ui-kit/contextuals.ts the kit's `contextuals` (light/dark)
*
* Usage:
* npm run theme:sync re-generate from the pinned release
* npm run theme:sync -- --version 1.6.0 move to another release of the kit
* npm run theme:sync -- --theme default mirror another theme of the kit
* npm run theme:sync -- --css ./style.css read a stylesheet from disk
*
* When moving to another release, also update UI_KIT_VERSION below so that the
* next run stays on it.
*/
import { execFileSync } from 'node:child_process'
import { mkdtempSync, readFileSync, rmSync, writeFileSync } from 'node:fs'
import { tmpdir } from 'node:os'
import { dirname, join, relative, resolve } from 'node:path'
import { fileURLToPath } from 'node:url'
import { parseArgs } from 'node:util'
import prettier from 'prettier'
const UI_KIT_PACKAGE = '@gouvfr-lasuite/ui-components'
const UI_KIT_VERSION = '1.5.0'
/** `default` is the white-label theme of the kit, `dsfr` and `anct` the others. */
const UI_KIT_THEME = 'dsfr'
const FRONTEND_DIR = resolve(dirname(fileURLToPath(import.meta.url)), '..')
const OUTPUT_DIR = join(FRONTEND_DIR, 'src/styles/theme/ui-kit')
const GLOBAL_COLOR_PREFIX = '--c--globals--colors--'
const CONTEXTUAL_PREFIX = '--c--contextuals--'
/** Downloads the published package and returns the content of its stylesheet. */
function fetchStylesheet(version) {
const workdir = mkdtempSync(join(tmpdir(), 'ui-kit-'))
try {
const [{ filename }] = JSON.parse(
execFileSync(
'npm',
[
'pack',
`${UI_KIT_PACKAGE}@${version}`,
'--pack-destination',
workdir,
'--json',
'--loglevel=error',
],
{ encoding: 'utf8', stdio: ['ignore', 'pipe', 'inherit'] }
)
)
execFileSync('tar', [
'-xzf',
join(workdir, filename),
'-C',
workdir,
'package/dist/style.css',
])
return readFileSync(join(workdir, 'package/dist/style.css'), 'utf8')
} finally {
rmSync(workdir, { recursive: true, force: true })
}
}
/**
* Returns the custom properties each theme declares, keyed by theme name.
*
* The kit declares its default theme on `:root` (the bare token engine also
* ships one on `html`, which `:root` out-specifies) and the other themes in
* `.cunningham-theme--<name>` blocks. These blocks are flat, a regex is enough.
*/
function parseThemes(css) {
const themeClassPrefix = '.cunningham-theme--'
const themes = {}
for (const [, selector, body] of css.matchAll(
/(:root|html|\.cunningham-theme--[a-z0-9-]+)\s*\{([^{}]*)\}/g
)) {
const declarations = Object.fromEntries(
[...body.matchAll(/(--c--[\w-]+)\s*:\s*([^;}]+)/g)].map(
([, name, value]) => [name, value.trim()]
)
)
if (Object.keys(declarations).length === 0) continue
const theme = selector.startsWith(themeClassPrefix)
? selector.slice(themeClassPrefix.length)
: 'default'
themes[theme] = { ...themes[theme], ...declarations }
}
return themes
}
/**
* Returns what the browser resolves for the light and dark variants of a theme.
*
* A theme class only re-declares what it changes: the rest cascades from the
* default theme, hence the merge.
*/
function resolveVariants(themes, theme) {
const [lightName, darkName] =
theme === 'default'
? ['default', 'dark']
: [`${theme}-light`, `${theme}-dark`]
for (const name of [lightName, darkName]) {
if (!themes[name]) {
throw new Error(
`theme "${name}" not found, the stylesheet declares: ` +
Object.keys(themes).join(', ')
)
}
}
return {
light: { ...themes.default, ...themes[lightName] },
dark: { ...themes.default, ...themes[darkName] },
}
}
/** `brand-550` -> `['brand', '550']`, `blue-1-050` -> `['blue-1', '050']` */
function splitColorName(name) {
const match = name.match(/^(.+)-(\d{3,4})$/)
return match ? [match[1], match[2]] : [name]
}
/**
* Trees are Maps rather than objects: an object would move the integer-like
* keys first ('100' before '050'), and we want to keep the order of the kit.
*/
function setIn(tree, path, value) {
let node = tree
for (const key of path.slice(0, -1)) {
if (!node.has(key)) node.set(key, new Map())
node = node.get(key)
}
node.set(path.at(-1), value)
}
function collectColors({ light, dark }) {
const colors = new Map()
for (const [name, value] of Object.entries(light)) {
if (!name.startsWith(GLOBAL_COLOR_PREFIX)) continue
if (dark[name] !== value) {
throw new Error(
`${name} differs between the light and dark variants, ` +
'while both are expected to share their palettes'
)
}
setIn(colors, splitColorName(name.slice(GLOBAL_COLOR_PREFIX.length)), value)
}
return colors
}
/** `var(--c--globals--colors--brand-550)` -> `brand.550` */
function toColorReference(name, value) {
const match = value?.match(/^var\(--c--globals--colors--([\w-]+)\)$/)
if (!match) {
throw new Error(`${name} should refer to a color, got "${value}"`)
}
return splitColorName(match[1]).join('.')
}
function collectContextuals({ light, dark }) {
const contextuals = new Map()
for (const [name, value] of Object.entries(light)) {
if (!name.startsWith(CONTEXTUAL_PREFIX)) continue
setIn(contextuals, name.slice(CONTEXTUAL_PREFIX.length).split('--'), {
light: toColorReference(name, value),
dark: toColorReference(name, dark[name]),
})
}
return contextuals
}
const formatKey = (key) => (/^[a-zA-Z_$][\w$]*$/.test(key) ? key : `'${key}'`)
/** Serializes a tree of tokens, `leaf` rendering what sits at the end of a path. */
function serialize(tree, leaf) {
const entries = [...tree].map(([key, node]) => {
const value = node instanceof Map ? serialize(node, leaf) : leaf(node)
return `${formatKey(key)}: ${value}`
})
return `{ ${entries.join(', ')} }`
}
const count = (tree) =>
[...tree.values()].reduce(
(total, node) => total + (node instanceof Map ? count(node) : 1),
0
)
const renderHeader = ({ theme, source }) => `/**
* GENERATED FILE, do not edit by hand.
*
* Mirrors the "${theme}" theme of the La Suite UI kit.
* Source: ${source}
* To update it, run \`npm run theme:sync\` (see scripts/sync-ui-kit-tokens.mjs).
*/`
const renderColors = (origin, colors) => `${renderHeader(origin)}
import { defineTokens } from '@pandacss/dev'
/**
* The palettes of the UI kit, its \`globals.colors\`.
*
* Prefer the contextual tokens in components: they carry a role and follow the
* light/dark theme, where a palette step is a fixed color.
*/
export const colors = defineTokens.colors(
${serialize(colors, (hex) => `{ value: '${hex}' }`)}
)
`
const renderContextuals = (origin, contextuals) => `${renderHeader(origin)}
import { defineSemanticTokens } from '@pandacss/dev'
/**
* A token whose color depends on the theme: the light value applies by
* default, \`data-theme\` scopes switch it (see ../conditions.ts).
*/
const themed = (light: string, dark: string) => ({
value: {
base: \`{colors.\${light}}\`,
_light: \`{colors.\${light}}\`,
_dark: \`{colors.\${dark}}\`,
},
})
/**
* The contextual tokens of the UI kit, its \`contextuals\`.
*
* They read as \`<what is painted>.<family>.<role>.<emphasis>\`, for instance
* \`background.semantic.brand.primary\` or \`content.semantic.neutral.secondary\`.
*/
export const contextuals = defineSemanticTokens.colors(
${serialize(contextuals, ({ light, dark }) => `themed('${light}', '${dark}')`)}
)
`
async function write(filename, code) {
const filepath = join(OUTPUT_DIR, filename)
const options = await prettier.resolveConfig(filepath)
writeFileSync(filepath, await prettier.format(code, { ...options, filepath }))
console.log(` wrote ${relative(FRONTEND_DIR, filepath)}`)
}
async function main() {
const { values: args } = parseArgs({
options: {
version: { type: 'string', default: UI_KIT_VERSION },
theme: { type: 'string', default: UI_KIT_THEME },
css: { type: 'string' },
},
})
const origin = {
theme: args.theme,
source: args.css
? `a local stylesheet (${relative(FRONTEND_DIR, resolve(args.css))})`
: `${UI_KIT_PACKAGE}@${args.version}`,
}
console.log(`Reading the "${origin.theme}" theme from ${origin.source}`)
const stylesheet = args.css
? readFileSync(args.css, 'utf8')
: fetchStylesheet(args.version)
const variants = resolveVariants(parseThemes(stylesheet), args.theme)
const colors = collectColors(variants)
const contextuals = collectContextuals(variants)
await write('colors.ts', renderColors(origin, colors))
await write('contextuals.ts', renderContextuals(origin, contextuals))
console.log(
`Done: ${count(colors)} colors, ${count(contextuals)} contextual tokens.`
)
}
main().catch((error) => {
console.error(`\nCould not sync the UI kit tokens: ${error.message}`)
process.exit(1)
})
+1 -1
View File
@@ -1,7 +1,7 @@
import { fetchApi } from './fetchApi'
import { keys } from './queryKeys'
import { useQuery } from '@tanstack/react-query'
import type { RecordingMode } from '@/features/recording/types'
import { RecordingMode } from '@/features/recording'
import type { ApiAccessLevel } from '@/features/rooms/api/ApiRoom'
import type { Track, VideoCodec } from 'livekit-client'
type Source = Track.Source
@@ -14,8 +14,8 @@ export const FeedbackBanner = () => {
<div
className={css({
width: '100%',
backgroundColor: 'primary.50',
color: 'primary.600',
backgroundColor: 'brand.050',
color: 'brand.700',
display: { base: 'none', sm: 'flex' },
justifyContent: 'center',
padding: '0.5rem 0',
@@ -36,7 +36,7 @@ export const FeedbackBanner = () => {
className={css({
display: 'flex',
alignItems: 'center',
gap: 0.25,
gap: '3xs',
})}
>
<A href={data?.feedback?.url} target="_blank" size="sm">
+4 -3
View File
@@ -4,7 +4,6 @@ import { useTranslation } from 'react-i18next'
import { useMediaDeviceSelect } from '@livekit/components-react'
import { reportError } from '@/features/analytics/telemetry'
import { canTestAudioOutput } from '@/features/rooms/utils/canTestAudioOutput'
import upriseSoundSrc from '@/assets/sounds/uprise.mp3'
export const SoundTester = () => {
const { t } = useTranslation('settings')
@@ -48,7 +47,9 @@ export const SoundTester = () => {
isDisabled={isPlaying}
fullWidth
style={{
color: isPlaying ? 'var(--colors-primary)' : undefined,
color: isPlaying
? 'var(--colors-content-semantic-brand-tertiary)'
: undefined,
}}
>
{isPlaying ? t('audio.speakers.ongoingTest') : t('audio.speakers.test')}
@@ -56,7 +57,7 @@ export const SoundTester = () => {
{/* eslint-disable jsx-a11y/media-has-caption */}
<audio
ref={audioRef}
src={upriseSoundSrc}
src="/sounds/uprise.mp3"
onEnded={() => setIsPlaying(false)}
/>
</>
@@ -1,32 +0,0 @@
import { useEffect, useState } from 'react'
import { getPosthog } from '../utils'
import { useIsAnalyticsEnabled } from './useIsAnalyticsEnabled'
/**
* Same contract as `useFeatureFlagEnabled` from 'posthog-js/react', without a
* static import of posthog-js: that import puts the whole SDK on the critical
* path of every screen, defeating the lazy `getPosthog()`.
*/
export const useFeatureFlagEnabled = (flag: string): boolean | undefined => {
const isAnalyticsEnabled = useIsAnalyticsEnabled()
const [enabled, setEnabled] = useState<boolean | undefined>(undefined)
useEffect(() => {
if (!isAnalyticsEnabled) return
let cancelled = false
let unsubscribe: (() => void) | undefined
void getPosthog().then((ph) => {
if (cancelled) return
setEnabled(ph.isFeatureEnabled(flag))
unsubscribe = ph.onFeatureFlags(() =>
setEnabled(ph.isFeatureEnabled(flag))
)
})
return () => {
cancelled = true
unsubscribe?.()
}
}, [flag, isAnalyticsEnabled])
return enabled
}
@@ -27,7 +27,7 @@ const TextContainer = styled('div', {
base: {
display: 'flex',
padding: '0.75rem',
backgroundColor: 'greyscale.50',
backgroundColor: 'gray.025',
borderRadius: 4,
marginBottom: '0.75rem',
},
@@ -15,7 +15,7 @@ const StyledContainer = styled('div', {
display: 'flex',
margin: '0.75rem 0 1.5rem',
padding: '0.5rem',
backgroundColor: 'gray.100',
backgroundColor: 'gray.050',
borderRadius: 4,
},
})
@@ -16,7 +16,7 @@ import { StepStatusIndicator } from './StepStatusIndicator'
/** Each step is its own bounded card, collapsed or not. */
const cardClass = css({
border: '1px solid {colors.greyscale.900}',
border: '1px solid {colors.gray.850}',
borderRadius: '5px',
backgroundColor: 'white',
overflow: 'hidden',
@@ -47,7 +47,7 @@ const identityClass = css({
const triggerClass = css({
cursor: 'pointer',
transition: 'background-color 120ms',
_hover: { backgroundColor: 'greyscale.50' },
_hover: { backgroundColor: 'gray.025' },
'&[data-focus-visible]': {
outline: '2px solid {colors.focusRing}',
outlineOffset: '-2px!',
@@ -56,13 +56,13 @@ const triggerClass = css({
/** Expanded headers stay tinted so the open card reads as one block. */
const triggerExpandedClass = css({
backgroundColor: 'greyscale.100',
_hover: { backgroundColor: 'greyscale.100' },
backgroundColor: 'gray.050',
_hover: { backgroundColor: 'gray.050' },
})
const labelClass = css({
textStyle: 'body',
color: 'greyscale.1000',
color: 'gray.850',
fontWeight: 'medium',
})
@@ -74,7 +74,7 @@ const valueClass = css({
})
const chevronClass = css({
color: 'primary.800',
color: 'brand.550',
justifySelf: 'end',
transition: 'transform 150ms',
})
@@ -103,7 +103,7 @@ const logListClass = css({
const logItemClass = css({
fontFamily: 'mono',
textStyle: 'xs',
color: 'greyscale.700',
color: 'gray.750',
overflowWrap: 'anywhere',
})
@@ -17,12 +17,12 @@ type SummaryState =
/** Only a failure or a degraded route earns a colour: everything else stays near-black. */
const stateColorClass: Record<SummaryState, string> = {
idle: css({ color: 'greyscale.1000' }),
running: css({ color: 'greyscale.1000' }),
passed: css({ color: 'greyscale.1000' }),
partial: css({ color: 'greyscale.1000' }),
failed: css({ color: 'danger.600' }),
warning: css({ color: 'warning' }),
idle: css({ color: 'gray.850' }),
running: css({ color: 'gray.850' }),
passed: css({ color: 'gray.850' }),
partial: css({ color: 'gray.850' }),
failed: css({ color: 'content.semantic.error.secondary' }),
warning: css({ color: 'content.semantic.warning.secondary' }),
}
/**
@@ -45,7 +45,7 @@ const getSummaryState = (
const cardClass = css({
width: '100%',
borderRadius: '5px',
border: '1px solid {colors.greyscale.900}',
border: '1px solid {colors.gray.850}',
backgroundColor: 'white',
padding: { base: '1.25rem', xsm: '1.75rem' },
display: 'flex',
@@ -63,14 +63,14 @@ const headerClass = css({
const eyebrowClass = css({
textStyle: 'sm',
fontWeight: 'medium',
color: 'greyscale.600',
color: 'gray.600',
margin: 0,
})
const headlineClass = css({
// Sized for the longest state string ("N vérifications en échec"), not for
// the shortest one.
fontSize: { base: '28', xsm: '40' },
fontSize: { base: 'h2', xsm: '2.375rem' },
lineHeight: '1.1',
fontWeight: 'bold',
letterSpacing: '-0.02em',
@@ -80,14 +80,14 @@ const headlineClass = css({
const hintClass = css({
textStyle: 'sm',
color: 'greyscale.600',
color: 'gray.600',
margin: 0,
maxWidth: '34rem',
})
const dividerClass = css({
// Lighter than the card border: an inner rule should never compete with it.
borderTop: '1px solid {colors.greyscale.100}',
borderTop: '1px solid {colors.gray.050}',
paddingTop: '1.25rem',
display: 'flex',
flexDirection: 'column',
@@ -104,21 +104,21 @@ const trackClass = css({
height: '0.375rem',
width: '100%',
borderRadius: 'full',
backgroundColor: 'greyscale.200',
backgroundColor: 'gray.100',
overflow: 'hidden',
})
const fillClass = css({
height: '100%',
borderRadius: 'full',
backgroundColor: 'primary.800',
backgroundColor: 'brand.550',
transition: 'width 200ms ease-out',
})
const progressValueClass = css({
textStyle: 'sm',
fontVariantNumeric: 'tabular-nums',
color: 'greyscale.700',
color: 'gray.750',
whiteSpace: 'nowrap',
// Reserved width so the bar does not resize when the digits change.
minWidth: '3rem',
@@ -136,7 +136,7 @@ const counterClass = css({
alignItems: 'center',
gap: '0.5rem',
textStyle: 'sm',
color: 'greyscale.600',
color: 'gray.600',
})
const counterSquareClass = css({
@@ -149,14 +149,14 @@ const counterSquareClass = css({
const counterValueClass = css({
fontWeight: 'medium',
fontVariantNumeric: 'tabular-nums',
color: 'greyscale.1000',
color: 'gray.850',
})
/** A zero count is context, not a result: it recedes instead of shouting. */
const emptyCounterClass = css({ color: 'greyscale.600' })
const emptySquareClass = css({
backgroundColor: 'transparent!',
border: '1px solid {colors.greyscale.250}',
border: '1px solid {colors.gray.100}',
})
const actionsClass = css({
@@ -8,16 +8,16 @@ import type { ConnectionTestStepStatus } from '../types'
export const statusSquareClass: Record<ConnectionTestStepStatus, string> = {
pending: css({
backgroundColor: 'transparent',
border: '1px solid {colors.greyscale.300}',
border: '1px solid {colors.gray.150}',
}),
running: css({
backgroundColor: 'primary.800',
backgroundColor: 'brand.550',
animation: 'pulse_background 1.2s ease-in-out infinite',
}),
success: css({ backgroundColor: 'success.600' }),
warning: css({ backgroundColor: 'warning' }),
failed: css({ backgroundColor: 'danger.600' }),
skipped: css({ backgroundColor: 'greyscale.300' }),
success: css({ backgroundColor: 'background.semantic.success.primary' }),
warning: css({ backgroundColor: 'background.semantic.warning.primary' }),
failed: css({ backgroundColor: 'background.semantic.error.primary' }),
skipped: css({ backgroundColor: 'gray.150' }),
}
/**
@@ -24,13 +24,13 @@ const HIDE_LIVEKIT_VIDEO_CLASS = 'connection-test-hide-livekit-video'
const sectionClass = css({
width: '100%',
borderTop: '2px solid {colors.greyscale.900}',
borderTop: '2px solid {colors.gray.850}',
paddingTop: '1rem',
})
const sectionTitleClass = css({
textStyle: 'h2',
color: 'greyscale.1000',
color: 'gray.850',
margin: 0,
})
@@ -47,15 +47,15 @@ const helpClass = css({
gap: '0.5rem',
width: '100%',
borderRadius: 8,
border: '1px solid {colors.greyscale.200}',
border: '1px solid {colors.gray.100}',
backgroundColor: 'white',
padding: '0.75rem 1rem',
textStyle: 'sm',
color: 'greyscale.800',
color: 'gray.850',
})
const helpIconClass = css({
color: 'danger.600',
color: 'content.semantic.error.secondary',
flexShrink: 0,
marginTop: '2px',
})
@@ -154,7 +154,7 @@ const carouselNavButton = css({
outlineOffset: '1px',
},
_disabled: {
color: 'greyscale.400',
color: 'gray.400',
cursor: 'default',
pointerEvents: 'none',
_pressed: {
@@ -42,7 +42,7 @@ export const LaterMeetingDialog = ({
<div
className={css({
width: '100%',
backgroundColor: 'gray.50',
backgroundColor: 'gray.025',
borderRadius: '0.75rem',
display: 'flex',
flexDirection: 'column',
@@ -176,7 +176,7 @@ export const LaterMeetingDialog = ({
<HStack>
<div
className={css({
backgroundColor: 'primary.200',
backgroundColor: 'brand.150',
borderRadius: '50%',
padding: '4px',
marginTop: '1rem',
@@ -185,7 +185,7 @@ export const LaterMeetingDialog = ({
<RiSpam2Fill
size={22}
className={css({
fill: 'primary.500',
fill: 'brand.500',
})}
aria-hidden="true"
/>
@@ -109,7 +109,7 @@ const RightColumn = ({ children }: { children?: ReactNode }) => {
const Separator = styled('div', {
base: {
borderBottom: '1px solid',
borderColor: 'greyscale.500',
borderColor: 'gray.500',
marginTop: '2.5rem',
maxWidth: '30rem',
width: '100%',
@@ -188,7 +188,7 @@ const Home = () => {
<div
className={css({
display: 'flex',
gap: 0.5,
gap: 'xs',
flexDirection: { base: 'column', xsm: 'row' },
flexWrap: 'wrap',
alignItems: { base: 'center', xsm: 'items-start' },
@@ -10,10 +10,10 @@ const paginationToolbar = cva({
display: 'flex',
alignItems: 'center',
gap: '0.125rem',
backgroundColor: 'primaryDark.50',
backgroundColor: 'gray.900',
borderRadius: '2rem',
border: '1px solid',
borderColor: 'primaryDark.200',
borderColor: 'gray.650',
padding: '0.375rem',
},
variants: {
@@ -2,10 +2,10 @@ import { styled } from '@/styled-system/jsx'
export const StyledToastContainer = styled('div', {
base: {
margin: 0.5,
margin: 'xs',
boxShadow:
'rgba(0, 0, 0, 0.5) 0px 4px 8px 0px, rgba(0, 0, 0, 0.3) 0px 6px 20px 4px',
backgroundColor: 'greyscale.700',
backgroundColor: 'gray.750',
color: 'white',
borderRadius: '8px',
'&[data-entering]': { animation: 'fade 200ms' },
@@ -42,7 +42,7 @@ export function ToastAutoMuteLargeRoom({
size="sm"
variant="text"
className={css({
color: 'primary.300',
color: 'brand.150',
})}
onPress={() => handleDismiss()}
>
@@ -34,7 +34,7 @@ export function ToastLowerHand({ state, ...props }: Readonly<ToastProps>) {
size="sm"
variant="text"
className={css({
color: 'primary.300',
color: 'brand.150',
marginLeft: '0.5rem',
})}
onPress={() => handleDismiss()}
@@ -61,7 +61,7 @@ export function ToastMessageReceived({
<RiMessage2Line
size={20}
className={css({
color: 'primary.300',
color: 'brand.150',
marginTop: '3px',
})}
aria-hidden="true"
@@ -41,7 +41,7 @@ export function ToastRaised({ state, ...props }: Readonly<ToastProps>) {
animationIterationCount: '2',
}}
/>
<Div {...titleProps} marginRight={0.5}>
<Div {...titleProps} marginRight="xs">
{t('raised.description', {
name: participant.name || t('defaultName'),
})}
@@ -51,7 +51,7 @@ export function ToastRaised({ state, ...props }: Readonly<ToastProps>) {
size="sm"
variant="text"
className={css({
color: 'primary.300',
color: 'brand.150',
})}
onPress={(e) => {
toggleParticipants()
@@ -76,7 +76,7 @@ export function ToastRecordingRequest({
size="sm"
variant="text"
className={css({
color: 'primary.300',
color: 'brand.150',
})}
onPress={options.openMenu}
>
@@ -37,7 +37,7 @@ export function ToastRecordingSaving({
alignItems="center"
{...contentProps}
padding={14}
gap={1}
gap="base"
>
<Text
margin={false}
@@ -132,7 +132,7 @@ export const WaitingParticipantNotification = () => {
size="sm"
variant="text"
className={css({
color: 'primary.300',
color: 'brand.150',
})}
onPress={async () => {
await handleParticipantEntry(waitingParticipants[0], true)
@@ -145,7 +145,7 @@ export const WaitingParticipantNotification = () => {
size="sm"
variant="text"
className={css({
color: 'primary.300',
color: 'brand.150',
})}
onPress={() => {
toggleParticipants()
@@ -187,7 +187,7 @@ export const WaitingParticipantNotification = () => {
borderRadius: '50%',
justifyContent: 'center',
alignItems: 'center',
background: 'primaryDark.100',
background: 'gray.700',
border: '2px solid white',
marginLeft: '-10px',
})}
@@ -215,7 +215,7 @@ export const WaitingParticipantNotification = () => {
size="sm"
variant="text"
className={css({
color: 'primary.300',
color: 'brand.150',
})}
onPress={() => {
toggleParticipants()
@@ -1,25 +0,0 @@
import { useEffect } from 'react'
import { notificationsStore } from '@/stores/notifications'
import { runWhenIdle } from '@/utils/runWhenIdle'
import { loadNotificationSound } from '../notificationSound'
/**
* Fetch and decode the notification sound while the browser is idle, so it
* doesn't compete with the room connection and is ready for the first
* notification. Meant for screens shown before the meeting, e.g. pre-join.
*/
export const usePreloadNotificationSound = () => {
useEffect(() => {
const isAnySoundEnabled = Array.from(
notificationsStore.soundNotifications.values()
).some(Boolean)
const saveData = (navigator as { connection?: { saveData?: boolean } })
.connection?.saveData
if (!isAnySoundEnabled || saveData) return
return runWhenIdle(() => {
// Best effort: the room loads the sound itself if this fails.
loadNotificationSound().catch(() => {})
})
}, [])
}
@@ -1,25 +1,24 @@
import { useEffect } from 'react'
import useSound from 'use-sound'
import { useSnapshot } from 'valtio'
import { notificationsStore } from '@/stores/notifications'
import type { NotificationType } from '@/features/notifications/NotificationType'
import {
loadNotificationSound,
playNotificationSound,
} from '@/features/notifications/notificationSound'
// fixme - handle dynamic audio output changes
export const useNotificationSound = () => {
const notificationsSnap = useSnapshot(notificationsStore)
useEffect(() => {
loadNotificationSound().catch(() => {})
}, [])
const [play] = useSound('/sounds/notifications.mp3', {
sprite: {
participantJoined: [0, 1150],
handRaised: [1400, 180],
messageReceived: [1580, 300],
participantWaiting: [2039, 710],
success: [2740, 1304],
},
volume: notificationsSnap.soundNotificationVolume,
})
const triggerNotificationSound = (type: NotificationType) => {
const isSoundEnabled = notificationsSnap.soundNotifications.get(type)
if (isSoundEnabled) {
playNotificationSound(type, notificationsSnap.soundNotificationVolume)
}
if (isSoundEnabled) play({ id: type })
}
return { triggerNotificationSound }
}
@@ -1,66 +0,0 @@
import type { Howl } from 'howler'
import type { NotificationType } from './NotificationType'
import notificationSoundSrc from '@/assets/sounds/notifications.mp3'
const NOTIFICATION_SOUND_SPRITE: Record<string, [number, number]> = {
participantJoined: [0, 1150],
handRaised: [1400, 180],
messageReceived: [1580, 300],
participantWaiting: [2039, 710],
success: [2740, 1304],
}
let howl: Howl | undefined
let howlPromise: Promise<Howl> | undefined
/**
* Lazily load howler and the notification sound sprite.
*
* The Howl instance is shared by every consumer: whoever calls first triggers
* the (single) download and decoding of the file, later calls reuse it. It can
* thus be called ahead of time, e.g. from the pre-join screen, so the sound is
* ready before the first notification of the meeting.
*/
export const loadNotificationSound = (): Promise<Howl> => {
if (!howlPromise) {
howlPromise = import('howler')
.then(
({ Howl }) =>
new Promise<Howl>((resolve, reject) => {
const instance = new Howl({
src: [notificationSoundSrc],
// The extension is kept by the build, but don't rely on it.
format: ['mp3'],
sprite: NOTIFICATION_SOUND_SPRITE,
onload: () => {
howl = instance
resolve(instance)
},
onloaderror: (_id, error) => {
instance.unload()
reject(new Error(`Notification sound failed to load: ${error}`))
},
})
})
)
.catch((error) => {
// Let a later call retry.
howlPromise = undefined
throw error
})
}
return howlPromise
}
/**
* Play a notification sound, if the sprite is already loaded. A sound which
* isn't ready is skipped rather than played late.
*/
export const playNotificationSound = (
type: NotificationType,
volume: number
) => {
if (!howl) return
howl.volume(volume)
howl.play(type)
}
@@ -93,7 +93,7 @@ export const FullScreenShareWarning = ({
position: 'absolute',
height: '100%',
width: '100%',
backgroundColor: 'rgba(22, 22, 34, 0.9)',
backgroundColor: 'gray.900/90',
padding: '2rem',
})}
>
@@ -21,9 +21,9 @@ export const MutedMicIndicator = ({
return (
<div
className={css({
backgroundColor: 'red.600',
backgroundColor: 'error.550',
borderRadius: '4px',
padding: 0.25,
padding: '3xs',
})}
>
<RiMicOffFill size={16} color="white" />
@@ -23,7 +23,7 @@ export const ParticipantMetadata = ({
return (
<div className="lk-participant-metadata">
<HStack gap={0.25}>
<HStack gap="3xs">
{!isScreenShare && <MutedMicIndicator participant={participant} />}
<RaisedHandMetadataWrapper
participant={participant}
@@ -1,18 +1,14 @@
import React from 'react'
import { useTranslation } from 'react-i18next'
import { useSidePanel } from '@/features/rooms/livekit/hooks/useSidePanel'
import { useEffectsPreload } from '@/features/rooms/livekit/hooks/useEffectsPreload'
import { Button } from '@/primitives'
import { RiImageCircleAiFill } from '@remixicon/react'
export const EffectsButton = React.memo(() => {
const { t } = useTranslation('rooms', { keyPrefix: 'participantTileFocus' })
const { isEffectsOpen, toggleEffects } = useSidePanel()
const { hoverProps, focusProps } = useEffectsPreload()
return (
<Button
{...hoverProps}
{...focusProps}
size={'sm'}
variant={'primaryTextDark'}
square
@@ -104,7 +104,7 @@ export const ParticipantTileFocus = ({
<FadeOverlay hasKeyboardFocus={hasKeyboardFocus} tileRef={tileRef}>
<div
className={css({
backgroundColor: 'primaryDark.50',
backgroundColor: 'gray.900',
zIndex: 1,
borderRadius: '0.25rem',
display: 'flex',
@@ -116,7 +116,7 @@ export const ParticipantTileFocus = ({
},
})}
>
<HStack gap={0.5} padding={0.5}>
<HStack gap="xs" padding="xs">
<FocusButton trackRef={trackRef} />
{!isScreenShare && (
<>
@@ -67,7 +67,7 @@ const MicIndicator = ({ participant }: MicIndicatorProps) => {
) : (
<RiMicFill
className={css({
color: isSpeaking ? 'primaryDark.300' : 'primaryDark.50',
color: isSpeaking ? 'gray.550' : 'gray.900',
animation: isSpeaking
? 'pulse_background 800ms infinite'
: undefined,
@@ -5,7 +5,7 @@ import { styled, HStack, VStack } from '@/styled-system/jsx'
const Container = styled('div', {
base: {
border: '1px solid',
borderColor: 'greyscale.250',
borderColor: 'gray.100',
borderRadius: '8px',
margin: '0 .625rem 0.9375rem',
},
@@ -25,7 +25,7 @@ const Header = styled('button', {
fontSize: '1rem',
transition: 'background 200ms',
borderTopRadius: '7px', // container radius (8) minus its 1px border
_hover: { backgroundColor: 'greyscale.50' },
_hover: { backgroundColor: 'gray.025' },
},
variants: {
isOpen: { false: { borderRadius: '7px' } },
@@ -42,7 +42,7 @@ const Chevron = styled(RiArrowUpSLine, {
const List = styled(VStack, {
base: {
borderTop: '1px solid',
borderTopColor: 'greyscale.250',
borderTopColor: 'gray.100',
alignItems: 'start',
minHeight: 0,
flexGrow: 1,
@@ -89,7 +89,7 @@ export const ParticipantsList = () => {
className={css({
fontSize: '0.875rem',
fontWeight: 'bold',
color: 'greyscale.600',
color: 'gray.600',
padding: '0 1.5rem',
marginBottom: '0.83em',
})}
@@ -25,8 +25,8 @@ export const UnauthenticatedBadge = ({
height: '18px',
width: '18px',
borderRadius: '100%',
background: 'orange.200',
color: 'orange.800',
background: 'warning.100',
color: 'warning.600',
display: 'flex',
justifyContent: 'center',
alignItems: 'center',
@@ -32,7 +32,7 @@ export const PinMenuItem = ({ participant }: { participant: Participant }) => {
className={menuRecipe({ icon: true }).item}
onAction={() => (inFocus ? clearPinnedTrack() : setPinnedTrack(trackRef))}
>
<HStack gap={0.25}>
<HStack gap="3xs">
{inFocus ? (
<>
<RiUnpinLine size={20} aria-hidden />
@@ -35,7 +35,7 @@ export const PromoteMenuItem = React.memo(
className={menuRecipe({ icon: true }).item}
onAction={toggleRole}
>
<HStack gap={0.25} minWidth={280}>
<HStack gap="3xs" minWidth={280}>
<Icon size={20} aria-hidden />
{t(`${label}.label`)}
</HStack>
@@ -23,7 +23,7 @@ export const RemoveMenuItem = React.memo(
className={menuRecipe({ icon: true }).item}
onAction={() => removeParticipant(identity)}
>
<HStack gap={0.25}>
<HStack gap="3xs">
<RiCloseLine size={20} aria-hidden />
{t('label')}
</HStack>
@@ -14,7 +14,7 @@ const Container = styled('div', {
height: '100%',
display: 'grid',
gridTemplateRows: 'minmax(0, 1fr) auto auto',
backgroundColor: 'primaryDark.50',
backgroundColor: 'gray.900',
transition: 'padding .5s cubic-bezier(0.4,0,0.2,1) 5ms',
// Disable LiveKit's own border-radius on tiles so our containers
// (GridCell, Thumbnail, StageFrame) own the clipping exclusively.
@@ -52,7 +52,7 @@ const FocusContainer = styled('div', {
height: '100%',
borderRadius: '8px',
overflow: 'hidden',
backgroundColor: 'primaryDark.100',
backgroundColor: 'gray.700',
boxSizing: 'border-box',
},
})
@@ -66,7 +66,7 @@ const GridCell = styled('div', {
minHeight: 0,
borderRadius: '8px',
overflow: 'hidden',
backgroundColor: 'primaryDark.100',
backgroundColor: 'gray.700',
// Paint on own layer so FLIP transforms don't trigger layout thrash.
willChange: 'transform',
'& .lk-participant-tile': {
@@ -70,7 +70,7 @@ const CameraTile = styled('div', {
minWidth: 0,
borderRadius: '8px',
overflow: 'hidden',
backgroundColor: 'primaryDark.100',
backgroundColor: 'gray.700',
'& .lk-participant-tile': {
width: '100%',
height: '100%',
@@ -85,7 +85,7 @@ const ScreenShareSlot = styled('div', {
minHeight: 0,
borderRadius: '8px',
overflow: 'hidden',
backgroundColor: 'primaryDark.100',
backgroundColor: 'gray.700',
'& .lk-participant-tile': {
width: '100%',
height: '100%',
@@ -89,7 +89,7 @@ export function FloatingReaction({
<Text
variant="sm"
className={css({
backgroundColor: isLocal ? 'primary.100' : 'primaryDark.100',
backgroundColor: isLocal ? 'brand.100' : 'gray.700',
color: isLocal ? 'black' : 'white',
fontWeight: 500,
textAlign: 'center',
@@ -23,7 +23,7 @@ const StyledContainer = styled('div', {
alignItems: 'center',
gap: '0.2rem',
borderRadius: '21px',
backgroundColor: 'primaryDark.100',
backgroundColor: 'gray.700',
maxWidth: '100%',
opacity: 0,
translate: '0 3.25rem',
@@ -122,9 +122,9 @@ export const ControlsButton = ({
{statuses.isAnotherModeStarted && (
<RACButton
className={css({
backgroundColor: 'primary.50',
backgroundColor: 'brand.050',
border: '1px solid',
borderColor: 'primary.200',
borderColor: 'brand.150',
borderRadius: '6px',
padding: '0.75rem',
marginBottom: '0.75rem',
@@ -135,15 +135,15 @@ export const ControlsButton = ({
width: '100%',
cursor: 'pointer',
_hover: {
backgroundColor: 'primary.100',
borderColor: 'primary.400',
backgroundColor: 'brand.100',
borderColor: 'brand.400',
},
})}
onPress={() => openSidePanel()}
>
<Icon
className={css({
color: 'primary.500',
color: 'brand.500',
marginRight: '1rem',
})}
name="info"
@@ -153,7 +153,7 @@ export const ControlsButton = ({
</Text>
<Icon
className={css({
color: 'primary.500',
color: 'brand.500',
marginLeft: 'auto',
})}
name="chevron_right"
@@ -65,7 +65,7 @@ const LimitReachedAlertDialogContent = () => {
return (
<Dialog isOpen={isOpen} role="alertdialog" title={t('title')}>
<LimitDescription />
<HStack gap={1}>
<HStack gap="base">
<Button variant="text" size="sm" onPress={() => setIsOpen(false)}>
{t('button')}
</Button>
@@ -12,10 +12,10 @@ export const LoginPrompt = ({ heading, body }: LoginPromptProps) => {
return (
<div
className={css({
backgroundColor: 'primary.50',
backgroundColor: 'brand.050',
borderRadius: '5px',
border: '1px solid',
borderColor: 'primary.200',
borderColor: 'brand.150',
paddingY: '1rem',
paddingX: '1rem',
marginTop: '1rem',
@@ -8,9 +8,9 @@ import { HStack, VStack } from '@/styled-system/jsx'
const Divider = ({ label }: { label: string }) => (
<HStack gap="1rem" alignItems="center" width="100%" marginY="1rem">
<div className={css({ flex: 1, height: '1px', bg: 'neutral.200' })} />
<div className={css({ flex: 1, height: '1px', bg: 'gray.100' })} />
<Text variant="xsNote">{label}</Text>
<div className={css({ flex: 1, height: '1px', bg: 'neutral.200' })} />
<div className={css({ flex: 1, height: '1px', bg: 'gray.100' })} />
</HStack>
)
@@ -98,7 +98,7 @@ export const RecordingStateToast = () => {
left: '10px',
paddingY: '0.25rem',
paddingX: '0.75rem 0.75rem',
backgroundColor: 'danger.700',
backgroundColor: 'background.semantic.error.primary',
borderColor: 'white',
border: '1px solid',
color: 'white',
@@ -47,10 +47,10 @@ export const RequestRecording = ({
return (
<div
className={css({
backgroundColor: 'neutral.50',
backgroundColor: 'gray.025',
borderRadius: '5px',
border: '1px solid',
borderColor: 'neutral.200',
borderColor: 'gray.100',
paddingY: '1rem',
paddingX: '1rem',
display: 'flex',
@@ -29,7 +29,7 @@ export const RowWrapper = ({
}}
className={css({
width: '100%',
background: 'gray.100',
background: 'gray.050',
paddingBlock: '0.5rem',
paddingInline: '0',
display: 'flex',
@@ -1,4 +1,4 @@
import { useFeatureFlagEnabled } from '@/features/analytics/hooks/useFeatureFlagEnabled'
import { useFeatureFlagEnabled } from 'posthog-js/react'
import { useIsAnalyticsEnabled } from '@/features/analytics/hooks/useIsAnalyticsEnabled'
import type { RecordingMode } from '../types'
import { useIsRecordingModeEnabled } from './useIsRecordingModeEnabled'
@@ -1,4 +1,4 @@
import { useFeatureFlagEnabled } from '@/features/analytics/hooks/useFeatureFlagEnabled'
import { useFeatureFlagEnabled } from 'posthog-js/react'
import { useIsAnalyticsEnabled } from '@/features/analytics/hooks/useIsAnalyticsEnabled'
import type { RecordingMode } from '../types'
import { useIsRecordingModeEnabled } from './useIsRecordingModeEnabled'
@@ -1,4 +1,4 @@
import { useFeatureFlagEnabled } from '@/features/analytics/hooks/useFeatureFlagEnabled'
import { useFeatureFlagEnabled } from 'posthog-js/react'
import { useIsAnalyticsEnabled } from '@/features/analytics/hooks/useIsAnalyticsEnabled'
import { FeatureFlags } from '@/features/analytics/enums'
@@ -26,7 +26,7 @@ const BetaBadge = () => (
display: 'block',
letterSpacing: '-0.02rem',
padding: '0 0.25rem',
backgroundColor: 'primary.100',
backgroundColor: 'brand.050',
color: '#0063CB',
fontSize: '14px',
fontWeight: 500,
@@ -155,7 +155,7 @@ const RecordingDownload = () => {
</LinkButton>
<div
className={css({
backgroundColor: 'greyscale.50',
backgroundColor: 'gray.025',
borderRadius: '5px',
paddingY: '1rem',
paddingX: '1rem',
@@ -6,7 +6,7 @@ const StyledContainer = styled('div', {
width: '24px',
height: '24px',
boxSizing: 'border-box',
backgroundColor: 'primary',
backgroundColor: 'background.semantic.brand.primary',
borderRadius: '100%',
display: 'flex',
alignItems: 'center',
@@ -20,8 +20,8 @@ const StyledContainer = styled('div', {
width: '58px',
borderLeftRadius: 8,
borderRightRadius: 0,
backgroundColor: 'primary.200',
border: '1px solid primary.500',
backgroundColor: 'brand.150',
border: '1px solid brand.500',
gap: '3px',
},
},
@@ -55,7 +55,7 @@ const StyledChild = styled('div', {
},
pushToTalk: {
true: {
backgroundColor: 'primary',
backgroundColor: 'background.semantic.brand.primary',
width: '6px',
height: '6px',
},
@@ -318,7 +318,7 @@ export const Conference = ({
}
connectOptions={connectOptions}
className={css({
backgroundColor: 'primaryDark.50 !important',
backgroundColor: 'gray.900 !important',
})}
onError={handleError}
onConnected={handleConnected}
@@ -212,7 +212,7 @@ export const InviteDialog = ({ mode }: { mode: 'join' | 'create' }) => {
<HStack>
<div
className={css({
backgroundColor: 'primary.200',
backgroundColor: 'brand.150',
borderRadius: '50%',
padding: '4px',
marginTop: '1rem',
@@ -221,7 +221,7 @@ export const InviteDialog = ({ mode }: { mode: 'join' | 'create' }) => {
<RiSpam2Fill
size={22}
className={css({
fill: 'primary.500',
fill: 'brand.500',
})}
/>
</div>
@@ -15,7 +15,6 @@ import {
import { SelectDevice } from '../livekit/components/controls/Device/SelectDevice'
import { ToggleDevice } from '../livekit/components/controls/Device/ToggleDevice'
import { BackgroundProcessorFactory } from '../livekit/components/blur'
import { useEffectsPreload } from '../livekit/hooks/useEffectsPreload'
import { Lobby } from './Lobby'
import { openPermissionsDialog } from '@/stores/permissions'
import { isSafari } from '@/utils/livekit'
@@ -34,7 +33,6 @@ import { useDeviceMissing } from '../livekit/hooks/useDeviceMissing'
import { useJoinTracks } from '../livekit/hooks/useJoinTracks'
import { SilentMicDetector } from './SilentMicDetector'
import { type PreviewTrack, toggleTrack } from '../utils/toggleTrack'
import { usePreloadNotificationSound } from '@/features/notifications/hooks/usePreloadNotificationSound'
const styles = {
page: css({
@@ -274,7 +272,6 @@ const Effects = ({
}: Pick<EffectsConfigurationProps, 'videoTrack'>) => {
const { t } = useTranslation('rooms', { keyPrefix: 'join.effects' })
const [isDialogOpen, setIsDialogOpen] = useState(false)
const { hoverProps, focusProps } = useEffectsPreload()
if (!BackgroundProcessorFactory.isSupported() || isMobileBrowser()) {
return null
@@ -302,8 +299,6 @@ const Effects = ({
onPress={() => setIsDialogOpen(true)}
tooltip={t('description')}
aria-label={t('description')}
{...hoverProps}
{...focusProps}
>
<RiImageCircleAiFill size={24} />
</Button>
@@ -463,7 +458,6 @@ export const Join = ({
roomId: string
}) => {
const { audioTrack, videoTrack } = useJoinTracks()
usePreloadNotificationSound()
return (
<Screen footer={false}>
@@ -149,7 +149,7 @@ export const Lobby = ({
fullWidth: true,
}}
>
<VStack marginBottom={1}>
<VStack marginBottom="base">
<H lvl={1} margin="sm" centered>
{t('heading')}
</H>
@@ -10,7 +10,7 @@ import { captureEvent } from '@/features/analytics/telemetry'
const Card = styled('div', {
base: {
border: '1px solid',
borderColor: 'gray.300',
borderColor: 'gray.150',
padding: '1rem',
marginTop: '1.5rem',
borderRadius: '0.25rem',
@@ -25,7 +25,7 @@ const Bar = styled('div', {
base: {
display: 'flex',
border: '2px solid',
borderColor: 'gray.300',
borderColor: 'gray.150',
borderRadius: '8px',
overflowY: 'hidden',
scrollbar: 'hidden',
@@ -48,19 +48,19 @@ const ratingButtonRecipe = cva({
variants: {
selected: {
true: {
backgroundColor: 'primary.800',
backgroundColor: 'brand.550',
color: 'white',
},
false: {
'&[data-hovered]': {
backgroundColor: 'gray.100',
backgroundColor: 'gray.050',
},
},
},
borderLeft: {
true: {
borderLeft: '1px solid',
borderColor: 'gray.300',
borderColor: 'gray.150',
},
},
},
@@ -118,7 +118,7 @@ const OpenFeedback = ({
marginBottom: '1rem',
}}
/>
<VStack gap="0.5">
<VStack gap="xs">
<Button
variant="primary"
size="sm"
@@ -78,7 +78,7 @@ export const Admin = () => {
border: 'none',
height: '1px',
width: '100%',
background: 'greyscale.250',
background: 'gray.100',
})}
/>
<H
@@ -165,7 +165,7 @@ export const Admin = () => {
border: 'none',
height: '1px',
width: '100%',
background: 'greyscale.250',
background: 'gray.100',
})}
/>
<H
@@ -70,13 +70,13 @@ const VisualCountDown = () => {
className={css({
height: '50px',
width: '50px',
backgroundColor: 'blue.100',
backgroundColor: 'brand.100',
borderRadius: '25px',
display: 'flex',
justifyContent: 'center',
alignItems: 'center',
fontWeight: '500',
color: 'blue.800',
color: 'brand.700',
margin: 'auto',
})}
aria-hidden="true"
@@ -23,7 +23,7 @@ export const MuteAlertDialog = ({
aria-label={t('heading', { name })}
>
<P>{t('description', { name })}</P>
<HStack gap={1}>
<HStack gap="base">
<Button variant="text" size="sm" onPress={onClose}>
{t('cancel')}
</Button>
@@ -64,7 +64,7 @@ export const ScreenShareZoomControls = ({
className={css({
display: 'flex',
alignItems: 'center',
backgroundColor: 'primaryDark.50',
backgroundColor: 'gray.900',
borderRadius: '2rem',
padding: '0.5rem',
opacity: 0.7,
@@ -56,9 +56,9 @@ const StyledSidePanel = React.forwardRef<HTMLElement, StyledSidePanelProps>(
className={css({
borderWidth: '1px',
borderStyle: 'solid',
borderColor: 'box.border',
backgroundColor: 'box.bg',
color: 'box.text',
borderColor: 'border.surface.primary',
backgroundColor: 'background.surface.primary',
color: 'content.semantic.neutral.primary',
borderRadius: 8,
flex: 1,
position: 'absolute',
@@ -37,10 +37,10 @@ const ToolButton = ({
paddingX: '0.75rem 1.5rem',
borderRadius: '30px',
width: 'full',
backgroundColor: 'gray.50',
backgroundColor: 'gray.025',
textAlign: 'start',
'&[data-hovered]': {
backgroundColor: 'primary.50',
backgroundColor: 'brand.050',
cursor: 'pointer',
},
})}
@@ -56,7 +56,7 @@ const ToolButton = ({
justifyContent: 'center',
alignItems: 'center',
position: 'relative',
background: 'primary.800',
background: 'brand.550',
color: 'white',
})}
>
@@ -68,8 +68,8 @@ const ToolButton = ({
as="h2"
className={css({
display: 'flex',
gap: 0.25,
fontWeight: 'semibold',
gap: '3xs',
fontWeight: 'bold',
})}
>
{title}
@@ -146,7 +146,7 @@ export const Tools = () => {
flexGrow={1}
flexDirection="column"
alignItems="start"
gap={0.5}
gap="xs"
>
<Text
variant="note"
@@ -1,147 +0,0 @@
import { beforeEach, describe, expect, it, vi } from 'vitest'
const MODEL = '/assets/mediapipe/models/selfie_segmenter_landscape.tflite'
const WASM_LOADER = '/wasm/vision_wasm_internal.js'
const WASM_BINARY = '/wasm/vision_wasm_internal.wasm'
const isSupported = vi.fn(() => true)
vi.mock('.', () => ({
BackgroundProcessorFactory: { isSupported: () => isSupported() },
MEDIAPIPE_PATH_WASM: '/wasm',
SELFIE_SEGMENTER_MODEL_PATH: MODEL,
}))
vi.mock('@mediapipe/tasks-vision', () => ({
FilesetResolver: {
forVisionTasks: async () => ({
wasmLoaderPath: WASM_LOADER,
wasmBinaryPath: WASM_BINARY,
}),
},
}))
vi.mock('@/features/files/utils/resolveMediaUrl', () => ({
resolveMediaUrlOrFallback: async (url: string) => `resolved:${url}`,
}))
class FakeImage {
static instances: FakeImage[] = []
src = ''
crossOrigin: string | null = null
onerror: (() => void) | null = null
constructor() {
FakeImage.instances.push(this)
}
}
const fetchMock = vi.fn()
const fetchedUrls = () => fetchMock.mock.calls.map(([url]) => url)
const imageUrls = () => FakeImage.instances.map((image) => image.src)
// Let the fire-and-forget preloads settle.
const flush = () => new Promise((resolve) => setTimeout(resolve))
const load = () => import('./preload')
beforeEach(() => {
vi.resetModules()
isSupported.mockReturnValue(true)
FakeImage.instances = []
fetchMock.mockReset()
fetchMock.mockImplementation(async () => ({ ok: true, body: null }))
vi.stubGlobal('fetch', fetchMock)
vi.stubGlobal('Image', FakeImage)
vi.stubGlobal('navigator', {})
})
describe('preloadEffectsAssets', () => {
it('preloads the thumbnails, the model and the wasm', async () => {
const { preloadEffectsAssets } = await load()
preloadEffectsAssets()
await flush()
expect(imageUrls()).toHaveLength(8)
expect(imageUrls()[0]).toBe('/assets/backgrounds/thumbnails/1.webp')
expect(fetchedUrls().sort()).toEqual([MODEL, WASM_LOADER, WASM_BINARY])
expect(fetchMock).toHaveBeenCalledWith(WASM_BINARY, { priority: 'low' })
})
it('preloads only once', async () => {
const { preloadEffectsAssets } = await load()
preloadEffectsAssets()
await flush()
preloadEffectsAssets()
await flush()
expect(imageUrls()).toHaveLength(8)
expect(fetchMock).toHaveBeenCalledTimes(3)
})
it('skips the wasm when the caller reports a degraded connection', async () => {
const { preloadEffectsAssets } = await load()
preloadEffectsAssets({ isConstrained: true })
await flush()
expect(imageUrls()).toHaveLength(8)
expect(fetchedUrls()).toEqual([MODEL])
})
it.each([{ saveData: true }, { effectiveType: '3g' }])(
'skips the wasm when the browser reports %o',
async (connection) => {
vi.stubGlobal('navigator', { connection })
const { preloadEffectsAssets } = await load()
preloadEffectsAssets()
await flush()
expect(fetchedUrls()).toEqual([MODEL])
}
)
it('retries after a failure', async () => {
vi.spyOn(console, 'warn').mockImplementation(() => {})
fetchMock.mockImplementation(async () => ({ ok: false, status: 503 }))
const { preloadEffectsAssets } = await load()
preloadEffectsAssets({ isConstrained: true })
await flush()
preloadEffectsAssets({ isConstrained: true })
await flush()
expect(fetchedUrls()).toEqual([MODEL, MODEL])
})
it('does nothing when background processors are not supported', async () => {
isSupported.mockReturnValue(false)
const { preloadEffectsAssets } = await load()
preloadEffectsAssets()
await flush()
expect(imageUrls()).toHaveLength(0)
expect(fetchMock).not.toHaveBeenCalled()
})
})
describe('preloadBackgroundImage', () => {
it('loads the resolved image once, in CORS mode', async () => {
const { preloadBackgroundImage } = await load()
await preloadBackgroundImage('/assets/backgrounds/1.webp')
await preloadBackgroundImage('/assets/backgrounds/1.webp')
expect(FakeImage.instances).toHaveLength(1)
expect(FakeImage.instances[0].src).toBe(
'resolved:/assets/backgrounds/1.webp'
)
expect(FakeImage.instances[0].crossOrigin).toBe('anonymous')
})
it('skips local files and degraded connections', async () => {
const { preloadBackgroundImage } = await load()
await preloadBackgroundImage('blob:https://meet.example.com/1234')
await preloadBackgroundImage('/assets/backgrounds/1.webp', {
isConstrained: true,
})
expect(FakeImage.instances).toHaveLength(0)
})
})
@@ -1,148 +0,0 @@
import { FilesetResolver } from '@mediapipe/tasks-vision'
import { resolveMediaUrlOrFallback } from '@/features/files/utils/resolveMediaUrl'
import {
BackgroundProcessorFactory,
MEDIAPIPE_PATH_WASM,
SELFIE_SEGMENTER_MODEL_PATH,
} from '.'
/**
* Warm the browser caches with what a background effect needs, ahead of
* the click that applies it. Nothing is instantiated here: the processors
* issue the very same requests later and find them in the HTTP cache.
*
* A meeting may be running, so what is preloaded is arbitrated by cost:
*
* | Asset | Size | Preloaded |
* | ----------------------- | --------- | --------------------------------- |
* | Preset thumbnails | ~80KB | always |
* | Segmentation model | ~250KB | always |
* | MediaPipe wasm + loader | ~9.6MB | low priority, unless constrained |
* | One background image | ~300KB | on thumbnail hover, unless const. |
* | All background images | ~2.4MB | never |
*/
export const PRESET_BACKGROUNDS_COUNT = 8
export const getPresetBackgroundPaths = (index: number) => ({
imagePath: `/assets/backgrounds/${index + 1}.webp`,
thumbnailPath: `/assets/backgrounds/thumbnails/${index + 1}.webp`,
})
type NetworkInformation = {
saveData?: boolean
effectiveType?: string
}
/**
* Data saver or a slow link, as reported by the browser (Chromium only,
* other browsers are considered unconstrained).
*/
const isNetworkConstrained = () => {
const connection = (navigator as { connection?: NetworkInformation })
.connection
if (!connection) return false
return (
connection.saveData === true ||
['slow-2g', '2g', '3g'].includes(connection.effectiveType ?? '')
)
}
/**
* Download a same-origin asset into the HTTP cache. The body is read to
* completion, as an aborted response is not stored, and discarded chunk
* by chunk to avoid buffering several megabytes.
*/
const warmHttpCache = async (url: string, priority: RequestPriority) => {
const response = await fetch(url, { priority })
if (!response.ok) {
throw new Error(`Failed to preload ${url}: HTTP ${response.status}`)
}
const reader = response.body?.getReader()
if (!reader) return
while (!(await reader.read()).done) {
// discard
}
}
// Held so that in-flight and decoded images are not garbage collected,
// and can be reused from the memory cache. Bounded by the presets and
// the user's custom backgrounds.
const preloadedImages = new Map<string, HTMLImageElement>()
const preloadImage = (src: string, key = src, crossOrigin?: 'anonymous') => {
if (preloadedImages.has(key)) return
const image = new Image()
if (crossOrigin) image.crossOrigin = crossOrigin
image.onerror = () => preloadedImages.delete(key)
image.src = src
preloadedImages.set(key, image)
}
// Run each step once, and allow another attempt after a failure.
const once = (run: () => Promise<unknown>) => {
let pending: Promise<void> | undefined
return () => {
pending ??= run().then(
() => undefined,
(error) => {
console.warn(error)
pending = undefined
}
)
return pending
}
}
const preloadModel = once(() =>
warmHttpCache(SELFIE_SEGMENTER_MODEL_PATH, 'auto')
)
const preloadWasm = once(async () => {
// Resolves to the SIMD or non-SIMD build, as the processors will.
const { wasmLoaderPath, wasmBinaryPath } =
await FilesetResolver.forVisionTasks(MEDIAPIPE_PATH_WASM)
await Promise.all([
warmHttpCache(wasmLoaderPath, 'low'),
warmHttpCache(wasmBinaryPath, 'low'),
])
})
/**
* Preload what any background effect needs. Meant to be called when the
* user shows an intent to open the effects (hover or focus of an entry
* point).
*
* @param isConstrained caller's knowledge of a degraded connection (e.g.
* LiveKit connection quality): only the light assets are then preloaded.
*/
export const preloadEffectsAssets = ({ isConstrained = false } = {}) => {
if (!BackgroundProcessorFactory.isSupported()) return
for (let index = 0; index < PRESET_BACKGROUNDS_COUNT; index++) {
preloadImage(getPresetBackgroundPaths(index).thumbnailPath)
}
void preloadModel()
if (isConstrained || isNetworkConstrained()) return
void preloadWasm()
}
/**
* Preload a single full-size background. Meant to be called when the
* user dwells on its thumbnail.
*/
export const preloadBackgroundImage = async (
imagePath: string,
{ isConstrained = false } = {}
) => {
// Local files (not logged-in users) are already in memory.
if (imagePath.startsWith('blob:')) return
if (isConstrained || isNetworkConstrained()) return
if (preloadedImages.has(imagePath)) return
// Same resolution and CORS mode as the processors' own image load, so
// that the cached response can be reused.
const src = await resolveMediaUrlOrFallback(imagePath)
preloadImage(src, imagePath, 'anonymous')
}
@@ -55,11 +55,11 @@ export const ChatToggle = ({
right: '-.25rem',
width: '1rem',
height: '1rem',
backgroundColor: 'alert.notification',
backgroundColor: 'background.semantic.error.primary',
borderRadius: '50%',
zIndex: 1,
border: '2px solid',
borderColor: 'greyscale.250',
borderColor: 'gray.100',
})}
/>
)}
@@ -19,11 +19,11 @@ const StyledContainer = styled('div', {
variants: {
theme: {
light: {
borderColor: 'gray.200',
color: 'greyscale.600',
borderColor: 'gray.100',
color: 'gray.600',
},
dark: {
borderColor: 'primaryDark.300',
borderColor: 'gray.550',
color: 'rgba(255 255 255 / 0.7)',
},
},
@@ -40,7 +40,7 @@ const StyledGaugeContainer = styled('div', {
variants: {
theme: {
light: {
backgroundColor: 'greyscale.250',
backgroundColor: 'gray.100',
},
dark: {
backgroundColor: 'rgba(255 255 255 / 0.25)',
@@ -61,10 +61,10 @@ const StyledGauge = styled('div', {
variants: {
theme: {
light: {
backgroundColor: 'primary.500',
backgroundColor: 'brand.500',
},
dark: {
backgroundColor: 'primaryDark.800',
backgroundColor: 'gray.150',
},
},
},
@@ -5,7 +5,6 @@ import { styled } from '@/styled-system/jsx'
import { Button } from '@/primitives'
import { canTestAudioOutput } from '@/features/rooms/utils/canTestAudioOutput'
import { resolveAudioOutputDeviceId } from '@/features/rooms/utils/resolveAudioOutputDeviceId'
import upriseSoundSrc from '@/assets/sounds/uprise.mp3'
// Speaker test in the audiooutput menu footer (Meet-style UX). Outputs have
// no track: the test plays a bundled file through the selected sink, and
@@ -30,10 +29,10 @@ const StyledContainer = styled('div', {
variants: {
theme: {
light: {
borderColor: 'gray.200',
borderColor: 'gray.100',
},
dark: {
borderColor: 'primaryDark.300',
borderColor: 'gray.550',
},
},
},
@@ -130,7 +129,7 @@ export const OutputSoundTester = ({
{/* eslint-disable-next-line jsx-a11y/media-has-caption */}
<audio
ref={audioRef}
src={upriseSoundSrc}
src="/sounds/uprise.mp3"
onEnded={() => setIsPlaying(false)}
/>
</StyledContainer>
@@ -9,7 +9,6 @@ import { css } from '@/styled-system/css'
import { useCanPublishTrack } from '../../../hooks/useCanPublishTrack'
import { useCannotUseDevice } from '../../../hooks/useCannotUseDevice'
import { useSidePanel } from '../../../hooks/useSidePanel'
import { useEffectsPreload } from '../../../hooks/useEffectsPreload'
import { BackgroundProcessorFactory } from '../../blur'
import Source = Track.Source
import * as React from 'react'
@@ -28,13 +27,10 @@ import {
const EffectsButton = ({ onPress }: { onPress: () => void }) => {
const { t } = useTranslation('rooms', { keyPrefix: 'selectDevice' })
const { isEffectsOpen, toggleEffects } = useSidePanel()
const { hoverProps, focusProps } = useEffectsPreload()
return (
<Button
size="sm"
square
{...hoverProps}
{...focusProps}
tooltip={t('effects')}
aria-label={t('effects')}
variant="primaryDark"
@@ -3,17 +3,14 @@ import { MenuItem } from 'react-aria-components'
import { useTranslation } from 'react-i18next'
import { menuRecipe } from '@/primitives/menuRecipe'
import { useSidePanel } from '../../../hooks/useSidePanel'
import { useEffectsPreload } from '../../../hooks/useEffectsPreload'
export const EffectsMenuItem = () => {
const { t } = useTranslation('rooms', { keyPrefix: 'options.items' })
const { toggleEffects } = useSidePanel()
const { hoverProps } = useEffectsPreload()
return (
<MenuItem
onAction={() => toggleEffects()}
{...hoverProps}
className={menuRecipe({ icon: true, variant: 'dark' }).item}
>
<RiImageCircleAiFill size={20} />

Some files were not shown because too many files have changed in this diff Show More