build: update thespian to use separate cbor package

This commit is contained in:
CJ van den Berg 2025-03-26 20:41:44 +01:00
parent 6eaef79f43
commit c3cda5b7fe
Signed by: neurocyte
GPG key ID: 8EB1E1BB660E3FB9
6 changed files with 33 additions and 6 deletions

View file

@ -225,7 +225,12 @@ pub fn build_exe(
}); });
const thespian_mod = thespian_dep.module("thespian"); 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", .{ const tracy_dep = if (tracy_enabled) thespian_dep.builder.dependency("tracy", .{
.target = target, .target = target,

View file

@ -15,8 +15,8 @@
.hash = "dizzy-1.0.0-AAAAAM1wAAAiDbx_6RwcVEOBk8p2XOu8t9WPNc3K7kBK", .hash = "dizzy-1.0.0-AAAAAM1wAAAiDbx_6RwcVEOBk8p2XOu8t9WPNc3K7kBK",
}, },
.thespian = .{ .thespian = .{
.url = "https://github.com/neurocyte/thespian/archive/e3921691dc5d949ee38719251d67841f88dbabfd.tar.gz", .url = "https://github.com/neurocyte/thespian/archive/42a98a44e7590fd6e952b75523e5c0f4fa0e6c97.tar.gz",
.hash = "thespian-0.0.1-owFOjsnnBgDTBCdPHQhp3Ir3hLZI5pVLOrlIa8JtGJAb", .hash = "thespian-0.0.1-owFOjnUTBgBUlBtQ-SbN_6S7bXE6e2mKmCgk4A-RGBMA",
}, },
.themes = .{ .themes = .{
.url = "https://github.com/neurocyte/flow-themes/releases/download/master-59bf204551bcb238faddd06779063570e7e6d431/flow-themes.tar.gz", .url = "https://github.com/neurocyte/flow-themes/releases/download/master-59bf204551bcb238faddd06779063570e7e6d431/flow-themes.tar.gz",

View file

@ -227,6 +227,7 @@ const Process = struct {
UnsupportedType, UnsupportedType,
ExitNormal, ExitNormal,
ExitUnexpected, ExitUnexpected,
InvalidMapType,
}); });
fn receive_safe(self: *Process, from: tp.pid_ref, m: tp.message) Error!void { fn receive_safe(self: *Process, from: tp.pid_ref, m: tp.message) Error!void {

View file

@ -26,7 +26,7 @@ const Self = @This();
const OutOfMemoryError = error{OutOfMemory}; const OutOfMemoryError = error{OutOfMemory};
const SpawnError = (OutOfMemoryError || error{ThespianSpawnFailed}); 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 StartLspError = (error{ ThespianSpawnFailed, Timeout, InvalidLspCommand } || LspError || OutOfMemoryError || cbor.Error);
pub const LspError = (error{ NoLsp, LspFailed } || OutOfMemoryError); pub const LspError = (error{ NoLsp, LspFailed } || OutOfMemoryError);
pub const ClientError = (error{ClientFailed} || 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; var iter: []const u8 = data;
_ = cbor.matchValue(&iter, tp.string) catch {}; _ = cbor.matchValue(&iter, tp.string) catch {};
_ = cbor.decodeArrayHeader(&iter) catch |e| switch (e) { _ = 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 }), else => return tp.trace(tp.channel.debug, .{ "restore_state", "unknown format", data }),
}; };
self.persistent = true; 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"}); tp.trace(tp.channel.debug, .{"restore_state_v0"});
defer self.sort_files_by_mtime(); defer self.sort_files_by_mtime();
var name: []const u8 = undefined; var name: []const u8 = undefined;

View file

@ -52,6 +52,11 @@ pub const Error = error{
CodepointTooLarge, CodepointTooLarge,
TtyInitError, TtyInitError,
TtyWriteError, TtyWriteError,
InvalidFloatType,
InvalidArrayType,
InvalidPIntType,
JsonIncompatibleType,
NotAnObject,
} || std.Thread.SpawnError; } || std.Thread.SpawnError;
pub fn init(allocator: std.mem.Allocator, handler_ctx: *anyopaque, no_alternate: bool, _: *const fn (ctx: *anyopaque) void) Error!Self { pub fn init(allocator: std.mem.Allocator, handler_ctx: *anyopaque, no_alternate: bool, _: *const fn (ctx: *anyopaque) void) Error!Self {

View file

@ -21,6 +21,11 @@ pub const Error = error{
IntegerTooSmall, IntegerTooSmall,
InvalidType, InvalidType,
TooShort, TooShort,
InvalidFloatType,
InvalidArrayType,
InvalidPIntType,
JsonIncompatibleType,
NotAnObject,
}; };
pub const OutputHandler = fn (context: usize, parent: tp.pid_ref, arg0: []const u8, output: []const u8) void; pub const OutputHandler = fn (context: usize, parent: tp.pid_ref, arg0: []const u8, output: []const u8) void;