@nine-lab/nine-mu 0.1.345 โ 0.1.347
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/dist/nine-mu.js +80 -190
- package/dist/nine-mu.js.map +1 -1
- package/dist/nine-mu.umd.js +3 -3
- package/dist/nine-mu.umd.js.map +1 -1
- package/package.json +2 -1
- package/src/components/exception/ExceptionHook.js +67 -186
- package/src/index.js +2 -2
- package/vite.config.js +5 -1
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@nine-lab/nine-mu",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.347",
|
|
4
4
|
"description": "AI-Driven Full-Stack Code Fabrication Engine",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./dist/nine-mu.umd.js",
|
|
@@ -25,6 +25,7 @@
|
|
|
25
25
|
"@nine-lab/nine-nomenu": "*",
|
|
26
26
|
"@nine-lab/nine-util": "^0.9.126",
|
|
27
27
|
"@nine-lab/nine-ux": "^0.1.244",
|
|
28
|
+
"@vitejs/plugin-react": "^6.0.2",
|
|
28
29
|
"terser": "^5.31.0",
|
|
29
30
|
"vite": "^6.0.0"
|
|
30
31
|
},
|
|
@@ -1,211 +1,92 @@
|
|
|
1
|
-
|
|
2
|
-
import { nine } from '@nine-lab/nine-util';
|
|
3
|
-
import { trace } from '@nopeer';
|
|
1
|
+
import React from 'react';
|
|
4
2
|
|
|
5
|
-
export class
|
|
6
|
-
#lastPath = window.location.pathname;
|
|
7
|
-
#hasError = false;
|
|
8
|
-
#cssPath = "/css/nine-exception-hook.css";
|
|
9
|
-
#oldOnError = null;
|
|
3
|
+
export class NineExceptionHook extends React.Component {
|
|
10
4
|
|
|
11
|
-
constructor() {
|
|
12
|
-
super();
|
|
13
|
-
this.
|
|
5
|
+
constructor(props) {
|
|
6
|
+
super(props);
|
|
7
|
+
this.state = { hasError: false, error: null };
|
|
8
|
+
this.lastPath = window.location.pathname;
|
|
9
|
+
this.handleLocationChange = this.handleLocationChange.bind(this);
|
|
14
10
|
}
|
|
15
11
|
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
this.#injectShadowStylesheet();
|
|
19
|
-
this.#setupGlobalSniffer();
|
|
20
|
-
|
|
21
|
-
window.addEventListener('unhandledrejection', this.#handlePromiseError, true);
|
|
22
|
-
window.addEventListener('popstate', this.#handleLocationChange);
|
|
23
|
-
document.addEventListener('click', this.#handleLocationChange, true);
|
|
12
|
+
static getDerivedStateFromError(error) {
|
|
13
|
+
return { hasError: true, error };
|
|
24
14
|
}
|
|
25
15
|
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
window.removeEventListener('unhandledrejection', this.#handlePromiseError, true);
|
|
29
|
-
window.removeEventListener('popstate', this.#handleLocationChange);
|
|
30
|
-
document.removeEventListener('click', this.#handleLocationChange, true);
|
|
16
|
+
componentDidCatch(error, errorInfo) {
|
|
17
|
+
console.error("๐จ [Nine-Library] ๋ณธ๋ฌธ ๋ ๋๋ง ์๋ฌ ํฌ์ฐฉ:", error);
|
|
31
18
|
|
|
32
|
-
if (window.
|
|
33
|
-
window.
|
|
19
|
+
if (window.triggerAutoRecovery) {
|
|
20
|
+
window.triggerAutoRecovery(error.message || String(error));
|
|
34
21
|
}
|
|
35
|
-
}
|
|
36
|
-
|
|
37
|
-
#setupGlobalSniffer() {
|
|
38
|
-
window.addEventListener('error', this.#handleRuntimeError, true);
|
|
39
|
-
|
|
40
|
-
this.#oldOnError = window.onerror;
|
|
41
|
-
window.onerror = (message, source, lineno, colno, error) => {
|
|
42
|
-
if (!this.#hasError) {
|
|
43
|
-
const errorMessage = error?.message || message || "์ ์ ์๋ ๋ฐํ์ ์์ธ";
|
|
44
|
-
const errorStack = error?.stack || `${source}:${lineno}:${colno}`;
|
|
45
|
-
this.#renderError(errorMessage, errorStack);
|
|
46
|
-
}
|
|
47
|
-
if (this.#oldOnError) {
|
|
48
|
-
return this.#oldOnError(message, source, lineno, colno, error);
|
|
49
|
-
}
|
|
50
|
-
return false;
|
|
51
|
-
};
|
|
52
|
-
}
|
|
53
|
-
|
|
54
|
-
#renderer = () => {
|
|
55
|
-
const customImport = nine.cssPath ? `@import "${nine.cssPath}/nine-mu.css";` : "";
|
|
56
|
-
|
|
57
|
-
// ๐ฏ [ํต์ฌ ๋ณ๊ฒฝ 1] :host ์์ฒด๋ฅผ absolute์ ๊ธฐ์ค์ ์ด ๋๋ block์ผ๋ก ์ก๊ณ ,
|
|
58
|
-
// ๋ฆฌ์กํธ ์ฌ๋กฏ ๋ด์ฉ๋ฌผ(๋ฉ๋ด ๋ฑ)์ ์ ๋ ์จ๊ธฐ์ง ์๊ณ 100% ํฌ๊ธฐ๋ก ์ ์งํฉ๋๋ค.
|
|
59
|
-
this.shadowRoot.innerHTML = `
|
|
60
|
-
<style>
|
|
61
|
-
@import "https://cdn.jsdelivr.net/npm/@nine-lab/nine-mu@${__APP_VERSION__}/dist/css/nine-mu.css";
|
|
62
|
-
${customImport}
|
|
63
|
-
|
|
64
|
-
:host {
|
|
65
|
-
display: block;
|
|
66
|
-
width: 100%;
|
|
67
|
-
height: 100%;
|
|
68
|
-
position: relative !important; /* ๋ด๋ถ ์๋ฌ ๋ณด๋์ ๊ธฐ์ค์ ๊ธฐ๋ฅ ์์ฑ */
|
|
69
|
-
}
|
|
70
|
-
|
|
71
|
-
.nine-hook-core {
|
|
72
|
-
width: 100%;
|
|
73
|
-
height: 100%;
|
|
74
|
-
}
|
|
75
|
-
|
|
76
|
-
/* ๐ฏ [ํต์ฌ ๋ณ๊ฒฝ 2] ๋ฆฌ์กํธ ์ฌ๋กฏ์ ๊ฐ๋ฆฌ์ง ์๊ณ , ์ค์ง "์ด ์ปดํฌ๋ํธ ๊ตฌ์ญ"๋ง ๊ฐ๋ ์ฑ์ฐ๋ ๋
๋ฆฝ ํ์
๋ ์ด์ด */
|
|
77
|
-
.nine-hook-inner-cover {
|
|
78
|
-
position: absolute !important;
|
|
79
|
-
top: 0 !important;
|
|
80
|
-
left: 0 !important;
|
|
81
|
-
width: 100% !important;
|
|
82
|
-
height: 100% !important;
|
|
83
|
-
box-sizing: border-box !important;
|
|
84
|
-
background-color: #FFF5F5 !important;
|
|
85
|
-
z-index: 2147483647 !important; /* ๋ฆฌ์กํธ ๋ด๋ถ ๊ทธ ์ด๋ค ์ค๋ฒ๋ ์ด๋ณด๋ค ๋ฌด์กฐ๊ฑด ์ */
|
|
86
|
-
overflow: auto !important;
|
|
87
|
-
display: none; /* ํ์์ ์จ๊น */
|
|
88
|
-
}
|
|
89
|
-
</style>
|
|
90
|
-
|
|
91
|
-
<div class="nine-hook-core">
|
|
92
|
-
<slot></slot>
|
|
93
|
-
</div>
|
|
94
|
-
<div class="nine-exception-board class-target-board"></div>
|
|
95
|
-
`;
|
|
96
|
-
}
|
|
97
|
-
|
|
98
|
-
#injectShadowStylesheet() {
|
|
99
|
-
if (this.shadowRoot.querySelector(`link[href="${this.#cssPath}"]`)) return;
|
|
100
|
-
|
|
101
|
-
const link = document.createElement('link');
|
|
102
|
-
link.rel = 'stylesheet';
|
|
103
|
-
link.href = this.#cssPath;
|
|
104
|
-
this.shadowRoot.appendChild(link);
|
|
105
|
-
}
|
|
106
|
-
|
|
107
|
-
#handleRuntimeError = (event) => {
|
|
108
|
-
if (this.#hasError) return;
|
|
109
|
-
|
|
110
|
-
const errorMessage = event.error?.message || event.message || String(event);
|
|
111
|
-
const errorStack = event.error?.stack || "No stack trace available";
|
|
112
22
|
|
|
113
|
-
if (
|
|
114
|
-
this
|
|
23
|
+
if (this.props.onCatch) {
|
|
24
|
+
this.props.onCatch(error, errorInfo);
|
|
115
25
|
}
|
|
116
26
|
}
|
|
117
27
|
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
const errorMessage = reason?.message || String(reason || "Unhandled Promise Rejection");
|
|
123
|
-
const errorStack = reason?.stack || "No stack trace available";
|
|
28
|
+
componentDidMount() {
|
|
29
|
+
window.addEventListener('popstate', this.handleLocationChange);
|
|
30
|
+
document.addEventListener('click', this.handleLocationChange, true);
|
|
31
|
+
}
|
|
124
32
|
|
|
125
|
-
|
|
33
|
+
componentWillUnmount() {
|
|
34
|
+
window.removeEventListener('popstate', this.handleLocationChange);
|
|
35
|
+
document.removeEventListener('click', this.handleLocationChange, true);
|
|
126
36
|
}
|
|
127
37
|
|
|
128
|
-
|
|
38
|
+
handleLocationChange() {
|
|
129
39
|
setTimeout(() => {
|
|
130
|
-
if (this
|
|
131
|
-
|
|
132
|
-
this
|
|
133
|
-
|
|
134
|
-
const exceptionBoard = this.shadowRoot.querySelector('.nine-exception-board');
|
|
135
|
-
if (exceptionBoard) {
|
|
136
|
-
exceptionBoard.innerHTML = '';
|
|
137
|
-
exceptionBoard.className = 'nine-exception-board'; // ํด๋์ค ๋ฆฌ์
|
|
138
|
-
}
|
|
40
|
+
if (this.state.hasError && this.lastPath !== window.location.pathname) {
|
|
41
|
+
console.log("โจ [Nine-Library] ํ์ด์ง ์ฃผ์ ๋ณ๊ฒฝ ๊ฐ์ง -> ๋ฆฌ์กํธ ์๋ฌ ์ํ ์ด๊ธฐํ");
|
|
42
|
+
this.lastPath = window.location.pathname;
|
|
43
|
+
this.setState({ hasError: false, error: null });
|
|
139
44
|
}
|
|
140
|
-
},
|
|
45
|
+
}, 10);
|
|
141
46
|
}
|
|
142
47
|
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
btn.disabled = true;
|
|
149
|
-
btn.innerText = "โก AI ๊ด์ ํ์ ์์ค ๋ถ์ ์์ฒญ ์ค...";
|
|
150
|
-
btn.classList.add('loading');
|
|
151
|
-
|
|
152
|
-
try {
|
|
153
|
-
if (window.triggerAutoRecovery) {
|
|
154
|
-
await window.triggerAutoRecovery({
|
|
155
|
-
message: errorMessage,
|
|
156
|
-
stack: errorStack || "No stack trace available",
|
|
157
|
-
path: window.location.pathname
|
|
158
|
-
});
|
|
159
|
-
|
|
160
|
-
footer.innerHTML = `โ
<b>AI ๊ด์ ํ ์ ์ ์๋ฃ:</b> ๋ถ์์ ๋ฐํ์ผ๋ก ์์ค ์ฝ๋๋ฅผ ๊ต์ ํ๊ณ ์์ต๋๋ค. ์ ์๋ง ๊ธฐ๋ค๋ ค์ฃผ์ธ์.`;
|
|
161
|
-
btn.innerText = "๐ ์ ์ก ์๋ฃ";
|
|
162
|
-
} else {
|
|
163
|
-
throw new Error("window.triggerAutoRecovery ๊ด์ ํ ์์ง์ด ๋ก๋๋์ง ์์์ต๋๋ค.");
|
|
48
|
+
render() {
|
|
49
|
+
if (this.state.hasError) {
|
|
50
|
+
if (this.props.fallback) {
|
|
51
|
+
return this.props.fallback(this.state.error);
|
|
164
52
|
}
|
|
165
|
-
} catch (err) {
|
|
166
|
-
btn.disabled = false;
|
|
167
|
-
btn.innerText = "โ ์ฌ์ ์ก ์๋";
|
|
168
|
-
footer.innerHTML = `<span style="color: #E53E3E;">โ ๏ธ ์ ์ก ์คํจ: ${err.message}</span>`;
|
|
169
|
-
}
|
|
170
|
-
}
|
|
171
53
|
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
54
|
+
const errorMessage = this.state.error?.message || String(this.state.error);
|
|
55
|
+
|
|
56
|
+
// โญ Vite ๋น๋ ํต๊ณผ๋ฅผ ์ํด ์์ ์๋ฐ์คํฌ๋ฆฝํธ ํจ์(React.createElement)๋ก ๋ณ๊ฒฝ
|
|
57
|
+
return React.createElement(
|
|
58
|
+
'div',
|
|
59
|
+
{
|
|
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
|
+
}
|
|
70
|
+
},
|
|
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๊ฐ ์์ค ์ฝ๋๋ฅผ ์ฌ์์ ํ๋ ๋์ ์ ์๋ง ๊ธฐ๋ค๋ ค์ฃผ์ธ์...')
|
|
85
|
+
);
|
|
86
|
+
}
|
|
200
87
|
|
|
201
|
-
|
|
202
|
-
if (aiBtn) {
|
|
203
|
-
aiBtn.addEventListener('click', () => this.#sendToAiAction(errorMessage, errorStack));
|
|
204
|
-
}
|
|
205
|
-
}, 0);
|
|
88
|
+
return this.props.children;
|
|
206
89
|
}
|
|
207
90
|
}
|
|
208
91
|
|
|
209
|
-
|
|
210
|
-
customElements.define('nine-exception-hook', ExceptionHook);
|
|
211
|
-
}
|
|
92
|
+
export default NineExceptionHook;
|
package/src/index.js
CHANGED
|
@@ -4,7 +4,7 @@ import { NineDiff } from './components/NineDiff.js';
|
|
|
4
4
|
import { NineDiffPopup } from './components/NineDiffPopup.js';
|
|
5
5
|
import { NineMenuDiffPopup } from './components/NineMenuDiffPopup.js';
|
|
6
6
|
import './components/ChatMessage.js';
|
|
7
|
-
import './components/exception/ExceptionHook.js';
|
|
7
|
+
import { NineExceptionHook } from './components/exception/ExceptionHook.js';
|
|
8
8
|
|
|
9
9
|
/**
|
|
10
10
|
* Nine-Mu ์์ง ๋ฉ์ธ ํด๋์ค
|
|
@@ -20,4 +20,4 @@ export const NineMu = {
|
|
|
20
20
|
|
|
21
21
|
// ๊ธฐ๋ณธ export ๋ฐ ์ปดํฌ๋ํธ export
|
|
22
22
|
export default NineMu;
|
|
23
|
-
export { NineChat, NineDiff, NineDiffPopup };
|
|
23
|
+
export { NineChat, NineDiff, NineDiffPopup, NineExceptionHook };
|
package/vite.config.js
CHANGED
|
@@ -19,7 +19,7 @@ export default defineConfig({
|
|
|
19
19
|
formats: ['es', 'umd']
|
|
20
20
|
},
|
|
21
21
|
rollupOptions: {
|
|
22
|
-
external: ['@nine-lab/nine-ai', '@nine-lab/nine-util', '@nine-lab/nine-ux'],
|
|
22
|
+
external: ['@nine-lab/nine-ai', '@nine-lab/nine-util', '@nine-lab/nine-ux', 'react', 'react-dom'],
|
|
23
23
|
output: {
|
|
24
24
|
globals: {
|
|
25
25
|
'@nine-lab/nine-ai': 'NineAi',
|
|
@@ -31,5 +31,9 @@ export default defineConfig({
|
|
|
31
31
|
minify: 'terser',
|
|
32
32
|
sourcemap: true,
|
|
33
33
|
emptyOutDir: true
|
|
34
|
+
},
|
|
35
|
+
esbuild: {
|
|
36
|
+
loader: 'jsx',
|
|
37
|
+
include: /src\/.*\.js$/, // src ํด๋ ๋ด์ ๋ชจ๋ .js ํ์ผ์ ๋์์ผ๋ก ์ง์
|
|
34
38
|
}
|
|
35
39
|
});
|