@nine-lab/nine-mu 0.1.41 → 0.1.43
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 +71 -19
- 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 +10 -2
- package/src/components/NineDiff.js +15 -0
- package/src/components/NineDiffPopup.js +44 -1
package/dist/nine-mu.js
CHANGED
|
@@ -106,8 +106,13 @@ class NineChat extends HTMLElement {
|
|
|
106
106
|
__privateAdd(this, _service, null);
|
|
107
107
|
__privateAdd(this, _routes, []);
|
|
108
108
|
__privateAdd(this, _diffPopup);
|
|
109
|
-
|
|
110
|
-
|
|
109
|
+
/**
|
|
110
|
+
* 소스 비교 팝업을 띄우고 사용자의 최종 확정 본을 반환합니다.
|
|
111
|
+
* @param {Object} params - { asis, tobe, lang }
|
|
112
|
+
* @returns {Promise<string|null>} - 확정 시 소스코드, 취소 시 null
|
|
113
|
+
*/
|
|
114
|
+
__publicField(this, "showDiff", async ({ asis, tobe, lang }) => {
|
|
115
|
+
return await __privateGet(this, _diffPopup).popup().data(asis, tobe, lang).wait();
|
|
111
116
|
});
|
|
112
117
|
this.attachShadow({ mode: "open" });
|
|
113
118
|
}
|
|
@@ -183,7 +188,7 @@ render_fn = function() {
|
|
|
183
188
|
const customImport = this.getAttribute("css-path") ? `@import "${this.getAttribute("css-path")}";` : "";
|
|
184
189
|
this.shadowRoot.innerHTML = `
|
|
185
190
|
<style>
|
|
186
|
-
@import "https://cdn.jsdelivr.net/npm/@nine-lab/nine-mu@${"0.1.
|
|
191
|
+
@import "https://cdn.jsdelivr.net/npm/@nine-lab/nine-mu@${"0.1.42"}/dist/css/nine-mu.css";
|
|
187
192
|
${customImport}
|
|
188
193
|
</style>
|
|
189
194
|
<div class="wrapper">
|
|
@@ -26117,6 +26122,13 @@ class NineDiff extends HTMLElement {
|
|
|
26117
26122
|
return __privateGet(this, _tobeEditorView) ? __privateGet(this, _tobeEditorView).state.doc.toString() : "";
|
|
26118
26123
|
});
|
|
26119
26124
|
__privateAdd(this, _initCodeMirror, () => {
|
|
26125
|
+
let asisReady = false;
|
|
26126
|
+
let tobeReady = false;
|
|
26127
|
+
const checkAllReady = () => {
|
|
26128
|
+
if (asisReady && tobeReady) {
|
|
26129
|
+
this.dispatchEvent(new CustomEvent("ready", { bubbles: true, composed: true }));
|
|
26130
|
+
}
|
|
26131
|
+
};
|
|
26120
26132
|
__privateSet(this, _asisEditorEl, this.shadowRoot.querySelector(".panel.asis"));
|
|
26121
26133
|
__privateSet(this, _tobeEditorEl, this.shadowRoot.querySelector(".panel.tobe"));
|
|
26122
26134
|
if (!__privateGet(this, _asisEditorEl) || !__privateGet(this, _tobeEditorEl)) {
|
|
@@ -26162,6 +26174,8 @@ class NineDiff extends HTMLElement {
|
|
|
26162
26174
|
if (update.view.contentDOM.firstChild && !update.view._initialAsisContentLoaded) {
|
|
26163
26175
|
update.view._initialAsisContentLoaded = true;
|
|
26164
26176
|
trace.log("CodeMirror ASIS view is ready for initial content.");
|
|
26177
|
+
asisReady = true;
|
|
26178
|
+
checkAllReady();
|
|
26165
26179
|
}
|
|
26166
26180
|
})
|
|
26167
26181
|
]
|
|
@@ -26182,6 +26196,8 @@ class NineDiff extends HTMLElement {
|
|
|
26182
26196
|
if (update.view.contentDOM.firstChild && !update.view._initialTobeContentLoaded) {
|
|
26183
26197
|
update.view._initialTobeContentLoaded = true;
|
|
26184
26198
|
trace.log("CodeMirror TOBE view is ready for initial content.");
|
|
26199
|
+
tobeReady = true;
|
|
26200
|
+
checkAllReady();
|
|
26185
26201
|
}
|
|
26186
26202
|
})
|
|
26187
26203
|
]
|
|
@@ -26385,7 +26401,7 @@ class NineDiff extends HTMLElement {
|
|
|
26385
26401
|
const customImport = this.getAttribute("css-path") ? `@import "${this.getAttribute("css-path")}";` : "";
|
|
26386
26402
|
this.shadowRoot.innerHTML = `
|
|
26387
26403
|
<style>
|
|
26388
|
-
@import "https://cdn.jsdelivr.net/npm/@nine-lab/nine-mu@${"0.1.
|
|
26404
|
+
@import "https://cdn.jsdelivr.net/npm/@nine-lab/nine-mu@${"0.1.42"}/dist/css/nine-mu.css";
|
|
26389
26405
|
${customImport}
|
|
26390
26406
|
</style>
|
|
26391
26407
|
|
|
@@ -26450,7 +26466,7 @@ class NineDiffPopup extends HTMLElement {
|
|
|
26450
26466
|
const customImport = this.getAttribute("css-path") ? `@import "${this.getAttribute("css-path")}";` : "";
|
|
26451
26467
|
this.shadowRoot.innerHTML = `
|
|
26452
26468
|
<style>
|
|
26453
|
-
@import "https://cdn.jsdelivr.net/npm/@nine-lab/nine-mu@${"0.1.
|
|
26469
|
+
@import "https://cdn.jsdelivr.net/npm/@nine-lab/nine-mu@${"0.1.42"}/dist/css/nine-mu.css";
|
|
26454
26470
|
${customImport}
|
|
26455
26471
|
</style>
|
|
26456
26472
|
|
|
@@ -26471,19 +26487,55 @@ class NineDiffPopup extends HTMLElement {
|
|
|
26471
26487
|
this.shadowRoot.querySelector(".btn-confirm").onclick = () => __privateMethod(this, _NineDiffPopup_instances, handleConfirm_fn).call(this);
|
|
26472
26488
|
this.shadowRoot.querySelector(".btn-cancel").onclick = () => __privateMethod(this, _NineDiffPopup_instances, handleCancel_fn).call(this);
|
|
26473
26489
|
}
|
|
26474
|
-
|
|
26475
|
-
|
|
26476
|
-
|
|
26477
|
-
|
|
26478
|
-
|
|
26479
|
-
|
|
26480
|
-
|
|
26481
|
-
|
|
26482
|
-
|
|
26483
|
-
|
|
26484
|
-
|
|
26485
|
-
|
|
26486
|
-
|
|
26490
|
+
/**
|
|
26491
|
+
async popup1(data) {
|
|
26492
|
+
return new Promise((resolve) => {
|
|
26493
|
+
this.#resolve = resolve;
|
|
26494
|
+
this.#asisBackup = data?.asis || "";
|
|
26495
|
+
|
|
26496
|
+
|
|
26497
|
+
// 💡 에디터가 준비되었다는 신호를 받으면 데이터 주입
|
|
26498
|
+
this.#diffView.addEventListener('ready', () => {
|
|
26499
|
+
trace.log("NineDiff is Ready! Injecting data...");
|
|
26500
|
+
|
|
26501
|
+
const asisStr = typeof data.asis === 'object' ? JSON.stringify(data.asis, null, 2) : data.asis;
|
|
26502
|
+
const tobeStr = typeof data.tobe === 'object' ? JSON.stringify(data.tobe, null, 2) : data.tobe;
|
|
26503
|
+
|
|
26504
|
+
trace.log(asisStr, tobeStr);
|
|
26505
|
+
|
|
26506
|
+
this.#diffView.initialize(asisStr, tobeStr, data.lang);
|
|
26507
|
+
}, { once: true }); // 딱 한 번만 실행
|
|
26508
|
+
|
|
26509
|
+
this.#dialog.showModal();
|
|
26510
|
+
});
|
|
26511
|
+
} */
|
|
26512
|
+
popup() {
|
|
26513
|
+
__privateGet(this, _dialog).showModal();
|
|
26514
|
+
return this;
|
|
26515
|
+
}
|
|
26516
|
+
async data(asis, tobe, lang = "javascript") {
|
|
26517
|
+
let finalAsis = asis;
|
|
26518
|
+
const isRemote = typeof asis === "string" && (asis.startsWith("url:") || asis.startsWith("file:"));
|
|
26519
|
+
if (isRemote) {
|
|
26520
|
+
const targetUrl = asis.replace(/^(url:|file:)/, "");
|
|
26521
|
+
try {
|
|
26522
|
+
trace.log(`📡 원격 소스 로드 시도: ${targetUrl}`);
|
|
26523
|
+
const res = await fetch(targetUrl);
|
|
26524
|
+
if (!res.ok) throw new Error(`HTTP error! status: ${res.status}`);
|
|
26525
|
+
finalAsis = await res.text();
|
|
26526
|
+
} catch (e) {
|
|
26527
|
+
trace.error(`파일 로드 실패 [${targetUrl}]:`, e);
|
|
26528
|
+
finalAsis = `// 파일을 불러오는데 실패했습니다.
|
|
26529
|
+
// 경로: ${targetUrl}`;
|
|
26530
|
+
}
|
|
26531
|
+
}
|
|
26532
|
+
__privateSet(this, _asisBackup, finalAsis);
|
|
26533
|
+
__privateGet(this, _diffView).addEventListener("ready", () => {
|
|
26534
|
+
const asisStr = typeof finalAsis === "object" ? JSON.stringify(finalAsis, null, 2) : finalAsis;
|
|
26535
|
+
const tobeStr = typeof tobe === "object" ? JSON.stringify(tobe, null, 2) : tobe;
|
|
26536
|
+
__privateGet(this, _diffView).initialize(asisStr, tobeStr, lang);
|
|
26537
|
+
}, { once: true });
|
|
26538
|
+
return this;
|
|
26487
26539
|
}
|
|
26488
26540
|
}
|
|
26489
26541
|
_dialog = new WeakMap();
|
|
@@ -26595,7 +26647,7 @@ if (!customElements.get("nine-dialog")) {
|
|
|
26595
26647
|
customElements.define("nine-dialog", NineDialog);
|
|
26596
26648
|
}
|
|
26597
26649
|
const NineMu = {
|
|
26598
|
-
version: "0.1.
|
|
26650
|
+
version: "0.1.42",
|
|
26599
26651
|
init: (config) => {
|
|
26600
26652
|
trace.log("🛠️ Nine-Mu Engine initialized", config);
|
|
26601
26653
|
}
|