ZLATEX // ENGINEERING REPORT

// host structure · shared modules · hook points · tests

Docs GitHub

zlatex is a thin Tauri v2 host: the window, the native menu bar, the shared embeds and the app shell. Every feature is a command on the zlatex-core engine, and the editor UI is that crate's mountable view, vendored into frontend/ at build time.

Host structure

PieceWhat it does
app/src-tauri/src/main.rsManages the engine (bundled math face included), registers the shared file-browser and terminal commands, the powerline stats command and the stryke hook runner, and adds the host-only surfaces: the native save/open panels and printing
native_menu.rsApp / Edit / File / Equation / Insert / View / Window / Help; every id round-trips to the same handler the ⌘K palette calls
bus.rsThe GUI Automation Bus socket, so App::open("zlatex") can drive the app; engine commands route Rust-direct, appShell verbs forward into the webview
stryke_lsp.rs · sidecar.rsRuns the app's stryke lifecycle hooks and backs the hooks editor's language server
main.rs · recent documentsrecent_documents / remember_recent / clear_recents / open_recent_path, backing Open Recent (⇧⌘O) out of a list in the host's app-config dir rather than WebView storage, with vanished files dropped
frontend/index.html · main.jsMounts the one ZGui.appShell, feeds it the document commands — typeset, outline, Open Recent, TeX Live packages, export — and wires the file / print / export menu actions
frontend/zlatex-view.js · preview.jsThe editor + document view itself, with the zpdf viewer bar under the pages — vendored from crates/zlatex-core/frontend, never forked

Where the engine ends and the host begins

Typesetting — text mode, hyphenation, line breaking, page building, footnotes, floats, \input / \include splicing, references, math — plus the symbol palettes, the library, the TeX Live package manager and the export renderers all live in the engine and are reachable as JSON commands. The host owns only what the engine cannot do: show a save panel and write the chosen file (zl_export_to_file), show an open panel and read a .tex file or recover the source from a PDF this app wrote (open_equation_file), keep the recent-documents list on disk (recent_documents and friends), and render for the native macOS print panel (print_report).

Shared modules it mounts

ModuleRole
zgui-coreThe widget toolkit and the app shell (palette, settings, colourscheme, splash, powerline)
zpwr-embed-terminalThe PTY terminal pane (Ctrl+` / ⌘T)
zpwr-file-browserThe multi-pane file browser overlay (⌘B) over the host's fs backend
zpwr-hooks-editorThe Monaco editor — twice: the stryke hooks overlay (⌘⇧H), and the document pane itself in LaTeX mode
zpwr-i18nThe interface localization runtime
zgui-bridge · zwire-hostThe automation-bus socket and the live system stats behind the powerline bar

One editor, two grammars

The document pane is not a second editor. It is the same shared zpwr-hooks-editor bundle every app in the family ships, created with language: 'latex' — a LaTeX Monarch grammar and snippet completion instead of the stryke grammar and its language server. The LaTeX mode knows the document it is editing: inside \ref{…} it completes from the \labels the file defines, inside \cite{…} from its \bibitem keys, and its sectioning is registered as document symbols. The theme, the vim and emacs keymaps and the Monaco instance are shared; the handle adds insert, selectRange and onSelection, which is what maps the preview back to the source, plus a bindKey that takes CmdOrCtrl+Shift+O back from Monaco's own Go to Symbol so Open Recent fires with the editor focused.

Hook points

The app publishes three stryke hook points — equation.typeset, equation.exported and equation.saved — so a script can post-process an exported file, index what was saved, or react to a formula being set. They are edited in the shared hooks overlay and run through the app's stryke runner.

Test status

The engine's suite runs unit tests metric-less (structure only: spacing table, style transitions, script placement, line-breaker behaviour, hyphenation against tex \showhyphens, parser totality) plus integration tests against the vendored Latin Modern faces, which pin the OpenType MATH field mapping against an independent read of the same table, typeset a whole paper into pages with no line past the right margin and no unresolved reference, and check that exports are outline-based and that a multi-page PDF's source round-trips. The host itself is thin by design and carries no logic worth a second suite.