建立 AGC 资源 kind Rust 枚举与 TypeScript 绑定
新增 GameCreationAppAssetKind 及 Unknown 解析边界 通过 ts-rs 生成 shell 专属 TypeScript 联合类型 补充未知值上下文日志与 Rust/绑定生成测试
This commit is contained in:
+2
@@ -4900,6 +4900,8 @@ dependencies = [
|
||||
"serde",
|
||||
"serde_json",
|
||||
"sha2",
|
||||
"tracing",
|
||||
"ts-rs",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
|
||||
@@ -14,7 +14,7 @@ cocos-editor-injection = ["cocos-editor-execute", "cocos-editor-bridge/windows-i
|
||||
serde = { version = "1", features = ["derive"] }
|
||||
serde_json = "1"
|
||||
sha2 = "0.10"
|
||||
shared-contracts = { path = "../../../server-rs/crates/shared-contracts", default-features = false }
|
||||
shared-contracts = { path = "../../../server-rs/crates/shared-contracts", default-features = false, features = ["ts-bindings"] }
|
||||
tauri-build = { version = "2.6.2", features = [] }
|
||||
|
||||
[dependencies]
|
||||
@@ -50,7 +50,7 @@ portable-pty = "0.9"
|
||||
percent-encoding = "2"
|
||||
reqwest = { version = "0.12", default-features = false, features = ["json", "multipart", "native-tls", "stream"] }
|
||||
regex = "1"
|
||||
shared-contracts = { path = "../../../server-rs/crates/shared-contracts", default-features = false }
|
||||
shared-contracts = { path = "../../../server-rs/crates/shared-contracts", default-features = false, features = ["ts-bindings"] }
|
||||
tauri = { version = "2.11.2", features = [] }
|
||||
tauri-plugin-dialog = "2.7.1"
|
||||
tauri-plugin-http = { version = "2.5.9", default-features = false, features = ["charset", "cookies", "http2", "rustls-tls"] }
|
||||
|
||||
@@ -15,6 +15,7 @@ use platform_llm::{
|
||||
};
|
||||
use schemars::JsonSchema;
|
||||
use serde::{Deserialize, Serialize};
|
||||
use shared_contracts::game_creation_app::GameCreationAppAssetKind;
|
||||
use std::collections::HashSet;
|
||||
use std::path::Path;
|
||||
use ts_rs::TS;
|
||||
@@ -645,5 +646,30 @@ mod tests {
|
||||
Node::export_all(&config).expect("Node TypeScript export succeeds");
|
||||
TextComponent::export_all(&config).expect("TextComponent TypeScript export succeeds");
|
||||
FontSource::export_all(&config).expect("FontSource TypeScript export succeeds");
|
||||
|
||||
let game_creation_config = Config::new().with_out_dir(concat!(
|
||||
env!("CARGO_MANIFEST_DIR"),
|
||||
"/../src/contracts/generated/"
|
||||
));
|
||||
GameCreationAppAssetKind::export_all(&game_creation_config)
|
||||
.expect("GameCreationAppAssetKind TypeScript export succeeds");
|
||||
let generated = std::fs::read_to_string(concat!(
|
||||
env!("CARGO_MANIFEST_DIR"),
|
||||
"/../src/contracts/generated/GameCreationAppAssetKind.ts"
|
||||
))
|
||||
.expect("generated GameCreationAppAssetKind binding exists");
|
||||
for value in [
|
||||
"\"image\"",
|
||||
"\"audio\"",
|
||||
"\"sound-effect\"",
|
||||
"\"background-music\"",
|
||||
"\"font\"",
|
||||
"\"unknown\"",
|
||||
] {
|
||||
assert!(
|
||||
generated.contains(value),
|
||||
"generated binding misses {value}"
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,28 @@
|
||||
// This file was generated by [ts-rs](https://github.com/Aleph-Alpha/ts-rs). Do not edit this file manually.
|
||||
|
||||
/**
|
||||
* GameCreationApp manifest 资源 kind 的唯一 Rust 类型。
|
||||
*
|
||||
* JSON 使用 kebab-case;`Unknown` 只表示解析边界遇到尚未登记的输入,
|
||||
* 正常资源写入路径不应主动选择它。
|
||||
*/
|
||||
export type GameCreationAppAssetKind =
|
||||
| 'image'
|
||||
| 'scene'
|
||||
| 'character'
|
||||
| 'character-animation'
|
||||
| 'icon'
|
||||
| 'icon-spritesheet'
|
||||
| 'icon-spec'
|
||||
| 'ui-design'
|
||||
| 'ui-design-doc'
|
||||
| 'publication-material'
|
||||
| 'spec'
|
||||
| 'video'
|
||||
| 'audio'
|
||||
| 'sound-effect'
|
||||
| 'background-music'
|
||||
| 'font'
|
||||
| 'document'
|
||||
| 'code'
|
||||
| 'unknown';
|
||||
Reference in New Issue
Block a user