feat: unify phase one creation flow

This commit is contained in:
2026-05-30 05:05:02 +08:00
parent 3a87b2d966
commit 26975644b5
33 changed files with 2037 additions and 539 deletions

View File

@@ -13,6 +13,29 @@ export type CreationEntryTypeConfig = {
categoryLabel: string;
categorySortOrder: number;
updatedAtMicros: number;
unifiedCreationSpec?: UnifiedCreationSpec | null;
};
export type UnifiedCreationField = {
id: string;
kind: 'text' | 'select' | 'image' | 'audio';
label: string;
required: boolean;
};
export type UnifiedCreationSpec = {
playId: 'puzzle' | 'match3d' | 'wooden-fish';
title: string;
workspaceStage:
| 'puzzle-agent-workspace'
| 'match3d-agent-workspace'
| 'wooden-fish-workspace';
generationStage:
| 'puzzle-generating'
| 'match3d-generating'
| 'wooden-fish-generating';
resultStage: 'puzzle-result' | 'match3d-result' | 'wooden-fish-result';
fields: UnifiedCreationField[];
};
export type CreationEntryConfig = {

View File

@@ -467,6 +467,24 @@ function clampProgress(value: number) {
return Math.max(0, Math.min(100, Math.round(value)));
}
export function resolveMiniGameDraftGenerationStartedAtMs(
startedAt: string | number | null | undefined,
fallbackMs = Date.now(),
) {
if (typeof startedAt === 'number' && Number.isFinite(startedAt)) {
return startedAt;
}
if (typeof startedAt === 'string') {
const parsed = Date.parse(startedAt);
if (Number.isFinite(parsed)) {
return parsed;
}
}
return fallbackMs;
}
function getStepDefinitions(kind: MiniGameDraftGenerationKind) {
if (kind === 'puzzle') {
return buildPuzzleSteps(createMiniGameDraftGenerationState('puzzle'));
@@ -542,6 +560,7 @@ function buildMiniGameProgressSteps(
export function createMiniGameDraftGenerationState(
kind: MiniGameDraftGenerationKind,
startedAtMs = Date.now(),
): MiniGameDraftGenerationState {
return {
kind,
@@ -559,7 +578,7 @@ export function createMiniGameDraftGenerationState(
: kind === 'wooden-fish'
? 'wooden-fish-draft'
: 'compile',
startedAtMs: Date.now(),
startedAtMs,
completedAssetCount: 0,
totalAssetCount: 0,
error: null,