chore: apply formatter updates
This commit is contained in:
1 parent
8f754b3f00
commit
b111ae0a76
5 files changed
+110
-97
No files matched your search
@@ -18,7 +18,10 @@ serde_json = "1"
|
|||||||
tauri = { version = "2", features = ["tray-icon", "image-png"] }
|
tauri = { version = "2", features = ["tray-icon", "image-png"] }
|
||||||
tauri-plugin-opener = "2"
|
tauri-plugin-opener = "2"
|
||||||
tauri-plugin-global-shortcut = "2"
|
tauri-plugin-global-shortcut = "2"
|
||||||
reqwest = { version = "0.12", default-features = false, features = ["blocking", "rustls-tls"] }
|
reqwest = { version = "0.12", default-features = false, features = [
|
||||||
|
"blocking",
|
||||||
|
"rustls-tls",
|
||||||
|
] }
|
||||||
cpal = "0.15.3"
|
cpal = "0.15.3"
|
||||||
hound = "3.5"
|
hound = "3.5"
|
||||||
arboard = "3.6"
|
arboard = "3.6"
|
||||||
|
|||||||
@@ -87,7 +87,8 @@ pub fn status_for_path(path: &Path, expected_size: u64) -> ModelInstallStatus {
|
|||||||
Ok(metadata) if metadata.len() >= expected_size => ModelInstallStatus::Ready,
|
Ok(metadata) if metadata.len() >= expected_size => ModelInstallStatus::Ready,
|
||||||
Ok(metadata) => ModelInstallStatus::Error(format!(
|
Ok(metadata) => ModelInstallStatus::Error(format!(
|
||||||
"arquivo incompleto: {} de {} bytes",
|
"arquivo incompleto: {} de {} bytes",
|
||||||
metadata.len(), expected_size
|
metadata.len(),
|
||||||
|
expected_size
|
||||||
)),
|
)),
|
||||||
Err(_) => ModelInstallStatus::NotInstalled,
|
Err(_) => ModelInstallStatus::NotInstalled,
|
||||||
}
|
}
|
||||||
@@ -132,7 +133,8 @@ pub fn download_default_model(model_dir: &Path) -> AppResult<ModelDownloadResult
|
|||||||
bytes_written += read as u64;
|
bytes_written += read as u64;
|
||||||
}
|
}
|
||||||
|
|
||||||
file.flush().map_err(|error| AppError::Io(error.to_string()))?;
|
file.flush()
|
||||||
|
.map_err(|error| AppError::Io(error.to_string()))?;
|
||||||
|
|
||||||
if bytes_written < model.size_bytes {
|
if bytes_written < model.size_bytes {
|
||||||
let _ = fs::remove_file(&temp_path);
|
let _ = fs::remove_file(&temp_path);
|
||||||
@@ -180,9 +182,12 @@ mod tests {
|
|||||||
fs::write(&path, [1_u8, 2, 3, 4]).unwrap_or_else(|error| panic!("write model: {error}"));
|
fs::write(&path, [1_u8, 2, 3, 4]).unwrap_or_else(|error| panic!("write model: {error}"));
|
||||||
|
|
||||||
assert_eq!(status_for_path(&path, 4), ModelInstallStatus::Ready);
|
assert_eq!(status_for_path(&path, 4), ModelInstallStatus::Ready);
|
||||||
assert!(matches!(status_for_path(&path, 5), ModelInstallStatus::Error(_)));
|
assert!(matches!(
|
||||||
|
status_for_path(&path, 5),
|
||||||
|
ModelInstallStatus::Error(_)
|
||||||
|
));
|
||||||
|
|
||||||
let _ = fs::remove_file(path);
|
let _ = fs::remove_file(path);
|
||||||
let _ = fs::remove_dir(dir);
|
let _ = fs::remove_dir(dir);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
+82
-77
@@ -1,98 +1,103 @@
|
|||||||
import { beforeEach, describe, expect, it } from 'vitest';
|
import { beforeEach, describe, expect, it } from "vitest";
|
||||||
|
|
||||||
import { createTranscriptionApp, type AppSnapshot, type NativeClient } from './app';
|
import {
|
||||||
|
createTranscriptionApp,
|
||||||
|
type AppSnapshot,
|
||||||
|
type NativeClient,
|
||||||
|
} from "./app";
|
||||||
|
|
||||||
const baseSnapshot: AppSnapshot = {
|
const baseSnapshot: AppSnapshot = {
|
||||||
recordingStatus: 'idle',
|
recordingStatus: "idle",
|
||||||
transcript: {
|
transcript: {
|
||||||
text: 'Texto inicial',
|
text: "Texto inicial",
|
||||||
lastMessage: 'Revise o texto antes de inserir.',
|
lastMessage: "Revise o texto antes de inserir.",
|
||||||
},
|
},
|
||||||
settings: {
|
settings: {
|
||||||
transcription: {
|
transcription: {
|
||||||
mode: 'localFirst',
|
mode: "localFirst",
|
||||||
modelId: 'parakeet-tdt-0.6b-v3-q8_0',
|
modelId: "parakeet-tdt-0.6b-v3-q8_0",
|
||||||
language: null,
|
language: null,
|
||||||
openaiCompatible: {
|
openaiCompatible: {
|
||||||
endpoint: 'https://api.openai.com/v1/audio/transcriptions',
|
endpoint: "https://api.openai.com/v1/audio/transcriptions",
|
||||||
apiKeyConfigured: false,
|
apiKeyConfigured: false,
|
||||||
model: 'whisper-1',
|
model: "whisper-1",
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
insertion: {
|
insertion: {
|
||||||
method: 'clipboardPaste',
|
method: "clipboardPaste",
|
||||||
restoreClipboard: true,
|
restoreClipboard: true,
|
||||||
waylandManualFallback: true,
|
waylandManualFallback: true,
|
||||||
},
|
},
|
||||||
storage: {
|
storage: {
|
||||||
keepAudio: false,
|
keepAudio: false,
|
||||||
audioFormat: 'wav',
|
audioFormat: "wav",
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
models: [
|
models: [
|
||||||
{
|
{
|
||||||
model: {
|
model: {
|
||||||
id: 'parakeet-tdt-0.6b-v3-q8_0',
|
id: "parakeet-tdt-0.6b-v3-q8_0",
|
||||||
displayName: 'Parakeet TDT 0.6B v3 Q8',
|
displayName: "Parakeet TDT 0.6B v3 Q8",
|
||||||
repository: 'cstr/parakeet-tdt-0.6b-v3-GGUF',
|
repository: "cstr/parakeet-tdt-0.6b-v3-GGUF",
|
||||||
filename: 'parakeet-tdt-0.6b-v3-q8_0.gguf',
|
filename: "parakeet-tdt-0.6b-v3-q8_0.gguf",
|
||||||
quantization: 'Q8_0',
|
quantization: "Q8_0",
|
||||||
sizeBytes: 745_121_600,
|
sizeBytes: 745_121_600,
|
||||||
languages: ['pt'],
|
languages: ["pt"],
|
||||||
recommendedForSimplePc: true,
|
recommendedForSimplePc: true,
|
||||||
},
|
},
|
||||||
status: 'notInstalled',
|
status: "notInstalled",
|
||||||
},
|
},
|
||||||
],
|
],
|
||||||
};
|
};
|
||||||
|
|
||||||
function createFakeClient(): NativeClient & { calls: string[] } {
|
function createFakeClient(): NativeClient & { calls: string[] } {
|
||||||
const calls: string[] = [];
|
const calls: string[] = [];
|
||||||
|
|
||||||
return {
|
return {
|
||||||
calls,
|
calls,
|
||||||
async invoke<T>(command: string): Promise<T> {
|
async invoke<T>(command: string): Promise<T> {
|
||||||
calls.push(command);
|
calls.push(command);
|
||||||
return baseSnapshot as T;
|
return baseSnapshot as T;
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
async function flushPromises(): Promise<void> {
|
async function flushPromises(): Promise<void> {
|
||||||
await new Promise((resolve) => window.setTimeout(resolve, 0));
|
await new Promise((resolve) => window.setTimeout(resolve, 0));
|
||||||
}
|
}
|
||||||
|
|
||||||
describe('createTranscriptionApp', () => {
|
describe("createTranscriptionApp", () => {
|
||||||
beforeEach(() => {
|
beforeEach(() => {
|
||||||
document.body.textContent = '';
|
document.body.textContent = "";
|
||||||
});
|
});
|
||||||
|
|
||||||
it('renders editable transcript modal with offline model details', async () => {
|
it("renders editable transcript modal with offline model details", async () => {
|
||||||
const mount = document.createElement('main');
|
const mount = document.createElement("main");
|
||||||
const client = createFakeClient();
|
const client = createFakeClient();
|
||||||
|
|
||||||
createTranscriptionApp(mount, client);
|
createTranscriptionApp(mount, client);
|
||||||
await flushPromises();
|
await flushPromises();
|
||||||
|
|
||||||
const editor = mount.querySelector<HTMLTextAreaElement>('#transcript-editor');
|
const editor =
|
||||||
|
mount.querySelector<HTMLTextAreaElement>("#transcript-editor");
|
||||||
|
|
||||||
expect(editor?.value).toBe('Texto inicial');
|
expect(editor?.value).toBe("Texto inicial");
|
||||||
expect(mount.textContent).toContain('Parakeet TDT 0.6B v3 Q8');
|
expect(mount.textContent).toContain("Parakeet TDT 0.6B v3 Q8");
|
||||||
expect(mount.textContent).toContain('Offline primeiro');
|
expect(mount.textContent).toContain("Offline primeiro");
|
||||||
});
|
});
|
||||||
|
|
||||||
it('calls native start command when record button is pressed', async () => {
|
it("calls native start command when record button is pressed", async () => {
|
||||||
const mount = document.createElement('main');
|
const mount = document.createElement("main");
|
||||||
const client = createFakeClient();
|
const client = createFakeClient();
|
||||||
|
|
||||||
createTranscriptionApp(mount, client);
|
createTranscriptionApp(mount, client);
|
||||||
await flushPromises();
|
await flushPromises();
|
||||||
|
|
||||||
const button = mount.querySelector<HTMLButtonElement>('.primary-button');
|
const button = mount.querySelector<HTMLButtonElement>(".primary-button");
|
||||||
button?.click();
|
button?.click();
|
||||||
await flushPromises();
|
await flushPromises();
|
||||||
|
|
||||||
expect(client.calls).toContain('get_app_snapshot');
|
expect(client.calls).toContain("get_app_snapshot");
|
||||||
expect(client.calls).toContain('start_recording');
|
expect(client.calls).toContain("start_recording");
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
+4
-4
@@ -1,10 +1,10 @@
|
|||||||
import './styles.css';
|
import "./styles.css";
|
||||||
import { createTranscriptionApp } from './app';
|
import { createTranscriptionApp } from "./app";
|
||||||
|
|
||||||
const app = document.querySelector<HTMLElement>('#app');
|
const app = document.querySelector<HTMLElement>("#app");
|
||||||
|
|
||||||
if (!app) {
|
if (!app) {
|
||||||
throw new Error('Elemento #app não encontrado.');
|
throw new Error("Elemento #app não encontrado.");
|
||||||
}
|
}
|
||||||
|
|
||||||
createTranscriptionApp(app);
|
createTranscriptionApp(app);
|
||||||
+11
-11
@@ -1,14 +1,14 @@
|
|||||||
import { defineConfig } from 'vitest/config';
|
import { defineConfig } from "vitest/config";
|
||||||
|
|
||||||
export default defineConfig({
|
export default defineConfig({
|
||||||
clearScreen: false,
|
clearScreen: false,
|
||||||
server: {
|
server: {
|
||||||
host: '127.0.0.1',
|
host: "127.0.0.1",
|
||||||
port: 1420,
|
port: 1420,
|
||||||
strictPort: true,
|
strictPort: true,
|
||||||
},
|
},
|
||||||
envPrefix: ['VITE_', 'TAURI_'],
|
envPrefix: ["VITE_", "TAURI_"],
|
||||||
test: {
|
test: {
|
||||||
environment: 'jsdom',
|
environment: "jsdom",
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
Reference in new issue
Block a user