Skip to content

Commit 3920949

Browse files
WIP OPFS impl
1 parent 2330a9d commit 3920949

6 files changed

Lines changed: 369 additions & 379 deletions

File tree

frontend/wrapper/src/editor_wrapper.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ use editor::messages::portfolio::utility_types::{DockingSplitDirection, FontCata
2424
use editor::messages::prelude::*;
2525
use editor::messages::tool::tool_messages::tool_prelude::WidgetId;
2626
#[cfg(all(not(feature = "native"), target_family = "wasm"))]
27-
use graph_craft::application_io::IndexedDbResourceStorage;
27+
use graph_craft::application_io::OpfsResourceStorage;
2828
use graph_craft::document::NodeId;
2929
use graphene_std::color::SRGBA8;
3030
use graphene_std::graphene_hash::CacheHashWrapper;
@@ -83,10 +83,10 @@ impl EditorWrapper {
8383
_ => unreachable!(),
8484
};
8585

86-
let storage: Box<dyn graph_craft::application_io::ResourceStorage> = match IndexedDbResourceStorage::load("graphite-resources").await {
86+
let storage: Box<dyn graph_craft::application_io::ResourceStorage> = match OpfsResourceStorage::load("resources").await {
8787
Ok(storage) => Box::new(storage),
8888
Err(error) => {
89-
log::error!("Failed to open IndexedDB resource storage, falling back to in-memory: {error:?}");
89+
log::error!("Failed to open OPFS resource storage, falling back to in-memory: {error:?}");
9090
Box::new(graph_craft::application_io::HashMapResourceStorage::new())
9191
}
9292
};

node-graph/graph-craft/Cargo.toml

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,16 @@ web-sys = { workspace = true, features = [
6666
"DomStringList",
6767
"Event",
6868
"EventTarget",
69+
"StorageManager",
70+
"FileSystemDirectoryHandle",
71+
"FileSystemFileHandle",
72+
"FileSystemGetFileOptions",
73+
"FileSystemGetDirectoryOptions",
74+
"FileSystemWritableFileStream",
75+
"FileSystemRemoveOptions",
76+
"WritableStream",
77+
"File",
78+
"Blob",
6979
] }
7080
js-sys = { workspace = true }
7181
wasm-bindgen = { workspace = true }

node-graph/graph-craft/src/application_io.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,10 @@ pub mod resource;
66

77
pub use graphene_application_io::{ApplicationIo, Resource, ResourceFuture, ResourceHash, ResourceStorage, Resources};
88
pub use resource::HashMapResourceStorage;
9-
#[cfg(target_family = "wasm")]
10-
pub use resource::indexed_db::IndexedDbResourceStorage;
119
#[cfg(not(target_family = "wasm"))]
1210
pub use resource::mmap::MmapResourceStorage;
11+
#[cfg(target_family = "wasm")]
12+
pub use resource::opfs::OpfsResourceStorage;
1313

1414
pub struct PlatformApplicationIo {
1515
#[cfg(feature = "wgpu")]

node-graph/graph-craft/src/application_io/resource.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
1-
#[cfg(target_family = "wasm")]
2-
pub mod indexed_db;
31
#[cfg(not(target_family = "wasm"))]
42
pub mod mmap;
3+
#[cfg(target_family = "wasm")]
4+
pub mod opfs;
55

66
use graphene_application_io::{Resource, ResourceFuture, ResourceHash, ResourceStorage, Resources};
77
use std::collections::HashMap;

0 commit comments

Comments
 (0)