Phase 1: core engine (SRS+180 kicks, 7-bag, hold, ghost, lock delay, line clear)
- src/engine.js: 순수 코어 로직 (보드 10x40, 피스 7종, SRS+180 킥테이블, T-spin/mini 판정, 콤보/B2B, 7-bag, 홀드, 고스트, 락딜레이 15회 캡) - test/engine.test.js: 24개 단위 테스트 (킥테이블·T-spin 판정·7-bag·클리어 등) 전부 통과 - src/index.template.html + build.js: 엔진을 인라인한 단일 index.html 생성 (외부 에셋 0개). 키보드 플레이 가능 (DAS/ARR, 하드/소프트드롭, 판정 팝업)
This commit is contained in:
17
build.js
Normal file
17
build.js
Normal file
@@ -0,0 +1,17 @@
|
||||
// 빌드: src/engine.js 를 src/index.template.html 에 인라인해 단일 index.html 생성.
|
||||
// 최종 클라이언트 요건("단일 HTML 파일, 외부 에셋 0개")을 만족시키기 위한 개발용 도구.
|
||||
import { readFileSync, writeFileSync } from 'node:fs';
|
||||
|
||||
const engine = readFileSync(new URL('./src/engine.js', import.meta.url), 'utf8')
|
||||
// 모듈 export 키워드 제거 → 같은 스크립트 스코프의 일반 선언으로 인라인
|
||||
.replace(/^export\s+/gm, '');
|
||||
|
||||
const template = readFileSync(new URL('./src/index.template.html', import.meta.url), 'utf8');
|
||||
|
||||
if (!template.includes('//__ENGINE__')) {
|
||||
throw new Error('템플릿에 //__ENGINE__ 자리표시자가 없습니다.');
|
||||
}
|
||||
|
||||
const out = template.replace('//__ENGINE__', engine);
|
||||
writeFileSync(new URL('./index.html', import.meta.url), out);
|
||||
console.log(`index.html 생성 완료 (${(out.length/1024).toFixed(1)} KB, 외부 에셋 0개)`);
|
||||
Reference in New Issue
Block a user