Merge pull request #3006 from matrix-org/revert-2995-rav/indexeddb_optional_base

Revert "matrix-sdk-indexeddb: make `matrix-sdk-base` an optional dependency"
This commit is contained in:
Ivan Enderlin
2024-01-11 15:18:27 +01:00
committed by GitHub
7 changed files with 25 additions and 42 deletions

View File

@@ -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

View File

@@ -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 = []

View File

@@ -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 }

View File

@@ -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.

View File

@@ -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),

View File

@@ -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"]

View File

@@ -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<WasmFeatureSet>) -> 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<WasmFeatureSet>) -> 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<WasmFeatureSet>) -> Result<()> {
fn run_wasm_pack_tests(cmd: Option<WasmFeatureSet>) -> 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<WasmFeatureSet>) -> 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)| {