feat: update Godot integration and coordinated package dependencies

This commit is contained in:
cneicy committed 2026-11-06 19:13:17 +08:00
1 parent fea752a8ff
commit c522594520
6 files changed
+96 -28

No files matched your search

+12
View File
@@ -2,6 +2,18 @@
本文件记录 `ShrinkDataSaver.Integration.App` 的包内变更。
## [0.3.0] - 2026-11-06
### Added
- 新增 `ShrinkDataSaverAppModuleConfig`,可同时传入 `ShrinkAppServices` 和自定义 `ShrinkDataSaverRuntimeConfig`。
- `ShrinkDataSaverAppComponent` 新增接收运行时配置的构造函数。
### Changed
- App 停止时等待 `ShrinkSettings.SaveAsync()` 完成,并把写入失败传播到停用链,不再 fire-and-forget。
- 精确依赖 `ShrinkDataSaver 2.5.0`、`ShrinkSDK.Runtime.Abstractions 0.2.0`。
## [0.1.3] - 2026-08-28
### Changed
@@ -5,16 +5,16 @@
<AssemblyName>ShrinkDataSaver.Integration.App</AssemblyName>
<RootNamespace>ShrinkDataSaver.Integration.App</RootNamespace>
<PackageId>ShrinkSDK.DataSaver.Integration.App</PackageId>
<Version>0.2.5</Version>
<Version>0.3.1</Version>
<Description>ShrinkDataSaver and App host integration.</Description>
<ShrinkCodeGenEnabled>true</ShrinkCodeGenEnabled>
</PropertyGroup>
<ItemGroup>
<Compile Include="..\Runtime\*.cs" />
<PackageReference Include="ShrinkSDK.Runtime.Abstractions" Version="0.1.0" />
<PackageReference Include="ShrinkSDK.Context.Core" Version="0.3.0" />
<PackageReference Include="ShrinkSDK.App.Core" Version="0.2.3" />
<PackageReference Include="ShrinkSDK.DataSaver" Version="2.4.0" />
<PackageReference Include="ShrinkSDK.Runtime.Abstractions" Version="0.2.0" />
<PackageReference Include="ShrinkSDK.Context.Core" Version="0.3.1" />
<PackageReference Include="ShrinkSDK.App.Core" Version="0.2.4" />
<PackageReference Include="ShrinkSDK.DataSaver" Version="2.5.0" />
<PackageReference Include="ShrinkSDK.CodeGen" Version="0.2.0" PrivateAssets="compile;runtime;contentfiles;native" />
</ItemGroup>
</Project>
+41 -19
View File
@@ -21,6 +21,16 @@ namespace ShrinkDataSaver.Integration.App
public const string ModuleKey = "app.module.shrink.datasaver";
private static readonly string[] ProvideKeys = { ModuleKey, ServiceKey };
private readonly ShrinkDataSaverRuntimeConfig? _runtimeConfig;
public ShrinkDataSaverAppComponent()
{
}
public ShrinkDataSaverAppComponent(ShrinkDataSaverRuntimeConfig? runtimeConfig)
{
_runtimeConfig = runtimeConfig;
}
public string Name => "shrink.datasaver";
@@ -28,22 +38,27 @@ namespace ShrinkDataSaver.Integration.App
public IReadOnlyList<string> Provide => ProvideKeys;
public async UniTask ApplyAsync(ShrinkCtx ctx, object? config)
public UniTask ApplyAsync(ShrinkCtx ctx, object? config)
{
// 编辑器/EditMode 环境下 DontDestroyOnLoad 会抛异常,驱动只在播放模式常驻
ShrinkDataSaverRuntime.Initialize(new ShrinkDataSaverRuntimeConfig
ShrinkAppServices? appServices = null;
var runtimeConfig = _runtimeConfig ?? CreateDefaultRuntimeConfig();
if (config is ShrinkDataSaverAppModuleConfig moduleConfig)
{
#if UNITY_5_3_OR_NEWER
DontDestroyOnLoadDriver = UnityEngine.Application.isPlaying
#else
DontDestroyOnLoadDriver = false
#endif
});
appServices = moduleConfig.Services;
if (moduleConfig.RuntimeConfig != null)
runtimeConfig = moduleConfig.RuntimeConfig;
}
else if (config is ShrinkAppServices services)
{
appServices = services;
}
ShrinkDataSaverRuntime.Initialize(runtimeConfig);
var facade = new ShrinkDataSaverService();
ctx.Set(ServiceKey, facade, new ShrinkDataSaverAccessPolicy(facade));
ctx.Set(ModuleKey, Name);
if (config is ShrinkAppServices appServices)
if (appServices != null)
{
appServices.Register(facade);
ctx.EffectInverse(() =>
@@ -53,17 +68,24 @@ namespace ShrinkDataSaver.Integration.App
});
}
await ctx.EffectAsync(async () =>
ctx.EffectInverse(async () =>
{
await UniTask.CompletedTask;
return () =>
{
// 终止动作(触发式):停用时把防抖中的设置写盘。
// 磁盘 IO 在线程池完成,不阻塞停用链;未初始化环境安全跳过(SaveAsync 守卫)。
ShrinkSettings.SaveAsync().Forget();
return UniTask.CompletedTask;
};
await ShrinkSettings.SaveAsync();
});
return UniTask.CompletedTask;
}
private static ShrinkDataSaverRuntimeConfig CreateDefaultRuntimeConfig()
{
// 编辑器/EditMode 环境下 DontDestroyOnLoad 会抛异常,驱动只在播放模式常驻
return new ShrinkDataSaverRuntimeConfig
{
#if UNITY_5_3_OR_NEWER
DontDestroyOnLoadDriver = UnityEngine.Application.isPlaying
#else
DontDestroyOnLoadDriver = false
#endif
};
}
}
}
+23
View File
@@ -0,0 +1,23 @@
#nullable enable
using ShrinkApp;
namespace ShrinkDataSaver.Integration.App
{
public sealed class ShrinkDataSaverAppModuleConfig
{
public ShrinkDataSaverAppModuleConfig()
{
}
public ShrinkDataSaverAppModuleConfig(ShrinkAppServices? services,
ShrinkDataSaverRuntimeConfig? runtimeConfig = null)
{
Services = services;
RuntimeConfig = runtimeConfig;
}
public ShrinkAppServices? Services { get; set; }
public ShrinkDataSaverRuntimeConfig? RuntimeConfig { get; set; }
}
}
@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: bd27f288ce72493889806887d825b37d
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
+4 -4
View File
@@ -1,14 +1,14 @@
{
"name": "com.cneicy.shrink-datasaver-integration-app",
"version": "0.2.5",
"version": "0.3.1",
"displayName": "ShrinkDataSaver - App Integration",
"description": "ShrinkDataSaver 与 ShrinkApp 的桥接层,提供宿主接管初始化与服务注册。",
"unity": "2022.3",
"dependencies": {
"com.cneicy.shrink-datasaver": "2.4.0",
"com.cneicy.shrink-app-core": "0.2.3",
"com.cneicy.shrink-datasaver": "2.5.0",
"com.cneicy.shrink-app-core": "0.2.4",
"com.cysharp.unitask": "2.5.10",
"com.cneicy.shrink-context-core": "0.3.0"
"com.cneicy.shrink-context-core": "0.3.1"
},
"keywords": [
"save",