diff --git a/apps/whispering/src/lib/query/commands.ts b/apps/whispering/src/lib/query/commands.ts index 8d1752bb84..7e92166a0a 100644 --- a/apps/whispering/src/lib/query/commands.ts +++ b/apps/whispering/src/lib/query/commands.ts @@ -14,7 +14,7 @@ import { transcription } from './transcription'; import { transformations } from './transformations'; import { transformer } from './transformer'; import { vadRecorder } from './vad-recorder'; -import { rpc } from './'; +import { rpc } from '$lib/query'; // Track manual recording start time for duration calculation let manualRecordingStartTime: number | null = null; @@ -387,7 +387,7 @@ export const commands = { validFiles.map(async (file) => { const arrayBuffer = await file.arrayBuffer(); const audioBlob = new Blob([arrayBuffer], { type: file.type }); - + // Log file upload event rpc.analytics.logEvent.execute({ type: 'file_uploaded', diff --git a/apps/whispering/src/lib/query/transcription.ts b/apps/whispering/src/lib/query/transcription.ts index 829c5227c5..f26449cc5b 100644 --- a/apps/whispering/src/lib/query/transcription.ts +++ b/apps/whispering/src/lib/query/transcription.ts @@ -6,7 +6,7 @@ import { Err, Ok, type Result, partitionResults } from 'wellcrafted/result'; import { defineMutation, queryClient } from './_client'; import { notify } from './notify'; import { recordings } from './recordings'; -import { rpc } from './'; +import { rpc } from '$lib/query'; const transcriptionKeys = { isTranscribing: ['transcription', 'isTranscribing'] as const, diff --git a/apps/whispering/src/lib/services/db/index.ts b/apps/whispering/src/lib/services/db/index.ts index dbb5018e15..b90a77c22e 100644 --- a/apps/whispering/src/lib/services/db/index.ts +++ b/apps/whispering/src/lib/services/db/index.ts @@ -1,13 +1,13 @@ -import { DownloadServiceLive } from '../download'; -import { createDbServiceDexie } from './dexie'; +import { DownloadServiceLive } from '$lib/services/download'; +import { createDbServiceDexie } from '$lib/services/db/dexie'; -export { createDbServiceDexie, DbServiceErr } from './dexie'; +export { createDbServiceDexie, DbServiceErr } from '$lib/services/db/dexie'; export { generateDefaultTransformation, generateDefaultTransformationStep, TRANSFORMATION_STEP_TYPES, TRANSFORMATION_STEP_TYPES_TO_LABELS, -} from './models'; +} from '$lib/services/db/models'; export type { InsertTransformationStep, Recording, @@ -17,7 +17,7 @@ export type { TransformationRunFailed, TransformationStep, TransformationStepRun, -} from './models'; +} from '$lib/services/db/models'; export const DbServiceLive = createDbServiceDexie({ DownloadService: DownloadServiceLive, diff --git a/apps/whispering/src/lib/services/ffmpeg/desktop.ts b/apps/whispering/src/lib/services/ffmpeg/desktop.ts index 6e76f656bf..24e59a7424 100644 --- a/apps/whispering/src/lib/services/ffmpeg/desktop.ts +++ b/apps/whispering/src/lib/services/ffmpeg/desktop.ts @@ -1,7 +1,10 @@ import { IS_WINDOWS } from '$lib/constants/platform'; import { extractErrorMessage } from 'wellcrafted/error'; import { Err, Ok, tryAsync } from 'wellcrafted/result'; -import { type FfmpegService, FfmpegServiceErr } from './types'; +import { + type FfmpegService, + FfmpegServiceErr, +} from '$lib/services/ffmpeg/types'; export function createFfmpegService(): FfmpegService { return { @@ -10,9 +13,10 @@ export function createFfmpegService(): FfmpegService { await tryAsync({ try: async () => { const { Command } = await import('@tauri-apps/plugin-shell'); - const output = await (IS_WINDOWS - ? Command.create('cmd', ['/c', 'ffmpeg -version']) - : Command.create('sh', ['-c', 'ffmpeg -version']) + const output = await ( + IS_WINDOWS + ? Command.create('cmd', ['/c', 'ffmpeg -version']) + : Command.create('sh', ['-c', 'ffmpeg -version']) ).execute(); return output; }, diff --git a/apps/whispering/src/lib/services/ffmpeg/index.ts b/apps/whispering/src/lib/services/ffmpeg/index.ts index 29dbefd02c..1b27117a1b 100644 --- a/apps/whispering/src/lib/services/ffmpeg/index.ts +++ b/apps/whispering/src/lib/services/ffmpeg/index.ts @@ -1,6 +1,6 @@ -export type { FfmpegService } from './types'; -import { createFfmpegService } from './desktop'; -import { createFfmpegServiceWeb } from './web'; +export type { FfmpegService } from '$lib/services/ffmpeg/types'; +import { createFfmpegService } from '$lib/services/ffmpeg/desktop'; +import { createFfmpegServiceWeb } from '$lib/services/ffmpeg/web'; export const FfmpegServiceLive = window.__TAURI_INTERNALS__ ? createFfmpegService() diff --git a/apps/whispering/src/lib/services/ffmpeg/web.ts b/apps/whispering/src/lib/services/ffmpeg/web.ts index 1ce88cb28b..d17fe5bce0 100644 --- a/apps/whispering/src/lib/services/ffmpeg/web.ts +++ b/apps/whispering/src/lib/services/ffmpeg/web.ts @@ -1,6 +1,6 @@ import { Ok, type Result } from 'wellcrafted/result'; import type { WhisperingError } from '$lib/result'; -import type { FfmpegService } from './types'; +import type { FfmpegService } from '$lib/services/ffmpeg/types'; export function createFfmpegServiceWeb(): FfmpegService { return { diff --git a/apps/whispering/src/lib/services/recorder/desktop.ts b/apps/whispering/src/lib/services/recorder/desktop.ts index c086645030..a670fe20b8 100644 --- a/apps/whispering/src/lib/services/recorder/desktop.ts +++ b/apps/whispering/src/lib/services/recorder/desktop.ts @@ -1,14 +1,14 @@ import type { CancelRecordingResult } from '$lib/constants/audio'; import { invoke as tauriInvoke } from '@tauri-apps/api/core'; import { Err, Ok, type Result, tryAsync } from 'wellcrafted/result'; -import type { Device, DeviceAcquisitionOutcome } from '../types'; -import { asDeviceIdentifier } from '../types'; +import type { Device, DeviceAcquisitionOutcome } from '$lib/services/types'; +import { asDeviceIdentifier } from '$lib/services/types'; import type { RecorderService, RecorderServiceError, StartRecordingParams, -} from './types'; -import { RecorderServiceErr } from './types'; +} from '$lib/services/recorder/types'; +import { RecorderServiceErr } from '$lib/services/recorder/types'; import { readFile } from '@tauri-apps/plugin-fs'; import { remove } from '@tauri-apps/plugin-fs'; diff --git a/apps/whispering/src/lib/services/text/desktop.ts b/apps/whispering/src/lib/services/text/desktop.ts index 5da4862a95..294d527d9e 100644 --- a/apps/whispering/src/lib/services/text/desktop.ts +++ b/apps/whispering/src/lib/services/text/desktop.ts @@ -3,8 +3,8 @@ import { invoke } from '@tauri-apps/api/core'; import { writeText } from '@tauri-apps/plugin-clipboard-manager'; import { type } from '@tauri-apps/plugin-os'; import { Err, Ok, tryAsync } from 'wellcrafted/result'; -import type { TextService } from './types'; -import { TextServiceErr } from './types'; +import type { TextService } from '$lib/services/text/types'; +import { TextServiceErr } from '$lib/services/text/types'; export function createTextServiceDesktop(): TextService { return { @@ -32,4 +32,4 @@ export function createTextServiceDesktop(): TextService { }), }), }; -} \ No newline at end of file +} diff --git a/apps/whispering/src/lib/services/text/extension.ts b/apps/whispering/src/lib/services/text/extension.ts index 67c5a98bf7..2ec01d0e71 100644 --- a/apps/whispering/src/lib/services/text/extension.ts +++ b/apps/whispering/src/lib/services/text/extension.ts @@ -1,5 +1,5 @@ import { tryAsync } from 'wellcrafted/result'; -import { type TextService, TextServiceErr } from './types'; +import { type TextService, TextServiceErr } from '$lib/services/text/types'; export function createTextServiceExtension(): TextService { return { @@ -91,4 +91,4 @@ function appendTextToContentEditableElement( text: string, ): void { element.innerHTML += text; -} \ No newline at end of file +} diff --git a/apps/whispering/src/lib/services/text/index.ts b/apps/whispering/src/lib/services/text/index.ts index d79db4a447..f9d0bc4552 100644 --- a/apps/whispering/src/lib/services/text/index.ts +++ b/apps/whispering/src/lib/services/text/index.ts @@ -1,7 +1,7 @@ -import { createTextServiceDesktop } from './desktop'; -import { createTextServiceWeb } from './web'; +import { createTextServiceDesktop } from '$lib/services/text/desktop'; +import { createTextServiceWeb } from '$lib/services/text/web'; -export type { TextService, TextServiceError } from './types'; +export type { TextService, TextServiceError } from '$lib/services/text/types'; export const TextServiceLive = window.__TAURI_INTERNALS__ ? createTextServiceDesktop() diff --git a/apps/whispering/src/lib/services/text/web.ts b/apps/whispering/src/lib/services/text/web.ts index 6f4ea38e1b..c2bbb8b6fc 100644 --- a/apps/whispering/src/lib/services/text/web.ts +++ b/apps/whispering/src/lib/services/text/web.ts @@ -1,6 +1,6 @@ import { Ok, tryAsync } from 'wellcrafted/result'; -import type { TextService } from './types'; -import { TextServiceErr } from './types'; +import type { TextService } from '$lib/services/text/types'; +import { TextServiceErr } from '$lib/services/text/types'; export function createTextServiceWeb(): TextService { return { @@ -36,4 +36,4 @@ export function createTextServiceWeb(): TextService { }); }, }; -} \ No newline at end of file +} diff --git a/apps/whispering/src/lib/services/transcription/index.ts b/apps/whispering/src/lib/services/transcription/index.ts index b703fc8975..eef0b98447 100644 --- a/apps/whispering/src/lib/services/transcription/index.ts +++ b/apps/whispering/src/lib/services/transcription/index.ts @@ -1,9 +1,9 @@ -import { DeepgramTranscriptionServiceLive } from './deepgram'; -import { ElevenlabsTranscriptionServiceLive } from './elevenlabs'; -import { GroqTranscriptionServiceLive } from './groq'; -import { OpenaiTranscriptionServiceLive } from './openai'; -import { SpeachesTranscriptionServiceLive } from './speaches'; -import { WhisperCppTranscriptionServiceLive } from './whispercpp'; +import { DeepgramTranscriptionServiceLive } from '$lib/services/transcription/deepgram'; +import { ElevenlabsTranscriptionServiceLive } from '$lib/services/transcription/elevenlabs'; +import { GroqTranscriptionServiceLive } from '$lib/services/transcription/groq'; +import { OpenaiTranscriptionServiceLive } from '$lib/services/transcription/openai'; +import { SpeachesTranscriptionServiceLive } from '$lib/services/transcription/speaches'; +import { WhisperCppTranscriptionServiceLive } from '$lib/services/transcription/whispercpp'; export { ElevenlabsTranscriptionServiceLive as elevenlabs, @@ -19,4 +19,4 @@ export type { GroqTranscriptionService } from './groq'; export type { OpenaiTranscriptionService } from './openai'; export type { SpeachesTranscriptionService } from './speaches'; export type { DeepgramTranscriptionService } from './deepgram'; -export type { WhisperCppTranscriptionService } from './whispercpp'; \ No newline at end of file +export type { WhisperCppTranscriptionService } from './whispercpp'; diff --git a/apps/whispering/src/lib/services/vad-recorder.ts b/apps/whispering/src/lib/services/vad-recorder.ts index 6ce4725a83..5ed6bea0b6 100644 --- a/apps/whispering/src/lib/services/vad-recorder.ts +++ b/apps/whispering/src/lib/services/vad-recorder.ts @@ -2,8 +2,11 @@ import type { VadState } from '$lib/constants/audio'; import { MicVAD, utils } from '@ricky0123/vad-web'; import { createTaggedError, extractErrorMessage } from 'wellcrafted/error'; import { Err, Ok, tryAsync, trySync } from 'wellcrafted/result'; -import { cleanupRecordingStream, getRecordingStream } from './device-stream'; -import type { DeviceIdentifier } from './types'; +import { + cleanupRecordingStream, + getRecordingStream, +} from '$lib/services/device-stream'; +import type { DeviceIdentifier } from '$lib/services/types'; const { VadRecorderServiceError, VadRecorderServiceErr } = createTaggedError( 'VadRecorderServiceError', diff --git a/apps/whispering/src/lib/stores/settings.svelte.ts b/apps/whispering/src/lib/stores/settings.svelte.ts index 244681a6f8..a1d39e0a85 100644 --- a/apps/whispering/src/lib/stores/settings.svelte.ts +++ b/apps/whispering/src/lib/stores/settings.svelte.ts @@ -10,7 +10,7 @@ import { createPersistedState } from '@repo/svelte-utils'; import { syncGlobalShortcutsWithSettings, syncLocalShortcutsWithSettings, -} from '../../routes/+layout/register-commands'; +} from '$lib/utils/register-commands'; import { extractErrorMessage } from 'wellcrafted/error'; /** diff --git a/apps/whispering/src/routes/+layout/check-ffmpeg.ts b/apps/whispering/src/lib/utils/check-ffmpeg.ts similarity index 100% rename from apps/whispering/src/routes/+layout/check-ffmpeg.ts rename to apps/whispering/src/lib/utils/check-ffmpeg.ts diff --git a/apps/whispering/src/routes/+layout/register-commands.ts b/apps/whispering/src/lib/utils/register-commands.ts similarity index 100% rename from apps/whispering/src/routes/+layout/register-commands.ts rename to apps/whispering/src/lib/utils/register-commands.ts diff --git a/apps/whispering/src/routes/(config)/settings/recording/+page.svelte b/apps/whispering/src/routes/(config)/settings/recording/+page.svelte index c3c50ba2ea..74010bc39f 100644 --- a/apps/whispering/src/routes/(config)/settings/recording/+page.svelte +++ b/apps/whispering/src/routes/(config)/settings/recording/+page.svelte @@ -14,7 +14,7 @@ import { isUsingNativeBackendWithCloudTranscription, isUsingNativeBackendAtWrongSampleRate, - } from '../../../+layout/check-ffmpeg'; + } from '$lib/utils/check-ffmpeg'; import { IS_MACOS } from '$lib/constants/platform'; const { data } = $props(); diff --git a/apps/whispering/src/routes/(config)/settings/transcription/+page.svelte b/apps/whispering/src/routes/(config)/settings/transcription/+page.svelte index fdab1ddd5e..f0a347bf43 100644 --- a/apps/whispering/src/routes/(config)/settings/transcription/+page.svelte +++ b/apps/whispering/src/routes/(config)/settings/transcription/+page.svelte @@ -36,7 +36,7 @@ import { isUsingWhisperCppWithBrowserBackend, isUsingNativeBackendAtWrongSampleRate, - } from '../../../+layout/check-ffmpeg'; + } from '$lib/utils/check-ffmpeg'; diff --git a/apps/whispering/src/routes/+layout/AppShell.svelte b/apps/whispering/src/routes/+layout/AppShell.svelte index e3e9fcc349..2c5cee45d0 100644 --- a/apps/whispering/src/routes/+layout/AppShell.svelte +++ b/apps/whispering/src/routes/+layout/AppShell.svelte @@ -20,12 +20,12 @@ resetLocalShortcutsToDefaultIfDuplicates, syncGlobalShortcutsWithSettings, syncLocalShortcutsWithSettings, - } from './register-commands'; + } from '$lib/utils/register-commands'; import { registerOnboarding } from './register-onboarding'; - import { checkFfmpeg } from './check-ffmpeg'; - import { + import { checkFfmpeg } from '$lib/utils/check-ffmpeg'; + import { registerAccessibilityPermission, - registerMicrophonePermission + registerMicrophonePermission, } from './register-permissions'; import { syncIconWithRecorderState } from './syncIconWithRecorderState.svelte'; @@ -52,7 +52,7 @@ // await extension.notifyWhisperingTabReady(undefined); } registerOnboarding(); - + // Register permission checkers separately cleanupAccessibilityPermission = registerAccessibilityPermission(); cleanupMicrophonePermission = registerMicrophonePermission();