@nine-lab/nine-mu 0.1.390 → 0.1.392

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.390",
3
+ "version": "0.1.392",
4
4
  "description": "AI-Driven Full-Stack Code Fabrication Engine",
5
5
  "type": "module",
6
6
  "main": "./dist/nine-mu.umd.js",
@@ -1,5 +1,6 @@
1
1
  import React, { createContext, useEffect, useState, useContext, lazy, Suspense } from 'react';
2
2
  import { Route, Routes } from 'react-router-dom';
3
+ import { trace } from '@nopeer';
3
4
 
4
5
  // ==========================================
5
6
  // 1. 내부 기능 A: ScreenContext 및 구조
@@ -69,6 +70,8 @@ const createDynamicRoutes = (menuData, projectViews, Custom404) => {
69
70
  // 사용자 프로젝트 루트 기준 상대 경로 매핑
70
71
  const componentPath = `./views/${fullFolderPath}/${pascalName}.jsx`;
71
72
 
73
+ trace.log(componentPath);
74
+
72
75
  dynamicRoutes.push({
73
76
  path: menu.path,
74
77
  Component: lazyLoad(componentPath)
@@ -202,54 +205,8 @@ class NineExceptionHook extends React.Component {
202
205
  }
203
206
  }
204
207
 
205
- // ==========================================
206
- // 🎯 3. 핵심: 외부 주입형 404 라우팅 기능 탑재
207
- // ==========================================
208
- // ==========================================
209
- // 🎯 3. 최종 완결: 자식 컴포넌트(children)를 수용하는 구조로 변경
210
- // ==========================================
211
- export function NineHook({ children, menuUrl, views, error404, onCatch, fallback, styles, containerStyle }) {
212
- const [menuData, setMenuData] = useState([]);
213
-
214
- const fetchRoutes = async () => {
215
- if (!menuUrl) return;
216
- try {
217
- const response = await fetch(`${menuUrl}?t=${Date.now()}`);
218
- if (response.ok) {
219
- const data = await response.json();
220
- setMenuData((prev) => {
221
- if (JSON.stringify(prev) === JSON.stringify(data)) return prev;
222
- console.log("🔥 [Nine-Library] routes.json 변경 감지 -> 전체 시스템 동기화");
223
- return data;
224
- });
225
- }
226
- } catch (e) {
227
- console.error("[Nine-Library] 런타임 메뉴 동기화 실패:", e);
228
- }
229
- };
230
-
231
- useEffect(() => {
232
- fetchRoutes();
233
- window.addEventListener('popstate', fetchRoutes);
234
- document.addEventListener('click', fetchRoutes, true);
235
- const intervalId = setInterval(fetchRoutes, 3000);
236
-
237
- return () => {
238
- window.removeEventListener('popstate', fetchRoutes);
239
- document.removeEventListener('click', fetchRoutes, true);
240
- clearInterval(intervalId);
241
- };
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
- }
252
-
208
+ export function NineHook({ children, menuData, views, error404, onCatch, fallback, styles, containerStyle }) {
209
+ // 🎯 꼼수 완전 제거: 오직 주입받은 menuData가 변경될 때만 리액트가 라우터를 동적 재구성
253
210
  const dynamicRoutes = createDynamicRoutes(menuData, views, error404);
254
211
 
255
212
  return React.createElement(
@@ -258,8 +215,12 @@ export function NineHook({ children, menuUrl, views, error404, onCatch, fallback
258
215
  React.createElement(
259
216
  NineExceptionHook,
260
217
  { onCatch, fallback, styles, containerStyle },
218
+
219
+ // LeftMenu 레이아웃 자식 출력 (부팅 딜레이 없이 즉시 렌더링)
261
220
  children,
262
- React.createElement(
221
+
222
+ // 데이터가 존재할 때 정석대로 라우터 구역 활성화
223
+ menuData && menuData.length > 0 ? React.createElement(
263
224
  Suspense,
264
225
  { fallback: React.createElement('div', { style: { padding: '25px', color: '#666', fontFamily: 'monospace' } }, '>> Loading component matrix...') },
265
226
  React.createElement(
@@ -273,7 +234,7 @@ export function NineHook({ children, menuUrl, views, error404, onCatch, fallback
273
234
  })
274
235
  )
275
236
  )
276
- )
237
+ ) : React.createElement('div', { style: { padding: '25px', color: '#444', fontFamily: 'monospace' } }, '>> Database route matrix empty.')
277
238
  )
278
239
  );
279
240
  }