feat(wasm): port Ghostty's wasm32 build
Ports main_wasm.zig as crates/ghostty-wasm (cdylib exporting the Zig names: atlas_*, face_*, deferred_face_*, shaper_*, config_*), the web_canvas font face and shaper (backend selected on wasm32), os/wasm (logging, target, JS interop) and config/Wasm.zig. C-library dependencies (freetype, harfbuzz, fontconfig, onig, gettext, D-Bus, rustix) are target-gated. Like Zig's wasm build, link regex search (StringMap::search_iterator) is unavailable without Oniguruma; Collection/SharedGrid/harfbuzz are compiled out on wasm32. ghostty-os switches from forbid to deny unsafe_code for the JS import blocks. The JS import ABI is currently a documented handle-based interface with a reference host (js/ghostty_host.js); aligning it with zig-js's exact import names follows separately. Test Plan: - cargo build --target wasm32-unknown-unknown -p ghostty-font \ -p ghostty-config -p ghostty-terminal -p ghostty-vt -p ghostty-wasm - cargo test -p ghostty-wasm (node runs the module against a fake canvas)
This commit is contained in:
1 parent
0915f7b935
commit
d89691b0ce
33 files changed
+2866
-30
No files matched your search
@@ -3976,7 +3976,18 @@ impl Config {
|
||||
//
|
||||
// See: https://github.com/Vladimir-csp/xdg-terminal-exec
|
||||
{
|
||||
#[cfg(unix)]
|
||||
use std::os::unix::ffi::OsStrExt;
|
||||
#[cfg(not(unix))]
|
||||
trait OsStrExt {
|
||||
fn as_bytes(&self) -> &[u8];
|
||||
}
|
||||
#[cfg(not(unix))]
|
||||
impl OsStrExt for std::ffi::OsString {
|
||||
fn as_bytes(&self) -> &[u8] {
|
||||
self.as_encoded_bytes()
|
||||
}
|
||||
}
|
||||
let cargs: Vec<std::ffi::CString> = argv
|
||||
.iter()
|
||||
.filter_map(|a| std::ffi::CString::new(a.as_bytes()).ok())
|
||||
@@ -4619,22 +4630,13 @@ fn zig_io_error_name(err: &std::io::Error) -> String {
|
||||
}
|
||||
|
||||
fn file_kind_name(meta: &std::fs::Metadata) -> &'static str {
|
||||
use std::os::unix::fs::FileTypeExt;
|
||||
let ft = meta.file_type();
|
||||
if ft.is_dir() {
|
||||
"directory"
|
||||
} else if ft.is_symlink() {
|
||||
"sym_link"
|
||||
} else if ft.is_block_device() {
|
||||
"block_device"
|
||||
} else if ft.is_char_device() {
|
||||
"character_device"
|
||||
} else if ft.is_fifo() {
|
||||
"named_pipe"
|
||||
} else if ft.is_socket() {
|
||||
"unix_domain_socket"
|
||||
} else {
|
||||
"unknown"
|
||||
crate::theme::special_kind_name(ft)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user