From c3cda5b7fee6e1d104811de7fd45c85a37efe663 Mon Sep 17 00:00:00 2001 From: CJ van den Berg Date: Wed, 26 Mar 2025 20:41:44 +0100 Subject: [PATCH] build: update thespian to use separate cbor package --- build.zig | 7 ++++++- build.zig.zon | 4 ++-- src/LSP.zig | 1 + src/Project.zig | 17 ++++++++++++++--- src/renderer/vaxis/renderer.zig | 5 +++++ src/shell.zig | 5 +++++ 6 files changed, 33 insertions(+), 6 deletions(-) diff --git a/build.zig b/build.zig index da52996..ac0c004 100644 --- a/build.zig +++ b/build.zig @@ -225,7 +225,12 @@ pub fn build_exe( }); const thespian_mod = thespian_dep.module("thespian"); - const cbor_mod = thespian_dep.module("cbor"); + + const cbor_dep = thespian_dep.builder.dependency("cbor", .{ + .target = target, + .optimize = optimize_deps, + }); + const cbor_mod = cbor_dep.module("cbor"); const tracy_dep = if (tracy_enabled) thespian_dep.builder.dependency("tracy", .{ .target = target, diff --git a/build.zig.zon b/build.zig.zon index 7d281a5..c41c109 100644 --- a/build.zig.zon +++ b/build.zig.zon @@ -15,8 +15,8 @@ .hash = "dizzy-1.0.0-AAAAAM1wAAAiDbx_6RwcVEOBk8p2XOu8t9WPNc3K7kBK", }, .thespian = .{ - .url = "https://github.com/neurocyte/thespian/archive/e3921691dc5d949ee38719251d67841f88dbabfd.tar.gz", - .hash = "thespian-0.0.1-owFOjsnnBgDTBCdPHQhp3Ir3hLZI5pVLOrlIa8JtGJAb", + .url = "https://github.com/neurocyte/thespian/archive/42a98a44e7590fd6e952b75523e5c0f4fa0e6c97.tar.gz", + .hash = "thespian-0.0.1-owFOjnUTBgBUlBtQ-SbN_6S7bXE6e2mKmCgk4A-RGBMA", }, .themes = .{ .url = "https://github.com/neurocyte/flow-themes/releases/download/master-59bf204551bcb238faddd06779063570e7e6d431/flow-themes.tar.gz", diff --git a/src/LSP.zig b/src/LSP.zig index 171bbb1..1f8666a 100644 --- a/src/LSP.zig +++ b/src/LSP.zig @@ -227,6 +227,7 @@ const Process = struct { UnsupportedType, ExitNormal, ExitUnexpected, + InvalidMapType, }); fn receive_safe(self: *Process, from: tp.pid_ref, m: tp.message) Error!void { diff --git a/src/Project.zig b/src/Project.zig index 2309c82..54b59a3 100644 --- a/src/Project.zig +++ b/src/Project.zig @@ -26,7 +26,7 @@ const Self = @This(); const OutOfMemoryError = error{OutOfMemory}; const SpawnError = (OutOfMemoryError || error{ThespianSpawnFailed}); -pub const InvalidMessageError = error{ InvalidMessage, InvalidMessageField, InvalidTargetURI }; +pub const InvalidMessageError = error{ InvalidMessage, InvalidMessageField, InvalidTargetURI, InvalidMapType }; pub const StartLspError = (error{ ThespianSpawnFailed, Timeout, InvalidLspCommand } || LspError || OutOfMemoryError || cbor.Error); pub const LspError = (error{ NoLsp, LspFailed } || OutOfMemoryError); pub const ClientError = (error{ClientFailed} || OutOfMemoryError); @@ -131,7 +131,7 @@ pub fn restore_state(self: *Self, data: []const u8) !void { var iter: []const u8 = data; _ = cbor.matchValue(&iter, tp.string) catch {}; _ = cbor.decodeArrayHeader(&iter) catch |e| switch (e) { - error.InvalidType => return self.restore_state_v0(data), + error.InvalidArrayType => return self.restore_state_v0(data), else => return tp.trace(tp.channel.debug, .{ "restore_state", "unknown format", data }), }; self.persistent = true; @@ -191,7 +191,18 @@ pub fn restore_state_v1(self: *Self, data: []const u8) !void { } } -pub fn restore_state_v0(self: *Self, data: []const u8) error{ OutOfMemory, IntegerTooLarge, IntegerTooSmall, InvalidType, TooShort }!void { +pub fn restore_state_v0(self: *Self, data: []const u8) error{ + OutOfMemory, + IntegerTooLarge, + IntegerTooSmall, + InvalidType, + TooShort, + InvalidFloatType, + InvalidArrayType, + InvalidPIntType, + JsonIncompatibleType, + NotAnObject, +}!void { tp.trace(tp.channel.debug, .{"restore_state_v0"}); defer self.sort_files_by_mtime(); var name: []const u8 = undefined; diff --git a/src/renderer/vaxis/renderer.zig b/src/renderer/vaxis/renderer.zig index 32af142..5cfb232 100644 --- a/src/renderer/vaxis/renderer.zig +++ b/src/renderer/vaxis/renderer.zig @@ -52,6 +52,11 @@ pub const Error = error{ CodepointTooLarge, TtyInitError, TtyWriteError, + InvalidFloatType, + InvalidArrayType, + InvalidPIntType, + JsonIncompatibleType, + NotAnObject, } || std.Thread.SpawnError; pub fn init(allocator: std.mem.Allocator, handler_ctx: *anyopaque, no_alternate: bool, _: *const fn (ctx: *anyopaque) void) Error!Self { diff --git a/src/shell.zig b/src/shell.zig index 05aa4d9..c4ee5ca 100644 --- a/src/shell.zig +++ b/src/shell.zig @@ -21,6 +21,11 @@ pub const Error = error{ IntegerTooSmall, InvalidType, TooShort, + InvalidFloatType, + InvalidArrayType, + InvalidPIntType, + JsonIncompatibleType, + NotAnObject, }; pub const OutputHandler = fn (context: usize, parent: tp.pid_ref, arg0: []const u8, output: []const u8) void;