Skip to content

Releases: FunnySaltyFish/ComposeDataSaver

v1.2.4 release

Choose a tag to compare

@FunnySaltyFish FunnySaltyFish released this 02 May 16:19

中文

Breaking Change

  • 移除了 data-saver-core 中的 DataSaverLogger。如果你之前直接使用它,需要改为直接调用 Log。
  • 日志配置从单一的 DEBUG 开关演进为 logLevel 分级控制。DEBUG 仍可兼容使用,但后续应迁移到 DataSaverConfig.logLevel。

其他更新

  • 修复:类型转换器现已可正确处理泛型(例如,同时注册 List/List 时,能自动匹配对应的转换器)
  • 修复:wasmJs 版本的外部数据感知改为 JS 实现,可实现跨实例监听
  • 默认日志级别调整为 INFO,关键的读取、恢复、写入、移除和外部数据变更日志在默认配置下即可看到。
  • 新增统一日志流能力,日志可同时输出到底层 logger,并接入示例应用中的 UI 日志面板。
  • 重构 ExampleComposables 示例页面,调整为更清晰的分组布局,保留各演示项的可读性。
  • 将日志区域改为侧边栏形式,支持随时展开查看、切换日志级别、清空日志和测试输出。

English

Breaking Changes

  • Fix: Type converters now handle generics correctly (e.g., when both List<String> and List<Int> are registered, the corresponding converter is automatically matched)
  • Fix: External data awareness in the wasmJs version has been switched to a JS implementation, enabling cross-instance observation
  • Removed DataSaverLogger from data-saver-core. If your code referenced it directly, migrate to Log.
  • Logging configuration has been upgraded from a single DEBUG switch to leveled logging with logLevel. DEBUG is still kept for compatibility, but DataSaverConfig.logLevel is now the recommended
    API.

Other Updates

  • Fix: Type converters now handle generics correctly (e.g., when both List<String> and List<Int> are registered, the corresponding converter is automatically matched)
  • Fix: External data awareness in the wasmJs version has been switched to a JS implementation, enabling cross-instance observation
  • Changed the default log level to INFO, so important read, restore, write, remove, and external-change logs are visible by default.
  • Added a unified log stream so logs can be emitted through the underlying logger and displayed inside the demo app UI at the same time.
  • Refined the ExampleComposables demo page with clearer grouping and improved layout while keeping each demo easy to inspect.
  • Moved the log viewer into a sidebar, making it easier to open at any time, change log levels, clear logs, and trigger test output.

Full Changelog: v.1.2.3...v1.2.4

v1.2.3 released! iOS & WASM are supported now!

Choose a tag to compare

@FunnySaltyFish FunnySaltyFish released this 31 Jul 06:33

ComposeDataSaver v1.2.3

🚀 What's New

  • Bump Kotlin to 2.2.0 & Compose to 1.8.2
  • Fix errors due to re-usage of cipher in DataSaverEncryptedProperties, support enableFileMonitoring and enableDataIntegrityCheck for it
  • New Platform Support
  • iOS: Native NSUserDefaults integration with KVO monitoring with rich data types (ByteArray, List, Map, NSDate, URL)
  • WASM: Browser localStorage support for web applications

新特性

  • 升级 Kotlin 至 2.2.0 & Compose 至 1.8.2
  • 修复 DataSaverEncryptedProperties 中因 cipher 复用导致的数据读取问题,并提供了数据完整性校验以及文件外部修改检测的功能
  • 新平台支持
  • iOS: 原生 NSUserDefaults 集成,支持 KVO 监听,支持多种数据类型(ByteArray、List、Map、NSDate、URL)
  • WASM: 浏览器 localStorage 支持,适用于 Web 应用

Full Changelog: v1.2.2...v.1.2.3

v1.2.2

Choose a tag to compare

@FunnySaltyFish FunnySaltyFish released this 01 Dec 14:07

v1.2.2

  • 升级 Compose 至 1.7.0、Kotlin 至 2.0.0
  • LocalDataSaver 改为 val #9
  • DataSaverProperties 系列支持传入编码 #8
    • 重要:为了编码的通用性,新的编码默认指定为 UTF-8,这与 Properties 的默认编码并不一致。如果您之前使用过此类存储数据,请注意手动指定编码为原先文件的编码,否则可能导致数据丢失!!!
  • rememberDataSaverState 支持直接传入 typeConverter,此优先级高于全局注册,有助于解决多个 Converter 都满足条件时导致的选择错误问题
  • DataSaverConfig 现在可以指定 logger,以接入你自己的 logger。默认的桌面端输出有颜色了

感谢 GitHub 用户 @XingMingYue @Nyayurin @Kyant0,感谢热心的邮箱用户 graveyard233 提的建议。感谢所有愿意尝试此库的小伙伴们

Full Changelog: v1.2.1...v1.2.2

v1.2.1 released

Choose a tag to compare

@FunnySaltyFish FunnySaltyFish released this 24 Jul 14:45

v1.2.1

破坏性变更:移除 DataSaverListState 及相关类

不再支持 rememberDataSaverListState 以及相关内容。创建此类的初衷是希望能够对 List 的操作做一些优化,但实际上,由于 mutableStateListOf 返回的 SnapshotStateList 也无法被继承,因此在旧版实现中,其相对于 DataSaverState<List<T>> 并无任何性能优势,有些冗余。且新版实现在 findRestorer 上无法传入某一个值,代码不太好写,故最终去除

迁移指南

  • 如果之前没有用到过此类:那么新的直接用 mutableDataSaverState<List<ExampleBean>("key", emptyList()) 这种即可,且需要注册转换器,但务必注明具体泛型。否则此变量将被推断为 List<Any>,转换器无法正常工作
  • 如果之前有用到,且希望保留数据,在迁移到 mutableDataSaverState 的同时,您还需要注册新的转换器以支持 List<Bean>。同时,由于之前默认的分隔符是 #@#,与大多数框架的 , 不同,您需要在 restore 时转换一下:
registerTypeConverters<ExampleBean>(
	save = { bean -> Json.encodeToString(bean) },
	restore = { str -> Json.decodeFromString(str.replace("#@#", ",")) }
)

其他更改

  • 支持 emptyList/emptyMap 作为默认值(#7)
  • 增强 registerTypeConverters,现在除了通过类判断,也可以自行传入判断条件
  • 在 JVM Desktop 端新增 DataSaverEncryptedProperties,用于保存加密的键值对数据
  • 引入了 kotlin-reflect 的依赖库,这是为了多平台做准备。之前的 ::class.java 在 JVM 以外平台无法使用。将在下一版新增其他平台

Full Changelog: v1.2.0...v1.2.1

v1.2.0 release! Now for Compose Multiplatform !

Choose a tag to compare

@FunnySaltyFish FunnySaltyFish released this 08 Feb 03:28

The library has been migrated to Compose Multiplatform (Android / JVM Desktop) since v1.2.0, and the publish repository has been changed from jitpack to Maven Central. Check README to see the new group id.

v1.1.9 released!

Choose a tag to compare

@FunnySaltyFish FunnySaltyFish released this 08 Dec 06:37

Note:

  • revert the changes in v1.1.8 of DataSaverListState. When using StateList, it is impossible to save data when the list has been changed, sorry for the incorrectness.

v1.1.8 released!

Choose a tag to compare

@FunnySaltyFish FunnySaltyFish released this 04 Dec 16:21

Breaking changes

  • use SnapShotStateList to implement DataSaverListState to improve performance, you should use its method like add/remoeve to modify the data

Updates

  • add error handler when restoring, when error occurs, the data will be reset to initialValue
  • bump Compose bom to 2023.10.01, kotlin to 1.9.20, compose complier to 1.5.5 and so on

Full Changelog: v1.1.7...v1.1.8

v1.1.7 released

Choose a tag to compare

@FunnySaltyFish FunnySaltyFish released this 06 Sep 09:42

About the lib

  • add coroutineScope parameter, so you can pass your custom coroutineScope to DataSaverState
  • make mutableDataSaverStateOf with paramter autoSave deprecated, you can use AS to replace automatically
  • make DataSaverXXX classes open & job public and observable

About the sample

  • refactor the code, add AppConfig to manage the dataSaver
  • add samples of using the state in ViewModel and doing time-consuming jobs

Special thanks to one staff who works in BiliBili, he gave me these advice.

v1.1.6 released!

Choose a tag to compare

@FunnySaltyFish FunnySaltyFish released this 09 Jul 11:53

v1.1.6

Breaking Changes

  • change DataSaverInterface from interface to abstract class

Other Changes

  • support @Preview, including normally preview and simple interactive mode
  • support simple senseExternalDataChange (see readme and ExampleComposables.kt)
  • update compose version to BOM 2023.06.01
  • replace some implementation to compileOnly
  • clean logger's code

v1.1.5 released !

Choose a tag to compare

@FunnySaltyFish FunnySaltyFish released this 12 Mar 10:29
  • add support for sealed class
    • actually, this means that if you call registerTypeConverters<A>, then classes that extends from A will be supported automatically
sealed class ThemeType(val id: Int) {
    object StaticDefault: ThemeType(-1)
    object DynamicNative : ThemeType(0)
    class DynamicFromImage(val color: Color) : ThemeType(1)
    class StaticFromColor(val color: Color): ThemeType(2)
}

you can call

registerTypeConverters<ThemeType>(save = ThemeType.Saver, restore = ThemeType.Restorer)

to support converting it.

  • add a function getGenericType() to obtain the actual type of an Object