╭─────────────╮ │scroll to top│ ╰─────────────╯ ╭ main_wasm.zig ────────────────────────────────────────────────╮ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ ╰───────────────────────────────────────────────────────────────╯
╭────╮ ╭ clone ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ╮ │http│ ssh │ │ ╰────╯ ╰ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ╯
80 } 81 82 extern fn _consoleLog(arg: [*]const u8, len: u32) void; 83 extern fn _setHtml(arg: [*]const u8, len: u32) void; 84 85 /// js calls this first to get a wasm pointer it can write the page json into. 86 export fn _alloc(len: u32) ?[*]u8 { 87 const slice = allocator.alloc(u8, len) catch return null; 88 return slice.ptr; 89 } 90 91 export fn _start(json_ptr: [*]u8, json_len: u32, max_width: u32) void { 92 const json = json_ptr[0..json_len]; 93 defer allocator.free(json); 94 start(json, max_width) catch |err| { 95 var buf: [256]u8 = undefined; 96 const str = std.fmt.bufPrint(&buf, "start: {}", .{err}) catch unreachable; 97 consoleLog(str); 98 }; 99 } 100 101 export fn _tick(max_width: u32) bool { 102 tick(max_width) catch |err| { 103 var buf: [256]u8 = undefined; 104 const str = std.fmt.bufPrint(&buf, "tick: {}", .{err}) catch unreachable; 105 consoleLog(str); 106 return false; 107 }; 108 return true; 109 } 110 111 export fn _onKeyDown(key_code: u32) void { 112 onKeyDown(key_code) catch |err| { 113 var buf: [256]u8 = undefined; 114 const str = std.fmt.bufPrint(&buf, "onKeyDown: {}", .{err}) catch unreachable; 115 consoleLog(str); 116 }; 117 } 118 119 export fn _onMouseClick(focus_id: u32) void { 120 onMouseClick(focus_id) catch |err| { 121 var buf: [256]u8 = undefined; 122 const str = std.fmt.bufPrint(&buf, "onMouseClick: {}", .{err}) catch unreachable; 123 consoleLog(str); 124 }; 125 } 126