feat(solution): 발행 워커·버전 관리와 예약·미리보기 정리

상시 프리렌더와 중복 예약 안내를 없애고, 검수된 발행 버전을 보존한다. 미리보기는 실제 렌더 완료까지 스피너를 표시한다.

사이트 81건, 발행·롤백·서치콘솔 45건, 프로세스 수명 3건 통과. 빌더·사이트 빌드 및 compose 설정 검증 통과.
This commit is contained in:
minaChoi committed 2026-09-15 16:12:16 +09:00
1 parent 0f7d22750f
commit f2087aad5e
207 files changed
+8424 -4429

No files matched your search

+24 -1
View File
@@ -1,4 +1,4 @@
import {StrictMode} from 'react';
import {StrictMode, useEffect} from 'react';
import {createRoot, hydrateRoot} from 'react-dom/client';
import type {SitePayload} from '@o2o/shared';
import {App} from './App';
@@ -15,6 +15,22 @@ declare global {
const container = document.getElementById('root')!;
const injected = window.__SITE_PAYLOAD__;
/**
* 미리보기를 띄운 빌더에게 "이제 그림이 나왔다" 고 알린다.
*
* ★ 빌더는 iframe 의 `load` 만으로는 이 시점을 알 수 없다. `load` 는 **셸이 뜬** 순간이고,
* 그 뒤에 payload fetch + 웹폰트 대기(최대 2.5s) + `document.fonts.ready` 가 남아 있다.
* 그 사이 iframe 은 흰 화면인데, load 를 완료로 읽으면 로딩 표시가 바로 사라져
* 사장님은 "다 됐다는데 아무것도 없는" 화면을 본다.
* ★ 두 번의 rAF 를 기다린다 — 첫 프레임은 React 가 DOM 을 붙인 직후라 아직 그려지기 전이다.
* ★ 실패해도 보낸다(ok=false). 안 보내면 빌더의 로딩 표시가 영영 안 걷힌다.
*/
function signalPreviewPainted(ok: boolean) {
if (window.parent === window) return;
const post = () => window.parent.postMessage({type: 'o2o:preview-painted', ok}, window.location.origin);
requestAnimationFrame(() => requestAnimationFrame(post));
}
/**
* 빌더 미리보기(iframe)가 여는 셸에서만 쓰는 경로 — `/preview?placeId=…`.
*
@@ -30,6 +46,11 @@ const injected = window.__SITE_PAYLOAD__;
* 떨어진다. 실측(2026-09-09): 간판체(Gugi)가 안 실려 픽셀 차이가 92% 였는데
* 지오메트리(header·hero·h1 위치)는 발행본과 완전히 같았다.
*/
function PreviewReady() {
useEffect(() => signalPreviewPainted(true), []);
return null;
}
async function renderPreview(placeId: string) {
const token = (() => {
try {
@@ -68,6 +89,7 @@ async function renderPreview(placeId: string) {
createRoot(container).render(
<StrictMode>
<App payload={payload} />
<PreviewReady />
</StrictMode>,
);
}
@@ -87,6 +109,7 @@ if (injected) {
void renderPreview(previewPlaceId).catch((ex: unknown) => {
// 미리보기가 못 떠도 편집은 계속돼야 한다. 부모 창이 읽을 수 있게 이유를 남긴다.
container.textContent = `미리보기를 불러오지 못했습니다 — ${ex instanceof Error ? ex.message : String(ex)}`;
signalPreviewPainted(false);
});
} else {
// 개발 서버(vite dev) — 데모 payload 로 CSR 렌더. 프로덕션 경로가 아니다.