@@ -25,6 +25,41 @@ void main() {
2525}
2626```
2727
28+ ## Generation conventions
29+
30+ The generator scripts use a number of conventions to consistently handle Web IDL
31+ definitions:
32+
33+ ### Interfaces
34+
35+ - Interfaces are emitted as extension types that wrap and implement ` JSObject ` .
36+ - Interface inheritance is maintained using ` implements ` between extension
37+ types.
38+ - Members of partial interfaces, partial mixins, and mixins are added to the
39+ interfaces that include them, and therefore do not have separate declarations.
40+
41+ ### Types
42+
43+ - Generic types include the generic in the case of ` JSArray ` and ` JSPromise ` .
44+ - Enums are typedef'd to ` String ` .
45+ - Callbacks and callback interfaces are typedef'd to ` JSFunction ` .
46+ - In general, we prefer the Dart primitive over the JS type equivalent wherever
47+ possible. For example, APIs use ` String ` instead of ` JSString ` .
48+ - If a type appears in a generic position and it was typedef'd to a Dart
49+ primitive type, it is replaced with the JS type equivalent to respect the type
50+ bound of ` JSAny? ` .
51+ - Union types are computed by picking the least upper bound of the types in the
52+ JS type hierarchy, where every interface is equivalent to ` JSObject ` .
53+
54+ ### Compatibility
55+
56+ - The generator uses the
57+ [ MDN compatibility data] ( https://github.com/mdn/browser-compat-data ) to
58+ determine what members and interfaces to emit. Currently, we only emit code
59+ that is standards track and supported on Chrome, Firefox, and Safari to reduce
60+ the number of breaking changes. This is currently WIP and some members may be
61+ added or removed.
62+
2863## Web IDL version
2964
3065Based on:
0 commit comments