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

Add unstable bindings for the FileSystemAccess API (#3799) #3810

Merged
merged 5 commits into from
Jan 24, 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
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,9 @@

### Added

* Add unstable bindings for the FileSystemAccess API
[#3810](https://github.com/rustwasm/wasm-bindgen/pull/3810)

* Added support for running tests in shared and service workers with ``wasm_bindgen_test_configure!` `run_in_shared_worker` and `run_in_service_worker`.
[#3804](https://github.com/rustwasm/wasm-bindgen/pull/3804)

Expand Down
9 changes: 9 additions & 0 deletions crates/web-sys/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -289,6 +289,7 @@ DeviceRotationRateInit = []
DhKeyDeriveParams = []
DirectionSetting = []
Directory = []
DirectoryPickerOptions = []
DisplayMediaStreamConstraints = []
DisplayNameOptions = []
DisplayNameResult = []
Expand Down Expand Up @@ -384,6 +385,8 @@ FetchState = []
File = ["Blob"]
FileCallback = []
FileList = []
FilePickerAcceptType = []
FilePickerOptions = []
FilePropertyBag = []
FileReader = ["EventTarget"]
FileReaderSync = []
Expand All @@ -402,6 +405,9 @@ FileSystemGetDirectoryOptions = []
FileSystemGetFileOptions = []
FileSystemHandle = []
FileSystemHandleKind = []
FileSystemHandlePermissionDescriptor = []
FileSystemPermissionDescriptor = []
FileSystemPermissionMode = []
FileSystemReadWriteOptions = []
FileSystemRemoveOptions = []
FileSystemSyncAccessHandle = []
Expand Down Expand Up @@ -895,6 +901,7 @@ OfflineAudioContextOptions = []
OfflineResourceList = ["EventTarget"]
OffscreenCanvas = ["EventTarget"]
OffscreenCanvasRenderingContext2d = []
OpenFilePickerOptions = []
OpenWindowEventDetail = []
OptionalEffectTiming = []
OrientationLockType = []
Expand Down Expand Up @@ -1135,6 +1142,7 @@ RtcdtmfToneChangeEvent = ["Event"]
RtcdtmfToneChangeEventInit = []
RtcrtpContributingSourceStats = []
RtcrtpStreamStats = []
SaveFilePickerOptions = []
Scheduler = []
SchedulerPostTaskOptions = []
Scheduling = []
Expand Down Expand Up @@ -1541,6 +1549,7 @@ WebglDepthTexture = []
WebglDrawBuffers = []
WebglLoseContext = []
WebglMultiDraw = []
WellKnownDirectory = []
WgslLanguageFeatures = []
WheelEvent = ["Event", "MouseEvent", "UiEvent"]
WheelEventInit = []
Expand Down
11 changes: 11 additions & 0 deletions crates/web-sys/src/features/gen_DataTransferItem.rs
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,17 @@ extern "C" {
#[doc = ""]
#[doc = "*This API requires the following crate features to be activated: `DataTransferItem`, `File`*"]
pub fn get_as_file(this: &DataTransferItem) -> Result<Option<File>, JsValue>;
#[cfg(web_sys_unstable_apis)]
# [wasm_bindgen (method , structural , js_class = "DataTransferItem" , js_name = getAsFileSystemHandle)]
#[doc = "The `getAsFileSystemHandle()` method."]
#[doc = ""]
#[doc = "[MDN Documentation](https://developer.mozilla.org/en-US/docs/Web/API/DataTransferItem/getAsFileSystemHandle)"]
#[doc = ""]
#[doc = "*This API requires the following crate features to be activated: `DataTransferItem`*"]
#[doc = ""]
#[doc = "*This API is unstable and requires `--cfg=web_sys_unstable_apis` to be activated, as"]
#[doc = "[described in the `wasm-bindgen` guide](https://rustwasm.github.io/docs/wasm-bindgen/web-sys/unstable-apis.html)*"]
pub fn get_as_file_system_handle(this: &DataTransferItem) -> ::js_sys::Promise;
# [wasm_bindgen (catch , method , structural , js_class = "DataTransferItem" , js_name = getAsString)]
#[doc = "The `getAsString()` method."]
#[doc = ""]
Expand Down
93 changes: 93 additions & 0 deletions crates/web-sys/src/features/gen_DirectoryPickerOptions.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,93 @@
#![allow(unused_imports)]
#![allow(clippy::all)]
use super::*;
use wasm_bindgen::prelude::*;
#[cfg(web_sys_unstable_apis)]
#[wasm_bindgen]
extern "C" {
# [wasm_bindgen (extends = :: js_sys :: Object , js_name = DirectoryPickerOptions)]
#[derive(Debug, Clone, PartialEq, Eq)]
#[doc = "The `DirectoryPickerOptions` dictionary."]
#[doc = ""]
#[doc = "*This API requires the following crate features to be activated: `DirectoryPickerOptions`*"]
#[doc = ""]
#[doc = "*This API is unstable and requires `--cfg=web_sys_unstable_apis` to be activated, as"]
#[doc = "[described in the `wasm-bindgen` guide](https://rustwasm.github.io/docs/wasm-bindgen/web-sys/unstable-apis.html)*"]
pub type DirectoryPickerOptions;
}
#[cfg(web_sys_unstable_apis)]
impl DirectoryPickerOptions {
#[doc = "Construct a new `DirectoryPickerOptions`."]
#[doc = ""]
#[doc = "*This API requires the following crate features to be activated: `DirectoryPickerOptions`*"]
#[doc = ""]
#[doc = "*This API is unstable and requires `--cfg=web_sys_unstable_apis` to be activated, as"]
#[doc = "[described in the `wasm-bindgen` guide](https://rustwasm.github.io/docs/wasm-bindgen/web-sys/unstable-apis.html)*"]
pub fn new() -> Self {
#[allow(unused_mut)]
let mut ret: Self = ::wasm_bindgen::JsCast::unchecked_into(::js_sys::Object::new());
ret
}
#[cfg(web_sys_unstable_apis)]
#[doc = "Change the `id` field of this object."]
#[doc = ""]
#[doc = "*This API requires the following crate features to be activated: `DirectoryPickerOptions`*"]
#[doc = ""]
#[doc = "*This API is unstable and requires `--cfg=web_sys_unstable_apis` to be activated, as"]
#[doc = "[described in the `wasm-bindgen` guide](https://rustwasm.github.io/docs/wasm-bindgen/web-sys/unstable-apis.html)*"]
pub fn id(&mut self, val: &str) -> &mut Self {
use wasm_bindgen::JsValue;
let r = ::js_sys::Reflect::set(self.as_ref(), &JsValue::from("id"), &JsValue::from(val));
debug_assert!(
r.is_ok(),
"setting properties should never fail on our dictionary objects"
);
let _ = r;
self
}
#[cfg(web_sys_unstable_apis)]
#[cfg(feature = "FileSystemPermissionMode")]
#[doc = "Change the `mode` field of this object."]
#[doc = ""]
#[doc = "*This API requires the following crate features to be activated: `DirectoryPickerOptions`, `FileSystemPermissionMode`*"]
#[doc = ""]
#[doc = "*This API is unstable and requires `--cfg=web_sys_unstable_apis` to be activated, as"]
#[doc = "[described in the `wasm-bindgen` guide](https://rustwasm.github.io/docs/wasm-bindgen/web-sys/unstable-apis.html)*"]
pub fn mode(&mut self, val: FileSystemPermissionMode) -> &mut Self {
use wasm_bindgen::JsValue;
let r = ::js_sys::Reflect::set(self.as_ref(), &JsValue::from("mode"), &JsValue::from(val));
debug_assert!(
r.is_ok(),
"setting properties should never fail on our dictionary objects"
);
let _ = r;
self
}
#[cfg(web_sys_unstable_apis)]
#[doc = "Change the `startIn` field of this object."]
#[doc = ""]
#[doc = "*This API requires the following crate features to be activated: `DirectoryPickerOptions`*"]
#[doc = ""]
#[doc = "*This API is unstable and requires `--cfg=web_sys_unstable_apis` to be activated, as"]
#[doc = "[described in the `wasm-bindgen` guide](https://rustwasm.github.io/docs/wasm-bindgen/web-sys/unstable-apis.html)*"]
pub fn start_in(&mut self, val: &::wasm_bindgen::JsValue) -> &mut Self {
use wasm_bindgen::JsValue;
let r = ::js_sys::Reflect::set(
self.as_ref(),
&JsValue::from("startIn"),
&JsValue::from(val),
);
debug_assert!(
r.is_ok(),
"setting properties should never fail on our dictionary objects"
);
let _ = r;
self
}
}
#[cfg(web_sys_unstable_apis)]
impl Default for DirectoryPickerOptions {
fn default() -> Self {
Self::new()
}
}
58 changes: 58 additions & 0 deletions crates/web-sys/src/features/gen_FilePickerAcceptType.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
#![allow(unused_imports)]
#![allow(clippy::all)]
use super::*;
use wasm_bindgen::prelude::*;
#[cfg(web_sys_unstable_apis)]
#[wasm_bindgen]
extern "C" {
# [wasm_bindgen (extends = :: js_sys :: Object , js_name = FilePickerAcceptType)]
#[derive(Debug, Clone, PartialEq, Eq)]
#[doc = "The `FilePickerAcceptType` dictionary."]
#[doc = ""]
#[doc = "*This API requires the following crate features to be activated: `FilePickerAcceptType`*"]
#[doc = ""]
#[doc = "*This API is unstable and requires `--cfg=web_sys_unstable_apis` to be activated, as"]
#[doc = "[described in the `wasm-bindgen` guide](https://rustwasm.github.io/docs/wasm-bindgen/web-sys/unstable-apis.html)*"]
pub type FilePickerAcceptType;
}
#[cfg(web_sys_unstable_apis)]
impl FilePickerAcceptType {
#[doc = "Construct a new `FilePickerAcceptType`."]
#[doc = ""]
#[doc = "*This API requires the following crate features to be activated: `FilePickerAcceptType`*"]
#[doc = ""]
#[doc = "*This API is unstable and requires `--cfg=web_sys_unstable_apis` to be activated, as"]
#[doc = "[described in the `wasm-bindgen` guide](https://rustwasm.github.io/docs/wasm-bindgen/web-sys/unstable-apis.html)*"]
pub fn new() -> Self {
#[allow(unused_mut)]
let mut ret: Self = ::wasm_bindgen::JsCast::unchecked_into(::js_sys::Object::new());
ret
}
#[cfg(web_sys_unstable_apis)]
#[doc = "Change the `description` field of this object."]
#[doc = ""]
#[doc = "*This API requires the following crate features to be activated: `FilePickerAcceptType`*"]
#[doc = ""]
#[doc = "*This API is unstable and requires `--cfg=web_sys_unstable_apis` to be activated, as"]
#[doc = "[described in the `wasm-bindgen` guide](https://rustwasm.github.io/docs/wasm-bindgen/web-sys/unstable-apis.html)*"]
pub fn description(&mut self, val: &str) -> &mut Self {
use wasm_bindgen::JsValue;
let r = ::js_sys::Reflect::set(
self.as_ref(),
&JsValue::from("description"),
&JsValue::from(val),
);
debug_assert!(
r.is_ok(),
"setting properties should never fail on our dictionary objects"
);
let _ = r;
self
}
}
#[cfg(web_sys_unstable_apis)]
impl Default for FilePickerAcceptType {
fn default() -> Self {
Self::new()
}
}
113 changes: 113 additions & 0 deletions crates/web-sys/src/features/gen_FilePickerOptions.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,113 @@
#![allow(unused_imports)]
#![allow(clippy::all)]
use super::*;
use wasm_bindgen::prelude::*;
#[cfg(web_sys_unstable_apis)]
#[wasm_bindgen]
extern "C" {
# [wasm_bindgen (extends = :: js_sys :: Object , js_name = FilePickerOptions)]
#[derive(Debug, Clone, PartialEq, Eq)]
#[doc = "The `FilePickerOptions` dictionary."]
#[doc = ""]
#[doc = "*This API requires the following crate features to be activated: `FilePickerOptions`*"]
#[doc = ""]
#[doc = "*This API is unstable and requires `--cfg=web_sys_unstable_apis` to be activated, as"]
#[doc = "[described in the `wasm-bindgen` guide](https://rustwasm.github.io/docs/wasm-bindgen/web-sys/unstable-apis.html)*"]
pub type FilePickerOptions;
}
#[cfg(web_sys_unstable_apis)]
impl FilePickerOptions {
#[doc = "Construct a new `FilePickerOptions`."]
#[doc = ""]
#[doc = "*This API requires the following crate features to be activated: `FilePickerOptions`*"]
#[doc = ""]
#[doc = "*This API is unstable and requires `--cfg=web_sys_unstable_apis` to be activated, as"]
#[doc = "[described in the `wasm-bindgen` guide](https://rustwasm.github.io/docs/wasm-bindgen/web-sys/unstable-apis.html)*"]
pub fn new() -> Self {
#[allow(unused_mut)]
let mut ret: Self = ::wasm_bindgen::JsCast::unchecked_into(::js_sys::Object::new());
ret
}
#[cfg(web_sys_unstable_apis)]
#[doc = "Change the `excludeAcceptAllOption` field of this object."]
#[doc = ""]
#[doc = "*This API requires the following crate features to be activated: `FilePickerOptions`*"]
#[doc = ""]
#[doc = "*This API is unstable and requires `--cfg=web_sys_unstable_apis` to be activated, as"]
#[doc = "[described in the `wasm-bindgen` guide](https://rustwasm.github.io/docs/wasm-bindgen/web-sys/unstable-apis.html)*"]
pub fn exclude_accept_all_option(&mut self, val: bool) -> &mut Self {
use wasm_bindgen::JsValue;
let r = ::js_sys::Reflect::set(
self.as_ref(),
&JsValue::from("excludeAcceptAllOption"),
&JsValue::from(val),
);
debug_assert!(
r.is_ok(),
"setting properties should never fail on our dictionary objects"
);
let _ = r;
self
}
#[cfg(web_sys_unstable_apis)]
#[doc = "Change the `id` field of this object."]
#[doc = ""]
#[doc = "*This API requires the following crate features to be activated: `FilePickerOptions`*"]
#[doc = ""]
#[doc = "*This API is unstable and requires `--cfg=web_sys_unstable_apis` to be activated, as"]
#[doc = "[described in the `wasm-bindgen` guide](https://rustwasm.github.io/docs/wasm-bindgen/web-sys/unstable-apis.html)*"]
pub fn id(&mut self, val: &str) -> &mut Self {
use wasm_bindgen::JsValue;
let r = ::js_sys::Reflect::set(self.as_ref(), &JsValue::from("id"), &JsValue::from(val));
debug_assert!(
r.is_ok(),
"setting properties should never fail on our dictionary objects"
);
let _ = r;
self
}
#[cfg(web_sys_unstable_apis)]
#[doc = "Change the `startIn` field of this object."]
#[doc = ""]
#[doc = "*This API requires the following crate features to be activated: `FilePickerOptions`*"]
#[doc = ""]
#[doc = "*This API is unstable and requires `--cfg=web_sys_unstable_apis` to be activated, as"]
#[doc = "[described in the `wasm-bindgen` guide](https://rustwasm.github.io/docs/wasm-bindgen/web-sys/unstable-apis.html)*"]
pub fn start_in(&mut self, val: &::wasm_bindgen::JsValue) -> &mut Self {
use wasm_bindgen::JsValue;
let r = ::js_sys::Reflect::set(
self.as_ref(),
&JsValue::from("startIn"),
&JsValue::from(val),
);
debug_assert!(
r.is_ok(),
"setting properties should never fail on our dictionary objects"
);
let _ = r;
self
}
#[cfg(web_sys_unstable_apis)]
#[doc = "Change the `types` field of this object."]
#[doc = ""]
#[doc = "*This API requires the following crate features to be activated: `FilePickerOptions`*"]
#[doc = ""]
#[doc = "*This API is unstable and requires `--cfg=web_sys_unstable_apis` to be activated, as"]
#[doc = "[described in the `wasm-bindgen` guide](https://rustwasm.github.io/docs/wasm-bindgen/web-sys/unstable-apis.html)*"]
pub fn types(&mut self, val: &::wasm_bindgen::JsValue) -> &mut Self {
use wasm_bindgen::JsValue;
let r = ::js_sys::Reflect::set(self.as_ref(), &JsValue::from("types"), &JsValue::from(val));
debug_assert!(
r.is_ok(),
"setting properties should never fail on our dictionary objects"
);
let _ = r;
self
}
}
#[cfg(web_sys_unstable_apis)]
impl Default for FilePickerOptions {
fn default() -> Self {
Self::new()
}
}
Loading