1- // 개발 환경 감지 유틸리티
21export const isDevelopment = ( ) => {
32 try {
4- return import . meta. env ?. MODE === 'development' ||
5- import . meta. env ?. DEV === true ||
6- window . location . hostname === 'localhost' ||
7- window . location . hostname === '127.0.0.1' ||
8- window . location . port !== '' ;
3+ if ( import . meta. env ?. MODE === 'development' || import . meta. env ?. DEV === true ) {
4+ return true ;
5+ }
6+
7+ if ( typeof window !== 'undefined' ) {
8+ const hostname = window . location . hostname ;
9+ return hostname === 'localhost' ||
10+ hostname === '127.0.0.1' ||
11+ hostname . startsWith ( '192.168.' ) ||
12+ hostname . startsWith ( '10.' ) ||
13+ window . location . port !== '' ;
14+ }
15+
16+ return false ;
917 } catch {
1018 return false ;
1119 }
1220} ;
1321
14- // 프로덕션 환경 감지
1522export const isProduction = ( ) => {
1623 try {
17- return import . meta. env ?. MODE === 'production' &&
18- import . meta. env ?. PROD === true ;
24+ if ( import . meta. env ?. MODE === 'production' || import . meta. env ?. PROD === true ) {
25+ return true ;
26+ }
27+
28+ return ! isDevelopment ( ) ;
1929 } catch {
20- return false ;
30+ return true ;
2131 }
2232} ;
2333
24- // GitHub Pages 환경 감지
2534export const isGitHubPages = ( ) => {
2635 try {
2736 return window . location . hostname . includes ( 'github.io' ) ;
@@ -30,7 +39,6 @@ export const isGitHubPages = () => {
3039 }
3140} ;
3241
33- // 광고 차단기 감지
3442export const isAdBlockerActive = async ( ) : Promise < boolean > => {
3543 try {
3644 const testAd = document . createElement ( 'div' ) ;
@@ -53,8 +61,6 @@ export const isAdBlockerActive = async (): Promise<boolean> => {
5361 return false ;
5462 }
5563} ;
56-
57- // 스크립트 로딩 상태 관리
5864class ScriptLoader {
5965 private static loadedScripts = new Set < string > ( ) ;
6066
@@ -66,7 +72,6 @@ class ScriptLoader {
6672 timeout ?: number ;
6773 } = { } ) : Promise < boolean > {
6874 return new Promise ( ( resolve ) => {
69- // 이미 로드된 스크립트는 다시 로드하지 않음
7075 if ( this . loadedScripts . has ( src ) ) {
7176 resolve ( true ) ;
7277 return ;
@@ -101,7 +106,6 @@ class ScriptLoader {
101106 resolve ( false ) ;
102107 } ;
103108
104- // 타임아웃 설정 (기본 10초)
105109 if ( options . timeout ) {
106110 timeoutId = window . setTimeout ( ( ) => {
107111 options . onError ?.( new Error ( 'Script loading timeout' ) ) ;
@@ -124,7 +128,6 @@ class ScriptLoader {
124128
125129export { ScriptLoader } ;
126130
127- // 안전한 console 로깅
128131export const safeLog = {
129132 info : ( message : string , ...args : any [ ] ) => {
130133 if ( ! isProduction ( ) ) {
0 commit comments