Skip to content

Commit 0069b66

Browse files
authored
Add unstable bindings for the Compression Streams API (#3752)
1 parent a070715 commit 0069b66

File tree

7 files changed

+168
-0
lines changed

7 files changed

+168
-0
lines changed

CHANGELOG.md

+3
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,9 @@
1919
* Add bindings for `UserActivation`.
2020
[#3719](https://github.com/rustwasm/wasm-bindgen/pull/3719)
2121

22+
* Add unstable bindings for the Compression Streams API.
23+
[#3752](https://github.com/rustwasm/wasm-bindgen/pull/3752)
24+
2225
### Changed
2326

2427
* Stabilize File System API.

crates/web-sys/Cargo.toml

+3
Original file line numberDiff line numberDiff line change
@@ -203,6 +203,8 @@ Comment = ["CharacterData", "EventTarget", "Node"]
203203
CompositeOperation = []
204204
CompositionEvent = ["Event", "UiEvent"]
205205
CompositionEventInit = []
206+
CompressionFormat = []
207+
CompressionStream = []
206208
ComputedEffectTiming = []
207209
ConnStatusDict = []
208210
ConnectionType = []
@@ -268,6 +270,7 @@ DataTransferItemList = []
268270
DateTimeValue = []
269271
DecoderDoctorNotification = []
270272
DecoderDoctorNotificationType = []
273+
DecompressionStream = []
271274
DedicatedWorkerGlobalScope = ["EventTarget", "WorkerGlobalScope"]
272275
DelayNode = ["AudioNode", "EventTarget"]
273276
DelayOptions = []
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
#![allow(unused_imports)]
2+
#![allow(clippy::all)]
3+
use wasm_bindgen::prelude::*;
4+
#[cfg(web_sys_unstable_apis)]
5+
#[wasm_bindgen]
6+
#[doc = "The `CompressionFormat` enum."]
7+
#[doc = ""]
8+
#[doc = "*This API requires the following crate features to be activated: `CompressionFormat`*"]
9+
#[doc = ""]
10+
#[doc = "*This API is unstable and requires `--cfg=web_sys_unstable_apis` to be activated, as"]
11+
#[doc = "[described in the `wasm-bindgen` guide](https://rustwasm.github.io/docs/wasm-bindgen/web-sys/unstable-apis.html)*"]
12+
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
13+
pub enum CompressionFormat {
14+
Deflate = "deflate",
15+
DeflateRaw = "deflate-raw",
16+
Gzip = "gzip",
17+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
#![allow(unused_imports)]
2+
#![allow(clippy::all)]
3+
use super::*;
4+
use wasm_bindgen::prelude::*;
5+
#[cfg(web_sys_unstable_apis)]
6+
#[wasm_bindgen]
7+
extern "C" {
8+
# [wasm_bindgen (extends = :: js_sys :: Object , js_name = CompressionStream , typescript_type = "CompressionStream")]
9+
#[derive(Debug, Clone, PartialEq, Eq)]
10+
#[doc = "The `CompressionStream` class."]
11+
#[doc = ""]
12+
#[doc = "[MDN Documentation](https://developer.mozilla.org/en-US/docs/Web/API/CompressionStream)"]
13+
#[doc = ""]
14+
#[doc = "*This API requires the following crate features to be activated: `CompressionStream`*"]
15+
#[doc = ""]
16+
#[doc = "*This API is unstable and requires `--cfg=web_sys_unstable_apis` to be activated, as"]
17+
#[doc = "[described in the `wasm-bindgen` guide](https://rustwasm.github.io/docs/wasm-bindgen/web-sys/unstable-apis.html)*"]
18+
pub type CompressionStream;
19+
#[cfg(web_sys_unstable_apis)]
20+
#[cfg(feature = "ReadableStream")]
21+
# [wasm_bindgen (structural , method , getter , js_class = "CompressionStream" , js_name = readable)]
22+
#[doc = "Getter for the `readable` field of this object."]
23+
#[doc = ""]
24+
#[doc = "[MDN Documentation](https://developer.mozilla.org/en-US/docs/Web/API/CompressionStream/readable)"]
25+
#[doc = ""]
26+
#[doc = "*This API requires the following crate features to be activated: `CompressionStream`, `ReadableStream`*"]
27+
#[doc = ""]
28+
#[doc = "*This API is unstable and requires `--cfg=web_sys_unstable_apis` to be activated, as"]
29+
#[doc = "[described in the `wasm-bindgen` guide](https://rustwasm.github.io/docs/wasm-bindgen/web-sys/unstable-apis.html)*"]
30+
pub fn readable(this: &CompressionStream) -> ReadableStream;
31+
#[cfg(web_sys_unstable_apis)]
32+
#[cfg(feature = "WritableStream")]
33+
# [wasm_bindgen (structural , method , getter , js_class = "CompressionStream" , js_name = writable)]
34+
#[doc = "Getter for the `writable` field of this object."]
35+
#[doc = ""]
36+
#[doc = "[MDN Documentation](https://developer.mozilla.org/en-US/docs/Web/API/CompressionStream/writable)"]
37+
#[doc = ""]
38+
#[doc = "*This API requires the following crate features to be activated: `CompressionStream`, `WritableStream`*"]
39+
#[doc = ""]
40+
#[doc = "*This API is unstable and requires `--cfg=web_sys_unstable_apis` to be activated, as"]
41+
#[doc = "[described in the `wasm-bindgen` guide](https://rustwasm.github.io/docs/wasm-bindgen/web-sys/unstable-apis.html)*"]
42+
pub fn writable(this: &CompressionStream) -> WritableStream;
43+
#[cfg(web_sys_unstable_apis)]
44+
#[cfg(feature = "CompressionFormat")]
45+
#[wasm_bindgen(catch, constructor, js_class = "CompressionStream")]
46+
#[doc = "The `new CompressionStream(..)` constructor, creating a new instance of `CompressionStream`."]
47+
#[doc = ""]
48+
#[doc = "[MDN Documentation](https://developer.mozilla.org/en-US/docs/Web/API/CompressionStream/CompressionStream)"]
49+
#[doc = ""]
50+
#[doc = "*This API requires the following crate features to be activated: `CompressionFormat`, `CompressionStream`*"]
51+
#[doc = ""]
52+
#[doc = "*This API is unstable and requires `--cfg=web_sys_unstable_apis` to be activated, as"]
53+
#[doc = "[described in the `wasm-bindgen` guide](https://rustwasm.github.io/docs/wasm-bindgen/web-sys/unstable-apis.html)*"]
54+
pub fn new(format: CompressionFormat) -> Result<CompressionStream, JsValue>;
55+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
#![allow(unused_imports)]
2+
#![allow(clippy::all)]
3+
use super::*;
4+
use wasm_bindgen::prelude::*;
5+
#[cfg(web_sys_unstable_apis)]
6+
#[wasm_bindgen]
7+
extern "C" {
8+
# [wasm_bindgen (extends = :: js_sys :: Object , js_name = DecompressionStream , typescript_type = "DecompressionStream")]
9+
#[derive(Debug, Clone, PartialEq, Eq)]
10+
#[doc = "The `DecompressionStream` class."]
11+
#[doc = ""]
12+
#[doc = "[MDN Documentation](https://developer.mozilla.org/en-US/docs/Web/API/DecompressionStream)"]
13+
#[doc = ""]
14+
#[doc = "*This API requires the following crate features to be activated: `DecompressionStream`*"]
15+
#[doc = ""]
16+
#[doc = "*This API is unstable and requires `--cfg=web_sys_unstable_apis` to be activated, as"]
17+
#[doc = "[described in the `wasm-bindgen` guide](https://rustwasm.github.io/docs/wasm-bindgen/web-sys/unstable-apis.html)*"]
18+
pub type DecompressionStream;
19+
#[cfg(web_sys_unstable_apis)]
20+
#[cfg(feature = "ReadableStream")]
21+
# [wasm_bindgen (structural , method , getter , js_class = "DecompressionStream" , js_name = readable)]
22+
#[doc = "Getter for the `readable` field of this object."]
23+
#[doc = ""]
24+
#[doc = "[MDN Documentation](https://developer.mozilla.org/en-US/docs/Web/API/DecompressionStream/readable)"]
25+
#[doc = ""]
26+
#[doc = "*This API requires the following crate features to be activated: `DecompressionStream`, `ReadableStream`*"]
27+
#[doc = ""]
28+
#[doc = "*This API is unstable and requires `--cfg=web_sys_unstable_apis` to be activated, as"]
29+
#[doc = "[described in the `wasm-bindgen` guide](https://rustwasm.github.io/docs/wasm-bindgen/web-sys/unstable-apis.html)*"]
30+
pub fn readable(this: &DecompressionStream) -> ReadableStream;
31+
#[cfg(web_sys_unstable_apis)]
32+
#[cfg(feature = "WritableStream")]
33+
# [wasm_bindgen (structural , method , getter , js_class = "DecompressionStream" , js_name = writable)]
34+
#[doc = "Getter for the `writable` field of this object."]
35+
#[doc = ""]
36+
#[doc = "[MDN Documentation](https://developer.mozilla.org/en-US/docs/Web/API/DecompressionStream/writable)"]
37+
#[doc = ""]
38+
#[doc = "*This API requires the following crate features to be activated: `DecompressionStream`, `WritableStream`*"]
39+
#[doc = ""]
40+
#[doc = "*This API is unstable and requires `--cfg=web_sys_unstable_apis` to be activated, as"]
41+
#[doc = "[described in the `wasm-bindgen` guide](https://rustwasm.github.io/docs/wasm-bindgen/web-sys/unstable-apis.html)*"]
42+
pub fn writable(this: &DecompressionStream) -> WritableStream;
43+
#[cfg(web_sys_unstable_apis)]
44+
#[cfg(feature = "CompressionFormat")]
45+
#[wasm_bindgen(catch, constructor, js_class = "DecompressionStream")]
46+
#[doc = "The `new DecompressionStream(..)` constructor, creating a new instance of `DecompressionStream`."]
47+
#[doc = ""]
48+
#[doc = "[MDN Documentation](https://developer.mozilla.org/en-US/docs/Web/API/DecompressionStream/DecompressionStream)"]
49+
#[doc = ""]
50+
#[doc = "*This API requires the following crate features to be activated: `CompressionFormat`, `DecompressionStream`*"]
51+
#[doc = ""]
52+
#[doc = "*This API is unstable and requires `--cfg=web_sys_unstable_apis` to be activated, as"]
53+
#[doc = "[described in the `wasm-bindgen` guide](https://rustwasm.github.io/docs/wasm-bindgen/web-sys/unstable-apis.html)*"]
54+
pub fn new(format: CompressionFormat) -> Result<DecompressionStream, JsValue>;
55+
}

crates/web-sys/src/features/mod.rs

+18
Original file line numberDiff line numberDiff line change
@@ -1030,6 +1030,18 @@ mod gen_CompositionEventInit;
10301030
#[cfg(feature = "CompositionEventInit")]
10311031
pub use gen_CompositionEventInit::*;
10321032

1033+
#[cfg(feature = "CompressionFormat")]
1034+
#[allow(non_snake_case)]
1035+
mod gen_CompressionFormat;
1036+
#[cfg(feature = "CompressionFormat")]
1037+
pub use gen_CompressionFormat::*;
1038+
1039+
#[cfg(feature = "CompressionStream")]
1040+
#[allow(non_snake_case)]
1041+
mod gen_CompressionStream;
1042+
#[cfg(feature = "CompressionStream")]
1043+
pub use gen_CompressionStream::*;
1044+
10331045
#[cfg(feature = "ComputedEffectTiming")]
10341046
#[allow(non_snake_case)]
10351047
mod gen_ComputedEffectTiming;
@@ -1420,6 +1432,12 @@ mod gen_DecoderDoctorNotificationType;
14201432
#[cfg(feature = "DecoderDoctorNotificationType")]
14211433
pub use gen_DecoderDoctorNotificationType::*;
14221434

1435+
#[cfg(feature = "DecompressionStream")]
1436+
#[allow(non_snake_case)]
1437+
mod gen_DecompressionStream;
1438+
#[cfg(feature = "DecompressionStream")]
1439+
pub use gen_DecompressionStream::*;
1440+
14231441
#[cfg(feature = "DedicatedWorkerGlobalScope")]
14241442
#[allow(non_snake_case)]
14251443
mod gen_DedicatedWorkerGlobalScope;
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
enum CompressionFormat {
2+
"deflate",
3+
"deflate-raw",
4+
"gzip",
5+
};
6+
7+
[Exposed=*]
8+
interface CompressionStream {
9+
constructor(CompressionFormat format);
10+
};
11+
CompressionStream includes GenericTransformStream;
12+
13+
[Exposed=*]
14+
interface DecompressionStream {
15+
constructor(CompressionFormat format);
16+
};
17+
DecompressionStream includes GenericTransformStream;

0 commit comments

Comments
 (0)