diff --git a/.forgejo/workflows/deploy-dev.yml b/.forgejo/workflows/deploy-dev.yml index 0d5be50..d456cda 100644 --- a/.forgejo/workflows/deploy-dev.yml +++ b/.forgejo/workflows/deploy-dev.yml @@ -18,9 +18,6 @@ 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 @@ -45,9 +42,6 @@ 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 @@ -134,9 +128,6 @@ 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 @@ -189,9 +180,6 @@ 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 d85ce27..42323f2 100644 --- a/.forgejo/workflows/deploy-prod.yml +++ b/.forgejo/workflows/deploy-prod.yml @@ -19,9 +19,6 @@ 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 @@ -46,9 +43,6 @@ 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 @@ -135,9 +129,6 @@ 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 @@ -186,9 +177,6 @@ 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 261f60b..c0e6a9b 100644 --- a/.gitignore +++ b/.gitignore @@ -2,5 +2,3 @@ node_modules releases .fallow .direnv -keystore.jks -keystore.properties diff --git a/.gitmodules b/.gitmodules deleted file mode 100644 index 1e9ee12..0000000 --- a/.gitmodules +++ /dev/null @@ -1,3 +0,0 @@ -[submodule "mtp-type-maps"] - path = mtp-type-maps - url = https://git.methanium.net/tensamin/mtp-type-maps diff --git a/LICENSE b/LICENSE index e952c84..d218eff 100644 --- a/LICENSE +++ b/LICENSE @@ -1,15 +1,16 @@ -Copyright (c) 2025 Methanium - +Copyright (c) [2025] [Methanium] All rights reserved. -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. +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. -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. +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. diff --git a/TODO b/TODO deleted file mode 100644 index 3ec0948..0000000 --- a/TODO +++ /dev/null @@ -1,7 +0,0 @@ -- 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 d87c1ca..f410033 100644 --- a/apps/electron/package.json +++ b/apps/electron/package.json @@ -95,11 +95,7 @@ "target": [ "dmg" ], - "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." - } + "icon": "build/icons/icon.icns" }, "publish": null } diff --git a/apps/electron/src/main/main.ts b/apps/electron/src/main/main.ts index 2a0ebfa..e3099f2 100644 --- a/apps/electron/src/main/main.ts +++ b/apps/electron/src/main/main.ts @@ -30,22 +30,12 @@ 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" && @@ -180,29 +170,6 @@ 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"); @@ -383,7 +350,6 @@ 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 9f1f37f..b09117e 100644 --- a/apps/electron/src/main/secureStorage.ts +++ b/apps/electron/src/main/secureStorage.ts @@ -34,6 +34,10 @@ 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() @@ -44,9 +48,7 @@ export function getSecureStorageStatus(): DesktopSecureStorageStatus { : null; return { - available: - safeStorage.isEncryptionAvailable() && - (process.platform !== "linux" || backend !== "basic_text"), + available: process.platform !== "linux" || backend !== "basic_text", backend, }; } diff --git a/apps/electron/src/main/tray.ts b/apps/electron/src/main/tray.ts index 5daaf1b..3937a4d 100644 --- a/apps/electron/src/main/tray.ts +++ b/apps/electron/src/main/tray.ts @@ -8,12 +8,14 @@ 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 8952e07..dc67136 100644 --- a/apps/tauri/.gitignore +++ b/apps/tauri/.gitignore @@ -24,3 +24,6 @@ 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 27be94c..7cfe0dc 100644 --- a/apps/tauri/package.json +++ b/apps/tauri/package.json @@ -4,6 +4,10 @@ "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" @@ -31,7 +35,7 @@ "@tauri-apps/plugin-log": "~2", "@tauri-apps/plugin-notification": "~2", "@tensamin/shared": "workspace:*", - "@methanium/ui": "*", + "@tensamin/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 7757466..697b23b 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,12 +1,6 @@ - - - - - - @@ -45,11 +39,6 @@ - - - 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) @@ -76,84 +30,9 @@ 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 deleted file mode 100644 index 0afa75a..0000000 --- a/apps/tauri/src-tauri/gen/android/app/src/main/java/net/tensamin/client/MediaProjectionService.kt +++ /dev/null @@ -1,348 +0,0 @@ -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 deleted file mode 100644 index c8c377c..0000000 --- a/apps/tauri/src-tauri/gen/android/app/src/main/java/net/tensamin/client/MobileMediaEvents.kt +++ /dev/null @@ -1,29 +0,0 @@ -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 2094b73..1053ea3 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 "@methanium/ui"; +import { useIsMobile } from "@tensamin/ui"; type DeeplinkContextValue = { deeplinks: readonly string[]; diff --git a/apps/tauri/src/qrCodeScanner.tsx b/apps/tauri/src/qrCodeScanner.tsx index fa3f3c7..e4c36ca 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 "@methanium/ui"; +import { Button } from "@tensamin/ui"; import { toast } from "@tensamin/shared/log"; diff --git a/apps/web/package.json b/apps/web/package.json index d95d914..dfa243a 100644 --- a/apps/web/package.json +++ b/apps/web/package.json @@ -60,10 +60,9 @@ "@tensamin/mtp": "workspace:*", "@tensamin/tauth": "workspace:*", "@tensamin/markdown": "workspace:*", - "@methanium/ui": "*", + "@tensamin/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 deleted file mode 100644 index 93a23b5..0000000 Binary files a/apps/web/public/sounds/call_jingle_1.wav and /dev/null differ diff --git a/apps/web/public/sounds/call_jingle_2.wav b/apps/web/public/sounds/call_jingle_2.wav deleted file mode 100644 index 33d9efd..0000000 Binary files a/apps/web/public/sounds/call_jingle_2.wav and /dev/null differ diff --git a/apps/web/public/sounds/call_join.wav b/apps/web/public/sounds/call_join.wav deleted file mode 100644 index b135ab7..0000000 Binary files a/apps/web/public/sounds/call_join.wav and /dev/null differ diff --git a/apps/web/public/sounds/call_leave.wav b/apps/web/public/sounds/call_leave.wav deleted file mode 100644 index eb7f53b..0000000 Binary files a/apps/web/public/sounds/call_leave.wav and /dev/null differ diff --git a/apps/web/public/sounds/message.wav b/apps/web/public/sounds/message.wav deleted file mode 100644 index 59ecedf..0000000 Binary files a/apps/web/public/sounds/message.wav and /dev/null differ diff --git a/apps/web/public/sounds/stream_end_other.wav b/apps/web/public/sounds/stream_end_other.wav deleted file mode 100644 index 4177d12..0000000 Binary files a/apps/web/public/sounds/stream_end_other.wav and /dev/null differ diff --git a/apps/web/public/sounds/stream_end_self.wav b/apps/web/public/sounds/stream_end_self.wav deleted file mode 100644 index 8a78493..0000000 Binary files a/apps/web/public/sounds/stream_end_self.wav and /dev/null differ diff --git a/apps/web/public/sounds/stream_start_other.wav b/apps/web/public/sounds/stream_start_other.wav deleted file mode 100644 index bca4724..0000000 Binary files a/apps/web/public/sounds/stream_start_other.wav and /dev/null differ diff --git a/apps/web/public/sounds/stream_start_self.wav b/apps/web/public/sounds/stream_start_self.wav deleted file mode 100644 index 5e57021..0000000 Binary files a/apps/web/public/sounds/stream_start_self.wav and /dev/null differ diff --git a/apps/web/public/sounds/stream_watch_end.wav b/apps/web/public/sounds/stream_watch_end.wav deleted file mode 100644 index e81557a..0000000 Binary files a/apps/web/public/sounds/stream_watch_end.wav and /dev/null differ diff --git a/apps/web/public/sounds/stream_watch_start.wav b/apps/web/public/sounds/stream_watch_start.wav deleted file mode 100644 index acf863d..0000000 Binary files a/apps/web/public/sounds/stream_watch_start.wav and /dev/null differ diff --git a/apps/web/src/components/modals/basic.tsx b/apps/web/src/components/modals/basic.tsx index 46eaa45..01794cb 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, - Button, -} from "@methanium/ui"; -import { Skeleton } from "@methanium/ui"; +} from "@tensamin/ui"; +import { Card, CardHeader } from "@tensamin/ui"; +import { Skeleton } from "@tensamin/ui"; import { getStatusColor } from "@tensamin/shared/data"; export function Basic({ @@ -18,50 +18,42 @@ 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 edd83a6..62405cc 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 "@methanium/ui"; +import { Avatar, AvatarFallback, AvatarImage, Button } from "@tensamin/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 }) { - )} - /> + className="w-9 h-9 aspect-square rounded-lg ml-2" + variant="outline" + > + + ) : ( <> )} - {isMobile && pathname === "/call" && callId && ( -

{displayCallId(callId)}

- )} {pathname === "/chat" && id && ( ( + render={ - )} + } /> @@ -132,7 +109,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" > @@ -147,7 +124,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" > @@ -184,11 +161,6 @@ export default function Navbar({ forMobile }: { forMobile: boolean }) { )} )} - {isMobile && pathname === "/call" && callId && ( - - )} @@ -203,7 +175,7 @@ export function MobileNavbar() {
@@ -214,7 +186,7 @@ export function MobileNavbar() { navigate({ to: "/" }); setOpenMobile(false); }} - className="text-foreground w-12 h-12 aspect-square rounded-xl flex flex-col gap-1 border-0! bg-none! bg-transparent!" + className="text-foreground w-12 h-12 aspect-square rounded-xl flex flex-col gap-1" variant="link" > @@ -225,7 +197,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 border-0! bg-none! bg-transparent!" + className="text-foreground w-12 h-12 aspect-square rounded-xl flex flex-col gap-1" variant="link" > diff --git a/apps/web/src/components/screens/login/form.tsx b/apps/web/src/components/screens/login/form.tsx index c81ef92..89a0d74 100644 --- a/apps/web/src/components/screens/login/form.tsx +++ b/apps/web/src/components/screens/login/form.tsx @@ -1,21 +1,13 @@ -import { Button, cn, useIsMobile } from "@methanium/ui"; -import { Input } from "@methanium/ui"; -import { Label } from "@methanium/ui"; +import { Button, cn, useIsMobile } from "@tensamin/ui"; +import { Input } from "@tensamin/ui"; +import { Label } from "@tensamin/ui"; import { useStorage } from "@tensamin/storage/context"; import { log, toast } from "@tensamin/shared/log"; import { File } from "lucide-react"; -import { - type ChangeEvent, - type FormEvent, - useCallback, - useEffect, - useRef, - useState, -} from "react"; +import * as React 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(), @@ -85,13 +77,12 @@ function parseTuFileContent(rawFileContent: string): { export default function Form() { const isMobile = useIsMobile(); - const uploadRef = useRef(null); - const [isDragging, setIsDragging] = useState(false); + const uploadRef = React.useRef(null); + const [isDragging, setIsDragging] = React.useState(false); const { save } = useStorage(); - const navigate = useNavigate(); - const loginPendingRef = useRef(false); + const loginPendingRef = React.useRef(false); - const persistLogin = useCallback( + const persistLogin = React.useCallback( async (userId: number, privateKey: string, domain?: string | null) => { if (loginPendingRef.current) return false; loginPendingRef.current = true; @@ -100,17 +91,22 @@ export default function Form() { await save("mtp_keyring", privateKey, { secure: true }); await save("session_id", Date.now()); await save("user_id", userId); - await navigate({ to: "/", replace: true }); + window.history.replaceState( + null, + "", + window.location.protocol === "file:" ? "#/" : "/", + ); + window.location.reload(); return true; } finally { loginPendingRef.current = false; } }, - [navigate, save], + [save], ); // Process dropped files - const processDroppedFile = useCallback( + const processDroppedFile = React.useCallback( async (file: globalThis.File): Promise => { try { if (!file.name.endsWith(".tu")) { @@ -131,8 +127,8 @@ export default function Form() { ); // Handle .tu files - const handleFileInputChange = useCallback( - async (event: ChangeEvent): Promise => { + const handleFileInputChange = React.useCallback( + async (event: React.ChangeEvent): Promise => { const file = event.currentTarget.files?.[0]; if (!file) { @@ -146,7 +142,7 @@ export default function Form() { ); // Drag and drop listener - useEffect(() => { + React.useEffect(() => { let dragCounter = 0; const handleDragEnter = (event: DragEvent) => { @@ -216,8 +212,8 @@ export default function Form() { * @param event Form submit event. * @returns Promise that resolves after login processing. */ - const handleCredentialsSubmit = useCallback( - async (event: FormEvent): Promise => { + const handleCredentialsSubmit = React.useCallback( + async (event: React.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 10baf34..9e0c314 100644 --- a/apps/web/src/components/sidebar.tsx +++ b/apps/web/src/components/sidebar.tsx @@ -26,9 +26,9 @@ import { SelectValue, SelectContent, SelectItem, -} from "@methanium/ui"; +} from "@tensamin/ui"; import { isTauri } from "@tauri-apps/api/core"; -import { useIsMobile } from "@methanium/ui"; +import { useIsMobile } from "@tensamin/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" + 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" 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 cc3baaf..36399e9 100644 --- a/apps/web/src/features/conversation/list/body.tsx +++ b/apps/web/src/features/conversation/list/body.tsx @@ -1,4 +1,4 @@ -import { useRef, useState } from "react"; +import * as React 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] = useState<"conversations" | "communities">( - "conversations", - ); + const [category, setCategory] = React.useState< + "conversations" | "communities" + >("conversations"); const { contacts, communities } = useSession(); const items = category === "conversations" ? contacts : communities; - const scrollRef = useRef(null); + const scrollRef = React.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 90a45a6..efa8ba5 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 "@methanium/ui"; +} from "@tensamin/ui"; import { useNavigate } from "@tanstack/react-router"; -import { useSidebar } from "@methanium/ui"; +import { useSidebar } from "@tensamin/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 new file mode 100644 index 0000000..9859036 --- /dev/null +++ b/apps/web/src/features/legal/screen.tsx @@ -0,0 +1,247 @@ +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 8a7e776..f59bfc5 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 "@methanium/ui/index.css"; +import "@tensamin/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 "@methanium/ui"; +import { ErrorScreen, ThemeProvider, useTheme } from "@tensamin/ui"; import z from "zod"; import { useEffect, useRef, useState, type ReactNode } from "react"; @@ -43,11 +43,12 @@ 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 "@methanium/ui"; +import { useIsMobile, Toaster, TooltipProvider } from "@tensamin/ui"; import { isTauri } from "@tauri-apps/api/core"; const wrapper = document.getElementById("root"); @@ -130,11 +131,6 @@ function ThemeStorageBridge() { setThemeBorderRadius, themeCustomCss, setThemeCustomCss, - parentThemeId, - setParentThemeId, - applyThemePreset, - themeDesign, - setThemeDesign, } = useTheme(); const loadedRef = useRef(false); @@ -149,8 +145,6 @@ function ThemeStorageBridge() { load("theme_tint"), load("theme_border_radius"), load("theme_custom_css"), - load("theme_parent"), - load("theme_design"), ]).then( ([ color, @@ -160,23 +154,18 @@ 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); - if (customCss !== "") setThemeCustomCss(customCss); - setThemeDesign(design); + setThemeCustomCss(customCss); loadedRef.current = true; }, ); @@ -186,12 +175,9 @@ function ThemeStorageBridge() { }; }, [ load, - applyThemePreset, setThemeBorderRadius, setThemeColor, setThemeCustomCss, - setParentThemeId, - setThemeDesign, setThemePalette, setThemePolarity, setThemePrimaryColor, @@ -226,14 +212,6 @@ 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; } @@ -250,8 +228,6 @@ function RootShell() { tintStorageKey={null} borderRadiusStorageKey={null} customCssStorageKey={null} - parentThemeStorageKey={null} - designStorageKey={null} >
- + + + + + + + @@ -280,29 +262,24 @@ function RootShell() { function AppShell() { return ( - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + ); } @@ -330,7 +307,7 @@ function createCallTrayIcon(color: string, speaking: boolean) { } function CallInit() { - const callInvitePopup = useInitializeCall(); + useInitializeCall(); const { load } = useStorage(); const { @@ -393,7 +370,7 @@ function CallInit() { }); }, [inCall, primaryColor, speaking]); - return callInvitePopup; + return null; } const rootRoute = createRootRoute({ diff --git a/apps/web/src/routes/app/home.tsx b/apps/web/src/routes/app/home.tsx index cd4f662..ee5220b 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 "@methanium/ui"; +} from "@tensamin/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.type === "ErrorNotFound" || data.data.UserId === 0) { + if (data.data.UserId === 0) { throw new Error(); } @@ -101,7 +101,7 @@ function AddConversationButton() { const timeout = setTimeout(() => setLoading(true), 500); send("AddConversation", { - ChatPartnerId: user.data.UserId, + ChatPartnerName: result.data, }) .then(() => { insertContact(user.data.UserId); @@ -131,12 +131,8 @@ function AddConversationButton() { setOpen(value); }} > - ( - - )} - /> - + Add Conversation} /> + New Conversation @@ -164,13 +160,7 @@ function AddConversationButton() { {error && (

{error}

)} - ( - - )} - /> + Cancel} /> diff --git a/apps/web/src/routes/app/layout.tsx b/apps/web/src/routes/app/layout.tsx index 9a46805..4f5c657 100644 --- a/apps/web/src/routes/app/layout.tsx +++ b/apps/web/src/routes/app/layout.tsx @@ -3,9 +3,8 @@ 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 "@methanium/ui"; +import { useIsMobile, cn, SidebarProvider } from "@tensamin/ui"; import { isTauri } from "@tauri-apps/api/core"; @@ -17,7 +16,6 @@ export default function Layout({ children }: { children: ReactNode }) {
-
and others +Copyright (c) 2022 Paul Miller (https://paulmillr.com) 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. +THE SOFTWARE. \ No newline at end of file diff --git a/licenses/@codemirror_language@6.12.4/LICENSE b/licenses/@noble_hashes@2.2.0/LICENSE similarity index 76% rename from licenses/@codemirror_language@6.12.4/LICENSE rename to licenses/@noble_hashes@2.2.0/LICENSE index 9a91f48..9297a04 100644 --- a/licenses/@codemirror_language@6.12.4/LICENSE +++ b/licenses/@noble_hashes@2.2.0/LICENSE @@ -1,9 +1,9 @@ -MIT License +The MIT License (MIT) -Copyright (C) 2018-2021 by Marijn Haverbeke and others +Copyright (c) 2022 Paul Miller (https://paulmillr.com) 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. +THE SOFTWARE. \ No newline at end of file diff --git a/licenses/@twemoji_api@17.0.3/LICENSE b/licenses/@twemoji_api@17.0.3/LICENSE deleted file mode 100644 index d2e3436..0000000 --- a/licenses/@twemoji_api@17.0.3/LICENSE +++ /dev/null @@ -1,22 +0,0 @@ -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 f9c8103..d17e50b 100644 --- a/licenses/THIRD_PARTY_NOTICES.md +++ b/licenses/THIRD_PARTY_NOTICES.md @@ -31,15 +31,6 @@ 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 @@ -58,15 +49,6 @@ 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 @@ -163,6 +145,26 @@ 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 @@ -492,23 +494,13 @@ 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.41 +## @tensamin/ui@0.0.39 - License: UNKNOWN - Included files: none found -- Folder: `licenses/@tensamin_ui@0.0.41` +- Folder: `licenses/@tensamin_ui@0.0.39` - 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 @@ -607,6 +599,15 @@ 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 @@ -822,15 +823,6 @@ 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 @@ -966,21 +958,12 @@ 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` -## 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 +## mtp@0.1.0 - License: UNKNOWN - Description: MTP TypeScript SDK - Included files: none found -- Folder: `licenses/mtp@0.2.0` +- Folder: `licenses/mtp@0.1.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 new file mode 100644 index 0000000..12b597d --- /dev/null +++ b/licenses/comlink@4.4.2/LICENSE @@ -0,0 +1,202 @@ + + 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 deleted file mode 100644 index 3e21d0b..0000000 --- a/licenses/emojibase-data@17.0.0/LICENSE +++ /dev/null @@ -1,21 +0,0 @@ -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 deleted file mode 100644 index 8111044..0000000 --- a/licenses/motion@12.42.2/LICENSE.md +++ /dev/null @@ -1,21 +0,0 @@ -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 1c35ba5..e5f7673 100644 --- a/licenses/sbom.cyclonedx.json +++ b/licenses/sbom.cyclonedx.json @@ -3,7 +3,7 @@ "specVersion": "1.5", "version": 1, "metadata": { - "timestamp": "2026-07-24T10:43:11.914Z", + "timestamp": "2026-07-03T19:50:00.640Z", "tools": [ { "vendor": "OpenAI", @@ -117,37 +117,6 @@ } ] }, - { - "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", @@ -210,37 +179,6 @@ } ] }, - { - "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", @@ -578,6 +516,76 @@ } ] }, + { + "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", @@ -1772,15 +1780,15 @@ }, { "type": "library", - "bomRef": "pkg:npm/%40tensamin/ui@0.0.41", + "bomRef": "pkg:npm/%40tensamin/ui@0.0.39", "name": "@tensamin/ui", - "version": "0.0.41", - "purl": "pkg:npm/%40tensamin/ui@0.0.41", + "version": "0.0.39", + "purl": "pkg:npm/%40tensamin/ui@0.0.39", "externalReferences": [], "properties": [ { "name": "local:licenseFolder", - "value": "licenses/@tensamin_ui@0.0.41" + "value": "licenses/@tensamin_ui@0.0.39" }, { "name": "local:sourcePackageDir", @@ -1788,41 +1796,6 @@ } ] }, - { - "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", @@ -2168,6 +2141,37 @@ } ] }, + { + "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", @@ -2921,37 +2925,6 @@ } ] }, - { - "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", @@ -3424,47 +3397,16 @@ }, { "type": "library", - "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", + "bomRef": "pkg:npm/mtp@0.1.0", "name": "mtp", - "version": "0.2.0", - "purl": "pkg:npm/mtp@0.2.0", + "version": "0.1.0", + "purl": "pkg:npm/mtp@0.1.0", "description": "MTP TypeScript SDK", "externalReferences": [], "properties": [ { "name": "local:licenseFolder", - "value": "licenses/mtp@0.2.0" + "value": "licenses/mtp@0.1.0" }, { "name": "local:sourcePackageDir", @@ -4909,4 +4851,4 @@ ] } ] -} \ No newline at end of file +} diff --git a/licenses/third-party-credits.json b/licenses/third-party-credits.json index 180e5e4..81d1ba8 100644 --- a/licenses/third-party-credits.json +++ b/licenses/third-party-credits.json @@ -1,6 +1,6 @@ { - "generatedAt": "2026-07-24T10:43:11.913Z", - "packageCount": 145, + "generatedAt": "2026-07-03T19:50:00.637Z", + "packageCount": 143, "packages": [ { "name": "@babel/runtime", @@ -41,19 +41,6 @@ "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", @@ -80,19 +67,6 @@ "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", @@ -223,6 +197,32 @@ "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.3.0", + "version": "1.2.1", "license": "MIT", "homepage": "https://radix-ui.com/primitives", "repository": "git+https://github.com/radix-ui/primitives.git", @@ -682,28 +682,15 @@ }, { "name": "@tensamin/ui", - "version": "0.0.41", + "version": "0.0.39", "license": "UNKNOWN", "homepage": null, "repository": null, "description": null, "files": [], - "licenseFolder": "licenses/@tensamin_ui@0.0.41", + "licenseFolder": "licenses/@tensamin_ui@0.0.39", "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", @@ -834,6 +821,19 @@ "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.2.1", + "version": "1.3.0", "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,19 +1115,6 @@ "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", @@ -1306,28 +1293,15 @@ "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.2.0", + "version": "0.1.0", "license": "UNKNOWN", "homepage": null, "repository": null, "description": "MTP TypeScript SDK", "files": [], - "licenseFolder": "licenses/mtp@0.2.0", + "licenseFolder": "licenses/mtp@0.1.0", "sourcePackageDir": "packages/mtp/node_modules/mtp" }, { @@ -1873,4 +1847,4 @@ "sourcePackageDir": "packages/call/node_modules/zustand" } ] -} \ No newline at end of file +} diff --git a/mtp-type-maps b/mtp-type-maps deleted file mode 160000 index 11a1d79..0000000 --- a/mtp-type-maps +++ /dev/null @@ -1 +0,0 @@ -Subproject commit 11a1d79409857b734e948dd8c3e28e6ba721d15f diff --git a/package.json b/package.json index c3da492..3765f87 100644 --- a/package.json +++ b/package.json @@ -10,15 +10,15 @@ "type": "module", "scripts": { "format": "pnpm exec prettier --write .", - "lint": "node utils/scripts/lint-packages.ts", + "lint": "node scripts/lint-packages.ts", "check": "fallow && pnpm run lint", - "copy-licenses": "node utils/scripts/copy-licenses.ts", - "copy-releases": "node utils/scripts/copy-releases.ts", + "copy-licenses": "node scripts/copy-licenses.ts", + "copy-releases": "node 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 utils/scripts/build-packages.ts", - "update:packages": "node utils/scripts/update-packages.ts", - "dev": "cd apps/web && pnpm dev", + "build:packages": "node scripts/build-packages.ts", + "update:packages": "node scripts/update-packages.ts", + "dev:web": "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.dev" + "delete:mobile": "cd apps/tauri && nix develop ../..#tauri --command adb uninstall net.tensamin.client" }, "devDependencies": { "@eslint/js": "^10.0.1", @@ -46,7 +46,7 @@ "yaml": "^2.8.2" }, "dependencies": { - "@methanium/ui": "https://git.methanium.net/methanium/ui/releases/download/0.0.2/methanium-ui.tgz", + "@tensamin/ui": "*", "mtp": "*", "sonner": "^2.0.7" } diff --git a/packages/cache/src/index.ts b/packages/cache/src/index.ts index 43c5018..cd78102 100644 --- a/packages/cache/src/index.ts +++ b/packages/cache/src/index.ts @@ -175,7 +175,12 @@ 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), + ), + ]; }), ); }, @@ -205,7 +210,12 @@ 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), + ), + ]; }), ); }, @@ -231,7 +241,12 @@ 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 f90e80d..b1c7a84 100644 --- a/packages/cache/src/sync.tsx +++ b/packages/cache/src/sync.tsx @@ -18,6 +18,7 @@ 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); @@ -142,7 +143,6 @@ export default function CacheSync() { MessageState: "sent", SenderId: accountId, SendTime: Number(request.SendTime), - ReplyId: request.ReplyId ? Number(request.ReplyId) : undefined, }); return; } @@ -195,6 +195,23 @@ 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], ); @@ -242,28 +259,13 @@ export default function CacheSync() { return; } if (message.type === "MessageReactionLive") { - 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, + reactionPartnersRef.current.set( + Number(data.SendTime), + Number(data.ChatPartnerId), ); - 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, secureCache], + [accountId, insertMessage, removeMessage, replaceMessage], ); useEffect(() => { diff --git a/packages/call/package.json b/packages/call/package.json index 4fafe09..576caa1 100644 --- a/packages/call/package.json +++ b/packages/call/package.json @@ -19,11 +19,12 @@ "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:*", - "@methanium/ui": "*", + "@tensamin/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 7856d7e..a0d3a77 100644 --- a/packages/call/src/components/actions.tsx +++ b/packages/call/src/components/actions.tsx @@ -5,13 +5,11 @@ import { Tooltip, TooltipContent, TooltipTrigger, - useIsMobile, - cn, -} from "@methanium/ui"; +} from "@tensamin/ui"; import { useEffect, useState } from "react"; import MuteButton from "./buttons/mute"; import DeafButton from "./buttons/deaf"; -import MediaShareButton from "./buttons/mediaShare"; +import ScreenshareButton from "./buttons/screenshare"; import LeaveButton from "./buttons/leave"; import { setCallIsPopout, @@ -33,7 +31,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); @@ -79,45 +77,34 @@ export default function Actions() { (state) => state.usersInFocusedViewHidden, ); - const isMobile = useIsMobile(); - return ( -
- {!isMobile && ( -
- {view === "focused" && ( - - ( - - )} - /> - - Hide users - - - )} -
- )} +
+
+ {view === "focused" && ( + + + setUsersInFocusedViewHidden(!usersInFocusedViewHidden) + } + variant="link" + className="w-11 h-11 p-0! ml-3 text-foreground" + > + {usersInFocusedViewHidden ? ( + + ) : ( + + )} + + } + /> + + Hide users + + + )} +
- ( + render={ - )} + } /> Stop watching @@ -178,58 +161,50 @@ export default function Actions() { )} - {!isMobile && ( -
- - ( - - )} - /> - - Popout - - - - ( - - )} - /> - - Fullscreen - - -
- )} +
+ + 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 + + +
); } diff --git a/packages/call/src/components/buttons/deaf.tsx b/packages/call/src/components/buttons/deaf.tsx index 417e3f4..6d0ede0 100644 --- a/packages/call/src/components/buttons/deaf.tsx +++ b/packages/call/src/components/buttons/deaf.tsx @@ -1,11 +1,7 @@ -import { Button } from "@methanium/ui"; +import { Button } from "@tensamin/ui"; import { toggleDeaf, useCall } from "../../store"; import { HeadphoneOff, Headphones } from "lucide-react"; -import { - type CallButtonProps, - iconScale, - withButtonTooltip, -} from "./tooltipButton"; +import { type CallButtonProps, iconScale, withTooltip } from "./tooltipButton"; export default function DeafButton({ className, @@ -29,5 +25,5 @@ export default function DeafButton({ ); - return withButtonTooltip(button, tooltip, portalContainer); + return withTooltip(button, tooltip, portalContainer); } diff --git a/packages/call/src/components/buttons/invite.tsx b/packages/call/src/components/buttons/invite.tsx index b478529..d049a5a 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 "@methanium/ui"; +} from "@tensamin/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 ? ( ( - - )} + } /> ) : ( ); - return withButtonTooltip(button, tooltip, portalContainer); + return withTooltip(button, tooltip, portalContainer); } diff --git a/packages/call/src/components/buttons/mediaShare.tsx b/packages/call/src/components/buttons/mediaShare.tsx deleted file mode 100644 index 510fbef..0000000 --- a/packages/call/src/components/buttons/mediaShare.tsx +++ /dev/null @@ -1,171 +0,0 @@ -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 025f2ca..3067a2b 100644 --- a/packages/call/src/components/buttons/mute.tsx +++ b/packages/call/src/components/buttons/mute.tsx @@ -1,11 +1,7 @@ -import { Button } from "@methanium/ui"; +import { Button } from "@tensamin/ui"; import { toggleMute, useCall } from "../../store"; import { Mic, MicOff } from "lucide-react"; -import { - type CallButtonProps, - iconScale, - withButtonTooltip, -} from "./tooltipButton"; +import { type CallButtonProps, iconScale, withTooltip } from "./tooltipButton"; export default function MuteButton({ className, @@ -29,5 +25,5 @@ export default function MuteButton({ ); - return withButtonTooltip(button, tooltip, portalContainer); + return withTooltip(button, tooltip, portalContainer); } diff --git a/packages/call/src/components/buttons/screenshare.tsx b/packages/call/src/components/buttons/screenshare.tsx new file mode 100644 index 0000000..21ba118 --- /dev/null +++ b/packages/call/src/components/buttons/screenshare.tsx @@ -0,0 +1,169 @@ +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 3b3d04e..72110f8 100644 --- a/packages/call/src/components/buttons/tooltipButton.tsx +++ b/packages/call/src/components/buttons/tooltipButton.tsx @@ -1,6 +1,5 @@ -import { cloneElement } from "react"; -import type { MouseEvent as ReactMouseEvent, ReactElement, Ref } from "react"; -import { Tooltip, TooltipContent, TooltipTrigger } from "@methanium/ui"; +import { type ReactElement } from "react"; +import { Tooltip, TooltipContent, TooltipTrigger } from "@tensamin/ui"; export type CallButtonProps = { className?: string; @@ -13,31 +12,20 @@ export function iconScale(iconSize?: number) { return { scale: (iconSize ? iconSize + 100 : 100) + "%" }; } -export function withButtonTooltip( - trigger: ReactElement<{ - onClick?: (event: ReactMouseEvent) => void; - ref?: Ref; - }>, - content?: string, +export function withTooltip( + button: ReactElement, + tooltip?: string, portalContainer?: HTMLElement, ) { - if (!content) return trigger; + if (!tooltip) { + return button; + } return ( - - cloneElement(trigger, { - ref, - onClick: (event) => { - onClick?.(event); - trigger.props.onClick?.(event); - }, - }) - } - /> + - {content} + {tooltip} ); diff --git a/packages/call/src/components/invitePopup.tsx b/packages/call/src/components/invitePopup.tsx index ed26a1a..15d9b1a 100644 --- a/packages/call/src/components/invitePopup.tsx +++ b/packages/call/src/components/invitePopup.tsx @@ -5,7 +5,7 @@ import { Button, Dialog, DialogContent, -} from "@methanium/ui"; +} from "@tensamin/ui"; import Wrapper from "@tensamin/user/wrapper"; import { PhoneIncoming, X } from "lucide-react"; @@ -26,10 +26,7 @@ export default function InvitePopup({ loading={null} component={(user) => ( - + @@ -39,14 +36,14 @@ export default function InvitePopup({

{user.Display}

- - - -
- ); -} diff --git a/packages/call/src/components/mediaSourceCard.tsx b/packages/call/src/components/mediaSourceCard.tsx deleted file mode 100644 index f740dbc..0000000 --- a/packages/call/src/components/mediaSourceCard.tsx +++ /dev/null @@ -1,77 +0,0 @@ -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 ( -