Adds/updates documentation, assets and implementation for Match3D and puzzle image generation workflows. Key changes: decision logs and pitfalls updated to prefer VectorEngine Gemini for Match3D material sheets and to require edits (multipart) for 1:1 container reference images; guidance added for when to use APIMart vs VectorEngine. .env.example clarified APIMart/Responses config. Many new public assets and PPT visuals added. Code changes across frontend and backend: updated shared contracts, server-rs match3d/puzzle/image-generation handlers, VectorEngine/OpenAI image generation clients, and multiple React components/tests to handle UI/background/container image signing, edits workflow, and puzzle UI background resolution. Added src/services/puzzle-runtime/puzzleUiBackgroundSource.ts and related test updates. Includes notes about multipart HTTP/1.1 requirement and test/verification commands in docs.
58 lines
1.2 KiB
TypeScript
58 lines
1.2 KiB
TypeScript
import { type ImgHTMLAttributes, useEffect, useState } from 'react';
|
|
|
|
import { useResolvedAssetReadUrl } from '../hooks/useResolvedAssetReadUrl';
|
|
|
|
type ResolvedAssetImageProps = Omit<
|
|
ImgHTMLAttributes<HTMLImageElement>,
|
|
'src'
|
|
> & {
|
|
src?: string | null;
|
|
fallbackSrc?: string | null;
|
|
refreshKey?: string | number | null;
|
|
};
|
|
|
|
export function ResolvedAssetImage({
|
|
src,
|
|
fallbackSrc,
|
|
alt,
|
|
refreshKey,
|
|
onError,
|
|
...rest
|
|
}: ResolvedAssetImageProps) {
|
|
const { resolvedUrl } = useResolvedAssetReadUrl(src, {
|
|
refreshKey,
|
|
});
|
|
const normalizedFallbackSrc = fallbackSrc?.trim() ?? '';
|
|
const [useFallbackSrc, setUseFallbackSrc] = useState(false);
|
|
const finalSrc =
|
|
useFallbackSrc && normalizedFallbackSrc
|
|
? normalizedFallbackSrc
|
|
: resolvedUrl || normalizedFallbackSrc;
|
|
|
|
useEffect(() => {
|
|
setUseFallbackSrc(false);
|
|
}, [normalizedFallbackSrc, resolvedUrl]);
|
|
|
|
if (!finalSrc) {
|
|
return null;
|
|
}
|
|
|
|
return (
|
|
<img
|
|
{...rest}
|
|
src={finalSrc}
|
|
alt={alt}
|
|
onError={(event) => {
|
|
if (
|
|
normalizedFallbackSrc &&
|
|
!useFallbackSrc &&
|
|
finalSrc !== normalizedFallbackSrc
|
|
) {
|
|
setUseFallbackSrc(true);
|
|
}
|
|
onError?.(event);
|
|
}}
|
|
/>
|
|
);
|
|
}
|