This folder contains the Contract that defines how the C++ Backend and the Svelte Frontend communicate. This approach is inspired by tRPC, ensuring that both sides speak the same "language" with strong typing.
The definition lives in contract.ts.
These are actions triggered by the UI that execute in C++.
| Method | Description | Return |
|---|---|---|
openFileDialog() |
Opens a native file picker. | Promise<string> (File Path) |
loadPdf(path) |
Commands the backend to read a PDF file. | void |
translate(text, lang) |
Sends text to the C++ translation engine. | void |
These are events emitted by C++ that the UI listens to.
| Signal | Payload | Description |
|---|---|---|
pdfLoaded |
(data, pages) |
Triggered after loadPdf finishes processing. |
translationReady |
(orig, trans) |
Triggered when a translation result is available. |
errorOccurred |
(message) |
Triggered on backend-side errors. |
middlend/contract.ts.backend/bridge.h and add the corresponding Q_INVOKABLE method or Q_SIGNAL.backend/bridge.cpp.bridgeStore to call the new method.graph LR
subgraph "Frontend (Svelte)"
UI[App.svelte] --> Store[bridgeStore]
end
subgraph "middlend (Contract)"
Store -- typed calls --> Contract((contract.ts))
end
subgraph "Backend (Qt/C++)"
Contract -- QWebChannel --> QObj[Bridge Object]
end