From c3d0b84b7961ae26d2d654e7120821cc2d83d20d Mon Sep 17 00:00:00 2001 From: Gabriel Schneider Date: Mon, 24 Aug 2026 10:56:05 -0300 Subject: host: the core owns the event loop; every platform becomes a vtable of optional methods --- src/source_manifest.zig | 44 ++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 44 insertions(+) create mode 100644 src/source_manifest.zig (limited to 'src/source_manifest.zig') diff --git a/src/source_manifest.zig b/src/source_manifest.zig new file mode 100644 index 00000000..5de560ac --- /dev/null +++ b/src/source_manifest.zig @@ -0,0 +1,44 @@ +//! The virtual filesystem: pardes's own source, embedded, as an ALLOWLIST. +//! +//! This is the default filesystem — what a host that implements no file method +//! reads and writes, and the only one the browser has ever had. It replaced a +//! build-time generator that embedded every tracked `.zig` file: 64 files and +//! 2.4 MB of generated Zig, rediscovered on every consumer build because the +//! tracked set can change without any known input changing. +//! +//! An allowlist instead, for the reason the generator's own comment gave away: +//! nothing needs all of them. What earns a place here is a file that explains +//! how pardes works to someone reading it inside pardes — the core, the host +//! seam, the keymap, the build. `src/pardes.zig` alone is 722 KB of the total, +//! and it is the one file worth that: it IS the program. +//! +//! Paths are as a user would type them, repo-root-relative, which is what +//! `look` resolves a click against. + +pub const Source = struct { path: []const u8, contents: []const u8 }; + +pub const all = [_]Source{ + .{ .path = "build.zig", .contents = @embedFile("root-build.zig") }, + .{ .path = "build.zig.zon", .contents = @embedFile("root-build.zig.zon") }, + .{ .path = "src/pardes.zig", .contents = @embedFile("pardes.zig") }, + .{ .path = "src/host.zig", .contents = @embedFile("host.zig") }, + .{ .path = "src/config.zig", .contents = @embedFile("config.zig") }, + .{ .path = "src/main.zig", .contents = @embedFile("main.zig") }, + .{ .path = "src/builtins.zig", .contents = @embedFile("builtins.zig") }, + .{ .path = "src/grammar_manifest.zig", .contents = @embedFile("grammar_manifest.zig") }, + .{ .path = "src/source_manifest.zig", .contents = @embedFile("source_manifest.zig") }, + .{ .path = "src/CHANGELOG.md", .contents = @embedFile("CHANGELOG.md") }, +}; + +/// The written-file override wins, then the allowlist. Callers own no memory +/// here: every byte is static or lives in the Fallback that answered. +pub fn find(path: []const u8) ?[]const u8 { + for (all) |s| if (eql(s.path, path)) return s.contents; + return null; +} + +fn eql(a: []const u8, b: []const u8) bool { + if (a.len != b.len) return false; + for (a, b) |x, y| if (x != y) return false; + return true; +} -- cgit v1.3