Skip to content

Commit

Permalink
Minor: Generate APIs
Browse files Browse the repository at this point in the history
  • Loading branch information
mingyaulee committed May 12, 2024
1 parent 5e992e9 commit 1f77bb6
Show file tree
Hide file tree
Showing 42 changed files with 189 additions and 94 deletions.
6 changes: 3 additions & 3 deletions src/WebExtensions.Net/Generated/Action/ActionApi.cs
Original file line number Diff line number Diff line change
Expand Up @@ -30,13 +30,13 @@ public OnClickedEvent OnClicked
}

/// <inheritdoc />
public virtual ValueTask Disable(int? tabId)
public virtual ValueTask Disable(int? tabId = null)
{
return InvokeVoidAsync("disable", tabId);
}

/// <inheritdoc />
public virtual ValueTask Enable(int? tabId)
public virtual ValueTask Enable(int? tabId = null)
{
return InvokeVoidAsync("enable", tabId);
}
Expand Down Expand Up @@ -84,7 +84,7 @@ public virtual ValueTask IsEnabled(Details details)
}

/// <inheritdoc />
public virtual ValueTask OpenPopup(Options options)
public virtual ValueTask OpenPopup(Options options = null)
{
return InvokeVoidAsync("openPopup", options);
}
Expand Down
6 changes: 3 additions & 3 deletions src/WebExtensions.Net/Generated/Action/IActionApi.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,11 @@ public partial interface IActionApi

/// <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>
ValueTask Disable(int? tabId);
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>
ValueTask Enable(int? tabId);
ValueTask Enable(int? tabId = null);

/// <summary>Gets the background color of the browser action badge.</summary>
/// <param name="details"></param>
Expand Down Expand Up @@ -50,7 +50,7 @@ public partial interface IActionApi

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

/// <summary>Sets the background color for the badge.</summary>
/// <param name="details"></param>
Expand Down
10 changes: 8 additions & 2 deletions src/WebExtensions.Net/Generated/Alarms/AlarmsApi.cs
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ public OnAlarmEvent OnAlarm
}

/// <inheritdoc />
public virtual ValueTask<bool> Clear(string name)
public virtual ValueTask<bool> Clear(string name = null)
{
return InvokeAsync<bool>("clear", name);
}
Expand All @@ -42,14 +42,20 @@ public virtual ValueTask<bool> ClearAll()
return InvokeAsync<bool>("clearAll");
}

/// <inheritdoc />
public virtual ValueTask Create(AlarmInfo alarmInfo)
{
return InvokeVoidAsync("create", alarmInfo);
}

/// <inheritdoc />
public virtual ValueTask Create(string name, AlarmInfo alarmInfo)
{
return InvokeVoidAsync("create", name, alarmInfo);
}

/// <inheritdoc />
public virtual ValueTask<Alarm> Get(string name)
public virtual ValueTask<Alarm> Get(string name = null)
{
return InvokeAsync<Alarm>("get", name);
}
Expand Down
8 changes: 6 additions & 2 deletions src/WebExtensions.Net/Generated/Alarms/IAlarmsApi.cs
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,16 @@ public partial interface IAlarmsApi
/// <summary>Clears the alarm with the given name.</summary>
/// <param name="name">The name of the alarm to clear. Defaults to the empty string.</param>
/// <returns>Whether an alarm of the given name was found to clear.</returns>
ValueTask<bool> Clear(string name);
ValueTask<bool> Clear(string name = null);

/// <summary>Clears all alarms.</summary>
/// <returns>Whether any alarm was found to clear.</returns>
ValueTask<bool> ClearAll();

/// <summary>Creates an alarm. After the delay is expired, the onAlarm event is fired. If there is another alarm with the same name (or no name if none is specified), it will be cancelled and replaced by this alarm.</summary>
/// <param name="alarmInfo">Details about the alarm. The alarm first fires either at 'when' milliseconds past the epoch (if 'when' is provided), after 'delayInMinutes' minutes from the current time (if 'delayInMinutes' is provided instead), or after 'periodInMinutes' minutes from the current time (if only 'periodInMinutes' is provided). Users should never provide both 'when' and 'delayInMinutes'. If 'periodInMinutes' is provided, then the alarm recurs repeatedly after that many minutes.</param>
ValueTask Create(AlarmInfo alarmInfo);

/// <summary>Creates an alarm. After the delay is expired, the onAlarm event is fired. If there is another alarm with the same name (or no name if none is specified), it will be cancelled and replaced by this alarm.</summary>
/// <param name="name">Optional name to identify this alarm. Defaults to the empty string.</param>
/// <param name="alarmInfo">Details about the alarm. The alarm first fires either at 'when' milliseconds past the epoch (if 'when' is provided), after 'delayInMinutes' minutes from the current time (if 'delayInMinutes' is provided instead), or after 'periodInMinutes' minutes from the current time (if only 'periodInMinutes' is provided). Users should never provide both 'when' and 'delayInMinutes'. If 'periodInMinutes' is provided, then the alarm recurs repeatedly after that many minutes.</param>
Expand All @@ -26,7 +30,7 @@ public partial interface IAlarmsApi
/// <summary>Retrieves details about the specified alarm.</summary>
/// <param name="name">The name of the alarm to get. Defaults to the empty string.</param>
/// <returns></returns>
ValueTask<Alarm> Get(string name);
ValueTask<Alarm> Get(string name = null);

/// <summary>Gets an array of all the alarms.</summary>
/// <returns></returns>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,13 +30,13 @@ public OnClickedEvent OnClicked
}

/// <inheritdoc />
public virtual ValueTask Disable(int? tabId)
public virtual ValueTask Disable(int? tabId = null)
{
return InvokeVoidAsync("disable", tabId);
}

/// <inheritdoc />
public virtual ValueTask Enable(int? tabId)
public virtual ValueTask Enable(int? tabId = null)
{
return InvokeVoidAsync("enable", tabId);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,11 @@ public partial interface IBrowserActionApi

/// <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>
ValueTask Disable(int? tabId);
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>
ValueTask Enable(int? tabId);
ValueTask Enable(int? tabId = null);

/// <summary>Gets the background color of the browser action badge.</summary>
/// <param name="details"></param>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ public virtual ValueTask<IsRegexSupportedCallbackResult> IsRegexSupported(RegexO
}

/// <inheritdoc />
public virtual ValueTask<TestMatchOutcomeCallbackResult> TestMatchOutcome(Request request, TestMatchOutcomeOptions options)
public virtual ValueTask<TestMatchOutcomeCallbackResult> TestMatchOutcome(Request request, TestMatchOutcomeOptions options = null)
{
return InvokeAsync<TestMatchOutcomeCallbackResult>("testMatchOutcome", request, options);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ public partial interface IDeclarativeNetRequestApi
/// <param name="request">The details of the request to test.</param>
/// <param name="options"></param>
/// <returns></returns>
ValueTask<TestMatchOutcomeCallbackResult> TestMatchOutcome(Request request, TestMatchOutcomeOptions options);
ValueTask<TestMatchOutcomeCallbackResult> TestMatchOutcome(Request request, TestMatchOutcomeOptions options = null);

/// <summary>Modifies the current set of dynamic rules for the extension. The rules with IDs listed in options.removeRuleIds are first removed, and then the rules given in options.addRules are added. These rules are persisted across browser sessions and extension updates.</summary>
/// <param name="options"></param>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,10 @@ public partial interface IInspectedWindowApi
/// <param name="expression">An expression to evaluate.</param>
/// <param name="options">The options parameter can contain one or more options.</param>
/// <returns></returns>
ValueTask<EvalResult> Eval(string expression, object options);
ValueTask<EvalResult> Eval(string expression, object options = null);

/// <summary>Reloads the inspected page.</summary>
/// <param name="reloadOptions"></param>
ValueTask Reload(ReloadOptions reloadOptions);
ValueTask Reload(ReloadOptions reloadOptions = null);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -17,13 +17,13 @@ public InspectedWindowApi(IJsRuntimeAdapter jsRuntime, string accessPath) : base
public int TabId => GetProperty<int>("tabId");

/// <inheritdoc />
public virtual ValueTask<EvalResult> Eval(string expression, object options)
public virtual ValueTask<EvalResult> Eval(string expression, object options = null)
{
return InvokeAsync<EvalResult>("eval", expression, options);
}

/// <inheritdoc />
public virtual ValueTask Reload(ReloadOptions reloadOptions)
public virtual ValueTask Reload(ReloadOptions reloadOptions = null)
{
return InvokeVoidAsync("reload", reloadOptions);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,15 +12,15 @@ public partial class ExtensionSidebarPane : BaseObject
/// <summary>Sets an expression that is evaluated within the inspected page. The result is displayed in the sidebar pane.</summary>
/// <param name="expression">An expression to be evaluated in context of the inspected page. JavaScript objects and DOM nodes are displayed in an expandable tree similar to the console/watch.</param>
/// <param name="rootTitle">An optional title for the root of the expression tree.</param>
public virtual ValueTask SetExpression(string expression, string rootTitle)
public virtual ValueTask SetExpression(string expression, string rootTitle = null)
{
return InvokeVoidAsync("setExpression", expression, rootTitle);
}

/// <summary>Sets a JSON-compliant object to be displayed in the sidebar pane.</summary>
/// <param name="jsonObject">An object to be displayed in context of the inspected page. Evaluated in the context of the caller (API client).</param>
/// <param name="rootTitle">An optional title for the root of the expression tree.</param>
public virtual ValueTask SetObject(string jsonObject, string rootTitle)
public virtual ValueTask SetObject(string jsonObject, string rootTitle = null)
{
return InvokeVoidAsync("setObject", jsonObject, rootTitle);
}
Expand Down
2 changes: 1 addition & 1 deletion src/WebExtensions.Net/Generated/Downloads/DownloadsApi.cs
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ public virtual ValueTask<IEnumerable<int>> Erase(DownloadQuery query)
}

/// <inheritdoc />
public virtual ValueTask<string> GetFileIcon(int downloadId, GetFileIconOptions options)
public virtual ValueTask<string> GetFileIcon(int downloadId, GetFileIconOptions options = null)
{
return InvokeAsync<string>("getFileIcon", downloadId, options);
}
Expand Down
2 changes: 1 addition & 1 deletion src/WebExtensions.Net/Generated/Downloads/IDownloadsApi.cs
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ public partial interface IDownloadsApi
/// <param name="downloadId">The identifier for the download.</param>
/// <param name="options"></param>
/// <returns></returns>
ValueTask<string> GetFileIcon(int downloadId, GetFileIconOptions options);
ValueTask<string> GetFileIcon(int downloadId, GetFileIconOptions options = null);

/// <summary>Open the downloaded file.</summary>
/// <param name="downloadId"></param>
Expand Down
2 changes: 1 addition & 1 deletion src/WebExtensions.Net/Generated/Extension/ExtensionApi.cs
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ public virtual ValueTask<string> GetURL(string path)
}

/// <inheritdoc />
public virtual ValueTask<IEnumerable<object>> GetViews(FetchProperties fetchProperties)
public virtual ValueTask<IEnumerable<object>> GetViews(FetchProperties fetchProperties = null)
{
return InvokeAsync<IEnumerable<object>>("getViews", fetchProperties);
}
Expand Down
2 changes: 1 addition & 1 deletion src/WebExtensions.Net/Generated/Extension/IExtensionApi.cs
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ public partial interface IExtensionApi
/// <summary>Returns an array of the JavaScript 'window' objects for each of the pages running inside the current extension.</summary>
/// <param name="fetchProperties"></param>
/// <returns>Array of global objects</returns>
ValueTask<IEnumerable<object>> GetViews(FetchProperties fetchProperties);
ValueTask<IEnumerable<object>> GetViews(FetchProperties fetchProperties = null);

/// <summary>Retrieves the state of the extension's access to the 'file://' scheme (as determined by the user-controlled 'Allow access to File URLs' checkbox.</summary>
/// <returns>True if the extension can access the 'file://' scheme, false otherwise.</returns>
Expand Down
2 changes: 1 addition & 1 deletion src/WebExtensions.Net/Generated/I18n/I18nApi.cs
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ public virtual ValueTask<IEnumerable<LanguageCode>> GetAcceptLanguages()
}

/// <inheritdoc />
public virtual ValueTask<string> GetMessage(string messageName, object substitutions)
public virtual ValueTask<string> GetMessage(string messageName, object substitutions = null)
{
return InvokeAsync<string>("getMessage", messageName, substitutions);
}
Expand Down
2 changes: 1 addition & 1 deletion src/WebExtensions.Net/Generated/I18n/II18nApi.cs
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ public partial interface II18nApi
/// <param name="messageName">The name of the message, as specified in the <c>$(topic:i18n-messages)[messages.json]</c> file.</param>
/// <param name="substitutions">Substitution strings, if the message requires any.</param>
/// <returns>Message localized for current locale.</returns>
ValueTask<string> GetMessage(string messageName, object substitutions);
ValueTask<string> GetMessage(string messageName, object substitutions = null);

/// <summary>Gets the browser UI language of the browser. This is different from $(ref:i18n.getAcceptLanguages) which returns the preferred user languages.</summary>
/// <returns>The browser UI language code such as en-US or fr-FR.</returns>
Expand Down
2 changes: 1 addition & 1 deletion src/WebExtensions.Net/Generated/Identity/IIdentityApi.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ public partial interface IIdentityApi
/// <summary>Generates a redirect URL to be used in |launchWebAuthFlow|.</summary>
/// <param name="path">The path appended to the end of the generated URL. </param>
/// <returns></returns>
ValueTask<string> GetRedirectURL(string path);
ValueTask<string> GetRedirectURL(string path = null);

/// <summary>Starts an auth flow at the specified URL.</summary>
/// <param name="details"></param>
Expand Down
2 changes: 1 addition & 1 deletion src/WebExtensions.Net/Generated/Identity/IdentityApi.cs
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ public IdentityApi(IJsRuntimeAdapter jsRuntime, string accessPath) : base(jsRunt
}

/// <inheritdoc />
public virtual ValueTask<string> GetRedirectURL(string path)
public virtual ValueTask<string> GetRedirectURL(string path = null)
{
return InvokeAsync<string>("getRedirectURL", path);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,6 @@ public partial interface IManagementApi

/// <summary>Uninstalls the calling extension. Note: This function can be used without requesting the 'management' permission in the manifest.</summary>
/// <param name="options"></param>
ValueTask UninstallSelf(UninstallSelfOptions options);
ValueTask UninstallSelf(UninstallSelfOptions options = null);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ public virtual ValueTask SetEnabled(string id, bool enabled)
}

/// <inheritdoc />
public virtual ValueTask UninstallSelf(UninstallSelfOptions options)
public virtual ValueTask UninstallSelf(UninstallSelfOptions options = null)
{
return InvokeVoidAsync("uninstallSelf", options);
}
Expand Down
2 changes: 1 addition & 1 deletion src/WebExtensions.Net/Generated/Menus/IMenusApi.cs
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ public partial interface IMenusApi
/// <param name="createProperties"></param>
/// <param name="callback">Called when the item has been created in the browser. If there were any problems creating the item, details will be available in $(ref:runtime.lastError).</param>
/// <returns>The ID of the newly created item.</returns>
ValueTask<CreateReturnType> Create(CreateProperties createProperties, Action callback);
ValueTask<CreateReturnType> Create(CreateProperties createProperties, Action callback = null);

/// <summary>Retrieve the element that was associated with a recent contextmenu event.</summary>
/// <param name="targetElementId">The identifier of the clicked element, available as info.targetElementId in the menus.onShown, onClicked or onclick event.</param>
Expand Down
2 changes: 1 addition & 1 deletion src/WebExtensions.Net/Generated/Menus/MenusApi.cs
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ public OnShownEvent OnShown
}

/// <inheritdoc />
public virtual ValueTask<CreateReturnType> Create(CreateProperties createProperties, Action callback)
public virtual ValueTask<CreateReturnType> Create(CreateProperties createProperties, Action callback = null)
{
return InvokeAsync<CreateReturnType>("create", createProperties, callback);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,11 @@ public partial interface INotificationsApi
/// <returns>Indicates whether a matching notification existed.</returns>
ValueTask<bool> Clear(string notificationId);

/// <summary>Creates and displays a notification.</summary>
/// <param name="options">Contents of the notification.</param>
/// <returns>The notification id (either supplied or generated) that represents the created notification.</returns>
ValueTask<string> Create(NotificationOptions options);

/// <summary>Creates and displays a notification.</summary>
/// <param name="notificationId">Identifier of the notification. If it is empty, this method generates an id. If it matches an existing notification, this method first clears that notification before proceeding with the create operation.</param>
/// <param name="options">Contents of the notification.</param>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,12 @@ public virtual ValueTask<bool> Clear(string notificationId)
return InvokeAsync<bool>("clear", notificationId);
}

/// <inheritdoc />
public virtual ValueTask<string> Create(NotificationOptions options)
{
return InvokeAsync<string>("create", options);
}

/// <inheritdoc />
public virtual ValueTask<string> Create(string notificationId, NotificationOptions options)
{
Expand Down
Loading

0 comments on commit 1f77bb6

Please sign in to comment.