Lightpanda: the headless browser designed for AI and automation
change how `--load-resources` are provided from CLI
Halil Durak3265d66052e1
diff --git a/src/Config.zig b/src/Config.zigindex b986066b7..676995c7c 100644--- a/src/Config.zig+++ b/src/Config.zig@@ -211,26 +211,10 @@ fn caPathValidator(}}-// Sub-resources the browser actually requests. A comma-separated list so-// more can be opted into individually as they land; only `image` fetches-// today.pub const LoadResources = packed struct(u1) {image: bool = false,};-fn loadResourcesValidator(_: Allocator, args: *std.process.Args.Iterator, target: *LoadResources) !void {- const resources = args.next() orelse return error.MissingArgument;-- var it = std.mem.splitScalar(u8, resources, ',');- while (it.next()) |resource| {- inline for (@typeInfo(LoadResources).@"struct".fields) |field| {- if (std.mem.eql(u8, field.name, resource)) {- @field(target, field.name) = true;- }- }- }-}-/// Common CLI args.const CommonOptions = .{.{ .name = "obey_robots", .type = bool },@@ -265,12 +249,7 @@ const CommonOptions = .{.{ .name = "disable_subframes", .type = bool },.{ .name = "disable_workers", .type = bool },.{ .name = "enable_external_stylesheets", .type = bool },- .{- .name = "load_resources",- .type = LoadResources,- .default = LoadResources{},- .validator = loadResourcesValidator,- },+ .{ .name = "load_resources", .type = LoadResources, .default = LoadResources{} },.{ .name = "v8_flags_unsafe", .type = ?[]const u8 },.{ .name = "v8_max_heap_mb", .type = ?u32 },.{ .name = "watchdog_ms", .type = ?u32 },diff --git a/src/help.zon b/src/help.zonindex a95baa04b..225e8cccb 100644--- a/src/help.zon+++ b/src/help.zon@@ -348,19 +348,14 @@\\ contribute to computed styles (and therefore to visibility checks like\\ display, visibility, opacity, pointer-events).\\ Defaults to false, except in agent mode with an LLM, where it is on.- \\ --load-resources <LIST>- \\ Comma-separated list of sub-resources to actually request.- \\ Defaults to empty, i.e. none of them.- \\ Allowed values: "image".- \\ "image" requests <img> sources so that load/error events reflect the- \\ real HTTP status, instead of load firing for any non-empty src. The- \\ request stops at the end of the response headers, so only a small- \\ image's body is ever transferred, and images are never decoded:- \\ naturalWidth/naturalHeight stay 0 either way.- \\ Requested images delay the window load event, and therefore- \\ --wait-until load. They are fetched at a lower priority than- \\ scripts, stylesheets and XHR, and never take a connection one of- \\ those is waiting for.+ \\ --load-resources <RESOURCE>+ \\ Sub-resource to actually request. Can be passed multiple times.+ \\ Defaults to requesting none of them.+ \\ Allowed values:+ \\ image <img> sources, so that load/error reflects the real+ \\ HTTP status. Only the response headers are read;+ \\ images are never decoded, so naturalWidth and+ \\ naturalHeight stay 0. Delays the window load event.\\ --http-cache-dir <PATH>\\ Directory used as a filesystem cache for network resources. Omitting\\ this disables caching.