Package-level declarations

WidgetBridge publishes a @Serializable payload plus WidgetAssets as an atomic generation and reads it back as a ResolvedFeed. Platform wiring: androidWidgetBridge / iosWidgetBridge. Helpers: WidgetImages and AssetBudget for images, WidgetRotation for hourly rotation shared with the Swift package. The Swift reader lives in Sources/WidgetBridge.

WidgetBridge publishes a @Serializable payload plus WidgetAssets as an atomic generation and reads it back as a ResolvedFeed. Platform wiring: androidWidgetBridge / iosWidgetBridge. Helpers: WidgetImages and AssetBudget for images, WidgetRotation for hourly rotation shared with the Swift package. The Swift reader lives in Sources/WidgetBridge.

WidgetBridge publishes a @Serializable payload plus WidgetAssets as an atomic generation and reads it back as a ResolvedFeed. Platform wiring: androidWidgetBridge / iosWidgetBridge. Helpers: WidgetImages and AssetBudget for images, WidgetRotation for hourly rotation shared with the Swift package. The Swift reader lives in Sources/WidgetBridge.

Types

Link copied to clipboard

Generation folders under root; every promote and pointer write is an atomic rename.

Link copied to clipboard
class AppWidgetRefreshNotifier(context: ERROR CLASS: Symbol not found for Context, receiverClass: Class<*>) : WidgetRefreshNotifier

Broadcasts ACTION_APPWIDGET_UPDATE to receiverClass for every placed widget. No Glance dependency.

Link copied to clipboard
class AssetBudget(budgetBytes: Long = 8L * 1024 * 1024, maxDimension: Int = 512, maxBytes: Int = 2 * 1024 * 1024, encoder: (candidate: AssetCandidate, maxDimension: Int, maxBytes: Int) -> EncodedImage? = { c, dim, bytes -> WidgetImages.encode(c.sourcePath, c.format, dim, bytes) })

Greedy packer: encodes AssetCandidates in order until budgetBytes is spent; failures are skipped.

Link copied to clipboard
class AssetCandidate(val fileName: String, val sourcePath: String, val format: WidgetImageFormat)
Link copied to clipboard
class EncodedImage(val bytes: ByteArray, val extension: String)
Link copied to clipboard
class IosWidgetFeedStorage : WidgetFeedStorage

Generation folders inside the App Group container so the widget extension can read them.

Link copied to clipboard
class NotificationCenterRefreshNotifier : WidgetRefreshNotifier
Link copied to clipboard
sealed interface PublishResult
Link copied to clipboard

The generation a reader resolved: current, or the newest readable fallback.

Link copied to clipboard
class WidgetAsset(val fileName: String, val bytes: ByteArray)

An image (or any file) shipped inside a generation under assets/. fileName must satisfy isSafeName.

Link copied to clipboard
class WidgetBridge<T>(config: WidgetBridgeConfig, serializer: KSerializer<T>, storage: WidgetFeedStorage, notifier: WidgetRefreshNotifier, clock: () -> Long = { Clock.System.now().toEpochMilliseconds() })

Publishes a typed payload plus assets as an atomic generation and reads it back. Construct through androidWidgetBridge / iosWidgetBridge, or directly with a custom storage.

Link copied to clipboard
data class WidgetBridgeConfig(val schemaVersion: Int, val directoryName: String = "widgetbridge", val iosAppGroup: String? = null, val keepPrevious: Int = 1)
Link copied to clipboard

Platform filesystem operations for the generation-versioned export. Implement it yourself for a custom location; the defaults are AndroidWidgetFeedStorage and IosWidgetFeedStorage.

Link copied to clipboard
class WidgetGeneration(val id: String, val directoryPath: String, val feedBytes: ByteArray)

One exported generation as found on disk.

Link copied to clipboard
Link copied to clipboard
actual object WidgetImages
expect object WidgetImages

Downsamples an image file for a widget. PNG keeps transparency (cutouts); JPEG for photos.

actual object WidgetImages
Link copied to clipboard
fun interface WidgetRefreshNotifier

Tells the OS that a new generation is current so widgets redraw. Platform defaults exist; None for tests.

Link copied to clipboard

Deterministic hourly rotation shared by Kotlin and Swift readers so both platforms show the same item.

Properties

Link copied to clipboard

Name observed by the Swift package's WidgetBridgeReloader, which calls WidgetCenter.reloadAllTimelines().

Functions

Link copied to clipboard
fun <T> androidWidgetBridge(context: ERROR CLASS: Symbol not found for Context, config: WidgetBridgeConfig, serializer: KSerializer<T>, receiverClass: Class<*>): WidgetBridge<T>

Default Android wiring: files-dir storage plus an app-widget update broadcast to receiverClass.

Link copied to clipboard
fun <T> iosWidgetBridge(config: WidgetBridgeConfig, serializer: KSerializer<T>): WidgetBridge<T>

Default iOS wiring: App Group storage plus a NotificationCenter post. Requires WidgetBridgeConfig.iosAppGroup.

Link copied to clipboard

Letters, digits, -, _, .; never blank. Rejects path separators and traversal by construction.