feat(core,engine): 부트스트랩 리소스 정적 게시(bake) 및 폴백 체계 도입

공개 제보 https://github.com/gnuboard/g7/issues/122 대응 — 초기 부트스트랩
리소스(다국어 병합·컴포넌트 정의·라우트·확장 번들·템플릿 dist)를 캐시 버전
디렉토리(public/build/ext/{v}/)에 실파일로 게시해 웹서버가 rewrite 전에 직접
서빙한다. 부트 임계 경로의 PHP 왕복을 제거하고(실측 TTFB 131~144ms → 1~7ms),
미게시·부분게시·GC 직후에는 fetch·태그·번들 3계층이 종전 API 로 즉시 폴백한다.

- 게시: 원자적 tmp→rename→manifest(존재=완료), 캐시 락 단일 실행, 인라인 GC
 (현재+직전 1개), incrementExtensionCacheVersion 단일 지점 terminating 트리거
 + blade 자가 치유 + 설치기 태스크(best_effort) + 일일 cleanup 스케줄,
 sudo 업데이트 대비 소유권 정상화(normalizeOwnership)·prune/백업 제외
- 프론트(engine-v1.61.0): blade 주입 cache_version 1급 시드(이중 부트 로드 제거),
 fetchStaticFirst 즉시 폴백, ComponentRegistry 버전 키드 매니페스트,
 ModuleAssetLoader 번들 정적→레거시 폴백, asset-url-recovery staticToLegacy 역변환
- 폴백 API 품질: lang/components/routes ETag+304 + 환경 분기 Cache-Control,
 열화 라우트 스냅샷 공개 캐시 금지(서버측 캐시 회피와 대칭), 게시 .htaccess
 mod_deflate + nginx gzip 스니펫(압축 전송량 회귀 방지)
- SEO 정합: 봇 HTML 은 GC 대상 정적 URL 미사용(allowStatic:false), props $switch
 봇측 해석 구현(engine-v1.56.0 패리티), 패리티 룰 expression-dialect 그룹 신설,
 상주 allow 헤더 제거로 잠금 복원, _comment* 접두 주석 키 분류
- 검증: 전 수정 red→green 4단계, Playwright 라이브 21건, Chrome MCP 24축+M1~M3,
 봇 curl 3축, 캐시 저장소(file/redis/database) 축 판정, 히스토리·공개이슈·커밋
 이력 전수 재조사 반영
- 코어 7.0.10, engine-v1.61.0. kill-switch: G7_STATIC_CACHE=false
This commit is contained in:
HeuJung committed 2026-08-25 17:02:53 +09:00
1 parent 56836a2b66
commit 5ba7a83597
73 files changed
+4219 -98

No files matched your search

+76
View File
@@ -1457,6 +1457,9 @@ class ComponentHtmlMapper
// 표현식 해석: 문자열/숫자는 evaluate, 배열/객체는 evaluateRaw
$resolved = $evaluator->evaluateRaw($value, $context);
$data[$key] = $resolved;
} elseif ($this->isSwitchDefinition($value)) {
// $switch 선언적 분기 (React resolveObject 와 동일 위치에서 해석)
$data[$key] = $this->resolveSwitchValue($value, $context, $evaluator);
} elseif (is_array($value)) {
// 중첩 객체 (예: socialLinks): 재귀적으로 해석
$data[$key] = $this->resolveAllPropsRecursive($value, $context, $evaluator);
@@ -1482,6 +1485,8 @@ class ComponentHtmlMapper
foreach ($values as $k => $v) {
if (is_string($v) && str_contains($v, '{{')) {
$result[$k] = $evaluator->evaluateRaw($v, $context);
} elseif ($this->isSwitchDefinition($v)) {
$result[$k] = $this->resolveSwitchValue($v, $context, $evaluator);
} elseif (is_array($v)) {
$result[$k] = $this->resolveAllPropsRecursive($v, $context, $evaluator);
} else {
@@ -1492,6 +1497,71 @@ class ComponentHtmlMapper
return $result;
}
/**
* 값이 `$switch` 선언적 분기 객체인지 판정합니다.
*
* React `DataBindingEngine.isSwitchExpression` 과 동일 — `$switch` 와 `$cases`
* 키를 모두 가진 객체(연관 배열)만 해당한다.
*
* @param mixed $value 판정 대상 값
* @return bool $switch 정의 여부
*/
private function isSwitchDefinition(mixed $value): bool
{
return is_array($value)
&& array_key_exists('$switch', $value)
&& array_key_exists('$cases', $value);
}
/**
* `$switch` 선언적 분기 객체를 해석합니다.
*
* React `DataBindingEngine.resolveSwitch` 와 동일 의미론 (engine-v1.56.0 패리티):
* ① `$switch` 키 표현식을 평가해 문자열 키로 정규화(trim, 실패 시 빈 문자열)
* ② `$cases` 에서 키 일치 값 선택, 없으면 `$default`, 그것도 없으면 null(React undefined)
* ③ 결과가 `{{}}` 포함 문자열이면 재해석, 객체면 재귀 해석(중첩 $switch 포함)
*
* 레이아웃 최상위 `computed` 의 $switch 는 `SeoRenderer::resolveComputedSwitch` 가
* 별도 처리한다 — 이 메서드는 노드 props 값 축 담당.
*
* @param array $definition $switch 정의 { "$switch", "$cases", "$default"? }
* @param array $context 데이터 컨텍스트
* @param ExpressionEvaluator $evaluator 표현식 평가기
* @return mixed 해석된 값 (매칭·기본값 모두 없으면 null)
*/
private function resolveSwitchValue(array $definition, array $context, ExpressionEvaluator $evaluator): mixed
{
try {
$keyValue = trim((string) $evaluator->evaluate((string) ($definition['$switch'] ?? ''), $context));
} catch (\Throwable) {
$keyValue = '';
}
$cases = is_array($definition['$cases'] ?? null) ? $definition['$cases'] : [];
if ($keyValue !== '' && array_key_exists($keyValue, $cases)) {
$result = $cases[$keyValue];
} elseif (array_key_exists('$default', $definition)) {
$result = $definition['$default'];
} else {
return null;
}
if (is_string($result)) {
return str_contains($result, '{{') ? $evaluator->evaluate($result, $context) : $result;
}
if ($this->isSwitchDefinition($result)) {
return $this->resolveSwitchValue($result, $context, $evaluator);
}
if (is_array($result)) {
return $this->resolveAllPropsRecursive($result, $context, $evaluator);
}
return $result;
}
/**
* {field|alt_field} 패턴에서 아이템 값을 해석합니다.
*
@@ -1688,6 +1758,12 @@ class ComponentHtmlMapper
continue;
}
// $switch 선언적 분기 객체 (engine-v1.56.0 React 패리티) — 해석하지 않으면
// 배열이라는 이유로 속성이 조용히 사라진다 (예외·경고 없음)
if ($this->isSwitchDefinition($value)) {
$value = $this->resolveSwitchValue($value, $context, $evaluator);
}
if (is_string($value)) {
$evaluated = $evaluator->evaluate($value, $context);
if ($evaluated !== '') {