Files
invyone/frontend/lib/dataPort/runtime.ts
T
gbpark 1aa48cc0bb INVYONE 화면 디자이너 개편 + 컴포넌트 86→8 통합
## 디자인 개편
- IDE 톤 CSS 오버라이드 (builder-ide.css)
- 컴팩트화 (폰트/간격/패딩 축소)
- INVYONE STUDIO 로고 추가 (SlimToolbar)
- 좌측 수평 탭 → 수직 아코디언 (details/summary)
- 우측 속성 패널 신설 (V2PropertiesPanel 완전 이주)
- 다크모드 지원 (7개 통합 컴포넌트 inline hex → CSS 변수)

## 기반 시스템
- ScreenDefinition.fields/connections 타입 확장
- ComponentDefinition.dataPorts 타입 확장
- FieldConfig adapters (fieldsToColumns/Search/Form)
- DataPortBus + setupConnections runtime
- FieldsPanel (화면 수준 필드 관리 패널)

## 컴포넌트 통합 (Phase A~C)
- divider (3→1): 가로/세로 + 텍스트 구분선
- title (2→1): h1~h6/body/caption variant
- button (3→1): 6 variant × 13 actionType
- search (3→1): inline/stacked 검색 필터
- input (20+→1): FieldConfig.type 10종 내부 분기
- stats (6→1): card/chip/bigNumber 3종 스타일
- table (9→1): table/split/grouped/pivot/card 5종 displayMode
- container (11→1): tabs/section/accordion/repeater/conditional 5종

## 버그 수정 (기존 VEX 코드)
- 드래그 드롭 불가 (defaultSize camelCase 불일치)
- 설정 변경 미반영 (componentConfig vs component_config)
- ConfigPanel 미인식 (config_panel vs configPanel)
- v2- 자동 매핑 함정 (INVYONE_UNIFIED_IDS 화이트리스트)
- LayerManagerPanel 무한 API 호출 (useEffect deps)
- Button size 이름 충돌 (visual size 객체 vs config string)

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-04-12 20:37:23 +09:00

59 lines
1.8 KiB
TypeScript

/**
* DataPort Runtime — Connection 배열을 DataPortBus 브리지로 풀어주는 함수.
*
* 사용 시점:
* 화면 렌더러가 Screen(혹은 Template) 을 마운트할 때 setupConnections 를
* 호출하고, 반환된 cleanup 함수를 언마운트 시 호출한다.
*
* 동작:
* 각 Connection 에 대해
* 1. from 컴포넌트의 output 채널을 구독
* 2. 값이 들어오면 to 컴포넌트의 input 채널로 publish
* 즉 화면 수준 Connection 선언을 런타임 브리지로 풀어준다.
*
* 컴포넌트 쪽 책임:
* - 각 v2-* 컴포넌트는 자기 outputs 포트에 값이 생기면 DataPortBus 에 publish
* - inputs 포트는 subscribe 해서 값이 오면 처리
* 이 파일은 그 둘을 중간에서 연결만 한다.
*/
import type { Connection } from "@/types/invyone-component";
import { DataPortBus } from "./DataPortBus";
/**
* Connection[] 을 DataPortBus 브리지로 변환.
*
* @param connections 화면/템플릿에 선언된 포트 연결 목록
* @param bus 연결을 걸 대상 DataPortBus 인스턴스
* @returns cleanup 함수. 화면 언마운트 시 반드시 호출 (메모리 누수 방지).
*/
export function setupConnections(
connections: Connection[] | undefined,
bus: DataPortBus,
): () => void {
if (!connections || connections.length === 0) {
return () => {};
}
const unsubs: Array<() => void> = [];
for (const conn of connections) {
const fromChannel = DataPortBus.channelOf(
conn.from.componentId,
conn.from.port,
);
const toChannel = DataPortBus.channelOf(
conn.to.componentId,
conn.to.port,
);
const unsub = bus.subscribe(fromChannel, (value) => {
bus.publish(toChannel, value);
});
unsubs.push(unsub);
}
return () => {
unsubs.forEach((u) => u());
};
}