// ZPWR-FILE-BROWSER — ENGINEERING REPORT

Shared GUI component · host-agnostic vanilla-JS front end · pure-Rust fs_* crate · one source of truth for Audio-Haxor, traderview, ztranslator, zpwr-daw

Docs

>_EXECUTIVE SUMMARY

zpwr-file-browser is the shared multi-pane file browser of the MenkeTechnologies GUI stack — a host-agnostic vanilla-JS front end plus a pure-Rust filesystem crate, both extracted from Audio-Haxor so every app browses files from one source of truth. The front end is loaded as a classic script and calls a fixed set of invoke names on the host IPC object (window.zfbHost); each host supplies the filesystem backend.

The Rust crate ships those backend operations as 34 pure pub async fn functions (faithfully ported, no Tauri types), so it builds Tauri-free by default. Enabling the tauri cargo feature additively compiles 35 thin #[tauri::command] wrappers — one per pure fn, plus the fb_watcher_set watcher command — each named with the exact invoke name the front end expects. A parallel capi feature compiles the ffi module, exposing the same surface to non-Tauri (JUCE) hosts through the staticlib C ABI entry fb_invoke.

v0.1.0
Version
34
Pure fs_* fns
35
Tauri commands
4
Rust src files
2,226
Rust src lines
16
Direct deps
5,359
Front-end JS lines
4
Host apps

~ARCHITECTURE

One front end, one backend contract. The vanilla-JS browser is host-agnostic; the Rust crate provides the filesystem operations either natively (pure fns) or via the tauri-feature command wrappers. The directory watcher core is framework-agnostic and always compiled.

LayerImplementation
Front endwebui/file-browser.js (5,359 lines) + file-browser.css + the #tabFiles markup; multi-pane, sortable + resizable columns, fzf filter with matched-char highlight, color labels, tree sidebar, context menu, text/hex/image quicklook + preview pane, git status
Backend contractthe front end calls fixed invoke names on window.zfbHost.*; each method returns a Promise; unsupported optional capabilities resolve to a neutral value (never throw) so rows/previews degrade gracefully
Pure Rust corecrate/src/lib.rs — 34 pub async fn filesystem functions returning Result<T, String>, no Tauri types; ported verbatim from Audio-Haxor's command bodies with the Tauri layer stripped
Tauri command layercrate/src/commands.rs — 35 thin #[tauri::command] wrappers (each awaits its pure counterpart), compiled only under the additive tauri feature; param names mirror the pure fns so Tauri's camelCase→snake_case arg mapping resolves
C ABI layercrate/src/ffi.rs — the staticlib C ABI for non-Tauri (JUCE) hosts, compiled under the additive capi feature; one entry fb_invoke(cmd, args_json) dispatches by name into the pure fns and returns a JSON envelope, with fb_string_free to release results
Watchercrate/src/fb_watcher.rs — framework-agnostic WatcherSession; notify-based, non-recursive, 300 ms-debounced single-directory watch; canonicalizes the path and hands it back; always compiled (no Tauri/JUCE types)
BuildCargo crate-type = ["rlib", "staticlib"], publish = false; cargo build (no features) stays Tauri-free; --features tauri adds the command layer; --features capi adds the staticlib C ABI

&FILESYSTEM SURFACE

34 pure functions in lib.rs, mirrored by 35 command wrappers in commands.rs (the extra wrapper is fb_watcher_set). Grouped by role:

GroupFunctions
List / inspectfs_list_dir · fs_list_subdirs · fs_get_info · fs_folder_size · fs_disk_usage · fs_xattrs · fs_git_status
Create / modifyfs_create_dir · fs_create_file · fs_touch · fs_copy_path · fs_duplicate · fs_make_alias · fs_chmod · fs_symlink_retarget · rename_file
Deletedelete_file · move_to_trash · fs_secure_delete
Read / previewfs_read_head · fs_read_head_bytes · fs_read_file_base64 · fs_write_file_base64 · fs_read_file_bytes
Search / comparefs_grep · fs_find_duplicates · fs_compare_dirs · fs_diff · fs_hash
Archivefs_compress (zip) · fs_extract (.zip / .tar / .tar.gz / .tgz / .7z)
Open / runfs_open_in_editor · fs_open_terminal · fs_run_program
Watch (command-only)fb_watcher_set — wraps fb_watcher::WatcherSession; emits file-browser-change with { "dir": canonical }

Return types serialize as camelCase JSON via serde: FsInfo, FsHashResult, GrepMatch, DiskUsage, DirCompareResult, DiffOp, DuplicateGroup, XattrEntry, FolderWalkResult. Unix-only operations (fs_chmod, fs_xattrs, fs_symlink_retarget, fs_run_program) compile a cfg(not(unix)) fallback that returns an error or empty result.


/DIRECTORY WATCHER

WatcherSession is a single-directory, non-recursive, notify-based watcher with a 300 ms debounce (bursty operations collapse into one reload). watch(dir, on_change) stops any prior watch, canonicalizes dir, starts watching, and fires the injected on_change(canonical) callback on each debounced change; stop() drops the watcher (idempotent). The core pulls in no Tauri or JUCE types — the framework wiring lives in the tauri-feature fb_watcher_set command, which emits AppHandle::emit("file-browser-change", { "dir": canonical }) — the exact event and payload the front end consumes.


$DEPENDENCIES

16 direct dependencies in [dependencies], plus xattr under the cfg(unix) target. tauri and futures are optional (pulled in only by the tauri and capi features respectively).

DependencyRole
serde / serde_jsonreturn-type serialization (camelCase JSON; preserve_order)
chronomtime / ctime formatting in directory listings
sha2SHA-256 for fs_hash, dedup and dir-compare fingerprints
base64base64 file reads for image quicklook (fs_read_file_base64)
similarMyers / Patience text diff for fs_diff
zip / tar / flate2 / sevenz-rust2archive read + write (.zip, .tar, .tar.gz/.tgz, .7z)
filetimecross-platform atime/mtime set for fs_touch
sysinfodisk total/free for fs_disk_usage
trashOS trash (recoverable delete) for move_to_trash
notifyfilesystem watcher backend (FSEvents / inotify, poll fallback)
xattr (unix)extended attributes for fs_xattrs
tauri (optional)command layer — only compiled under the tauri feature
futures (optional)minimal block_on executor driving the sync-bodied fs_* fns from the C ABI — only compiled under the capi feature

+CI GATES

GateCommand
fmtcargo fmt --all --check
clippycargo clippy --all-targets -- -D warnings
docRUSTDOCFLAGS=-D warnings cargo doc --no-deps
testcargo test --verbose (headless; the watcher tests scan temp dirs)

The umbrella MenkeTechnologiesMeta repo additionally pins this component's metadata across its gate suite — LICENSE present + canonical MIT text, authors field, and the house docs gates that this report and the docs page satisfy.


#PROJECT METADATA

ItemValue
Version0.1.0
LicenseMIT
Crate typerlib + staticlib C ABI (publish = false); tauri and capi features additive
Rust source4 files, 2,226 lines (lib.rs, commands.rs, fb_watcher.rs, ffi.rs)
Front endfile-browser.js (5,359), file-browser.css (1,876), file-browser.html (168)
HostsAudio-Haxor, traderview, ztranslator (Tauri), zpwr-daw (JUCE)
AuthorMenkeTechnologies
Repositorygithub.com/MenkeTechnologies/zpwr-file-browser
Meta umbrellaMenkeTechnologiesMeta