@nine-lab/nine-mu 0.1.28 → 0.1.30

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.28",
3
+ "version": "0.1.30",
4
4
  "description": "AI-Driven Full-Stack Code Fabrication Engine",
5
5
  "type": "module",
6
6
  "main": "./dist/nine-mu.umd.js",
@@ -813,10 +813,16 @@
813
813
  cursor: pointer;
814
814
  outline: none;
815
815
  }
816
- }
817
-
818
- :host(nine-diff-container) {
819
816
 
817
+ nx-dialog { --dialog-width: 90vw; --dialog-height: 85vh; }
818
+ .main-layout { width: 100%; height: 100%; display: flex; flex-direction: column; }
819
+ .diff-area { flex: 1; min-height: 0; border: 1px solid #ddd; }
820
+ .footer {
821
+ display: flex; justify-content: flex-end; gap: 10px;
822
+ padding: 12px; background: #f9f9f9; border-top: 1px solid #eee;
823
+ }
824
+ .btn { padding: 8px 20px; cursor: pointer; border-radius: 4px; border: 1px solid #ccc; font-weight: bold; }
825
+ .btn-confirm { background: #007bff; color: white; border: none; }
820
826
  }
821
827
 
822
828
  :host(nine-diff) {
@@ -1,9 +1,10 @@
1
1
  import { trace } from '@nine-lab/nine-util';
2
2
 
3
3
  export class NineDiffPopup extends HTMLElement {
4
- #container = null;
5
4
  #dialog = null;
5
+ #diffView = null; // Container 대신 직접 에디터 뷰를 참조
6
6
  #resolve = null;
7
+ #asisBackup = "";
7
8
 
8
9
  constructor() {
9
10
  super();
@@ -17,62 +18,51 @@ export class NineDiffPopup extends HTMLElement {
17
18
  render() {
18
19
  this.shadowRoot.innerHTML = `
19
20
  <style>
20
- @import "https://cdn.jsdelivr.net/npm/@nine-lab/nine-ai@${__APP_VERSION__}/dist/css/nine-ai.css";
21
- /* nx-dialog 내부 스타일 조정 */
22
- nx-dialog { --dialog-width: 90vw; --dialog-height: 85vh; }
23
- .footer {
24
- display: flex;
25
- justify-content: flex-end;
26
- gap: 10px;
27
- padding: 15px;
28
- background: #f9f9f9;
29
- border-top: 1px solid #ddd;
30
- }
31
- .btn { padding: 8px 20px; cursor: pointer; border-radius: 4px; border: 1px solid #ccc; }
32
- .btn.primary { background: #007bff; color: white; border: none; }
21
+ @import "https://cdn.jsdelivr.net/npm/@nine-lab/nine-mu@${__APP_VERSION__}/dist/css/nine-mu.css";
33
22
  </style>
34
23
 
35
24
  <nx-dialog>
36
- <div style="width: 100%; height: 100%; display: flex; flex-direction: column;">
37
- <div style="flex: 1; min-height: 0;">
38
- <nine-diff-container id="diff-container"></nine-diff-container>
25
+ <div class="main-layout">
26
+ <div class="diff-area">
27
+ <nine-diff id="editor"></nine-diff>
39
28
  </div>
40
29
  <div class="footer">
41
30
  <button class="btn btn-cancel">취소</button>
42
- <button class="btn btn-confirm primary">최종 확정 및 저장</button>
31
+ <button class="btn btn-confirm">최종 확정 및 저장</button>
43
32
  </div>
44
33
  </div>
45
34
  </nx-dialog>
46
35
  `;
47
36
 
48
37
  this.#dialog = this.shadowRoot.querySelector('nx-dialog');
49
- this.#container = this.shadowRoot.querySelector('#diff-container');
38
+ this.#diffView = this.shadowRoot.querySelector('#editor');
50
39
 
51
- // 버튼 이벤트 바인딩
52
40
  this.shadowRoot.querySelector('.btn-confirm').onclick = () => this.#handleConfirm();
53
41
  this.shadowRoot.querySelector('.btn-cancel').onclick = () => this.#handleCancel();
54
42
  }
55
43
 
56
- /**
57
- * 외부 호출용 팝업 실행 메서드
58
- * @param {Object} diffData - { asis, tobe, lang }
59
- * @returns {Promise<string|null>} - 확정 시 수정된 텍스트, 취소 시 null
60
- */
61
- async popup(diffData) {
44
+ async popup(data) {
62
45
  return new Promise((resolve) => {
63
46
  this.#resolve = resolve;
47
+ this.#asisBackup = data?.asis || "";
48
+
49
+ // 에디터 초기화 (Container가 하던 일)
50
+ if (this.#diffView) {
51
+ const asisStr = typeof data.asis === 'object' ? JSON.stringify(data.asis, null, 2) : data.asis;
52
+ const tobeStr = typeof data.tobe === 'object' ? JSON.stringify(data.tobe, null, 2) : data.tobe;
53
+ this.#diffView.initialize(asisStr, tobeStr, data.lang || "javascript");
54
+ }
64
55
 
65
- // 데이터 설정 및 팝업 표시
66
- this.#container.setData(diffData);
67
56
  this.#dialog.showModal();
68
57
  });
69
58
  }
70
59
 
71
60
  #handleConfirm() {
72
- const finalContent = this.#container.getContents();
61
+ // 에디터에서 직접 콘텐츠 추출
62
+ const finalContent = this.#diffView ? this.#diffView.getContents() : this.#asisBackup;
73
63
  this.#dialog.close();
74
64
  if (this.#resolve) this.#resolve(finalContent);
75
- this.remove(); // 사용 후 제거
65
+ this.remove();
76
66
  }
77
67
 
78
68
  #handleCancel() {
@@ -82,6 +72,4 @@ export class NineDiffPopup extends HTMLElement {
82
72
  }
83
73
  }
84
74
 
85
- if (!customElements.get("nine-diff-popup")) {
86
- customElements.define("nine-diff-popup", NineDiffPopup);
87
- }
75
+ customElements.define("nine-diff-popup", NineDiffPopup);
package/src/index.js CHANGED
@@ -1,7 +1,6 @@
1
1
  import { trace } from '@nine-lab/nine-util';
2
2
  import { NineChat } from './components/NineChat.js';
3
3
  import { NineDiff } from './components/NineDiff.js';
4
- import { NineDiffContainer } from './components/NineDiffContainer.js';
5
4
  import { NineDiffPopup } from './components/NineDiffPopup.js';
6
5
  import { NineDialog } from './components/NineDialog.js';
7
6
 
@@ -18,4 +17,4 @@ export const NineMu = {
18
17
 
19
18
  // 기본 export 및 컴포넌트 export
20
19
  export default NineMu;
21
- export { NineChat, NineDiff, NineDiffContainer, NineDialog, NineDiffPopup };
20
+ export { NineChat, NineDiff, NineDialog, NineDiffPopup };
@@ -1,58 +0,0 @@
1
- export class NineDiffContainer extends HTMLElement {
2
- #asis = "";
3
- #tobe = "";
4
- #lang = "javascript";
5
- #diffView = null;
6
-
7
- constructor() {
8
- super();
9
- this.attachShadow({ mode: 'open' });
10
- }
11
-
12
- /**
13
- * 단일 비교 데이터를 설정합니다.
14
- * @param {Object} data - { asis, tobe, lang }
15
- */
16
- setData = (data) => {
17
-
18
- try {
19
- this.#asis = data?.asis || "";
20
- this.#tobe = data?.tobe || "";
21
- this.#lang = data?.lang || "";
22
- } catch (e) {}
23
-
24
-
25
- this.render();
26
- }
27
-
28
- // 최종 결과물(사용자가 편집한 ASIS 내용)을 가져옵니다.
29
- getContents = () => {
30
- return this.#diffView ? this.#diffView.getContents() : this.#asis;
31
- }
32
-
33
- render() {
34
- const customImport = this.getAttribute("css-path") ? `@import "${this.getAttribute("css-path")}";` : "";
35
-
36
- this.shadowRoot.innerHTML = `
37
- <style>
38
- @import "https://cdn.jsdelivr.net/npm/@nine-lab/nine-mu@${__APP_VERSION__}/dist/css/nine-mu.css";
39
- ${customImport}
40
- </style>
41
-
42
- <div class="diff-wrapper">
43
- <nine-diff id="single-diff"></nine-diff>
44
- </div>
45
- `;
46
-
47
- this.#diffView = this.shadowRoot.querySelector('#single-diff');
48
-
49
- // 데이터 주입 (DOM이 렌더링된 직후 실행)
50
- if (this.#diffView) {
51
- this.#diffView.initialize(this.#asis, this.#tobe, this.#lang);
52
- }
53
- }
54
- }
55
-
56
- if (!customElements.get("nine-diff-container")) {
57
- customElements.define("nine-diff-container", NineDiffContainer);
58
- }