@lodado/sdui-template 1.0.0

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.
Files changed (51) hide show
  1. package/LICENCE +8 -0
  2. package/README.md +462 -0
  3. package/dist/cjs/client/index.cjs +1 -0
  4. package/dist/es/client/src/components/componentMap.mjs +2 -0
  5. package/dist/es/client/src/index.mjs +1 -0
  6. package/dist/es/client/src/react-wrapper/components/SduiLayoutRenderer.mjs +2 -0
  7. package/dist/es/client/src/react-wrapper/context/SduiLayoutContext.mjs +2 -0
  8. package/dist/es/client/src/react-wrapper/hooks/useRenderNode.mjs +2 -0
  9. package/dist/es/client/src/react-wrapper/hooks/useSduiLayoutAction.mjs +2 -0
  10. package/dist/es/client/src/react-wrapper/hooks/useSduiNodeSubscription.mjs +2 -0
  11. package/dist/es/client/src/store/SduiLayoutStore.mjs +1 -0
  12. package/dist/es/client/src/store/errors.mjs +1 -0
  13. package/dist/es/client/src/store/managers/DocumentManager.mjs +1 -0
  14. package/dist/es/client/src/store/managers/LayoutStateRepository.mjs +1 -0
  15. package/dist/es/client/src/store/managers/SubscriptionManager.mjs +1 -0
  16. package/dist/es/client/src/store/managers/VariablesManager.mjs +1 -0
  17. package/dist/es/client/src/utils/normalize/denormalize.mjs +1 -0
  18. package/dist/es/client/src/utils/normalize/normalize.mjs +1 -0
  19. package/dist/types/index.d.ts +1 -0
  20. package/dist/types/setupTests.d.ts +1 -0
  21. package/dist/types/src/components/componentMap.d.ts +15 -0
  22. package/dist/types/src/components/index.d.ts +7 -0
  23. package/dist/types/src/components/types.d.ts +18 -0
  24. package/dist/types/src/index.d.ts +38 -0
  25. package/dist/types/src/react-wrapper/components/SduiLayoutRenderer.d.ts +62 -0
  26. package/dist/types/src/react-wrapper/components/index.d.ts +6 -0
  27. package/dist/types/src/react-wrapper/context/SduiLayoutContext.d.ts +37 -0
  28. package/dist/types/src/react-wrapper/context/index.d.ts +6 -0
  29. package/dist/types/src/react-wrapper/hooks/index.d.ts +8 -0
  30. package/dist/types/src/react-wrapper/hooks/useRenderNode.d.ts +10 -0
  31. package/dist/types/src/react-wrapper/hooks/useSduiLayoutAction.d.ts +15 -0
  32. package/dist/types/src/react-wrapper/hooks/useSduiNodeSubscription.d.ts +45 -0
  33. package/dist/types/src/react-wrapper/index.d.ts +8 -0
  34. package/dist/types/src/schema/base.d.ts +44 -0
  35. package/dist/types/src/schema/document.d.ts +16 -0
  36. package/dist/types/src/schema/index.d.ts +8 -0
  37. package/dist/types/src/schema/node.d.ts +19 -0
  38. package/dist/types/src/store/SduiLayoutStore.d.ts +192 -0
  39. package/dist/types/src/store/errors.d.ts +37 -0
  40. package/dist/types/src/store/index.d.ts +8 -0
  41. package/dist/types/src/store/managers/DocumentManager.d.ts +67 -0
  42. package/dist/types/src/store/managers/LayoutStateRepository.d.ts +110 -0
  43. package/dist/types/src/store/managers/SubscriptionManager.d.ts +48 -0
  44. package/dist/types/src/store/managers/VariablesManager.d.ts +38 -0
  45. package/dist/types/src/store/managers/index.d.ts +9 -0
  46. package/dist/types/src/store/types.d.ts +46 -0
  47. package/dist/types/src/utils/normalize/denormalize.d.ts +24 -0
  48. package/dist/types/src/utils/normalize/index.d.ts +8 -0
  49. package/dist/types/src/utils/normalize/normalize.d.ts +28 -0
  50. package/dist/types/src/utils/normalize/types.d.ts +15 -0
  51. package/package.json +89 -0
@@ -0,0 +1,62 @@
1
+ /**
2
+ * SDUI Layout Renderer
3
+ *
4
+ * SDUI Layout Document를 받아서 전체 UI를 렌더링하는 최상위 컴포넌트입니다.
5
+ * Render Props Pattern: renderNode 함수를 정의하고 하위 컴포넌트에 주입합니다.
6
+ *
7
+ * @param document - SDUI Layout Document (required)
8
+ * @param components - Custom component map (optional, merged with defaults)
9
+ * @param componentOverrides - Component overrides by ID or type (optional, ID > type priority)
10
+ * @param onLayoutChange - Callback when layout changes (optional)
11
+ * @param onError - Error callback (optional)
12
+ *
13
+ * @example
14
+ * ```tsx
15
+ * <SduiLayoutRenderer
16
+ * document={myDocument}
17
+ * components={{ CustomChart: CustomChartFactory }}
18
+ * onError={(error) => console.error(error)}
19
+ * />
20
+ * ```
21
+ *
22
+ * @remarks
23
+ * - Must be wrapped with "use client" directive in Next.js App Router
24
+ * - Component overrides: byNodeId > byNodeType > defaultComponentFactory
25
+ * - Errors are passed to onError callback, component continues rendering if possible
26
+ */
27
+ import React from 'react';
28
+ import type { ComponentFactory } from '../../components/types';
29
+ import type { SduiLayoutDocument } from '../../schema';
30
+ interface SduiLayoutRendererProps {
31
+ /** SDUI Layout Document */
32
+ document: SduiLayoutDocument;
33
+ /** 커스텀 컴포넌트 맵 (componentMap에 추가될 컴포넌트들) */
34
+ components?: Record<string, ComponentFactory>;
35
+ /** 1회용 컴포넌트 오버라이드 설정 */
36
+ componentOverrides?: {
37
+ byNodeId?: Record<string, ComponentFactory>;
38
+ byNodeType?: Record<string, ComponentFactory>;
39
+ };
40
+ /** Layout change callback */
41
+ onLayoutChange?: (document: SduiLayoutDocument) => void;
42
+ /** Error callback */
43
+ onError?: (error: Error) => void;
44
+ }
45
+ /**
46
+ * SduiLayoutRenderer 내부 컴포넌트
47
+ *
48
+ * useRenderNode hook을 사용하여 renderNode 함수를 생성하고,
49
+ * 하위 컴포넌트에 주입합니다.
50
+ * 각 컴포넌트는 이 함수를 통해 자식을 렌더링합니다.
51
+ */
52
+ declare const SduiLayoutRendererInner: ({ id, componentMap: customComponentMap, }: {
53
+ id: string;
54
+ componentMap?: Record<string, ComponentFactory>;
55
+ }) => React.ReactNode;
56
+ /**
57
+ * SduiLayoutRenderer
58
+ *
59
+ * SDUI Layout Document를 렌더링하는 최상위 컴포넌트입니다.
60
+ */
61
+ export declare const SduiLayoutRenderer: React.FC<SduiLayoutRendererProps>;
62
+ export { SduiLayoutRendererInner };
@@ -0,0 +1,6 @@
1
+ /**
2
+ * Server-Driven UI - React Components
3
+ *
4
+ * React components exports
5
+ */
6
+ export * from "./SduiLayoutRenderer";
@@ -0,0 +1,37 @@
1
+ /**
2
+ * SDUI Layout Context
3
+ *
4
+ * Context API를 사용하여 SduiLayoutStore를 제공합니다.
5
+ */
6
+ import React from 'react';
7
+ import type { SduiLayoutStore } from '../../store';
8
+ /**
9
+ * SduiLayoutContext 타입
10
+ */
11
+ interface SduiLayoutContextValue {
12
+ /** Store 인스턴스 */
13
+ store: SduiLayoutStore;
14
+ }
15
+ /**
16
+ * SduiLayoutProvider Props
17
+ */
18
+ interface SduiLayoutProviderProps {
19
+ /** Store 인스턴스 */
20
+ store: SduiLayoutStore;
21
+ /** 자식 컴포넌트 */
22
+ children: React.ReactNode;
23
+ }
24
+ /**
25
+ * SduiLayoutProvider
26
+ *
27
+ * Context를 통해 SduiLayoutStore를 제공합니다.
28
+ */
29
+ export declare const SduiLayoutProvider: React.FC<SduiLayoutProviderProps>;
30
+ /**
31
+ * useSduiLayoutContext
32
+ *
33
+ * Context에서 store를 가져옵니다.
34
+ * Provider 외부에서 사용 시 에러를 throw합니다.
35
+ */
36
+ export declare const useSduiLayoutContext: () => SduiLayoutContextValue;
37
+ export {};
@@ -0,0 +1,6 @@
1
+ /**
2
+ * Server-Driven UI - React Context
3
+ *
4
+ * Context API 및 Provider export
5
+ */
6
+ export * from './SduiLayoutContext';
@@ -0,0 +1,8 @@
1
+ /**
2
+ * Server-Driven UI - React Hooks
3
+ *
4
+ * React hooks for accessing store state and actions
5
+ */
6
+ export * from './useRenderNode';
7
+ export * from './useSduiLayoutAction';
8
+ export * from './useSduiNodeSubscription';
@@ -0,0 +1,10 @@
1
+ import type { ComponentFactory, RenderNodeFn } from '../../components/types';
2
+ /**
3
+ * renderNode 함수를 생성하는 hook
4
+ *
5
+ * nodes는 React 상태로 관리되므로 변경 시 자동으로 리렌더링됩니다.
6
+ *
7
+ * @param componentMap - 기본 컴포넌트 맵 (선택적)
8
+ * @returns 자식 노드를 렌더링하는 함수
9
+ */
10
+ export declare const useRenderNode: (componentMap?: Record<string, ComponentFactory>) => RenderNodeFn;
@@ -0,0 +1,15 @@
1
+ /**
2
+ * useSduiLayoutAction
3
+ *
4
+ * Store 인스턴스를 반환하여 액션을 호출할 수 있게 합니다.
5
+ *
6
+ * @returns Store 인스턴스
7
+ *
8
+ * @example
9
+ * ```tsx
10
+ * const store = useSduiLayoutAction();
11
+ * store.updateNodeState(nodeId, newState);
12
+ * ```
13
+ */
14
+ import type { SduiLayoutStore } from '../../store';
15
+ export declare const useSduiLayoutAction: () => SduiLayoutStore;
@@ -0,0 +1,45 @@
1
+ import type { z, ZodSchema } from 'zod';
2
+ import type { SduiLayoutNode } from '../../schema';
3
+ /**
4
+ * useSduiNodeSubscription 파라미터 타입
5
+ */
6
+ export interface UseSduiNodeSubscriptionParams<TSchema extends ZodSchema<Record<string, unknown>> = ZodSchema<Record<string, unknown>>> {
7
+ /** 구독할 노드 ID */
8
+ nodeId: string;
9
+ /** Zod 스키마 (선택적). state를 검증하고, 실패 시 에러를 throw합니다. 성공 시 state는 스키마에서 추론된 타입으로 보장됩니다. */
10
+ schema?: TSchema;
11
+ }
12
+ /**
13
+ * 특정 노드 ID를 구독하고 변경 시 forceRender를 트리거합니다.
14
+ *
15
+ * - nodes, variables: version 구독으로 변경 감지
16
+ * - layoutStates: 노드별 구독으로 변경 감지
17
+ *
18
+ * @template TSchema - Zod 스키마 타입. 스키마에서 타입을 추론합니다.
19
+ * @param params - 구독 파라미터 객체
20
+ * - `nodeId`: 구독할 노드 ID
21
+ * - `schema`: Zod 스키마 (선택적). state를 검증하고, 실패 시 에러를 throw합니다. 성공 시 state는 스키마에서 추론된 타입으로 보장됩니다.
22
+ * @returns 노드 정보 객체
23
+ * - `node`: 노드 엔티티 (SduiLayoutNode | undefined)
24
+ * - `type`: 노드 타입 (string | undefined)
25
+ * - `state`: 레이아웃 상태 (스키마가 제공되면 z.infer<TSchema>, 아니면 Record<string, unknown>)
26
+ * - `childrenIds`: 자식 노드 ID 배열 (string[])
27
+ * - `attributes`: 노드 속성 (Record<string, unknown> | undefined)
28
+ * - `exists`: 노드 존재 여부 (boolean)
29
+ *
30
+ * @example
31
+ * ```tsx
32
+ * const { node, state } = useSduiNodeSubscription({
33
+ * nodeId: 'node-1',
34
+ * schema: baseLayoutStateSchema, // optional
35
+ * });
36
+ * ```
37
+ */
38
+ export declare function useSduiNodeSubscription<TSchema extends ZodSchema<Record<string, unknown>> = ZodSchema<Record<string, unknown>>>(params: UseSduiNodeSubscriptionParams<TSchema>): {
39
+ node: SduiLayoutNode | undefined;
40
+ type: string | undefined;
41
+ state: TSchema extends ZodSchema<any> ? z.infer<TSchema> : Record<string, unknown>;
42
+ childrenIds: string[];
43
+ attributes: Record<string, unknown> | undefined;
44
+ exists: boolean;
45
+ };
@@ -0,0 +1,8 @@
1
+ /**
2
+ * Server-Driven UI - React Integration
3
+ *
4
+ * React components, hooks, and context exports
5
+ */
6
+ export * from './components';
7
+ export * from './context';
8
+ export * from './hooks';
@@ -0,0 +1,44 @@
1
+ /**
2
+ * Server-Driven UI - 기본 스키마
3
+ *
4
+ * SDUI의 기본 노드와 문서 구조를 정의합니다.
5
+ */
6
+ /**
7
+ * SDUI 노드 기본 인터페이스
8
+ *
9
+ * 재귀적 구조를 가지며, 각 노드는 id, type, state, children을 가집니다.
10
+ */
11
+ export interface SduiNode {
12
+ /** 노드 고유 식별자 */
13
+ id: string;
14
+ /** 컴포넌트 타입 */
15
+ type: string;
16
+ /** 상태 (모든 설정값 및 UI 상태) */
17
+ state?: Record<string, unknown>;
18
+ /** 외형 스타일 속성 (순수 CSS 스타일만) */
19
+ attributes?: Record<string, unknown>;
20
+ /** 자식 노드 배열 (재귀 구조) */
21
+ children?: SduiNode[];
22
+ }
23
+ /**
24
+ * SDUI 문서 기본 인터페이스
25
+ *
26
+ * 서버에서 내려주는 전체 UI 구조를 담는 루트 문서입니다.
27
+ */
28
+ export interface SduiDocument {
29
+ /** 스키마 버전 */
30
+ version: string;
31
+ /** 문서 메타데이터 */
32
+ metadata?: {
33
+ id?: string;
34
+ name?: string;
35
+ description?: string;
36
+ createdAt?: string;
37
+ updatedAt?: string;
38
+ author?: string;
39
+ };
40
+ /** 루트 노드 */
41
+ root: SduiNode;
42
+ /** 전역 변수 */
43
+ variables?: Record<string, unknown>;
44
+ }
@@ -0,0 +1,16 @@
1
+ /**
2
+ * Server-Driven UI - Layout 전용 문서
3
+ *
4
+ * Layout 시스템을 위한 문서 타입 정의
5
+ */
6
+ import type { SduiDocument } from './base';
7
+ import type { SduiLayoutNode } from './node';
8
+ /**
9
+ * Layout 전용 문서
10
+ *
11
+ * SduiDocument를 상속받아 root를 SduiLayoutNode로 구체화합니다.
12
+ */
13
+ export interface SduiLayoutDocument extends SduiDocument {
14
+ /** 루트 노드 (Layout 전용 노드) */
15
+ root: SduiLayoutNode;
16
+ }
@@ -0,0 +1,8 @@
1
+ /**
2
+ * Server-Driven UI - Schema
3
+ *
4
+ * SDUI 스키마 타입들을 export합니다.
5
+ */
6
+ export type * from './base';
7
+ export type * from './node';
8
+ export type * from './document';
@@ -0,0 +1,19 @@
1
+ /**
2
+ * Server-Driven UI - Layout 전용 노드
3
+ *
4
+ * Layout 시스템을 위한 노드 타입 정의
5
+ */
6
+ import type { SduiNode } from './base';
7
+ /**
8
+ * Layout 전용 노드
9
+ *
10
+ * SduiNode를 상속받아 state를 LayoutState로 구체화합니다.
11
+ */
12
+ export interface SduiLayoutNode extends SduiNode {
13
+ /** 컴포넌트 타입 */
14
+ type: string;
15
+ /** 레이아웃 상태 */
16
+ state?: Record<string, unknown>;
17
+ /** 자식 노드 배열 (재귀 구조) */
18
+ children?: SduiLayoutNode[];
19
+ }
@@ -0,0 +1,192 @@
1
+ /**
2
+ * SDUI Layout Store
3
+ *
4
+ * ID 기반 구독 시스템을 사용하여 SDUI Layout 상태를 관리합니다.
5
+ * 데이터는 일반 변수로 관리하고, 변경 시 해당 노드만 notify하여
6
+ * 구독한 컴포넌트만 forceRender합니다.
7
+ *
8
+ * @description
9
+ * - 성능 최적화: cloneDeep 제거, 변경된 노드만 리렌더링
10
+ * - 구독 시스템: ID별 구독자 관리, 선택적 notify
11
+ */
12
+ import type { ComponentFactory } from '../components/types';
13
+ import type { SduiLayoutDocument } from '../schema';
14
+ import type { SduiLayoutStoreOptions, SduiLayoutStoreState } from './types';
15
+ /**
16
+ * SduiLayoutStore
17
+ *
18
+ * Facade Pattern을 사용하여 SDUI Layout 상태를 관리합니다.
19
+ * 여러 매니저 클래스를 조합하여 단일 인터페이스를 제공합니다.
20
+ *
21
+ * @description
22
+ * - SubscriptionManager: 구독 시스템 관리
23
+ * - LayoutStateRepository: 상태 저장소 관리
24
+ * - DocumentManager: 문서 캐싱 및 직렬화
25
+ * - VariablesManager: 전역 변수 관리
26
+ *
27
+ * 모든 데이터는 일반 변수로 관리하고, 구독 시스템을 통해 변경을 감지합니다.
28
+ */
29
+ export declare class SduiLayoutStore {
30
+ /** 구독 시스템 매니저 */
31
+ private _subscriptionManager;
32
+ /** 상태 저장소 */
33
+ private _repository;
34
+ /** 문서 관리자 */
35
+ private _documentManager;
36
+ /** 변수 관리자 */
37
+ private _variablesManager;
38
+ /** 컴포넌트 오버라이드 (일반 변수) - ID와 타입을 하나의 맵으로 관리 */
39
+ private _componentOverrides;
40
+ constructor(initialState?: Partial<SduiLayoutStoreState>, options?: SduiLayoutStoreOptions);
41
+ /**
42
+ * 특정 노드 ID를 구독합니다.
43
+ *
44
+ * @param nodeId - 구독할 노드 ID
45
+ * @param callback - 변경 시 호출될 콜백 (forceRender)
46
+ * @returns 구독 해제 함수
47
+ */
48
+ subscribeNode(nodeId: string, callback: () => void): () => void;
49
+ /**
50
+ * version을 구독합니다. (nodes, rootId, variables 변경 감지용)
51
+ *
52
+ * @param callback - 변경 시 호출될 콜백 (forceRender)
53
+ * @returns 구독 해제 함수
54
+ */
55
+ subscribeVersion(callback: () => void): () => void;
56
+ /**
57
+ * Store 상태를 반환합니다.
58
+ */
59
+ get state(): SduiLayoutStoreState;
60
+ /**
61
+ * 노드 엔티티를 반환합니다.
62
+ */
63
+ get nodes(): Record<string, import("../schema").SduiLayoutNode>;
64
+ /**
65
+ * 문서 메타데이터를 반환합니다.
66
+ *
67
+ * @throws {MetadataNotFoundError} 메타데이터가 없을 경우
68
+ */
69
+ get metadata(): SduiLayoutDocument['metadata'];
70
+ /**
71
+ * 컴포넌트 오버라이드 맵을 반환합니다.
72
+ */
73
+ getComponentOverrides(): Record<string, ComponentFactory>;
74
+ /**
75
+ * ID로 노드를 조회합니다.
76
+ *
77
+ * @param nodeId - 조회할 노드 ID
78
+ * @returns 노드
79
+ * @throws {NodeNotFoundError} 노드가 존재하지 않을 경우
80
+ */
81
+ getNodeById(nodeId: string): import("../schema").SduiLayoutNode;
82
+ /**
83
+ * ID로 노드 타입을 조회합니다.
84
+ *
85
+ * @param nodeId - 조회할 노드 ID
86
+ * @returns 노드 타입
87
+ * @throws {NodeNotFoundError} 노드가 존재하지 않을 경우
88
+ */
89
+ getNodeTypeById(nodeId: string): string;
90
+ /**
91
+ * ID로 자식 노드 ID 목록을 조회합니다.
92
+ *
93
+ * @param nodeId - 조회할 노드 ID
94
+ * @returns 자식 노드 ID 배열
95
+ * @throws {NodeNotFoundError} 노드가 존재하지 않을 경우
96
+ */
97
+ getChildrenIdsById(nodeId: string): string[];
98
+ /**
99
+ * ID로 레이아웃 상태를 조회합니다.
100
+ *
101
+ * @param nodeId - 조회할 노드 ID
102
+ * @returns 레이아웃 상태 (없으면 빈 객체 반환)
103
+ * @throws {NodeNotFoundError} 노드가 존재하지 않을 경우
104
+ */
105
+ getLayoutStateById(nodeId: string): Record<string, unknown>;
106
+ /**
107
+ * ID로 속성을 조회합니다.
108
+ *
109
+ * @param nodeId - 조회할 노드 ID
110
+ * @returns 속성 (없으면 빈 객체 반환)
111
+ * @throws {NodeNotFoundError} 노드가 존재하지 않을 경우
112
+ */
113
+ getAttributesById(nodeId: string): Record<string, unknown>;
114
+ /**
115
+ * 루트 노드 ID를 반환합니다.
116
+ *
117
+ * @returns 루트 노드 ID
118
+ * @throws {RootNotFoundError} 루트 노드 ID가 존재하지 않을 경우
119
+ */
120
+ getRootId(): string;
121
+ /**
122
+ * 레이아웃 문서를 업데이트하고 normalize합니다.
123
+ * 전체 문서가 변경되는 경우이므로 version을 증가시켜 전체 리렌더를 트리거합니다.
124
+ *
125
+ * @param document - 업데이트할 레이아웃 문서
126
+ */
127
+ updateLayout(document: SduiLayoutDocument): void;
128
+ /**
129
+ * 레이아웃 변경사항을 취소하고 원본으로 복원합니다.
130
+ *
131
+ * @param documentId - 복원할 문서 ID
132
+ */
133
+ cancelEdit(documentId?: string): void;
134
+ /**
135
+ * 특정 노드의 상태를 업데이트합니다.
136
+ *
137
+ * @param nodeId - 업데이트할 노드 ID
138
+ * @param state - 새로운 상태
139
+ * @throws {NodeNotFoundError} 노드가 존재하지 않을 경우
140
+ */
141
+ updateNodeState(nodeId: string, state: Partial<Record<string, unknown>>): void;
142
+ /**
143
+ * 특정 노드의 속성을 업데이트합니다.
144
+ *
145
+ * @param nodeId - 업데이트할 노드 ID
146
+ * @param attributes - 새로운 속성
147
+ * @throws {NodeNotFoundError} 노드가 존재하지 않을 경우
148
+ */
149
+ updateNodeAttributes(nodeId: string, attributes: Partial<Record<string, unknown>>): void;
150
+ /**
151
+ * 전역 변수를 업데이트합니다.
152
+ * 깊은 복사로 새 객체를 생성하여 React 리렌더를 트리거합니다.
153
+ *
154
+ * @param variables - 새로운 전역 변수 객체
155
+ */
156
+ updateVariables(variables: Record<string, unknown>): void;
157
+ /**
158
+ * 개별 전역 변수를 업데이트합니다.
159
+ * 깊은 복사로 새 객체를 생성하여 version을 증가시킵니다.
160
+ *
161
+ * @param key - 변수 키
162
+ * @param value - 변수 값
163
+ */
164
+ updateVariable(key: string, value: unknown): void;
165
+ /**
166
+ * 전역 변수를 삭제합니다.
167
+ *
168
+ * @param key - 삭제할 변수 키
169
+ */
170
+ deleteVariable(key: string): void;
171
+ /**
172
+ * 선택된 노드 ID를 설정합니다.
173
+ *
174
+ * @param nodeId - 선택할 노드 ID
175
+ */
176
+ setSelectedNodeId(nodeId?: string): void;
177
+ /**
178
+ * 현재 상태를 문서로 변환합니다.
179
+ * 저장/내보내기 시에만 사용합니다.
180
+ *
181
+ * @returns 복원된 문서 또는 null
182
+ */
183
+ getDocument(): SduiLayoutDocument | null;
184
+ /**
185
+ * 캐시를 초기화합니다.
186
+ */
187
+ clearCache(): void;
188
+ /**
189
+ * 상태를 초기화합니다.
190
+ */
191
+ reset(): void;
192
+ }
@@ -0,0 +1,37 @@
1
+ /**
2
+ * SDUI Layout Store Errors
3
+ *
4
+ * Custom error classes for SDUI Layout Store operations
5
+ */
6
+ /**
7
+ * NodeNotFoundError
8
+ *
9
+ * Thrown when attempting to access or update a node that does not exist in the store
10
+ */
11
+ export declare class NodeNotFoundError extends Error {
12
+ constructor(nodeId: string);
13
+ }
14
+ /**
15
+ * RootNotFoundError
16
+ *
17
+ * Thrown when attempting to access root node ID that does not exist
18
+ */
19
+ export declare class RootNotFoundError extends Error {
20
+ constructor();
21
+ }
22
+ /**
23
+ * MetadataNotFoundError
24
+ *
25
+ * Thrown when attempting to access metadata that does not exist
26
+ */
27
+ export declare class MetadataNotFoundError extends Error {
28
+ constructor();
29
+ }
30
+ /**
31
+ * AttributesNotFoundError
32
+ *
33
+ * Thrown when attempting to access attributes that does not exist
34
+ */
35
+ export declare class AttributesNotFoundError extends Error {
36
+ constructor(nodeId: string);
37
+ }
@@ -0,0 +1,8 @@
1
+ /**
2
+ * Server-Driven UI - Store
3
+ *
4
+ * Store 클래스 및 타입 export
5
+ */
6
+ export * from './errors';
7
+ export * from './SduiLayoutStore';
8
+ export * from './types';
@@ -0,0 +1,67 @@
1
+ /**
2
+ * DocumentManager
3
+ *
4
+ * 문서 캐싱, 복원, 직렬화를 관리합니다.
5
+ */
6
+ import type { SduiLayoutDocument } from '../../schema';
7
+ import type { LayoutStateRepository } from './LayoutStateRepository';
8
+ /**
9
+ * DocumentManager
10
+ *
11
+ * 문서 캐싱, 복원, 직렬화를 관리합니다.
12
+ */
13
+ export declare class DocumentManager {
14
+ /** 문서 메타데이터 */
15
+ private _metadata?;
16
+ /** 캐시된 문서 */
17
+ private _cached;
18
+ /** 원본 문서 캐시 (편집 취소용) */
19
+ private _originalCached;
20
+ /**
21
+ * 문서를 캐시합니다.
22
+ *
23
+ * @param document - 캐시할 문서
24
+ */
25
+ cacheDocument(document: SduiLayoutDocument): void;
26
+ /**
27
+ * 메타데이터를 설정합니다.
28
+ *
29
+ * @param metadata - 메타데이터
30
+ */
31
+ setMetadata(metadata?: SduiLayoutDocument['metadata']): void;
32
+ /**
33
+ * 메타데이터를 반환합니다.
34
+ *
35
+ * @returns 메타데이터 또는 undefined
36
+ */
37
+ getMetadata(): SduiLayoutDocument['metadata'] | undefined;
38
+ /**
39
+ * 원본 문서를 반환합니다.
40
+ *
41
+ * @param documentId - 문서 ID
42
+ * @returns 원본 문서 또는 undefined
43
+ */
44
+ getOriginalDocument(documentId: string): SduiLayoutDocument | undefined;
45
+ /**
46
+ * 문서 ID를 가져옵니다.
47
+ *
48
+ * @param rootId - 루트 노드 ID (fallback)
49
+ * @returns 문서 ID 또는 undefined
50
+ */
51
+ getDocumentId(rootId?: string): string | undefined;
52
+ /**
53
+ * 현재 상태를 문서로 변환합니다.
54
+ *
55
+ * @param repository - 상태 저장소
56
+ * @returns 복원된 문서 또는 null
57
+ */
58
+ getDocument(repository: LayoutStateRepository): SduiLayoutDocument | null;
59
+ /**
60
+ * 캐시를 초기화합니다.
61
+ */
62
+ clearCache(): void;
63
+ /**
64
+ * 상태를 초기화합니다.
65
+ */
66
+ reset(): void;
67
+ }