@roottale/cms-renderer-next 0.63.0 → 0.65.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +27 -0
- package/README.md +33 -2
- package/dist/{chunk-SEPUIKVM.js → chunk-LUL73SKP.js} +192 -51
- package/dist/chunk-LUL73SKP.js.map +1 -0
- package/dist/cms-public.css +1 -0
- package/dist/exposure-client.js +1 -1
- package/dist/exposures.d.ts +10 -2
- package/dist/exposures.js +9 -3
- package/dist/routes.d.ts +35 -1
- package/dist/routes.js +117 -20
- package/dist/routes.js.map +1 -1
- package/dist/server.js +1 -1
- package/package.json +4 -4
- package/dist/chunk-SEPUIKVM.js.map +0 -1
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/exposures.tsx","../src/exposure-decision-client.ts","../src/exposure-runtime-data.ts","../src/exposure-group.tsx","../src/exposure-content.tsx","../src/exposure-dialog.tsx","../src/exposure-carousel.tsx","../src/exposure-scroll.ts","../src/exposure-storage.ts","../src/exposure-site-preview.ts"],"sourcesContent":["\"use client\";\n\nimport { createContext, useCallback, useContext, useEffect, useRef, useState, type CSSProperties, type ReactNode } from \"react\";\nimport type { CmsExposureCampaign } from \"@roottale/cms-client/server\";\nimport { useExposureDecision } from \"./exposure-decision-client\";\nimport type { ExposurePlacement } from \"./exposure-content\";\nimport { ExposureCampaignGroup } from \"./exposure-group\";\nimport { exposureHomePaths, isExposureHome } from \"./exposure-home\";\nimport { exposureServerNow, liveCampaigns } from \"./exposure-runtime-data\";\nimport type { ExposureRuntime } from \"./exposure-runtime-context\";\nimport { useExposureSitePreview } from \"./exposure-site-preview\";\n\nexport { RootTaleExposurePreview } from \"./exposure-content\";\nexport { RootTaleExposureCarouselPreview } from \"./exposure-group\";\nexport type { ExposurePlacement } from \"./exposure-content\";\nexport { exposureSitePreviewUrl, EXPOSURE_PREVIEW_PROTOCOL, parseExposurePreviewCampaign } from \"./exposure-site-preview\";\nexport type { CmsExposureCampaign } from \"./exposure-site-preview\";\n\nexport interface RootTaleExposureProviderProps {\n endpoint: string;\n /** 사이트의 usePathname() 값. API 키는 서버에만 둔다. */\n pathname: string;\n slots: readonly string[];\n breakpoint?: number;\n /** 메인 홈만 허용하며 locale 홈은 실제로 만든 exact 경로를 명시한다. */\n homePaths?: readonly string[];\n slideDurationMs?: number;\n hideMobileBannersOnScroll?: boolean;\n legacyDismissalKeyPrefixes?: readonly string[];\n /** 추가 관리자 출처가 필요한 사이트에서만 지정한다. 기본은 canonical ROOT-ADMIN. */\n previewOrigins?: readonly string[];\n children: ReactNode;\n}\n\nconst Context = createContext<ExposureRuntime | null>(null);\nconst emptyPrefixes: readonly string[] = [];\n\nexport function RootTaleExposureProvider({ endpoint, pathname, slots, breakpoint = 768, homePaths, slideDurationMs = 5000,\n hideMobileBannersOnScroll = true, legacyDismissalKeyPrefixes = emptyPrefixes, previewOrigins, children }: RootTaleExposureProviderProps) {\n const [themeElement, setThemeElement] = useState<HTMLDivElement | null>(null);\n const [device, setDevice] = useState<\"desktop\" | \"mobile\">(\"desktop\");\n const [heights, setHeights] = useState<Record<string, { placement: \"top\" | \"bottom\"; height: number }>>({});\n useEffect(() => {\n const media = window.matchMedia(`(max-width: ${breakpoint - 1}px)`);\n const update = () => setDevice(media.matches ? \"mobile\" : \"desktop\");\n update(); media.addEventListener(\"change\", update);\n return () => media.removeEventListener(\"change\", update);\n }, [breakpoint]);\n const path = pathname.split(/[?#]/, 1)[0] || \"/\";\n const home = isExposureHome(path, exposureHomePaths(homePaths));\n const routeKey = `${path}:${device}`;\n const preview = useExposureSitePreview(slots, previewOrigins);\n const snapshot = useExposureDecision(endpoint, path, device, slots, home && !preview.active);\n const popupVisit = useRef<{ key: string; slot?: string }>({ key: routeKey });\n useEffect(() => { popupVisit.current = { key: routeKey }; }, [routeKey]);\n const now = useCallback(() => snapshot ? exposureServerNow(snapshot) : Date.now(), [snapshot]);\n const claimPopup = useCallback((slot: string) => {\n const claimed = popupVisit.current.slot;\n if (claimed && claimed !== slot) return false;\n popupVisit.current.slot = slot;\n return true;\n }, []);\n const setHeight = useCallback((key: string, placement: \"top\" | \"bottom\", height: number) => {\n setHeights((previous) => previous[key]?.height === height && previous[key]?.placement === placement ? previous : { ...previous, [key]: { placement, height } });\n }, []);\n const value: ExposureRuntime = { campaigns: preview.active ? preview.draft ? [preview.draft.campaign] : [] : liveCampaigns(snapshot), device, routeKey, home,\n slideDurationMs: Number.isFinite(slideDurationMs) ? slideDurationMs : 5000, hideMobileBannersOnScroll,\n now, claimPopup, setHeight, legacyPrefixes: legacyDismissalKeyPrefixes, themeElement,\n preview: preview.active ? { revision: preview.draft?.revision ?? 0, report: preview.report } : undefined };\n const top = Math.max(0, ...Object.values(heights).filter((item) => item.placement === \"top\").map((item) => item.height));\n const bottom = Math.max(0, ...Object.values(heights).filter((item) => item.placement === \"bottom\").map((item) => item.height));\n const style = { display: \"contents\", \"--rt-exposure-top-height\": `${top}px`, \"--rt-exposure-bottom-height\": `${bottom}px` } as CSSProperties;\n return <Context.Provider value={value}><div ref={setThemeElement} data-roottale-exposure-root=\"\" style={style}>{children}</div></Context.Provider>;\n}\n\nexport interface RootTaleExposureSlotProps {\n slotKey: string;\n placement: ExposurePlacement;\n allowedVariants: readonly string[];\n /** 배너를 닫아도 같은 방문에서 이전 공지를 이어서 표시하지 않는다. */\n fallback?: ReactNode;\n className?: string;\n}\n\nexport function RootTaleExposureSlot({ slotKey, placement, allowedVariants, fallback = null, className = \"\" }: RootTaleExposureSlotProps) {\n const runtime = useContext(Context);\n const previewCampaign = runtime?.preview ? runtime.campaigns[0] : undefined;\n const reportPreview = runtime?.preview?.report;\n const validPreview = previewCampaign?.slotKey === slotKey && previewCampaign.kind === (placement === \"popup\" ? \"popup\" : \"banner\") && allowedVariants.includes(previewCampaign.content.variant);\n useEffect(() => {\n if (previewCampaign?.slotKey === slotKey && !validPreview) reportPreview?.(false);\n }, [previewCampaign, slotKey, validPreview, reportPreview]);\n if (runtime && !runtime.home) return fallback;\n const campaigns = runtime?.campaigns.filter((item) => item.slotKey === slotKey && item.kind === (placement === \"popup\" ? \"popup\" : \"banner\") && allowedVariants.includes(item.content.variant)).slice(0, 20);\n if (!runtime || !campaigns?.length) return fallback;\n return <ExposureCampaignGroup key={`${runtime.routeKey}:${slotKey}:${runtime.preview?.revision ?? \"live\"}`} campaigns={campaigns} runtime={runtime} placement={placement} className={className} />;\n}\n\n/** 기존 서버 슬롯의 client island. 신규 설치는 Provider/Slot을 사용한다. */\nexport function RootTaleLegacyExposure({ campaign, allowedVariants }: { campaign: CmsExposureCampaign; allowedVariants: readonly string[] }) {\n const [device, setDevice] = useState<\"desktop\" | \"mobile\">(\"desktop\");\n useEffect(() => { const media = window.matchMedia(\"(max-width: 767px)\"); const update = () => setDevice(media.matches ? \"mobile\" : \"desktop\"); update(); media.addEventListener(\"change\", update); return () => media.removeEventListener(\"change\", update); }, []);\n if (!allowedVariants.includes(campaign.content.variant)) return null;\n const runtime: ExposureRuntime = { campaigns: [campaign], device, routeKey: \"legacy\", home: true, slideDurationMs: 5000, hideMobileBannersOnScroll: true,\n now: Date.now, claimPopup: () => true, setHeight: () => undefined, legacyPrefixes: emptyPrefixes, themeElement: null };\n return <ExposureCampaignGroup key={campaign.id} campaigns={[campaign]} runtime={runtime} placement={campaign.kind === \"popup\" ? \"popup\" : \"inline\"} className=\"\" />;\n}\n","\"use client\";\n\nimport { useEffect, useState } from \"react\";\nimport { readExposureDecision, type TimedExposureDecision } from \"./exposure-runtime-data\";\n\nexport function useExposureDecision(endpoint: string, pathname: string, device: \"mobile\" | \"desktop\", slots: readonly string[], enabled = true) {\n const slotsKey = slots.join(\",\");\n const requestKey = JSON.stringify([endpoint, pathname, device, slotsKey, enabled]);\n const [result, setResult] = useState<{ key: string; snapshot: TimedExposureDecision } | null>(null);\n\n useEffect(() => {\n if (!enabled) return;\n let disposed = false;\n let sequence = 0;\n let controller: AbortController | undefined;\n let pollTimer: ReturnType<typeof setTimeout> | undefined;\n let expiryTimer: ReturnType<typeof setTimeout> | undefined;\n let requestTimer: ReturnType<typeof setTimeout> | undefined;\n let current: TimedExposureDecision | null = null;\n const clearPoll = () => { clearTimeout(pollTimer); clearTimeout(requestTimer); controller?.abort(); sequence++; };\n\n function schedule(delay: number) {\n clearTimeout(pollTimer);\n if (!disposed && document.visibilityState !== \"hidden\") pollTimer = setTimeout(refresh, Math.max(100, Math.min(delay, 60_000)));\n }\n\n function expireKnownCampaigns() {\n if (!current) return;\n // Timer callbacks rerender at known expiry even while a replacement request is offline.\n setResult(performance.now() >= current.expiresAt ? null : { key: requestKey, snapshot: current });\n armExpiry();\n }\n\n function armExpiry() {\n clearTimeout(expiryTimer);\n if (!current || current.expiresAt <= performance.now()) return;\n const ends = current.decision.campaigns.flatMap((campaign) => campaign.endsAt ?\n [current!.receivedAt + Date.parse(campaign.endsAt) - current!.serverAtReceipt] : []);\n const future = [current.expiresAt, ...ends].filter((time) => time > performance.now());\n expiryTimer = setTimeout(expireKnownCampaigns, Math.max(1, Math.min(...future) - performance.now()));\n }\n\n async function refresh() {\n if (disposed || document.visibilityState === \"hidden\") return;\n clearPoll();\n if (current && performance.now() >= current.expiresAt) setResult(null);\n const seq = sequence;\n controller = new AbortController();\n const startedAt = performance.now();\n let refreshed = false;\n requestTimer = setTimeout(() => controller?.abort(), 10_000);\n try {\n const url = new URL(endpoint, window.location.origin);\n if (url.origin !== window.location.origin || url.username || url.password) throw new Error(\"Exposure endpoint must be same origin\");\n url.search = new URLSearchParams({ path: pathname, device }).toString();\n const response = await fetch(url, { cache: \"no-store\", credentials: \"same-origin\", signal: controller.signal });\n if (!response.ok) throw new Error(\"Exposure unavailable\");\n const payload: unknown = await response.json();\n if (disposed || seq !== sequence) return;\n const receivedAt = performance.now();\n current = readExposureDecision(payload, slotsKey.split(\",\"), receivedAt, receivedAt - startedAt);\n refreshed = current !== null;\n setResult(current ? { key: requestKey, snapshot: current } : null);\n armExpiry();\n } catch {\n if (disposed || seq !== sequence) return;\n if (!current || performance.now() >= current.expiresAt) { current = null; setResult(null); }\n } finally {\n if (!disposed && seq === sequence) {\n clearTimeout(requestTimer);\n const now = performance.now();\n const next = current?.nextAt;\n const boundaryDelay = next != null && next > now ? next - now : 60_000;\n // 오래 걸리는 요청에도 현재 노출이 만료 전에 갱신될 여유를 둔다.\n const refreshDelay = refreshed && current ? Math.max(1000, current.expiresAt - now - 10_000) : 60_000;\n schedule(Math.min(boundaryDelay, refreshDelay));\n }\n }\n }\n\n function onVisibility() {\n if (document.visibilityState === \"hidden\") clearPoll();\n else void refresh();\n }\n void refresh();\n document.addEventListener(\"visibilitychange\", onVisibility);\n window.addEventListener(\"focus\", refresh);\n return () => {\n disposed = true; clearPoll(); clearTimeout(expiryTimer);\n document.removeEventListener(\"visibilitychange\", onVisibility);\n window.removeEventListener(\"focus\", refresh);\n };\n }, [endpoint, pathname, device, slotsKey, requestKey, enabled]);\n\n // Layout survives client navigation: never paint the preceding route while effects catch up.\n return enabled && result?.key === requestKey ? result.snapshot : null;\n}\n","import type { CmsExposureCampaign, CmsExposureDecision } from \"@roottale/cms-client/server\";\n\nexport interface TimedExposureDecision {\n decision: CmsExposureDecision;\n receivedAt: number;\n serverAtReceipt: number;\n expiresAt: number;\n nextAt: number | null;\n}\n\nfunction validLink(value: unknown, internal = true): boolean {\n if (value == null) return true;\n if (typeof value !== \"string\" || /[\\u0000-\\u0020\\u007f\\\\]/.test(value)) return false;\n if (internal && value.startsWith(\"/\") && !value.startsWith(\"//\")) return true;\n try { const url = new URL(value); return url.protocol === \"https:\" && !url.username && !url.password; } catch { return false; }\n}\n\n/** 판정 응답이 손상돼도 페이지 본문은 유지하는 브라우저 입력 경계. */\nexport function readExposureDecision(value: unknown, slots: readonly string[], receivedAt: number, elapsed: number): TimedExposureDecision | null {\n if (!value || typeof value !== \"object\") return null;\n const data = value as CmsExposureDecision;\n const evaluated = Date.parse(data.evaluatedAt);\n const validUntil = Date.parse(data.validUntil);\n if (!Number.isFinite(evaluated) || !Number.isFinite(validUntil) || validUntil <= evaluated ||\n !Array.isArray(data.campaigns) || data.campaigns.length > 200) return null;\n // 편도 시간을 모르므로 왕복 전체를 차감한다. 늦은 응답으로 유효기간을 늘리지 않는다.\n const serverAtReceipt = evaluated + Math.max(0, elapsed);\n const expiresAt = receivedAt + Math.min(validUntil - serverAtReceipt, 120_000);\n if (expiresAt <= receivedAt) return null;\n const campaigns: CmsExposureCampaign[] = [];\n for (const item of data.campaigns) {\n if (!item || typeof item.id !== \"string\" || !slots.includes(item.slotKey) ||\n (item.kind !== \"banner\" && item.kind !== \"popup\") || !item.content ||\n typeof item.content.title !== \"string\" || typeof item.content.variant !== \"string\" ||\n ![\"always\", \"session\", \"day\", \"never\"].includes(item.repeat) ||\n !validLink(item.content.linkUrl) || !validLink(item.content.assetUrl, false) || !validLink(item.content.mobileAssetUrl, false)) return null;\n if (item.endsAt != null && !Number.isFinite(Date.parse(item.endsAt))) return null;\n if (item.delivery) {\n const delivery = item.delivery;\n if (delivery.version !== 2 || !Number.isFinite(delivery.delaySeconds) || delivery.delaySeconds < 0 || delivery.delaySeconds > 30 ||\n ![null, 25, 50, 75].includes(delivery.scrollPercent) || ![\"small\", \"medium\", \"large\"].includes(delivery.size) ||\n ![\"calendar\", \"rolling\"].includes(delivery.dayBoundary) || typeof delivery.dismissible !== \"boolean\" || typeof delivery.hideForToday !== \"boolean\") return null;\n try { new Intl.DateTimeFormat(\"en\", { timeZone: delivery.timeZone }); } catch { return null; }\n }\n const popupSlot = campaigns.find((existing) => existing.kind === \"popup\")?.slotKey;\n if (!campaigns.some((existing) => existing.id === item.id) &&\n campaigns.filter((existing) => existing.slotKey === item.slotKey).length < 20 &&\n (item.kind !== \"popup\" || popupSlot === undefined || popupSlot === item.slotKey)) campaigns.push(item);\n }\n const boundary = data.nextChangeAt == null ? null : Date.parse(data.nextChangeAt);\n if (boundary !== null && !Number.isFinite(boundary)) return null;\n return { decision: { ...data, campaigns }, receivedAt, serverAtReceipt, expiresAt,\n nextAt: boundary === null ? null : receivedAt + boundary - serverAtReceipt };\n}\n\nexport function exposureServerNow(snapshot: TimedExposureDecision): number {\n return snapshot.serverAtReceipt + performance.now() - snapshot.receivedAt;\n}\n\nexport function liveCampaigns(snapshot: TimedExposureDecision | null): CmsExposureCampaign[] {\n if (!snapshot || performance.now() >= snapshot.expiresAt) return [];\n const now = exposureServerNow(snapshot);\n return snapshot.decision.campaigns.filter((campaign) => !campaign.endsAt || Date.parse(campaign.endsAt) > now);\n}\n","\"use client\";\n\nimport { useEffect, useLayoutEffect, useRef, useState } from \"react\";\nimport type { CmsExposureCampaign } from \"@roottale/cms-client/server\";\nimport { ExposureContent, contentVariant, type ExposurePlacement } from \"./exposure-content\";\nimport { ExposureDialog, exposureCanOpenPopup, releaseExposurePopup, reserveExposurePopup } from \"./exposure-dialog\";\nimport { ExposureCarouselControls, useExposureCarousel } from \"./exposure-carousel\";\nimport type { ExposureRuntime } from \"./exposure-runtime-context\";\nimport { useMobileExposureScroll } from \"./exposure-scroll\";\nimport { exposureWasHidden, rememberExposureGroupDismissal, rememberExposureView } from \"./exposure-storage\";\n\nfunction useSlideScrollReset(campaignId: string | undefined) {\n const ref = useRef<HTMLDivElement>(null);\n useLayoutEffect(() => {\n // 모달·포커스는 유지하고 새 안내의 내용만 처음부터 읽을 수 있게 한다.\n if (ref.current) ref.current.scrollTop = 0;\n }, [campaignId]);\n return ref;\n}\n\nfunction exposureGroupSize(campaigns: readonly CmsExposureCampaign[]): \"small\" | \"medium\" | \"large\" {\n if (campaigns.some((campaign) => campaign.delivery?.size === \"large\")) return \"large\";\n if (campaigns.some((campaign) => (campaign.delivery?.size ?? \"medium\") === \"medium\")) return \"medium\";\n return \"small\";\n}\n\nexport function ExposureCampaignGroup({ campaigns, runtime, placement, className }: {\n campaigns: readonly CmsExposureCampaign[]; runtime: ExposureRuntime; placement: ExposurePlacement; className: string;\n}) {\n const [visible, setVisible] = useState(Boolean(runtime.preview));\n const [dismissed, setDismissed] = useState(false);\n const [popupReady, setPopupReady] = useState(false);\n const [height, setMeasuredHeight] = useState(0);\n const [inView, setInView] = useState(() => placement !== \"inline\" || typeof IntersectionObserver === \"undefined\");\n const measuredRef = useRef<HTMLDivElement>(null);\n const campaignIds = campaigns.map((campaign) => campaign.id).join(\",\");\n const [admission, setAdmission] = useState(() => ({ ids: campaignIds,\n allowed: new Map(campaigns.map((campaign) => [campaign.id, Boolean(runtime.preview) || !exposureWasHidden(campaign, runtime.now(), runtime.legacyPrefixes)])) }));\n if (admission.ids !== campaignIds) {\n const allowed = new Map(admission.allowed);\n for (const campaign of campaigns) if (!allowed.has(campaign.id)) allowed.set(campaign.id, Boolean(runtime.preview) || !exposureWasHidden(campaign, runtime.now(), runtime.legacyPrefixes));\n setAdmission({ ids: campaignIds, allowed });\n }\n const viewed = useRef(new Set<string>());\n const owner = useRef(Symbol(\"exposure-group\"));\n const latest = useRef({ campaigns, runtime });\n useEffect(() => { latest.current = { campaigns, runtime }; }, [campaigns, runtime]);\n const eligible = campaigns.filter((campaign) => admission.allowed.get(campaign.id));\n const first = eligible[0];\n const firstId = first?.id;\n const slotKey = campaigns[0]?.slotKey ?? \"\";\n const hiddenOnScroll = useMobileExposureScroll(runtime.device === \"mobile\" && runtime.hideMobileBannersOnScroll && (placement === \"top\" || placement === \"bottom\"));\n const active = visible && !dismissed && eligible.length > 0;\n const carousel = useExposureCarousel(eligible, active && (placement !== \"popup\" || popupReady) && !hiddenOnScroll && inView, runtime.slideDurationMs, placement === \"popup\");\n const campaign = carousel.campaign;\n const activeId = campaign?.id;\n const setHeight = runtime.setHeight;\n const device = runtime.device;\n const slideRef = useSlideScrollReset(activeId);\n const reportPreview = runtime.preview?.report;\n useEffect(() => { if (active && (placement !== \"popup\" || popupReady)) reportPreview?.(true); }, [active, placement, popupReady, reportPreview]);\n\n useEffect(() => {\n const first = latest.current.campaigns.find((campaign) => campaign.id === firstId);\n if (visible || dismissed || !first) return;\n let opened = false;\n let delayPassed = false;\n const scrollPercent = first.delivery?.scrollPercent;\n const tryOpen = () => {\n if (opened || !delayPassed || document.visibilityState === \"hidden\") return;\n if (scrollPercent) {\n const scrollable = document.documentElement.scrollHeight - window.innerHeight;\n if (scrollable <= 0 || window.scrollY / scrollable * 100 < scrollPercent) return;\n }\n if (placement === \"popup\") {\n if (!exposureCanOpenPopup() || !reserveExposurePopup(owner.current)) return;\n if (!latest.current.runtime.claimPopup(first.slotKey)) { releaseExposurePopup(owner.current); return; }\n }\n opened = true; setVisible(true); clearInterval(retry);\n };\n const timer = setTimeout(() => { delayPassed = true; tryOpen(); }, placement === \"popup\" ? (first.delivery?.delaySeconds ?? 0) * 1000 : 0);\n const retry = setInterval(tryOpen, 500);\n window.addEventListener(\"scroll\", tryOpen, { passive: true });\n window.addEventListener(\"resize\", tryOpen); document.addEventListener(\"visibilitychange\", tryOpen);\n return () => { clearTimeout(timer); clearInterval(retry); window.removeEventListener(\"scroll\", tryOpen); window.removeEventListener(\"resize\", tryOpen); document.removeEventListener(\"visibilitychange\", tryOpen); };\n }, [firstId, visible, dismissed, placement]);\n\n useEffect(() => { const token = owner.current; return () => releaseExposurePopup(token); }, []);\n useEffect(() => {\n if (placement !== \"inline\" || !active) return;\n if (typeof IntersectionObserver === \"undefined\") return;\n const element = measuredRef.current;\n const observer = new IntersectionObserver(([entry]) => setInView(Boolean(entry?.isIntersecting)), { threshold: 0.1 });\n if (element) observer.observe(element);\n return () => observer.disconnect();\n }, [placement, active]);\n useEffect(() => {\n const campaign = latest.current.campaigns.find((item) => item.id === activeId);\n if (runtime.preview || !active || hiddenOnScroll || !inView || !campaign || viewed.current.has(campaign.id)) return;\n // 현재 묶음의 방문 중 한 번 기록은 다음 슬라이드의 표시를 방해하지 않는다.\n viewed.current.add(campaign.id); rememberExposureView(campaign, latest.current.runtime.now());\n }, [active, hiddenOnScroll, inView, activeId, runtime.preview]);\n\n useEffect(() => {\n if (placement !== \"top\" && placement !== \"bottom\") return;\n const element = measuredRef.current;\n const measure = () => {\n const rect = element?.getBoundingClientRect();\n const fullHeight = active && rect ? Math.ceil(rect.height) : 0;\n setMeasuredHeight((previous) => active ? Math.max(previous, fullHeight) : 0);\n setHeight(slotKey, placement, hiddenOnScroll ? 0 : placement === \"top\" && device === \"desktop\" && rect ? Math.max(0, Math.min(fullHeight, Math.ceil(rect.bottom))) : fullHeight);\n };\n measure();\n const observer = typeof ResizeObserver === \"undefined\" ? null : new ResizeObserver(measure);\n if (element) observer?.observe(element);\n window.addEventListener(\"resize\", measure); window.addEventListener(\"scroll\", measure, { passive: true });\n return () => { observer?.disconnect(); window.removeEventListener(\"resize\", measure); window.removeEventListener(\"scroll\", measure); setHeight(slotKey, placement, 0); };\n }, [active, placement, slotKey, setHeight, hiddenOnScroll, device]);\n\n function close(forToday = false) {\n releaseExposurePopup(owner.current);\n if (!latest.current.runtime.preview) rememberExposureGroupDismissal(latest.current.campaigns, latest.current.runtime.now(), forToday);\n setDismissed(true);\n }\n if (!active || !campaign) return null;\n const closeControls = <>\n {placement === \"popup\" || placement === \"bottom\" || (campaign.delivery?.dismissible ?? true) ? <button type=\"button\" data-exposure-close=\"\" className=\"rt-exposure__close\" aria-label=\"안내 닫기\" onClick={() => close()}>×</button> : null}\n {placement === \"popup\" && campaigns.some((item) => item.delivery?.hideForToday) ? <button type=\"button\" className=\"rt-exposure__hide-today\" onClick={() => close(true)}>오늘 그만 보기</button> : null}\n </>;\n const body = <div className=\"rt-exposure-carousel\" aria-roledescription={eligible.length > 1 ? \"캐러셀\" : undefined} {...carousel.interactions}>\n <div ref={slideRef} className=\"rt-exposure-slide\" role=\"group\" aria-roledescription={eligible.length > 1 ? \"슬라이드\" : undefined} aria-label={`${carousel.index + 1} / ${eligible.length}`}>\n <ExposureContent key={campaign.id} campaign={campaign} device={runtime.device} />\n </div>\n {closeControls}\n <ExposureCarouselControls carousel={carousel} campaigns={eligible} />\n {placement === \"popup\" && eligible.length > 1 ? <div className=\"rt-exposure-sizer\" aria-hidden=\"true\" inert style={{ visibility: \"hidden\", pointerEvents: \"none\" }}>\n {eligible.map((item) => <ExposureContent key={item.id} campaign={item} device={runtime.device} />)}\n </div> : null}\n </div>;\n const classes = `rt-exposure rt-exposure--${campaign.kind} rt-exposure--${contentVariant(campaign)}`;\n if (placement === \"popup\") return <ExposureDialog title=\"홈페이지 안내\" className={`${classes} ${className}`} onClose={() => close()}\n device={runtime.device} size={exposureGroupSize(eligible)} themeElement={runtime.themeElement} manageFocus={!runtime.preview} onReady={setPopupReady}>{body}</ExposureDialog>;\n return <div className={className} data-roottale-exposure-slot={slotKey} data-roottale-exposure-placement={placement}\n style={placement === \"bottom\" || runtime.device === \"mobile\" && placement === \"top\" ? { height } : { minHeight: height }}>\n <div ref={measuredRef} className={`rt-exposure-position rt-exposure-position--${placement}`} data-device={runtime.device}\n data-scroll-hidden={hiddenOnScroll ? \"true\" : \"false\"} aria-hidden={hiddenOnScroll || undefined} inert={hiddenOnScroll || undefined}>\n <aside className={classes} aria-label=\"홈페이지 안내\">{body}</aside>\n </div>\n </div>;\n}\n\nexport function RootTaleExposureCarouselPreview({ campaigns, placement = \"popup\", device = \"desktop\", slideDurationMs = 5000 }: {\n campaigns: readonly CmsExposureCampaign[]; placement?: ExposurePlacement; device?: \"desktop\" | \"mobile\"; slideDurationMs?: number;\n}) {\n const carousel = useExposureCarousel(campaigns, true, slideDurationMs, true);\n const campaign = carousel.campaign;\n const slideRef = useSlideScrollReset(campaign?.id);\n if (!campaign) return null;\n return <div className={`rt-exposure rt-exposure--${campaign.kind} rt-exposure--preview`} data-placement={placement} data-device={device} data-size={exposureGroupSize(campaigns)}>\n <div className=\"rt-exposure-carousel\" {...carousel.interactions}>\n <div ref={slideRef} className=\"rt-exposure-slide\">\n <ExposureContent key={campaign.id} campaign={campaign} device={device} />\n </div>\n <ExposureCarouselControls carousel={carousel} campaigns={campaigns} />\n </div>\n </div>;\n}\n","\"use client\";\n\nimport { useState, type ReactNode } from \"react\";\nimport type { CmsExposureCampaign } from \"@roottale/cms-client/server\";\n\nexport type ExposurePlacement = \"top\" | \"inline\" | \"bottom\" | \"popup\";\n\nexport function ExposureContent({ campaign, device, controls }: {\n campaign: CmsExposureCampaign;\n device: \"mobile\" | \"desktop\";\n controls?: ReactNode;\n}) {\n const { content } = campaign;\n const [failedUrls, setFailedUrls] = useState<readonly string[]>([]);\n const preferred = device === \"mobile\" && content.mobileAssetUrl ? content.mobileAssetUrl : content.assetUrl;\n const textOnly = campaign.delivery?.version === 2 && [\"notice\", \"card\"].includes(content.variant);\n const assetUrl = textOnly ? undefined : preferred && !failedUrls.includes(preferred) ? preferred : content.assetUrl && !failedUrls.includes(content.assetUrl) ? content.assetUrl : undefined;\n const assetAlt = device === \"mobile\" && assetUrl === content.mobileAssetUrl ? content.mobileAssetAlt ?? content.assetAlt : content.assetAlt;\n const imageOnly = content.variant === \"image\" && Boolean(assetUrl);\n const linkProps = { href: content.linkUrl, ...(content.linkTarget === \"blank\" ? { target: \"_blank\", rel: \"noopener noreferrer\" } : {}) };\n const asset = assetUrl ? <img className=\"rt-exposure__asset\" src={assetUrl} alt={assetAlt ?? content.title}\n onError={() => setFailedUrls((previous) => [...previous, assetUrl])} /> : null;\n return <div className={`rt-exposure__body${imageOnly ? \" rt-exposure__body--image\" : \"\"}`}>\n {imageOnly && content.linkUrl ? <a {...linkProps} aria-label={content.linkLabel ?? content.title}>{asset}</a> : asset}\n <div className={`rt-exposure__copy${imageOnly ? \" rt-exposure__sr-only\" : \"\"}`}>\n {content.eyebrow ? <p className=\"rt-exposure__eyebrow\">{content.eyebrow}</p> : null}\n <h2 className=\"rt-exposure__title\">{content.title}</h2>\n {content.description ? <p className=\"rt-exposure__description\">{content.description}</p> : null}\n {!imageOnly && content.linkUrl && content.linkLabel ? <a className=\"rt-exposure__link\" {...linkProps}>{content.linkLabel}</a> : null}\n </div>\n {controls}\n </div>;\n}\n\n/** 실제 콘텐츠 출력과 같지만 방문 기록·조회·포커스 이동이 없는 편집기 미리보기. */\nexport function RootTaleExposurePreview({ campaign, placement = campaign.kind === \"popup\" ? \"popup\" : \"inline\", device = \"desktop\", className = \"\" }: {\n campaign: CmsExposureCampaign;\n placement?: ExposurePlacement;\n device?: \"mobile\" | \"desktop\";\n className?: string;\n}) {\n return <div className={`rt-exposure rt-exposure--${campaign.kind} rt-exposure--${contentVariant(campaign)} rt-exposure--preview ${className}`}\n data-placement={placement} data-device={device} data-size={campaign.delivery?.size ?? \"medium\"}>\n <ExposureContent campaign={campaign} device={device} />\n </div>;\n}\n\nexport function contentVariant(campaign: CmsExposureCampaign): string {\n // 공개 문자열을 임의 CSS 클래스 목록으로 확장하지 않는다.\n return campaign.content.variant.replace(/[^a-zA-Z0-9_-]/g, \"\");\n}\n","\"use client\";\n\nimport { useEffect, useLayoutEffect, useRef, useState, type ReactNode } from \"react\";\nimport { createPortal } from \"react-dom\";\n\nlet activeDialog: HTMLElement | null = null;\nlet openingOwner: symbol | null = null;\n\nexport function reserveExposurePopup(owner: symbol): boolean {\n if (openingOwner !== null && openingOwner !== owner) return false;\n openingOwner = owner;\n return true;\n}\n\nexport function releaseExposurePopup(owner: symbol) {\n if (openingOwner === owner) openingOwner = null;\n}\n\nexport function exposureCanOpenPopup(): boolean {\n const focused = document.activeElement;\n if (focused instanceof HTMLElement && (focused.matches(\"input, textarea, select\") || focused.isContentEditable)) return false;\n if (activeDialog?.isConnected) return false;\n return !Array.from(document.querySelectorAll<HTMLElement>('dialog[open], [role=\"dialog\"][aria-modal=\"true\"]'))\n .some((element) => {\n // keepMounted Drawer처럼 DOM에 남은 닫힌 모달을 활성 모달로 세지 않는다.\n for (let ancestor: HTMLElement | null = element; ancestor; ancestor = ancestor.parentElement) {\n if (ancestor.hidden || ancestor.inert || ancestor.getAttribute(\"aria-hidden\") === \"true\") return false;\n const style = getComputedStyle(ancestor);\n if (style.display === \"none\" || style.visibility === \"hidden\" || style.visibility === \"collapse\") return false;\n }\n return true;\n });\n}\n\nexport function ExposureDialog({ title, className, children, onClose, onReady, device, size, themeElement, manageFocus = true }: {\n title: string; className: string; children: ReactNode; onClose: () => void;\n device: \"desktop\" | \"mobile\"; size: \"small\" | \"medium\" | \"large\";\n themeElement: HTMLElement | null;\n onReady?: (ready: boolean) => void;\n manageFocus?: boolean;\n}) {\n const rootRef = useRef<HTMLDivElement>(null);\n const dialogRef = useRef<HTMLElement>(null);\n const closeRef = useRef(onClose);\n const [ready, setReady] = useState(false);\n useEffect(() => { if (ready) onReady?.(true); }, [ready, onReady]);\n useLayoutEffect(() => {\n const root = rootRef.current;\n if (!root) return;\n // 모든 안내의 이미지 높이가 정해진 뒤 공통 크기의 창을 보여 준다.\n const pending = Array.from(root.querySelectorAll(\"img\")).filter((image) => !image.complete);\n if (!pending.length) { setReady(true); return; }\n const remaining = new Set(pending);\n const settle = (event: Event) => {\n remaining.delete(event.currentTarget as HTMLImageElement);\n if (!remaining.size) setReady(true);\n };\n for (const image of pending) { image.addEventListener(\"load\", settle); image.addEventListener(\"error\", settle); }\n return () => { for (const image of pending) { image.removeEventListener(\"load\", settle); image.removeEventListener(\"error\", settle); } };\n }, []);\n useEffect(() => { closeRef.current = onClose; }, [onClose]);\n useEffect(() => {\n const target = rootRef.current;\n if (!themeElement || !target) return;\n const computed = getComputedStyle(themeElement);\n target.style.fontFamily = computed.fontFamily;\n target.style.color = computed.color;\n for (let index = 0; index < computed.length; index++) {\n const key = computed.item(index);\n if (key.startsWith(\"--\")) target.style.setProperty(key, computed.getPropertyValue(key));\n }\n }, [themeElement]);\n useEffect(() => {\n const root = rootRef.current;\n const dialog = dialogRef.current;\n if (!root || !dialog || !ready) return;\n activeDialog = dialog;\n const previous = document.activeElement instanceof HTMLElement ? document.activeElement : null;\n const previousOverflow = document.body.style.overflow;\n const previousPadding = document.body.style.paddingRight;\n const gutter = Math.max(0, window.innerWidth - document.documentElement.clientWidth);\n const padding = Number.parseFloat(getComputedStyle(document.body).paddingRight) || 0;\n document.body.style.overflow = \"hidden\";\n if (gutter > 0) document.body.style.paddingRight = `${padding + gutter}px`;\n const inertBefore = new Map<HTMLElement, boolean>();\n function inertBackground() {\n for (const child of document.body.children) {\n if (!(child instanceof HTMLElement) || child === root || child.contains(root) || inertBefore.has(child)) continue;\n inertBefore.set(child, child.inert); child.inert = true;\n }\n }\n inertBackground();\n const observer = new MutationObserver(inertBackground);\n observer.observe(document.body, { childList: true });\n const focusable = () => Array.from(dialog.querySelectorAll<HTMLElement>('a[href], button:not([disabled]), input:not([disabled]), select:not([disabled]), textarea:not([disabled]), [tabindex=\"0\"]'))\n .filter((element) => !element.hidden && !element.closest('[hidden], [aria-hidden=\"true\"]'));\n if (manageFocus) dialog.focus({ preventScroll: true });\n const handleKey = (event: KeyboardEvent) => {\n if (event.key === \"Escape\") { event.preventDefault(); event.stopPropagation(); closeRef.current(); }\n if (event.key !== \"Tab\") return;\n const items = focusable();\n const first = items[0]; const last = items[items.length - 1];\n if (!first || !last) { event.preventDefault(); dialog.focus(); }\n else if (event.shiftKey && (document.activeElement === first || document.activeElement === dialog)) { event.preventDefault(); last.focus(); }\n else if (!event.shiftKey && (document.activeElement === last || document.activeElement === dialog)) { event.preventDefault(); first.focus(); }\n };\n const handleFocus = (event: FocusEvent) => {\n if (event.target instanceof Node && !dialog.contains(event.target)) (focusable()[0] ?? dialog).focus({ preventScroll: true });\n };\n document.addEventListener(\"keydown\", handleKey, true);\n if (manageFocus) document.addEventListener(\"focusin\", handleFocus);\n return () => {\n observer.disconnect();\n document.removeEventListener(\"keydown\", handleKey, true);\n document.removeEventListener(\"focusin\", handleFocus);\n for (const [element, wasInert] of inertBefore) element.inert = wasInert;\n if (activeDialog === dialog) activeDialog = null;\n document.body.style.overflow = previousOverflow;\n document.body.style.paddingRight = previousPadding;\n if (!manageFocus) return;\n if (previous?.isConnected && !previous.inert) previous.focus({ preventScroll: true });\n else {\n const fallback = document.querySelector<HTMLElement>('main, [role=\"main\"]') ?? document.body;\n const hadTabIndex = fallback.hasAttribute(\"tabindex\");\n if (!hadTabIndex) fallback.tabIndex = -1;\n fallback.focus({ preventScroll: true });\n if (!hadTabIndex) fallback.removeAttribute(\"tabindex\");\n }\n };\n }, [ready, manageFocus]);\n\n return createPortal(<div ref={rootRef} className=\"rt-exposure-backdrop\" data-device={device} style={{ visibility: ready ? undefined : \"hidden\" }}>\n <section ref={dialogRef} className={className} role=\"dialog\" aria-modal=\"true\" aria-label={title} tabIndex={-1} data-size={size}>\n {children}\n </section>\n </div>, document.body);\n}\n","\"use client\";\n\nimport { useCallback, useEffect, useRef, useState, type FocusEvent, type TouchEvent } from \"react\";\nimport type { CmsExposureCampaign } from \"@roottale/cms-client/server\";\nimport { exposureCanOpenPopup } from \"./exposure-dialog\";\n\nexport function useExposureCarousel(campaigns: readonly CmsExposureCampaign[], enabled: boolean, durationMs: number, popup: boolean) {\n const [selection, setSelection] = useState({ id: campaigns[0]?.id, cycle: 0 });\n const [elapsedState, setElapsed] = useState({ id: campaigns[0]?.id, value: 0 });\n const [userPaused, setUserPaused] = useState(false);\n const [motionAllowed, setMotionAllowed] = useState(false);\n const [reducedMotion, setReducedMotion] = useState(false);\n const [hovered, setHovered] = useState(false);\n const [focused, setFocused] = useState(false);\n const [touching, setTouching] = useState(false);\n const [environmentPaused, setEnvironmentPaused] = useState(false);\n const elapsedRef = useRef(0);\n const touchOrigin = useRef<{ x: number; y: number } | null>(null);\n const index = Math.max(0, campaigns.findIndex((campaign) => campaign.id === selection.id));\n const campaign = campaigns[index];\n const elapsed = elapsedState.id === campaign?.id ? elapsedState.value : 0;\n const latest = useRef({ campaigns, index });\n useEffect(() => { latest.current = { campaigns, index }; }, [campaigns, index]);\n const duration = Math.max(3000, Math.min(30_000, durationMs));\n const paused = userPaused || hovered || focused || touching || environmentPaused || (reducedMotion && !motionAllowed);\n\n const select = useCallback((nextIndex: number) => {\n const items = latest.current.campaigns;\n if (!items.length) return;\n const normalized = (nextIndex + items.length) % items.length;\n latest.current.index = normalized;\n elapsedRef.current = 0; setElapsed({ id: items[normalized]!.id, value: 0 });\n setSelection((previous) => ({ id: items[normalized]!.id, cycle: previous.cycle + 1 }));\n }, []);\n const next = useCallback(() => select(latest.current.index + 1), [select]);\n const previous = useCallback(() => select(latest.current.index - 1), [select]);\n\n useEffect(() => {\n const media = window.matchMedia(\"(prefers-reduced-motion: reduce)\");\n const changed = () => setReducedMotion(media.matches);\n changed(); media.addEventListener(\"change\", changed);\n return () => media.removeEventListener(\"change\", changed);\n }, []);\n\n useEffect(() => {\n const changed = () => setEnvironmentPaused(document.visibilityState === \"hidden\" || (!popup && !exposureCanOpenPopup()));\n changed();\n const check = setInterval(changed, 250);\n document.addEventListener(\"visibilitychange\", changed);\n return () => { clearInterval(check); document.removeEventListener(\"visibilitychange\", changed); };\n }, [popup]);\n\n useEffect(() => { elapsedRef.current = 0; }, [campaign?.id, selection.cycle]);\n useEffect(() => {\n if (!enabled || paused || campaigns.length < 2) return;\n let previousTick = performance.now();\n const timer = setInterval(() => {\n const now = performance.now();\n elapsedRef.current += now - previousTick; previousTick = now;\n if (elapsedRef.current >= duration) next();\n else setElapsed({ id: campaign?.id, value: elapsedRef.current });\n }, 100);\n return () => clearInterval(timer);\n }, [campaign?.id, campaigns.length, enabled, paused, duration, next, selection.cycle]);\n\n function onTouchStart(event: TouchEvent<HTMLElement>) {\n const touch = event.touches[0];\n if (touch) { touchOrigin.current = { x: touch.clientX, y: touch.clientY }; setTouching(true); }\n }\n function onTouchEnd(event: TouchEvent<HTMLElement>) {\n const origin = touchOrigin.current; const touch = event.changedTouches[0];\n touchOrigin.current = null; setTouching(false);\n if (!origin || !touch || campaigns.length < 2) return;\n const dx = touch.clientX - origin.x; const dy = touch.clientY - origin.y;\n if (Math.abs(dx) >= 48 && Math.abs(dx) > Math.abs(dy) * 1.4) { if (dx < 0) next(); else previous(); }\n }\n function onFocus(event: FocusEvent<HTMLElement>) {\n // 모달을 열며 옮긴 닫기 버튼의 초기 포커스는 자동 전환을 막지 않는다.\n if (!(event.target instanceof HTMLElement)) return;\n if (event.target.closest(\"[data-exposure-close], .rt-exposure__hide-today\")) { setFocused(false); return; }\n setFocused(true);\n }\n const interactions = {\n onPointerEnter: (event: { pointerType: string }) => { if (event.pointerType === \"mouse\") setHovered(true); },\n onPointerLeave: () => setHovered(false),\n onFocusCapture: onFocus,\n onBlurCapture: (event: FocusEvent<HTMLElement>) => { if (!(event.relatedTarget instanceof Node) || !event.currentTarget.contains(event.relatedTarget)) setFocused(false); },\n onTouchStart, onTouchEnd,\n onTouchCancel: () => { touchOrigin.current = null; setTouching(false); },\n };\n const toggle = () => {\n // 재생을 명시적으로 누른 경우 그 버튼의 초점은 재생 요청을 다시 막지 않는다.\n setFocused(false);\n setHovered(false);\n if (reducedMotion && !motionAllowed) { setMotionAllowed(true); setUserPaused(false); }\n else setUserPaused((value) => !value);\n };\n return { campaign, index, paused, userPaused: userPaused || (reducedMotion && !motionAllowed), progress: Math.min(1, elapsed / duration),\n seconds: Math.max(1, Math.ceil((duration - elapsed) / 1000)), next, previous, select, toggle, interactions };\n}\n\nexport function ExposureCarouselControls({ carousel, campaigns }: { carousel: ReturnType<typeof useExposureCarousel>; campaigns: readonly CmsExposureCampaign[] }) {\n if (campaigns.length < 2) return null;\n const firstDot = Math.max(0, Math.min(campaigns.length - 5, carousel.index - 2));\n return <div className=\"rt-exposure-carousel-controls\">\n <div className=\"rt-exposure-carousel-meta\">\n <span className=\"rt-exposure-carousel-count\" aria-live={carousel.paused ? \"polite\" : \"off\"}><strong>{String(carousel.index + 1).padStart(2, \"0\")}</strong><span> / {String(campaigns.length).padStart(2, \"0\")}</span></span>\n <span className=\"rt-exposure-carousel-time\">{carousel.paused ? \"전환 일시정지\" : `${carousel.seconds}초 후 다음 안내`}</span>\n <div className=\"rt-exposure-carousel-actions\">\n <button type=\"button\" aria-label=\"이전 안내\" onClick={carousel.previous}><svg viewBox=\"0 0 24 24\" aria-hidden=\"true\"><path d=\"m14 6-6 6 6 6\" /></svg></button>\n <button type=\"button\" aria-label={carousel.userPaused ? \"자동 전환 재생\" : \"자동 전환 일시정지\"} onClick={carousel.toggle} aria-pressed={carousel.userPaused}>\n <svg viewBox=\"0 0 24 24\" aria-hidden=\"true\">{carousel.userPaused ? <path d=\"m9 5 10 7-10 7Z\" /> : <path d=\"M9 5v14M15 5v14\" />}</svg>\n </button>\n <button type=\"button\" aria-label=\"다음 안내\" onClick={carousel.next}><svg viewBox=\"0 0 24 24\" aria-hidden=\"true\"><path d=\"m10 6 6 6-6 6\" /></svg></button>\n </div>\n </div>\n <div className=\"rt-exposure-carousel-progress\" role=\"progressbar\" aria-label=\"다음 안내까지 진행\" aria-valuemin={0} aria-valuemax={100} aria-valuenow={Math.round(carousel.progress * 100)}>\n <span style={{ transform: `scaleX(${carousel.progress})` }} />\n </div>\n <div className=\"rt-exposure-carousel-dots\" aria-label=\"안내 선택\">\n {campaigns.slice(firstDot, firstDot + 5).map((campaign, offset) => { const index = firstDot + offset; return <button key={campaign.id} type=\"button\" aria-label={`${index + 1}번째 안내: ${campaign.content.title}`} aria-current={index === carousel.index ? \"true\" : undefined} onClick={() => carousel.select(index)}><span /></button>; })}\n </div>\n </div>;\n}\n","\"use client\";\nimport { useEffect, useState } from \"react\";\n\nexport function useMobileExposureScroll(enabled: boolean): boolean {\n const [hidden, setHidden] = useState(false);\n useEffect(() => {\n if (!enabled) { setHidden(false); return; }\n let previous = Math.max(0, window.scrollY);\n let distance = 0;\n const onScroll = () => {\n const current = Math.max(0, window.scrollY);\n const delta = current - previous; previous = current;\n if (current < 32) { distance = 0; setHidden(false); return; }\n if (Math.sign(delta) !== Math.sign(distance)) distance = 0;\n distance += delta;\n if (distance >= 12) { setHidden(true); distance = 0; }\n else if (distance <= -8) { setHidden(false); distance = 0; }\n };\n window.addEventListener(\"scroll\", onScroll, { passive: true });\n return () => window.removeEventListener(\"scroll\", onScroll);\n }, [enabled]);\n return enabled && hidden;\n}\n","import type { CmsExposureCampaign } from \"@roottale/cms-client/server\";\n\nfunction read(kind: \"session\" | \"local\", key: string): string | null {\n try {\n const store = kind === \"session\" ? sessionStorage : localStorage;\n return store.getItem(key);\n } catch { return null; }\n}\n\nconst cookieFallback = new Map<string, string>();\nconst sessionCookie = \"rt_exposure_session\";\nconst preferencesCookie = \"rt_exposure_preferences\";\n\nfunction compactKey(value: string, scope: \"c\" | \"g\"): string {\n // 비밀이나 권한이 아닌 UI 기록 식별자. 64bit로 줄여 다수 슬라이드도 쿠키 한도 안에 둔다.\n let left = 2166136261; let right = 2246822519;\n for (let index = 0; index < value.length; index++) {\n left = Math.imul(left ^ value.charCodeAt(index), 16777619);\n right = Math.imul(right ^ value.charCodeAt(index), 3266489917);\n }\n return `${scope}${(left >>> 0).toString(16).padStart(8, \"0\")}${(right >>> 0).toString(16).padStart(8, \"0\")}`;\n}\n\nfunction rawCookie(name: string): string | null {\n const entry = document.cookie.split(\";\").map((part) => part.trim()).find((part) => part.startsWith(`${name}=`));\n return entry ? entry.slice(name.length + 1) : null;\n}\n\nfunction readPreferences(name: string): Map<string, string> {\n let raw: string | null;\n try {\n raw = cookieFallback.get(name) ?? rawCookie(name) ?? null;\n } catch { raw = cookieFallback.get(name) ?? null; }\n const result = new Map<string, string>();\n for (const entry of raw?.split(\".\") ?? []) {\n const match = /^([cg][a-f0-9]{16})_([svun])([0-9a-z]+)$/.exec(entry);\n if (match) result.set(match[1]!, `${match[2]}:${match[2] === \"u\" ? Number.parseInt(match[3]!, 36) * 1000 : 1}`);\n }\n return result;\n}\n\nfunction writePreferenceKey(key: string, value: string, persistent: boolean, now: number) {\n const name = persistent ? preferencesCookie : sessionCookie;\n const values = readPreferences(name);\n for (const [id, preference] of values) if (preference.startsWith(\"u:\") && Number(preference.slice(2)) <= now) values.delete(id);\n values.delete(key); values.set(key, value);\n const packed = [...values].slice(-100).map(([id, preference]) => `${id}_${preference[0]}${preference.startsWith(\"u:\") ? Math.ceil(Number(preference.slice(2)) / 1000).toString(36) : \"1\"}`).join(\".\");\n try {\n const secure = location.protocol === \"https:\" ? \"; Secure\" : \"\";\n document.cookie = `${name}=${packed}; Path=/; SameSite=Lax${secure}${persistent ? \"; Max-Age=34560000\" : \"\"}`;\n if (rawCookie(name) !== packed) cookieFallback.set(name, packed);\n else cookieFallback.delete(name);\n } catch { cookieFallback.set(name, packed); }\n}\n\nfunction dateInZone(epoch: number, timeZone: string): string {\n return new Intl.DateTimeFormat(\"en-CA\", { timeZone, year: \"numeric\", month: \"2-digit\", day: \"2-digit\" }).format(epoch);\n}\n\n/** DST로 하루가 23/25시간인 곳도 날짜가 바뀌는 첫 시각을 찾는다. */\nexport function nextExposureMidnight(now: number, timeZone: string): number {\n const today = dateInZone(now, timeZone);\n let low = now;\n let high = now + 48 * 3_600_000;\n while (high - low > 1) {\n const mid = Math.floor((low + high) / 2);\n if (dateInZone(mid, timeZone) === today) low = mid;\n else high = mid;\n }\n return high;\n}\n\nexport function exposureWasHidden(campaign: CmsExposureCampaign, now: number, legacyPrefixes: readonly string[] = []): boolean {\n const persistent = readPreferences(preferencesCookie);\n const preferences = [persistent.get(compactKey(campaign.slotKey, \"g\")), persistent.get(compactKey(campaign.id, \"c\")), readPreferences(sessionCookie).get(compactKey(campaign.id, \"c\"))];\n if (preferences.some((preference) => (campaign.repeat !== \"always\" && (preference?.startsWith(\"s:\") || preference?.startsWith(\"v:\") || preference === \"n:1\")) || (preference?.startsWith(\"u:\") && Number(preference.slice(2)) > now))) return true;\n // 종전 local/sessionStorage 기록은 읽어서 호환한다. 새 기록은 쿠키만 쓴다.\n const until = Number(read(\"local\", `rt-exposure-until:${campaign.id}`));\n if (Number.isFinite(until) && until > now) return true;\n if (campaign.repeat === \"always\") return false;\n if (campaign.repeat === \"session\" && read(\"session\", `rt-exposure-viewed:${campaign.id}`)) return true;\n const kind = campaign.repeat === \"session\" ? \"session\" : \"local\";\n for (const prefix of [\"rt-exposure-dismissed:\", ...legacyPrefixes]) {\n const value = read(kind, `${prefix}${campaign.id}`);\n if (value === null) continue;\n if (campaign.repeat !== \"day\") return true;\n const dismissedAt = Number(value);\n // 레거시 접두어·delivery 없는 기존 항목은 종전의 24시간 의미를 보존한다.\n const calendar = prefix === \"rt-exposure-dismissed:\" && campaign.delivery?.dayBoundary === \"calendar\";\n if (Number.isFinite(dismissedAt) && (calendar ? dateInZone(dismissedAt, campaign.delivery!.timeZone) === dateInZone(now, campaign.delivery!.timeZone) : now - dismissedAt < 86_400_000)) return true;\n }\n return false;\n}\n\nexport function rememberExposureView(campaign: CmsExposureCampaign, now: number) {\n if (campaign.repeat === \"session\") writePreferenceKey(compactKey(campaign.id, \"c\"), \"v:1\", false, now);\n // 새 표시 규칙의 일/영구 빈도는 방문자가 닫지 않고 이동해도 실제 노출을 센다.\n if (campaign.delivery && (campaign.repeat === \"day\" || campaign.repeat === \"never\")) rememberExposureDismissal(campaign, now);\n}\n\nexport function rememberExposureDismissal(campaign: CmsExposureCampaign, now: number, forToday = false) {\n // 매번 표시의 일반 닫기는 현재 마운트의 dismissed 상태만 사용한다.\n if (campaign.repeat === \"always\" && !forToday) return;\n if (forToday || campaign.repeat === \"day\") {\n const until = forToday || campaign.delivery?.dayBoundary === \"calendar\" ? nextExposureMidnight(now, campaign.delivery?.timeZone ?? \"Asia/Seoul\") : now + 86_400_000;\n writePreferenceKey(compactKey(campaign.id, \"c\"), `u:${until}`, true, now);\n } else if (campaign.repeat === \"never\") writePreferenceKey(compactKey(campaign.id, \"c\"), \"n:1\", true, now);\n else writePreferenceKey(compactKey(campaign.id, \"c\"), \"s:1\", false, now);\n}\n\n/** 현재 보이는 묶음 전체를 닫는다. 새 캠페인 ID의 다음 방문까지 숨기지는 않는다. */\nexport function rememberExposureGroupDismissal(campaigns: readonly CmsExposureCampaign[], now: number, forToday = false) {\n if (forToday && campaigns[0]) {\n writePreferenceKey(compactKey(campaigns[0].slotKey, \"g\"), `u:${nextExposureMidnight(now, campaigns[0].delivery?.timeZone ?? \"Asia/Seoul\")}`, true, now);\n return;\n }\n for (const campaign of campaigns) rememberExposureDismissal(campaign, now, forToday);\n}\n","\"use client\";\n\nimport { useCallback, useEffect, useRef, useState } from \"react\";\nimport type { CmsExposureCampaign } from \"@roottale/cms-client/server\";\nimport { readExposureDecision } from \"./exposure-runtime-data\";\n\nexport type { CmsExposureCampaign } from \"@roottale/cms-client/server\";\nexport const EXPOSURE_PREVIEW_PROTOCOL = \"roottale:exposure-preview\";\nconst defaultOrigins: readonly string[] = [\"https://admin.roottale.com\"];\n\n/** 편집 내용은 URL에 싣지 않는다. fragment는 브라우저 간 연결 식별자만 전달한다. */\nexport function exposureSitePreviewUrl(siteUrl: string, editorOrigin: string, session: string): string | null {\n try {\n const url = new URL(siteUrl);\n const local = [\"localhost\", \"127.0.0.1\", \"[::1]\"].includes(url.hostname);\n if (url.username || url.password || (url.protocol !== \"https:\" && !(local && url.protocol === \"http:\"))) return null;\n url.pathname = \"/\"; url.search = \"\";\n url.hash = new URLSearchParams({ \"rt-exposure-preview\": session, origin: editorOrigin }).toString();\n return url.href;\n } catch { return null; }\n}\n\nfunction previewConnection(origins: readonly string[]) {\n if (typeof window === \"undefined\" || window.parent === window) return null;\n const params = new URLSearchParams(window.location.hash.slice(1));\n const session = params.get(\"rt-exposure-preview\");\n const origin = params.get(\"origin\");\n if (!session || !/^[a-f0-9]{8}(?:-[a-f0-9]{4}){3}-[a-f0-9]{12}$/i.test(session) || !origin || ![...defaultOrigins, ...origins].includes(origin)) return null;\n return { session, origin };\n}\n\nexport function parseExposurePreviewCampaign(value: unknown, slots: readonly string[]): CmsExposureCampaign | null {\n try {\n if (JSON.stringify(value).length > 32_000) return null;\n const snapshot = readExposureDecision({ campaigns: [value], evaluatedAt: \"2026-01-01T00:00:00Z\", validUntil: \"2026-01-01T00:01:00Z\" }, slots, 0, 0);\n const campaign = snapshot?.decision.campaigns[0];\n if (!campaign?.delivery || campaign.content.title.length > 200 || campaign.content.variant.length > 100) return null;\n for (const field of [\"eyebrow\", \"description\", \"assetAlt\", \"mobileAssetAlt\", \"linkLabel\"] as const) {\n const text = campaign.content[field];\n if (text !== undefined && (typeof text !== \"string\" || text.length > 2000)) return null;\n }\n if (campaign.content.linkTarget !== undefined && ![\"self\", \"blank\"].includes(campaign.content.linkTarget)) return null;\n return campaign;\n } catch { return null; }\n}\n\nexport function useExposureSitePreview(slots: readonly string[], origins: readonly string[] = defaultOrigins) {\n const [connection] = useState(() => previewConnection(origins));\n const [draft, setDraft] = useState<{ revision: number; campaign: CmsExposureCampaign } | null>(null);\n const revision = useRef(-1);\n const slotsKey = slots.join(\",\");\n const reply = useCallback((type: string, data: Record<string, unknown> = {}) => {\n if (connection) window.parent.postMessage({ type: `${EXPOSURE_PREVIEW_PROTOCOL}:${type}`, session: connection.session, ...data }, connection.origin);\n }, [connection]);\n\n useEffect(() => {\n if (!connection) return;\n function receive(event: MessageEvent) {\n if (event.source !== window.parent || event.origin !== connection!.origin) return;\n const data = event.data;\n if (!data || data.session !== connection!.session) return;\n if (data.type === `${EXPOSURE_PREVIEW_PROTOCOL}:connect`) { reply(\"ready\"); return; }\n if (data.type !== `${EXPOSURE_PREVIEW_PROTOCOL}:render` || !Number.isSafeInteger(data.revision) || data.revision <= revision.current) return;\n const campaign = parseExposurePreviewCampaign(data.campaign, slotsKey.split(\",\"));\n if (!campaign) { reply(\"error\", { revision: data.revision }); return; }\n revision.current = data.revision;\n setDraft({ revision: data.revision, campaign });\n }\n // 사이트 링크를 눌러 편집 세션을 이탈하거나 제출하지 않는다.\n const preventNavigation = (event: Event) => {\n const target = event.target instanceof Element ? event.target : null;\n const previewControl = target?.closest(\"[data-roottale-exposure-slot], .rt-exposure-backdrop\");\n if (event.type === \"submit\" || !previewControl || target?.closest(\"a[href]\")) {\n event.preventDefault(); event.stopImmediatePropagation();\n }\n };\n window.addEventListener(\"message\", receive);\n document.addEventListener(\"click\", preventNavigation, true);\n document.addEventListener(\"submit\", preventNavigation, true);\n reply(\"ready\");\n return () => {\n window.removeEventListener(\"message\", receive);\n document.removeEventListener(\"click\", preventNavigation, true);\n document.removeEventListener(\"submit\", preventNavigation, true);\n };\n }, [connection, reply, slotsKey]);\n const draftRevision = draft?.revision ?? -1;\n const report = useCallback((valid: boolean) => reply(valid ? \"rendered\" : \"error\", { revision: draftRevision }), [reply, draftRevision]);\n return { active: connection !== null, draft, report };\n}\n"],"mappings":";;;;;;AAEA,SAAS,eAAe,eAAAA,cAAa,YAAY,aAAAC,YAAW,UAAAC,SAAQ,YAAAC,iBAAoD;;;ACAxH,SAAS,WAAW,gBAAgB;;;ACQpC,SAAS,UAAU,OAAgB,WAAW,MAAe;AAC3D,MAAI,SAAS,KAAM,QAAO;AAC1B,MAAI,OAAO,UAAU,YAAY,0BAA0B,KAAK,KAAK,EAAG,QAAO;AAC/E,MAAI,YAAY,MAAM,WAAW,GAAG,KAAK,CAAC,MAAM,WAAW,IAAI,EAAG,QAAO;AACzE,MAAI;AAAE,UAAM,MAAM,IAAI,IAAI,KAAK;AAAG,WAAO,IAAI,aAAa,YAAY,CAAC,IAAI,YAAY,CAAC,IAAI;AAAA,EAAU,QAAQ;AAAE,WAAO;AAAA,EAAO;AAChI;AAGO,SAAS,qBAAqB,OAAgB,OAA0B,YAAoB,SAA+C;AAChJ,MAAI,CAAC,SAAS,OAAO,UAAU,SAAU,QAAO;AAChD,QAAM,OAAO;AACb,QAAM,YAAY,KAAK,MAAM,KAAK,WAAW;AAC7C,QAAM,aAAa,KAAK,MAAM,KAAK,UAAU;AAC7C,MAAI,CAAC,OAAO,SAAS,SAAS,KAAK,CAAC,OAAO,SAAS,UAAU,KAAK,cAAc,aAC/E,CAAC,MAAM,QAAQ,KAAK,SAAS,KAAK,KAAK,UAAU,SAAS,IAAK,QAAO;AAExE,QAAM,kBAAkB,YAAY,KAAK,IAAI,GAAG,OAAO;AACvD,QAAM,YAAY,aAAa,KAAK,IAAI,aAAa,iBAAiB,IAAO;AAC7E,MAAI,aAAa,WAAY,QAAO;AACpC,QAAM,YAAmC,CAAC;AAC1C,aAAW,QAAQ,KAAK,WAAW;AACjC,QAAI,CAAC,QAAQ,OAAO,KAAK,OAAO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AAI,QAAQ,SAAS,YAAY,MAAM,EAAwF;AAClM;AAGO,SAAS,uBAAuB,EAAE,UAAU,gBAAgB,GAA0E;AAC3I,QAAM,CAAC,QAAQ,SAAS,IAAIC,UAA+B,SAAS;AACpE,EAAAC,WAAU,MAAM;AAAE,UAAM,QAAQ,OAAO,WAAW,oBAAoB;AAAG,UAAM,SAAS,MAAM,UAAU,MAAM,UAAU,WAAW,SAAS;AAAG,WAAO;AAAG,UAAM,iBAAiB,UAAU,MAAM;AAAG,WAAO,MAAM,MAAM,oBAAoB,UAAU,MAAM;AAAA,EAAG,GAAG,CAAC,CAAC;AAClQ,MAAI,CAAC,gBAAgB,SAAS,SAAS,QAAQ,OAAO,EAAG,QAAO;AAChE,QAAM,UAA2B;AAAA,IAAE,WAAW,CAAC,QAAQ;AAAA,IAAG;AAAA,IAAQ,UAAU;AAAA,IAAU,MAAM;AAAA,IAAM,iBAAiB;AAAA,IAAM,2BAA2B;AAAA,IAClJ,KAAK,KAAK;AAAA,IAAK,YAAY,MAAM;AAAA,IAAM,WAAW,MAAM;AAAA,IAAW,gBAAgB;AAAA,IAAe,cAAc;AAAA,EAAK;AACvH,SAAO,gBAAAF,KAAC,yBAAwC,WAAW,CAAC,QAAQ,GAAG,SAAkB,WAAW,SAAS,SAAS,UAAU,UAAU,UAAU,WAAU,MAA3H,SAAS,EAAqH;AACnK;","names":["useCallback","useEffect","useRef","useState","useEffect","useLayoutEffect","useRef","useState","useState","useEffect","useState","jsx","useEffect","useRef","useState","jsx","jsxs","useState","useRef","campaign","useEffect","previous","useEffect","useState","jsx","jsxs","useRef","useLayoutEffect","useState","campaign","useEffect","first","useCallback","useEffect","useRef","useState","useState","useRef","useCallback","useEffect","jsx","useState","useEffect","useRef","useCallback"]}
|
package/dist/cms-public.css
CHANGED
|
@@ -58,6 +58,7 @@
|
|
|
58
58
|
.rt-exposure--preview { position: relative; max-inline-size: 100%; }
|
|
59
59
|
.rt-exposure-carousel { position: relative; font: inherit; touch-action: pan-y pinch-zoom; }
|
|
60
60
|
.rt-exposure-slide { min-inline-size: 0; }
|
|
61
|
+
.rt-exposure-sizer { display: none; }
|
|
61
62
|
.rt-exposure-slide > .rt-exposure__body { animation: rt-exposure-reveal 180ms ease-out; }
|
|
62
63
|
.rt-exposure-carousel-controls { padding: .375rem 1rem .5rem; border-block-start: 1px solid var(--rt-color-border, rgb(0 0 0 / .1)); }
|
|
63
64
|
.rt-exposure-carousel-meta { display: flex; align-items: center; gap: .75rem; min-block-size: 2.75rem; }
|
package/dist/exposure-client.js
CHANGED
package/dist/exposures.d.ts
CHANGED
|
@@ -2,6 +2,7 @@ import * as react from 'react';
|
|
|
2
2
|
import { ReactNode } from 'react';
|
|
3
3
|
import * as react_jsx_runtime from 'react/jsx-runtime';
|
|
4
4
|
import { CmsExposureCampaign } from '@roottale/cms-client/server';
|
|
5
|
+
export { CmsExposureCampaign } from '@roottale/cms-client/server';
|
|
5
6
|
|
|
6
7
|
type ExposurePlacement = "top" | "inline" | "bottom" | "popup";
|
|
7
8
|
/** 실제 콘텐츠 출력과 같지만 방문 기록·조회·포커스 이동이 없는 편집기 미리보기. */
|
|
@@ -19,6 +20,11 @@ declare function RootTaleExposureCarouselPreview({ campaigns, placement, device,
|
|
|
19
20
|
slideDurationMs?: number;
|
|
20
21
|
}): react_jsx_runtime.JSX.Element | null;
|
|
21
22
|
|
|
23
|
+
declare const EXPOSURE_PREVIEW_PROTOCOL = "roottale:exposure-preview";
|
|
24
|
+
/** 편집 내용은 URL에 싣지 않는다. fragment는 브라우저 간 연결 식별자만 전달한다. */
|
|
25
|
+
declare function exposureSitePreviewUrl(siteUrl: string, editorOrigin: string, session: string): string | null;
|
|
26
|
+
declare function parseExposurePreviewCampaign(value: unknown, slots: readonly string[]): CmsExposureCampaign | null;
|
|
27
|
+
|
|
22
28
|
interface RootTaleExposureProviderProps {
|
|
23
29
|
endpoint: string;
|
|
24
30
|
/** 사이트의 usePathname() 값. API 키는 서버에만 둔다. */
|
|
@@ -30,9 +36,11 @@ interface RootTaleExposureProviderProps {
|
|
|
30
36
|
slideDurationMs?: number;
|
|
31
37
|
hideMobileBannersOnScroll?: boolean;
|
|
32
38
|
legacyDismissalKeyPrefixes?: readonly string[];
|
|
39
|
+
/** 추가 관리자 출처가 필요한 사이트에서만 지정한다. 기본은 canonical ROOT-ADMIN. */
|
|
40
|
+
previewOrigins?: readonly string[];
|
|
33
41
|
children: ReactNode;
|
|
34
42
|
}
|
|
35
|
-
declare function RootTaleExposureProvider({ endpoint, pathname, slots, breakpoint, homePaths, slideDurationMs, hideMobileBannersOnScroll, legacyDismissalKeyPrefixes, children }: RootTaleExposureProviderProps): react_jsx_runtime.JSX.Element;
|
|
43
|
+
declare function RootTaleExposureProvider({ endpoint, pathname, slots, breakpoint, homePaths, slideDurationMs, hideMobileBannersOnScroll, legacyDismissalKeyPrefixes, previewOrigins, children }: RootTaleExposureProviderProps): react_jsx_runtime.JSX.Element;
|
|
36
44
|
interface RootTaleExposureSlotProps {
|
|
37
45
|
slotKey: string;
|
|
38
46
|
placement: ExposurePlacement;
|
|
@@ -48,4 +56,4 @@ declare function RootTaleLegacyExposure({ campaign, allowedVariants }: {
|
|
|
48
56
|
allowedVariants: readonly string[];
|
|
49
57
|
}): react_jsx_runtime.JSX.Element | null;
|
|
50
58
|
|
|
51
|
-
export { type ExposurePlacement, RootTaleExposureCarouselPreview, RootTaleExposurePreview, RootTaleExposureProvider, type RootTaleExposureProviderProps, RootTaleExposureSlot, type RootTaleExposureSlotProps, RootTaleLegacyExposure };
|
|
59
|
+
export { EXPOSURE_PREVIEW_PROTOCOL, type ExposurePlacement, RootTaleExposureCarouselPreview, RootTaleExposurePreview, RootTaleExposureProvider, type RootTaleExposureProviderProps, RootTaleExposureSlot, type RootTaleExposureSlotProps, RootTaleLegacyExposure, exposureSitePreviewUrl, parseExposurePreviewCampaign };
|
package/dist/exposures.js
CHANGED
|
@@ -1,17 +1,23 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
import {
|
|
3
|
+
EXPOSURE_PREVIEW_PROTOCOL,
|
|
3
4
|
RootTaleExposureCarouselPreview,
|
|
4
5
|
RootTaleExposurePreview,
|
|
5
6
|
RootTaleExposureProvider,
|
|
6
7
|
RootTaleExposureSlot,
|
|
7
|
-
RootTaleLegacyExposure
|
|
8
|
-
|
|
8
|
+
RootTaleLegacyExposure,
|
|
9
|
+
exposureSitePreviewUrl,
|
|
10
|
+
parseExposurePreviewCampaign
|
|
11
|
+
} from "./chunk-LUL73SKP.js";
|
|
9
12
|
import "./chunk-L3I4W5NP.js";
|
|
10
13
|
export {
|
|
14
|
+
EXPOSURE_PREVIEW_PROTOCOL,
|
|
11
15
|
RootTaleExposureCarouselPreview,
|
|
12
16
|
RootTaleExposurePreview,
|
|
13
17
|
RootTaleExposureProvider,
|
|
14
18
|
RootTaleExposureSlot,
|
|
15
|
-
RootTaleLegacyExposure
|
|
19
|
+
RootTaleLegacyExposure,
|
|
20
|
+
exposureSitePreviewUrl,
|
|
21
|
+
parseExposurePreviewCampaign
|
|
16
22
|
};
|
|
17
23
|
//# sourceMappingURL=exposures.js.map
|
package/dist/routes.d.ts
CHANGED
|
@@ -250,7 +250,29 @@ interface RevalidateRouteConfig {
|
|
|
250
250
|
alsoRevalidate?: string[];
|
|
251
251
|
/** (옵션) jti replay 방지 hook (cms-client verify 로 전달). */
|
|
252
252
|
consumeJti?: (jti: string, exp: number) => Promise<"new" | "seen">;
|
|
253
|
+
/**
|
|
254
|
+
* 본문 상한(바이트). 기본 64KB. 서명 검증 전에 `content-length` 와 실제 바이트를
|
|
255
|
+
* 모두 확인해 413 으로 거절한다 — 발행 알림은 경로 목록뿐이라 이보다 클 수 없다.
|
|
256
|
+
*/
|
|
257
|
+
maxBodyBytes?: number;
|
|
258
|
+
/**
|
|
259
|
+
* (옵션) 글 이벤트에서 **본문 paths 에 없는** 상세 경로를 더 무효화해야 할 때.
|
|
260
|
+
* 방금 발행한 글을 "관련 콘텐츠"로 고른 다른 글의 상세는 캐시본의 관계 필드에
|
|
261
|
+
* 그 글이 없어(발행 전 제외) 본문 paths 에 오지 않는다. 사이트가 CMS 를
|
|
262
|
+
* `fresh` 로 직접 읽어 역참조 경로를 돌려주면 함께 무효화한다(ADR-0114 §1).
|
|
263
|
+
* throw 하면 이 훅만 건너뛰고 나머지는 계속한다.
|
|
264
|
+
*/
|
|
265
|
+
relatedPaths?: (context: RevalidateRelatedPathsContext) => string[] | Promise<string[]>;
|
|
266
|
+
}
|
|
267
|
+
interface RevalidateRelatedPathsContext {
|
|
268
|
+
event: string;
|
|
269
|
+
deliveryId: string;
|
|
270
|
+
paths: string[];
|
|
271
|
+
postId: string | null;
|
|
272
|
+
modelKey: string | null;
|
|
253
273
|
}
|
|
274
|
+
/** 4xx·5xx 거절 사유 — 응답 본문 `reason` 으로 ROOT-ADMIN 전달 표에 그대로 보인다. */
|
|
275
|
+
type RevalidateRejectReason = "service_unconfigured" | "payload_too_large" | "invalid_body" | "missing_paths" | "model_path_mismatch";
|
|
254
276
|
/**
|
|
255
277
|
* `app/api/revalidate/route.ts` 용 POST 핸들러.
|
|
256
278
|
*
|
|
@@ -267,6 +289,18 @@ interface RevalidateRouteConfig {
|
|
|
267
289
|
* ```
|
|
268
290
|
*/
|
|
269
291
|
declare function createRevalidateRoute(config: RevalidateRouteConfig): (req: Request) => Promise<Response>;
|
|
292
|
+
/**
|
|
293
|
+
* `app/api/revalidate/route.ts` 에 `export const { POST, GET } = …` 로 쓰는 묶음.
|
|
294
|
+
* GET 은 405 — 브라우저·크롤러가 주소를 열어도 200 이 캐시되지 않는다.
|
|
295
|
+
*
|
|
296
|
+
* ```ts
|
|
297
|
+
* export const { POST, GET } = createRevalidateRouteHandlers({ … });
|
|
298
|
+
* ```
|
|
299
|
+
*/
|
|
300
|
+
declare function createRevalidateRouteHandlers(config: RevalidateRouteConfig): {
|
|
301
|
+
POST: (req: Request) => Promise<Response>;
|
|
302
|
+
GET: () => Response;
|
|
303
|
+
};
|
|
270
304
|
|
|
271
305
|
interface ExposureRouteConfig {
|
|
272
306
|
/** 서버 전용 고객 CMS 키. 브라우저의 요청으로 바꾸지 않는다. */
|
|
@@ -1042,4 +1076,4 @@ interface FleetInfoRouteConfig {
|
|
|
1042
1076
|
*/
|
|
1043
1077
|
declare function createFleetInfoRoute(config?: FleetInfoRouteConfig): () => Promise<Response>;
|
|
1044
1078
|
|
|
1045
|
-
export { ARCHIVE_POST_COUNT_LIMIT, type AlwaysNoindexArchiveKind, type ArchiveCategoriesConfig, type ArchiveCategoriesOptions, type ArchiveIndexDecision, type ArchiveIndexInput, type ArchiveKind, type ArchiveMetadata, type ArchiveMetadataFields, type ArchiveMetadataInput, type ArchivePromotion, type BuildArchiveMetadataOptions, type BuildPostMetadataOptions, type CollectionsInput, type ExposureRouteConfig, type FleetInfoRouteConfig, type ImageResponseLike, type LlmsTxtLink, type LlmsTxtRouteConfig, type LlmsTxtSection, OG_IMAGE_CONTENT_TYPE, OG_IMAGE_SIZE, type OgImageRouteConfig, type PostLocaleOptions, type PostMetadata, type PostMetadataInput, type PostSeoOverrides, type PreviewMetadata, type PromotableArchiveKind, type PublicUrlPost, type RedirectMiddlewareConfig, type RevalidateRouteConfig, type RobotsMeta, type RootTaleSiteConfig, type SitemapEntry, type SitemapIndexOptions, type SitemapSectionId, buildArchiveMetadata, buildHreflangLanguages, buildPostMetadata, buildPreviewMetadata, createExposureRoute, createFeedRoute, createFleetInfoRoute, createLlmsTxtRoute, createPostOgImage, createRedirectMiddleware, createRevalidateRoute, createSitemap, createSitemapIndex, decideArchiveIndex, fetchBlogArchiveCategories, fetchBlogArchivePosts, matchRedirect, normalizeRedirectPath, postRedirectPath, resolveAuthorPromotion, resolveCategoryPromotion, resolveCollections, resolveCollectionsResult, resolveRobotsMeta, safeFetchPosts, storedPostPath, trimSlash };
|
|
1079
|
+
export { ARCHIVE_POST_COUNT_LIMIT, type AlwaysNoindexArchiveKind, type ArchiveCategoriesConfig, type ArchiveCategoriesOptions, type ArchiveIndexDecision, type ArchiveIndexInput, type ArchiveKind, type ArchiveMetadata, type ArchiveMetadataFields, type ArchiveMetadataInput, type ArchivePromotion, type BuildArchiveMetadataOptions, type BuildPostMetadataOptions, type CollectionsInput, type ExposureRouteConfig, type FleetInfoRouteConfig, type ImageResponseLike, type LlmsTxtLink, type LlmsTxtRouteConfig, type LlmsTxtSection, OG_IMAGE_CONTENT_TYPE, OG_IMAGE_SIZE, type OgImageRouteConfig, type PostLocaleOptions, type PostMetadata, type PostMetadataInput, type PostSeoOverrides, type PreviewMetadata, type PromotableArchiveKind, type PublicUrlPost, type RedirectMiddlewareConfig, type RevalidateRejectReason, type RevalidateRelatedPathsContext, type RevalidateRouteConfig, type RobotsMeta, type RootTaleSiteConfig, type SitemapEntry, type SitemapIndexOptions, type SitemapSectionId, buildArchiveMetadata, buildHreflangLanguages, buildPostMetadata, buildPreviewMetadata, createExposureRoute, createFeedRoute, createFleetInfoRoute, createLlmsTxtRoute, createPostOgImage, createRedirectMiddleware, createRevalidateRoute, createRevalidateRouteHandlers, createSitemap, createSitemapIndex, decideArchiveIndex, fetchBlogArchiveCategories, fetchBlogArchivePosts, matchRedirect, normalizeRedirectPath, postRedirectPath, resolveAuthorPromotion, resolveCategoryPromotion, resolveCollections, resolveCollectionsResult, resolveRobotsMeta, safeFetchPosts, storedPostPath, trimSlash };
|
package/dist/routes.js
CHANGED
|
@@ -577,30 +577,86 @@ import {
|
|
|
577
577
|
verifyRootTaleWebhook
|
|
578
578
|
} from "@roottale/cms-client/webhook";
|
|
579
579
|
import { isInCollectionMode as isInCollectionMode4 } from "@roottale/cms-core";
|
|
580
|
-
|
|
580
|
+
var DEFAULT_MAX_BODY_BYTES = 64 * 1024;
|
|
581
|
+
var NO_STORE = { "cache-control": "no-store" };
|
|
582
|
+
function jsonResponse(body, status) {
|
|
583
|
+
return Response.json(body, { status, headers: NO_STORE });
|
|
584
|
+
}
|
|
585
|
+
function reject(reason, status, context) {
|
|
586
|
+
console.warn(
|
|
587
|
+
JSON.stringify({
|
|
588
|
+
message: "[@roottale/cms-renderer-next/routes] revalidate \uAC70\uC808",
|
|
589
|
+
reason,
|
|
590
|
+
status,
|
|
591
|
+
...context
|
|
592
|
+
})
|
|
593
|
+
);
|
|
594
|
+
return jsonResponse({ ok: false, reason }, status);
|
|
595
|
+
}
|
|
596
|
+
function isSafePath(value) {
|
|
597
|
+
return typeof value === "string" && value.startsWith("/") && !value.startsWith("//");
|
|
598
|
+
}
|
|
599
|
+
function trimmedString(value) {
|
|
600
|
+
return typeof value === "string" && value.trim() ? value.trim() : null;
|
|
601
|
+
}
|
|
602
|
+
function bodyFromRaw(rawBody) {
|
|
581
603
|
try {
|
|
582
|
-
const
|
|
583
|
-
if (Array.isArray(
|
|
584
|
-
|
|
585
|
-
|
|
604
|
+
const parsed = JSON.parse(rawBody);
|
|
605
|
+
if (!parsed || typeof parsed !== "object" || Array.isArray(parsed)) return null;
|
|
606
|
+
const record = parsed;
|
|
607
|
+
const paths = Array.isArray(record.paths) ? record.paths.filter(isSafePath) : [];
|
|
608
|
+
return {
|
|
609
|
+
paths: [...new Set(paths)],
|
|
610
|
+
postId: trimmedString(record.postId),
|
|
611
|
+
modelKey: trimmedString(record.modelKey)
|
|
612
|
+
};
|
|
586
613
|
} catch {
|
|
614
|
+
return null;
|
|
587
615
|
}
|
|
588
|
-
|
|
616
|
+
}
|
|
617
|
+
function isPostEvent(event) {
|
|
618
|
+
return event.startsWith("post.");
|
|
619
|
+
}
|
|
620
|
+
function modelPathMismatch(body, collections) {
|
|
621
|
+
if (!body.modelKey || !collections) return false;
|
|
622
|
+
const collection = collections.find((c) => c.key === body.modelKey);
|
|
623
|
+
if (!collection || !collection.basePath) return false;
|
|
624
|
+
const base = collection.basePath.replace(/\/+$/, "");
|
|
625
|
+
return !body.paths.some((p) => p === base || p.startsWith(`${base}/`));
|
|
589
626
|
}
|
|
590
627
|
function createRevalidateRoute(config) {
|
|
591
628
|
const blogBase = config.blogBasePath ?? "/blog";
|
|
629
|
+
const maxBodyBytes = config.maxBodyBytes ?? DEFAULT_MAX_BODY_BYTES;
|
|
592
630
|
return async function POST(req) {
|
|
631
|
+
const apiKey = config.apiKey?.trim();
|
|
632
|
+
if (!apiKey || apiKey === "local_unconfigured") {
|
|
633
|
+
return reject("service_unconfigured", 503, {});
|
|
634
|
+
}
|
|
635
|
+
const declared = Number(req.headers.get("content-length") ?? 0);
|
|
636
|
+
if (declared > maxBodyBytes) return reject("payload_too_large", 413, {});
|
|
593
637
|
const rawBody = await req.text();
|
|
638
|
+
if (new TextEncoder().encode(rawBody).byteLength > maxBodyBytes) {
|
|
639
|
+
return reject("payload_too_large", 413, {});
|
|
640
|
+
}
|
|
594
641
|
const result = await verifyRootTaleWebhook({
|
|
595
642
|
rawBody,
|
|
596
643
|
headers: req.headers,
|
|
597
|
-
apiKey
|
|
644
|
+
apiKey,
|
|
598
645
|
apiBase: config.apiBase,
|
|
599
646
|
consumeJti: config.consumeJti
|
|
600
647
|
});
|
|
601
648
|
if (!result.ok) {
|
|
602
|
-
return
|
|
649
|
+
return jsonResponse({ ok: false, reason: result.reason }, 401);
|
|
650
|
+
}
|
|
651
|
+
const logContext = { deliveryId: result.deliveryId, event: result.event };
|
|
652
|
+
const body = bodyFromRaw(rawBody);
|
|
653
|
+
if (isPostEvent(result.event)) {
|
|
654
|
+
if (!body) return reject("invalid_body", 400, logContext);
|
|
655
|
+
if (body.paths.length === 0) {
|
|
656
|
+
return reject("missing_paths", 422, { ...logContext, modelKey: body.modelKey, pathCount: 0 });
|
|
657
|
+
}
|
|
603
658
|
}
|
|
659
|
+
const parsed = body ?? { paths: [], postId: null, modelKey: null };
|
|
604
660
|
if (result.event === "theme.updated") {
|
|
605
661
|
const themeTag = config.themeTag ?? THEME_CACHE_TAG;
|
|
606
662
|
const requestedTags = [
|
|
@@ -609,7 +665,7 @@ function createRevalidateRoute(config) {
|
|
|
609
665
|
...SETTINGS_CACHE_TAGS.filter((t) => t !== THEME_CACHE_TAG)
|
|
610
666
|
])
|
|
611
667
|
];
|
|
612
|
-
const paths2 =
|
|
668
|
+
const paths2 = parsed.paths;
|
|
613
669
|
const failed = [];
|
|
614
670
|
const attempt = async (target, run) => {
|
|
615
671
|
try {
|
|
@@ -633,7 +689,7 @@ function createRevalidateRoute(config) {
|
|
|
633
689
|
for (const p of paths2) {
|
|
634
690
|
await attempt(`path:${p}`, () => config.revalidate(p));
|
|
635
691
|
}
|
|
636
|
-
return
|
|
692
|
+
return jsonResponse(
|
|
637
693
|
{
|
|
638
694
|
ok: failed.length === 0,
|
|
639
695
|
event: result.event,
|
|
@@ -650,7 +706,7 @@ function createRevalidateRoute(config) {
|
|
|
650
706
|
},
|
|
651
707
|
...failed.length > 0 ? { failed } : {}
|
|
652
708
|
},
|
|
653
|
-
|
|
709
|
+
failed.length === 0 ? 200 : 500
|
|
654
710
|
);
|
|
655
711
|
}
|
|
656
712
|
const INVARIANTS = [
|
|
@@ -666,10 +722,13 @@ function createRevalidateRoute(config) {
|
|
|
666
722
|
];
|
|
667
723
|
let alsoRevalidate;
|
|
668
724
|
let warning;
|
|
725
|
+
let knownCollections;
|
|
669
726
|
if (config.alsoRevalidate) {
|
|
670
727
|
alsoRevalidate = config.alsoRevalidate;
|
|
728
|
+
if (Array.isArray(config.collections)) knownCollections = config.collections;
|
|
671
729
|
} else {
|
|
672
730
|
const { collections, failed } = await resolveCollectionsResult(config.collections);
|
|
731
|
+
knownCollections = collections;
|
|
673
732
|
if (failed) {
|
|
674
733
|
alsoRevalidate = INVARIANTS;
|
|
675
734
|
warning = "collections_resolve_failed";
|
|
@@ -686,17 +745,54 @@ function createRevalidateRoute(config) {
|
|
|
686
745
|
alsoRevalidate = [...INVARIANTS, blogBase, `${blogBase}/categories`];
|
|
687
746
|
}
|
|
688
747
|
}
|
|
689
|
-
|
|
748
|
+
if (isPostEvent(result.event) && modelPathMismatch(parsed, knownCollections)) {
|
|
749
|
+
return reject("model_path_mismatch", 422, {
|
|
750
|
+
...logContext,
|
|
751
|
+
modelKey: parsed.modelKey,
|
|
752
|
+
pathCount: parsed.paths.length
|
|
753
|
+
});
|
|
754
|
+
}
|
|
755
|
+
let related = [];
|
|
756
|
+
if (config.relatedPaths && isPostEvent(result.event)) {
|
|
757
|
+
try {
|
|
758
|
+
related = (await config.relatedPaths({
|
|
759
|
+
event: result.event,
|
|
760
|
+
deliveryId: result.deliveryId,
|
|
761
|
+
paths: parsed.paths,
|
|
762
|
+
postId: parsed.postId,
|
|
763
|
+
modelKey: parsed.modelKey
|
|
764
|
+
})).filter(isSafePath);
|
|
765
|
+
} catch (e) {
|
|
766
|
+
console.error(
|
|
767
|
+
"[@roottale/cms-renderer-next/routes] relatedPaths \uD6C5 \uC2E4\uD328(\uBCF8\uBB38 paths \uB9CC \uAC31\uC2E0):",
|
|
768
|
+
e instanceof Error ? e.message : String(e)
|
|
769
|
+
);
|
|
770
|
+
warning = warning ?? "related_paths_failed";
|
|
771
|
+
}
|
|
772
|
+
}
|
|
773
|
+
const paths = [.../* @__PURE__ */ new Set([...parsed.paths, ...related, ...alsoRevalidate])];
|
|
690
774
|
for (const p of paths) {
|
|
691
775
|
await config.revalidate(p);
|
|
692
776
|
}
|
|
693
|
-
return
|
|
694
|
-
|
|
695
|
-
|
|
696
|
-
|
|
697
|
-
|
|
698
|
-
|
|
699
|
-
|
|
777
|
+
return jsonResponse(
|
|
778
|
+
{
|
|
779
|
+
ok: true,
|
|
780
|
+
event: result.event,
|
|
781
|
+
deliveryId: result.deliveryId,
|
|
782
|
+
revalidated: paths,
|
|
783
|
+
...warning ? { warning } : {}
|
|
784
|
+
},
|
|
785
|
+
200
|
|
786
|
+
);
|
|
787
|
+
};
|
|
788
|
+
}
|
|
789
|
+
function createRevalidateRouteHandlers(config) {
|
|
790
|
+
return {
|
|
791
|
+
POST: createRevalidateRoute(config),
|
|
792
|
+
GET: () => new Response("Method Not Allowed", {
|
|
793
|
+
status: 405,
|
|
794
|
+
headers: { allow: "POST", ...NO_STORE }
|
|
795
|
+
})
|
|
700
796
|
};
|
|
701
797
|
}
|
|
702
798
|
|
|
@@ -964,7 +1060,7 @@ function createFleetInfoRoute(config = {}) {
|
|
|
964
1060
|
site: config.site ?? env.VERCEL_PROJECT_PRODUCTION_URL ?? null,
|
|
965
1061
|
framework: "next",
|
|
966
1062
|
cms_client: CMS_CLIENT_VERSION,
|
|
967
|
-
cms_renderer: true ? "0.
|
|
1063
|
+
cms_renderer: true ? "0.65.0" : "dev",
|
|
968
1064
|
build_sha: env.VERCEL_GIT_COMMIT_SHA?.slice(0, 7) ?? null,
|
|
969
1065
|
...config.exposures ? { exposures: config.exposures } : {}
|
|
970
1066
|
},
|
|
@@ -987,6 +1083,7 @@ export {
|
|
|
987
1083
|
createPostOgImage,
|
|
988
1084
|
createRedirectMiddleware,
|
|
989
1085
|
createRevalidateRoute,
|
|
1086
|
+
createRevalidateRouteHandlers,
|
|
990
1087
|
createSitemap,
|
|
991
1088
|
createSitemapIndex,
|
|
992
1089
|
decideArchiveIndex,
|