-
Notifications
You must be signed in to change notification settings - Fork 23
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Only emit APIs that are standards track and not experimental (#239)
* Only emit APIs that are standards track and not experimental The current implementation only emits APIs that are on the standards track and supported in Chrome, Firefox, and Safari. This leaves out widely used APIs like Trusted Types, so this change relaxes those requirements. In order to support this change, a number of changes are included: - BrowserCompatData is modified to handle some slight discrepancies in how compatibility data is stored, including global APIs, namespaces, static members, and event handlers. - Interfaces and namespaces are generated based on whether they are standards track and experimental. If they are not generated, any references to them will be replaced by the equivalent JS type. - Likewise, inheritance for interfaces is modified to subtype the first generated interface in the inheritance hierarchy. - Dictionaries and typedef-like types are generated based on whether they are used as they don't have compatibility data. In order to determine this, whenever we generate a _RawType, we mark it as used, and recursively generate the types needed. - For each API within an interface, compat data in that interface and its superinterfaces are used to determine if an API is generated. - In order to support the above changes, intermediate representations for some members (attributes, fields, constants) are added. There are other members that might be worth moving to an IR, but that refactoring can be done in a future CL. Closes a number of issues: #209 #234 #216 #205 #203 #192 * Generate APIs based on standards track and not experimental * Handle some TODOs that came up when addressing #209 - Removes an unnecessary null-check - Refactors getTypeForUnionCalculation to a shared _getJSTypeEquivalent function - Avoids shadowing an instance variable * Address some lints * Update CHANGELOG and README * Add types to the field declaration
- Loading branch information
Showing
106 changed files
with
7,133 additions
and
4,871 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,70 @@ | ||
// Copyright (c) 2024, the Dart project authors. Please see the AUTHORS file | ||
// for details. All rights reserved. Use of this source code is governed by a | ||
// BSD-style license that can be found in the LICENSE file. | ||
// | ||
// API docs from [MDN Web Docs](https://developer.mozilla.org/en-US/docs/Web). | ||
// Attributions and copyright licensing by Mozilla Contributors is licensed | ||
// under [CC-BY-SA 2.5](https://creativecommons.org/licenses/by-sa/2.5/. | ||
|
||
// Generated from Web IDL definitions. | ||
|
||
@JS() | ||
library; | ||
|
||
import 'dart:js_interop'; | ||
|
||
import 'generic_sensor.dart'; | ||
|
||
typedef AccelerometerLocalCoordinateSystem = String; | ||
extension type AccelerometerSensorOptions._(JSObject _) | ||
implements SensorOptions, JSObject { | ||
external factory AccelerometerSensorOptions({ | ||
num frequency, | ||
AccelerometerLocalCoordinateSystem referenceFrame, | ||
}); | ||
|
||
external AccelerometerLocalCoordinateSystem get referenceFrame; | ||
external set referenceFrame(AccelerometerLocalCoordinateSystem value); | ||
} | ||
|
||
/// The **`LinearAccelerationSensor`** interface of the | ||
/// [Sensor APIs](https://developer.mozilla.org/en-US/docs/Web/API/Sensor_APIs) | ||
/// provides on each reading the acceleration applied to the device along all | ||
/// three axes, but without the contribution of gravity. | ||
/// | ||
/// To use this sensor, the user must grant permission to the `'accelerometer'` | ||
/// device sensor through the | ||
/// [Permissions API](https://developer.mozilla.org/en-US/docs/Web/API/Permissions_API). | ||
/// In addition, this feature may be blocked by a | ||
/// [Permissions Policy](https://developer.mozilla.org/en-US/docs/Web/HTTP/Permissions_Policy) | ||
/// set on your server. | ||
/// | ||
/// --- | ||
/// | ||
/// API documentation sourced from | ||
/// [MDN Web Docs](https://developer.mozilla.org/en-US/docs/Web/API/LinearAccelerationSensor). | ||
extension type LinearAccelerationSensor._(JSObject _) | ||
implements Sensor, JSObject { | ||
external factory LinearAccelerationSensor( | ||
[AccelerometerSensorOptions options]); | ||
} | ||
|
||
/// The **`GravitySensor`** interface of the | ||
/// [Sensor APIs](https://developer.mozilla.org/en-US/docs/Web/API/Sensor_APIs) | ||
/// provides on each reading the gravity applied to the device along all three | ||
/// axes. | ||
/// | ||
/// To use this sensor, the user must grant permission to the `'accelerometer'` | ||
/// device sensor through the | ||
/// [Permissions API](https://developer.mozilla.org/en-US/docs/Web/API/Permissions_API). | ||
/// In addition, this feature may be blocked by a | ||
/// [Permissions Policy](https://developer.mozilla.org/en-US/docs/Web/HTTP/Permissions_Policy) | ||
/// set on your server. | ||
/// | ||
/// --- | ||
/// | ||
/// API documentation sourced from | ||
/// [MDN Web Docs](https://developer.mozilla.org/en-US/docs/Web/API/GravitySensor). | ||
extension type GravitySensor._(JSObject _) implements Sensor, JSObject { | ||
external factory GravitySensor([AccelerometerSensorOptions options]); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
// Copyright (c) 2024, the Dart project authors. Please see the AUTHORS file | ||
// for details. All rights reserved. Use of this source code is governed by a | ||
// BSD-style license that can be found in the LICENSE file. | ||
// | ||
// API docs from [MDN Web Docs](https://developer.mozilla.org/en-US/docs/Web). | ||
// Attributions and copyright licensing by Mozilla Contributors is licensed | ||
// under [CC-BY-SA 2.5](https://creativecommons.org/licenses/by-sa/2.5/. | ||
|
||
// Generated from Web IDL definitions. | ||
|
||
@JS() | ||
library; | ||
|
||
import 'dart:js_interop'; | ||
|
||
extension type AttributionReportingRequestOptions._(JSObject _) | ||
implements JSObject { | ||
external factory AttributionReportingRequestOptions({ | ||
required bool eventSourceEligible, | ||
required bool triggerEligible, | ||
}); | ||
|
||
external bool get eventSourceEligible; | ||
external set eventSourceEligible(bool value); | ||
external bool get triggerEligible; | ||
external set triggerEligible(bool value); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,83 @@ | ||
// Copyright (c) 2024, the Dart project authors. Please see the AUTHORS file | ||
// for details. All rights reserved. Use of this source code is governed by a | ||
// BSD-style license that can be found in the LICENSE file. | ||
// | ||
// API docs from [MDN Web Docs](https://developer.mozilla.org/en-US/docs/Web). | ||
// Attributions and copyright licensing by Mozilla Contributors is licensed | ||
// under [CC-BY-SA 2.5](https://creativecommons.org/licenses/by-sa/2.5/. | ||
|
||
// Generated from Web IDL definitions. | ||
|
||
@JS() | ||
library; | ||
|
||
import 'dart:js_interop'; | ||
|
||
import 'dom.dart'; | ||
import 'html.dart'; | ||
|
||
/// 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. | ||
/// | ||
/// Since Chrome 103, the `BatteryManager` interface of [Battery Status API] | ||
/// only expose to secure context. | ||
/// | ||
/// --- | ||
/// | ||
/// 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. | ||
/// | ||
/// 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. | ||
/// If the battery is currently discharging, its value is `Infinity`. | ||
/// When its value changes, the [BatteryManager.chargingtimechange_event] | ||
/// event is fired. | ||
/// | ||
/// > **Note:** Even if the time returned is precise to the second, | ||
/// > browsers round them to a higher interval | ||
/// > (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, | ||
/// 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] | ||
/// event is fired. | ||
/// | ||
/// > **Note:** Even if the time returned is precise to the second, browsers | ||
/// > round them to a higher | ||
/// > 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`. | ||
/// 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 | ||
/// report the battery status information. | ||
/// When its value changes, the [BatteryManager.levelchange_event] event is | ||
/// fired. | ||
external num get level; | ||
external EventHandler get onchargingchange; | ||
external set onchargingchange(EventHandler value); | ||
external EventHandler get onchargingtimechange; | ||
external set onchargingtimechange(EventHandler value); | ||
external EventHandler get ondischargingtimechange; | ||
external set ondischargingtimechange(EventHandler value); | ||
external EventHandler get onlevelchange; | ||
external set onlevelchange(EventHandler value); | ||
} |
Oops, something went wrong.