mirror of
https://github.com/lightpanda-io/browser.git
synced 2026-02-04 14:33:47 +00:00
Add Plugin and PluginArray placeholders
This commit is contained in:
@@ -761,6 +761,7 @@ pub const JsApis = flattenTypes(&.{
|
|||||||
@import("../webapi/URL.zig"),
|
@import("../webapi/URL.zig"),
|
||||||
@import("../webapi/Window.zig"),
|
@import("../webapi/Window.zig"),
|
||||||
@import("../webapi/Performance.zig"),
|
@import("../webapi/Performance.zig"),
|
||||||
|
@import("../webapi/PluginArray.zig"),
|
||||||
@import("../webapi/MutationObserver.zig"),
|
@import("../webapi/MutationObserver.zig"),
|
||||||
@import("../webapi/IntersectionObserver.zig"),
|
@import("../webapi/IntersectionObserver.zig"),
|
||||||
@import("../webapi/CustomElementRegistry.zig"),
|
@import("../webapi/CustomElementRegistry.zig"),
|
||||||
|
|||||||
@@ -20,9 +20,11 @@ const std = @import("std");
|
|||||||
const builtin = @import("builtin");
|
const builtin = @import("builtin");
|
||||||
const js = @import("../js/js.zig");
|
const js = @import("../js/js.zig");
|
||||||
const Page = @import("../Page.zig");
|
const Page = @import("../Page.zig");
|
||||||
|
const PluginArray = @import("PluginArray.zig");
|
||||||
|
|
||||||
const Navigator = @This();
|
const Navigator = @This();
|
||||||
_pad: bool = false,
|
_pad: bool = false,
|
||||||
|
_plugins: PluginArray = .{},
|
||||||
|
|
||||||
pub const init: Navigator = .{};
|
pub const init: Navigator = .{};
|
||||||
|
|
||||||
@@ -96,6 +98,10 @@ pub fn getWebdriver(_: *const Navigator) bool {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub fn getPlugins(self: *Navigator) *PluginArray {
|
||||||
|
return &self._plugins;
|
||||||
|
}
|
||||||
|
|
||||||
pub fn registerProtocolHandler(_: *const Navigator, scheme: []const u8, url: [:0]const u8, page: *const Page) !void {
|
pub fn registerProtocolHandler(_: *const Navigator, scheme: []const u8, url: [:0]const u8, page: *const Page) !void {
|
||||||
try validateProtocolHandlerScheme(scheme);
|
try validateProtocolHandlerScheme(scheme);
|
||||||
try validateProtocolHandlerURL(url, page);
|
try validateProtocolHandlerURL(url, page);
|
||||||
@@ -189,6 +195,7 @@ pub const JsApi = struct {
|
|||||||
pub const vendor = bridge.accessor(Navigator.getVendor, null, .{});
|
pub const vendor = bridge.accessor(Navigator.getVendor, null, .{});
|
||||||
pub const product = bridge.accessor(Navigator.getProduct, null, .{});
|
pub const product = bridge.accessor(Navigator.getProduct, null, .{});
|
||||||
pub const webdriver = bridge.accessor(Navigator.getWebdriver, null, .{});
|
pub const webdriver = bridge.accessor(Navigator.getWebdriver, null, .{});
|
||||||
|
pub const plugins = bridge.accessor(Navigator.getPlugins, null, .{});
|
||||||
pub const registerProtocolHandler = bridge.function(Navigator.registerProtocolHandler, .{ .dom_exception = true });
|
pub const registerProtocolHandler = bridge.function(Navigator.registerProtocolHandler, .{ .dom_exception = true });
|
||||||
pub const unregisterProtocolHandler = bridge.function(Navigator.unregisterProtocolHandler, .{ .dom_exception = true });
|
pub const unregisterProtocolHandler = bridge.function(Navigator.unregisterProtocolHandler, .{ .dom_exception = true });
|
||||||
|
|
||||||
|
|||||||
79
src/browser/webapi/PluginArray.zig
Normal file
79
src/browser/webapi/PluginArray.zig
Normal file
@@ -0,0 +1,79 @@
|
|||||||
|
// Copyright (C) 2023-2026 Lightpanda (Selecy SAS)
|
||||||
|
//
|
||||||
|
// Francis Bouvier <francis@lightpanda.io>
|
||||||
|
// Pierre Tachoire <pierre@lightpanda.io>
|
||||||
|
//
|
||||||
|
// 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 <https://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
|
const js = @import("../js/js.zig");
|
||||||
|
|
||||||
|
pub fn registerTypes() []const type {
|
||||||
|
return &.{ PluginArray, Plugin };
|
||||||
|
}
|
||||||
|
|
||||||
|
const PluginArray = @This();
|
||||||
|
|
||||||
|
_pad: bool = false,
|
||||||
|
|
||||||
|
pub fn getLength(_: *const PluginArray) u32 {
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
pub fn refresh(_: *const PluginArray) void {}
|
||||||
|
pub fn getAtIndex(_: *const PluginArray, index: usize) ?*Plugin {
|
||||||
|
_ = index;
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn getByName(_: *const PluginArray, name: []const u8) ?*Plugin {
|
||||||
|
_ = name;
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Cannot be constructed, and we currently never return any, so no reason to
|
||||||
|
// implement anything on it (for now)
|
||||||
|
const Plugin = struct {
|
||||||
|
pub const JsApi = struct {
|
||||||
|
pub const bridge = js.Bridge(Plugin);
|
||||||
|
pub const Meta = struct {
|
||||||
|
pub const name = "Plugin";
|
||||||
|
pub const prototype_chain = bridge.prototypeChain();
|
||||||
|
pub var class_id: bridge.ClassId = undefined;
|
||||||
|
pub const empty_with_no_proto = true;
|
||||||
|
};
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
|
pub const JsApi = struct {
|
||||||
|
pub const bridge = js.Bridge(PluginArray);
|
||||||
|
|
||||||
|
pub const Meta = struct {
|
||||||
|
pub const name = "PluginArray";
|
||||||
|
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(PluginArray.getLength, null, .{});
|
||||||
|
pub const refresh = bridge.function(PluginArray.refresh, .{});
|
||||||
|
pub const @"[int]" = bridge.indexed(PluginArray.getAtIndex, .{ .null_as_undefined = true });
|
||||||
|
pub const @"[str]" = bridge.namedIndexed(PluginArray.getByName, null, null, .{ .null_as_undefined = true });
|
||||||
|
pub const item = bridge.function(_item, .{});
|
||||||
|
fn _item(self: *const PluginArray, index: i32) ?*Plugin {
|
||||||
|
if (index < 0) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
return self.getAtIndex(@intCast(index));
|
||||||
|
}
|
||||||
|
pub const namedItem = bridge.function(PluginArray.getByName, .{});
|
||||||
|
};
|
||||||
Reference in New Issue
Block a user