@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/dist/nine-mu.js +54 -18
- package/dist/nine-mu.js.map +1 -1
- package/dist/nine-mu.umd.js +1 -1
- package/dist/nine-mu.umd.js.map +1 -1
- package/package.json +1 -1
- package/src/components/NineChat.js +1 -1
- package/src/components/NineDiffPopup.js +44 -1
package/package.json
CHANGED
|
@@ -44,11 +44,13 @@ export class NineDiffPopup extends HTMLElement {
|
|
|
44
44
|
this.shadowRoot.querySelector('.btn-cancel').onclick = () => this.#handleCancel();
|
|
45
45
|
}
|
|
46
46
|
|
|
47
|
-
|
|
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;
|