"use client"; import React, { useEffect, useState } from "react"; import { initializeRegistries } from "@/lib/registry/init"; import { initV2Core, cleanupV2Core } from "@/lib/v2-core"; interface RegistryProviderProps { children: React.ReactNode; } /** * 레지스트리 초기화 프로바이더 * 앱 시작 시 모든 웹타입과 버튼 액션을 등록합니다. */ export function RegistryProvider({ children }: RegistryProviderProps) { const [isInitialized, setIsInitialized] = useState(false); useEffect(() => { // 레지스트리 초기화 try { initializeRegistries(); // V2 Core 초기화 (느슨한 결합 아키텍처) initV2Core({ debug: false, legacyBridge: { legacyToV2: true, v2ToLegacy: true, }, }); setIsInitialized(true); } catch (error) { console.error("❌ 레지스트리 초기화 실패:", error); setIsInitialized(true); // 오류가 있어도 앱은 계속 실행 } // 정리 함수 return () => { cleanupV2Core(); }; }, []); // 초기화 중 로딩 표시 (선택사항) // if (!isInitialized) { // return ( //
//
//
//

시스템 초기화 중...

//
//
// ); // } return <>{children}; } /** * 레지스트리 초기화 상태를 확인하는 훅 */ export function useRegistryInitialization() { const [isInitialized, setIsInitialized] = useState(false); const [error, setError] = useState(null); useEffect(() => { try { initializeRegistries(); setIsInitialized(true); } catch (err) { setError(err as Error); setIsInitialized(true); } }, []); return { isInitialized, error }; }