Skip to content

Commit

Permalink
Add WebIDLs for File System Access API (continuing PR #3327) (#3427)
Browse files Browse the repository at this point in the history
Co-authored-by: Speak2Erase <matthew@nowaffles.com>
  • Loading branch information
djozis and Speak2Erase authored May 15, 2023
1 parent 15ca11b commit e6ec09c
Show file tree
Hide file tree
Showing 17 changed files with 1,190 additions and 0 deletions.
13 changes: 13 additions & 0 deletions crates/web-sys/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -382,13 +382,24 @@ FilePropertyBag = []
FileReader = ["EventTarget"]
FileReaderSync = []
FileSystem = []
FileSystemCreateWritableOptions = []
FileSystemDirectoryEntry = ["FileSystemEntry"]
FileSystemDirectoryHandle = ["FileSystemHandle"]
FileSystemDirectoryReader = []
FileSystemEntriesCallback = []
FileSystemEntry = []
FileSystemEntryCallback = []
FileSystemFileEntry = ["FileSystemEntry"]
FileSystemFileHandle = ["FileSystemHandle"]
FileSystemFlags = []
FileSystemGetDirectoryOptions = []
FileSystemGetFileOptions = []
FileSystemHandle = []
FileSystemHandleKind = []
FileSystemReadWriteOptions = []
FileSystemRemoveOptions = []
FileSystemSyncAccessHandle = []
FileSystemWritableFileStream = ["WritableStream"]
FillMode = []
FlashClassification = []
FlexLineGrowthState = []
Expand Down Expand Up @@ -1526,6 +1537,8 @@ WorkletOptions = []
WritableStream = []
WritableStreamDefaultController = []
WritableStreamDefaultWriter = []
WriteCommandType = []
WriteParams = []
XPathExpression = []
XPathNsResolver = []
XPathResult = []
Expand Down
57 changes: 57 additions & 0 deletions crates/web-sys/src/features/gen_FileSystemCreateWritableOptions.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
#![allow(unused_imports)]
use super::*;
use wasm_bindgen::prelude::*;
#[cfg(web_sys_unstable_apis)]
#[wasm_bindgen]
extern "C" {
# [wasm_bindgen (extends = :: js_sys :: Object , js_name = FileSystemCreateWritableOptions)]
#[derive(Debug, Clone, PartialEq, Eq)]
#[doc = "The `FileSystemCreateWritableOptions` dictionary."]
#[doc = ""]
#[doc = "*This API requires the following crate features to be activated: `FileSystemCreateWritableOptions`*"]
#[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 FileSystemCreateWritableOptions;
}
#[cfg(web_sys_unstable_apis)]
impl FileSystemCreateWritableOptions {
#[doc = "Construct a new `FileSystemCreateWritableOptions`."]
#[doc = ""]
#[doc = "*This API requires the following crate features to be activated: `FileSystemCreateWritableOptions`*"]
#[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 `keepExistingData` field of this object."]
#[doc = ""]
#[doc = "*This API requires the following crate features to be activated: `FileSystemCreateWritableOptions`*"]
#[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 keep_existing_data(&mut self, val: bool) -> &mut Self {
use wasm_bindgen::JsValue;
let r = ::js_sys::Reflect::set(
self.as_ref(),
&JsValue::from("keepExistingData"),
&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 FileSystemCreateWritableOptions {
fn default() -> Self {
Self::new()
}
}
113 changes: 113 additions & 0 deletions crates/web-sys/src/features/gen_FileSystemDirectoryHandle.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,113 @@
#![allow(unused_imports)]
use super::*;
use wasm_bindgen::prelude::*;
#[cfg(web_sys_unstable_apis)]
#[wasm_bindgen]
extern "C" {
# [wasm_bindgen (extends = FileSystemHandle , extends = :: js_sys :: Object , js_name = FileSystemDirectoryHandle , typescript_type = "FileSystemDirectoryHandle")]
#[derive(Debug, Clone, PartialEq, Eq)]
#[doc = "The `FileSystemDirectoryHandle` class."]
#[doc = ""]
#[doc = "[MDN Documentation](https://developer.mozilla.org/en-US/docs/Web/API/FileSystemDirectoryHandle)"]
#[doc = ""]
#[doc = "*This API requires the following crate features to be activated: `FileSystemDirectoryHandle`*"]
#[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 FileSystemDirectoryHandle;
#[cfg(web_sys_unstable_apis)]
# [wasm_bindgen (method , structural , js_class = "FileSystemDirectoryHandle" , js_name = getDirectoryHandle)]
#[doc = "The `getDirectoryHandle()` method."]
#[doc = ""]
#[doc = "[MDN Documentation](https://developer.mozilla.org/en-US/docs/Web/API/FileSystemDirectoryHandle/getDirectoryHandle)"]
#[doc = ""]
#[doc = "*This API requires the following crate features to be activated: `FileSystemDirectoryHandle`*"]
#[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_directory_handle(this: &FileSystemDirectoryHandle, name: &str) -> ::js_sys::Promise;
#[cfg(web_sys_unstable_apis)]
#[cfg(feature = "FileSystemGetDirectoryOptions")]
# [wasm_bindgen (method , structural , js_class = "FileSystemDirectoryHandle" , js_name = getDirectoryHandle)]
#[doc = "The `getDirectoryHandle()` method."]
#[doc = ""]
#[doc = "[MDN Documentation](https://developer.mozilla.org/en-US/docs/Web/API/FileSystemDirectoryHandle/getDirectoryHandle)"]
#[doc = ""]
#[doc = "*This API requires the following crate features to be activated: `FileSystemDirectoryHandle`, `FileSystemGetDirectoryOptions`*"]
#[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_directory_handle_with_options(
this: &FileSystemDirectoryHandle,
name: &str,
options: &FileSystemGetDirectoryOptions,
) -> ::js_sys::Promise;
#[cfg(web_sys_unstable_apis)]
# [wasm_bindgen (method , structural , js_class = "FileSystemDirectoryHandle" , js_name = getFileHandle)]
#[doc = "The `getFileHandle()` method."]
#[doc = ""]
#[doc = "[MDN Documentation](https://developer.mozilla.org/en-US/docs/Web/API/FileSystemDirectoryHandle/getFileHandle)"]
#[doc = ""]
#[doc = "*This API requires the following crate features to be activated: `FileSystemDirectoryHandle`*"]
#[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_file_handle(this: &FileSystemDirectoryHandle, name: &str) -> ::js_sys::Promise;
#[cfg(web_sys_unstable_apis)]
#[cfg(feature = "FileSystemGetFileOptions")]
# [wasm_bindgen (method , structural , js_class = "FileSystemDirectoryHandle" , js_name = getFileHandle)]
#[doc = "The `getFileHandle()` method."]
#[doc = ""]
#[doc = "[MDN Documentation](https://developer.mozilla.org/en-US/docs/Web/API/FileSystemDirectoryHandle/getFileHandle)"]
#[doc = ""]
#[doc = "*This API requires the following crate features to be activated: `FileSystemDirectoryHandle`, `FileSystemGetFileOptions`*"]
#[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_file_handle_with_options(
this: &FileSystemDirectoryHandle,
name: &str,
options: &FileSystemGetFileOptions,
) -> ::js_sys::Promise;
#[cfg(web_sys_unstable_apis)]
# [wasm_bindgen (method , structural , js_class = "FileSystemDirectoryHandle" , js_name = removeEntry)]
#[doc = "The `removeEntry()` method."]
#[doc = ""]
#[doc = "[MDN Documentation](https://developer.mozilla.org/en-US/docs/Web/API/FileSystemDirectoryHandle/removeEntry)"]
#[doc = ""]
#[doc = "*This API requires the following crate features to be activated: `FileSystemDirectoryHandle`*"]
#[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 remove_entry(this: &FileSystemDirectoryHandle, name: &str) -> ::js_sys::Promise;
#[cfg(web_sys_unstable_apis)]
#[cfg(feature = "FileSystemRemoveOptions")]
# [wasm_bindgen (method , structural , js_class = "FileSystemDirectoryHandle" , js_name = removeEntry)]
#[doc = "The `removeEntry()` method."]
#[doc = ""]
#[doc = "[MDN Documentation](https://developer.mozilla.org/en-US/docs/Web/API/FileSystemDirectoryHandle/removeEntry)"]
#[doc = ""]
#[doc = "*This API requires the following crate features to be activated: `FileSystemDirectoryHandle`, `FileSystemRemoveOptions`*"]
#[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 remove_entry_with_options(
this: &FileSystemDirectoryHandle,
name: &str,
options: &FileSystemRemoveOptions,
) -> ::js_sys::Promise;
#[cfg(web_sys_unstable_apis)]
# [wasm_bindgen (method , structural , js_class = "FileSystemDirectoryHandle" , js_name = resolve)]
#[doc = "The `resolve()` method."]
#[doc = ""]
#[doc = "[MDN Documentation](https://developer.mozilla.org/en-US/docs/Web/API/FileSystemDirectoryHandle/resolve)"]
#[doc = ""]
#[doc = "*This API requires the following crate features to be activated: `FileSystemDirectoryHandle`*"]
#[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 resolve(
this: &FileSystemDirectoryHandle,
possible_descendant: &FileSystemHandle,
) -> ::js_sys::Promise;
}
66 changes: 66 additions & 0 deletions crates/web-sys/src/features/gen_FileSystemFileHandle.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
#![allow(unused_imports)]
use super::*;
use wasm_bindgen::prelude::*;
#[cfg(web_sys_unstable_apis)]
#[wasm_bindgen]
extern "C" {
# [wasm_bindgen (extends = FileSystemHandle , extends = :: js_sys :: Object , js_name = FileSystemFileHandle , typescript_type = "FileSystemFileHandle")]
#[derive(Debug, Clone, PartialEq, Eq)]
#[doc = "The `FileSystemFileHandle` class."]
#[doc = ""]
#[doc = "[MDN Documentation](https://developer.mozilla.org/en-US/docs/Web/API/FileSystemFileHandle)"]
#[doc = ""]
#[doc = "*This API requires the following crate features to be activated: `FileSystemFileHandle`*"]
#[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 FileSystemFileHandle;
#[cfg(web_sys_unstable_apis)]
# [wasm_bindgen (method , structural , js_class = "FileSystemFileHandle" , js_name = createSyncAccessHandle)]
#[doc = "The `createSyncAccessHandle()` method."]
#[doc = ""]
#[doc = "[MDN Documentation](https://developer.mozilla.org/en-US/docs/Web/API/FileSystemFileHandle/createSyncAccessHandle)"]
#[doc = ""]
#[doc = "*This API requires the following crate features to be activated: `FileSystemFileHandle`*"]
#[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 create_sync_access_handle(this: &FileSystemFileHandle) -> ::js_sys::Promise;
#[cfg(web_sys_unstable_apis)]
# [wasm_bindgen (method , structural , js_class = "FileSystemFileHandle" , js_name = createWritable)]
#[doc = "The `createWritable()` method."]
#[doc = ""]
#[doc = "[MDN Documentation](https://developer.mozilla.org/en-US/docs/Web/API/FileSystemFileHandle/createWritable)"]
#[doc = ""]
#[doc = "*This API requires the following crate features to be activated: `FileSystemFileHandle`*"]
#[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 create_writable(this: &FileSystemFileHandle) -> ::js_sys::Promise;
#[cfg(web_sys_unstable_apis)]
#[cfg(feature = "FileSystemCreateWritableOptions")]
# [wasm_bindgen (method , structural , js_class = "FileSystemFileHandle" , js_name = createWritable)]
#[doc = "The `createWritable()` method."]
#[doc = ""]
#[doc = "[MDN Documentation](https://developer.mozilla.org/en-US/docs/Web/API/FileSystemFileHandle/createWritable)"]
#[doc = ""]
#[doc = "*This API requires the following crate features to be activated: `FileSystemCreateWritableOptions`, `FileSystemFileHandle`*"]
#[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 create_writable_with_options(
this: &FileSystemFileHandle,
options: &FileSystemCreateWritableOptions,
) -> ::js_sys::Promise;
#[cfg(web_sys_unstable_apis)]
# [wasm_bindgen (method , structural , js_class = "FileSystemFileHandle" , js_name = getFile)]
#[doc = "The `getFile()` method."]
#[doc = ""]
#[doc = "[MDN Documentation](https://developer.mozilla.org/en-US/docs/Web/API/FileSystemFileHandle/getFile)"]
#[doc = ""]
#[doc = "*This API requires the following crate features to be activated: `FileSystemFileHandle`*"]
#[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_file(this: &FileSystemFileHandle) -> ::js_sys::Promise;
}
54 changes: 54 additions & 0 deletions crates/web-sys/src/features/gen_FileSystemGetDirectoryOptions.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
#![allow(unused_imports)]
use super::*;
use wasm_bindgen::prelude::*;
#[cfg(web_sys_unstable_apis)]
#[wasm_bindgen]
extern "C" {
# [wasm_bindgen (extends = :: js_sys :: Object , js_name = FileSystemGetDirectoryOptions)]
#[derive(Debug, Clone, PartialEq, Eq)]
#[doc = "The `FileSystemGetDirectoryOptions` dictionary."]
#[doc = ""]
#[doc = "*This API requires the following crate features to be activated: `FileSystemGetDirectoryOptions`*"]
#[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 FileSystemGetDirectoryOptions;
}
#[cfg(web_sys_unstable_apis)]
impl FileSystemGetDirectoryOptions {
#[doc = "Construct a new `FileSystemGetDirectoryOptions`."]
#[doc = ""]
#[doc = "*This API requires the following crate features to be activated: `FileSystemGetDirectoryOptions`*"]
#[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 `create` field of this object."]
#[doc = ""]
#[doc = "*This API requires the following crate features to be activated: `FileSystemGetDirectoryOptions`*"]
#[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 create(&mut self, val: bool) -> &mut Self {
use wasm_bindgen::JsValue;
let r =
::js_sys::Reflect::set(self.as_ref(), &JsValue::from("create"), &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 FileSystemGetDirectoryOptions {
fn default() -> Self {
Self::new()
}
}
54 changes: 54 additions & 0 deletions crates/web-sys/src/features/gen_FileSystemGetFileOptions.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
#![allow(unused_imports)]
use super::*;
use wasm_bindgen::prelude::*;
#[cfg(web_sys_unstable_apis)]
#[wasm_bindgen]
extern "C" {
# [wasm_bindgen (extends = :: js_sys :: Object , js_name = FileSystemGetFileOptions)]
#[derive(Debug, Clone, PartialEq, Eq)]
#[doc = "The `FileSystemGetFileOptions` dictionary."]
#[doc = ""]
#[doc = "*This API requires the following crate features to be activated: `FileSystemGetFileOptions`*"]
#[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 FileSystemGetFileOptions;
}
#[cfg(web_sys_unstable_apis)]
impl FileSystemGetFileOptions {
#[doc = "Construct a new `FileSystemGetFileOptions`."]
#[doc = ""]
#[doc = "*This API requires the following crate features to be activated: `FileSystemGetFileOptions`*"]
#[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 `create` field of this object."]
#[doc = ""]
#[doc = "*This API requires the following crate features to be activated: `FileSystemGetFileOptions`*"]
#[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 create(&mut self, val: bool) -> &mut Self {
use wasm_bindgen::JsValue;
let r =
::js_sys::Reflect::set(self.as_ref(), &JsValue::from("create"), &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 FileSystemGetFileOptions {
fn default() -> Self {
Self::new()
}
}
Loading

0 comments on commit e6ec09c

Please sign in to comment.