Update landing page and ground link features
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
This commit is contained in:
1 parent
a5cc458252
commit
7efe9097ce
28 files changed
+928
-120
No files matched your search
@@ -0,0 +1,14 @@
|
||||
import { parseProject } from '../src/core/project';
|
||||
import type { Sample } from './sample-explorer';
|
||||
const resources=new Map<string,Promise<{text:string;project:ReturnType<typeof parseProject>}>>();
|
||||
/** One immutable resource per sample URL, shared by preview and existing app-file loader. */
|
||||
export function sampleResource(sample:Pick<Sample,'url'|'bridge'|'pierCount'>){
|
||||
if(!resources.has(sample.url))resources.set(sample.url,(async()=>{
|
||||
const response=await fetch(sample.url);if(!response.ok)throw new Error(`샘플 파일 읽기 실패: HTTP ${response.status}`);
|
||||
const text=await response.text(),project=parseProject(text);
|
||||
if(project.project.bridge!==sample.bridge)throw new Error(`교량 ID 불일치: 선택 ${sample.bridge} / 파일 ${project.project.bridge}`);
|
||||
if(project.piers.length!==sample.pierCount)throw new Error(`교각 수 불일치: 목록 ${sample.pierCount} / 파일 ${project.piers.length}`);
|
||||
return {text,project};
|
||||
})().catch(error=>{resources.delete(sample.url);throw error;}));
|
||||
return resources.get(sample.url)!;
|
||||
}
|
||||
Reference in new issue
Block a user