@nine-lab/nine-mu 0.1.331 โ†’ 0.1.333

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.331",
3
+ "version": "0.1.333",
4
4
  "description": "AI-Driven Full-Stack Code Fabrication Engine",
5
5
  "type": "module",
6
6
  "main": "./dist/nine-mu.umd.js",
@@ -385,6 +385,11 @@ class ChatMessageBody extends HTMLElement
385
385
 
386
386
  };
387
387
 
388
+ removeIng = () => {
389
+ this.shadowRoot.querySelectorAll("nine-chat-ing").forEach(el => {
390
+ el.remove();
391
+ });
392
+ }
388
393
 
389
394
  add = (sender, message, info, data, unique) => {
390
395
 
@@ -119,7 +119,9 @@ export class NineChat extends HTMLElement {
119
119
 
120
120
  if (parsed.message) {
121
121
  this.#manager.addChatHistory(parsed.message);
122
- //this.#$nineChatMessage.add("ai", parsed.message);
122
+ this.#$nineChatMessage.add("ai", parsed.message);
123
+ } else {
124
+ this.#$nineChatMessage.removeIng();
123
125
  }
124
126
  }
125
127
  }
@@ -0,0 +1,94 @@
1
+ export class ExceptionHook extends HTMLElement {
2
+ constructor() {
3
+ super();
4
+ this.lastPath = window.location.pathname;
5
+ this.hasError = false;
6
+
7
+ // ๐Ÿ’ก ๊น”๋”ํ•˜๊ฒŒ ๋ช…์นญ์„ ์‹ฑํฌํ•œ ์™ธ๋ถ€ CSS ๊ฒฝ๋กœ
8
+ this.cssPath = "/css/nine-exception-hook.css";
9
+ }
10
+
11
+ connectedCallback() {
12
+ this.injectStylesheet();
13
+
14
+ // ๋Ÿฐํƒ€์ž„ ์—๋Ÿฌ ๋ฐ ๋น„๋™๊ธฐ ๊ฑฐ๋ถ€(Promise Rejection)์— ๊ฐˆ๊ณ ๋ฆฌ(Hook)๋ฅผ ๊ฒ๋‹ˆ๋‹ค.
15
+ window.addEventListener('error', this.handleRuntimeError.bind(this), true);
16
+ window.addEventListener('unhandledrejection', this.handlePromiseError.bind(this), true);
17
+ window.addEventListener('popstate', this.handleLocationChange.bind(this));
18
+ document.addEventListener('click', this.handleLocationChange.bind(this), true);
19
+ }
20
+
21
+ disconnectedCallback() {
22
+ window.removeEventListener('error', this.handleRuntimeError);
23
+ window.removeEventListener('unhandledrejection', this.handlePromiseError);
24
+ window.removeEventListener('popstate', this.handleLocationChange);
25
+ document.removeEventListener('click', this.handleLocationChange, true);
26
+ }
27
+
28
+ injectStylesheet() {
29
+ if (document.querySelector(`link[href="${this.cssPath}"]`)) return;
30
+
31
+ const link = document.createElement('link');
32
+ link.rel = 'stylesheet';
33
+ link.href = this.cssPath;
34
+ document.head.appendChild(link);
35
+ }
36
+
37
+ handleRuntimeError(event) {
38
+ if (this.contains(event.target) || event.error) {
39
+ this.renderError(event.error?.message || event.message);
40
+ }
41
+ }
42
+
43
+ handlePromiseError(event) {
44
+ this.renderError(event.reason?.message || String(event.reason));
45
+ }
46
+
47
+ handleLocationChange() {
48
+ setTimeout(() => {
49
+ // ์ฃผ์†Œ๊ฐ€ ๋ฐ”๋€Œ๋ฉด ํ›…(Hook)์„ ์ผ์‹œ์ ์œผ๋กœ ํ’€๊ณ  ํ™”๋ฉด์„ ๋ถ€๋“œ๋Ÿฝ๊ฒŒ ๋ณต๊ตฌ
50
+ if (this.hasError && this.lastPath !== window.location.pathname) {
51
+ console.log("โœจ [nine-exception-hook] ์˜ˆ์™ธ ํ•ด์ œ ๋ฐ ๋ Œ๋”๋ง ์ •์ƒ ๋ณต๊ตฌ");
52
+ this.lastPath = window.location.pathname;
53
+ this.hasError = false;
54
+
55
+ const errorBox = this.querySelector('.nine-error-container');
56
+ if (errorBox) errorBox.remove();
57
+
58
+ Array.from(this.children).forEach(child => {
59
+ if (child.tagName !== 'LINK') child.style.display = '';
60
+ });
61
+ }
62
+ }, 10);
63
+ }
64
+
65
+ renderError(errorMessage) {
66
+ if (this.hasError) return;
67
+ this.hasError = true;
68
+
69
+ if (window.triggerAutoRecovery) {
70
+ window.triggerAutoRecovery(errorMessage);
71
+ }
72
+
73
+ Array.from(this.children).forEach(child => {
74
+ if (child.tagName !== 'LINK') child.style.display = 'none';
75
+ });
76
+
77
+ const errorHTML = `
78
+ <div class="nine-error-container">
79
+ <h3 class="nine-error-title">โš ๏ธ ์‹œ์Šคํ…œ ์˜ˆ์™ธ ๊ฐ์ง€ (${this.tagName.toLowerCase()})</h3>
80
+ <p class="nine-error-label">[์—๋Ÿฌ ์›์ธ ๋กœ๊ทธ]:</p>
81
+ <pre class="nine-error-log">${errorMessage}</pre>
82
+ <div class="nine-error-footer">
83
+ ๐Ÿ”„ ์—๋Ÿฌ ๋กœ๊ทธ๊ฐ€ ๊ด€์ œํƒ‘์œผ๋กœ ์ž๋™ ํ”ผ๋“œ๋ฐฑ๋˜์—ˆ์Šต๋‹ˆ๋‹ค. AI๊ฐ€ ์†Œ์Šค ์ฝ”๋“œ๋ฅผ ์žฌ์ˆ˜์ •ํ•˜๋Š” ๋™์•ˆ ์ž ์‹œ๋งŒ ๊ธฐ๋‹ค๋ ค์ฃผ์„ธ์š”...
84
+ </div>
85
+ </div>
86
+ `;
87
+ this.insertAdjacentHTML('beforeend', errorHTML);
88
+ }
89
+ }
90
+
91
+ // ๐Ÿ’ก ์ „์—ญ ๋ธŒ๋ผ์šฐ์ € ํ…œํ”Œ๋ฆฟ ํƒœ๊ทธ๋กœ ๊ณต์‹ ๋“ฑ๋ก
92
+ if (!customElements.get('nine-exception-hook')) {
93
+ customElements.define('nine-exception-hook', ExceptionHook);
94
+ }
package/src/index.js CHANGED
@@ -4,6 +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
8
 
8
9
  /**
9
10
  * Nine-Mu ์—”์ง„ ๋ฉ”์ธ ํด๋ž˜์Šค