From 6784388a4239fa85cb1bc3c5dd1766a292021c8b Mon Sep 17 00:00:00 2001 From: Halil Durak Date: Thu, 20 Nov 2025 20:05:01 +0300 Subject: [PATCH] initial `Blob` support on zigdom --- src/browser/js/bridge.zig | 2 ++ src/browser/webapi/File.zig | 44 ++++++++++++++++++++++++++++++++ src/browser/webapi/file/Blob.zig | 39 ++++++++++++++++++++++++++++ 3 files changed, 85 insertions(+) create mode 100644 src/browser/webapi/File.zig create mode 100644 src/browser/webapi/file/Blob.zig diff --git a/src/browser/js/bridge.zig b/src/browser/js/bridge.zig index 4319df25..76fcc7be 100644 --- a/src/browser/js/bridge.zig +++ b/src/browser/js/bridge.zig @@ -564,4 +564,6 @@ pub const JsApis = flattenTypes(&.{ @import("../webapi/IntersectionObserver.zig"), @import("../webapi/CustomElementRegistry.zig"), @import("../webapi/ResizeObserver.zig"), + @import("../webapi/file/Blob.zig"), + @import("../webapi/File.zig"), }); diff --git a/src/browser/webapi/File.zig b/src/browser/webapi/File.zig new file mode 100644 index 00000000..64614531 --- /dev/null +++ b/src/browser/webapi/File.zig @@ -0,0 +1,44 @@ +// 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 std = @import("std"); + +const Blob = @import("file/Blob.zig"); +const js = @import("../js/js.zig"); + +const File = @This(); + +/// `File` inherits `Blob`. +_proto: *Blob, + +// TODO: Implement File API. +pub fn init() File { + return .{ ._proto = undefined }; +} + +pub const JsApi = struct { + pub const bridge = js.Bridge(File); + + pub const Meta = struct { + pub const name = "File"; + pub const prototype_chain = bridge.prototypeChain(); + pub var class_id: bridge.ClassId = undefined; + }; + + pub const constructor = bridge.constructor(File.init, .{}); +}; diff --git a/src/browser/webapi/file/Blob.zig b/src/browser/webapi/file/Blob.zig new file mode 100644 index 00000000..f7c4bb10 --- /dev/null +++ b/src/browser/webapi/file/Blob.zig @@ -0,0 +1,39 @@ +// 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 std = @import("std"); + +const js = @import("../../js/js.zig"); + +const Blob = @This(); + +pub fn init() Blob { + return .{}; +} + +pub const JsApi = struct { + pub const bridge = js.Bridge(Blob); + + pub const Meta = struct { + pub const name = "Blob"; + pub const prototype_chain = bridge.prototypeChain(); + pub var class_id: bridge.ClassId = undefined; + }; + + pub const constructor = bridge.constructor(Blob.init, .{}); +};