mirror of
https://github.com/fluencelabs/wasm-bindgen
synced 2025-03-31 01:11:06 +00:00
Update and improve crate features in web-sys
* Regenerate the list of features for the crate given recent improvements, enabling some more types to be bound. * Add feature gates for the `css` and `console` namespaces (modules), gating the APIs by default. Now `web_sys` has zero APIs unless they're requested. * Improved the "required feature" documentation for `struct` types to not list parent classes and mention just the `struct` type instead.
This commit is contained in:
parent
d10ca579e4
commit
97cceebe7e
@ -211,7 +211,6 @@ CssImportRule = []
|
|||||||
CssKeyframeRule = []
|
CssKeyframeRule = []
|
||||||
CssKeyframesRule = []
|
CssKeyframesRule = []
|
||||||
CssMediaRule = []
|
CssMediaRule = []
|
||||||
CssMozDocumentRule = []
|
|
||||||
CssNamespaceRule = []
|
CssNamespaceRule = []
|
||||||
CssPageRule = []
|
CssPageRule = []
|
||||||
CssPseudoElement = []
|
CssPseudoElement = []
|
||||||
@ -289,6 +288,7 @@ EcKeyAlgorithm = []
|
|||||||
EcKeyGenParams = []
|
EcKeyGenParams = []
|
||||||
EcKeyImportParams = []
|
EcKeyImportParams = []
|
||||||
EcdhKeyDeriveParams = []
|
EcdhKeyDeriveParams = []
|
||||||
|
EcdsaParams = []
|
||||||
EffectTiming = []
|
EffectTiming = []
|
||||||
Element = []
|
Element = []
|
||||||
ElementCreationOptions = []
|
ElementCreationOptions = []
|
||||||
@ -363,6 +363,7 @@ GamepadMappingType = []
|
|||||||
GamepadPose = []
|
GamepadPose = []
|
||||||
GamepadServiceTest = []
|
GamepadServiceTest = []
|
||||||
GetNotificationOptions = []
|
GetNotificationOptions = []
|
||||||
|
GetRootNodeOptions = []
|
||||||
GridDeclaration = []
|
GridDeclaration = []
|
||||||
GridTrackState = []
|
GridTrackState = []
|
||||||
GroupedHistoryEventInit = []
|
GroupedHistoryEventInit = []
|
||||||
@ -374,7 +375,11 @@ HeadersGuardEnum = []
|
|||||||
HiddenPluginEventInit = []
|
HiddenPluginEventInit = []
|
||||||
History = []
|
History = []
|
||||||
HitRegionOptions = []
|
HitRegionOptions = []
|
||||||
|
HkdfParams = []
|
||||||
|
HmacDerivedKeyParams = []
|
||||||
|
HmacImportParams = []
|
||||||
HmacKeyAlgorithm = []
|
HmacKeyAlgorithm = []
|
||||||
|
HmacKeyGenParams = []
|
||||||
HtmlAllCollection = []
|
HtmlAllCollection = []
|
||||||
HtmlAnchorElement = []
|
HtmlAnchorElement = []
|
||||||
HtmlAreaElement = []
|
HtmlAreaElement = []
|
||||||
@ -591,13 +596,6 @@ MimeTypeArray = []
|
|||||||
MouseEvent = []
|
MouseEvent = []
|
||||||
MouseEventInit = []
|
MouseEventInit = []
|
||||||
MouseScrollEvent = []
|
MouseScrollEvent = []
|
||||||
MozApplicationEventInit = []
|
|
||||||
MozPacketDumpType = []
|
|
||||||
MozPluginParameter = []
|
|
||||||
MozRtcIceCandidate = []
|
|
||||||
MozRtcPeerConnection = []
|
|
||||||
MozRtcSessionDescription = []
|
|
||||||
MozXmlHttpRequestParameters = []
|
|
||||||
MutationEvent = []
|
MutationEvent = []
|
||||||
MutationObserver = []
|
MutationObserver = []
|
||||||
MutationObserverInit = []
|
MutationObserverInit = []
|
||||||
@ -653,6 +651,7 @@ PaymentMethodChangeEventInit = []
|
|||||||
PaymentRequestUpdateEvent = []
|
PaymentRequestUpdateEvent = []
|
||||||
PaymentRequestUpdateEventInit = []
|
PaymentRequestUpdateEventInit = []
|
||||||
PaymentResponse = []
|
PaymentResponse = []
|
||||||
|
Pbkdf2Params = []
|
||||||
PcImplIceConnectionState = []
|
PcImplIceConnectionState = []
|
||||||
PcImplIceGatheringState = []
|
PcImplIceGatheringState = []
|
||||||
PcImplSignalingState = []
|
PcImplSignalingState = []
|
||||||
@ -754,6 +753,7 @@ RequestRedirect = []
|
|||||||
Response = []
|
Response = []
|
||||||
ResponseInit = []
|
ResponseInit = []
|
||||||
ResponseType = []
|
ResponseType = []
|
||||||
|
RsaHashedImportParams = []
|
||||||
RsaOaepParams = []
|
RsaOaepParams = []
|
||||||
RsaOtherPrimesInfo = []
|
RsaOtherPrimesInfo = []
|
||||||
RsaPssParams = []
|
RsaPssParams = []
|
||||||
@ -1054,6 +1054,7 @@ VideoPlaybackQuality = []
|
|||||||
VideoStreamTrack = []
|
VideoStreamTrack = []
|
||||||
VideoTrack = []
|
VideoTrack = []
|
||||||
VideoTrackList = []
|
VideoTrackList = []
|
||||||
|
VisibilityState = []
|
||||||
VoidCallback = []
|
VoidCallback = []
|
||||||
VrDisplay = []
|
VrDisplay = []
|
||||||
VrDisplayCapabilities = []
|
VrDisplayCapabilities = []
|
||||||
@ -1196,3 +1197,5 @@ XmlHttpRequestResponseType = []
|
|||||||
XmlHttpRequestUpload = []
|
XmlHttpRequestUpload = []
|
||||||
XmlSerializer = []
|
XmlSerializer = []
|
||||||
XsltProcessor = []
|
XsltProcessor = []
|
||||||
|
console = []
|
||||||
|
css = []
|
||||||
|
@ -69,6 +69,7 @@ fn try_main() -> Result<(), failure::Error> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// If we're printing all features don't filter anything
|
// If we're printing all features don't filter anything
|
||||||
|
println!("cargo:rerun-if-env-changed=__WASM_BINDGEN_DUMP_FEATURES");
|
||||||
let allowed = if env::var("__WASM_BINDGEN_DUMP_FEATURES").is_ok() {
|
let allowed = if env::var("__WASM_BINDGEN_DUMP_FEATURES").is_ok() {
|
||||||
None
|
None
|
||||||
} else {
|
} else {
|
||||||
|
@ -93,32 +93,34 @@ fn parse(webidl_source: &str, allowed_types: Option<&[&str]>)
|
|||||||
});
|
});
|
||||||
let filter = |name: &str| {
|
let filter = |name: &str| {
|
||||||
match &allowed_types {
|
match &allowed_types {
|
||||||
Some(set) => set.contains(&camel_case_ident(name)[..]),
|
Some(set) => set.contains(name),
|
||||||
None => true,
|
None => true,
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
for (name, e) in first_pass_record.enums.iter() {
|
for (name, e) in first_pass_record.enums.iter() {
|
||||||
if filter(name) {
|
if filter(&camel_case_ident(name)) {
|
||||||
first_pass_record.append_enum(&mut program, e);
|
first_pass_record.append_enum(&mut program, e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
for (name, d) in first_pass_record.dictionaries.iter() {
|
for (name, d) in first_pass_record.dictionaries.iter() {
|
||||||
if filter(name) {
|
if filter(&camel_case_ident(name)) {
|
||||||
first_pass_record.append_dictionary(&mut program, d);
|
first_pass_record.append_dictionary(&mut program, d);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
for (name, n) in first_pass_record.namespaces.iter() {
|
for (name, n) in first_pass_record.namespaces.iter() {
|
||||||
|
if filter(&snake_case_ident(name)) {
|
||||||
let prog = first_pass_record.append_ns(name, n);
|
let prog = first_pass_record.append_ns(name, n);
|
||||||
submodules.push((snake_case_ident(name).to_string(), prog));
|
submodules.push((snake_case_ident(name).to_string(), prog));
|
||||||
}
|
}
|
||||||
|
}
|
||||||
for (name, d) in first_pass_record.interfaces.iter() {
|
for (name, d) in first_pass_record.interfaces.iter() {
|
||||||
if filter(name) {
|
if filter(&camel_case_ident(name)) {
|
||||||
first_pass_record.append_interface(&mut program, name, d);
|
first_pass_record.append_interface(&mut program, name, d);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
for (name, d) in first_pass_record.callback_interfaces.iter() {
|
for (name, d) in first_pass_record.callback_interfaces.iter() {
|
||||||
if filter(name) {
|
if filter(&camel_case_ident(name)) {
|
||||||
first_pass_record.append_callback_interface(&mut program, d);
|
first_pass_record.append_callback_interface(&mut program, d);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -181,7 +183,8 @@ fn compile_ast(mut ast: Program) -> String {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
ast.main.imported_type_definitions(&mut cb);
|
ast.main.imported_type_definitions(&mut cb);
|
||||||
for (_, m) in ast.submodules.iter() {
|
for (name, m) in ast.submodules.iter() {
|
||||||
|
cb(&Ident::new(name, Span::call_site()));
|
||||||
m.imported_type_references(&mut cb);
|
m.imported_type_references(&mut cb);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -196,6 +199,7 @@ fn compile_ast(mut ast: Program) -> String {
|
|||||||
}
|
}
|
||||||
if let Some(path) = track {
|
if let Some(path) = track {
|
||||||
let contents = all_definitions.into_iter()
|
let contents = all_definitions.into_iter()
|
||||||
|
.filter(|def| !builtin.contains(def))
|
||||||
.map(|s| format!("{} = []", s))
|
.map(|s| format!("{} = []", s))
|
||||||
.collect::<Vec<_>>()
|
.collect::<Vec<_>>()
|
||||||
.join("\n");
|
.join("\n");
|
||||||
@ -412,8 +416,12 @@ impl<'src> FirstPassRecord<'src> {
|
|||||||
);
|
);
|
||||||
|
|
||||||
let kind = backend::ast::ImportFunctionKind::Normal;
|
let kind = backend::ast::ImportFunctionKind::Normal;
|
||||||
|
let extra = snake_case_ident(self_name);
|
||||||
|
let extra = &[&extra[..]];
|
||||||
for mut import_function in self.create_imports(None, kind, id, data) {
|
for mut import_function in self.create_imports(None, kind, id, data) {
|
||||||
import_function.doc_comment = Some(doc_comment.clone());
|
let mut doc = Some(doc_comment.clone());
|
||||||
|
self.append_required_features_doc(&import_function, &mut doc, extra);
|
||||||
|
import_function.doc_comment = doc;
|
||||||
module.imports.push(
|
module.imports.push(
|
||||||
backend::ast::Import {
|
backend::ast::Import {
|
||||||
module: None,
|
module: None,
|
||||||
@ -482,12 +490,15 @@ impl<'src> FirstPassRecord<'src> {
|
|||||||
attrs: vec![derive],
|
attrs: vec![derive],
|
||||||
doc_comment: None,
|
doc_comment: None,
|
||||||
instanceof_shim: format!("__widl_instanceof_{}", name),
|
instanceof_shim: format!("__widl_instanceof_{}", name),
|
||||||
extends: self.all_superclasses(name)
|
extends: Vec::new(),
|
||||||
|
};
|
||||||
|
let extra = camel_case_ident(name);
|
||||||
|
let extra = &[&extra[..]];
|
||||||
|
self.append_required_features_doc(&import_type, &mut doc_comment, extra);
|
||||||
|
import_type.extends = self.all_superclasses(name)
|
||||||
.map(|name| Ident::new(&name, Span::call_site()))
|
.map(|name| Ident::new(&name, Span::call_site()))
|
||||||
.chain(Some(Ident::new("Object", Span::call_site())))
|
.chain(Some(Ident::new("Object", Span::call_site())))
|
||||||
.collect(),
|
.collect();
|
||||||
};
|
|
||||||
self.append_required_features_doc(&import_type, &mut doc_comment);
|
|
||||||
import_type.doc_comment = doc_comment;
|
import_type.doc_comment = doc_comment;
|
||||||
|
|
||||||
program.imports.push(backend::ast::Import {
|
program.imports.push(backend::ast::Import {
|
||||||
@ -570,7 +581,7 @@ impl<'src> FirstPassRecord<'src> {
|
|||||||
container_attrs,
|
container_attrs,
|
||||||
) {
|
) {
|
||||||
let mut doc = import_function.doc_comment.take();
|
let mut doc = import_function.doc_comment.take();
|
||||||
self.append_required_features_doc(&import_function, &mut doc);
|
self.append_required_features_doc(&import_function, &mut doc, &[]);
|
||||||
import_function.doc_comment = doc;
|
import_function.doc_comment = doc;
|
||||||
program.imports.push(wrap_import_function(import_function));
|
program.imports.push(wrap_import_function(import_function));
|
||||||
}
|
}
|
||||||
@ -585,7 +596,7 @@ impl<'src> FirstPassRecord<'src> {
|
|||||||
container_attrs,
|
container_attrs,
|
||||||
) {
|
) {
|
||||||
let mut doc = import_function.doc_comment.take();
|
let mut doc = import_function.doc_comment.take();
|
||||||
self.append_required_features_doc(&import_function, &mut doc);
|
self.append_required_features_doc(&import_function, &mut doc, &[]);
|
||||||
import_function.doc_comment = doc;
|
import_function.doc_comment = doc;
|
||||||
program.imports.push(wrap_import_function(import_function));
|
program.imports.push(wrap_import_function(import_function));
|
||||||
}
|
}
|
||||||
@ -648,7 +659,7 @@ impl<'src> FirstPassRecord<'src> {
|
|||||||
let attrs = data.definition_attributes;
|
let attrs = data.definition_attributes;
|
||||||
for mut method in self.create_imports(attrs, kind, id, op_data) {
|
for mut method in self.create_imports(attrs, kind, id, op_data) {
|
||||||
let mut doc = doc.clone();
|
let mut doc = doc.clone();
|
||||||
self.append_required_features_doc(&method, &mut doc);
|
self.append_required_features_doc(&method, &mut doc, &[]);
|
||||||
method.doc_comment = doc;
|
method.doc_comment = doc;
|
||||||
program.imports.push(wrap_import_function(method));
|
program.imports.push(wrap_import_function(method));
|
||||||
}
|
}
|
||||||
@ -658,12 +669,15 @@ impl<'src> FirstPassRecord<'src> {
|
|||||||
&self,
|
&self,
|
||||||
item: impl ImportedTypeReferences,
|
item: impl ImportedTypeReferences,
|
||||||
doc: &mut Option<String>,
|
doc: &mut Option<String>,
|
||||||
|
extra: &[&str],
|
||||||
) {
|
) {
|
||||||
let doc = match doc {
|
let doc = match doc {
|
||||||
Some(doc) => doc,
|
Some(doc) => doc,
|
||||||
None => return,
|
None => return,
|
||||||
};
|
};
|
||||||
let mut required = BTreeSet::new();
|
let mut required = extra.iter()
|
||||||
|
.map(|s| Ident::new(s, Span::call_site()))
|
||||||
|
.collect::<BTreeSet<_>>();
|
||||||
item.imported_type_references(&mut |f| {
|
item.imported_type_references(&mut |f| {
|
||||||
if !self.builtin_idents.contains(f) {
|
if !self.builtin_idents.contains(f) {
|
||||||
required.insert(f.clone());
|
required.insert(f.clone());
|
||||||
@ -677,7 +691,7 @@ impl<'src> FirstPassRecord<'src> {
|
|||||||
.collect::<Vec<_>>()
|
.collect::<Vec<_>>()
|
||||||
.join(", ");
|
.join(", ");
|
||||||
doc.push_str(&format!(
|
doc.push_str(&format!(
|
||||||
"\n\n*This function requires the following crate features \
|
"\n\n*This API requires the following crate features \
|
||||||
to be activated: {}*",
|
to be activated: {}*",
|
||||||
list,
|
list,
|
||||||
));
|
));
|
||||||
|
@ -8,4 +8,4 @@ crate-type = ["cdylib"]
|
|||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
wasm-bindgen = { path = "../.." }
|
wasm-bindgen = { path = "../.." }
|
||||||
web-sys = { path = '../../crates/web-sys' }
|
web-sys = { path = '../../crates/web-sys', features = ['console'] }
|
||||||
|
Loading…
x
Reference in New Issue
Block a user