From ec08981b867049c1e7994c6671d454283ddf5e8b Mon Sep 17 00:00:00 2001 From: Jesse Wilson Date: Thu, 18 Jan 2024 14:41:04 -0500 Subject: [PATCH] Propagate more events to EventListener In particular: * manifestReady * codeLoadSkippedNotFresh --- .../cash/redwood/treehouse/EventListener.kt | 20 +++++++++++++++++++ .../redwood/treehouse/RealEventPublisher.kt | 16 +++++++++++++++ 2 files changed, 36 insertions(+) diff --git a/redwood-treehouse-host/src/commonMain/kotlin/app/cash/redwood/treehouse/EventListener.kt b/redwood-treehouse-host/src/commonMain/kotlin/app/cash/redwood/treehouse/EventListener.kt index 85da1c1e4b..b8673b7541 100644 --- a/redwood-treehouse-host/src/commonMain/kotlin/app/cash/redwood/treehouse/EventListener.kt +++ b/redwood-treehouse-host/src/commonMain/kotlin/app/cash/redwood/treehouse/EventListener.kt @@ -64,6 +64,17 @@ public open class EventListener { ) { } + /** + * Invoked when a code load is skipped because the cached code isn't up-to-date. + * + * @param startValue the value returned by [codeLoadStart] for the start of this call. This + * is null unless [codeLoadStart] is overridden to return something else. + */ + public open fun codeLoadSkippedNotFresh( + startValue: Any?, + ) { + } + /** * Invoked when a code load fails. * @@ -190,6 +201,15 @@ public open class EventListener { ) { } + /** + * Invoked when the loader has successfully fetched a manifest, verified it (if necessary), and + * will proceed to download and load each of its modules. + */ + public open fun manifestReady( + manifest: ZiplineManifest, + ) { + } + /** * Invoked when a module load starts. This is the process of loading code into QuickJS. * diff --git a/redwood-treehouse-host/src/commonMain/kotlin/app/cash/redwood/treehouse/RealEventPublisher.kt b/redwood-treehouse-host/src/commonMain/kotlin/app/cash/redwood/treehouse/RealEventPublisher.kt index 1d02138e6e..3654a59f22 100644 --- a/redwood-treehouse-host/src/commonMain/kotlin/app/cash/redwood/treehouse/RealEventPublisher.kt +++ b/redwood-treehouse-host/src/commonMain/kotlin/app/cash/redwood/treehouse/RealEventPublisher.kt @@ -61,6 +61,14 @@ internal class RealEventPublisher( listener.codeLoadSkipped(startValue) } + override fun applicationLoadSkippedNotFresh( + applicationName: String, + manifestUrl: String?, + startValue: Any?, + ) { + listener.codeLoadSkippedNotFresh(startValue) + } + override fun applicationLoadFailed( applicationName: String, manifestUrl: String?, @@ -115,6 +123,14 @@ internal class RealEventPublisher( listener.manifestVerified(manifest, verifiedKey) } + override fun manifestReady( + applicationName: String, + manifestUrl: String?, + manifest: ZiplineManifest, + ) { + listener.manifestReady(manifest) + } + override fun moduleLoadStart(zipline: Zipline, moduleId: String): Any? { return listener.moduleLoadStart(moduleId) }