From 448386e52bec358466c5da1874e812be8de70884 Mon Sep 17 00:00:00 2001 From: Pierre Tachoire Date: Wed, 11 Mar 2026 22:21:41 +0100 Subject: [PATCH] Add FileList Web API stub MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Next.js hydration references FileList as a global for feature detection. Register a minimal stub (length=0, item()→null) so the type exists in the global scope and the reference check doesn't throw. --- src/browser/js/bridge.zig | 1 + src/browser/webapi/FileList.zig | 28 ++++++++++++++++++++++++++++ 2 files changed, 29 insertions(+) create mode 100644 src/browser/webapi/FileList.zig diff --git a/src/browser/js/bridge.zig b/src/browser/js/bridge.zig index f95329dc..cf6e999e 100644 --- a/src/browser/js/bridge.zig +++ b/src/browser/js/bridge.zig @@ -885,6 +885,7 @@ pub const JsApis = flattenTypes(&.{ @import("../webapi/IdleDeadline.zig"), @import("../webapi/Blob.zig"), @import("../webapi/File.zig"), + @import("../webapi/FileList.zig"), @import("../webapi/FileReader.zig"), @import("../webapi/Screen.zig"), @import("../webapi/VisualViewport.zig"), diff --git a/src/browser/webapi/FileList.zig b/src/browser/webapi/FileList.zig new file mode 100644 index 00000000..7688002b --- /dev/null +++ b/src/browser/webapi/FileList.zig @@ -0,0 +1,28 @@ +const js = @import("../js/js.zig"); + +const FileList = @This(); + +/// Padding to avoid zero-size struct, which causes identity_map pointer collisions. +_pad: bool = false, + +pub fn getLength(_: *const FileList) u32 { + return 0; +} + +pub fn item(_: *const FileList, _: u32) ?*@import("File.zig") { + return null; +} + +pub const JsApi = struct { + pub const bridge = js.Bridge(FileList); + + pub const Meta = struct { + pub const name = "FileList"; + pub const prototype_chain = bridge.prototypeChain(); + pub var class_id: bridge.ClassId = undefined; + pub const empty_with_no_proto = true; + }; + + pub const length = bridge.accessor(FileList.getLength, null, .{}); + pub const item = bridge.function(FileList.item, .{}); +};