From a19a125aecea3bed6a1cbed6439991dbc0c146e8 Mon Sep 17 00:00:00 2001 From: Karl Seguin Date: Thu, 29 Jan 2026 19:44:10 +0800 Subject: [PATCH] Remove unused import And a few unused functions --- src/browser/Page.zig | 1 - src/browser/Scheduler.zig | 3 +- src/browser/URL.zig | 3 +- src/browser/js/Caller.zig | 2 - src/browser/js/Context.zig | 1 - src/browser/js/Function.zig | 4 +- src/browser/js/Name.zig | 24 ------------ src/browser/js/Object.zig | 6 +-- src/browser/js/js.zig | 4 +- src/browser/reflect.zig | 38 +------------------ src/browser/webapi/Crypto.zig | 2 - .../webapi/CustomElementDefinition.zig | 3 +- src/browser/webapi/DOMParser.zig | 3 +- src/browser/webapi/Document.zig | 4 +- src/browser/webapi/element/Html.zig | 3 +- .../navigation/NavigationHistoryEntry.zig | 16 +------- src/browser/webapi/selector/Parser.zig | 3 +- src/cdp/AXNode.zig | 5 +-- src/cdp/domains/page.zig | 1 - src/string.zig | 3 +- 20 files changed, 15 insertions(+), 114 deletions(-) delete mode 100644 src/browser/js/Name.zig diff --git a/src/browser/Page.zig b/src/browser/Page.zig index d5dd28f3..9632ef2a 100644 --- a/src/browser/Page.zig +++ b/src/browser/Page.zig @@ -276,7 +276,6 @@ fn reset(self: *Page, comptime initializing: bool) !void { self._arena_pool_leak_track.clearRetainingCapacity(); } - // We force a garbage collection between page navigations to keep v8 // memory usage as low as possible. self._session.browser.env.memoryPressureNotification(.moderate); diff --git a/src/browser/Scheduler.zig b/src/browser/Scheduler.zig index 41a69484..c3246124 100644 --- a/src/browser/Scheduler.zig +++ b/src/browser/Scheduler.zig @@ -1,4 +1,4 @@ -// Copyright (C) 2023-2025 Lightpanda (Selecy SAS) +// Copyright (C) 2023-2026 Lightpanda (Selecy SAS) // // Francis Bouvier // Pierre Tachoire @@ -19,7 +19,6 @@ const std = @import("std"); const builtin = @import("builtin"); -const js = @import("js/js.zig"); const log = @import("../log.zig"); const milliTimestamp = @import("../datetime.zig").milliTimestamp; diff --git a/src/browser/URL.zig b/src/browser/URL.zig index 356d2d55..d36673cc 100644 --- a/src/browser/URL.zig +++ b/src/browser/URL.zig @@ -1,4 +1,4 @@ -// Copyright (C) 2023-2025 Lightpanda (Selecy SAS) +// Copyright (C) 2023-2026 Lightpanda (Selecy SAS) // // Francis Bouvier // Pierre Tachoire @@ -17,7 +17,6 @@ // along with this program. If not, see . const std = @import("std"); -const lp = @import("lightpanda"); const Allocator = std.mem.Allocator; const ResolveOpts = struct { diff --git a/src/browser/js/Caller.zig b/src/browser/js/Caller.zig index 1eb160ba..7d0b5186 100644 --- a/src/browser/js/Caller.zig +++ b/src/browser/js/Caller.zig @@ -23,12 +23,10 @@ const string = @import("../../string.zig"); const Page = @import("../Page.zig"); const js = @import("js.zig"); -const bridge = @import("bridge.zig"); const Context = @import("Context.zig"); const TaggedOpaque = @import("TaggedOpaque.zig"); const v8 = js.v8; -const Allocator = std.mem.Allocator; const ArenaAllocator = std.heap.ArenaAllocator; const CALL_ARENA_RETAIN = 1024 * 16; diff --git a/src/browser/js/Context.zig b/src/browser/js/Context.zig index 648f6de3..8a6063e2 100644 --- a/src/browser/js/Context.zig +++ b/src/browser/js/Context.zig @@ -22,7 +22,6 @@ const log = @import("../../log.zig"); const js = @import("js.zig"); const bridge = @import("bridge.zig"); -const TaggedOpaque = @import("TaggedOpaque.zig"); const Page = @import("../Page.zig"); const ScriptManager = @import("../ScriptManager.zig"); diff --git a/src/browser/js/Function.zig b/src/browser/js/Function.zig index f30508a6..2038deee 100644 --- a/src/browser/js/Function.zig +++ b/src/browser/js/Function.zig @@ -1,4 +1,4 @@ -// Copyright (C) 2023-2025 Lightpanda (Selecy SAS) +// Copyright (C) 2023-2026 Lightpanda (Selecy SAS) // // Francis Bouvier // Pierre Tachoire @@ -22,8 +22,6 @@ const v8 = js.v8; const log = @import("../../log.zig"); -const Allocator = std.mem.Allocator; - const Function = @This(); local: *const js.Local, diff --git a/src/browser/js/Name.zig b/src/browser/js/Name.zig deleted file mode 100644 index 45904d35..00000000 --- a/src/browser/js/Name.zig +++ /dev/null @@ -1,24 +0,0 @@ -// Copyright (C) 2023-2025 Lightpanda (Selecy SAS) -// -// Francis Bouvier -// Pierre Tachoire -// -// This program is free software: you can redistribute it and/or modify -// it under the terms of the GNU Affero General Public License as -// published by the Free Software Foundation, either version 3 of the -// License, or (at your option) any later version. -// -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU Affero General Public License for more details. -// -// You should have received a copy of the GNU Affero General Public License -// along with this program. If not, see . - -const js = @import("js.zig"); -const v8 = js.v8; - -const Name = @This(); - -handle: *const v8.Name, diff --git a/src/browser/js/Object.zig b/src/browser/js/Object.zig index 1306234c..2cd7d243 100644 --- a/src/browser/js/Object.zig +++ b/src/browser/js/Object.zig @@ -1,4 +1,4 @@ -// Copyright (C) 2023-2025 Lightpanda (Selecy SAS) +// Copyright (C) 2023-2026 Lightpanda (Selecy SAS) // // Francis Bouvier // Pierre Tachoire @@ -22,10 +22,6 @@ const v8 = js.v8; const IS_DEBUG = @import("builtin").mode == .Debug; -const Context = @import("Context.zig"); - -const Allocator = std.mem.Allocator; - const Object = @This(); local: *const js.Local, diff --git a/src/browser/js/js.zig b/src/browser/js/js.zig index ee3c8009..bca8ee50 100644 --- a/src/browser/js/js.zig +++ b/src/browser/js/js.zig @@ -1,4 +1,4 @@ -// Copyright (C) 2023-2025 Lightpanda (Selecy SAS) +// Copyright (C) 2023-2026 Lightpanda (Selecy SAS) // // Francis Bouvier // Pierre Tachoire @@ -19,7 +19,6 @@ const std = @import("std"); pub const v8 = @import("v8").c; -const log = @import("../../log.zig"); const string = @import("../../string.zig"); pub const Env = @import("Env.zig"); @@ -34,7 +33,6 @@ pub const Platform = @import("Platform.zig"); pub const Isolate = @import("Isolate.zig"); pub const HandleScope = @import("HandleScope.zig"); -pub const Name = @import("Name.zig"); pub const Value = @import("Value.zig"); pub const Array = @import("Array.zig"); pub const String = @import("String.zig"); diff --git a/src/browser/reflect.zig b/src/browser/reflect.zig index ad0c54be..d1bd30c2 100644 --- a/src/browser/reflect.zig +++ b/src/browser/reflect.zig @@ -1,4 +1,4 @@ -// Copyright (C) 2023-2025 Lightpanda (Selecy SAS) +// Copyright (C) 2023-2026 Lightpanda (Selecy SAS) // // Francis Bouvier // Pierre Tachoire @@ -16,8 +16,6 @@ // You should have received a copy of the GNU Affero General Public License // along with this program. If not, see . -const std = @import("std"); - // Gets the Parent of child. // HtmlElement.of(script) -> *HTMLElement pub fn Struct(comptime T: type) type { @@ -28,37 +26,3 @@ pub fn Struct(comptime T: type) type { else => unreachable, }; } - -// Creates an enum of N enums. Doesn't perserve their underlying integer -pub fn mergeEnums(comptime enums: []const type) type { - const field_count = blk: { - var count: usize = 0; - inline for (enums) |e| { - count += @typeInfo(e).@"enum".fields.len; - } - break :blk count; - }; - - var i: usize = 0; - var fields: [field_count]std.builtin.Type.EnumField = undefined; - for (enums) |e| { - for (@typeInfo(e).@"enum".fields) |f| { - fields[i] = .{ - .name = f.name, - .value = i, - }; - i += 1; - } - } - - return @Type(.{ .@"enum" = .{ - .decls = &.{}, - .tag_type = blk: { - if (field_count <= std.math.maxInt(u8)) break :blk u8; - if (field_count <= std.math.maxInt(u16)) break :blk u16; - unreachable; - }, - .fields = &fields, - .is_exhaustive = true, - } }); -} diff --git a/src/browser/webapi/Crypto.zig b/src/browser/webapi/Crypto.zig index cd482c2c..89324695 100644 --- a/src/browser/webapi/Crypto.zig +++ b/src/browser/webapi/Crypto.zig @@ -19,8 +19,6 @@ const std = @import("std"); const js = @import("../js/js.zig"); -const Page = @import("../Page.zig"); - const SubtleCrypto = @import("SubtleCrypto.zig"); const Crypto = @This(); diff --git a/src/browser/webapi/CustomElementDefinition.zig b/src/browser/webapi/CustomElementDefinition.zig index de802f12..c89b942a 100644 --- a/src/browser/webapi/CustomElementDefinition.zig +++ b/src/browser/webapi/CustomElementDefinition.zig @@ -1,4 +1,4 @@ -// Copyright (C) 2023-2025 Lightpanda (Selecy SAS) +// Copyright (C) 2023-2026 Lightpanda (Selecy SAS) // // Francis Bouvier // Pierre Tachoire @@ -20,7 +20,6 @@ const std = @import("std"); const String = @import("../../string.zig").String; const js = @import("../js/js.zig"); -const Page = @import("../Page.zig"); const Element = @import("Element.zig"); const CustomElementDefinition = @This(); diff --git a/src/browser/webapi/DOMParser.zig b/src/browser/webapi/DOMParser.zig index 30f8bf33..d386794a 100644 --- a/src/browser/webapi/DOMParser.zig +++ b/src/browser/webapi/DOMParser.zig @@ -1,4 +1,4 @@ -// Copyright (C) 2023-2025 Lightpanda (Selecy SAS) +// Copyright (C) 2023-2026 Lightpanda (Selecy SAS) // // Francis Bouvier // Pierre Tachoire @@ -26,7 +26,6 @@ const Parser = @import("../parser/Parser.zig"); const HTMLDocument = @import("HTMLDocument.zig"); const XMLDocument = @import("XMLDocument.zig"); const Document = @import("Document.zig"); -const ProcessingInstruction = @import("../webapi/cdata/ProcessingInstruction.zig"); const DOMParser = @This(); diff --git a/src/browser/webapi/Document.zig b/src/browser/webapi/Document.zig index 17b2639b..f428b1f1 100644 --- a/src/browser/webapi/Document.zig +++ b/src/browser/webapi/Document.zig @@ -1,4 +1,4 @@ -// Copyright (C) 2023-2025 Lightpanda (Selecy SAS) +// Copyright (C) 2023-2026 Lightpanda (Selecy SAS) // // Francis Bouvier // Pierre Tachoire @@ -30,8 +30,6 @@ const Location = @import("Location.zig"); const Parser = @import("../parser/Parser.zig"); const collections = @import("collections.zig"); const Selector = @import("selector/Selector.zig"); -const NodeFilter = @import("NodeFilter.zig"); -const DocumentType = @import("DocumentType.zig"); const DOMTreeWalker = @import("DOMTreeWalker.zig"); const DOMNodeIterator = @import("DOMNodeIterator.zig"); const DOMImplementation = @import("DOMImplementation.zig"); diff --git a/src/browser/webapi/element/Html.zig b/src/browser/webapi/element/Html.zig index 639231b5..3844275b 100644 --- a/src/browser/webapi/element/Html.zig +++ b/src/browser/webapi/element/Html.zig @@ -1,4 +1,4 @@ -// Copyright (C) 2023-2025 Lightpanda (Selecy SAS) +// Copyright (C) 2023-2026 Lightpanda (Selecy SAS) // // Francis Bouvier // Pierre Tachoire @@ -17,7 +17,6 @@ // along with this program. If not, see . const std = @import("std"); -const lp = @import("lightpanda"); const js = @import("../../js/js.zig"); const reflect = @import("../../reflect.zig"); diff --git a/src/browser/webapi/navigation/NavigationHistoryEntry.zig b/src/browser/webapi/navigation/NavigationHistoryEntry.zig index af006702..6ab9b6b6 100644 --- a/src/browser/webapi/navigation/NavigationHistoryEntry.zig +++ b/src/browser/webapi/navigation/NavigationHistoryEntry.zig @@ -1,4 +1,4 @@ -// Copyright (C) 2023-2025 Lightpanda (Selecy SAS) +// Copyright (C) 2023-2026 Lightpanda (Selecy SAS) // // Francis Bouvier // Pierre Tachoire @@ -33,20 +33,6 @@ _key: []const u8, _url: ?[:0]const u8, _state: NavigationState, -// fn asEventTarget(self: *NavigationHistoryEntry) *EventTarget { -// return self._proto.?.asEventTarget(); -// } - -// pub fn onRemovePage(self: *NavigationHistoryEntry) void { -// self._proto = null; -// } - -// pub fn onNewPage(self: *NavigationHistoryEntry, page: *Page) !void { -// self._proto = try page._factory.eventTarget( -// NavigationHistoryEntryEventTarget{ ._proto = undefined }, -// ); -// } - pub fn id(self: *const NavigationHistoryEntry) []const u8 { return self._id; } diff --git a/src/browser/webapi/selector/Parser.zig b/src/browser/webapi/selector/Parser.zig index c03f8483..a594f66f 100644 --- a/src/browser/webapi/selector/Parser.zig +++ b/src/browser/webapi/selector/Parser.zig @@ -1,4 +1,4 @@ -// Copyright (C) 2023-2025 Lightpanda (Selecy SAS) +// Copyright (C) 2023-2026 Lightpanda (Selecy SAS) // // Francis Bouvier // Pierre Tachoire @@ -17,7 +17,6 @@ // along with this program. If not, see . const std = @import("std"); -const String = @import("../../../string.zig").String; const Page = @import("../../Page.zig"); diff --git a/src/cdp/AXNode.zig b/src/cdp/AXNode.zig index 272003a6..487e79ad 100644 --- a/src/cdp/AXNode.zig +++ b/src/cdp/AXNode.zig @@ -17,16 +17,15 @@ // along with this program. If not, see . const std = @import("std"); -const Allocator = std.mem.Allocator; const jsonStringify = std.json.Stringify; const log = @import("../log.zig"); const Page = @import("../browser/Page.zig"); const DOMNode = @import("../browser/webapi/Node.zig"); -const URL = @import("../browser/URL.zig"); + +const Node = @import("Node.zig"); const AXNode = @This(); -const Node = @import("Node.zig"); // Need a custom writer, because we can't just serialize the node as-is. // Sometimes we want to serializ the node without chidren, sometimes with just diff --git a/src/cdp/domains/page.zig b/src/cdp/domains/page.zig index de368821..a726cc97 100644 --- a/src/cdp/domains/page.zig +++ b/src/cdp/domains/page.zig @@ -25,7 +25,6 @@ const Page = @import("../../browser/Page.zig"); const timestampF = @import("../../datetime.zig").timestamp; const Notification = @import("../../Notification.zig"); -const v8 = js.v8; const Allocator = std.mem.Allocator; pub fn processMessage(cmd: anytype) !void { diff --git a/src/string.zig b/src/string.zig index e0950784..bbbc374a 100644 --- a/src/string.zig +++ b/src/string.zig @@ -1,4 +1,4 @@ -// Copyright (C) 2023-2025 Lightpanda (Selecy SAS) +// Copyright (C) 2023-2026 Lightpanda (Selecy SAS) // // Francis Bouvier // Pierre Tachoire @@ -17,7 +17,6 @@ // along with this program. If not, see . const std = @import("std"); -const js = @import("browser/js/js.zig"); const Allocator = std.mem.Allocator; const M = @This();