收紧 UI 资源桥接的 manifest kind

UI 原型与文档链接改用生成枚举边界
删除 ui-prototype 的主动 alias 使用并更新测试清单
This commit is contained in:
2026-09-15 18:06:27 +08:00
parent 2befaaef9d
commit 4d0dd2d721
3 changed files with 14 additions and 3 deletions
@@ -6,6 +6,7 @@ import {
GAME_CREATION_APP_UI_DESIGN_DOC_ASSET_KIND,
GAME_CREATION_APP_UI_DESIGN_DOC_MEDIA_TYPE,
} from '../../../../../packages/shared/src/contracts/gameCreationApp';
import { parseGameCreationAppAssetKind } from '../../contracts/assetKind';
export type UiDesignResourceBridgeResult = {
asset: GameCreationAppAssetManifestEntry;
@@ -52,7 +53,10 @@ export function findLinkedUiDesignResource(
manifest.assets
.filter(
(asset) =>
asset.kind === GAME_CREATION_APP_UI_DESIGN_DOC_ASSET_KIND &&
parseGameCreationAppAssetKind(
asset.kind,
'ui-design-resource-bridge.linked-document',
) === GAME_CREATION_APP_UI_DESIGN_DOC_ASSET_KIND &&
asset.mediaType === GAME_CREATION_APP_UI_DESIGN_DOC_MEDIA_TYPE &&
asset.source.referenceResourceIds?.some((reference) =>
referenceIds.has(reference),
@@ -84,7 +88,13 @@ export async function ensureUiDesignResourceForPrototype({
const prototype = manifest.assets.find(
(asset) => asset.id === normalizedPrototypeAssetId,
);
if (!prototype || prototype.kind !== 'ui-prototype') {
if (
!prototype ||
parseGameCreationAppAssetKind(
prototype.kind,
'ui-design-resource-bridge.prototype',
) !== 'ui-design'
) {
throw new Error('目标资源不是 UI 原型图片');
}
if (!prototype.mediaType.toLowerCase().startsWith('image/')) {
@@ -16,7 +16,7 @@ import {
function manifestWithPrototype(): GameCreationAppManifest {
const prototype: GameCreationAppAssetManifestEntry = {
id: 'prototype-asset',
kind: 'ui-prototype',
kind: 'ui-design',
mediaType: 'image/png',
localPath: 'assets/ui-prototype.png',
source: { kind: 'canvas', referenceResourceIds: [] },
@@ -216,5 +216,6 @@
- `src/contracts/assetKind.ts`:消费 Rust 生成的 `GameCreationAppAssetKind`,未知输入记录 `rawKind` / `sourceContext` 并返回 `unknown`,不做旧 alias 转换。
- `src/features/project-workspace/resourceReferences.ts`:资源引用 kind 改为生成枚举类型并通过 parser 收口。
- `src/view/project-development/index.tsx`:画布引用入口通过同一 parser 构造资源引用 kind。
- `src/features/ui-editor/uiDesignResourceBridge.ts`UI 原型 manifest kind 只接受 `ui-design`UI 文档链接只接受 `ui-design-doc`;旧 `ui-prototype` 不再 alias。
其余 `packages/shared` import 和前端 manifest `kind: string` 字段仍未迁移,继续作为后续小切片,不在本次提交中伪装完成。