@kohryan/moodui 0.0.1
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/index.d.mts +162 -0
- package/dist/index.d.ts +162 -0
- package/dist/index.js +581 -0
- package/dist/index.mjs +547 -0
- package/package.json +33 -0
package/dist/index.d.mts
ADDED
|
@@ -0,0 +1,162 @@
|
|
|
1
|
+
type MoodUISpecVersion = 1;
|
|
2
|
+
type MoodUISpec = {
|
|
3
|
+
version: MoodUISpecVersion;
|
|
4
|
+
root: MoodUINode;
|
|
5
|
+
theme?: MoodUITheme;
|
|
6
|
+
meta?: Record<string, unknown>;
|
|
7
|
+
};
|
|
8
|
+
type MoodUITheme = {
|
|
9
|
+
colors?: Record<string, string>;
|
|
10
|
+
space?: Record<string, number | string>;
|
|
11
|
+
radii?: Record<string, number | string>;
|
|
12
|
+
fontSizes?: Record<string, number | string>;
|
|
13
|
+
fonts?: Record<string, string>;
|
|
14
|
+
};
|
|
15
|
+
type MoodUICommonProps = {
|
|
16
|
+
id?: string;
|
|
17
|
+
testId?: string;
|
|
18
|
+
className?: string;
|
|
19
|
+
style?: Record<string, unknown>;
|
|
20
|
+
padding?: MoodUISpace;
|
|
21
|
+
margin?: MoodUISpace;
|
|
22
|
+
background?: MoodUIColor;
|
|
23
|
+
borderRadius?: MoodUIRadius;
|
|
24
|
+
width?: number | string;
|
|
25
|
+
height?: number | string;
|
|
26
|
+
};
|
|
27
|
+
type MoodUISpace = number | string | {
|
|
28
|
+
top?: number | string;
|
|
29
|
+
right?: number | string;
|
|
30
|
+
bottom?: number | string;
|
|
31
|
+
left?: number | string;
|
|
32
|
+
x?: number | string;
|
|
33
|
+
y?: number | string;
|
|
34
|
+
all?: number | string;
|
|
35
|
+
};
|
|
36
|
+
type MoodUIColor = string;
|
|
37
|
+
type MoodUIRadius = number | string;
|
|
38
|
+
type MoodUINode = MoodUIBoxNode | MoodUITextNode | MoodUIButtonNode | MoodUIInputNode | MoodUIImageNode | MoodUISpacerNode;
|
|
39
|
+
type MoodUIBoxNode = {
|
|
40
|
+
type: "box";
|
|
41
|
+
props?: MoodUICommonProps & {
|
|
42
|
+
direction?: "row" | "column";
|
|
43
|
+
gap?: number | string;
|
|
44
|
+
align?: "stretch" | "flex-start" | "center" | "flex-end" | "baseline";
|
|
45
|
+
justify?: "flex-start" | "center" | "flex-end" | "space-between" | "space-around" | "space-evenly";
|
|
46
|
+
wrap?: "nowrap" | "wrap";
|
|
47
|
+
};
|
|
48
|
+
children?: MoodUINode[];
|
|
49
|
+
};
|
|
50
|
+
type MoodUITextNode = {
|
|
51
|
+
type: "text";
|
|
52
|
+
props?: MoodUICommonProps & {
|
|
53
|
+
as?: "p" | "span" | "h1" | "h2" | "h3" | "h4" | "h5" | "h6";
|
|
54
|
+
value: string;
|
|
55
|
+
color?: MoodUIColor;
|
|
56
|
+
fontSize?: number | string;
|
|
57
|
+
fontWeight?: number | string;
|
|
58
|
+
textAlign?: "left" | "center" | "right" | "justify";
|
|
59
|
+
};
|
|
60
|
+
};
|
|
61
|
+
type MoodUIButtonNode = {
|
|
62
|
+
type: "button";
|
|
63
|
+
props?: MoodUICommonProps & {
|
|
64
|
+
label: string;
|
|
65
|
+
variant?: "primary" | "secondary" | "ghost";
|
|
66
|
+
actionId?: string;
|
|
67
|
+
disabled?: boolean;
|
|
68
|
+
};
|
|
69
|
+
};
|
|
70
|
+
type MoodUIInputNode = {
|
|
71
|
+
type: "input";
|
|
72
|
+
props?: MoodUICommonProps & {
|
|
73
|
+
name?: string;
|
|
74
|
+
placeholder?: string;
|
|
75
|
+
defaultValue?: string;
|
|
76
|
+
};
|
|
77
|
+
};
|
|
78
|
+
type MoodUIImageNode = {
|
|
79
|
+
type: "image";
|
|
80
|
+
props?: MoodUICommonProps & {
|
|
81
|
+
src: string;
|
|
82
|
+
alt?: string;
|
|
83
|
+
fit?: "cover" | "contain" | "fill" | "none" | "scale-down";
|
|
84
|
+
};
|
|
85
|
+
};
|
|
86
|
+
type MoodUISpacerNode = {
|
|
87
|
+
type: "spacer";
|
|
88
|
+
props?: {
|
|
89
|
+
size?: number | string;
|
|
90
|
+
};
|
|
91
|
+
};
|
|
92
|
+
|
|
93
|
+
type Ok<T> = {
|
|
94
|
+
ok: true;
|
|
95
|
+
value: T;
|
|
96
|
+
};
|
|
97
|
+
type Err = {
|
|
98
|
+
ok: false;
|
|
99
|
+
errors: string[];
|
|
100
|
+
};
|
|
101
|
+
type ValidationResult<T> = Ok<T> | Err;
|
|
102
|
+
declare function validateMoodUISpec(input: unknown): ValidationResult<MoodUISpec>;
|
|
103
|
+
declare function assertMoodUISpec(input: unknown): MoodUISpec;
|
|
104
|
+
type _InternalNodeTypes = MoodUITextNode | MoodUIButtonNode | MoodUIInputNode | MoodUIImageNode | MoodUISpacerNode;
|
|
105
|
+
|
|
106
|
+
type RenderReactOptions = {
|
|
107
|
+
componentName?: string;
|
|
108
|
+
};
|
|
109
|
+
declare function renderReact(specInput: unknown, options?: RenderReactOptions): string;
|
|
110
|
+
declare function renderReactJSX(node: MoodUINode): string;
|
|
111
|
+
type _RenderReactExports = {
|
|
112
|
+
renderReact: typeof renderReact;
|
|
113
|
+
renderReactJSX: typeof renderReactJSX;
|
|
114
|
+
};
|
|
115
|
+
|
|
116
|
+
type LLMMessage = {
|
|
117
|
+
role: "system" | "user" | "assistant";
|
|
118
|
+
content: string;
|
|
119
|
+
};
|
|
120
|
+
type LLMChatRequest = {
|
|
121
|
+
model: string;
|
|
122
|
+
messages: LLMMessage[];
|
|
123
|
+
temperature?: number;
|
|
124
|
+
};
|
|
125
|
+
type LLMChatClient = {
|
|
126
|
+
chat(req: LLMChatRequest): Promise<string>;
|
|
127
|
+
};
|
|
128
|
+
|
|
129
|
+
type OllamaClientOptions = {
|
|
130
|
+
baseUrl?: string;
|
|
131
|
+
fetchFn?: typeof fetch;
|
|
132
|
+
};
|
|
133
|
+
declare function createOllamaClient(options?: OllamaClientOptions): LLMChatClient;
|
|
134
|
+
|
|
135
|
+
type OpenAICompatibleClientOptions = {
|
|
136
|
+
baseUrl: string;
|
|
137
|
+
apiKey: string;
|
|
138
|
+
fetchFn?: typeof fetch;
|
|
139
|
+
defaultHeaders?: Record<string, string>;
|
|
140
|
+
};
|
|
141
|
+
declare function createOpenAICompatibleClient(options: OpenAICompatibleClientOptions): LLMChatClient;
|
|
142
|
+
|
|
143
|
+
type GeminiClientOptions = {
|
|
144
|
+
apiKey: string;
|
|
145
|
+
baseUrl?: string;
|
|
146
|
+
fetchFn?: typeof fetch;
|
|
147
|
+
};
|
|
148
|
+
declare function createGeminiClient(options: GeminiClientOptions): LLMChatClient;
|
|
149
|
+
|
|
150
|
+
type GenerateSpecOptions = {
|
|
151
|
+
model: string;
|
|
152
|
+
prompt: string;
|
|
153
|
+
temperature?: number;
|
|
154
|
+
maxAttempts?: number;
|
|
155
|
+
};
|
|
156
|
+
type GenerateSpecResult = {
|
|
157
|
+
spec: MoodUISpec;
|
|
158
|
+
raw: string;
|
|
159
|
+
};
|
|
160
|
+
declare function generateMoodUISpec(llm: LLMChatClient, options: GenerateSpecOptions): Promise<GenerateSpecResult>;
|
|
161
|
+
|
|
162
|
+
export { type GeminiClientOptions, type GenerateSpecOptions, type GenerateSpecResult, type LLMChatClient, type LLMChatRequest, type LLMMessage, type MoodUIBoxNode, type MoodUIButtonNode, type MoodUIColor, type MoodUICommonProps, type MoodUIImageNode, type MoodUIInputNode, type MoodUINode, type MoodUIRadius, type MoodUISpace, type MoodUISpacerNode, type MoodUISpec, type MoodUISpecVersion, type MoodUITextNode, type MoodUITheme, type OllamaClientOptions, type OpenAICompatibleClientOptions, type RenderReactOptions, type ValidationResult, type _InternalNodeTypes, type _RenderReactExports, assertMoodUISpec, createGeminiClient, createOllamaClient, createOpenAICompatibleClient, generateMoodUISpec, renderReact, renderReactJSX, validateMoodUISpec };
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,162 @@
|
|
|
1
|
+
type MoodUISpecVersion = 1;
|
|
2
|
+
type MoodUISpec = {
|
|
3
|
+
version: MoodUISpecVersion;
|
|
4
|
+
root: MoodUINode;
|
|
5
|
+
theme?: MoodUITheme;
|
|
6
|
+
meta?: Record<string, unknown>;
|
|
7
|
+
};
|
|
8
|
+
type MoodUITheme = {
|
|
9
|
+
colors?: Record<string, string>;
|
|
10
|
+
space?: Record<string, number | string>;
|
|
11
|
+
radii?: Record<string, number | string>;
|
|
12
|
+
fontSizes?: Record<string, number | string>;
|
|
13
|
+
fonts?: Record<string, string>;
|
|
14
|
+
};
|
|
15
|
+
type MoodUICommonProps = {
|
|
16
|
+
id?: string;
|
|
17
|
+
testId?: string;
|
|
18
|
+
className?: string;
|
|
19
|
+
style?: Record<string, unknown>;
|
|
20
|
+
padding?: MoodUISpace;
|
|
21
|
+
margin?: MoodUISpace;
|
|
22
|
+
background?: MoodUIColor;
|
|
23
|
+
borderRadius?: MoodUIRadius;
|
|
24
|
+
width?: number | string;
|
|
25
|
+
height?: number | string;
|
|
26
|
+
};
|
|
27
|
+
type MoodUISpace = number | string | {
|
|
28
|
+
top?: number | string;
|
|
29
|
+
right?: number | string;
|
|
30
|
+
bottom?: number | string;
|
|
31
|
+
left?: number | string;
|
|
32
|
+
x?: number | string;
|
|
33
|
+
y?: number | string;
|
|
34
|
+
all?: number | string;
|
|
35
|
+
};
|
|
36
|
+
type MoodUIColor = string;
|
|
37
|
+
type MoodUIRadius = number | string;
|
|
38
|
+
type MoodUINode = MoodUIBoxNode | MoodUITextNode | MoodUIButtonNode | MoodUIInputNode | MoodUIImageNode | MoodUISpacerNode;
|
|
39
|
+
type MoodUIBoxNode = {
|
|
40
|
+
type: "box";
|
|
41
|
+
props?: MoodUICommonProps & {
|
|
42
|
+
direction?: "row" | "column";
|
|
43
|
+
gap?: number | string;
|
|
44
|
+
align?: "stretch" | "flex-start" | "center" | "flex-end" | "baseline";
|
|
45
|
+
justify?: "flex-start" | "center" | "flex-end" | "space-between" | "space-around" | "space-evenly";
|
|
46
|
+
wrap?: "nowrap" | "wrap";
|
|
47
|
+
};
|
|
48
|
+
children?: MoodUINode[];
|
|
49
|
+
};
|
|
50
|
+
type MoodUITextNode = {
|
|
51
|
+
type: "text";
|
|
52
|
+
props?: MoodUICommonProps & {
|
|
53
|
+
as?: "p" | "span" | "h1" | "h2" | "h3" | "h4" | "h5" | "h6";
|
|
54
|
+
value: string;
|
|
55
|
+
color?: MoodUIColor;
|
|
56
|
+
fontSize?: number | string;
|
|
57
|
+
fontWeight?: number | string;
|
|
58
|
+
textAlign?: "left" | "center" | "right" | "justify";
|
|
59
|
+
};
|
|
60
|
+
};
|
|
61
|
+
type MoodUIButtonNode = {
|
|
62
|
+
type: "button";
|
|
63
|
+
props?: MoodUICommonProps & {
|
|
64
|
+
label: string;
|
|
65
|
+
variant?: "primary" | "secondary" | "ghost";
|
|
66
|
+
actionId?: string;
|
|
67
|
+
disabled?: boolean;
|
|
68
|
+
};
|
|
69
|
+
};
|
|
70
|
+
type MoodUIInputNode = {
|
|
71
|
+
type: "input";
|
|
72
|
+
props?: MoodUICommonProps & {
|
|
73
|
+
name?: string;
|
|
74
|
+
placeholder?: string;
|
|
75
|
+
defaultValue?: string;
|
|
76
|
+
};
|
|
77
|
+
};
|
|
78
|
+
type MoodUIImageNode = {
|
|
79
|
+
type: "image";
|
|
80
|
+
props?: MoodUICommonProps & {
|
|
81
|
+
src: string;
|
|
82
|
+
alt?: string;
|
|
83
|
+
fit?: "cover" | "contain" | "fill" | "none" | "scale-down";
|
|
84
|
+
};
|
|
85
|
+
};
|
|
86
|
+
type MoodUISpacerNode = {
|
|
87
|
+
type: "spacer";
|
|
88
|
+
props?: {
|
|
89
|
+
size?: number | string;
|
|
90
|
+
};
|
|
91
|
+
};
|
|
92
|
+
|
|
93
|
+
type Ok<T> = {
|
|
94
|
+
ok: true;
|
|
95
|
+
value: T;
|
|
96
|
+
};
|
|
97
|
+
type Err = {
|
|
98
|
+
ok: false;
|
|
99
|
+
errors: string[];
|
|
100
|
+
};
|
|
101
|
+
type ValidationResult<T> = Ok<T> | Err;
|
|
102
|
+
declare function validateMoodUISpec(input: unknown): ValidationResult<MoodUISpec>;
|
|
103
|
+
declare function assertMoodUISpec(input: unknown): MoodUISpec;
|
|
104
|
+
type _InternalNodeTypes = MoodUITextNode | MoodUIButtonNode | MoodUIInputNode | MoodUIImageNode | MoodUISpacerNode;
|
|
105
|
+
|
|
106
|
+
type RenderReactOptions = {
|
|
107
|
+
componentName?: string;
|
|
108
|
+
};
|
|
109
|
+
declare function renderReact(specInput: unknown, options?: RenderReactOptions): string;
|
|
110
|
+
declare function renderReactJSX(node: MoodUINode): string;
|
|
111
|
+
type _RenderReactExports = {
|
|
112
|
+
renderReact: typeof renderReact;
|
|
113
|
+
renderReactJSX: typeof renderReactJSX;
|
|
114
|
+
};
|
|
115
|
+
|
|
116
|
+
type LLMMessage = {
|
|
117
|
+
role: "system" | "user" | "assistant";
|
|
118
|
+
content: string;
|
|
119
|
+
};
|
|
120
|
+
type LLMChatRequest = {
|
|
121
|
+
model: string;
|
|
122
|
+
messages: LLMMessage[];
|
|
123
|
+
temperature?: number;
|
|
124
|
+
};
|
|
125
|
+
type LLMChatClient = {
|
|
126
|
+
chat(req: LLMChatRequest): Promise<string>;
|
|
127
|
+
};
|
|
128
|
+
|
|
129
|
+
type OllamaClientOptions = {
|
|
130
|
+
baseUrl?: string;
|
|
131
|
+
fetchFn?: typeof fetch;
|
|
132
|
+
};
|
|
133
|
+
declare function createOllamaClient(options?: OllamaClientOptions): LLMChatClient;
|
|
134
|
+
|
|
135
|
+
type OpenAICompatibleClientOptions = {
|
|
136
|
+
baseUrl: string;
|
|
137
|
+
apiKey: string;
|
|
138
|
+
fetchFn?: typeof fetch;
|
|
139
|
+
defaultHeaders?: Record<string, string>;
|
|
140
|
+
};
|
|
141
|
+
declare function createOpenAICompatibleClient(options: OpenAICompatibleClientOptions): LLMChatClient;
|
|
142
|
+
|
|
143
|
+
type GeminiClientOptions = {
|
|
144
|
+
apiKey: string;
|
|
145
|
+
baseUrl?: string;
|
|
146
|
+
fetchFn?: typeof fetch;
|
|
147
|
+
};
|
|
148
|
+
declare function createGeminiClient(options: GeminiClientOptions): LLMChatClient;
|
|
149
|
+
|
|
150
|
+
type GenerateSpecOptions = {
|
|
151
|
+
model: string;
|
|
152
|
+
prompt: string;
|
|
153
|
+
temperature?: number;
|
|
154
|
+
maxAttempts?: number;
|
|
155
|
+
};
|
|
156
|
+
type GenerateSpecResult = {
|
|
157
|
+
spec: MoodUISpec;
|
|
158
|
+
raw: string;
|
|
159
|
+
};
|
|
160
|
+
declare function generateMoodUISpec(llm: LLMChatClient, options: GenerateSpecOptions): Promise<GenerateSpecResult>;
|
|
161
|
+
|
|
162
|
+
export { type GeminiClientOptions, type GenerateSpecOptions, type GenerateSpecResult, type LLMChatClient, type LLMChatRequest, type LLMMessage, type MoodUIBoxNode, type MoodUIButtonNode, type MoodUIColor, type MoodUICommonProps, type MoodUIImageNode, type MoodUIInputNode, type MoodUINode, type MoodUIRadius, type MoodUISpace, type MoodUISpacerNode, type MoodUISpec, type MoodUISpecVersion, type MoodUITextNode, type MoodUITheme, type OllamaClientOptions, type OpenAICompatibleClientOptions, type RenderReactOptions, type ValidationResult, type _InternalNodeTypes, type _RenderReactExports, assertMoodUISpec, createGeminiClient, createOllamaClient, createOpenAICompatibleClient, generateMoodUISpec, renderReact, renderReactJSX, validateMoodUISpec };
|