Skip to content

Commit

Permalink
Put FileSystem before Path in APIs (#1952)
Browse files Browse the repository at this point in the history
  • Loading branch information
JakeWharton authored Apr 10, 2024
1 parent f365275 commit 8b4a41d
Show file tree
Hide file tree
Showing 9 changed files with 67 additions and 9 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ New:
Changed:
- Removed generated `typealias`es for package names which changed in 0.10.0.
- In `UIViewLazyList`'s `UITableView`, adding special-case handling for programmatic scroll-to-top calls.
- APIs accepting a `FileSystem` and `Path` now have the `FileSystem` coming before the `Path` in the parameter list. Compatibility functions are retained for this version, but will be removed in the next version.

Fixed:
- Work around a problem with our memory-leak fix where our old LazyList code would crash when its placeholders were unexpectedly removed.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,9 @@ public abstract class app/cash/redwood/treehouse/TreehouseApp$Spec {
}

public final class app/cash/redwood/treehouse/TreehouseAppFactoryAndroidKt {
public static final fun TreehouseAppFactory (Landroid/content/Context;Lokhttp3/OkHttpClient;Lapp/cash/zipline/loader/ManifestVerifier;Lokio/Path;Lokio/FileSystem;Ljava/lang/String;JILapp/cash/redwood/treehouse/StateStore;)Lapp/cash/redwood/treehouse/TreehouseApp$Factory;
public static final fun TreehouseAppFactory (Landroid/content/Context;Lokhttp3/OkHttpClient;Lapp/cash/zipline/loader/ManifestVerifier;Lokio/FileSystem;Lokio/Path;Ljava/lang/String;JILapp/cash/redwood/treehouse/StateStore;)Lapp/cash/redwood/treehouse/TreehouseApp$Factory;
public static final synthetic fun TreehouseAppFactory (Landroid/content/Context;Lokhttp3/OkHttpClient;Lapp/cash/zipline/loader/ManifestVerifier;Lokio/Path;Lokio/FileSystem;Ljava/lang/String;JILapp/cash/redwood/treehouse/StateStore;)Lapp/cash/redwood/treehouse/TreehouseApp$Factory;
public static synthetic fun TreehouseAppFactory$default (Landroid/content/Context;Lokhttp3/OkHttpClient;Lapp/cash/zipline/loader/ManifestVerifier;Lokio/FileSystem;Lokio/Path;Ljava/lang/String;JILapp/cash/redwood/treehouse/StateStore;ILjava/lang/Object;)Lapp/cash/redwood/treehouse/TreehouseApp$Factory;
public static synthetic fun TreehouseAppFactory$default (Landroid/content/Context;Lokhttp3/OkHttpClient;Lapp/cash/zipline/loader/ManifestVerifier;Lokio/Path;Lokio/FileSystem;Ljava/lang/String;JILapp/cash/redwood/treehouse/StateStore;ILjava/lang/Object;)Lapp/cash/redwood/treehouse/TreehouseApp$Factory;
}

Expand Down
2 changes: 2 additions & 0 deletions redwood-treehouse-host/api/redwood-treehouse-host.klib.api
Original file line number Diff line number Diff line change
Expand Up @@ -161,4 +161,6 @@ final class app.cash.redwood.treehouse/TreehouseUIView : app.cash.redwood.treeho
final fun <set-stateSnapshotId>(app.cash.redwood.treehouse/StateSnapshot.Id) // app.cash.redwood.treehouse/TreehouseUIView.stateSnapshotId.<set-stateSnapshotId>|<set-stateSnapshotId>(app.cash.redwood.treehouse.StateSnapshot.Id){}[0]
}
// Targets: [ios]
final fun app.cash.redwood.treehouse/TreehouseAppFactory(app.cash.zipline.loader/ZiplineHttpClient, app.cash.zipline.loader/ManifestVerifier, okio/FileSystem? =..., okio/Path? =..., kotlin/String =..., kotlin/Long =..., kotlin/Int =..., app.cash.redwood.treehouse/StateStore =...): app.cash.redwood.treehouse/TreehouseApp.Factory // app.cash.redwood.treehouse/TreehouseAppFactory|TreehouseAppFactory(app.cash.zipline.loader.ZiplineHttpClient;app.cash.zipline.loader.ManifestVerifier;okio.FileSystem?;okio.Path?;kotlin.String;kotlin.Long;kotlin.Int;app.cash.redwood.treehouse.StateStore){}[0]
// Targets: [ios]
final fun app.cash.redwood.treehouse/TreehouseAppFactory(app.cash.zipline.loader/ZiplineHttpClient, app.cash.zipline.loader/ManifestVerifier, okio/Path? =..., okio/FileSystem? =..., kotlin/String =..., kotlin/Long =..., kotlin/Int =..., app.cash.redwood.treehouse/StateStore =...): app.cash.redwood.treehouse/TreehouseApp.Factory // app.cash.redwood.treehouse/TreehouseAppFactory|TreehouseAppFactory(app.cash.zipline.loader.ZiplineHttpClient;app.cash.zipline.loader.ManifestVerifier;okio.Path?;okio.FileSystem?;kotlin.String;kotlin.Long;kotlin.Int;app.cash.redwood.treehouse.StateStore){}[0]
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ package app.cash.redwood.treehouse
import android.content.Context
import app.cash.zipline.loader.ManifestVerifier
import app.cash.zipline.loader.asZiplineHttpClient
import kotlin.DeprecationLevel.HIDDEN
import okhttp3.OkHttpClient
import okio.FileSystem
import okio.Path
Expand All @@ -27,8 +28,8 @@ public fun TreehouseAppFactory(
context: Context,
httpClient: OkHttpClient,
manifestVerifier: ManifestVerifier,
embeddedDir: Path? = null,
embeddedFileSystem: FileSystem? = null,
embeddedDir: Path? = null,
cacheName: String = "zipline",
cacheMaxSizeInBytes: Long = 50L * 1024L * 1024L,
concurrentDownloads: Int = 8,
Expand All @@ -39,8 +40,34 @@ public fun TreehouseAppFactory(
httpClient = httpClient.asZiplineHttpClient(),
frameClockFactory = AndroidChoreographerFrameClock.Factory(),
manifestVerifier = manifestVerifier,
embeddedFileSystem = embeddedFileSystem,
embeddedDir = embeddedDir,
cacheName = cacheName,
cacheMaxSizeInBytes = cacheMaxSizeInBytes,
concurrentDownloads = concurrentDownloads,
stateStore = stateStore,
)

@Deprecated("", level = HIDDEN) // TODO Delete overload once 0.11.0 ships.
@Suppress("FunctionName")
public fun TreehouseAppFactory(
context: Context,
httpClient: OkHttpClient,
manifestVerifier: ManifestVerifier,
embeddedDir: Path? = null,
embeddedFileSystem: FileSystem? = null,
cacheName: String = "zipline",
cacheMaxSizeInBytes: Long = 50L * 1024L * 1024L,
concurrentDownloads: Int = 8,
stateStore: StateStore = MemoryStateStore(),
): TreehouseApp.Factory = TreehouseApp.Factory(
platform = AndroidTreehousePlatform(context),
dispatchers = AndroidTreehouseDispatchers(),
httpClient = httpClient.asZiplineHttpClient(),
frameClockFactory = AndroidChoreographerFrameClock.Factory(),
manifestVerifier = manifestVerifier,
embeddedFileSystem = embeddedFileSystem,
embeddedDir = embeddedDir,
cacheName = cacheName,
cacheMaxSizeInBytes = cacheMaxSizeInBytes,
concurrentDownloads = concurrentDownloads,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -151,10 +151,10 @@ public class TreehouseApp<A : AppService> private constructor(
cache = factory.cache,
)

if (factory.embeddedDir != null && factory.embeddedFileSystem != null) {
if (factory.embeddedFileSystem != null && factory.embeddedDir != null) {
loader = loader.withEmbedded(
embeddedDir = factory.embeddedDir,
embeddedFileSystem = factory.embeddedFileSystem,
embeddedDir = factory.embeddedDir,
)
}
}
Expand Down Expand Up @@ -199,8 +199,8 @@ public class TreehouseApp<A : AppService> private constructor(
internal val httpClient: ZiplineHttpClient,
internal val frameClockFactory: FrameClock.Factory,
internal val manifestVerifier: ManifestVerifier,
internal val embeddedDir: Path?,
internal val embeddedFileSystem: FileSystem?,
internal val embeddedDir: Path?,
private val cacheName: String,
private val cacheMaxSizeInBytes: Long,
internal val concurrentDownloads: Int,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,15 +17,16 @@ package app.cash.redwood.treehouse

import app.cash.zipline.loader.ManifestVerifier
import app.cash.zipline.loader.ZiplineHttpClient
import kotlin.DeprecationLevel.HIDDEN
import okio.FileSystem
import okio.Path

@Suppress("FunctionName")
public fun TreehouseAppFactory(
httpClient: ZiplineHttpClient,
manifestVerifier: ManifestVerifier,
embeddedDir: Path? = null,
embeddedFileSystem: FileSystem? = null,
embeddedDir: Path? = null,
cacheName: String = "zipline",
cacheMaxSizeInBytes: Long = 50L * 1024L * 1024L,
concurrentDownloads: Int = 8,
Expand All @@ -36,8 +37,33 @@ public fun TreehouseAppFactory(
httpClient = httpClient,
frameClockFactory = IosDisplayLinkClock,
manifestVerifier = manifestVerifier,
embeddedFileSystem = embeddedFileSystem,
embeddedDir = embeddedDir,
cacheName = cacheName,
cacheMaxSizeInBytes = cacheMaxSizeInBytes,
concurrentDownloads = concurrentDownloads,
stateStore = stateStore,
)

@Deprecated("", level = HIDDEN) // TODO Delete overload once 0.11.0 ships.
@Suppress("FunctionName")
public fun TreehouseAppFactory(
httpClient: ZiplineHttpClient,
manifestVerifier: ManifestVerifier,
embeddedDir: Path? = null,
embeddedFileSystem: FileSystem? = null,
cacheName: String = "zipline",
cacheMaxSizeInBytes: Long = 50L * 1024L * 1024L,
concurrentDownloads: Int = 8,
stateStore: StateStore = MemoryStateStore(),
): TreehouseApp.Factory = TreehouseApp.Factory(
platform = IosTreehousePlatform(),
dispatchers = IosTreehouseDispatchers(),
httpClient = httpClient,
frameClockFactory = IosDisplayLinkClock,
manifestVerifier = manifestVerifier,
embeddedFileSystem = embeddedFileSystem,
embeddedDir = embeddedDir,
cacheName = cacheName,
cacheMaxSizeInBytes = cacheMaxSizeInBytes,
concurrentDownloads = concurrentDownloads,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -141,8 +141,8 @@ class EmojiSearchActivity : ComponentActivity() {
context = applicationContext,
httpClient = httpClient,
manifestVerifier = ManifestVerifier.Companion.NO_SIGNATURE_CHECKS,
embeddedDir = "/".toPath(),
embeddedFileSystem = applicationContext.assets.asFileSystem(),
embeddedDir = "/".toPath(),
)

val manifestUrlFlow = flowOf("http://10.0.2.2:8080/manifest.zipline.json")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -142,8 +142,8 @@ class EmojiSearchActivity : ComponentActivity() {
context = applicationContext,
httpClient = httpClient,
manifestVerifier = ManifestVerifier.NO_SIGNATURE_CHECKS,
embeddedDir = "/".toPath(),
embeddedFileSystem = applicationContext.assets.asFileSystem(),
embeddedDir = "/".toPath(),
stateStore = FileStateStore(
json = Json {
useArrayPolymorphism = true
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -126,8 +126,8 @@ class TestAppActivity : ComponentActivity() {
context = applicationContext,
httpClient = httpClient,
manifestVerifier = ManifestVerifier.NO_SIGNATURE_CHECKS,
embeddedDir = "/".toPath(),
embeddedFileSystem = applicationContext.assets.asFileSystem(),
embeddedDir = "/".toPath(),
stateStore = FileStateStore(
json = Json {
serializersModule = testAppSerializersModule
Expand Down

0 comments on commit 8b4a41d

Please sign in to comment.