Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update MDN source and doc comments #244

Merged
merged 1 commit into from
May 23, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 15 additions & 12 deletions lib/src/dom/battery_status.dart
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ import 'dart:js_interop';
import 'dom.dart';
import 'html.dart';

/// The `BatteryManager` interface of the [Battery Status API] provides
/// The **`BatteryManager`** interface of the [Battery Status API] provides
/// information about the system's battery charge level. The
/// [navigator.getBattery] method returns a promise that resolves with a
/// `BatteryManager` interface.
Expand All @@ -29,19 +29,20 @@ import 'html.dart';
/// API documentation sourced from
/// [MDN Web Docs](https://developer.mozilla.org/en-US/docs/Web/API/BatteryManager).
extension type BatteryManager._(JSObject _) implements EventTarget, JSObject {
/// The **`BatteryManager.charging`** property is a Boolean value indicating
/// whether or not the device's battery is currently being charged. When its
/// value changes, the [BatteryManager.chargingchange_event] event is fired.
/// The **`charging`** read-only property of the [BatteryManager] interface is
/// a Boolean value indicating whether or not the device's battery is
/// currently being charged. When its value changes, the
/// [BatteryManager.chargingchange_event] event is fired.
///
/// If the battery is charging or the user agent is unable to report the
/// battery status information, this value is `true`. Otherwise, it is
/// `false`.
external bool get charging;

/// The **`BatteryManager.chargingTime`** property indicates the amount of
/// time, in seconds, that remain until the battery is fully charged, or `0`
/// if the battery is already fully charged or the user agent is unable to
/// report the battery status information.
/// The **`chargingTime`** read-only property of the [BatteryManager]
/// interface indicates the amount of time, in seconds, that remain until the
/// battery is fully charged, or `0` if the battery is already fully charged
/// or the user agent is unable to report the battery status information.
/// If the battery is currently discharging, its value is `Infinity`.
/// When its value changes, the [BatteryManager.chargingtimechange_event]
/// event is fired.
Expand All @@ -51,8 +52,9 @@ extension type BatteryManager._(JSObject _) implements EventTarget, JSObject {
/// > (typically to the closest 15 minutes) for privacy reasons.
external num get chargingTime;

/// The **`BatteryManager.dischargingTime`** property indicates the amount of
/// time, in seconds, that remains until the battery is fully discharged,
/// The **`dischargingTime`** read-only property of the [BatteryManager]
/// interface indicates the amount of time, in seconds, that remains until the
/// battery is fully discharged,
/// or `Infinity` if the battery is currently charging rather than discharging
/// or the user agent is unable to report the battery status information.
/// When its value changes, the [BatteryManager.dischargingtimechange_event]
Expand All @@ -63,8 +65,9 @@ extension type BatteryManager._(JSObject _) implements EventTarget, JSObject {
/// > interval (typically to the closest 15 minutes) for privacy reasons.
external num get dischargingTime;

/// The **`BatteryManager.level`** property indicates the current battery
/// charge level as a value between `0.0` and `1.0`.
/// The **`level`** read-only property of the [BatteryManager] interface
/// indicates the current battery charge level as a value between `0.0` and
/// `1.0`.
/// A value of `0.0` means the battery is empty and the system is about to be
/// suspended.
/// A value of `1.0` means the battery is full or the user agent is unable to
Expand Down
16 changes: 7 additions & 9 deletions lib/src/dom/console.dart
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,13 @@ external $Console get console;

/// The **`console`** object provides access to the debugging console (e.g., the
/// [Web console](https://firefox-source-docs.mozilla.org/devtools-user/web_console/index.html)
/// in Firefox). The specifics of how it works vary from browser to browser or
/// server runtimes (Node.js, for example), but there is a _de facto_ set of
/// features that are typically provided.
/// in Firefox).
///
/// Implementations of the console API may differ between runtimes. In
/// particular, some console methods may work differently or not work at all in
/// some online editors and IDEs. To see the behavior described in this
/// documentation, try the methods in your browser's developer tools, although
/// even here, there are some differences between browsers.
///
/// The `console` object can be accessed from any global object. [Window] on
/// browsing scopes and [WorkerGlobalScope] as specific variants in workers via
Expand All @@ -34,12 +38,6 @@ external $Console get console;
/// This page documents the [Methods](#methods) available on the `console`
/// object and gives a few [Usage](#usage) examples.
///
/// > **Note:** Certain online IDEs and editors may implement the console API
/// > differently than the browsers. As a result, certain functionality of the
/// > console API, such as the timer methods, may not be outputted in the
/// > console of online IDEs or editors. Always open your browser's DevTools
/// > console to see the logs as shown in this documentation.
///
/// ---
///
/// API documentation sourced from
Expand Down
38 changes: 31 additions & 7 deletions lib/src/dom/cookie_store.dart
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@ import 'service_workers.dart';
typedef CookieList = JSArray<CookieListItem>;
typedef CookieSameSite = String;

/// @AvailableInWorkers("window_and_service")
///
/// The **`CookieStore`** interface of the [Cookie Store API] provides methods
/// for getting and setting cookies asynchronously from either a page or a
/// service worker.
Expand All @@ -34,26 +36,34 @@ typedef CookieSameSite = String;
/// API documentation sourced from
/// [MDN Web Docs](https://developer.mozilla.org/en-US/docs/Web/API/CookieStore).
extension type CookieStore._(JSObject _) implements EventTarget, JSObject {
/// @AvailableInWorkers("window_and_service")
///
/// The **`get()`** method of the [CookieStore] interface returns a single
/// cookie with the given name or options object. The method will return the
/// first matching cookie for the passed parameters.
/// cookie with the given `name` or `options` object. The method will return
/// the first matching cookie for the passed parameters.
external JSPromise<CookieListItem?> get([JSAny nameOrOptions]);

/// @AvailableInWorkers("window_and_service")
///
/// The **`getAll()`** method of the [CookieStore] interface returns a list of
/// cookies that match the name or options passed to it. Passing no parameters
/// will return all cookies for the current context.
/// cookies that match the `name` or `options` passed to it. Passing no
/// parameters will return all cookies for the current context.
external JSPromise<CookieList> getAll([JSAny nameOrOptions]);

/// @AvailableInWorkers("window_and_service")
///
/// The **`set()`** method of the [CookieStore] interface sets a cookie with
/// the given name and value or options object.
/// the given `name` and `value` or `options` object.
external JSPromise<JSAny?> set(
JSAny nameOrOptions, [
String value,
]);

/// @AvailableInWorkers("window_and_service")
///
/// The **`delete()`** method of the [CookieStore] interface deletes a cookie
/// with the given name or options object. The `delete()` method expires the
/// cookie by changing the date to one in the past.
/// with the given `name` or `options` object. The `delete()` method expires
/// the cookie by changing the date to one in the past.
external JSPromise<JSAny?> delete(JSAny nameOrOptions);
external EventHandler get onchange;
external set onchange(EventHandler value);
Expand Down Expand Up @@ -142,6 +152,8 @@ extension type CookieListItem._(JSObject _) implements JSObject {
external set partitioned(bool value);
}

/// @AvailableInWorkers("window_and_service")
///
/// The **`CookieStoreManager`** interface of the [Cookie Store API] allows
/// service workers to subscribe to cookie change events. Call
/// [CookieStoreManager.subscribe] on a particular service worker registration
Expand All @@ -160,16 +172,22 @@ extension type CookieListItem._(JSObject _) implements JSObject {
/// API documentation sourced from
/// [MDN Web Docs](https://developer.mozilla.org/en-US/docs/Web/API/CookieStoreManager).
extension type CookieStoreManager._(JSObject _) implements JSObject {
/// @AvailableInWorkers("window_and_service")
///
/// The **`subscribe()`** method of the [CookieStoreManager] interface
/// subscribes a [ServiceWorkerRegistration] to cookie change events.
external JSPromise<JSAny?> subscribe(
JSArray<CookieStoreGetOptions> subscriptions);

/// @AvailableInWorkers("window_and_service")
///
/// The **`getSubscriptions()`** method of the [CookieStoreManager] interface
/// returns a list of all the cookie change subscriptions for this
/// [ServiceWorkerRegistration].
external JSPromise<JSArray<CookieStoreGetOptions>> getSubscriptions();

/// @AvailableInWorkers("window_and_service")
///
/// The **`unsubscribe()`** method of the [CookieStoreManager] interface stops
/// the [ServiceWorkerRegistration] from receiving previously subscribed
/// events.
Expand Down Expand Up @@ -229,6 +247,8 @@ extension type CookieChangeEventInit._(JSObject _)
external set deleted(CookieList value);
}

/// @AvailableInWorkers("service")
///
/// The **`ExtendableCookieChangeEvent`** interface of the [Cookie Store API] is
/// the event type passed to [ServiceWorkerGlobalScope.cookiechange_event] event
/// fired at the [ServiceWorkerGlobalScope] when any cookie changes occur which
Expand Down Expand Up @@ -259,11 +279,15 @@ extension type ExtendableCookieChangeEvent._(JSObject _)
ExtendableCookieChangeEventInit eventInitDict,
]);

/// @AvailableInWorkers("service")
///
/// The **`changed`** read-only property of the [ExtendableCookieChangeEvent]
/// interface returns any cookies that have been changed by the given
/// `ExtendableCookieChangeEvent` instance.
external JSArray<CookieListItem> get changed;

/// @AvailableInWorkers("service")
///
/// The **`deleted`** read-only property of the [ExtendableCookieChangeEvent]
/// interface returns any cookies that have been deleted by the given
/// `ExtendableCookieChangeEvent` instance.
Expand Down
54 changes: 31 additions & 23 deletions lib/src/dom/credential_management.dart
Original file line number Diff line number Diff line change
Expand Up @@ -99,32 +99,22 @@ extension type CredentialsContainer._(JSObject _) implements JSObject {
/// > `<iframe>` element will resolve without effect.
external JSPromise<JSAny?> store(Credential credential);

/// The **`create()`** method of the [CredentialsContainer] interface returns
/// a `Promise` that resolves with a new credential instance based on the
/// provided options, the information from which can then be stored and later
/// used to authenticate users via [CredentialsContainer.get].
/// The **`create()`** method of the [CredentialsContainer] interface creates
/// a new , which can then be stored and later used to authenticate users via
/// [CredentialsContainer.get].
///
/// This is used by multiple different credential-related APIs with
/// significantly different purposes:
/// This method supports three different types of credential:
///
/// - The
/// [Credential Management API](https://developer.mozilla.org/en-US/docs/Web/API/Credential_Management_API)
/// uses `create()` to create basic federated credentials or
/// username/password credentials.
/// - The
/// [Web Authentication API](https://developer.mozilla.org/en-US/docs/Web/API/Web_Authentication_API)
/// uses `create()` to create public key credentials (based on asymmetric
/// cryptography).
///
/// The below reference page starts with a syntax section that explains the
/// general method call structure and parameters that apply to all the
/// different APIs. After that, it is split into separate sections providing
/// parameters, return values, and examples specific to each API.
/// - A password credential, which enables a user to sign in using a password.
/// - A federated credential, which enables a user to sign in using a
/// federated identity provider.
/// - A public key credential, which enables a user to sign in with an
/// authenticator such as a biometric reader built into the platform or a
/// removable hardware token.
///
/// > **Note:** This method is restricted to top-level (i.e., a document
/// > running directly inside a browser tab, and not embedded inside another
/// > document). Calls to it from within an `<iframe>` element will resolve
/// > without effect.
/// Note that the [Federated Credential Management API
/// (FedCM)](https://developer.mozilla.org/en-US/docs/Web/API/FedCM_API)
/// supersedes the federated credential type.
external JSPromise<Credential?> create([CredentialCreationOptions options]);

/// The **`preventSilentAccess()`** method of the [CredentialsContainer]
Expand Down Expand Up @@ -224,6 +214,24 @@ extension type FederatedCredentialRequestOptions._(JSObject _)
external JSArray<JSString> get protocols;
external set protocols(JSArray<JSString> value);
}

/// The **`FederatedCredentialInit`** dictionary represents the object passed to
/// [CredentialsContainer.create] as the value of the `federated` option: that
/// is, when creating a [FederatedCredential] object representing a credential
/// associated with a federated identify provider.
///
/// > **Note:** The [Federated Credential Management API
/// > (FedCM)](https://developer.mozilla.org/en-US/docs/Web/API/FedCM_API)
/// > supersedes the [FederatedCredential] interface in favor of the
/// > [IdentityCredential] interface.
/// >
/// > The `FederatedCredentialInit` dictionary is not used when working with the
/// > `IdentityCredential`interface.
///
/// ---
///
/// API documentation sourced from
/// [MDN Web Docs](https://developer.mozilla.org/en-US/docs/Web/API/FederatedCredentialInit).
extension type FederatedCredentialInit._(JSObject _)
implements CredentialData, JSObject {
external factory FederatedCredentialInit({
Expand Down
Loading
Loading