@nine-lab/nine-mu 0.1.347 → 0.1.348

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@nine-lab/nine-mu",
3
- "version": "0.1.347",
3
+ "version": "0.1.348",
4
4
  "description": "AI-Driven Full-Stack Code Fabrication Engine",
5
5
  "type": "module",
6
6
  "main": "./dist/nine-mu.umd.js",
@@ -1,25 +1,85 @@
1
1
  import React from 'react';
2
2
 
3
+ // ==========================================
4
+ // 1. 외부에서 수정 및 관리가 용이하도록 CSS 분리
5
+ // ==========================================
6
+ export const NineExceptionStyles = {
7
+ container: {
8
+ padding: '30px',
9
+ margin: '20px',
10
+ background: '#FFF5F5',
11
+ border: '1px solid #FEB2B2',
12
+ borderRadius: '8px',
13
+ fontFamily: 'sans-serif',
14
+ textAlign: 'left'
15
+ },
16
+ title: {
17
+ color: '#C53030',
18
+ marginTop: 0,
19
+ fontSize: '18px',
20
+ display: 'flex',
21
+ alignItems: 'center',
22
+ gap: '8px'
23
+ },
24
+ label: {
25
+ margin: '10px 0 5px 0',
26
+ fontWeight: 'bold',
27
+ color: '#4A5568'
28
+ },
29
+ pre: {
30
+ background: '#1A202C',
31
+ color: '#EDF2F7',
32
+ padding: '15px',
33
+ borderRadius: '6px',
34
+ overflowX: 'auto',
35
+ whiteSpace: 'pre-wrap',
36
+ fontFamily: 'monospace',
37
+ fontSize: '14px'
38
+ },
39
+ footer: {
40
+ marginTop: '15px',
41
+ fontSize: '14px',
42
+ color: '#718096',
43
+ display: 'flex',
44
+ flexDirection: 'column',
45
+ gap: '10px'
46
+ },
47
+ button: {
48
+ padding: '10px 16px',
49
+ background: '#E53E3E',
50
+ color: '#FFFFFF',
51
+ border: 'none',
52
+ borderRadius: '6px',
53
+ cursor: 'pointer',
54
+ fontWeight: 'bold',
55
+ fontSize: '14px',
56
+ alignSelf: 'flex-start',
57
+ transition: 'background 0.2s',
58
+ }
59
+ };
60
+
61
+ // ==========================================
62
+ // 2. 컴포넌트 본문
63
+ // ==========================================
3
64
  export class NineExceptionHook extends React.Component {
4
65
 
5
66
  constructor(props) {
6
67
  super(props);
7
- this.state = { hasError: false, error: null };
68
+ // 관제탑 전송 상태 관리를 위해 정송 단계(idle, sending, success) 추가
69
+ this.state = { hasError: false, error: null, reportStatus: 'idle' };
8
70
  this.lastPath = window.location.pathname;
9
71
  this.handleLocationChange = this.handleLocationChange.bind(this);
72
+ this.handleReport = this.handleReport.bind(this);
10
73
  }
11
74
 
12
75
  static getDerivedStateFromError(error) {
13
- return { hasError: true, error };
76
+ return { hasError: true, error, reportStatus: 'idle' };
14
77
  }
15
78
 
16
79
  componentDidCatch(error, errorInfo) {
17
80
  console.error("🚨 [Nine-Library] 본문 렌더링 에러 포착:", error);
18
81
 
19
- if (window.triggerAutoRecovery) {
20
- window.triggerAutoRecovery(error.message || String(error));
21
- }
22
-
82
+ // 자동 복구 엔진 호출 제거 (버튼 클릭 시 처리로 이관)
23
83
  if (this.props.onCatch) {
24
84
  this.props.onCatch(error, errorInfo);
25
85
  }
@@ -40,11 +100,28 @@ export class NineExceptionHook extends React.Component {
40
100
  if (this.state.hasError && this.lastPath !== window.location.pathname) {
41
101
  console.log("✨ [Nine-Library] 페이지 주소 변경 감지 -> 리액트 에러 상태 초기화");
42
102
  this.lastPath = window.location.pathname;
43
- this.setState({ hasError: false, error: null });
103
+ this.setState({ hasError: false, error: null, reportStatus: 'idle' });
44
104
  }
45
105
  }, 10);
46
106
  }
47
107
 
108
+ // 🚀 버튼 클릭 시 실행될 관제탑 수동 신고 핸들러
109
+ handleReport() {
110
+ if (this.state.reportStatus !== 'idle') return;
111
+
112
+ this.setState({ reportStatus: 'sending' });
113
+ const errorMessage = this.state.error?.message || String(this.state.error);
114
+
115
+ setTimeout(() => {
116
+ if (window.triggerAutoRecovery) {
117
+ window.triggerAutoRecovery(errorMessage);
118
+ } else {
119
+ console.warn("⚠️ [Nine-Library] window.triggerAutoRecovery 가 정의되지 않았습니다.");
120
+ }
121
+ this.setState({ reportStatus: 'success' });
122
+ }, 500); // 사용자 경험(UX) 피드백용 0.5초 딜레이
123
+ }
124
+
48
125
  render() {
49
126
  if (this.state.hasError) {
50
127
  if (this.props.fallback) {
@@ -52,36 +129,46 @@ export class NineExceptionHook extends React.Component {
52
129
  }
53
130
 
54
131
  const errorMessage = this.state.error?.message || String(this.state.error);
132
+ const customStyles = this.props.styles || {}; // props로 스타일 통째로 덮어쓰기 지원
133
+
134
+ // 버튼 텍스트 상태 제어
135
+ let buttonText = '🚀 관제탑에 에러 피드백 전송하기';
136
+ if (this.state.reportStatus === 'sending') buttonText = '⏳ 관제탑 연락 중...';
137
+ if (this.state.reportStatus === 'success') buttonText = '✅ 전송 완료! AI가 분석을 시작합니다.';
55
138
 
56
- // ⭐ Vite 빌드 통과를 위해 순수 자바스크립트 함수(React.createElement)로 변경
57
139
  return React.createElement(
58
140
  'div',
59
141
  {
60
- style: {
61
- padding: '30px',
62
- margin: '20px',
63
- background: '#FFF5F5',
64
- border: '1px solid #FEB2B2',
65
- borderRadius: '8px',
66
- fontFamily: 'sans-serif',
67
- textAlign: 'left',
68
- ...this.props.containerStyle
69
- }
142
+ style: { ...NineExceptionStyles.container, ...customStyles.container, ...this.props.containerStyle }
70
143
  },
71
- React.createElement('h3', { style: { color: '#C53030', marginTop: 0, fontSize: '18px' } }, '⚠️ 컴포넌트 빌드/렌더링 에러 감지'),
72
- React.createElement('p', { style: { margin: '10px 0 5px 0', fontWeight: 'bold', color: '#4A5568' } }, '[에러 원인 로그]:'),
73
- React.createElement('pre', {
74
- style: {
75
- background: '#1A202C',
76
- color: '#EDF2F7',
77
- padding: '15px',
78
- borderRadius: '6px',
79
- overflowX: 'auto',
80
- whiteSpace: 'pre-wrap',
81
- fontFamily: 'monospace'
82
- }
83
- }, errorMessage),
84
- React.createElement('div', { style: { marginTop: '15px', fontSize: '14px', color: '#718096' } }, '🔄 에러 로그가 관제탑으로 자동 피드백되었습니다. AI가 소스 코드를 재수정하는 동안 잠시만 기다려주세요...')
144
+ React.createElement('h3', { style: { ...NineExceptionStyles.title, ...customStyles.title } }, '⚠️ 컴포넌트 빌드/렌더링 에러 감지'),
145
+ React.createElement('p', { style: { ...NineExceptionStyles.label, ...customStyles.label } }, '[에러 원인 로그]:'),
146
+ React.createElement('pre', { style: { ...NineExceptionStyles.pre, ...customStyles.pre } }, errorMessage),
147
+
148
+ // 하단 안내 영역 및 수동 전송 버튼
149
+ React.createElement(
150
+ 'div',
151
+ { style: { ...NineExceptionStyles.footer, ...customStyles.footer } },
152
+ React.createElement(
153
+ 'button',
154
+ {
155
+ style: {
156
+ ...NineExceptionStyles.button,
157
+ ...customStyles.button,
158
+ backgroundColor: this.state.reportStatus === 'success' ? '#38A169' : (this.state.reportStatus === 'sending' ? '#A0AEC0' : '#E53E3E'),
159
+ cursor: this.state.reportStatus === 'idle' ? 'pointer' : 'not-allowed'
160
+ },
161
+ disabled: this.state.reportStatus !== 'idle',
162
+ onClick: this.handleReport
163
+ },
164
+ buttonText
165
+ ),
166
+ this.state.reportStatus === 'success' && React.createElement(
167
+ 'div',
168
+ { style: { color: '#4A5568', fontSize: '13px', marginTop: '5px' } },
169
+ '🔄 AI가 소스 코드를 재수정하는 동안 잠시만 기다려주세요...'
170
+ )
171
+ )
85
172
  );
86
173
  }
87
174