66 lines
1.8 KiB
TypeScript
66 lines
1.8 KiB
TypeScript
import {
|
|
buildCompiledCustomWorldProfile,
|
|
normalizeCustomWorldProfile,
|
|
} from '../modules/custom-world/runtime-profile/index.js';
|
|
import type {
|
|
RpgCreationPreview,
|
|
RpgCreationPreviewEnvelope,
|
|
RpgCreationPreviewSource,
|
|
} from '../../../packages/shared/src/contracts/rpgCreationPreview.js';
|
|
import type { CustomWorldProfile } from '../modules/custom-world/runtimeTypes.js';
|
|
|
|
/**
|
|
* 工作包 G 把服务端结果预览编译入口收口到这里。
|
|
* Phase 5 后当前 preview 正式作为 session_preview 主链输出,
|
|
* 编译边界已经从 foundation draft 流程中抽离。
|
|
*/
|
|
export type RpgWorldPreviewProfile = CustomWorldProfile;
|
|
|
|
const RPG_WORLD_PREVIEW_SOURCE: RpgCreationPreviewSource =
|
|
'session_preview';
|
|
|
|
function toRpgCreationPreview(
|
|
profile: RpgWorldPreviewProfile,
|
|
): RpgCreationPreview {
|
|
return profile as unknown as RpgCreationPreview;
|
|
}
|
|
|
|
export function buildRpgWorldPreviewProfile(
|
|
raw: unknown,
|
|
settingText: string,
|
|
): RpgWorldPreviewProfile {
|
|
return buildCompiledCustomWorldProfile(raw, settingText);
|
|
}
|
|
|
|
export function normalizeRpgWorldPreviewProfile(
|
|
raw: unknown,
|
|
settingText: string,
|
|
): RpgWorldPreviewProfile {
|
|
return normalizeCustomWorldProfile(raw, settingText);
|
|
}
|
|
|
|
export function buildRpgWorldPreviewEnvelope(
|
|
raw: unknown,
|
|
settingText: string,
|
|
): RpgCreationPreviewEnvelope {
|
|
return {
|
|
preview: toRpgCreationPreview(buildRpgWorldPreviewProfile(raw, settingText)),
|
|
source: RPG_WORLD_PREVIEW_SOURCE,
|
|
};
|
|
}
|
|
|
|
export function normalizeRpgWorldPreviewEnvelope(
|
|
raw: unknown,
|
|
settingText: string,
|
|
): RpgCreationPreviewEnvelope {
|
|
return {
|
|
preview: toRpgCreationPreview(
|
|
buildRpgWorldPreviewProfile(
|
|
normalizeRpgWorldPreviewProfile(raw, settingText),
|
|
settingText,
|
|
),
|
|
),
|
|
source: RPG_WORLD_PREVIEW_SOURCE,
|
|
};
|
|
}
|