diff --git a/.forgejo/workflows/deploy-dev.yml b/.forgejo/workflows/deploy-dev.yml index d456cda..0d5be50 100644 --- a/.forgejo/workflows/deploy-dev.yml +++ b/.forgejo/workflows/deploy-dev.yml @@ -18,6 +18,9 @@ jobs: - name: Check out repo uses: https://data.forgejo.org/actions/checkout@v4 + - name: Pull git submodules + run: git submodule update --init --recursive + - name: Install dependencies run: nix develop .#electron --command pnpm install --frozen-lockfile @@ -42,6 +45,9 @@ jobs: - name: Check out repo uses: https://data.forgejo.org/actions/checkout@v4 + - name: Pull git submodules + run: git submodule update --init --recursive + - name: Install dependencies run: nix develop .#tauri --command pnpm install --frozen-lockfile @@ -128,6 +134,9 @@ jobs: - name: Check out repo uses: https://data.forgejo.org/actions/checkout@v4 + - name: Pull git submodules + run: git submodule update --init --recursive + - name: Install dependencies run: nix develop .#electron --command pnpm install --frozen-lockfile @@ -180,6 +189,9 @@ jobs: with: fetch-depth: 0 + - name: Pull git submodules + run: git submodule update --init --recursive + - name: Install dependencies run: nix develop .#electron --command pnpm install --frozen-lockfile diff --git a/.forgejo/workflows/deploy-prod.yml b/.forgejo/workflows/deploy-prod.yml index 42323f2..d85ce27 100644 --- a/.forgejo/workflows/deploy-prod.yml +++ b/.forgejo/workflows/deploy-prod.yml @@ -19,6 +19,9 @@ jobs: - name: Check out repo uses: https://data.forgejo.org/actions/checkout@v4 + - name: Pull git submodules + run: git submodule update --init --recursive + - name: Install dependencies run: nix develop .#electron --command pnpm install --frozen-lockfile @@ -43,6 +46,9 @@ jobs: - name: Check out repo uses: https://data.forgejo.org/actions/checkout@v4 + - name: Pull git submodules + run: git submodule update --init --recursive + - name: Install dependencies run: nix develop .#tauri --command pnpm install --frozen-lockfile @@ -129,6 +135,9 @@ jobs: - name: Check out repo uses: https://data.forgejo.org/actions/checkout@v4 + - name: Pull git submodules + run: git submodule update --init --recursive + - name: Install dependencies run: nix develop .#electron --command pnpm install --frozen-lockfile @@ -177,6 +186,9 @@ jobs: - name: Check out repo uses: https://data.forgejo.org/actions/checkout@v4 + - name: Pull git submodules + run: git submodule update --init --recursive + - name: Install dependencies run: nix develop .#electron --command pnpm install --frozen-lockfile diff --git a/.gitignore b/.gitignore index c0e6a9b..261f60b 100644 --- a/.gitignore +++ b/.gitignore @@ -2,3 +2,5 @@ node_modules releases .fallow .direnv +keystore.jks +keystore.properties diff --git a/.gitmodules b/.gitmodules new file mode 100644 index 0000000..1e9ee12 --- /dev/null +++ b/.gitmodules @@ -0,0 +1,3 @@ +[submodule "mtp-type-maps"] + path = mtp-type-maps + url = https://git.methanium.net/tensamin/mtp-type-maps diff --git a/LICENSE b/LICENSE index d218eff..e952c84 100644 --- a/LICENSE +++ b/LICENSE @@ -1,16 +1,15 @@ -Copyright (c) [2025] [Methanium] +Copyright (c) 2025 Methanium + All rights reserved. -This software is protected by copyright. Copying, editing, -distributing, publicly performing, or any other use of this software -or its components, in source or binary form, is strictly prohibited without the express -written permission of the copyright holder. +No part of this software, source code, documentation, or +associated materials may be copied, reproduced, modified, +distributed, published, sublicensed, sold, or used to create +derivative works without prior written permission from the +copyright holder. -FUTURE LICENSE ACCEPTANCE: -It is the copyright holder's intention to release this software in the future -under a license yet to be defined, which will, among other things, -allow private, non-commercial use. This statement does not constitute -a current license grant and does not alter the above -prohibition on use, copying, or modification. Until the formal -publication of such a future license, all rights remain -reserved. +THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY +OF ANY KIND, EXPRESS OR IMPLIED. TO THE MAXIMUM +EXTENT PERMITTED BY LAW, THE COPYRIGHT HOLDER SHALL +NOT BE LIABLE FOR ANY CLAIM, DAMAGES, OR OTHER +LIABILITY ARISING FROM THE SOFTWARE OR ITS USE. diff --git a/readme.md b/README similarity index 100% rename from readme.md rename to README diff --git a/TODO b/TODO new file mode 100644 index 0000000..3ec0948 --- /dev/null +++ b/TODO @@ -0,0 +1,7 @@ +- Add a bunch of tests +- Add packages/hotkeys/ +- Full accessability +- Add settings saving & update onboarding to use it +- Add onboarding page to load one profile during onboarding + +-> Most folders in packages/ have specific todos diff --git a/apps/electron/package.json b/apps/electron/package.json index f410033..d87c1ca 100644 --- a/apps/electron/package.json +++ b/apps/electron/package.json @@ -95,7 +95,11 @@ "target": [ "dmg" ], - "icon": "build/icons/icon.icns" + "icon": "build/icons/icon.icns", + "extendInfo": { + "NSCameraUsageDescription": "Tensamin uses your camera when you choose to share it in a call.", + "NSMicrophoneUsageDescription": "Tensamin uses your microphone for calls." + } }, "publish": null } diff --git a/apps/electron/src/main/main.ts b/apps/electron/src/main/main.ts index e3099f2..2a0ebfa 100644 --- a/apps/electron/src/main/main.ts +++ b/apps/electron/src/main/main.ts @@ -30,12 +30,22 @@ const verbose = process.argv.includes("--verbose"); let mainWindow: BrowserWindow | null = null; let selectedScreenShareSourceId: string | null = null; +app.setName("tensamin"); +app.setPath("userData", join(app.getPath("appData"), "tensamin", "electron")); + if (verbose) { app.commandLine.appendSwitch("enable-logging", "stderr"); app.commandLine.appendSwitch("v", "1"); app.commandLine.appendSwitch("log-level", "0"); } +if ( + process.platform === "linux" && + !app.commandLine.hasSwitch("password-store") +) { + app.commandLine.appendSwitch("password-store", "gnome-libsecret"); +} + if ( process.platform === "linux" && process.env.XDG_SESSION_TYPE === "wayland" && @@ -170,6 +180,29 @@ function registerDisplayMediaHandler() { ); } +function registerMediaPermissionHandler() { + const isTrustedRenderer = (url: string) => { + try { + const parsed = new URL(url); + return parsed.protocol === "file:"; + } catch { + return false; + } + }; + + session.defaultSession.setPermissionCheckHandler( + (_webContents, permission, requestingOrigin) => + permission === "media" && isTrustedRenderer(requestingOrigin), + ); + session.defaultSession.setPermissionRequestHandler( + (_webContents, permission, callback, details) => { + callback( + permission === "media" && isTrustedRenderer(details.requestingUrl), + ); + }, + ); +} + function registerIpc() { verboseLog("registering ipc handlers"); @@ -350,6 +383,7 @@ async function start() { verboseLog("app ready"); registerIpc(); registerDisplayMediaHandler(); + registerMediaPermissionHandler(); initTray(() => mainWindow); await createWindow(); } diff --git a/apps/electron/src/main/secureStorage.ts b/apps/electron/src/main/secureStorage.ts index b09117e..9f1f37f 100644 --- a/apps/electron/src/main/secureStorage.ts +++ b/apps/electron/src/main/secureStorage.ts @@ -34,10 +34,6 @@ function validateValue(value: unknown): asserts value is string { } export function getSecureStorageStatus(): DesktopSecureStorageStatus { - if (!safeStorage.isEncryptionAvailable()) { - return { available: false, backend: null }; - } - const backend = process.platform === "linux" ? safeStorage.getSelectedStorageBackend() @@ -48,7 +44,9 @@ export function getSecureStorageStatus(): DesktopSecureStorageStatus { : null; return { - available: process.platform !== "linux" || backend !== "basic_text", + available: + safeStorage.isEncryptionAvailable() && + (process.platform !== "linux" || backend !== "basic_text"), backend, }; } diff --git a/apps/electron/src/main/tray.ts b/apps/electron/src/main/tray.ts index 3937a4d..5daaf1b 100644 --- a/apps/electron/src/main/tray.ts +++ b/apps/electron/src/main/tray.ts @@ -8,14 +8,12 @@ const __filename = fileURLToPath(import.meta.url); const __dirname = path.dirname(__filename); function getTrayIconPath(filename: string) { - if (app.isPackaged) return path.join(process.resourcesPath, "icons", filename); + if (app.isPackaged) + return path.join(process.resourcesPath, "icons", filename); return path.resolve(__dirname, "../../build/icons", filename); } -export function setTrayCallStatus( - inCall: boolean, - iconDataUrl?: string, -) { +export function setTrayCallStatus(inCall: boolean, iconDataUrl?: string) { if (!tray) return; if (inCall && iconDataUrl) { diff --git a/apps/tauri/.gitignore b/apps/tauri/.gitignore index dc67136..8952e07 100644 --- a/apps/tauri/.gitignore +++ b/apps/tauri/.gitignore @@ -24,6 +24,3 @@ dist-ssr *.sw? .android - -/src-tauri/gen/android/keystore.properties -/src-tauri/gen/android/keystore.jks diff --git a/apps/tauri/package.json b/apps/tauri/package.json index 7cfe0dc..27be94c 100644 --- a/apps/tauri/package.json +++ b/apps/tauri/package.json @@ -4,10 +4,6 @@ "version": "0.0.0", "type": "module", "exports": { - "./controls": { - "types": "./src/windowControls.tsx", - "default": "./src/windowControls.tsx" - }, "./deeplinkHandler": { "types": "./src/deeplinkHandler.tsx", "default": "./src/deeplinkHandler.tsx" @@ -35,7 +31,7 @@ "@tauri-apps/plugin-log": "~2", "@tauri-apps/plugin-notification": "~2", "@tensamin/shared": "workspace:*", - "@tensamin/ui": "*", + "@methanium/ui": "*", "react": "^19.2.0", "react-dom": "^19.2.0" }, diff --git a/apps/tauri/src-tauri/gen/android/app/src/main/AndroidManifest.xml b/apps/tauri/src-tauri/gen/android/app/src/main/AndroidManifest.xml index 697b23b..7757466 100644 --- a/apps/tauri/src-tauri/gen/android/app/src/main/AndroidManifest.xml +++ b/apps/tauri/src-tauri/gen/android/app/src/main/AndroidManifest.xml @@ -1,6 +1,12 @@ + + + + + + @@ -39,6 +45,11 @@ + + + val includeAudio = pendingScreenAudio + pendingScreenAudio = null + + if (includeAudio == null) return@registerForActivityResult + val data = result.data + if (result.resultCode != Activity.RESULT_OK || data == null) { + MobileMediaEvents.emitError("Screen capture permission was denied") + return@registerForActivityResult + } + + MediaProjectionService.start(this, result.resultCode, data, includeAudio) + } + + private val cameraPermissionLauncher = registerForActivityResult( + ActivityResultContracts.RequestMultiplePermissions(), + ) { + emitCameraPermission() + } + + private val screenAudioPermissionLauncher = registerForActivityResult( + ActivityResultContracts.RequestPermission(), + ) { + launchScreenCaptureIntent() + } + + override fun onWebViewCreate(webView: WebView) { + webView.setInitialScale(300) + mediaWebView = webView + MobileMediaEvents.attach(webView) + webView.addJavascriptInterface(MobileMediaJavascriptInterface(), "tensaminMobileMedia") + } override fun onCreate(savedInstanceState: Bundle?) { WindowCompat.setDecorFitsSystemWindows(window, true) @@ -30,9 +76,84 @@ class MainActivity : TauriActivity() { attachLayoutListener = null contentRoot = null contentChild = null + mediaWebView?.removeJavascriptInterface("tensaminMobileMedia") + mediaWebView = null + MobileMediaEvents.detach() super.onDestroy() } + private fun startScreenShare(includeAudio: Boolean) { + runOnUiThread { + if (pendingScreenAudio != null) { + MobileMediaEvents.emitError("Screen capture permission is already pending") + return@runOnUiThread + } + + pendingScreenAudio = includeAudio + if ( + includeAudio && + ContextCompat.checkSelfPermission(this, Manifest.permission.RECORD_AUDIO) != + PackageManager.PERMISSION_GRANTED + ) { + screenAudioPermissionLauncher.launch(Manifest.permission.RECORD_AUDIO) + } else { + launchScreenCaptureIntent() + } + } + } + + private fun launchScreenCaptureIntent() { + val manager = getSystemService(MediaProjectionManager::class.java) + screenCaptureLauncher.launch(manager.createScreenCaptureIntent()) + } + + private fun stopScreenShare() { + runOnUiThread { + pendingScreenAudio = null + MediaProjectionService.stop(this) + } + } + + private fun requestCameraPermission() { + runOnUiThread { + cameraPermissionLauncher.launch( + arrayOf(Manifest.permission.CAMERA, Manifest.permission.RECORD_AUDIO), + ) + } + } + + private fun emitCameraPermission() { + val detail = JSONObject() + .put( + "camera", + ContextCompat.checkSelfPermission(this, Manifest.permission.CAMERA) == + PackageManager.PERMISSION_GRANTED, + ) + .put( + "microphone", + ContextCompat.checkSelfPermission(this, Manifest.permission.RECORD_AUDIO) == + PackageManager.PERMISSION_GRANTED, + ) + MobileMediaEvents.emit("tensamin-mobile-camera-permission", detail) + } + + private inner class MobileMediaJavascriptInterface { + @JavascriptInterface + fun startScreenShare(includeAudio: Boolean) { + this@MainActivity.startScreenShare(includeAudio) + } + + @JavascriptInterface + fun stopScreenShare() { + this@MainActivity.stopScreenShare() + } + + @JavascriptInterface + fun requestCameraPermission() { + this@MainActivity.requestCameraPermission() + } + } + private fun installKeyboardResizeWorkaround() { val content = window.decorView.findViewById(android.R.id.content) contentRoot = content diff --git a/apps/tauri/src-tauri/gen/android/app/src/main/java/net/tensamin/client/MediaProjectionService.kt b/apps/tauri/src-tauri/gen/android/app/src/main/java/net/tensamin/client/MediaProjectionService.kt new file mode 100644 index 0000000..0afa75a --- /dev/null +++ b/apps/tauri/src-tauri/gen/android/app/src/main/java/net/tensamin/client/MediaProjectionService.kt @@ -0,0 +1,348 @@ +package net.tensamin.client + +import android.Manifest +import android.app.NotificationChannel +import android.app.NotificationManager +import android.app.PendingIntent +import android.app.Service +import android.content.Context +import android.content.Intent +import android.content.pm.PackageManager +import android.content.pm.ServiceInfo +import android.graphics.Bitmap +import android.graphics.PixelFormat +import android.hardware.display.DisplayManager +import android.hardware.display.VirtualDisplay +import android.media.AudioAttributes +import android.media.AudioFormat +import android.media.AudioPlaybackCaptureConfiguration +import android.media.AudioRecord +import android.media.projection.MediaProjection +import android.media.projection.MediaProjectionManager +import android.media.ImageReader +import android.os.Build +import android.os.Handler +import android.os.HandlerThread +import android.os.IBinder +import android.util.Base64 +import android.util.DisplayMetrics +import androidx.core.content.ContextCompat +import java.io.ByteArrayOutputStream +import java.util.concurrent.atomic.AtomicBoolean +import org.json.JSONObject + +class MediaProjectionService : Service() { + private var projection: MediaProjection? = null + private var virtualDisplay: VirtualDisplay? = null + private var imageReader: ImageReader? = null + private var captureThread: HandlerThread? = null + private var audioRecord: AudioRecord? = null + private var audioThread: Thread? = null + private val captureActive = AtomicBoolean(false) + private var lastFrameAt = 0L + + private val projectionCallback = object : MediaProjection.Callback() { + override fun onStop() { + stopCapture(stopProjection = false, emitStopped = true) + stopSelf() + } + } + + override fun onBind(intent: Intent?): IBinder? = null + + override fun onStartCommand(intent: Intent?, flags: Int, startId: Int): Int { + if (intent?.action == ACTION_STOP) { + stopCapture(stopProjection = true, emitStopped = true) + stopSelf() + return START_NOT_STICKY + } + + val permissionData = if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.TIRAMISU) { + intent?.getParcelableExtra(EXTRA_PERMISSION_DATA, Intent::class.java) + } else { + @Suppress("DEPRECATION") + intent?.getParcelableExtra(EXTRA_PERMISSION_DATA) + } + val resultCode = intent?.getIntExtra(EXTRA_RESULT_CODE, Int.MIN_VALUE) ?: Int.MIN_VALUE + if (permissionData == null || resultCode == Int.MIN_VALUE) { + MobileMediaEvents.emitError("Screen capture permission data is missing") + stopSelf() + return START_NOT_STICKY + } + + val includeAudio = intent?.getBooleanExtra(EXTRA_INCLUDE_AUDIO, false) ?: false + try { + startForegroundNotification() + startCapture(resultCode, permissionData, includeAudio) + } catch (error: Throwable) { + stopCapture(stopProjection = true, emitStopped = false) + stopForeground(STOP_FOREGROUND_REMOVE) + stopSelf() + MobileMediaEvents.emitError(error.message ?: "Unable to start screen capture") + } + return START_NOT_STICKY + } + + override fun onDestroy() { + stopCapture(stopProjection = true, emitStopped = true) + super.onDestroy() + } + + private fun startForegroundNotification() { + val notificationManager = getSystemService(NotificationManager::class.java) + if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) { + notificationManager.createNotificationChannel( + NotificationChannel( + NOTIFICATION_CHANNEL_ID, + "Screen sharing", + NotificationManager.IMPORTANCE_LOW, + ), + ) + } + + val stopIntent = Intent(this, MediaProjectionService::class.java).setAction(ACTION_STOP) + val stopPendingIntent = PendingIntent.getService( + this, + 0, + stopIntent, + PendingIntent.FLAG_UPDATE_CURRENT or PendingIntent.FLAG_IMMUTABLE, + ) + val notification = if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) { + android.app.Notification.Builder(this, NOTIFICATION_CHANNEL_ID) + } else { + android.app.Notification.Builder(this) + } + .setSmallIcon(android.R.drawable.ic_menu_share) + .setContentTitle("Tensamin is sharing your screen") + .setContentText("Tap Stop to end screen sharing") + .setOngoing(true) + .setCategory(android.app.Notification.CATEGORY_SERVICE) + .addAction(android.R.drawable.ic_media_pause, "Stop", stopPendingIntent) + .build() + + if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.Q) { + startForeground( + NOTIFICATION_ID, + notification, + ServiceInfo.FOREGROUND_SERVICE_TYPE_MEDIA_PROJECTION, + ) + } else { + startForeground(NOTIFICATION_ID, notification) + } + } + + @Suppress("DEPRECATION") + private fun startCapture(resultCode: Int, permissionData: Intent, includeAudio: Boolean) { + stopCapture(stopProjection = true, emitStopped = false) + + val manager = getSystemService(MediaProjectionManager::class.java) + val newProjection = manager.getMediaProjection(resultCode, permissionData) + ?: error("Android did not provide a screen capture session") + projection = newProjection + + val thread = HandlerThread("tensamin-screen-capture").also { it.start() } + captureThread = thread + val handler = Handler(thread.looper) + newProjection.registerCallback(projectionCallback, handler) + + val metrics = DisplayMetrics() + getSystemService(android.view.WindowManager::class.java).defaultDisplay.getRealMetrics(metrics) + val displayWidth = metrics.widthPixels + val displayHeight = metrics.heightPixels + val width = minOf(displayWidth, MAX_FRAME_WIDTH) + val height = (displayHeight.toLong() * width / displayWidth).toInt() + val density = metrics.densityDpi + val reader = ImageReader.newInstance(width, height, PixelFormat.RGBA_8888, 2) + imageReader = reader + reader.setOnImageAvailableListener({ source -> captureFrame(source, width, height) }, handler) + + virtualDisplay = newProjection.createVirtualDisplay( + "Tensamin screen sharing", + width, + height, + density, + DisplayManager.VIRTUAL_DISPLAY_FLAG_AUTO_MIRROR, + reader.surface, + null, + handler, + ) + captureActive.set(true) + + val audioStarted = includeAudio && startAudioCapture(newProjection) + MobileMediaEvents.emit( + "tensamin-mobile-screen-started", + JSONObject().put("includeAudio", audioStarted), + ) + } + + private fun captureFrame(source: ImageReader, width: Int, height: Int) { + val image = source.acquireLatestImage() ?: return + try { + val now = System.currentTimeMillis() + if (!captureActive.get() || now - lastFrameAt < FRAME_INTERVAL_MS) return + lastFrameAt = now + + val plane = image.planes[0] + val paddedWidth = plane.rowStride / plane.pixelStride + val paddedBitmap = Bitmap.createBitmap(paddedWidth, height, Bitmap.Config.ARGB_8888) + paddedBitmap.copyPixelsFromBuffer(plane.buffer) + val croppedBitmap = if (paddedWidth == width) { + paddedBitmap + } else { + Bitmap.createBitmap(paddedBitmap, 0, 0, width, height).also { paddedBitmap.recycle() } + } + val outputBitmap = croppedBitmap + + val bytes = ByteArrayOutputStream() + outputBitmap.compress(Bitmap.CompressFormat.JPEG, JPEG_QUALITY, bytes) + val outputWidth = outputBitmap.width + val outputHeight = outputBitmap.height + outputBitmap.recycle() + MobileMediaEvents.emit( + "tensamin-mobile-screen-frame", + JSONObject() + .put("data", Base64.encodeToString(bytes.toByteArray(), Base64.NO_WRAP)) + .put("mimeType", "image/jpeg") + .put("width", outputWidth) + .put("height", outputHeight), + ) + } catch (error: Throwable) { + if (captureActive.get()) { + MobileMediaEvents.emitError(error.message ?: "Unable to read a screen frame") + } + } finally { + image.close() + } + } + + private fun startAudioCapture(activeProjection: MediaProjection): Boolean { + if (Build.VERSION.SDK_INT < Build.VERSION_CODES.Q) { + MobileMediaEvents.emitError("System audio capture requires Android 10 or newer") + return false + } + if (ContextCompat.checkSelfPermission(this, Manifest.permission.RECORD_AUDIO) != + PackageManager.PERMISSION_GRANTED + ) { + MobileMediaEvents.emitError("Microphone permission is required for system audio capture") + return false + } + + return try { + val format = AudioFormat.Builder() + .setEncoding(AudioFormat.ENCODING_PCM_16BIT) + .setSampleRate(AUDIO_SAMPLE_RATE) + .setChannelMask(AudioFormat.CHANNEL_IN_MONO) + .build() + val configuration = AudioPlaybackCaptureConfiguration.Builder(activeProjection) + .addMatchingUsage(AudioAttributes.USAGE_MEDIA) + .addMatchingUsage(AudioAttributes.USAGE_GAME) + .build() + val minimumBuffer = AudioRecord.getMinBufferSize( + AUDIO_SAMPLE_RATE, + AudioFormat.CHANNEL_IN_MONO, + AudioFormat.ENCODING_PCM_16BIT, + ) + check(minimumBuffer > 0) { "Android could not allocate a system audio buffer" } + val bufferSize = maxOf(minimumBuffer * 2, AUDIO_BATCH_BYTES) + val record = AudioRecord.Builder() + .setAudioFormat(format) + .setAudioPlaybackCaptureConfig(configuration) + .setBufferSizeInBytes(bufferSize) + .build() + check(record.state == AudioRecord.STATE_INITIALIZED) { + "Android could not initialize system audio capture" + } + audioRecord = record + record.startRecording() + audioThread = Thread({ readAudio(record) }, "tensamin-audio-capture").also { it.start() } + true + } catch (error: Throwable) { + audioRecord?.release() + audioRecord = null + MobileMediaEvents.emitError(error.message ?: "Unable to capture system audio") + false + } + } + + private fun readAudio(record: AudioRecord) { + val buffer = ByteArray(AUDIO_BATCH_BYTES) + while (captureActive.get() && !Thread.currentThread().isInterrupted) { + val read = record.read(buffer, 0, buffer.size, AudioRecord.READ_BLOCKING) + if (read > 0 && captureActive.get()) { + MobileMediaEvents.emit( + "tensamin-mobile-screen-audio", + JSONObject() + .put("data", Base64.encodeToString(buffer, 0, read, Base64.NO_WRAP)) + .put("sampleRate", AUDIO_SAMPLE_RATE) + .put("channelCount", 1) + .put("encoding", "pcm16le"), + ) + } else if (read < 0 && captureActive.get()) { + MobileMediaEvents.emitError("System audio capture stopped with code $read") + return + } + } + } + + @Synchronized + private fun stopCapture(stopProjection: Boolean, emitStopped: Boolean) { + val wasActive = captureActive.getAndSet(false) + + val record = audioRecord + audioRecord = null + try { + record?.stop() + } catch (_: IllegalStateException) { + } + record?.release() + audioThread?.interrupt() + audioThread = null + + imageReader?.setOnImageAvailableListener(null, null) + virtualDisplay?.release() + virtualDisplay = null + imageReader?.close() + imageReader = null + + val oldProjection = projection + projection = null + oldProjection?.unregisterCallback(projectionCallback) + if (stopProjection) oldProjection?.stop() + + captureThread?.quitSafely() + captureThread = null + lastFrameAt = 0L + + if (wasActive && emitStopped) { + MobileMediaEvents.emit("tensamin-mobile-screen-stopped") + } + } + + companion object { + private const val ACTION_STOP = "net.tensamin.client.STOP_SCREEN_SHARE" + private const val EXTRA_RESULT_CODE = "resultCode" + private const val EXTRA_PERMISSION_DATA = "permissionData" + private const val EXTRA_INCLUDE_AUDIO = "includeAudio" + private const val NOTIFICATION_CHANNEL_ID = "screen-sharing" + private const val NOTIFICATION_ID = 7314 + private const val FRAME_INTERVAL_MS = 75L + private const val MAX_FRAME_WIDTH = 1280 + private const val JPEG_QUALITY = 72 + private const val AUDIO_SAMPLE_RATE = 48_000 + private const val AUDIO_BATCH_BYTES = 9_600 + + fun start(context: Context, resultCode: Int, data: Intent, includeAudio: Boolean) { + val intent = Intent(context, MediaProjectionService::class.java) + .putExtra(EXTRA_RESULT_CODE, resultCode) + .putExtra(EXTRA_PERMISSION_DATA, data) + .putExtra(EXTRA_INCLUDE_AUDIO, includeAudio) + ContextCompat.startForegroundService(context, intent) + } + + fun stop(context: Context) { + context.startService( + Intent(context, MediaProjectionService::class.java).setAction(ACTION_STOP), + ) + } + } +} diff --git a/apps/tauri/src-tauri/gen/android/app/src/main/java/net/tensamin/client/MobileMediaEvents.kt b/apps/tauri/src-tauri/gen/android/app/src/main/java/net/tensamin/client/MobileMediaEvents.kt new file mode 100644 index 0000000..c8c377c --- /dev/null +++ b/apps/tauri/src-tauri/gen/android/app/src/main/java/net/tensamin/client/MobileMediaEvents.kt @@ -0,0 +1,29 @@ +package net.tensamin.client + +import android.webkit.WebView +import java.lang.ref.WeakReference +import org.json.JSONObject + +object MobileMediaEvents { + private var webView = WeakReference(null) + + fun attach(value: WebView) { + webView = WeakReference(value) + } + + fun detach() { + webView.clear() + } + + fun emitError(message: String) { + emit("tensamin-mobile-screen-error", JSONObject().put("message", message)) + } + + fun emit(name: String, detail: JSONObject = JSONObject()) { + val view = webView.get() ?: return + val script = "window.dispatchEvent(new CustomEvent(" + + JSONObject.quote(name) + + ", { detail: " + detail.toString() + " }));" + view.post { view.evaluateJavascript(script, null) } + } +} diff --git a/apps/tauri/src/deeplinkHandler.tsx b/apps/tauri/src/deeplinkHandler.tsx index 1053ea3..2094b73 100644 --- a/apps/tauri/src/deeplinkHandler.tsx +++ b/apps/tauri/src/deeplinkHandler.tsx @@ -7,7 +7,7 @@ import { } from "react"; import { getCurrent, onOpenUrl } from "@tauri-apps/plugin-deep-link"; import { isTauri } from "@tauri-apps/api/core"; -import { useIsMobile } from "@tensamin/ui"; +import { useIsMobile } from "@methanium/ui"; type DeeplinkContextValue = { deeplinks: readonly string[]; diff --git a/apps/tauri/src/qrCodeScanner.tsx b/apps/tauri/src/qrCodeScanner.tsx index e4c36ca..fa3f3c7 100644 --- a/apps/tauri/src/qrCodeScanner.tsx +++ b/apps/tauri/src/qrCodeScanner.tsx @@ -3,7 +3,7 @@ import { Format, requestPermissions, } from "@tauri-apps/plugin-barcode-scanner"; -import { Button } from "@tensamin/ui"; +import { Button } from "@methanium/ui"; import { toast } from "@tensamin/shared/log"; diff --git a/apps/web/package.json b/apps/web/package.json index dfa243a..d95d914 100644 --- a/apps/web/package.json +++ b/apps/web/package.json @@ -60,9 +60,10 @@ "@tensamin/mtp": "workspace:*", "@tensamin/tauth": "workspace:*", "@tensamin/markdown": "workspace:*", - "@tensamin/ui": "*", + "@methanium/ui": "*", "@tensamin/user": "workspace:*", "@tensamin/notifications": "workspace:*", + "@tensamin/onboarding": "workspace:*", "aria-hidden": "^1.2.4", "class-variance-authority": "^0.7.1", "clsx": "^2.1.1", diff --git a/apps/web/public/sounds/call_jingle_1.wav b/apps/web/public/sounds/call_jingle_1.wav new file mode 100644 index 0000000..93a23b5 Binary files /dev/null and b/apps/web/public/sounds/call_jingle_1.wav differ diff --git a/apps/web/public/sounds/call_jingle_2.wav b/apps/web/public/sounds/call_jingle_2.wav new file mode 100644 index 0000000..33d9efd Binary files /dev/null and b/apps/web/public/sounds/call_jingle_2.wav differ diff --git a/apps/web/public/sounds/call_join.wav b/apps/web/public/sounds/call_join.wav new file mode 100644 index 0000000..b135ab7 Binary files /dev/null and b/apps/web/public/sounds/call_join.wav differ diff --git a/apps/web/public/sounds/call_leave.wav b/apps/web/public/sounds/call_leave.wav new file mode 100644 index 0000000..eb7f53b Binary files /dev/null and b/apps/web/public/sounds/call_leave.wav differ diff --git a/apps/web/public/sounds/message.wav b/apps/web/public/sounds/message.wav new file mode 100644 index 0000000..59ecedf Binary files /dev/null and b/apps/web/public/sounds/message.wav differ diff --git a/apps/web/public/sounds/stream_end_other.wav b/apps/web/public/sounds/stream_end_other.wav new file mode 100644 index 0000000..4177d12 Binary files /dev/null and b/apps/web/public/sounds/stream_end_other.wav differ diff --git a/apps/web/public/sounds/stream_end_self.wav b/apps/web/public/sounds/stream_end_self.wav new file mode 100644 index 0000000..8a78493 Binary files /dev/null and b/apps/web/public/sounds/stream_end_self.wav differ diff --git a/apps/web/public/sounds/stream_start_other.wav b/apps/web/public/sounds/stream_start_other.wav new file mode 100644 index 0000000..bca4724 Binary files /dev/null and b/apps/web/public/sounds/stream_start_other.wav differ diff --git a/apps/web/public/sounds/stream_start_self.wav b/apps/web/public/sounds/stream_start_self.wav new file mode 100644 index 0000000..5e57021 Binary files /dev/null and b/apps/web/public/sounds/stream_start_self.wav differ diff --git a/apps/web/public/sounds/stream_watch_end.wav b/apps/web/public/sounds/stream_watch_end.wav new file mode 100644 index 0000000..e81557a Binary files /dev/null and b/apps/web/public/sounds/stream_watch_end.wav differ diff --git a/apps/web/public/sounds/stream_watch_start.wav b/apps/web/public/sounds/stream_watch_start.wav new file mode 100644 index 0000000..acf863d Binary files /dev/null and b/apps/web/public/sounds/stream_watch_start.wav differ diff --git a/apps/web/src/components/modals/basic.tsx b/apps/web/src/components/modals/basic.tsx index 01794cb..46eaa45 100644 --- a/apps/web/src/components/modals/basic.tsx +++ b/apps/web/src/components/modals/basic.tsx @@ -6,9 +6,9 @@ import { Tooltip, TooltipTrigger, TooltipContent, -} from "@tensamin/ui"; -import { Card, CardHeader } from "@tensamin/ui"; -import { Skeleton } from "@tensamin/ui"; + Button, +} from "@methanium/ui"; +import { Skeleton } from "@methanium/ui"; import { getStatusColor } from "@tensamin/shared/data"; export function Basic({ @@ -18,42 +18,50 @@ export function Basic({ user: User; extra?: React.ReactNode; }) { + const display = user.Display || user.Username || "Unknown"; + const onlineStatus = user.OnlineStatus || "user_borked"; + const avatar = user.Avatar + ? `data:image/webp;base64,${user.Avatar}` + : undefined; + return ( - - -
- - - - {user.Display.slice(0, 2).toUpperCase()} - - - - -
-
- } - /> - - {user.OnlineStatus.split("_") - .map((word) => word.charAt(0).toUpperCase() + word.slice(1)) - .join(" ")} - -
-
-
-

{user.Display}

-
-
{extra}
-
-
+ ); } diff --git a/apps/web/src/components/modals/profile.tsx b/apps/web/src/components/modals/profile.tsx index 62405cc..edd83a6 100644 --- a/apps/web/src/components/modals/profile.tsx +++ b/apps/web/src/components/modals/profile.tsx @@ -1,5 +1,5 @@ import type { User } from "@tensamin/user/context"; -import { Avatar, AvatarFallback, AvatarImage, Button } from "@tensamin/ui"; +import { Avatar, AvatarFallback, AvatarImage, Button } from "@methanium/ui"; import Text from "@tensamin/markdown/text"; import { ChevronDown, ChevronUp } from "lucide-react"; import { useState } from "react"; @@ -24,7 +24,7 @@ export default function Profile({ user }: { user: User }) { + )} + /> ) : ( <> )} + {isMobile && pathname === "/call" && callId && ( +

{displayCallId(callId)}

+ )} {pathname === "/chat" && id && ( ( - } + )} /> @@ -109,7 +132,7 @@ export default function Navbar({ forMobile }: { forMobile: boolean }) { onClick={() => { void joinCall(id); }} - className="w-9 h-9 aspect-square rounded-lg" + className="w-9 h-9! aspect-square rounded-lg" variant="outline" > @@ -124,7 +147,7 @@ export default function Navbar({ forMobile }: { forMobile: boolean }) { currentCalls[0].CallId, ); }} - className="w-9 h-9 aspect-square rounded-lg" + className="w-9 h-9! aspect-square rounded-lg" > @@ -161,6 +184,11 @@ export default function Navbar({ forMobile }: { forMobile: boolean }) { )} )} + {isMobile && pathname === "/call" && callId && ( + + )} @@ -175,7 +203,7 @@ export function MobileNavbar() {
@@ -186,7 +214,7 @@ export function MobileNavbar() { navigate({ to: "/" }); setOpenMobile(false); }} - className="text-foreground w-12 h-12 aspect-square rounded-xl flex flex-col gap-1" + className="text-foreground w-12 h-12 aspect-square rounded-xl flex flex-col gap-1 border-0! bg-none! bg-transparent!" variant="link" > @@ -197,7 +225,7 @@ export function MobileNavbar() { navigate({ to: "/settings" }); setOpenMobile(false); }} - className="text-foreground w-12 h-12 aspect-square rounded-xl flex flex-col gap-1" + className="text-foreground w-12 h-12 aspect-square rounded-xl flex flex-col gap-1 border-0! bg-none! bg-transparent!" variant="link" > diff --git a/apps/web/src/components/screens/login/form.tsx b/apps/web/src/components/screens/login/form.tsx index 89a0d74..c81ef92 100644 --- a/apps/web/src/components/screens/login/form.tsx +++ b/apps/web/src/components/screens/login/form.tsx @@ -1,13 +1,21 @@ -import { Button, cn, useIsMobile } from "@tensamin/ui"; -import { Input } from "@tensamin/ui"; -import { Label } from "@tensamin/ui"; +import { Button, cn, useIsMobile } from "@methanium/ui"; +import { Input } from "@methanium/ui"; +import { Label } from "@methanium/ui"; import { useStorage } from "@tensamin/storage/context"; import { log, toast } from "@tensamin/shared/log"; import { File } from "lucide-react"; -import * as React from "react"; +import { + type ChangeEvent, + type FormEvent, + useCallback, + useEffect, + useRef, + useState, +} from "react"; import { z } from "zod"; import { isTauri } from "@tauri-apps/api/core"; import QrCodeScanner from "@tensamin/tauri/qrCodeScanner"; +import { useNavigate } from "@tanstack/react-router"; const fetchedUser = z.object({ id: z.uuidv4(), @@ -77,12 +85,13 @@ function parseTuFileContent(rawFileContent: string): { export default function Form() { const isMobile = useIsMobile(); - const uploadRef = React.useRef(null); - const [isDragging, setIsDragging] = React.useState(false); + const uploadRef = useRef(null); + const [isDragging, setIsDragging] = useState(false); const { save } = useStorage(); - const loginPendingRef = React.useRef(false); + const navigate = useNavigate(); + const loginPendingRef = useRef(false); - const persistLogin = React.useCallback( + const persistLogin = useCallback( async (userId: number, privateKey: string, domain?: string | null) => { if (loginPendingRef.current) return false; loginPendingRef.current = true; @@ -91,22 +100,17 @@ export default function Form() { await save("mtp_keyring", privateKey, { secure: true }); await save("session_id", Date.now()); await save("user_id", userId); - window.history.replaceState( - null, - "", - window.location.protocol === "file:" ? "#/" : "/", - ); - window.location.reload(); + await navigate({ to: "/", replace: true }); return true; } finally { loginPendingRef.current = false; } }, - [save], + [navigate, save], ); // Process dropped files - const processDroppedFile = React.useCallback( + const processDroppedFile = useCallback( async (file: globalThis.File): Promise => { try { if (!file.name.endsWith(".tu")) { @@ -127,8 +131,8 @@ export default function Form() { ); // Handle .tu files - const handleFileInputChange = React.useCallback( - async (event: React.ChangeEvent): Promise => { + const handleFileInputChange = useCallback( + async (event: ChangeEvent): Promise => { const file = event.currentTarget.files?.[0]; if (!file) { @@ -142,7 +146,7 @@ export default function Form() { ); // Drag and drop listener - React.useEffect(() => { + useEffect(() => { let dragCounter = 0; const handleDragEnter = (event: DragEvent) => { @@ -212,8 +216,8 @@ export default function Form() { * @param event Form submit event. * @returns Promise that resolves after login processing. */ - const handleCredentialsSubmit = React.useCallback( - async (event: React.FormEvent): Promise => { + const handleCredentialsSubmit = useCallback( + async (event: FormEvent): Promise => { event.preventDefault(); const formData = new FormData(event.currentTarget); diff --git a/apps/web/src/components/sidebar.tsx b/apps/web/src/components/sidebar.tsx index 9e0c314..10baf34 100644 --- a/apps/web/src/components/sidebar.tsx +++ b/apps/web/src/components/sidebar.tsx @@ -26,9 +26,9 @@ import { SelectValue, SelectContent, SelectItem, -} from "@tensamin/ui"; +} from "@methanium/ui"; import { isTauri } from "@tauri-apps/api/core"; -import { useIsMobile } from "@tensamin/ui"; +import { useIsMobile } from "@methanium/ui"; import { MobileNavbar } from "./navbar"; import SidebarBox from "@tensamin/call/sidebarBox"; @@ -298,7 +298,7 @@ export default function Sidebar() { data-sidebar="sidebar" data-slot="sidebar" data-mobile="true" - className="fixed inset-y-0 left-0 z-50 w-screen bg-sidebar p-0 text-sidebar-foreground transition-[transform,opacity] duration-150 ease-linear" + className="fixed inset-y-0 left-0 z-50 w-screen bg-sidebar p-0 text-sidebar-foreground" style={{ transform: openMobile ? "translateX(0)" : "translateX(-100%)", opacity: openMobile ? 1 : 0, diff --git a/apps/web/src/features/conversation/list/body.tsx b/apps/web/src/features/conversation/list/body.tsx index 36399e9..cc3baaf 100644 --- a/apps/web/src/features/conversation/list/body.tsx +++ b/apps/web/src/features/conversation/list/body.tsx @@ -1,4 +1,4 @@ -import * as React from "react"; +import { useRef, useState } from "react"; import { useVirtualizer } from "@tanstack/react-virtual"; import Switch from "./switch"; @@ -8,14 +8,14 @@ import { Loader2 } from "lucide-react"; import { useSession } from "@tensamin/storage/session"; export default function List() { - const [category, setCategory] = React.useState< - "conversations" | "communities" - >("conversations"); + const [category, setCategory] = useState<"conversations" | "communities">( + "conversations", + ); const { contacts, communities } = useSession(); const items = category === "conversations" ? contacts : communities; - const scrollRef = React.useRef(null); + const scrollRef = useRef(null); // TanStack Virtual is intentionally used here; React Compiler memoization is skipped. // eslint-disable-next-line react-hooks/incompatible-library @@ -31,7 +31,7 @@ export default function List() {
{items === null ? (
diff --git a/apps/web/src/features/conversation/modal/conversation.tsx b/apps/web/src/features/conversation/modal/conversation.tsx index efa8ba5..90a45a6 100644 --- a/apps/web/src/features/conversation/modal/conversation.tsx +++ b/apps/web/src/features/conversation/modal/conversation.tsx @@ -6,9 +6,9 @@ import { ContextMenuGroup, ContextMenuItem, ContextMenuTrigger, -} from "@tensamin/ui"; +} from "@methanium/ui"; import { useNavigate } from "@tanstack/react-router"; -import { useSidebar } from "@tensamin/ui"; +import { useSidebar } from "@methanium/ui"; export default function ConversationModal({ userId }: { userId: number }) { const navigate = useNavigate(); diff --git a/apps/web/src/features/legal/screen.tsx b/apps/web/src/features/legal/screen.tsx deleted file mode 100644 index 9859036..0000000 --- a/apps/web/src/features/legal/screen.tsx +++ /dev/null @@ -1,247 +0,0 @@ -import { useState, useCallback, useEffect } from "react"; -import { useStorage } from "@tensamin/storage/context"; -import { Button } from "@tensamin/ui"; -import { Checkbox } from "@tensamin/ui"; -import { z } from "zod"; - -import { ErrorScreen } from "@tensamin/ui"; - -import { legalDocsSchema } from "@tensamin/shared/features/legal/schema"; -import { log } from "@tensamin/shared/log"; -import { Link } from "@tensamin/ui"; -import { Label } from "@tensamin/ui"; -import { CreateScreen } from "@tensamin/ui"; - -// Prevents the user from using Tensamin without accepting the privacy policy and terms of service. -export default function Screen(props: { children: React.ReactNode }) { - const { load, save } = useStorage(); - - const [error, setError] = useState(""); - const [errorDescription, setErrorDescription] = useState(""); - - const [remoteDocs, setRemoteDocs] = useState< - z.infer | undefined - >(undefined); - const [localDocs, setLocalDocs] = useState< - z.infer | undefined - >(undefined); - - const [loading, setLoading] = useState(true); - - const [acceptedPP, acceptPP] = useState(false); - const [acceptedTOS, acceptTOS] = useState(false); - const [hasContinued, setHasContinued] = useState(false); - - const [userId, setUserId] = useState(undefined); - - // Saves - const handleContinueLegal = useCallback((): void => { - const currentDocs = remoteDocs; - if (!currentDocs) { - return; - } - - save("accepted_privacy_policy", true); - save("accepted_terms_of_service", true); - save("legal_docs", currentDocs); - setHasContinued(true); - }, [remoteDocs, save]); - - useEffect(() => { - let active = true; - - void (async () => { - try { - const id = await load("user_id"); - if (!active) { - return; - } - - setUserId(id); - - if (id === 0) { - return; - } - - const current = await fetch("https://legal.tensamin.net/api/current") - .then((res) => res.json()) - .catch((err) => { - if (!active) { - return undefined; - } - - setError("Failed to load legal documents"); - setErrorDescription( - "An error occurred while fetching the legal documents from the server. Please try again later.", - ); - log(0, "Legal", "red", "Failed to fetch legal documents", err); - return undefined; - }); - - if (!active || current === undefined) { - return; - } - - const safeCurrent = legalDocsSchema.safeParse(current); - if (!safeCurrent.success) { - setError("Failed to load legal documents"); - setErrorDescription( - "The legal documents data received from the server is invalid. Please try again later.", - ); - log( - 0, - "Legal", - "red", - "Invalid legal documents data", - safeCurrent.error, - ); - return; - } - - setRemoteDocs(safeCurrent.data); - - const currentLocalDocs = await load("legal_docs"); - setLocalDocs(currentLocalDocs); - - const [loadedAcceptedPP, loadedAcceptedTOS] = await Promise.all([ - load("accepted_privacy_policy"), - load("accepted_terms_of_service"), - ]); - - if (!active) { - return; - } - - acceptPP( - loadedAcceptedPP && - !!currentLocalDocs && - currentLocalDocs.pp.hash === safeCurrent.data.pp.hash, - ); - acceptTOS( - loadedAcceptedTOS && - !!currentLocalDocs && - currentLocalDocs.tos.hash === safeCurrent.data.tos.hash, - ); - } finally { - if (active) { - setLoading(false); - } - } - })(); - - return () => { - active = false; - }; - }, [load]); - - if (error !== "" && errorDescription !== "") { - return ; - } - - if (loading || userId === undefined) { - return null; - } - - const docsMatch = - localDocs !== undefined && - remoteDocs !== undefined && - localDocs.pp.hash === remoteDocs.pp.hash && - localDocs.tos.hash === remoteDocs.tos.hash; - - if ( - (acceptedPP && acceptedTOS && (docsMatch || hasContinued)) || - userId === 0 - ) { - return <>{props.children}; - } - - return ( - -
-

- Privacy Policy & ToS -

- {remoteDocs?.pp.version} / {remoteDocs?.tos.version} -

-

-
-
- - -
- - -
-
- -
- - ); -} - -// Components -function ContinueButton({ - onClick, - disabled, -}: { - onClick: () => void; - disabled?: boolean; -}) { - return ( -
- -
- ); -} - -function BigCheckbox({ - id, - label, - checked, - onChange, -}: { - id: string; - label: string; - checked: boolean; - onChange: (checked: boolean) => void; -}) { - return ( -
- - -
- ); -} diff --git a/apps/web/src/index.tsx b/apps/web/src/index.tsx index f59bfc5..8a7e776 100644 --- a/apps/web/src/index.tsx +++ b/apps/web/src/index.tsx @@ -9,19 +9,19 @@ import { } from "@tanstack/react-router"; import "./index.css"; -import "@tensamin/ui/index.css"; +import "@methanium/ui/index.css"; import NotFound from "@/routes/404"; import AppLayout from "@/routes/app/layout"; import { createSettingsRoute } from "@tensamin/settings"; +import OnboardingGate from "@tensamin/onboarding"; import Home from "@/routes/app/home"; import ChatScreen from "@tensamin/chat/screen"; import CallScreen from "@tensamin/call/screen"; import Login from "@/routes/screens/login"; -import CallPopout from "@tensamin/call/popout"; import ChatContext from "@tensamin/chat/context"; import { useCall, useInitializeCall } from "@tensamin/call/store"; import { useIsSpeaking } from "@tensamin/call/speakingState"; @@ -32,7 +32,7 @@ import NotificationsProvider from "@tensamin/notifications/context"; import TAuthWrapper from "@tensamin/tauth/context"; -import { ErrorScreen, ThemeProvider, useTheme } from "@tensamin/ui"; +import { ErrorScreen, ThemeProvider, useTheme } from "@methanium/ui"; import z from "zod"; import { useEffect, useRef, useState, type ReactNode } from "react"; @@ -43,12 +43,11 @@ import Crypto from "@tensamin/crypto/context"; import DesktopMediaProvider from "@tensamin/shared/desktopMedia"; import { log } from "@tensamin/shared/log"; -import LegalWrapper from "@/features/legal/screen"; import CacheSync from "@tensamin/cache/sync"; import { useStorage } from "@tensamin/storage/context"; import { useLocation, useNavigate } from "@tanstack/react-router"; -import { useIsMobile, Toaster, TooltipProvider } from "@tensamin/ui"; +import { useIsMobile, Toaster, TooltipProvider } from "@methanium/ui"; import { isTauri } from "@tauri-apps/api/core"; const wrapper = document.getElementById("root"); @@ -131,6 +130,11 @@ function ThemeStorageBridge() { setThemeBorderRadius, themeCustomCss, setThemeCustomCss, + parentThemeId, + setParentThemeId, + applyThemePreset, + themeDesign, + setThemeDesign, } = useTheme(); const loadedRef = useRef(false); @@ -145,6 +149,8 @@ function ThemeStorageBridge() { load("theme_tint"), load("theme_border_radius"), load("theme_custom_css"), + load("theme_parent"), + load("theme_design"), ]).then( ([ color, @@ -154,18 +160,23 @@ function ThemeStorageBridge() { tint, borderRadius, customCss, + parent, + design, ]) => { if (!active) { return; } + if (customCss === "" && parent) applyThemePreset(parent); + else setParentThemeId(parent || null); setThemeColor(color); setThemePalette(palette); setThemePrimaryColor(primaryColor); setThemePolarity(polarity); setThemeTint(tint); setThemeBorderRadius(borderRadius); - setThemeCustomCss(customCss); + if (customCss !== "") setThemeCustomCss(customCss); + setThemeDesign(design); loadedRef.current = true; }, ); @@ -175,9 +186,12 @@ function ThemeStorageBridge() { }; }, [ load, + applyThemePreset, setThemeBorderRadius, setThemeColor, setThemeCustomCss, + setParentThemeId, + setThemeDesign, setThemePalette, setThemePolarity, setThemePrimaryColor, @@ -212,6 +226,14 @@ function ThemeStorageBridge() { if (loadedRef.current) save("theme_custom_css", themeCustomCss); }, [save, themeCustomCss]); + useEffect(() => { + if (loadedRef.current) save("theme_parent", parentThemeId ?? ""); + }, [parentThemeId, save]); + + useEffect(() => { + if (loadedRef.current) save("theme_design", themeDesign); + }, [save, themeDesign]); + return null; } @@ -228,6 +250,8 @@ function RootShell() { tintStorageKey={null} borderRadiusStorageKey={null} customCssStorageKey={null} + parentThemeStorageKey={null} + designStorageKey={null} >
- - - - - - - + @@ -262,24 +280,29 @@ function RootShell() { function AppShell() { return ( - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + ); } @@ -307,7 +330,7 @@ function createCallTrayIcon(color: string, speaking: boolean) { } function CallInit() { - useInitializeCall(); + const callInvitePopup = useInitializeCall(); const { load } = useStorage(); const { @@ -370,7 +393,7 @@ function CallInit() { }); }, [inCall, primaryColor, speaking]); - return null; + return callInvitePopup; } const rootRoute = createRootRoute({ diff --git a/apps/web/src/routes/app/home.tsx b/apps/web/src/routes/app/home.tsx index ee5220b..cd4f662 100644 --- a/apps/web/src/routes/app/home.tsx +++ b/apps/web/src/routes/app/home.tsx @@ -9,7 +9,7 @@ import { Input, Button, useIsMobile, -} from "@tensamin/ui"; +} from "@methanium/ui"; import z from "zod"; import { useMTP } from "@tensamin/mtp"; import { useState } from "react"; @@ -79,7 +79,7 @@ function AddConversationButton() { Username: result.data, }) .then((data) => { - if (data.data.UserId === 0) { + if (data.type === "ErrorNotFound" || data.data.UserId === 0) { throw new Error(); } @@ -101,7 +101,7 @@ function AddConversationButton() { const timeout = setTimeout(() => setLoading(true), 500); send("AddConversation", { - ChatPartnerName: result.data, + ChatPartnerId: user.data.UserId, }) .then(() => { insertContact(user.data.UserId); @@ -131,8 +131,12 @@ function AddConversationButton() { setOpen(value); }} > - Add Conversation} /> - + ( + + )} + /> + New Conversation @@ -160,7 +164,13 @@ function AddConversationButton() { {error && (

{error}

)} - Cancel} /> + ( + + )} + /> diff --git a/apps/web/src/routes/app/layout.tsx b/apps/web/src/routes/app/layout.tsx index 4f5c657..9a46805 100644 --- a/apps/web/src/routes/app/layout.tsx +++ b/apps/web/src/routes/app/layout.tsx @@ -3,8 +3,9 @@ import { type ReactNode } from "react"; import Sidebar from "@/components/sidebar"; import Navbar, { MobileNavbar } from "@/components/navbar"; import { useShowMobileNavbar } from "./useShowMobileNavbar"; +import CallPopout from "@tensamin/call/popout"; -import { useIsMobile, cn, SidebarProvider } from "@tensamin/ui"; +import { useIsMobile, cn, SidebarProvider } from "@methanium/ui"; import { isTauri } from "@tauri-apps/api/core"; @@ -16,6 +17,7 @@ export default function Layout({ children }: { children: ReactNode }) {
+
and others Permission is hereby granted, free of charge, to any person obtaining a copy -of this software and associated documentation files (the “Software”), to deal +of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is @@ -12,10 +12,10 @@ furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. -THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN -THE SOFTWARE. \ No newline at end of file +THE SOFTWARE. diff --git a/licenses/@noble_hashes@2.2.0/LICENSE b/licenses/@codemirror_language@6.12.4/LICENSE similarity index 76% rename from licenses/@noble_hashes@2.2.0/LICENSE rename to licenses/@codemirror_language@6.12.4/LICENSE index 9297a04..9a91f48 100644 --- a/licenses/@noble_hashes@2.2.0/LICENSE +++ b/licenses/@codemirror_language@6.12.4/LICENSE @@ -1,9 +1,9 @@ -The MIT License (MIT) +MIT License -Copyright (c) 2022 Paul Miller (https://paulmillr.com) +Copyright (C) 2018-2021 by Marijn Haverbeke and others Permission is hereby granted, free of charge, to any person obtaining a copy -of this software and associated documentation files (the “Software”), to deal +of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is @@ -12,10 +12,10 @@ furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. -THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN -THE SOFTWARE. \ No newline at end of file +THE SOFTWARE. diff --git a/licenses/@twemoji_api@17.0.3/LICENSE b/licenses/@twemoji_api@17.0.3/LICENSE new file mode 100644 index 0000000..d2e3436 --- /dev/null +++ b/licenses/@twemoji_api@17.0.3/LICENSE @@ -0,0 +1,22 @@ +MIT License + +Copyright (c) 2022–present Jason Sofonia & Justine De Caires +Copyright (c) 2014–2021 Twitter + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. diff --git a/licenses/THIRD_PARTY_NOTICES.md b/licenses/THIRD_PARTY_NOTICES.md index d17e50b..f9c8103 100644 --- a/licenses/THIRD_PARTY_NOTICES.md +++ b/licenses/THIRD_PARTY_NOTICES.md @@ -31,6 +31,15 @@ Generated from pnpm-lock.yaml and installed packages in workspace node_modules f - Folder: `licenses/@base-ui_utils@0.3.1` - Source package dir: `apps/web/node_modules/@base-ui/utils` +## @codemirror/autocomplete@6.20.3 + +- License: MIT +- Repository: git+https://code.haverbeke.berlin/codemirror/autocomplete.git +- Description: Autocompletion for the CodeMirror code editor +- Included files: LICENSE +- Folder: `licenses/@codemirror_autocomplete@6.20.3` +- Source package dir: `packages/markdown/node_modules/@codemirror/autocomplete` + ## @codemirror/commands@6.10.4 - License: MIT @@ -49,6 +58,15 @@ Generated from pnpm-lock.yaml and installed packages in workspace node_modules f - Folder: `licenses/@codemirror_lang-markdown@6.5.0` - Source package dir: `packages/markdown/node_modules/@codemirror/lang-markdown` +## @codemirror/language@6.12.4 + +- License: MIT +- Repository: git+https://code.haverbeke.berlin/codemirror/language.git +- Description: Language support infrastructure for the CodeMirror code editor +- Included files: LICENSE +- Folder: `licenses/@codemirror_language@6.12.4` +- Source package dir: `packages/markdown/node_modules/@codemirror/language` + ## @codemirror/state@6.7.0 - License: MIT @@ -145,26 +163,6 @@ Generated from pnpm-lock.yaml and installed packages in workspace node_modules f - Folder: `licenses/@livekit_components-react@2.9.21` - Source package dir: `packages/call/node_modules/@livekit/components-react` -## @noble/curves@2.2.0 - -- License: MIT -- Homepage: https://paulmillr.com/noble/ -- Repository: git+https://github.com/paulmillr/noble-curves.git -- Description: Audited & minimal JS implementation of elliptic curve cryptography -- Included files: LICENSE -- Folder: `licenses/@noble_curves@2.2.0` -- Source package dir: `packages/crypto/node_modules/@noble/curves` - -## @noble/hashes@2.2.0 - -- License: MIT -- Homepage: https://paulmillr.com/noble/ -- Repository: git+https://github.com/paulmillr/noble-hashes.git -- Description: Audited & minimal 0-dependency JS implementation of SHA, RIPEMD, BLAKE, HMAC, HKDF, PBKDF & Scrypt -- Included files: LICENSE -- Folder: `licenses/@noble_hashes@2.2.0` -- Source package dir: `packages/crypto/node_modules/@noble/hashes` - ## @radix-ui/primitive@1.1.4 - License: MIT @@ -494,13 +492,23 @@ Generated from pnpm-lock.yaml and installed packages in workspace node_modules f - Folder: `licenses/@tauri-apps_plugin-notification@2.3.3` - Source package dir: `apps/tauri/node_modules/@tauri-apps/plugin-notification` -## @tensamin/ui@0.0.39 +## @tensamin/ui@0.0.41 - License: UNKNOWN - Included files: none found -- Folder: `licenses/@tensamin_ui@0.0.39` +- Folder: `licenses/@tensamin_ui@0.0.41` - Source package dir: `apps/tauri/node_modules/@tensamin/ui` +## @twemoji/api@17.0.3 + +- License: MIT AND CC-BY-4.0 +- Homepage: https://github.com/jdecked/twemoji +- Repository: git://github.com/jdecked/twemoji.git +- Description: A Unicode standard based way to implement emoji across all platforms. +- Included files: LICENSE +- Folder: `licenses/@twemoji_api@17.0.3` +- Source package dir: `packages/markdown/node_modules/@twemoji/api` + ## @types/node@25.9.4 - License: MIT @@ -599,15 +607,6 @@ Generated from pnpm-lock.yaml and installed packages in workspace node_modules f - Folder: `licenses/cmdk@1.1.1` - Source package dir: `apps/web/node_modules/cmdk` -## comlink@4.4.2 - -- License: Apache-2.0 -- Repository: https://github.com/GoogleChromeLabs/comlink.git -- Description: Comlink makes WebWorkers enjoyable -- Included files: LICENSE -- Folder: `licenses/comlink@4.4.2` -- Source package dir: `packages/crypto/node_modules/comlink` - ## cookie-es@3.1.1 - License: MIT @@ -823,6 +822,15 @@ Generated from pnpm-lock.yaml and installed packages in workspace node_modules f - Folder: `licenses/embla-carousel-reactive-utils@8.6.0` - Source package dir: `apps/web/node_modules/embla-carousel-reactive-utils` +## emojibase-data@17.0.0 + +- License: MIT +- Repository: git@github.com:milesj/emojibase.git +- Description: Evergreen emoji datasets. +- Included files: LICENSE +- Folder: `licenses/emojibase-data@17.0.0` +- Source package dir: `packages/markdown/node_modules/emojibase-data` + ## es-toolkit@1.49.0 - License: MIT @@ -958,12 +966,21 @@ Generated from pnpm-lock.yaml and installed packages in workspace node_modules f - Folder: `licenses/lucide-react@1.23.0` - Source package dir: `apps/web/node_modules/lucide-react` -## mtp@0.1.0 +## motion@12.42.2 + +- License: MIT +- Repository: https://github.com/motiondivision/motion +- Description: An animation library for JavaScript and React. +- Included files: LICENSE.md +- Folder: `licenses/motion@12.42.2` +- Source package dir: `packages/chat/node_modules/motion` + +## mtp@0.2.0 - License: UNKNOWN - Description: MTP TypeScript SDK - Included files: none found -- Folder: `licenses/mtp@0.1.0` +- Folder: `licenses/mtp@0.2.0` - Source package dir: `packages/mtp/node_modules/mtp` ## next-themes@0.4.6 diff --git a/licenses/comlink@4.4.2/LICENSE b/licenses/comlink@4.4.2/LICENSE deleted file mode 100644 index 12b597d..0000000 --- a/licenses/comlink@4.4.2/LICENSE +++ /dev/null @@ -1,202 +0,0 @@ - - Apache License - Version 2.0, January 2004 - http://www.apache.org/licenses/ - - TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION - - 1. Definitions. - - "License" shall mean the terms and conditions for use, reproduction, - and distribution as defined by Sections 1 through 9 of this document. - - "Licensor" shall mean the copyright owner or entity authorized by - the copyright owner that is granting the License. - - "Legal Entity" shall mean the union of the acting entity and all - other entities that control, are controlled by, or are under common - control with that entity. For the purposes of this definition, - "control" means (i) the power, direct or indirect, to cause the - direction or management of such entity, whether by contract or - otherwise, or (ii) ownership of fifty percent (50%) or more of the - outstanding shares, or (iii) beneficial ownership of such entity. - - "You" (or "Your") shall mean an individual or Legal Entity - exercising permissions granted by this License. - - "Source" form shall mean the preferred form for making modifications, - including but not limited to software source code, documentation - source, and configuration files. - - "Object" form shall mean any form resulting from mechanical - transformation or translation of a Source form, including but - not limited to compiled object code, generated documentation, - and conversions to other media types. - - "Work" shall mean the work of authorship, whether in Source or - Object form, made available under the License, as indicated by a - copyright notice that is included in or attached to the work - (an example is provided in the Appendix below). - - "Derivative Works" shall mean any work, whether in Source or Object - form, that is based on (or derived from) the Work and for which the - editorial revisions, annotations, elaborations, or other modifications - represent, as a whole, an original work of authorship. For the purposes - of this License, Derivative Works shall not include works that remain - separable from, or merely link (or bind by name) to the interfaces of, - the Work and Derivative Works thereof. - - "Contribution" shall mean any work of authorship, including - the original version of the Work and any modifications or additions - to that Work or Derivative Works thereof, that is intentionally - submitted to Licensor for inclusion in the Work by the copyright owner - or by an individual or Legal Entity authorized to submit on behalf of - the copyright owner. For the purposes of this definition, "submitted" - means any form of electronic, verbal, or written communication sent - to the Licensor or its representatives, including but not limited to - communication on electronic mailing lists, source code control systems, - and issue tracking systems that are managed by, or on behalf of, the - Licensor for the purpose of discussing and improving the Work, but - excluding communication that is conspicuously marked or otherwise - designated in writing by the copyright owner as "Not a Contribution." - - "Contributor" shall mean Licensor and any individual or Legal Entity - on behalf of whom a Contribution has been received by Licensor and - subsequently incorporated within the Work. - - 2. Grant of Copyright License. Subject to the terms and conditions of - this License, each Contributor hereby grants to You a perpetual, - worldwide, non-exclusive, no-charge, royalty-free, irrevocable - copyright license to reproduce, prepare Derivative Works of, - publicly display, publicly perform, sublicense, and distribute the - Work and such Derivative Works in Source or Object form. - - 3. Grant of Patent License. Subject to the terms and conditions of - this License, each Contributor hereby grants to You a perpetual, - worldwide, non-exclusive, no-charge, royalty-free, irrevocable - (except as stated in this section) patent license to make, have made, - use, offer to sell, sell, import, and otherwise transfer the Work, - where such license applies only to those patent claims licensable - by such Contributor that are necessarily infringed by their - Contribution(s) alone or by combination of their Contribution(s) - with the Work to which such Contribution(s) was submitted. If You - institute patent litigation against any entity (including a - cross-claim or counterclaim in a lawsuit) alleging that the Work - or a Contribution incorporated within the Work constitutes direct - or contributory patent infringement, then any patent licenses - granted to You under this License for that Work shall terminate - as of the date such litigation is filed. - - 4. Redistribution. You may reproduce and distribute copies of the - Work or Derivative Works thereof in any medium, with or without - modifications, and in Source or Object form, provided that You - meet the following conditions: - - (a) You must give any other recipients of the Work or - Derivative Works a copy of this License; and - - (b) You must cause any modified files to carry prominent notices - stating that You changed the files; and - - (c) You must retain, in the Source form of any Derivative Works - that You distribute, all copyright, patent, trademark, and - attribution notices from the Source form of the Work, - excluding those notices that do not pertain to any part of - the Derivative Works; and - - (d) If the Work includes a "NOTICE" text file as part of its - distribution, then any Derivative Works that You distribute must - include a readable copy of the attribution notices contained - within such NOTICE file, excluding those notices that do not - pertain to any part of the Derivative Works, in at least one - of the following places: within a NOTICE text file distributed - as part of the Derivative Works; within the Source form or - documentation, if provided along with the Derivative Works; or, - within a display generated by the Derivative Works, if and - wherever such third-party notices normally appear. The contents - of the NOTICE file are for informational purposes only and - do not modify the License. You may add Your own attribution - notices within Derivative Works that You distribute, alongside - or as an addendum to the NOTICE text from the Work, provided - that such additional attribution notices cannot be construed - as modifying the License. - - You may add Your own copyright statement to Your modifications and - may provide additional or different license terms and conditions - for use, reproduction, or distribution of Your modifications, or - for any such Derivative Works as a whole, provided Your use, - reproduction, and distribution of the Work otherwise complies with - the conditions stated in this License. - - 5. Submission of Contributions. Unless You explicitly state otherwise, - any Contribution intentionally submitted for inclusion in the Work - by You to the Licensor shall be under the terms and conditions of - this License, without any additional terms or conditions. - Notwithstanding the above, nothing herein shall supersede or modify - the terms of any separate license agreement you may have executed - with Licensor regarding such Contributions. - - 6. Trademarks. This License does not grant permission to use the trade - names, trademarks, service marks, or product names of the Licensor, - except as required for reasonable and customary use in describing the - origin of the Work and reproducing the content of the NOTICE file. - - 7. Disclaimer of Warranty. Unless required by applicable law or - agreed to in writing, Licensor provides the Work (and each - Contributor provides its Contributions) on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or - implied, including, without limitation, any warranties or conditions - of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A - PARTICULAR PURPOSE. You are solely responsible for determining the - appropriateness of using or redistributing the Work and assume any - risks associated with Your exercise of permissions under this License. - - 8. Limitation of Liability. In no event and under no legal theory, - whether in tort (including negligence), contract, or otherwise, - unless required by applicable law (such as deliberate and grossly - negligent acts) or agreed to in writing, shall any Contributor be - liable to You for damages, including any direct, indirect, special, - incidental, or consequential damages of any character arising as a - result of this License or out of the use or inability to use the - Work (including but not limited to damages for loss of goodwill, - work stoppage, computer failure or malfunction, or any and all - other commercial damages or losses), even if such Contributor - has been advised of the possibility of such damages. - - 9. Accepting Warranty or Additional Liability. While redistributing - the Work or Derivative Works thereof, You may choose to offer, - and charge a fee for, acceptance of support, warranty, indemnity, - or other liability obligations and/or rights consistent with this - License. However, in accepting such obligations, You may act only - on Your own behalf and on Your sole responsibility, not on behalf - of any other Contributor, and only if You agree to indemnify, - defend, and hold each Contributor harmless for any liability - incurred by, or claims asserted against, such Contributor by reason - of your accepting any such warranty or additional liability. - - END OF TERMS AND CONDITIONS - - APPENDIX: How to apply the Apache License to your work. - - To apply the Apache License to your work, attach the following - boilerplate notice, with the fields enclosed by brackets "[]" - replaced with your own identifying information. (Don't include - the brackets!) The text should be enclosed in the appropriate - comment syntax for the file format. We also recommend that a - file or class name and description of purpose be included on the - same "printed page" as the copyright notice for easier - identification within third-party archives. - - Copyright 2017 Google Inc. - - Licensed under the Apache License, Version 2.0 (the "License"); - you may not use this file except in compliance with the License. - You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - - Unless required by applicable law or agreed to in writing, software - distributed under the License is distributed on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - See the License for the specific language governing permissions and - limitations under the License. \ No newline at end of file diff --git a/licenses/emojibase-data@17.0.0/LICENSE b/licenses/emojibase-data@17.0.0/LICENSE new file mode 100644 index 0000000..3e21d0b --- /dev/null +++ b/licenses/emojibase-data@17.0.0/LICENSE @@ -0,0 +1,21 @@ +MIT License + +Copyright (c) 2017-2019 Miles Johnson + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. diff --git a/licenses/motion@12.42.2/LICENSE.md b/licenses/motion@12.42.2/LICENSE.md new file mode 100644 index 0000000..8111044 --- /dev/null +++ b/licenses/motion@12.42.2/LICENSE.md @@ -0,0 +1,21 @@ +The MIT License (MIT) + +Copyright (c) 2024 [Motion](https://motion.dev) B.V. + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. diff --git a/licenses/sbom.cyclonedx.json b/licenses/sbom.cyclonedx.json index e5f7673..1c35ba5 100644 --- a/licenses/sbom.cyclonedx.json +++ b/licenses/sbom.cyclonedx.json @@ -3,7 +3,7 @@ "specVersion": "1.5", "version": 1, "metadata": { - "timestamp": "2026-07-03T19:50:00.640Z", + "timestamp": "2026-07-24T10:43:11.914Z", "tools": [ { "vendor": "OpenAI", @@ -117,6 +117,37 @@ } ] }, + { + "type": "library", + "bomRef": "pkg:npm/%40codemirror/autocomplete@6.20.3", + "name": "@codemirror/autocomplete", + "version": "6.20.3", + "purl": "pkg:npm/%40codemirror/autocomplete@6.20.3", + "description": "Autocompletion for the CodeMirror code editor", + "licenses": [ + { + "license": { + "id": "MIT" + } + } + ], + "externalReferences": [ + { + "type": "vcs", + "url": "git+https://code.haverbeke.berlin/codemirror/autocomplete.git" + } + ], + "properties": [ + { + "name": "local:licenseFolder", + "value": "licenses/@codemirror_autocomplete@6.20.3" + }, + { + "name": "local:sourcePackageDir", + "value": "packages/markdown/node_modules/@codemirror/autocomplete" + } + ] + }, { "type": "library", "bomRef": "pkg:npm/%40codemirror/commands@6.10.4", @@ -179,6 +210,37 @@ } ] }, + { + "type": "library", + "bomRef": "pkg:npm/%40codemirror/language@6.12.4", + "name": "@codemirror/language", + "version": "6.12.4", + "purl": "pkg:npm/%40codemirror/language@6.12.4", + "description": "Language support infrastructure for the CodeMirror code editor", + "licenses": [ + { + "license": { + "id": "MIT" + } + } + ], + "externalReferences": [ + { + "type": "vcs", + "url": "git+https://code.haverbeke.berlin/codemirror/language.git" + } + ], + "properties": [ + { + "name": "local:licenseFolder", + "value": "licenses/@codemirror_language@6.12.4" + }, + { + "name": "local:sourcePackageDir", + "value": "packages/markdown/node_modules/@codemirror/language" + } + ] + }, { "type": "library", "bomRef": "pkg:npm/%40codemirror/state@6.7.0", @@ -516,76 +578,6 @@ } ] }, - { - "type": "library", - "bomRef": "pkg:npm/%40noble/curves@2.2.0", - "name": "@noble/curves", - "version": "2.2.0", - "purl": "pkg:npm/%40noble/curves@2.2.0", - "description": "Audited & minimal JS implementation of elliptic curve cryptography", - "licenses": [ - { - "license": { - "id": "MIT" - } - } - ], - "externalReferences": [ - { - "type": "website", - "url": "https://paulmillr.com/noble/" - }, - { - "type": "vcs", - "url": "git+https://github.com/paulmillr/noble-curves.git" - } - ], - "properties": [ - { - "name": "local:licenseFolder", - "value": "licenses/@noble_curves@2.2.0" - }, - { - "name": "local:sourcePackageDir", - "value": "packages/crypto/node_modules/@noble/curves" - } - ] - }, - { - "type": "library", - "bomRef": "pkg:npm/%40noble/hashes@2.2.0", - "name": "@noble/hashes", - "version": "2.2.0", - "purl": "pkg:npm/%40noble/hashes@2.2.0", - "description": "Audited & minimal 0-dependency JS implementation of SHA, RIPEMD, BLAKE, HMAC, HKDF, PBKDF & Scrypt", - "licenses": [ - { - "license": { - "id": "MIT" - } - } - ], - "externalReferences": [ - { - "type": "website", - "url": "https://paulmillr.com/noble/" - }, - { - "type": "vcs", - "url": "git+https://github.com/paulmillr/noble-hashes.git" - } - ], - "properties": [ - { - "name": "local:licenseFolder", - "value": "licenses/@noble_hashes@2.2.0" - }, - { - "name": "local:sourcePackageDir", - "value": "packages/crypto/node_modules/@noble/hashes" - } - ] - }, { "type": "library", "bomRef": "pkg:npm/%40radix-ui/primitive@1.1.4", @@ -1780,15 +1772,15 @@ }, { "type": "library", - "bomRef": "pkg:npm/%40tensamin/ui@0.0.39", + "bomRef": "pkg:npm/%40tensamin/ui@0.0.41", "name": "@tensamin/ui", - "version": "0.0.39", - "purl": "pkg:npm/%40tensamin/ui@0.0.39", + "version": "0.0.41", + "purl": "pkg:npm/%40tensamin/ui@0.0.41", "externalReferences": [], "properties": [ { "name": "local:licenseFolder", - "value": "licenses/@tensamin_ui@0.0.39" + "value": "licenses/@tensamin_ui@0.0.41" }, { "name": "local:sourcePackageDir", @@ -1796,6 +1788,41 @@ } ] }, + { + "type": "library", + "bomRef": "pkg:npm/%40twemoji/api@17.0.3", + "name": "@twemoji/api", + "version": "17.0.3", + "purl": "pkg:npm/%40twemoji/api@17.0.3", + "description": "A Unicode standard based way to implement emoji across all platforms.", + "licenses": [ + { + "license": { + "name": "MIT AND CC-BY-4.0" + } + } + ], + "externalReferences": [ + { + "type": "website", + "url": "https://github.com/jdecked/twemoji" + }, + { + "type": "vcs", + "url": "git://github.com/jdecked/twemoji.git" + } + ], + "properties": [ + { + "name": "local:licenseFolder", + "value": "licenses/@twemoji_api@17.0.3" + }, + { + "name": "local:sourcePackageDir", + "value": "packages/markdown/node_modules/@twemoji/api" + } + ] + }, { "type": "library", "bomRef": "pkg:npm/%40types/node@25.9.4", @@ -2141,37 +2168,6 @@ } ] }, - { - "type": "library", - "bomRef": "pkg:npm/comlink@4.4.2", - "name": "comlink", - "version": "4.4.2", - "purl": "pkg:npm/comlink@4.4.2", - "description": "Comlink makes WebWorkers enjoyable", - "licenses": [ - { - "license": { - "id": "Apache-2.0" - } - } - ], - "externalReferences": [ - { - "type": "vcs", - "url": "https://github.com/GoogleChromeLabs/comlink.git" - } - ], - "properties": [ - { - "name": "local:licenseFolder", - "value": "licenses/comlink@4.4.2" - }, - { - "name": "local:sourcePackageDir", - "value": "packages/crypto/node_modules/comlink" - } - ] - }, { "type": "library", "bomRef": "pkg:npm/cookie-es@3.1.1", @@ -2925,6 +2921,37 @@ } ] }, + { + "type": "library", + "bomRef": "pkg:npm/emojibase-data@17.0.0", + "name": "emojibase-data", + "version": "17.0.0", + "purl": "pkg:npm/emojibase-data@17.0.0", + "description": "Evergreen emoji datasets.", + "licenses": [ + { + "license": { + "id": "MIT" + } + } + ], + "externalReferences": [ + { + "type": "vcs", + "url": "git@github.com:milesj/emojibase.git" + } + ], + "properties": [ + { + "name": "local:licenseFolder", + "value": "licenses/emojibase-data@17.0.0" + }, + { + "name": "local:sourcePackageDir", + "value": "packages/markdown/node_modules/emojibase-data" + } + ] + }, { "type": "library", "bomRef": "pkg:npm/es-toolkit@1.49.0", @@ -3397,16 +3424,47 @@ }, { "type": "library", - "bomRef": "pkg:npm/mtp@0.1.0", + "bomRef": "pkg:npm/motion@12.42.2", + "name": "motion", + "version": "12.42.2", + "purl": "pkg:npm/motion@12.42.2", + "description": "An animation library for JavaScript and React.", + "licenses": [ + { + "license": { + "id": "MIT" + } + } + ], + "externalReferences": [ + { + "type": "vcs", + "url": "https://github.com/motiondivision/motion" + } + ], + "properties": [ + { + "name": "local:licenseFolder", + "value": "licenses/motion@12.42.2" + }, + { + "name": "local:sourcePackageDir", + "value": "packages/chat/node_modules/motion" + } + ] + }, + { + "type": "library", + "bomRef": "pkg:npm/mtp@0.2.0", "name": "mtp", - "version": "0.1.0", - "purl": "pkg:npm/mtp@0.1.0", + "version": "0.2.0", + "purl": "pkg:npm/mtp@0.2.0", "description": "MTP TypeScript SDK", "externalReferences": [], "properties": [ { "name": "local:licenseFolder", - "value": "licenses/mtp@0.1.0" + "value": "licenses/mtp@0.2.0" }, { "name": "local:sourcePackageDir", @@ -4851,4 +4909,4 @@ ] } ] -} +} \ No newline at end of file diff --git a/licenses/third-party-credits.json b/licenses/third-party-credits.json index 81d1ba8..180e5e4 100644 --- a/licenses/third-party-credits.json +++ b/licenses/third-party-credits.json @@ -1,6 +1,6 @@ { - "generatedAt": "2026-07-03T19:50:00.637Z", - "packageCount": 143, + "generatedAt": "2026-07-24T10:43:11.913Z", + "packageCount": 145, "packages": [ { "name": "@babel/runtime", @@ -41,6 +41,19 @@ "licenseFolder": "licenses/@base-ui_utils@0.3.1", "sourcePackageDir": "apps/web/node_modules/@base-ui/utils" }, + { + "name": "@codemirror/autocomplete", + "version": "6.20.3", + "license": "MIT", + "homepage": null, + "repository": "git+https://code.haverbeke.berlin/codemirror/autocomplete.git", + "description": "Autocompletion for the CodeMirror code editor", + "files": [ + "LICENSE" + ], + "licenseFolder": "licenses/@codemirror_autocomplete@6.20.3", + "sourcePackageDir": "packages/markdown/node_modules/@codemirror/autocomplete" + }, { "name": "@codemirror/commands", "version": "6.10.4", @@ -67,6 +80,19 @@ "licenseFolder": "licenses/@codemirror_lang-markdown@6.5.0", "sourcePackageDir": "packages/markdown/node_modules/@codemirror/lang-markdown" }, + { + "name": "@codemirror/language", + "version": "6.12.4", + "license": "MIT", + "homepage": null, + "repository": "git+https://code.haverbeke.berlin/codemirror/language.git", + "description": "Language support infrastructure for the CodeMirror code editor", + "files": [ + "LICENSE" + ], + "licenseFolder": "licenses/@codemirror_language@6.12.4", + "sourcePackageDir": "packages/markdown/node_modules/@codemirror/language" + }, { "name": "@codemirror/state", "version": "6.7.0", @@ -197,32 +223,6 @@ "licenseFolder": "licenses/@livekit_components-react@2.9.21", "sourcePackageDir": "packages/call/node_modules/@livekit/components-react" }, - { - "name": "@noble/curves", - "version": "2.2.0", - "license": "MIT", - "homepage": "https://paulmillr.com/noble/", - "repository": "git+https://github.com/paulmillr/noble-curves.git", - "description": "Audited & minimal JS implementation of elliptic curve cryptography", - "files": [ - "LICENSE" - ], - "licenseFolder": "licenses/@noble_curves@2.2.0", - "sourcePackageDir": "packages/crypto/node_modules/@noble/curves" - }, - { - "name": "@noble/hashes", - "version": "2.2.0", - "license": "MIT", - "homepage": "https://paulmillr.com/noble/", - "repository": "git+https://github.com/paulmillr/noble-hashes.git", - "description": "Audited & minimal 0-dependency JS implementation of SHA, RIPEMD, BLAKE, HMAC, HKDF, PBKDF & Scrypt", - "files": [ - "LICENSE" - ], - "licenseFolder": "licenses/@noble_hashes@2.2.0", - "sourcePackageDir": "packages/crypto/node_modules/@noble/hashes" - }, { "name": "@radix-ui/primitive", "version": "1.1.4", @@ -368,7 +368,7 @@ }, { "name": "@radix-ui/react-slot", - "version": "1.2.1", + "version": "1.3.0", "license": "MIT", "homepage": "https://radix-ui.com/primitives", "repository": "git+https://github.com/radix-ui/primitives.git", @@ -682,15 +682,28 @@ }, { "name": "@tensamin/ui", - "version": "0.0.39", + "version": "0.0.41", "license": "UNKNOWN", "homepage": null, "repository": null, "description": null, "files": [], - "licenseFolder": "licenses/@tensamin_ui@0.0.39", + "licenseFolder": "licenses/@tensamin_ui@0.0.41", "sourcePackageDir": "apps/tauri/node_modules/@tensamin/ui" }, + { + "name": "@twemoji/api", + "version": "17.0.3", + "license": "MIT AND CC-BY-4.0", + "homepage": "https://github.com/jdecked/twemoji", + "repository": "git://github.com/jdecked/twemoji.git", + "description": "A Unicode standard based way to implement emoji across all platforms.", + "files": [ + "LICENSE" + ], + "licenseFolder": "licenses/@twemoji_api@17.0.3", + "sourcePackageDir": "packages/markdown/node_modules/@twemoji/api" + }, { "name": "@types/node", "version": "25.9.4", @@ -821,19 +834,6 @@ "licenseFolder": "licenses/cmdk@1.1.1", "sourcePackageDir": "apps/web/node_modules/cmdk" }, - { - "name": "comlink", - "version": "4.4.2", - "license": "Apache-2.0", - "homepage": null, - "repository": "https://github.com/GoogleChromeLabs/comlink.git", - "description": "Comlink makes WebWorkers enjoyable", - "files": [ - "LICENSE" - ], - "licenseFolder": "licenses/comlink@4.4.2", - "sourcePackageDir": "packages/crypto/node_modules/comlink" - }, { "name": "cookie-es", "version": "3.1.1", @@ -1018,7 +1018,7 @@ }, { "name": "deepfilternet3-noise-filter", - "version": "1.3.0", + "version": "1.2.1", "license": "(Apache-2.0 OR MIT)", "homepage": "https://github.com/mezonai/mezon-noise-suppression#readme", "repository": "git+https://github.com/mezonai/mezon-noise-suppression.git", @@ -1115,6 +1115,19 @@ "licenseFolder": "licenses/embla-carousel-reactive-utils@8.6.0", "sourcePackageDir": "apps/web/node_modules/embla-carousel-reactive-utils" }, + { + "name": "emojibase-data", + "version": "17.0.0", + "license": "MIT", + "homepage": null, + "repository": "git@github.com:milesj/emojibase.git", + "description": "Evergreen emoji datasets.", + "files": [ + "LICENSE" + ], + "licenseFolder": "licenses/emojibase-data@17.0.0", + "sourcePackageDir": "packages/markdown/node_modules/emojibase-data" + }, { "name": "es-toolkit", "version": "1.49.0", @@ -1293,15 +1306,28 @@ "licenseFolder": "licenses/lucide-react@1.23.0", "sourcePackageDir": "apps/web/node_modules/lucide-react" }, + { + "name": "motion", + "version": "12.42.2", + "license": "MIT", + "homepage": null, + "repository": "https://github.com/motiondivision/motion", + "description": "An animation library for JavaScript and React.", + "files": [ + "LICENSE.md" + ], + "licenseFolder": "licenses/motion@12.42.2", + "sourcePackageDir": "packages/chat/node_modules/motion" + }, { "name": "mtp", - "version": "0.1.0", + "version": "0.2.0", "license": "UNKNOWN", "homepage": null, "repository": null, "description": "MTP TypeScript SDK", "files": [], - "licenseFolder": "licenses/mtp@0.1.0", + "licenseFolder": "licenses/mtp@0.2.0", "sourcePackageDir": "packages/mtp/node_modules/mtp" }, { @@ -1847,4 +1873,4 @@ "sourcePackageDir": "packages/call/node_modules/zustand" } ] -} +} \ No newline at end of file diff --git a/mtp-type-maps b/mtp-type-maps new file mode 160000 index 0000000..11a1d79 --- /dev/null +++ b/mtp-type-maps @@ -0,0 +1 @@ +Subproject commit 11a1d79409857b734e948dd8c3e28e6ba721d15f diff --git a/package.json b/package.json index 3765f87..c3da492 100644 --- a/package.json +++ b/package.json @@ -10,15 +10,15 @@ "type": "module", "scripts": { "format": "pnpm exec prettier --write .", - "lint": "node scripts/lint-packages.ts", + "lint": "node utils/scripts/lint-packages.ts", "check": "fallow && pnpm run lint", - "copy-licenses": "node scripts/copy-licenses.ts", - "copy-releases": "node scripts/copy-releases.ts", + "copy-licenses": "node utils/scripts/copy-licenses.ts", + "copy-releases": "node utils/scripts/copy-releases.ts", "pre-build": "pnpm run lint && pnpm run build:packages", "build:apps": "pnpm run copy-licenses && pnpm run pre-build && pnpm run build:mobile && pnpm run build:desktop && pnpm run copy-releases", - "build:packages": "node scripts/build-packages.ts", - "update:packages": "node scripts/update-packages.ts", - "dev:web": "cd apps/web && pnpm dev", + "build:packages": "node utils/scripts/build-packages.ts", + "update:packages": "node utils/scripts/update-packages.ts", + "dev": "cd apps/web && pnpm dev", "build:web": "cd apps/web && pnpm run build", "preview:web": "cd apps/web && pnpm run preview", "dev:mobile": "cd apps/tauri && pnpm dev:mobile", @@ -26,7 +26,7 @@ "start-adb:mobile": "cd apps/tauri && pnpm run start-adb:mobile", "dev:desktop": "cd apps/electron && pnpm run dev", "build:desktop": "cd apps/electron && pnpm run package", - "delete:mobile": "cd apps/tauri && nix develop ../..#tauri --command adb uninstall net.tensamin.client" + "delete:mobile": "cd apps/tauri && nix develop ../..#tauri --command adb uninstall net.tensamin.client.dev" }, "devDependencies": { "@eslint/js": "^10.0.1", @@ -46,7 +46,7 @@ "yaml": "^2.8.2" }, "dependencies": { - "@tensamin/ui": "*", + "@methanium/ui": "https://git.methanium.net/methanium/ui/releases/download/0.0.2/methanium-ui.tgz", "mtp": "*", "sonner": "^2.0.7" } diff --git a/packages/cache/src/index.ts b/packages/cache/src/index.ts index cd78102..43c5018 100644 --- a/packages/cache/src/index.ts +++ b/packages/cache/src/index.ts @@ -175,12 +175,7 @@ export function createCache(accountId: string, options: CacheOptions = {}) { const userId = Number(key); return retained.has(userId) ? [] - : [ - deleteDatabaseEntry( - "cache", - storedKey("conversations", key), - ), - ]; + : [deleteDatabaseEntry("cache", storedKey("conversations", key))]; }), ); }, @@ -210,12 +205,7 @@ export function createCache(accountId: string, options: CacheOptions = {}) { const userId = Number(key); return retained.has(userId) ? [] - : [ - deleteDatabaseEntry( - "cache", - storedKey("conversations", key), - ), - ]; + : [deleteDatabaseEntry("cache", storedKey("conversations", key))]; }), ); }, @@ -241,12 +231,7 @@ export function createCache(accountId: string, options: CacheOptions = {}) { storedEntries.flatMap(([key]) => retained.has(Number(key)) ? [] - : [ - deleteDatabaseEntry( - "cache", - storedKey("conversations", key), - ), - ], + : [deleteDatabaseEntry("cache", storedKey("conversations", key))], ), ); }, diff --git a/packages/cache/src/sync.tsx b/packages/cache/src/sync.tsx index b1c7a84..f90e80d 100644 --- a/packages/cache/src/sync.tsx +++ b/packages/cache/src/sync.tsx @@ -18,7 +18,6 @@ export default function CacheSync() { const { load } = useStorage(); const [accountId, setAccountId] = useState(0); const queueRef = useRef(Promise.resolve()); - const reactionPartnersRef = useRef(new Map()); useEffect(() => { void load("user_id").then(setAccountId); @@ -143,6 +142,7 @@ export default function CacheSync() { MessageState: "sent", SenderId: accountId, SendTime: Number(request.SendTime), + ReplyId: request.ReplyId ? Number(request.ReplyId) : undefined, }); return; } @@ -195,23 +195,6 @@ export default function CacheSync() { ); return; } - - if (type === "MessageGet") { - const message = result as unknown as CachedMessage; - const mappedPartner = reactionPartnersRef.current.get(message.SendTime); - reactionPartnersRef.current.delete(message.SendTime); - if (mappedPartner) { - await insertMessage(mappedPartner, message); - return; - } - const windows = await secureCache().conversations.list(); - const window = windows.find((candidate) => - candidate.Messages.some( - (cached) => cached.SendTime === message.SendTime, - ), - ); - if (window) await insertMessage(window.UserId, message); - } }, [accountId, insertMessage, removeMessage, replaceMessage, secureCache], ); @@ -259,13 +242,28 @@ export default function CacheSync() { return; } if (message.type === "MessageReactionLive") { - reactionPartnersRef.current.set( - Number(data.SendTime), - Number(data.ChatPartnerId), + const partnerId = Number(data.ChatPartnerId); + const sendTime = Number(data.SendTime); + const senderId = Number(data.SenderId); + const reaction = String(data.Reaction); + const cache = secureCache(); + const window = await cache.conversations.get(partnerId); + const target = window?.Messages.find( + (candidate) => candidate.SendTime === sendTime, ); + if (!window || !target) return; + + const reactions = (target.Reactions ?? []).filter( + (candidate) => + candidate.SenderId !== senderId || candidate.Reaction !== reaction, + ); + if (data.Accepted === true) { + reactions.push({ SenderId: senderId, Reaction: reaction }); + } + await replaceMessage(partnerId, sendTime, { Reactions: reactions }); } }, - [accountId, insertMessage, removeMessage, replaceMessage], + [accountId, insertMessage, removeMessage, replaceMessage, secureCache], ); useEffect(() => { diff --git a/packages/call/package.json b/packages/call/package.json index 576caa1..4fafe09 100644 --- a/packages/call/package.json +++ b/packages/call/package.json @@ -19,12 +19,11 @@ "dependencies": { "@livekit/components-react": "^2.9.20", "@tanstack/react-router": "^1.169.1", - "@tauri-apps/api": "^2", "@tensamin/crypto": "workspace:*", "@tensamin/shared": "workspace:*", "@tensamin/storage": "workspace:*", "@tensamin/mtp": "workspace:*", - "@tensamin/ui": "*", + "@methanium/ui": "*", "@tensamin/user": "workspace:*", "deepfilternet3-noise-filter": "1.2.1", "livekit-client": "^2.18.8", diff --git a/packages/call/src/components/actions.tsx b/packages/call/src/components/actions.tsx index a0d3a77..7856d7e 100644 --- a/packages/call/src/components/actions.tsx +++ b/packages/call/src/components/actions.tsx @@ -5,11 +5,13 @@ import { Tooltip, TooltipContent, TooltipTrigger, -} from "@tensamin/ui"; + useIsMobile, + cn, +} from "@methanium/ui"; import { useEffect, useState } from "react"; import MuteButton from "./buttons/mute"; import DeafButton from "./buttons/deaf"; -import ScreenshareButton from "./buttons/screenshare"; +import MediaShareButton from "./buttons/mediaShare"; import LeaveButton from "./buttons/leave"; import { setCallIsPopout, @@ -31,7 +33,7 @@ import { import { useStorage } from "@tensamin/storage/context"; export default function Actions() { - const sharedClasses = "w-14 h-10"; + const sharedClasses = "w-14! h-10!"; const sharedIconSize = 15; const view = useCall((state) => state.view); const focusedParticipantId = useCall((state) => state.focusedParticipantId); @@ -77,34 +79,45 @@ export default function Actions() { (state) => state.usersInFocusedViewHidden, ); + const isMobile = useIsMobile(); + return ( -
-
- {view === "focused" && ( - - - setUsersInFocusedViewHidden(!usersInFocusedViewHidden) - } - variant="link" - className="w-11 h-11 p-0! ml-3 text-foreground" - > - {usersInFocusedViewHidden ? ( - - ) : ( - - )} - - } - /> - - Hide users - - - )} -
+
+ {!isMobile && ( +
+ {view === "focused" && ( + + ( + + )} + /> + + Hide users + + + )} +
+ )} - ( - } + )} /> Stop watching @@ -161,50 +178,58 @@ export default function Actions() { )} -
- - setCallIsPopout(!callIsPopout)} - variant="link" - className="w-11 h-11 p-0! text-foreground" - > - {callIsPopout ? ( - - ) : ( - - )} - - } - /> - - Popout - - - - { - void toggleFullscreen(); - }} - variant="link" - className="w-11 h-11 p-0! mr-3 text-foreground" - > - {callIsFullscreen ? ( - - ) : ( - - )} - - } - /> - - Fullscreen - - -
+ {!isMobile && ( +
+ + ( + + )} + /> + + Popout + + + + ( + + )} + /> + + Fullscreen + + +
+ )}
); } diff --git a/packages/call/src/components/buttons/deaf.tsx b/packages/call/src/components/buttons/deaf.tsx index 6d0ede0..417e3f4 100644 --- a/packages/call/src/components/buttons/deaf.tsx +++ b/packages/call/src/components/buttons/deaf.tsx @@ -1,7 +1,11 @@ -import { Button } from "@tensamin/ui"; +import { Button } from "@methanium/ui"; import { toggleDeaf, useCall } from "../../store"; import { HeadphoneOff, Headphones } from "lucide-react"; -import { type CallButtonProps, iconScale, withTooltip } from "./tooltipButton"; +import { + type CallButtonProps, + iconScale, + withButtonTooltip, +} from "./tooltipButton"; export default function DeafButton({ className, @@ -25,5 +29,5 @@ export default function DeafButton({ ); - return withTooltip(button, tooltip, portalContainer); + return withButtonTooltip(button, tooltip, portalContainer); } diff --git a/packages/call/src/components/buttons/invite.tsx b/packages/call/src/components/buttons/invite.tsx index d049a5a..b478529 100644 --- a/packages/call/src/components/buttons/invite.tsx +++ b/packages/call/src/components/buttons/invite.tsx @@ -7,7 +7,7 @@ import { Tooltip, TooltipContent, TooltipTrigger, -} from "@tensamin/ui"; +} from "@methanium/ui"; import Wrapper from "@tensamin/user/wrapper"; import { Mail } from "lucide-react"; import { sendCallInvite, useCall } from "../../store"; @@ -38,13 +38,13 @@ export default function InviteButton({ render={ tooltip ? ( + render={({ ref, onClick }) => ( + - } + )} /> ) : ( ); - return withTooltip(button, tooltip, portalContainer); + return withButtonTooltip(button, tooltip, portalContainer); } diff --git a/packages/call/src/components/buttons/mediaShare.tsx b/packages/call/src/components/buttons/mediaShare.tsx new file mode 100644 index 0000000..510fbef --- /dev/null +++ b/packages/call/src/components/buttons/mediaShare.tsx @@ -0,0 +1,171 @@ +import { useEffect, useState } from "react"; +import { + Button, + Popover, + PopoverContent, + PopoverTrigger, + Tooltip, + TooltipContent, + TooltipTrigger, +} from "@methanium/ui"; +import { MonitorDot, ScreenShare } from "lucide-react"; +import { toast } from "@tensamin/shared/log"; +import { + startScreenShare, + stopCameraShare, + stopScreenShare, + useCall, +} from "../../store"; +import { getMediaShareAdapter, type MediaShareKind } from "../../mediaShare"; +import MediaShareDialog from "../mediaShareDialog"; + +export default function MediaShareButton({ + className, + iconSize, + tooltip, + defaultPortal, +}: { + className?: string; + iconSize?: number; + tooltip?: string; + defaultPortal?: boolean; +}) { + const isScreensharing = useCall((state) => state.screenShareEnabled); + const cameraEnabled = useCall((state) => state.cameraEnabled); + const screenRef = useCall((state) => state.screenRef); + const [portalContainer, setPortalContainer] = useState(); + const [dialogKind, setDialogKind] = useState(null); + const [menuOpen, setMenuOpen] = useState(false); + + useEffect(() => { + if (!defaultPortal) setPortalContainer(screenRef?.current ?? undefined); + }, [screenRef, defaultPortal]); + + async function beginScreenShare() { + try { + const capabilities = await getMediaShareAdapter().getCapabilities(); + if (capabilities.screenPicker === "sources") { + setDialogKind("screen"); + } else { + await startScreenShare({ includeAudio: true }); + } + } catch (error) { + console.error("Failed to start screen sharing", error); + toast( + "error", + error instanceof Error + ? error.message + : "Failed to start screen sharing.", + ); + } + } + + async function stop(kind: MediaShareKind) { + try { + await (kind === "screen" ? stopScreenShare() : stopCameraShare()); + } catch (error) { + console.error(`Failed to stop ${kind} sharing`, error); + toast("error", `Failed to stop ${kind} sharing.`); + } + } + + const trigger = ( + + ); + + return ( + <> + + + + tooltip ? ( + ( + } + onClick={onClick} + className={className} + > + {trigger} + + )} + /> + ) : ( + + {trigger} + + ) + } + /> + + + + {isScreensharing ? ( + + ) : null} + {cameraEnabled ? ( + + ) : null} + + + {tooltip ? ( + + {tooltip} + + ) : null} + + + {dialogKind ? ( + !open && setDialogKind(null)} + portalContainer={portalContainer} + /> + ) : null} + + ); +} diff --git a/packages/call/src/components/buttons/mute.tsx b/packages/call/src/components/buttons/mute.tsx index 3067a2b..025f2ca 100644 --- a/packages/call/src/components/buttons/mute.tsx +++ b/packages/call/src/components/buttons/mute.tsx @@ -1,7 +1,11 @@ -import { Button } from "@tensamin/ui"; +import { Button } from "@methanium/ui"; import { toggleMute, useCall } from "../../store"; import { Mic, MicOff } from "lucide-react"; -import { type CallButtonProps, iconScale, withTooltip } from "./tooltipButton"; +import { + type CallButtonProps, + iconScale, + withButtonTooltip, +} from "./tooltipButton"; export default function MuteButton({ className, @@ -25,5 +29,5 @@ export default function MuteButton({ ); - return withTooltip(button, tooltip, portalContainer); + return withButtonTooltip(button, tooltip, portalContainer); } diff --git a/packages/call/src/components/buttons/screenshare.tsx b/packages/call/src/components/buttons/screenshare.tsx deleted file mode 100644 index 21ba118..0000000 --- a/packages/call/src/components/buttons/screenshare.tsx +++ /dev/null @@ -1,169 +0,0 @@ -import { useEffect, useState } from "react"; -import { - Button, - Popover, - PopoverContent, - PopoverTrigger, - Tooltip, - TooltipContent, - TooltipTrigger, -} from "@tensamin/ui"; -import { MonitorDot, ScreenShare } from "lucide-react"; -import { toast } from "@tensamin/shared/log"; -import { isTauri } from "@tauri-apps/api/core"; -import { setScreenShareEnabled, useCall } from "../../store"; -import ScreenShareDialog from "../screenshareDialog"; - -export default function ScreenshareButton({ - className, - iconSize, - tooltip, - defaultPortal, -}: { - className?: string; - iconSize?: number; - tooltip?: string; - defaultPortal?: boolean; -}) { - const isScreensharing = useCall((state) => state.screenShareEnabled); - const screenRef = useCall((state) => state.screenRef); - const [portalContainer, setPortalContainer] = useState(); - const [dialogOpen, setDialogOpen] = useState(false); - const [menuOpen, setMenuOpen] = useState(false); - - useEffect(() => { - if (defaultPortal) return; - setPortalContainer(screenRef?.current ?? undefined); - }, [screenRef, defaultPortal]); - - async function startWebShare() { - try { - await setScreenShareEnabled(true, { - audio: true, - systemAudio: "include", - surfaceSwitching: "include", - video: true, - }); - } catch (error) { - console.error("Failed to start web screen share", error); - toast( - "error", - error instanceof Error - ? error.message - : "Failed to start screen sharing.", - ); - } - } - - async function stopShare() { - try { - await setScreenShareEnabled(false); - } catch (error) { - console.error("Failed to stop screen share", error); - toast("error", "Failed to stop screen sharing."); - } - } - - return ( - <> - - - - {isScreensharing ? ( - - ) : ( - - )} - - } - /> - ) : ( - - ) - } - /> - - - - - - - {tooltip && ( - - {tooltip} - - )} - - - {isTauri() && ( - - )} - - ); -} diff --git a/packages/call/src/components/buttons/tooltipButton.tsx b/packages/call/src/components/buttons/tooltipButton.tsx index 72110f8..3b3d04e 100644 --- a/packages/call/src/components/buttons/tooltipButton.tsx +++ b/packages/call/src/components/buttons/tooltipButton.tsx @@ -1,5 +1,6 @@ -import { type ReactElement } from "react"; -import { Tooltip, TooltipContent, TooltipTrigger } from "@tensamin/ui"; +import { cloneElement } from "react"; +import type { MouseEvent as ReactMouseEvent, ReactElement, Ref } from "react"; +import { Tooltip, TooltipContent, TooltipTrigger } from "@methanium/ui"; export type CallButtonProps = { className?: string; @@ -12,20 +13,31 @@ export function iconScale(iconSize?: number) { return { scale: (iconSize ? iconSize + 100 : 100) + "%" }; } -export function withTooltip( - button: ReactElement, - tooltip?: string, +export function withButtonTooltip( + trigger: ReactElement<{ + onClick?: (event: ReactMouseEvent) => void; + ref?: Ref; + }>, + content?: string, portalContainer?: HTMLElement, ) { - if (!tooltip) { - return button; - } + if (!content) return trigger; return ( - + + cloneElement(trigger, { + ref, + onClick: (event) => { + onClick?.(event); + trigger.props.onClick?.(event); + }, + }) + } + /> - {tooltip} + {content} ); diff --git a/packages/call/src/components/invitePopup.tsx b/packages/call/src/components/invitePopup.tsx index 15d9b1a..ed26a1a 100644 --- a/packages/call/src/components/invitePopup.tsx +++ b/packages/call/src/components/invitePopup.tsx @@ -5,7 +5,7 @@ import { Button, Dialog, DialogContent, -} from "@tensamin/ui"; +} from "@methanium/ui"; import Wrapper from "@tensamin/user/wrapper"; import { PhoneIncoming, X } from "lucide-react"; @@ -26,7 +26,10 @@ export default function InvitePopup({ loading={null} component={(user) => ( - + @@ -36,14 +39,14 @@ export default function InvitePopup({

{user.Display}

+ + + +
+ ); +} diff --git a/packages/call/src/components/mediaSourceCard.tsx b/packages/call/src/components/mediaSourceCard.tsx new file mode 100644 index 0000000..f740dbc --- /dev/null +++ b/packages/call/src/components/mediaSourceCard.tsx @@ -0,0 +1,77 @@ +import { cn } from "@methanium/ui"; +import { AppWindow, Camera, MonitorUp } from "lucide-react"; +import { useEffect, useRef } from "react"; +import type { MediaShareSource } from "../mediaShare"; + +function SourceIcon({ source }: { source: MediaShareSource }) { + const className = "size-8 text-muted-foreground"; + + if (source.kind === "camera") return ; + if (source.kind === "window") return ; + return ; +} + +function VideoPreview({ stream }: { stream: MediaStream }) { + const videoRef = useRef(null); + + useEffect(() => { + const video = videoRef.current; + if (!video) return; + video.srcObject = stream; + void video.play().catch(() => undefined); + + return () => { + video.srcObject = null; + }; + }, [stream]); + + return ( +