@nine-lab/nine-mu 0.1.383 โ 0.1.385
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 +16 -8
- 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/hook/NineHook.js +16 -14
package/package.json
CHANGED
|
@@ -205,22 +205,21 @@ class NineExceptionHook extends React.Component {
|
|
|
205
205
|
// ==========================================
|
|
206
206
|
// ๐ฏ 3. ํต์ฌ: ์ธ๋ถ ์ฃผ์
ํ 404 ๋ผ์ฐํ
๊ธฐ๋ฅ ํ์ฌ
|
|
207
207
|
// ==========================================
|
|
208
|
-
|
|
208
|
+
// ==========================================
|
|
209
|
+
// ๐ฏ 3. ์ต์ข
์๊ฒฐ: ์์ ์ปดํฌ๋ํธ(children)๋ฅผ ์์ฉํ๋ ๊ตฌ์กฐ๋ก ๋ณ๊ฒฝ
|
|
210
|
+
// ==========================================
|
|
211
|
+
export function NineHook({ children, menuUrl, views, error404, onCatch, fallback, styles, containerStyle }) {
|
|
209
212
|
const [menuData, setMenuData] = useState([]);
|
|
210
213
|
|
|
211
|
-
// ๐ฏ 1. ๋ฐํ์ ๋์ fetch ํจ์ ๋ถ๋ฆฌ
|
|
212
214
|
const fetchRoutes = async () => {
|
|
213
215
|
if (!menuUrl) return;
|
|
214
216
|
try {
|
|
215
|
-
// ํ์์คํฌํ(?t=...)๋ฅผ ์ฃผ์ด ๋ธ๋ผ์ฐ์ ์บ์๋ฅผ ๋ฌด์กฐ๊ฑด ํ๊ดดํ๊ณ ํ๋๋์คํฌ์ ๋ ๊ฒ ํ์ผ ๋ด์ฉ์ ๊ฐ์ ธ์ด
|
|
216
217
|
const response = await fetch(`${menuUrl}?t=${Date.now()}`);
|
|
217
218
|
if (response.ok) {
|
|
218
219
|
const data = await response.json();
|
|
219
|
-
|
|
220
|
-
// ๐ก ๊ธฐ์กด ๋ฐ์ดํฐ์ ์๋ก ๊ฐ์ ธ์จ ๋ฐ์ดํฐ๊ฐ ๋ค๋ฅผ ๋๋ง ์ํ๋ฅผ ์
๋ฐ์ดํธํ์ฌ ๋ฌดํ ๋ฃจํ ๋ฐฉ์ง
|
|
221
220
|
setMenuData((prev) => {
|
|
222
221
|
if (JSON.stringify(prev) === JSON.stringify(data)) return prev;
|
|
223
|
-
console.log("๐ฅ [Nine-Library]
|
|
222
|
+
console.log("๐ฅ [Nine-Library] routes.json ๋ณ๊ฒฝ ๊ฐ์ง -> ์ ์ฒด ์์คํ
๋๊ธฐํ");
|
|
224
223
|
return data;
|
|
225
224
|
});
|
|
226
225
|
}
|
|
@@ -229,16 +228,10 @@ export function NineHook({ menuUrl, views, error404, onCatch, fallback, styles,
|
|
|
229
228
|
}
|
|
230
229
|
};
|
|
231
230
|
|
|
232
|
-
// ๐ฏ 2. ์ค์๊ฐ ๋ฐ์ํ ํธ๋ฆฌ๊ฑฐ ์์ง ์ฒด์ธ
|
|
233
231
|
useEffect(() => {
|
|
234
|
-
// ์ต์ด ๋ก๋ ์ ์คํ
|
|
235
232
|
fetchRoutes();
|
|
236
|
-
|
|
237
|
-
// ๐ก ํธ๋ฆฌ๊ฑฐ A: AI๊ฐ ์ฝ๋๋ฅผ ๊ณ ์น๊ณ ์ฃผ์๋ฅผ ๋ฐ๊ฟจ์ ๋(popstate/click) ์ฆ์ ๋๊ธฐํ
|
|
238
233
|
window.addEventListener('popstate', fetchRoutes);
|
|
239
234
|
document.addEventListener('click', fetchRoutes, true);
|
|
240
|
-
|
|
241
|
-
// ๐ก ํธ๋ฆฌ๊ฑฐ B: ์ฌ์ฉ์๊ฐ ๊ฐ๋งํ ์์ด๋ AI๊ฐ ๋ฐฑ์๋์์ ํ์ผ์ ์์ ํ๋ฉด 3์ด๋ง๋ค ์๋ ์ฒดํฌ (ํด๋ง)
|
|
242
235
|
const intervalId = setInterval(fetchRoutes, 3000);
|
|
243
236
|
|
|
244
237
|
return () => {
|
|
@@ -246,9 +239,17 @@ export function NineHook({ menuUrl, views, error404, onCatch, fallback, styles,
|
|
|
246
239
|
document.removeEventListener('click', fetchRoutes, true);
|
|
247
240
|
clearInterval(intervalId);
|
|
248
241
|
};
|
|
249
|
-
}, [menuUrl]);
|
|
242
|
+
}, [menuUrl]);
|
|
243
|
+
|
|
244
|
+
// ๐ฏ [ํต์ฌ ๊ต์ ]: ์ต์ด fetch๊ฐ ์๋ฃ๋๊ธฐ ์ (๋ฐ์ดํฐ๊ฐ ์์ ๋)์๋ ๋ ๋๋ง์ ์ ์ ๋ฉ์ถฅ๋๋ค.
|
|
245
|
+
if (!menuData || menuData.length === 0) {
|
|
246
|
+
return React.createElement(
|
|
247
|
+
'div',
|
|
248
|
+
{ style: { padding: '25px', color: '#666', fontFamily: 'monospace', background: '#121314', minHeight: '100vh' } },
|
|
249
|
+
'>> Initializing menu matrix telemetry...'
|
|
250
|
+
);
|
|
251
|
+
}
|
|
250
252
|
|
|
251
|
-
// ๋ฐ์ดํฐ๊ฐ ๋ก๋๋๊ณ ์ ์ ๋๋ฉด ๋์ ๋ผ์ฐํธ ๋งคํธ๋ฆญ์ค ์์ฑ
|
|
252
253
|
const dynamicRoutes = createDynamicRoutes(menuData, views, error404);
|
|
253
254
|
|
|
254
255
|
return React.createElement(
|
|
@@ -257,6 +258,7 @@ export function NineHook({ menuUrl, views, error404, onCatch, fallback, styles,
|
|
|
257
258
|
React.createElement(
|
|
258
259
|
NineExceptionHook,
|
|
259
260
|
{ onCatch, fallback, styles, containerStyle },
|
|
261
|
+
children,
|
|
260
262
|
React.createElement(
|
|
261
263
|
Suspense,
|
|
262
264
|
{ fallback: React.createElement('div', { style: { padding: '25px', color: '#666', fontFamily: 'monospace' } }, '>> Loading component matrix...') },
|