ide-assi 0.2.0 → 0.3.0

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.
@@ -0,0 +1,190 @@
1
+ //import ninegrid from "../index.js";
2
+ import ninegrid from "ninegrid2";
3
+
4
+ class ideAssi extends HTMLElement
5
+ {
6
+ #ing = false;
7
+
8
+ constructor() {
9
+ super();
10
+ this.attachShadow({ mode: 'open' });
11
+ }
12
+
13
+ connectedCallback() {
14
+
15
+ const textareaText = "나에게 무엇이든 물어봐...";
16
+
17
+ this.shadowRoot.innerHTML = `
18
+ <style>
19
+ @import "https://cdn.jsdelivr.net/npm/ninegrid@${ninegrid.version}/dist/css/ideAssi.css";
20
+ ${ninegrid.getCustomPath(this,"ideAssi.css")}
21
+ </style>
22
+
23
+ <div class="wrapper">
24
+ <div class="container">
25
+ <div class="head">
26
+ <div class="logo"></div>
27
+ </div>
28
+ <nx-ai-chat></nx-ai-chat>
29
+ <div class="foot">
30
+ <textarea name="ask" id="q" name="q" rows="4" placeholder="${textareaText}"></textarea>
31
+ </div>
32
+ </div>
33
+ <div class="menu">
34
+ <div class="collapse-icon"></div>
35
+ <div class="menu-icon menu-filter active"></div>
36
+ <div class="menu-icon menu-general"></div>
37
+ <div class="menu-icon menu-setting"></div>
38
+ </div>
39
+ </div>
40
+
41
+ <div class="expand-icon"></div>
42
+ `;
43
+
44
+ requestAnimationFrame(() => {
45
+ this.#init();
46
+ });
47
+ };
48
+
49
+
50
+ #init = (info) => {
51
+
52
+ this.shadowRoot.querySelector("textarea").addEventListener("keydown", this.#keydownHandler);
53
+
54
+ this.shadowRoot.querySelector(".expand-icon").addEventListener("click", this.#toggleCollapseHandler);
55
+ this.shadowRoot.querySelector(".collapse-icon").addEventListener("click", this.#toggleCollapseHandler);
56
+
57
+ //this.shadowRoot.querySelectorAll(".menu-icon").forEach(el => el.addEventListener("click", this.#menuClickHandler));
58
+ };
59
+
60
+
61
+ #getMenuInfo = (question) => {
62
+ let arr = [];
63
+
64
+ ninegrid.querySelectorAll("nx-side-menu-item[url][title]").forEach(elem => {
65
+ arr.push({
66
+ //menuId: elem.getAttribute("menu-id"),
67
+ url: elem.getAttribute("url"),
68
+ title: elem.getAttribute("title"),
69
+ })
70
+ });
71
+
72
+ return arr;
73
+ };
74
+
75
+ #getTableInfo = async (question) => {
76
+ const response = await fetch("/api/meta/tables", {
77
+ method: "POST",
78
+ headers: { "Content-Type": "application/json" },
79
+ body: JSON.stringify({
80
+ //filename: "HelloWorld.java",
81
+ //filename: "Test.jsx",
82
+ //content: js
83
+ })
84
+ });
85
+
86
+ console.log(response);
87
+
88
+ };
89
+
90
+
91
+ /**
92
+ * 1. 소스 명칭 package 예) tmpl.population
93
+ * 2. 소스가 없으면 소스 생성
94
+ * 3.
95
+ */
96
+ #generateSource = async (question) => {
97
+
98
+ const menuInfo = this.#getMenuInfo();
99
+ const tableInfo = await this.#getTableInfo();
100
+ };
101
+
102
+ #keydownHandler = async (e) => {
103
+ if (e.key !== "Enter") return;
104
+
105
+ e.preventDefault();
106
+
107
+ const question = e.target.value.trim();
108
+ if (!question) return;
109
+
110
+ if (this.#ing) return;
111
+ this.#ing = true;
112
+
113
+ /**
114
+ * setTimeout 없으면, 맥에서 한글 잔상이 남음
115
+ * setTimeout 내에서 e.target이 nx-ai-container가 된다.
116
+ */
117
+ setTimeout(() => {
118
+ this.shadowRoot.querySelector("textarea").value = "";
119
+ });
120
+
121
+ const elAiChat = this.shadowRoot.querySelector("nx-ai-chat");
122
+
123
+ elAiChat.add("me", question);
124
+ elAiChat.add("ing", question);
125
+
126
+ try {
127
+ this.#generateSource(question);
128
+ } catch (error) {
129
+ console.error(error);
130
+ elAiChat.add("ai", error);
131
+ }
132
+
133
+ /**
134
+ try {
135
+ const code = `
136
+ package tmpl.generated;
137
+
138
+ public class HelloWorld {
139
+ public String sayHello() {
140
+ return "Hello from generated class!";
141
+ }
142
+ }
143
+ `;
144
+
145
+ const js = `
146
+ const Home = () => {
147
+ const wrapStyle = {
148
+ backgroundColor: "white",
149
+ color: "black",
150
+ padding: "0px",
151
+ textAlign: "center",
152
+ fontSize: "18px",
153
+ height: "100%",
154
+ };
155
+
156
+ return (
157
+ <div style={wrapStyle}>
158
+ 11111
159
+ </div>
160
+ );
161
+ };
162
+
163
+ export default Home;
164
+ `;
165
+
166
+
167
+ await fetch("/api/files/js", {
168
+ method: "POST",
169
+ headers: { "Content-Type": "application/json" },
170
+ body: JSON.stringify({
171
+ //filename: "HelloWorld.java",
172
+ filename: "Test.jsx",
173
+ content: js
174
+ })
175
+ });
176
+ } catch (error) {
177
+ console.error(error);
178
+ //elAiChat.add("ai", error);
179
+ }
180
+ */
181
+
182
+ this.#ing = false;
183
+ }
184
+
185
+ #toggleCollapseHandler = () => {
186
+ this.classList.toggle("collapse");
187
+ };
188
+ }
189
+
190
+ customElements.define("ide-assi", ideAssi);
File without changes
package/dist/index.js CHANGED
@@ -1,8 +1 @@
1
- class HelloCard extends HTMLElement {
2
- connectedCallback() {
3
- this.innerHTML = `<div style="padding:1rem;border:1px solid #ddd;">
4
- 안녕하세요, <b>${this.getAttribute("name") ?? "게스트"}</b>!
5
- </div>`;
6
- }
7
- }
8
- customElements.define("hello-card", HelloCard);
1
+ import "./components/ideAssi.js";
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "ide-assi",
3
3
  "type": "module",
4
- "version": "0.2.0",
4
+ "version": "0.3.0",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",
7
7
  "exports": {
@@ -30,6 +30,7 @@
30
30
  "@langchain/openai": "^0.x.x",
31
31
  "exceljs": "^4.4.0",
32
32
  "jquery": "^3.6.0",
33
+ "ninegrid2": "^6.650.0",
33
34
  "react": "^19.1.0"
34
35
  },
35
36
  "peerDependencies": {
@@ -0,0 +1,189 @@
1
+ import ninegrid from "ninegrid2";
2
+
3
+ class ideAssi extends HTMLElement
4
+ {
5
+ #ing = false;
6
+
7
+ constructor() {
8
+ super();
9
+ this.attachShadow({ mode: 'open' });
10
+ }
11
+
12
+ connectedCallback() {
13
+
14
+ const textareaText = "나에게 무엇이든 물어봐...";
15
+
16
+ this.shadowRoot.innerHTML = `
17
+ <style>
18
+ @import "https://cdn.jsdelivr.net/npm/ninegrid@${ninegrid.version}/dist/css/ideAssi.css";
19
+ ${ninegrid.getCustomPath(this,"ideAssi.css")}
20
+ </style>
21
+
22
+ <div class="wrapper">
23
+ <div class="container">
24
+ <div class="head">
25
+ <div class="logo"></div>
26
+ </div>
27
+ <nx-ai-chat></nx-ai-chat>
28
+ <div class="foot">
29
+ <textarea name="ask" id="q" name="q" rows="4" placeholder="${textareaText}"></textarea>
30
+ </div>
31
+ </div>
32
+ <div class="menu">
33
+ <div class="collapse-icon"></div>
34
+ <div class="menu-icon menu-filter active"></div>
35
+ <div class="menu-icon menu-general"></div>
36
+ <div class="menu-icon menu-setting"></div>
37
+ </div>
38
+ </div>
39
+
40
+ <div class="expand-icon"></div>
41
+ `;
42
+
43
+ requestAnimationFrame(() => {
44
+ this.#init();
45
+ });
46
+ };
47
+
48
+
49
+ #init = (info) => {
50
+
51
+ this.shadowRoot.querySelector("textarea").addEventListener("keydown", this.#keydownHandler);
52
+
53
+ this.shadowRoot.querySelector(".expand-icon").addEventListener("click", this.#toggleCollapseHandler);
54
+ this.shadowRoot.querySelector(".collapse-icon").addEventListener("click", this.#toggleCollapseHandler);
55
+
56
+ //this.shadowRoot.querySelectorAll(".menu-icon").forEach(el => el.addEventListener("click", this.#menuClickHandler));
57
+ };
58
+
59
+
60
+ #getMenuInfo = (question) => {
61
+ let arr = [];
62
+
63
+ ninegrid.querySelectorAll("nx-side-menu-item[url][title]").forEach(elem => {
64
+ arr.push({
65
+ //menuId: elem.getAttribute("menu-id"),
66
+ url: elem.getAttribute("url"),
67
+ title: elem.getAttribute("title"),
68
+ })
69
+ });
70
+
71
+ return arr;
72
+ };
73
+
74
+ #getTableInfo = async (question) => {
75
+ const response = await fetch("/api/meta/tables", {
76
+ method: "POST",
77
+ headers: { "Content-Type": "application/json" },
78
+ body: JSON.stringify({
79
+ //filename: "HelloWorld.java",
80
+ //filename: "Test.jsx",
81
+ //content: js
82
+ })
83
+ });
84
+
85
+ console.log(response);
86
+
87
+ };
88
+
89
+
90
+ /**
91
+ * 1. 소스 명칭 package 예) tmpl.population
92
+ * 2. 소스가 없으면 소스 생성
93
+ * 3.
94
+ */
95
+ #generateSource = async (question) => {
96
+
97
+ const menuInfo = this.#getMenuInfo();
98
+ const tableInfo = await this.#getTableInfo();
99
+ };
100
+
101
+ #keydownHandler = async (e) => {
102
+ if (e.key !== "Enter") return;
103
+
104
+ e.preventDefault();
105
+
106
+ const question = e.target.value.trim();
107
+ if (!question) return;
108
+
109
+ if (this.#ing) return;
110
+ this.#ing = true;
111
+
112
+ /**
113
+ * setTimeout 없으면, 맥에서 한글 잔상이 남음
114
+ * setTimeout 내에서 e.target이 nx-ai-container가 된다.
115
+ */
116
+ setTimeout(() => {
117
+ this.shadowRoot.querySelector("textarea").value = "";
118
+ });
119
+
120
+ const elAiChat = this.shadowRoot.querySelector("nx-ai-chat");
121
+
122
+ elAiChat.add("me", question);
123
+ elAiChat.add("ing", question);
124
+
125
+ try {
126
+ this.#generateSource(question);
127
+ } catch (error) {
128
+ console.error(error);
129
+ elAiChat.add("ai", error);
130
+ }
131
+
132
+ /**
133
+ try {
134
+ const code = `
135
+ package tmpl.generated;
136
+
137
+ public class HelloWorld {
138
+ public String sayHello() {
139
+ return "Hello from generated class!";
140
+ }
141
+ }
142
+ `;
143
+
144
+ const js = `
145
+ const Home = () => {
146
+ const wrapStyle = {
147
+ backgroundColor: "white",
148
+ color: "black",
149
+ padding: "0px",
150
+ textAlign: "center",
151
+ fontSize: "18px",
152
+ height: "100%",
153
+ };
154
+
155
+ return (
156
+ <div style={wrapStyle}>
157
+ 11111
158
+ </div>
159
+ );
160
+ };
161
+
162
+ export default Home;
163
+ `;
164
+
165
+
166
+ await fetch("/api/files/js", {
167
+ method: "POST",
168
+ headers: { "Content-Type": "application/json" },
169
+ body: JSON.stringify({
170
+ //filename: "HelloWorld.java",
171
+ filename: "Test.jsx",
172
+ content: js
173
+ })
174
+ });
175
+ } catch (error) {
176
+ console.error(error);
177
+ //elAiChat.add("ai", error);
178
+ }
179
+ */
180
+
181
+ this.#ing = false;
182
+ }
183
+
184
+ #toggleCollapseHandler = () => {
185
+ this.classList.toggle("collapse");
186
+ };
187
+ }
188
+
189
+ customElements.define("ide-assi", ideAssi);
package/src/index.d.ts ADDED
File without changes
package/src/index.js CHANGED
@@ -1,8 +1 @@
1
- class HelloCard extends HTMLElement {
2
- connectedCallback() {
3
- this.innerHTML = `<div style="padding:1rem;border:1px solid #ddd;">
4
- 안녕하세요, <b>${this.getAttribute("name") ?? "게스트"}</b>!
5
- </div>`;
6
- }
7
- }
8
- customElements.define("hello-card", HelloCard);
1
+ import "./components/ideAssi.js";