@nine-lab/nine-mu 0.1.324 β 0.1.326
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 +58 -44
- 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 +1 -1
- package/src/components/NineChat.js +3 -2
- package/src/components/NotificationHandler.js +64 -23
package/package.json
CHANGED
|
@@ -125,7 +125,8 @@ export class NineChat extends HTMLElement {
|
|
|
125
125
|
|
|
126
126
|
const asis = await this.#manager.getRoutes();
|
|
127
127
|
|
|
128
|
-
|
|
128
|
+
/**
|
|
129
|
+
if (parsed?.selected_tool === "generate-menu") {
|
|
129
130
|
const hasCreated = parsed?.data.some(item => item.action === 'CREATE');
|
|
130
131
|
const hasUpdated = parsed?.data.some(item => item.action === 'UPDATE');
|
|
131
132
|
const hasDeleted = parsed?.data.some(item => item.action === 'DELETE');
|
|
@@ -140,7 +141,7 @@ export class NineChat extends HTMLElement {
|
|
|
140
141
|
this.#showDiff(asis, tobe, "json");
|
|
141
142
|
});
|
|
142
143
|
}
|
|
143
|
-
}
|
|
144
|
+
} */
|
|
144
145
|
|
|
145
146
|
// π‘ λ§μ½ intentκ° EXECUTE_TOOLμ΄κ±°λ NAVIGATEμΌ λ νλ‘ νΈμμ
|
|
146
147
|
// νλ©΄ μ΄λ(Routing)μ΄λ μΆκ° μ‘μ
μ ν΄μΌ νλ€λ©΄ μ¬κΈ°μ parsedData.target_path λ±μ νμ©νλ©΄ λ©λλ€!
|
|
@@ -1,12 +1,15 @@
|
|
|
1
1
|
import { trace } from "@nopeer";
|
|
2
2
|
import { api } from "@nine-lab/nine-util";
|
|
3
|
+
import {NineChatManager} from "./NineChatManager.js";
|
|
3
4
|
|
|
4
5
|
export class NotificationHandler {
|
|
5
6
|
#owner;
|
|
7
|
+
#manager;
|
|
6
8
|
#collectedFiles = [];
|
|
7
9
|
|
|
8
10
|
constructor(owner) {
|
|
9
11
|
this.#owner = owner; // μΉ μ»΄ν¬λνΈλ UI DOM μΈμ€ν΄μ€
|
|
12
|
+
this.#manager = new NineChatManager(owner);
|
|
10
13
|
}
|
|
11
14
|
|
|
12
15
|
/**
|
|
@@ -36,31 +39,39 @@ export class NotificationHandler {
|
|
|
36
39
|
// 2. π¨ [λμ€μ 100μκ°μ§λ¦¬ μλ²½μ μ±μΈ ν΅μ¬ κΈΈλͺ©]
|
|
37
40
|
// λ°μ΄ν°μ μμ€μ½λ μλ§Ήμ΄(data.source)λ λ©νλ°μ΄ν°κ° μ€λ € λ΄λ €μμ λμ νμλ₯Ό μ¬κΈ°μ 격리 μ²λ¦¬ν©λλ€.
|
|
38
41
|
|
|
42
|
+
/**
|
|
39
43
|
switch (logger) {
|
|
40
44
|
case "generate-source-brain":
|
|
41
|
-
|
|
42
|
-
//trace.log(`[μκ·Έλ κ°μ§] μ€κ³ μλ£`, data);
|
|
43
|
-
this.#generateSource(data);
|
|
44
|
-
//}
|
|
45
|
+
this.#generateSource(data);
|
|
45
46
|
break;
|
|
46
47
|
|
|
47
48
|
case "modify-source-brain":
|
|
48
|
-
|
|
49
|
-
this.#collectModifySource(data);
|
|
50
|
-
}
|
|
49
|
+
this.#collectModifySource(data);
|
|
51
50
|
break;
|
|
52
51
|
|
|
53
52
|
case "modify-source-brain-completed":
|
|
54
|
-
//trace.log(`[μκ·Έλ κ°μ§] μ€κ³ μλ£`, data);
|
|
55
53
|
this.#openDiffPopup();
|
|
56
54
|
break;
|
|
57
|
-
}
|
|
55
|
+
} */
|
|
56
|
+
|
|
57
|
+
// μλ°μ -> μ²λΌ μλ°μ€ν¬λ¦½νΈμ => (νμ΄ν ν¨μ)λ₯Ό νμ©ν λ§€ν
|
|
58
|
+
const runAction = {
|
|
59
|
+
"generate-menu-completed": () => this.#generateMenu(data),
|
|
60
|
+
"generate-source-brain": () => this.#generateSource(data),
|
|
61
|
+
"modify-source-brain": () => this.#collectModifySource(data),
|
|
62
|
+
"modify-source-brain-completed": () => this.#openDiffPopup(),
|
|
63
|
+
}[logger];
|
|
64
|
+
|
|
65
|
+
runAction?.();
|
|
58
66
|
}
|
|
59
67
|
|
|
60
68
|
/**
|
|
61
69
|
* λ μ΄μ΄λ³λ‘ μμ°¨ λμ°©νλ νμΌλ€μ μ μ€ μμ΄ λ°°μ΄ λ²νΌμ μμ§
|
|
62
70
|
*/
|
|
63
71
|
#collectModifySource = (data) => {
|
|
72
|
+
|
|
73
|
+
if (!data || !data.source) return;
|
|
74
|
+
|
|
64
75
|
const filePayload = {
|
|
65
76
|
layer: data.layer || "Unknown",
|
|
66
77
|
full_path: data.full_path || "unknown_file",
|
|
@@ -78,9 +89,7 @@ export class NotificationHandler {
|
|
|
78
89
|
if (this.#collectedFiles.length === 0) return;
|
|
79
90
|
|
|
80
91
|
const $oldPopup = this.#owner.shadowRoot.querySelector('nine-diff-popup');
|
|
81
|
-
if ($oldPopup)
|
|
82
|
-
$oldPopup.remove();
|
|
83
|
-
}
|
|
92
|
+
if ($oldPopup) $oldPopup.remove();
|
|
84
93
|
|
|
85
94
|
// DOM μμ μ±κΈν€ νμ
μΈμ€ν΄μ€ λ μ΄μμ μΆμΆ λ° λΉλ
|
|
86
95
|
|
|
@@ -99,28 +108,60 @@ export class NotificationHandler {
|
|
|
99
108
|
this.#collectedFiles = [];
|
|
100
109
|
};
|
|
101
110
|
|
|
111
|
+
#openRouteDiffPopup = (asis, tobe, lang) => {
|
|
112
|
+
// 1. νΉμ μμμ΄ λ¨μμμμ§ λͺ¨λ₯΄λ κΈ°μ‘΄μ μμ±λ νμ
μ΄ μλ€λ©΄ κ°μ μ κ±°
|
|
113
|
+
const $oldPopup = this.#owner.shadowRoot.querySelector('nine-menu-diff-popup');
|
|
114
|
+
if ($oldPopup) $oldPopup.remove();
|
|
115
|
+
|
|
116
|
+
// 2. λμ μΌλ‘ 컀μ€ν
μλ¦¬λ¨ΌνΈ μμ±
|
|
117
|
+
const $diffPopup = document.createElement('nine-menu-diff-popup');
|
|
118
|
+
|
|
119
|
+
// 3. λνΌ(wrapper) μμ΄λ shadowRoot μ μΌ λ°λ°λ₯μ λΆμ°©
|
|
120
|
+
const container = this.#owner.shadowRoot.querySelector('.wrapper') || this.shadowRoot;
|
|
121
|
+
container.appendChild($diffPopup);
|
|
122
|
+
|
|
123
|
+
// 4. λ°μ΄ν° μ£Όμ
λ° νμ
μ€ν
|
|
124
|
+
// π‘ νμ
μ΄ λ€μ΄ν°λΈ <dialog> κΈ°λ°μ΄λΌλ©΄ .popup() λ΄λΆμμ showModal()μ΄ μ€νλ κ²λλ€.
|
|
125
|
+
$diffPopup.popup().data(asis, tobe, lang);
|
|
126
|
+
}
|
|
127
|
+
|
|
102
128
|
/**
|
|
103
129
|
* [λΆλ¦¬ λΉμ¦λμ€ λ‘μ§ 2] μμ λ μμ€μ½λ λ°μ΄ν° μ ν¨μ± κ²μ¦ λ° μΆν νμΌ μ μ₯ μ°λ
|
|
104
130
|
*/
|
|
105
131
|
#generateSource = async (data) => {
|
|
106
132
|
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
return;
|
|
110
|
-
|
|
111
|
-
// μμ€μ½λ λ°μ΄ν°κ° μ μμ μΌλ‘ ν보λμλμ§ 1%μ λλ½ κ²μ¦
|
|
112
|
-
if (data.layer) {
|
|
113
|
-
//trace.warn("β οΈ μμ€ λλ νμΌλͺ
λλ½ λ°μ΄ν° μμ λ¨", data);
|
|
114
|
-
//return;
|
|
115
|
-
}
|
|
133
|
+
if (!data.path || !data.source) return;
|
|
116
134
|
|
|
117
135
|
const res = await api.post("/nine-mu/source/generateRealFileSingle", {
|
|
118
136
|
//package_path: data.path,
|
|
119
137
|
//file_name: data.file_name,
|
|
120
|
-
currentPath:
|
|
138
|
+
currentPath: data.path,
|
|
121
139
|
contents: data.source
|
|
122
140
|
});
|
|
123
141
|
|
|
124
|
-
trace.log(res)
|
|
142
|
+
trace.log(res);
|
|
143
|
+
}
|
|
144
|
+
|
|
145
|
+
#generateMenu = async (data) => {
|
|
146
|
+
|
|
147
|
+
if (!data) return;
|
|
148
|
+
|
|
149
|
+
const hasCreated = data.some(item => item.action === 'CREATE');
|
|
150
|
+
const hasUpdated = data.some(item => item.action === 'UPDATE');
|
|
151
|
+
const hasDeleted = data.some(item => item.action === 'DELETE');
|
|
152
|
+
|
|
153
|
+
if (hasUpdated || hasCreated || hasDeleted) {
|
|
154
|
+
|
|
155
|
+
const asis = await this.#manager.getRoutes();
|
|
156
|
+
|
|
157
|
+
// μ§μ§ λ©λ΄λͺ
λ³κ²½μ΄λ μ΄λλ§ μμ²ν κ²½μ°
|
|
158
|
+
nine.alert("λ©λ΄ μ 리λ₯Ό μν λΌμ°ν° μ 보 μ μ₯ νλ©΄μΌλ‘ μ΄λν©λλ€.").then(res => {
|
|
159
|
+
const tobe = (data || [])
|
|
160
|
+
.filter(item => item.action !== 'DELETE')
|
|
161
|
+
.map(({ isNew, action, ...rest }) => rest);
|
|
162
|
+
|
|
163
|
+
this.#openRouteDiffPopup(asis, tobe, "json");
|
|
164
|
+
});
|
|
165
|
+
}
|
|
125
166
|
}
|
|
126
167
|
}
|