收紧 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: [] },