@nine-lab/nine-mu 0.1.42 β†’ 0.1.44

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.42",
3
+ "version": "0.1.44",
4
4
  "description": "AI-Driven Full-Stack Code Fabrication Engine",
5
5
  "type": "module",
6
6
  "main": "./dist/nine-mu.umd.js",
@@ -142,7 +142,7 @@ export class NineChat extends HTMLElement {
142
142
  }
143
143
 
144
144
  showDiff = (data) => {
145
- this.#diffPopup.popup(data);
145
+ this.#diffPopup.popup().data(data);
146
146
  }
147
147
  }
148
148
 
@@ -44,11 +44,13 @@ export class NineDiffPopup extends HTMLElement {
44
44
  this.shadowRoot.querySelector('.btn-cancel').onclick = () => this.#handleCancel();
45
45
  }
46
46
 
47
- async popup(data) {
47
+ /**
48
+ async popup1(data) {
48
49
  return new Promise((resolve) => {
49
50
  this.#resolve = resolve;
50
51
  this.#asisBackup = data?.asis || "";
51
52
 
53
+
52
54
  // πŸ’‘ 에디터가 μ€€λΉ„λ˜μ—ˆλ‹€λŠ” μ‹ ν˜Έλ₯Ό λ°›μœΌλ©΄ 데이터 μ£Όμž…
53
55
  this.#diffView.addEventListener('ready', () => {
54
56
  trace.log("NineDiff is Ready! Injecting data...");
@@ -63,8 +65,49 @@ export class NineDiffPopup extends HTMLElement {
63
65
 
64
66
  this.#dialog.showModal();
65
67
  });
68
+ } */
69
+
70
+ popup() {
71
+ // μ΄ˆκΈ°ν™”
72
+ this.#dialog.showModal();
73
+
74
+ return this;
66
75
  }
67
76
 
77
+ async data(asis, tobe, lang = "javascript") {
78
+ let finalAsis = asis;
79
+
80
+ // 1. μ•½μ†λœ 접두어 감지 (url: λ˜λŠ” file:)
81
+ const isRemote = typeof asis === 'string' && (asis.startsWith('url:') || asis.startsWith('file:'));
82
+
83
+ if (isRemote) {
84
+ // 접두어λ₯Ό μ œκ±°ν•˜κ³  μ‹€μ œ 경둜만 μΆ”μΆœ
85
+ const targetUrl = asis.replace(/^(url:|file:)/, '');
86
+
87
+ try {
88
+ trace.log(`πŸ“‘ 원격 μ†ŒμŠ€ λ‘œλ“œ μ‹œλ„: ${targetUrl}`);
89
+ const res = await fetch(targetUrl);
90
+ if (!res.ok) throw new Error(`HTTP error! status: ${res.status}`);
91
+ finalAsis = await res.text();
92
+ } catch (e) {
93
+ trace.error(`파일 λ‘œλ“œ μ‹€νŒ¨ [${targetUrl}]:`, e);
94
+ finalAsis = `// νŒŒμΌμ„ λΆˆλŸ¬μ˜€λŠ”λ° μ‹€νŒ¨ν–ˆμŠ΅λ‹ˆλ‹€.\n// 경둜: ${targetUrl}`;
95
+ }
96
+ }
97
+
98
+ // 2. 에디터 μ€€λΉ„ λŒ€κΈ° 및 μ΄ˆκΈ°ν™”
99
+ this.#asisBackup = finalAsis;
100
+ this.#diffView.addEventListener('ready', () => {
101
+ const asisStr = typeof finalAsis === 'object' ? JSON.stringify(finalAsis, null, 2) : finalAsis;
102
+ const tobeStr = typeof tobe === 'object' ? JSON.stringify(tobe, null, 2) : tobe;
103
+
104
+ this.#diffView.initialize(asisStr, tobeStr, lang);
105
+ }, { once: true });
106
+
107
+ return this;
108
+ }
109
+
110
+
68
111
  #handleConfirm() {
69
112
  // μ—λ””ν„°μ—μ„œ 직접 μ½˜ν…μΈ  μΆ”μΆœ
70
113
  const finalContent = this.#diffView ? this.#diffView.getContents() : this.#asisBackup;