1const Loader = @import("Loader.zig");
2const std = @import("std");
3
4pub fn main() !void {
5 var gpa: std.heap.GeneralPurposeAllocator(.{}) = .init;
6 const alloc = gpa.allocator();
7
8 const node = std.Progress.start(.{});
9 // defer node.end();
10
11 var cache = try std.fs.cwd().makeOpenPath(".cache", .{});
12 defer cache.close();
13
14 var loader = try Loader.init(.{
15 .allocator = alloc,
16 .progress = node,
17 .max_concurrent_downloads = 32,
18 .cache = cache,
19 });
20 defer loader.deinit();
21
22 const uri_text = "http://localhost:3000/src/loader/main.zig";
23 const sync = try loader.loadModuleSync(.{ .uri_text = uri_text });
24 switch (sync) {
25 .failed => |fail| {
26 std.debug.print("error: {}\n", .{fail});
27 std.debug.print("in {s}\n", .{uri_text});
28 },
29 .available => |data| {
30 std.debug.print("path_digest: 0x{s}\n", .{&std.fmt.bytesToHex(data.path_digest, .lower)});
31 std.debug.print("stat: {}\n", .{data.stat});
32 std.debug.print("{s}\n", .{data.contents});
33 },
34 }
35}