Skip to content

Commit

Permalink
Patch: Update extension codes and generate code with JsAccessPath att…
Browse files Browse the repository at this point in the history
…ributes
  • Loading branch information
mingyaulee committed Jun 21, 2024
1 parent 0b1ca00 commit 93ab5cf
Show file tree
Hide file tree
Showing 338 changed files with 1,870 additions and 4 deletions.
4 changes: 4 additions & 0 deletions src/WebExtensions.Net/Extensions/Events/Event.cs
Original file line number Diff line number Diff line change
@@ -1,12 +1,14 @@
using System;
using System.Threading.Tasks;
using JsBind.Net;

namespace WebExtensions.Net.Events
{
public partial class Event
{
/// <summary>Registers an event listener <em>callback</em> to an event.</summary>
/// <param name="callback">Called when an event occurs. The parameters of this function depend on the type of event.</param>
[JsAccessPath("addListener")]
public virtual ValueTask AddListener(Delegate callback)
{
return InvokeVoidAsync("addListener", callback);
Expand All @@ -15,13 +17,15 @@ public virtual ValueTask AddListener(Delegate callback)
/// <summary></summary>
/// <param name="callback">Listener whose registration status shall be tested.</param>
/// <returns>True if <em>callback</em> is registered to the event.</returns>
[JsAccessPath("hasListener")]
public virtual ValueTask<bool> HasListener(Delegate callback)
{
return InvokeAsync<bool>("hasListener", callback);
}

/// <summary>Deregisters an event listener <em>callback</em> from an event.</summary>
/// <param name="callback">Listener that shall be unregistered.</param>
[JsAccessPath("removeListener")]
public virtual ValueTask RemoveListener(Delegate callback)
{
return InvokeVoidAsync("removeListener", callback);
Expand Down
5 changes: 4 additions & 1 deletion src/WebExtensions.Net/Extensions/Menus/IContextMenusApi.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
namespace WebExtensions.Net.Menus
using JsBind.Net;

namespace WebExtensions.Net.Menus
{
/// <inheritdoc />
[JsAccessPath("contextMenus")]
public partial interface IContextMenusApi : IMenusApi
{
}
Expand Down
4 changes: 3 additions & 1 deletion src/WebExtensions.Net/Extensions/Menus/IWebExtensionsApi.cs
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
using WebExtensions.Net.Menus;
using JsBind.Net;
using WebExtensions.Net.Menus;

namespace WebExtensions.Net
{
public partial interface IWebExtensionsApi
{
/// <summary>The part of the menus API that is available in all extension contexts, including content scripts. Use the browser.contextMenus API to add items to the browser's menus. You can choose what types of objects your context menu additions apply to, such as images, hyperlinks, and pages.<br />Requires manifest permission menus, menus.</summary>
[JsAccessPath("contextMenus")]
IContextMenusApi ContextMenus { get; }
}
}
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using System.Threading.Tasks;
using JsBind.Net;

namespace WebExtensions.Net.Notifications
{
Expand All @@ -8,6 +9,7 @@ public partial interface INotificationsApi
/// <param name="notificationId">Identifier of the notification.</param>
/// <param name="options">Contents of the notification.</param>
/// <returns>Indicates whether a matching notification is updated.</returns>
[JsAccessPath("update")]
ValueTask<bool> Update(string notificationId, NotificationOptions options);
}
}
4 changes: 3 additions & 1 deletion src/WebExtensions.Net/Extensions/Runtime/OnMessageEvent.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
using System;
using System.Threading.Tasks;
using WebExtensions.Net.Runtime;
using JsBind.Net;

namespace WebExtensions.Net.Runtime
Expand All @@ -9,6 +8,7 @@ public partial class OnMessageEvent
{
/// <summary>Registers an event listener <em>callback</em> to an event.</summary>
/// <param name="callback">Fired when a message is sent from either an extension process or a content script.</param>
[JsAccessPath("addListener")]
public virtual ValueTask AddListener(Func<object, MessageSender, Action<object>, bool> callback)
{
return InvokeVoidAsync("addListener", callback);
Expand All @@ -17,13 +17,15 @@ public virtual ValueTask AddListener(Func<object, MessageSender, Action<object>,
/// <summary></summary>
/// <param name="callback">Listener whose registration status shall be tested.</param>
/// <returns>True if <em>callback</em> is registered to the event.</returns>
[JsAccessPath("hasListener")]
public virtual ValueTask<bool> HasListener(Func<object, MessageSender, Action<object>, bool> callback)
{
return InvokeAsync<bool>("hasListener", callback);
}

/// <summary>Deregisters an event listener <em>callback</em> from an event.</summary>
/// <param name="callback">Listener that shall be unregistered.</param>
[JsAccessPath("removeListener")]
public virtual ValueTask RemoveListener(Func<object, MessageSender, Action<object>, bool> callback)
{
return InvokeVoidAsync("removeListener", callback);
Expand Down
2 changes: 2 additions & 0 deletions src/WebExtensions.Net/Extensions/Runtime/Port.cs
Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@
using System.Threading.Tasks;
using JsBind.Net;

namespace WebExtensions.Net.Runtime
{
public partial class Port
{
/// <summary>Post a message to the port.</summary>
/// <param name="message">JSON-serializable message.</param>
[JsAccessPath("postMessage")]
public virtual ValueTask PostMessage(object message)
{
return InvokeVoidAsync("postMessage", message);
Expand Down
2 changes: 2 additions & 0 deletions src/WebExtensions.Net/Generated/Action/Details.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,13 @@ namespace WebExtensions.Net.ActionNs
public partial class Details : BaseObject
{
/// <summary>When setting a value, it will be specific to the specified tab, and will automatically reset when the tab navigates. When getting, specifies the tab to get the value from; if there is no tab-specific value, the window one will be inherited.</summary>
[JsAccessPath("tabId")]
[JsonPropertyName("tabId")]
[JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)]
public int? TabId { get; set; }

/// <summary>When setting a value, it will be specific to the specified window. When getting, specifies the window to get the value from; if there is no window-specific value, the global one will be inherited.</summary>
[JsAccessPath("windowId")]
[JsonPropertyName("windowId")]
[JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)]
public int? WindowId { get; set; }
Expand Down
19 changes: 19 additions & 0 deletions src/WebExtensions.Net/Generated/Action/IActionApi.cs
Original file line number Diff line number Diff line change
@@ -1,79 +1,98 @@
using JsBind.Net;
using System.Threading.Tasks;

namespace WebExtensions.Net.ActionNs
{
/// <summary>Use browser actions to put icons in the main browser toolbar, to the right of the address bar. In addition to its icon, a browser action can also have a tooltip, a badge, and a popup.</summary>
[JsAccessPath("action")]
public partial interface IActionApi
{
/// <summary>Fired when a browser action icon is clicked. This event will not fire if the browser action has a popup.</summary>
[JsAccessPath("onClicked")]
OnClickedEvent OnClicked { get; }

/// <summary>Disables the browser action for a tab.</summary>
/// <param name="tabId">The id of the tab for which you want to modify the browser action.</param>
[JsAccessPath("disable")]
ValueTask Disable(int? tabId = null);

/// <summary>Enables the browser action for a tab. By default, browser actions are enabled.</summary>
/// <param name="tabId">The id of the tab for which you want to modify the browser action.</param>
[JsAccessPath("enable")]
ValueTask Enable(int? tabId = null);

/// <summary>Gets the background color of the browser action badge.</summary>
/// <param name="details"></param>
/// <returns></returns>
[JsAccessPath("getBadgeBackgroundColor")]
ValueTask<ColorArray> GetBadgeBackgroundColor(Details details);

/// <summary>Gets the badge text of the browser action. If no tab nor window is specified is specified, the global badge text is returned.</summary>
/// <param name="details"></param>
/// <returns></returns>
[JsAccessPath("getBadgeText")]
ValueTask<string> GetBadgeText(Details details);

/// <summary>Gets the text color of the browser action badge.</summary>
/// <param name="details"></param>
[JsAccessPath("getBadgeTextColor")]
ValueTask GetBadgeTextColor(Details details);

/// <summary>Gets the html document set as the popup for this browser action.</summary>
/// <param name="details"></param>
/// <returns></returns>
[JsAccessPath("getPopup")]
ValueTask<string> GetPopup(Details details);

/// <summary>Gets the title of the browser action.</summary>
/// <param name="details"></param>
/// <returns></returns>
[JsAccessPath("getTitle")]
ValueTask<string> GetTitle(Details details);

/// <summary>Returns the user-specified settings relating to an extension's action.</summary>
/// <returns>The collection of user-specified settings relating to an extension's action.</returns>
[JsAccessPath("getUserSettings")]
ValueTask<UserSettings> GetUserSettings();

/// <summary>Checks whether the browser action is enabled.</summary>
/// <param name="details"></param>
[JsAccessPath("isEnabled")]
ValueTask IsEnabled(Details details);

/// <summary>Opens the extension popup window in the specified window.</summary>
/// <param name="options">An object with information about the popup to open.</param>
[JsAccessPath("openPopup")]
ValueTask OpenPopup(Options options = null);

/// <summary>Sets the background color for the badge.</summary>
/// <param name="details"></param>
[JsAccessPath("setBadgeBackgroundColor")]
ValueTask SetBadgeBackgroundColor(SetBadgeBackgroundColorDetails details);

/// <summary>Sets the badge text for the browser action. The badge is displayed on top of the icon.</summary>
/// <param name="details"></param>
[JsAccessPath("setBadgeText")]
ValueTask SetBadgeText(SetBadgeTextDetails details);

/// <summary>Sets the text color for the badge.</summary>
/// <param name="details"></param>
[JsAccessPath("setBadgeTextColor")]
ValueTask SetBadgeTextColor(SetBadgeTextColorDetails details);

/// <summary>Sets the icon for the browser action. The icon can be specified either as the path to an image file or as the pixel data from a canvas element, or as dictionary of either one of those. Either the 'b'path'/b' or the 'b'imageData'/b' property must be specified.</summary>
/// <param name="details"></param>
[JsAccessPath("setIcon")]
ValueTask SetIcon(SetIconDetails details);

/// <summary>Sets the html document to be opened as a popup when the user clicks on the browser action's icon.</summary>
/// <param name="details"></param>
[JsAccessPath("setPopup")]
ValueTask SetPopup(SetPopupDetails details);

/// <summary>Sets the title of the browser action. This shows up in the tooltip.</summary>
/// <param name="details"></param>
[JsAccessPath("setTitle")]
ValueTask SetTitle(SetTitleDetails details);
}
}
2 changes: 2 additions & 0 deletions src/WebExtensions.Net/Generated/Action/OnClickData.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,13 @@ namespace WebExtensions.Net.ActionNs
public partial class OnClickData : BaseObject
{
/// <summary>An integer value of button by which menu item was clicked.</summary>
[JsAccessPath("button")]
[JsonPropertyName("button")]
[JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)]
public int? Button { get; set; }

/// <summary>An array of keyboard modifiers that were held while the menu item was clicked.</summary>
[JsAccessPath("modifiers")]
[JsonPropertyName("modifiers")]
[JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)]
public IEnumerable<string> Modifiers { get; set; }
Expand Down
3 changes: 3 additions & 0 deletions src/WebExtensions.Net/Generated/Action/OnClickedEvent.cs
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ public partial class OnClickedEvent : Event
{
/// <summary>Registers an event listener <em>callback</em> to an event.</summary>
/// <param name="callback">Fired when a browser action icon is clicked. This event will not fire if the browser action has a popup.</param>
[JsAccessPath("addListener")]
public virtual ValueTask AddListener(Action<Tab, OnClickData> callback)
{
return InvokeVoidAsync("addListener", callback);
Expand All @@ -21,13 +22,15 @@ public virtual ValueTask AddListener(Action<Tab, OnClickData> callback)
/// <summary></summary>
/// <param name="callback">Listener whose registration status shall be tested.</param>
/// <returns>True if <em>callback</em> is registered to the event.</returns>
[JsAccessPath("hasListener")]
public virtual ValueTask<bool> HasListener(Action<Tab, OnClickData> callback)
{
return InvokeAsync<bool>("hasListener", callback);
}

/// <summary>Deregisters an event listener <em>callback</em> from an event.</summary>
/// <param name="callback">Listener that shall be unregistered.</param>
[JsAccessPath("removeListener")]
public virtual ValueTask RemoveListener(Action<Tab, OnClickData> callback)
{
return InvokeVoidAsync("removeListener", callback);
Expand Down
1 change: 1 addition & 0 deletions src/WebExtensions.Net/Generated/Action/Options.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ namespace WebExtensions.Net.ActionNs
public partial class Options : BaseObject
{
/// <summary>Defaults to the $(topic:current-window)[current window].</summary>
[JsAccessPath("windowId")]
[JsonPropertyName("windowId")]
[JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)]
public int? WindowId { get; set; }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ namespace WebExtensions.Net.ActionNs
public partial class SetBadgeBackgroundColorDetails : BaseObject
{
/// <summary></summary>
[JsAccessPath("color")]
[JsonPropertyName("color")]
[JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)]
public ColorValue Color { get; set; }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ namespace WebExtensions.Net.ActionNs
public partial class SetBadgeTextColorDetails : BaseObject
{
/// <summary></summary>
[JsAccessPath("color")]
[JsonPropertyName("color")]
[JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)]
public ColorValue Color { get; set; }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ namespace WebExtensions.Net.ActionNs
public partial class SetBadgeTextDetails : BaseObject
{
/// <summary>Any number of characters can be passed, but only about four can fit in the space.</summary>
[JsAccessPath("text")]
[JsonPropertyName("text")]
[JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)]
public Text Text { get; set; }
Expand Down
2 changes: 2 additions & 0 deletions src/WebExtensions.Net/Generated/Action/SetIconDetails.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,13 @@ namespace WebExtensions.Net.ActionNs
public partial class SetIconDetails : BaseObject
{
/// <summary>Either an ImageData object or a dictionary {size -> ImageData} representing icon to be set. If the icon is specified as a dictionary, the actual image to be used is chosen depending on screen's pixel density. If the number of image pixels that fit into one screen space unit equals <c>scale</c>, then image with size <c>scale</c> * 19 will be selected. Initially only scales 1 and 2 will be supported. At least one image must be specified. Note that 'details.imageData = foo' is equivalent to 'details.imageData = {'19': foo}'</summary>
[JsAccessPath("imageData")]
[JsonPropertyName("imageData")]
[JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)]
public ImageData ImageData { get; set; }

/// <summary>Either a relative image path or a dictionary {size -> relative image path} pointing to icon to be set. If the icon is specified as a dictionary, the actual image to be used is chosen depending on screen's pixel density. If the number of image pixels that fit into one screen space unit equals <c>scale</c>, then image with size <c>scale</c> * 19 will be selected. Initially only scales 1 and 2 will be supported. At least one image must be specified. Note that 'details.path = foo' is equivalent to 'details.imageData = {'19': foo}'</summary>
[JsAccessPath("path")]
[JsonPropertyName("path")]
[JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)]
public Path Path { get; set; }
Expand Down
1 change: 1 addition & 0 deletions src/WebExtensions.Net/Generated/Action/SetPopupDetails.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ namespace WebExtensions.Net.ActionNs
public partial class SetPopupDetails : BaseObject
{
/// <summary>The html file to show in a popup. If set to the empty string (''), no popup is shown.</summary>
[JsAccessPath("popup")]
[JsonPropertyName("popup")]
[JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)]
public Popup Popup { get; set; }
Expand Down
1 change: 1 addition & 0 deletions src/WebExtensions.Net/Generated/Action/SetTitleDetails.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ namespace WebExtensions.Net.ActionNs
public partial class SetTitleDetails : BaseObject
{
/// <summary>The string the browser action should display when moused over.</summary>
[JsAccessPath("title")]
[JsonPropertyName("title")]
[JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)]
public Title Title { get; set; }
Expand Down
1 change: 1 addition & 0 deletions src/WebExtensions.Net/Generated/Action/UserSettings.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ namespace WebExtensions.Net.ActionNs
public partial class UserSettings : BaseObject
{
/// <summary>Whether the extension's action icon is visible on browser windows' top-level toolbar (i.e., whether the extension has been 'pinned' by the user).</summary>
[JsAccessPath("isOnToolbar")]
[JsonPropertyName("isOnToolbar")]
[JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)]
public bool? IsOnToolbar { get; set; }
Expand Down
3 changes: 3 additions & 0 deletions src/WebExtensions.Net/Generated/Alarms/Alarm.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,16 +9,19 @@ namespace WebExtensions.Net.Alarms
public partial class Alarm : BaseObject
{
/// <summary>Name of this alarm.</summary>
[JsAccessPath("name")]
[JsonPropertyName("name")]
[JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)]
public string Name { get; set; }

/// <summary>When present, signals that the alarm triggers periodically after so many minutes.</summary>
[JsAccessPath("periodInMinutes")]
[JsonPropertyName("periodInMinutes")]
[JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)]
public double? PeriodInMinutes { get; set; }

/// <summary>Time when the alarm is scheduled to fire, in milliseconds past the epoch.</summary>
[JsAccessPath("scheduledTime")]
[JsonPropertyName("scheduledTime")]
public EpochTime ScheduledTime { get; set; }
}
Expand Down
3 changes: 3 additions & 0 deletions src/WebExtensions.Net/Generated/Alarms/AlarmInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,16 +9,19 @@ namespace WebExtensions.Net.Alarms
public partial class AlarmInfo : BaseObject
{
/// <summary>Number of minutes from the current time after which the alarm should first fire.</summary>
[JsAccessPath("delayInMinutes")]
[JsonPropertyName("delayInMinutes")]
[JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)]
public double? DelayInMinutes { get; set; }

/// <summary>Number of minutes after which the alarm should recur repeatedly.</summary>
[JsAccessPath("periodInMinutes")]
[JsonPropertyName("periodInMinutes")]
[JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)]
public double? PeriodInMinutes { get; set; }

/// <summary>Time when the alarm is scheduled to first fire, in milliseconds past the epoch.</summary>
[JsAccessPath("when")]
[JsonPropertyName("when")]
[JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)]
public EpochTime? When { get; set; }
Expand Down
Loading

0 comments on commit 93ab5cf

Please sign in to comment.