From 1521ec6cb27b562db57fd804cdbacd93f9495f6e Mon Sep 17 00:00:00 2001 From: Ivan Enderlin Date: Thu, 11 Jan 2024 15:05:00 +0100 Subject: [PATCH] Revert "matrix-sdk-indexeddb: make `matrix-sdk-base` an optional dependency" --- .github/workflows/ci.yml | 7 +++-- crates/matrix-sdk-crypto/Cargo.toml | 2 +- crates/matrix-sdk-indexeddb/Cargo.toml | 7 ++--- crates/matrix-sdk-indexeddb/README.md | 3 +- crates/matrix-sdk-indexeddb/src/lib.rs | 7 +---- crates/matrix-sdk/Cargo.toml | 2 +- xtask/src/ci.rs | 39 +++++++++----------------- 7 files changed, 25 insertions(+), 42 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index a5b69317d..396837951 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -210,8 +210,11 @@ jobs: - name: '[m]-common' cmd: matrix-sdk-common - - name: '[m]-indexeddb' - cmd: indexeddb + - name: '[m]-indexeddb, no crypto' + cmd: indexeddb-no-crypto + + - name: '[m]-indexeddb, with crypto' + cmd: indexeddb-with-crypto - name: '[m], no-default, wasm-flags' cmd: matrix-sdk-no-default diff --git a/crates/matrix-sdk-crypto/Cargo.toml b/crates/matrix-sdk-crypto/Cargo.toml index 1257eda92..023ec65ff 100644 --- a/crates/matrix-sdk-crypto/Cargo.toml +++ b/crates/matrix-sdk-crypto/Cargo.toml @@ -17,7 +17,7 @@ rustdoc-args = ["--cfg", "docsrs"] [features] default = [] automatic-room-key-forwarding = [] -js = ["ruma/js", "vodozemac/js", "matrix-sdk-common/js"] +js = ["ruma/js", "vodozemac/js"] qrcode = ["dep:matrix-sdk-qrcode"] message-ids = ["dep:ulid"] experimental-algorithms = [] diff --git a/crates/matrix-sdk-indexeddb/Cargo.toml b/crates/matrix-sdk-indexeddb/Cargo.toml index c5c6355e0..3718c5a5d 100644 --- a/crates/matrix-sdk-indexeddb/Cargo.toml +++ b/crates/matrix-sdk-indexeddb/Cargo.toml @@ -14,9 +14,8 @@ default-target = "wasm32-unknown-unknown" rustdoc-args = ["--cfg", "docsrs"] [features] -default = ["e2e-encryption", "state-store"] -state-store = ["dep:matrix-sdk-base"] -e2e-encryption = ["matrix-sdk-base?/e2e-encryption", "dep:matrix-sdk-crypto"] +default = ["e2e-encryption"] +e2e-encryption = ["matrix-sdk-base/e2e-encryption", "dep:matrix-sdk-crypto"] testing = ["matrix-sdk-crypto?/testing"] [dependencies] @@ -26,7 +25,7 @@ base64 = { workspace = true } gloo-utils = { version = "0.2.0", features = ["serde"] } indexed_db_futures = "0.4.1" js-sys = { version = "0.3.58" } -matrix-sdk-base = { workspace = true, features = ["js"], optional = true } +matrix-sdk-base = { workspace = true, features = ["js"] } matrix-sdk-crypto = { workspace = true, features = ["js"], optional = true } matrix-sdk-store-encryption = { workspace = true } ruma = { workspace = true } diff --git a/crates/matrix-sdk-indexeddb/README.md b/crates/matrix-sdk-indexeddb/README.md index 9917ca53b..27672ce6b 100644 --- a/crates/matrix-sdk-indexeddb/README.md +++ b/crates/matrix-sdk-indexeddb/README.md @@ -17,5 +17,4 @@ matrix-sdk = { version = "0.5, default-features = false, features = ["indexeddb" The following crate feature flags are available: -* `e2e-encryption`: (on by default) Enables the store for end-to-end encrypted data (`IndexeddbCryptoStore`). -* `state-store`: (on by default) Enables the `StateStore` implementation (`IndexeddbStateStore`). +* `e2e-encryption`: (on by default) Enables the store for end-to-end encrypted data. diff --git a/crates/matrix-sdk-indexeddb/src/lib.rs b/crates/matrix-sdk-indexeddb/src/lib.rs index faf24f9f8..9a86ac07a 100644 --- a/crates/matrix-sdk-indexeddb/src/lib.rs +++ b/crates/matrix-sdk-indexeddb/src/lib.rs @@ -1,6 +1,5 @@ #![cfg_attr(not(target_arch = "wasm32"), allow(unused))] -#[cfg(feature = "state-store")] use matrix_sdk_base::store::{StoreConfig, StoreError}; use thiserror::Error; @@ -9,12 +8,10 @@ mod crypto_store; mod safe_encode; #[cfg(feature = "e2e-encryption")] mod serialize_bool_for_indexeddb; -#[cfg(feature = "state-store")] mod state_store; #[cfg(feature = "e2e-encryption")] pub use crypto_store::{IndexeddbCryptoStore, IndexeddbCryptoStoreError}; -#[cfg(feature = "state-store")] pub use state_store::{ IndexeddbStateStore, IndexeddbStateStoreBuilder, IndexeddbStateStoreError, MigrationConflictStrategy, @@ -22,7 +19,7 @@ pub use state_store::{ /// Create a [`IndexeddbStateStore`] and a [`IndexeddbCryptoStore`] that use the /// same name and passphrase. -#[cfg(all(feature = "e2e-encryption", feature = "state-store"))] +#[cfg(feature = "e2e-encryption")] async fn open_stores_with_name( name: &str, passphrase: Option<&str>, @@ -43,7 +40,6 @@ async fn open_stores_with_name( /// Create a [`StoreConfig`] with an opened indexeddb [`IndexeddbStateStore`] /// that uses the given name and passphrase. If `encryption` is enabled, a /// [`IndexeddbCryptoStore`] with the same parameters is also opened. -#[cfg(feature = "state-store")] pub async fn make_store_config( name: &str, passphrase: Option<&str>, @@ -78,7 +74,6 @@ pub async fn make_store_config( #[derive(Error, Debug)] pub enum OpenStoreError { /// An error occurred with the state store implementation. - #[cfg(feature = "state-store")] #[error(transparent)] State(#[from] StoreError), diff --git a/crates/matrix-sdk/Cargo.toml b/crates/matrix-sdk/Cargo.toml index 9b820cd20..f053fe82d 100644 --- a/crates/matrix-sdk/Cargo.toml +++ b/crates/matrix-sdk/Cargo.toml @@ -29,7 +29,7 @@ js = ["matrix-sdk-common/js", "matrix-sdk-base/js"] sqlite = ["dep:matrix-sdk-sqlite", "matrix-sdk-sqlite?/state-store"] bundled-sqlite = ["sqlite", "matrix-sdk-sqlite?/bundled"] -indexeddb = ["matrix-sdk-indexeddb/state-store"] +indexeddb = ["dep:matrix-sdk-indexeddb"] qrcode = ["e2e-encryption", "matrix-sdk-base/qrcode"] automatic-room-key-forwarding = ["e2e-encryption", "matrix-sdk-base/automatic-room-key-forwarding"] diff --git a/xtask/src/ci.rs b/xtask/src/ci.rs index a4e473268..0a8fc0876 100644 --- a/xtask/src/ci.rs +++ b/xtask/src/ci.rs @@ -87,14 +87,11 @@ enum WasmFeatureSet { MatrixSdkIndexeddbStoresNoCrypto, /// Check `matrix-sdk` crate with `indexeddb` and `e2e-encryption` features MatrixSdkIndexeddbStores, - /// Check `matrix-sdk-indexeddb` crate with all features - IndexeddbAllFeatures, + /// Check `matrix-sdk-indexeddb` crate without `e2e-encryption` feature + IndexeddbNoCrypto, /// Check `matrix-sdk-indexeddb` crate with `e2e-encryption` feature - IndexeddbCrypto, - /// Check `matrix-sdk-indexeddb` crate with `state-store` feature - IndexeddbState, - /// Equivalent to `indexeddb-all-features`, `indexeddb-crypto` and - /// `indexeddb-state` + IndexeddbWithCrypto, + /// Equivalent to `IndexeddbNoCrypto` followed by `IndexeddbWithCrypto` Indexeddb, } @@ -272,9 +269,8 @@ fn run_crypto_tests() -> Result<()> { fn run_wasm_checks(cmd: Option) -> Result<()> { if let Some(WasmFeatureSet::Indexeddb) = cmd { - run_wasm_checks(Some(WasmFeatureSet::IndexeddbAllFeatures))?; - run_wasm_checks(Some(WasmFeatureSet::IndexeddbCrypto))?; - run_wasm_checks(Some(WasmFeatureSet::IndexeddbState))?; + run_wasm_checks(Some(WasmFeatureSet::IndexeddbNoCrypto))?; + run_wasm_checks(Some(WasmFeatureSet::IndexeddbWithCrypto))?; return Ok(()); } @@ -294,15 +290,11 @@ fn run_wasm_checks(cmd: Option) -> Result<()> { WasmFeatureSet::MatrixSdkIndexeddbStores, "-p matrix-sdk --no-default-features --features js,indexeddb,e2e-encryption,rustls-tls", ), - (WasmFeatureSet::IndexeddbAllFeatures, "-p matrix-sdk-indexeddb"), + (WasmFeatureSet::IndexeddbNoCrypto, "-p matrix-sdk-indexeddb --no-default-features "), ( - WasmFeatureSet::IndexeddbCrypto, + WasmFeatureSet::IndexeddbWithCrypto, "-p matrix-sdk-indexeddb --no-default-features --features e2e-encryption", ), - ( - WasmFeatureSet::IndexeddbState, - "-p matrix-sdk-indexeddb --no-default-features --features state-store", - ), ]); let run = |arg_set: &str| { @@ -329,9 +321,8 @@ fn run_wasm_checks(cmd: Option) -> Result<()> { fn run_wasm_pack_tests(cmd: Option) -> Result<()> { if let Some(WasmFeatureSet::Indexeddb) = cmd { - run_wasm_pack_tests(Some(WasmFeatureSet::IndexeddbAllFeatures))?; - run_wasm_pack_tests(Some(WasmFeatureSet::IndexeddbCrypto))?; - run_wasm_pack_tests(Some(WasmFeatureSet::IndexeddbState))?; + run_wasm_pack_tests(Some(WasmFeatureSet::IndexeddbNoCrypto))?; + run_wasm_pack_tests(Some(WasmFeatureSet::IndexeddbWithCrypto))?; return Ok(()); } let args = BTreeMap::from([ @@ -354,17 +345,13 @@ fn run_wasm_pack_tests(cmd: Option) -> Result<()> { ), ), ( - WasmFeatureSet::IndexeddbAllFeatures, - ("crates/matrix-sdk-indexeddb", ""), + WasmFeatureSet::IndexeddbNoCrypto, + ("crates/matrix-sdk-indexeddb", "--no-default-features"), ), ( - WasmFeatureSet::IndexeddbCrypto, + WasmFeatureSet::IndexeddbWithCrypto, ("crates/matrix-sdk-indexeddb", "--no-default-features --features e2e-encryption"), ), - ( - WasmFeatureSet::IndexeddbState, - ("crates/matrix-sdk-indexeddb", "--no-default-features --features state-store"), - ), ]); let run = |(folder, arg_set): (&str, &str)| {