@nine-lab/nine-mu 0.1.343 โ 0.1.345
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 +40 -72
- package/dist/nine-mu.js.map +1 -1
- package/dist/nine-mu.umd.js +1 -1
- package/dist/nine-mu.umd.js.map +1 -1
- package/package.json +1 -1
- package/src/components/exception/ExceptionHook.js +39 -77
package/package.json
CHANGED
|
@@ -11,14 +11,11 @@ export class ExceptionHook extends HTMLElement {
|
|
|
11
11
|
constructor() {
|
|
12
12
|
super();
|
|
13
13
|
this.attachShadow({ mode: 'open' });
|
|
14
|
-
trace.log("๐ [nine-exception-hook] ์ธ์คํด์ค ์์ฑ๋จ");
|
|
15
14
|
}
|
|
16
15
|
|
|
17
16
|
connectedCallback() {
|
|
18
|
-
trace.log("๐ [nine-exception-hook] DOM์ ๋ง์ดํธ๋จ. ์ด๋ฒคํธ ๋ฆฌ์ค๋ ๋ฐ์ธ๋ฉ ์์");
|
|
19
17
|
this.#renderer();
|
|
20
18
|
this.#injectShadowStylesheet();
|
|
21
|
-
|
|
22
19
|
this.#setupGlobalSniffer();
|
|
23
20
|
|
|
24
21
|
window.addEventListener('unhandledrejection', this.#handlePromiseError, true);
|
|
@@ -27,7 +24,6 @@ export class ExceptionHook extends HTMLElement {
|
|
|
27
24
|
}
|
|
28
25
|
|
|
29
26
|
disconnectedCallback() {
|
|
30
|
-
trace.log("๐ [nine-exception-hook] DOM์์ ์ธ๋ง์ดํธ๋จ. ๋ฆฌ์ค๋ ํด์ ");
|
|
31
27
|
window.removeEventListener('error', this.#handleRuntimeError, true);
|
|
32
28
|
window.removeEventListener('unhandledrejection', this.#handlePromiseError, true);
|
|
33
29
|
window.removeEventListener('popstate', this.#handleLocationChange);
|
|
@@ -35,40 +31,31 @@ export class ExceptionHook extends HTMLElement {
|
|
|
35
31
|
|
|
36
32
|
if (window.onerror === this.#handleRuntimeError || this.#oldOnError) {
|
|
37
33
|
window.onerror = this.#oldOnError;
|
|
38
|
-
trace.log("๐ [nine-exception-hook] window.onerror ๋ณต๊ตฌ ์๋ฃ");
|
|
39
34
|
}
|
|
40
35
|
}
|
|
41
36
|
|
|
42
37
|
#setupGlobalSniffer() {
|
|
43
38
|
window.addEventListener('error', this.#handleRuntimeError, true);
|
|
44
|
-
trace.log("๐ [nine-exception-hook] window.addEventListener('error') ๋ฑ๋ก ์๋ฃ");
|
|
45
39
|
|
|
46
40
|
this.#oldOnError = window.onerror;
|
|
47
41
|
window.onerror = (message, source, lineno, colno, error) => {
|
|
48
|
-
trace.log("๐จ [nine-exception-hook] ์์ window.onerror ํฌ์ฐฉ!!", { message, source, lineno, error });
|
|
49
|
-
|
|
50
42
|
if (!this.#hasError) {
|
|
51
|
-
trace.log("๐ฏ [nine-exception-hook] ํ์ฌ ์๋ฌ ์ํ ์์ -> ์๋ฌ ๋ณด๋ ์ถ๋ ฅ ์๋");
|
|
52
43
|
const errorMessage = error?.message || message || "์ ์ ์๋ ๋ฐํ์ ์์ธ";
|
|
53
44
|
const errorStack = error?.stack || `${source}:${lineno}:${colno}`;
|
|
54
45
|
this.#renderError(errorMessage, errorStack);
|
|
55
|
-
} else {
|
|
56
|
-
trace.log("โ ๏ธ [nine-exception-hook] ์ด๋ฏธ ์๋ฌ ํ๋ฉด์ด ํ์ฑํ๋์ด ์์ด ์์ onerror ํจ์ค");
|
|
57
46
|
}
|
|
58
|
-
|
|
59
47
|
if (this.#oldOnError) {
|
|
60
|
-
trace.log("๐ [nine-exception-hook] ๊ธฐ์กด์ ๋ฑ๋ก๋์ด ์๋ ๋ค๋ฅธ onerror ์์ง์ผ๋ก ์์");
|
|
61
48
|
return this.#oldOnError(message, source, lineno, colno, error);
|
|
62
49
|
}
|
|
63
50
|
return false;
|
|
64
51
|
};
|
|
65
|
-
trace.log("๐ [nine-exception-hook] ์์ window.onerror ๊ฐ๋ก์ฑ๊ธฐ(Chaining) ์๋ฃ");
|
|
66
52
|
}
|
|
67
53
|
|
|
68
54
|
#renderer = () => {
|
|
69
55
|
const customImport = nine.cssPath ? `@import "${nine.cssPath}/nine-mu.css";` : "";
|
|
70
56
|
|
|
71
|
-
// ๐ฏ [
|
|
57
|
+
// ๐ฏ [ํต์ฌ ๋ณ๊ฒฝ 1] :host ์์ฒด๋ฅผ absolute์ ๊ธฐ์ค์ ์ด ๋๋ block์ผ๋ก ์ก๊ณ ,
|
|
58
|
+
// ๋ฆฌ์กํธ ์ฌ๋กฏ ๋ด์ฉ๋ฌผ(๋ฉ๋ด ๋ฑ)์ ์ ๋ ์จ๊ธฐ์ง ์๊ณ 100% ํฌ๊ธฐ๋ก ์ ์งํฉ๋๋ค.
|
|
72
59
|
this.shadowRoot.innerHTML = `
|
|
73
60
|
<style>
|
|
74
61
|
@import "https://cdn.jsdelivr.net/npm/@nine-lab/nine-mu@${__APP_VERSION__}/dist/css/nine-mu.css";
|
|
@@ -78,25 +65,33 @@ export class ExceptionHook extends HTMLElement {
|
|
|
78
65
|
display: block;
|
|
79
66
|
width: 100%;
|
|
80
67
|
height: 100%;
|
|
68
|
+
position: relative !important; /* ๋ด๋ถ ์๋ฌ ๋ณด๋์ ๊ธฐ์ค์ ๊ธฐ๋ฅ ์์ฑ */
|
|
81
69
|
}
|
|
82
|
-
|
|
83
|
-
.nine-hook-
|
|
84
|
-
|
|
70
|
+
|
|
71
|
+
.nine-hook-core {
|
|
72
|
+
width: 100%;
|
|
73
|
+
height: 100%;
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
/* ๐ฏ [ํต์ฌ ๋ณ๊ฒฝ 2] ๋ฆฌ์กํธ ์ฌ๋กฏ์ ๊ฐ๋ฆฌ์ง ์๊ณ , ์ค์ง "์ด ์ปดํฌ๋ํธ ๊ตฌ์ญ"๋ง ๊ฐ๋ ์ฑ์ฐ๋ ๋
๋ฆฝ ํ์
๋ ์ด์ด */
|
|
77
|
+
.nine-hook-inner-cover {
|
|
78
|
+
position: absolute !important;
|
|
85
79
|
top: 0 !important;
|
|
86
80
|
left: 0 !important;
|
|
87
|
-
width:
|
|
88
|
-
height:
|
|
81
|
+
width: 100% !important;
|
|
82
|
+
height: 100% !important;
|
|
89
83
|
box-sizing: border-box !important;
|
|
90
84
|
background-color: #FFF5F5 !important;
|
|
91
|
-
z-index:
|
|
85
|
+
z-index: 2147483647 !important; /* ๋ฆฌ์กํธ ๋ด๋ถ ๊ทธ ์ด๋ค ์ค๋ฒ๋ ์ด๋ณด๋ค ๋ฌด์กฐ๊ฑด ์ */
|
|
92
86
|
overflow: auto !important;
|
|
87
|
+
display: none; /* ํ์์ ์จ๊น */
|
|
93
88
|
}
|
|
94
89
|
</style>
|
|
95
90
|
|
|
96
|
-
<div class="nine-hook-core"
|
|
91
|
+
<div class="nine-hook-core">
|
|
97
92
|
<slot></slot>
|
|
98
93
|
</div>
|
|
99
|
-
<div class="nine-exception-board"></div>
|
|
94
|
+
<div class="nine-exception-board class-target-board"></div>
|
|
100
95
|
`;
|
|
101
96
|
}
|
|
102
97
|
|
|
@@ -110,61 +105,42 @@ export class ExceptionHook extends HTMLElement {
|
|
|
110
105
|
}
|
|
111
106
|
|
|
112
107
|
#handleRuntimeError = (event) => {
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
if (this.#hasError) {
|
|
116
|
-
trace.log("โ ๏ธ [nine-exception-hook] ์ด๋ฏธ ์๋ฌ ํ๋ฉด์ด ํ์ฑํ๋์ด ์์ด ์ด๋ฒคํธ ๋ฆฌ์ค๋ ํจ์ค");
|
|
117
|
-
return;
|
|
118
|
-
}
|
|
108
|
+
if (this.#hasError) return;
|
|
119
109
|
|
|
120
110
|
const errorMessage = event.error?.message || event.message || String(event);
|
|
121
111
|
const errorStack = event.error?.stack || "No stack trace available";
|
|
122
112
|
|
|
123
113
|
if (errorMessage && errorMessage !== "Script error.") {
|
|
124
|
-
trace.log("๐ฏ [nine-exception-hook] ์ ์์ ์ธ ์๋ฌ ๋ฉ์์ง ํ์ธ -> ์๋ฌ ๋ณด๋ ์ถ๋ ฅ ์๋", { errorMessage });
|
|
125
114
|
this.#renderError(errorMessage, errorStack);
|
|
126
|
-
} else {
|
|
127
|
-
trace.log("โ ๏ธ [nine-exception-hook] 'Script error.' ์ด๊ฑฐ๋ ๋น ๋ฉ์์ง๋ผ ๋ฌด์๋จ");
|
|
128
115
|
}
|
|
129
116
|
}
|
|
130
117
|
|
|
131
118
|
#handlePromiseError = (event) => {
|
|
132
|
-
trace.log("๐จ [nine-exception-hook] unhandledrejection (Promise ์๋ฌ) ํฌ์ฐฉ!!", event);
|
|
133
|
-
|
|
134
119
|
if (this.#hasError) return;
|
|
135
120
|
|
|
136
121
|
const reason = event.reason;
|
|
137
122
|
const errorMessage = reason?.message || String(reason || "Unhandled Promise Rejection");
|
|
138
123
|
const errorStack = reason?.stack || "No stack trace available";
|
|
139
124
|
|
|
140
|
-
trace.log("๐ฏ [nine-exception-hook] Promise ๊ฑฐ๋ถ ํ์ธ -> ์๋ฌ ๋ณด๋ ์ถ๋ ฅ ์๋");
|
|
141
125
|
this.#renderError(errorMessage, errorStack);
|
|
142
126
|
}
|
|
143
127
|
|
|
144
128
|
#handleLocationChange = () => {
|
|
145
129
|
setTimeout(() => {
|
|
146
|
-
trace.log("๐ [nine-exception-hook] ์ฃผ์ ์ด๋ ๊ฐ์ง ์ฒดํฌ", {
|
|
147
|
-
hasError: this.#hasError,
|
|
148
|
-
lastPath: this.#lastPath,
|
|
149
|
-
currentPath: window.location.pathname
|
|
150
|
-
});
|
|
151
|
-
|
|
152
130
|
if (this.#hasError && this.#lastPath !== window.location.pathname) {
|
|
153
|
-
trace.log("โจ [nine-exception-hook] Shadow DOM ๋ด๋ถ ์์ธ ์ฒญ์ ๋ฐ ์ ์ ๋ณต๊ตฌ");
|
|
154
131
|
this.#lastPath = window.location.pathname;
|
|
155
132
|
this.#hasError = false;
|
|
156
133
|
|
|
157
134
|
const exceptionBoard = this.shadowRoot.querySelector('.nine-exception-board');
|
|
158
|
-
if (exceptionBoard)
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
135
|
+
if (exceptionBoard) {
|
|
136
|
+
exceptionBoard.innerHTML = '';
|
|
137
|
+
exceptionBoard.className = 'nine-exception-board'; // ํด๋์ค ๋ฆฌ์
|
|
138
|
+
}
|
|
162
139
|
}
|
|
163
|
-
}, 50);
|
|
140
|
+
}, 50);
|
|
164
141
|
}
|
|
165
142
|
|
|
166
143
|
#sendToAiAction = async (errorMessage, errorStack) => {
|
|
167
|
-
trace.log("๐ [nine-exception-hook] AI ์์ ์์ฒญ ๋ฒํผ ํด๋ฆญ๋จ");
|
|
168
144
|
const btn = this.shadowRoot.querySelector('.nine-ai-btn');
|
|
169
145
|
const footer = this.shadowRoot.querySelector('.nine-error-footer');
|
|
170
146
|
if (!btn) return;
|
|
@@ -175,7 +151,6 @@ export class ExceptionHook extends HTMLElement {
|
|
|
175
151
|
|
|
176
152
|
try {
|
|
177
153
|
if (window.triggerAutoRecovery) {
|
|
178
|
-
trace.log("๐ก [nine-exception-hook] window.triggerAutoRecovery ํธ์ถ ์คํ");
|
|
179
154
|
await window.triggerAutoRecovery({
|
|
180
155
|
message: errorMessage,
|
|
181
156
|
stack: errorStack || "No stack trace available",
|
|
@@ -188,7 +163,6 @@ export class ExceptionHook extends HTMLElement {
|
|
|
188
163
|
throw new Error("window.triggerAutoRecovery ๊ด์ ํ ์์ง์ด ๋ก๋๋์ง ์์์ต๋๋ค.");
|
|
189
164
|
}
|
|
190
165
|
} catch (err) {
|
|
191
|
-
trace.error("โ AI ์ ์ก ์คํจ:", err);
|
|
192
166
|
btn.disabled = false;
|
|
193
167
|
btn.innerText = "โ ์ฌ์ ์ก ์๋";
|
|
194
168
|
footer.innerHTML = `<span style="color: #E53E3E;">โ ๏ธ ์ ์ก ์คํจ: ${err.message}</span>`;
|
|
@@ -200,45 +174,33 @@ export class ExceptionHook extends HTMLElement {
|
|
|
200
174
|
this.#hasError = true;
|
|
201
175
|
|
|
202
176
|
setTimeout(() => {
|
|
203
|
-
trace.log("๐จ [nine-exception-hook] ๋ฆฌ์กํธ ์ฌ์ดํด ์ข
๋ฃ ํ ์๋ฌ UI ์ต์ข
๋ ๋๋ง");
|
|
204
|
-
|
|
205
|
-
const coreContainer = this.shadowRoot.querySelector('.nine-hook-core');
|
|
206
|
-
if (coreContainer) {
|
|
207
|
-
coreContainer.style.display = 'none';
|
|
208
|
-
trace.log("๐จ [nine-exception-hook] <slot> ๋ณธ๋ฌธ ์์ญ ์ปจํ
์ด๋ ์จ๊น");
|
|
209
|
-
}
|
|
210
|
-
|
|
211
177
|
const exceptionBoard = this.shadowRoot.querySelector('.nine-exception-board');
|
|
212
|
-
if (!exceptionBoard)
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
178
|
+
if (!exceptionBoard) return;
|
|
179
|
+
|
|
180
|
+
// ๐ฏ [ํต์ฌ ๋ณ๊ฒฝ 3] ๊ธฐ์กด ์ฌ๋กฏ ์ปจํ
์ด๋๋ฅผ ์จ๊ธฐ์ง(display: none) ์์ต๋๋ค!
|
|
181
|
+
// ๋์ ์๋ฌ ๋ณด๋์ ์ปค๋ฒ ํด๋์ค๋ฅผ ์ฃผ์
ํ์ฌ "์ค์ง ๋ณธ๋ฌธ ๊ณต๊ฐ๋ง" ๋ฌผ๋ฆฌ์ ์ผ๋ก ์์ ํ ๋ฎ์ด์์๋๋ค.
|
|
182
|
+
exceptionBoard.className = 'nine-hook-inner-cover';
|
|
216
183
|
|
|
217
|
-
// ๐ฏ [์์ 2] ์๋ฌ HTML ์ปจํ
์ด๋ ๊ตฌ์กฐ๋ฅผ ํ๋ฉด ์ ์ฒด ๋ทฐํฌํธ๋ฅผ ์ฅ์
ํ๋ ๊ณ ์ ๋ ์ด์์ ๊ตฌ์กฐ๋ก ๋ฉํ
|
|
218
184
|
const errorHTML = `
|
|
219
|
-
<div class="nine-
|
|
220
|
-
<
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
<
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
๋ฒํผ์ ๋๋ฅด๋ฉด AI๊ฐ ๋ก๊ทธ ๋ฐ ์ปดํฌ๋ํธ ๋งต์ ์ญ์ถ์ ํ์ฌ ์์ ์ ์์ํฉ๋๋ค.
|
|
229
|
-
</div>
|
|
185
|
+
<div class="nine-error-container" style="padding: 30px; box-sizing: border-box; font-family: sans-serif; background: white; min-height: 100%; text-align: left;">
|
|
186
|
+
<h3 class="nine-error-title" style="color: #C53030; margin-top: 0; font-size: 20px; font-weight: 700; border-bottom: 2px solid #FED2D2; padding-bottom: 12px; font-family: sans-serif;">โ ๏ธ ์์คํ
์์ธ ๊ฐ์ง (${this.tagName.toLowerCase()})</h3>
|
|
187
|
+
<p class="nine-error-label" style="font-weight: bold; margin: 15px 0 6px 0; color: #4A5568; font-size: 14px; font-family: sans-serif;">[์๋ฌ ์์ธ ๋ก๊ทธ]:</p>
|
|
188
|
+
<pre class="nine-error-log" style="background: #1A202C; color: #EDF2F7; padding: 15px; border-radius: 6px; overflow-x: auto; white-space: pre-wrap; font-family: monospace; font-size: 13px; line-height: 1.5; margin-bottom: 20px;">${errorMessage}\n\n[Stack Trace]\n${errorStack}</pre>
|
|
189
|
+
|
|
190
|
+
<div class="nine-action-area" style="display: flex; align-items: center; gap: 15px; border-top: 1px solid #E2E8F0; padding-top: 15px;">
|
|
191
|
+
<button class="nine-ai-btn" style="background: #3182CE; color: white; border: none; padding: 10px 20px; border-radius: 6px; font-weight: bold; cursor: pointer; font-size: 14px;">๐ค AI์๊ฒ ์์ค์ฝ๋ ์์ ์์ฒญ</button>
|
|
192
|
+
<div class="nine-error-footer" style="font-size: 13px; color: #718096; line-height: 1.4; font-family: sans-serif;">
|
|
193
|
+
๋ฒํผ์ ๋๋ฅด๋ฉด AI๊ฐ ๋ก๊ทธ ๋ฐ ์ปดํฌ๋ํธ ๋งต์ ์ญ์ถ์ ํ์ฌ ์์ ์ ์์ํฉ๋๋ค.
|
|
230
194
|
</div>
|
|
231
195
|
</div>
|
|
232
196
|
</div>
|
|
233
197
|
`;
|
|
234
198
|
|
|
235
199
|
exceptionBoard.innerHTML = errorHTML;
|
|
236
|
-
trace.log("๐จ [nine-exception-hook] Shadow DOM์ ์๋ฌ UI ์ต์ข
์ฝ์
์ฑ๊ณต");
|
|
237
200
|
|
|
238
|
-
const aiBtn =
|
|
201
|
+
const aiBtn = exceptionBoard.querySelector('.nine-ai-btn');
|
|
239
202
|
if (aiBtn) {
|
|
240
203
|
aiBtn.addEventListener('click', () => this.#sendToAiAction(errorMessage, errorStack));
|
|
241
|
-
trace.log("๐จ [nine-exception-hook] AI ์์ฒญ ๋ฒํผ ์ด๋ฒคํธ ๋ฆฌ์ค๋ ์ต์ข
๋ฐ์ธ๋ฉ ์ฑ๊ณต");
|
|
242
204
|
}
|
|
243
205
|
}, 0);
|
|
244
206
|
}
|